TrackOutput
@UnstableApi
public interface TrackOutput
DiscardingTrackOutput |
A |
DummyTrackOutput |
This class is deprecated. Use |
FakeTrackOutput |
A fake |
ForwardingTrackOutput |
An overridable |
PlayerEmsgHandler.PlayerTrackEmsgHandler |
Handles emsg messages for a specific track for the player. |
SampleQueue |
A queue of media samples. |
Receives track level data extracted by an Extractor.
Summary
Nested types |
|---|
public final class TrackOutput.CryptoDataHolds data required to decrypt a sample. |
@DocumentedDefines the part of the sample data to which a call to sampleData corresponds. |
Constants |
|
|---|---|
default static final int |
Sample encryption data. |
default static final int |
Main media sample data. |
default static final int |
Sample supplemental data. |
Public methods |
|
|---|---|
default void |
durationUs(long durationUs)Called to set the duration of the track in microseconds. |
abstract void |
Called when the |
default void |
sampleData(ParsableByteArray data, int length)Equivalent to |
abstract void |
sampleData(Called to write sample data to the output. |
default int |
sampleData(DataReader input, int length, boolean allowEndOfInput)Equivalent to |
abstract int |
sampleData(Called to write sample data to the output. |
abstract void |
sampleMetadata(Called when metadata associated with a sample has been extracted from the stream. |
Constants
SAMPLE_DATA_PART_ENCRYPTION
default static final int SAMPLE_DATA_PART_ENCRYPTION = 1
Sample encryption data.
The format for encryption information is:
- (1 byte)
encryption_signal_byte: Most significant bit signals whether the encryption data contains subsample encryption data. The remaining bits containinitialization_vector_size. - (
initialization_vector_sizebytes) Initialization vector. - If subsample encryption data is present, as per
encryption_signal_byte, the encryption data also contains:- (2 bytes)
subsample_encryption_data_length. - (
subsample_encryption_data_length * 6bytes) Subsample encryption data (repeatedsubsample_encryption_data_lengthtimes:- (2 bytes) Size of a clear section in sample.
- (4 bytes) Size of an encryption section in sample.
- (2 bytes)
SAMPLE_DATA_PART_SUPPLEMENTAL
default static final int SAMPLE_DATA_PART_SUPPLEMENTAL = 2
Sample supplemental data.
If a sample contains supplemental data, the format of the entire sample data will be:
- If the sample has the
BUFFER_FLAG_ENCRYPTEDflag set, all encryption information. - (4 bytes)
sample_data_size: The size of the actual sample data, not including supplemental data or encryption information. - (
sample_data_sizebytes): The media sample data. - (remaining bytes) The supplemental data.
Public methods
durationUs
default void durationUs(long durationUs)
Called to set the duration of the track in microseconds.
| Parameters | |
|---|---|
long durationUs |
The duration of the track in microseconds. |
format
abstract void format(Format format)
Called when the Format of the track has been extracted from the stream.
sampleData
default void sampleData(ParsableByteArray data, int length)
Equivalent to sampleData sampleData(data, length, SAMPLE_DATA_PART_MAIN)}.
sampleData
abstract void sampleData(
ParsableByteArray data,
int length,
@TrackOutput.SampleDataPart int sampleDataPart
)
Called to write sample data to the output.
| Parameters | |
|---|---|
ParsableByteArray data |
A |
int length |
The number of bytes to read, starting from |
@TrackOutput.SampleDataPart int sampleDataPart |
The part of the sample data to which this call corresponds. |
sampleData
default int sampleData(DataReader input, int length, boolean allowEndOfInput)
Equivalent to sampleData(input, length, allowEndOfInput, SAMPLE_DATA_PART_MAIN).
| Throws | |
|---|---|
java.io.IOException |
sampleData
abstract int sampleData(
DataReader input,
int length,
boolean allowEndOfInput,
@TrackOutput.SampleDataPart int sampleDataPart
)
Called to write sample data to the output.
| Parameters | |
|---|---|
DataReader input |
A |
int length |
The maximum length to read from the input. |
boolean allowEndOfInput |
True if encountering the end of the input having read no data is allowed, and should result in |
@TrackOutput.SampleDataPart int sampleDataPart |
The part of the sample data to which this call corresponds. |
| Returns | |
|---|---|
int |
The number of bytes appended. |
| Throws | |
|---|---|
java.io.IOException |
If an error occurred reading from the input. |
sampleMetadata
abstract void sampleMetadata(
long timeUs,
@C.BufferFlags int flags,
int size,
int offset,
@Nullable TrackOutput.CryptoData cryptoData
)
Called when metadata associated with a sample has been extracted from the stream.
The corresponding sample data will have already been passed to the output via calls to sampleData or sampleData.
| Parameters | |
|---|---|
long timeUs |
The media timestamp associated with the sample, in microseconds. |
@C.BufferFlags int flags |
Flags associated with the sample. See |
int size |
The size of the sample data, in bytes. |
int offset |
The number of bytes that have been passed to |
@Nullable TrackOutput.CryptoData cryptoData |
The encryption data required to decrypt the sample. May be null. |