Added in API level 30

MediaParser.OutputConsumer


public static interface MediaParser.OutputConsumer

android.media.MediaParser.OutputConsumer


Receives extracted media sample data and metadata from MediaParser.

Summary

Public methods

abstract void onSampleCompleted(int trackIndex, long timeMicros, int flags, int size, int offset, MediaCodec.CryptoInfo cryptoInfo)

Called once all the data of a sample has been passed to onSampleDataFound(int, InputReader).

abstract void onSampleDataFound(int trackIndex, MediaParser.InputReader inputReader)

Called when sample data is found in the stream.

abstract void onSeekMapFound(MediaParser.SeekMap seekMap)

Called when a SeekMap has been extracted from the stream.

abstract void onTrackCountFound(int numberOfTracks)

Called when the number of tracks is found.

abstract void onTrackDataFound(int trackIndex, MediaParser.TrackData trackData)

Called when new TrackData is found in the stream.

Public methods

onSampleCompleted

Added in API level 30
public abstract void onSampleCompleted (int trackIndex, 
                long timeMicros, 
                int flags, 
                int size, 
                int offset, 
                MediaCodec.CryptoInfo cryptoInfo)

Called once all the data of a sample has been passed to onSampleDataFound(int, InputReader).

Includes sample metadata, like presentation timestamp and flags.

Parameters
trackIndex int: The index of the track to which the sample corresponds.

timeMicros long: The media timestamp associated with the sample, in microseconds.

flags int: Flags associated with the sample. See the SAMPLE_FLAG_* constants. Value is either 0 or a combination of MediaParser.SAMPLE_FLAG_KEY_FRAME, MediaParser.SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA, MediaParser.SAMPLE_FLAG_LAST_SAMPLE, MediaParser.SAMPLE_FLAG_ENCRYPTED, and MediaParser.SAMPLE_FLAG_DECODE_ONLY

size int: The size of the sample data, in bytes.

offset int: The number of bytes that have been consumed by onSampleDataFound(int, MediaParser.InputReader) for the specified track, since the last byte belonging to the sample whose metadata is being passed.

cryptoInfo MediaCodec.CryptoInfo: Encryption data required to decrypt the sample. May be null for unencrypted samples. Implementors should treat any output CryptoInfo instances as immutable. MediaParser will not modify any output cryptoInfos and implementors should not modify them either.

onSampleDataFound

Added in API level 30
public abstract void onSampleDataFound (int trackIndex, 
                MediaParser.InputReader inputReader)

Called when sample data is found in the stream.

If the invocation of this method returns before the entire inputReader length is consumed, the method will be called again for the implementer to read the remaining data. Implementers should surface any thrown IOException caused by reading from input.

Parameters
trackIndex int: The index of the track to which the sample data corresponds.

inputReader MediaParser.InputReader: The InputReader from which to read the data. This value cannot be null.

Throws
IOException If an exception occurs while reading from inputReader.

onSeekMapFound

Added in API level 30
public abstract void onSeekMapFound (MediaParser.SeekMap seekMap)

Called when a SeekMap has been extracted from the stream.

This method is called at least once before any samples are complete. May be called multiple times after that in order to add SeekPoints.

Parameters
seekMap MediaParser.SeekMap: The extracted SeekMap. This value cannot be null.

onTrackCountFound

Added in API level 30
public abstract void onTrackCountFound (int numberOfTracks)

Called when the number of tracks is found.

Parameters
numberOfTracks int: The number of tracks in the stream.

onTrackDataFound

Added in API level 30
public abstract void onTrackDataFound (int trackIndex, 
                MediaParser.TrackData trackData)

Called when new TrackData is found in the stream.

Parameters
trackIndex int: The index of the track for which the TrackData was extracted.

trackData MediaParser.TrackData: The extracted TrackData. This value cannot be null.