Package org.robolectric.shadows
Class ShadowMediaExtractor
java.lang.Object
org.robolectric.shadows.ShadowMediaExtractor
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addTrack
(DataSource dataSource, MediaFormat format, byte[] sampleData) Adds a track of data to an associatedDataSource
.protected boolean
advance()
protected PersistableBundle
protected int
protected int
protected MediaFormat
getTrackFormat
(int index) protected int
readSampleData
(ByteBuffer byteBuf, int offset) static void
reset()
protected void
selectTrack
(int index) protected void
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) static void
setMetrics
(DataSource dataSource, PersistableBundle metrics) Sets metrics for an associatedDataSource
.protected void
unselectTrack
(int index)
-
Constructor Details
-
ShadowMediaExtractor
public ShadowMediaExtractor()
-
-
Method Details
-
addTrack
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)
.
-
setMetrics
Sets metrics for an associatedDataSource
.- Parameters:
metrics
- the data which will be returned byMediaExtractor.getMetrics()
.
-
setDataSource
-
setDataSource
-
setDataSource
-
setDataSource
-
setDataSource
@Implementation protected void setDataSource(FileDescriptor fileDescriptor, long offset, long length) -
setDataSource
-
setDataSource
-
advance
-
getSampleTrackIndex
-
getTrackCount
-
getTrackFormat
-
readSampleData
-
selectTrack
-
unselectTrack
-
getMetrics
-
reset
-