Methods Summary |
---|
public native boolean | advance()Advance to the next sample. Returns false if no more sample data
is available (end of stream).
|
protected void | finalize()
native_finalize();
|
public native long | getCachedDuration()Returns an estimate of how much data is presently cached in memory
expressed in microseconds. Returns -1 if that information is unavailable
or not applicable (no cache).
|
private native java.util.Map | getFileFormatNative()
|
public java.util.Map | getPsshInfo()Get the PSSH info if present.
Map<UUID, byte[]> psshMap = null;
Map<String, Object> formatMap = getFileFormatNative();
if (formatMap != null && formatMap.containsKey("pssh")) {
ByteBuffer rawpssh = (ByteBuffer) formatMap.get("pssh");
rawpssh.order(ByteOrder.nativeOrder());
rawpssh.rewind();
formatMap.remove("pssh");
// parse the flat pssh bytebuffer into something more manageable
psshMap = new HashMap<UUID, byte[]>();
while (rawpssh.remaining() > 0) {
rawpssh.order(ByteOrder.BIG_ENDIAN);
long msb = rawpssh.getLong();
long lsb = rawpssh.getLong();
UUID uuid = new UUID(msb, lsb);
rawpssh.order(ByteOrder.nativeOrder());
int datalen = rawpssh.getInt();
byte [] psshdata = new byte[datalen];
rawpssh.get(psshdata);
psshMap.put(uuid, psshdata);
}
}
return psshMap;
|
public native boolean | getSampleCryptoInfo(MediaCodec.CryptoInfo info)If the sample flags indicate that the current sample is at least
partially encrypted, this call returns relevant information about
the structure of the sample data required for decryption.
|
public native int | getSampleFlags()Returns the current sample's flags.
|
public native long | getSampleTime()Returns the current sample's presentation time in microseconds.
or -1 if no more samples are available.
|
public native int | getSampleTrackIndex()Returns the track index the current sample originates from (or -1
if no more samples are available)
|
public final native int | getTrackCount()Count the number of tracks found in the data source.
|
public android.media.MediaFormat | getTrackFormat(int index)Get the track format at the specified index.
More detail on the representation can be found at {@link android.media.MediaCodec}
return new MediaFormat(getTrackFormatNative(index));
|
private native java.util.Map | getTrackFormatNative(int index)
|
public native boolean | hasCacheReachedEndOfStream()Returns true iff we are caching data and the cache has reached the
end of the data stream (for now, a future seek may of course restart
the fetching of data).
This API only returns a meaningful result if {@link #getCachedDuration}
indicates the presence of a cache, i.e. does NOT return -1.
|
private final native void | nativeSetDataSource(android.os.IBinder httpServiceBinder, java.lang.String path, java.lang.String[] keys, java.lang.String[] values)
|
private final native void | native_finalize()
|
private static final native void | native_init()
|
private final native void | native_setup()
|
public native int | readSampleData(java.nio.ByteBuffer byteBuf, int offset)Retrieve the current encoded sample and store it in the byte buffer
starting at the given offset.
Note:As of API 21, on success the position and limit of
{@code byteBuf} is updated to point to the data just read.
|
public final native void | release()Make sure you call this when you're done to free up any resources
instead of relying on the garbage collector to do this for you at
some point in the future.
|
public native void | seekTo(long timeUs, int mode)All selected tracks seek near the requested time according to the
specified mode.
|
public native void | selectTrack(int index)Subsequent calls to {@link #readSampleData}, {@link #getSampleTrackIndex} and
{@link #getSampleTime} only retrieve information for the subset of tracks
selected.
Selecting the same track multiple times has no effect, the track is
only selected once.
|
public final native void | setDataSource(DataSource source)Sets the DataSource object to be used as the data source for this extractor
{@hide}
|
public final void | setDataSource(android.content.Context context, android.net.Uri uri, java.util.Map headers)Sets the data source as a content Uri.
String scheme = uri.getScheme();
if(scheme == null || scheme.equals("file")) {
setDataSource(uri.getPath());
return;
}
AssetFileDescriptor fd = null;
try {
ContentResolver resolver = context.getContentResolver();
fd = resolver.openAssetFileDescriptor(uri, "r");
if (fd == null) {
return;
}
// Note: using getDeclaredLength so that our behavior is the same
// as previous versions when the content provider is returning
// a full file.
if (fd.getDeclaredLength() < 0) {
setDataSource(fd.getFileDescriptor());
} else {
setDataSource(
fd.getFileDescriptor(),
fd.getStartOffset(),
fd.getDeclaredLength());
}
return;
} catch (SecurityException ex) {
} catch (IOException ex) {
} finally {
if (fd != null) {
fd.close();
}
}
setDataSource(uri.toString(), headers);
|
public final void | setDataSource(java.lang.String path, java.util.Map headers)Sets the data source (file-path or http URL) to use.
String[] keys = null;
String[] values = null;
if (headers != null) {
keys = new String[headers.size()];
values = new String[headers.size()];
int i = 0;
for (Map.Entry<String, String> entry: headers.entrySet()) {
keys[i] = entry.getKey();
values[i] = entry.getValue();
++i;
}
}
nativeSetDataSource(
MediaHTTPService.createHttpServiceBinderIfNecessary(path),
path,
keys,
values);
|
public final void | setDataSource(java.lang.String path)Sets the data source (file-path or http URL) to use.
nativeSetDataSource(
MediaHTTPService.createHttpServiceBinderIfNecessary(path),
path,
null,
null);
|
public final void | setDataSource(java.io.FileDescriptor fd)Sets the data source (FileDescriptor) to use. It is the caller's responsibility
to close the file descriptor. It is safe to do so as soon as this call returns.
setDataSource(fd, 0, 0x7ffffffffffffffL);
|
public final native void | setDataSource(java.io.FileDescriptor fd, long offset, long length)Sets the data source (FileDescriptor) to use. The FileDescriptor must be
seekable (N.B. a LocalSocket is not seekable). It is the caller's responsibility
to close the file descriptor. It is safe to do so as soon as this call returns.
|
public native void | unselectTrack(int index)Subsequent calls to {@link #readSampleData}, {@link #getSampleTrackIndex} and
{@link #getSampleTime} only retrieve information for the subset of tracks
selected.
|