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:

  • Constructor Details

    • ShadowMediaExtractor

      public ShadowMediaExtractor()
  • Method Details

    • addTrack

      public static void addTrack(DataSource dataSource, MediaFormat format, byte[] sampleData)
      Adds a track of data to an associated DataSource.
      Parameters:
      format - the format which will be returned by MediaExtractor.getTrackFormat(int)
      sampleData - the data which will be iterated upon and returned by MediaExtractor.readSampleData(ByteBuffer, int).
    • setMetrics

      public static void setMetrics(DataSource dataSource, PersistableBundle metrics)
      Sets metrics for an associated DataSource.
      Parameters:
      metrics - the data which will be returned by MediaExtractor.getMetrics().
    • 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)
    • getMetrics

      @Implementation(minSdk=26) protected PersistableBundle getMetrics()
    • reset

      @Resetter public static void reset()