Package org.robolectric.shadows
Class ShadowMediaExtractor
- java.lang.Object
-
- org.robolectric.shadows.ShadowMediaExtractor
-
@Implements(android.media.MediaExtractor.class) public class ShadowMediaExtractor extends Object
A shadow for the MediaExtractor class.Returns data previously injected by
addTrack(DataSource, MediaFormat, byte[])
.Note several limitations, due to not using actual media codecs for decoding:
- Only one track may be selected at a time; multi-track selection is not supported.
advance()
will advance by the size of the last read (i.e. the return value of the last call toreadSampleData(ByteBuffer, int)
).MediaExtractor.getSampleTime()
andMediaExtractor.getSampleSize()
are unimplemented.MediaExtractor#seekTo()
is unimplemented.
-
-
Constructor Summary
Constructors Constructor Description ShadowMediaExtractor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addTrack(DataSource dataSource, MediaFormat format, byte[] sampleData)
Adds a track of data to an associatedDataSource
.protected boolean
advance()
protected int
getSampleTrackIndex()
protected int
getTrackCount()
protected MediaFormat
getTrackFormat(int index)
protected int
readSampleData(ByteBuffer byteBuf, int offset)
static void
reset()
protected void
selectTrack(int index)
protected void
setDataSource(Context context, Uri uri, Map<String,String> headers)
protected void
setDataSource(AssetFileDescriptor assetFileDescriptor)
protected void
setDataSource(MediaDataSource mediaDataSource)
protected void
setDataSource(FileDescriptor fileDescriptor)
protected void
setDataSource(FileDescriptor fileDescriptor, long offset, long length)
protected void
setDataSource(String path)
protected void
setDataSource(String path, Map<String,String> headers)
protected void
unselectTrack(int index)
-
-
-
Method Detail
-
addTrack
public static void addTrack(DataSource dataSource, MediaFormat format, byte[] sampleData)
Adds a track of data to an associatedDataSource
.- Parameters:
format
- the format which will be returned byMediaExtractor.getTrackFormat(int)
sampleData
- the data which will be iterated upon and returned byMediaExtractor.readSampleData(ByteBuffer, int)
.
-
setDataSource
@Implementation(minSdk=24) protected void setDataSource(AssetFileDescriptor assetFileDescriptor)
-
setDataSource
@Implementation protected void setDataSource(Context context, Uri uri, Map<String,String> headers)
-
setDataSource
@Implementation protected void setDataSource(FileDescriptor fileDescriptor)
-
setDataSource
@Implementation(minSdk=23) protected void setDataSource(MediaDataSource mediaDataSource)
-
setDataSource
@Implementation protected void setDataSource(FileDescriptor fileDescriptor, long offset, long length)
-
setDataSource
@Implementation protected void setDataSource(String path)
-
setDataSource
@Implementation protected void setDataSource(String path, Map<String,String> headers)
-
advance
@Implementation protected boolean advance()
-
getSampleTrackIndex
@Implementation protected int getSampleTrackIndex()
-
getTrackCount
@Implementation protected final int getTrackCount()
-
getTrackFormat
@Implementation protected MediaFormat getTrackFormat(int index)
-
readSampleData
@Implementation protected int readSampleData(ByteBuffer byteBuf, int offset)
-
selectTrack
@Implementation protected void selectTrack(int index)
-
unselectTrack
@Implementation protected void unselectTrack(int index)
-
reset
@Resetter public static void reset()
-
-