Class DecoderInputBuffer
- java.lang.Object
-
- com.google.android.exoplayer2.decoder.Buffer
-
- com.google.android.exoplayer2.decoder.DecoderInputBuffer
-
- Direct Known Subclasses:
MetadataInputBuffer,SubtitleInputBuffer
public class DecoderInputBuffer extends Buffer
Holds input for a decoder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDecoderInputBuffer.BufferReplacementModeThe buffer replacement mode.static classDecoderInputBuffer.InsufficientCapacityExceptionThrown when an attempt is made to write into aDecoderInputBufferwhosebufferReplacementModeisBUFFER_REPLACEMENT_MODE_DISABLEDand whodatacapacity is smaller than required.
-
Field Summary
Fields Modifier and Type Field Description static intBUFFER_REPLACEMENT_MODE_DIRECTAllows buffer replacement usingByteBuffer.allocateDirect(int).static intBUFFER_REPLACEMENT_MODE_DISABLEDDisallows buffer replacement.static intBUFFER_REPLACEMENT_MODE_NORMALAllows buffer replacement usingByteBuffer.allocate(int).CryptoInfocryptoInfoCryptoInfofor encrypted data.ByteBufferdataThe buffer's data, ornullif no data has been set.FormatformatTheFormat.ByteBuffersupplementalDataSupplemental data related to the buffer, ifBuffer.hasSupplementalData()returns true.longtimeUsThe time at which the sample should be presented.booleanwaitingForKeysWhether the last attempt to read a sample into this buffer failed due to not yet having the DRM keys associated with the next sample.
-
Constructor Summary
Constructors Constructor Description DecoderInputBuffer(int bufferReplacementMode)Creates a new instance.DecoderInputBuffer(int bufferReplacementMode, int paddingSize)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the buffer.voidensureSpaceForWrite(int length)Ensures thatdatais large enough to accommodate a write of a given length at its current position.voidflip()FlipsdataandsupplementalDatain preparation for being queued to a decoder.booleanisEncrypted()Returns whether theC.BUFFER_FLAG_ENCRYPTEDflag is set.static DecoderInputBuffernewNoDataInstance()Returns a new instance that's not able to hold any data.voidresetSupplementalData(int length)ClearssupplementalDataand ensures that it's large enough to accommodatelengthbytes.-
Methods inherited from class com.google.android.exoplayer2.decoder.Buffer
addFlag, clearFlag, getFlag, hasSupplementalData, isDecodeOnly, isEndOfStream, isKeyFrame, setFlags
-
-
-
-
Field Detail
-
BUFFER_REPLACEMENT_MODE_DISABLED
public static final int BUFFER_REPLACEMENT_MODE_DISABLED
Disallows buffer replacement.- See Also:
- Constant Field Values
-
BUFFER_REPLACEMENT_MODE_NORMAL
public static final int BUFFER_REPLACEMENT_MODE_NORMAL
Allows buffer replacement usingByteBuffer.allocate(int).- See Also:
- Constant Field Values
-
BUFFER_REPLACEMENT_MODE_DIRECT
public static final int BUFFER_REPLACEMENT_MODE_DIRECT
Allows buffer replacement usingByteBuffer.allocateDirect(int).- See Also:
- Constant Field Values
-
cryptoInfo
public final CryptoInfo cryptoInfo
CryptoInfofor encrypted data.
-
data
@Nullable public ByteBuffer data
The buffer's data, ornullif no data has been set.
-
waitingForKeys
public boolean waitingForKeys
Whether the last attempt to read a sample into this buffer failed due to not yet having the DRM keys associated with the next sample.
-
timeUs
public long timeUs
The time at which the sample should be presented.
-
supplementalData
@Nullable public ByteBuffer supplementalData
Supplemental data related to the buffer, ifBuffer.hasSupplementalData()returns true. If present, the buffer is populated with supplemental data from position 0 to its limit.
-
-
Constructor Detail
-
DecoderInputBuffer
public DecoderInputBuffer(@BufferReplacementMode int bufferReplacementMode)
Creates a new instance.- Parameters:
bufferReplacementMode- TheDecoderInputBuffer.BufferReplacementModereplacement mode.
-
DecoderInputBuffer
public DecoderInputBuffer(@BufferReplacementMode int bufferReplacementMode, int paddingSize)
Creates a new instance.- Parameters:
bufferReplacementMode- TheDecoderInputBuffer.BufferReplacementModereplacement mode.paddingSize- If non-zero,ensureSpaceForWrite(int)will ensure that the buffer is this number of bytes larger than the requested length. This can be useful for decoders that consume data in fixed size blocks, for efficiency. Setting the padding size to the decoder's fixed read size is necessary to prevent such a decoder from trying to read beyond the end of the buffer.
-
-
Method Detail
-
newNoDataInstance
public static DecoderInputBuffer newNoDataInstance()
Returns a new instance that's not able to hold any data.
-
resetSupplementalData
@EnsuresNonNull("supplementalData") public void resetSupplementalData(int length)ClearssupplementalDataand ensures that it's large enough to accommodatelengthbytes.- Parameters:
length- The length of the supplemental data that must be accommodated, in bytes.
-
ensureSpaceForWrite
@EnsuresNonNull("data") public void ensureSpaceForWrite(int length)Ensures thatdatais large enough to accommodate a write of a given length at its current position.If the capacity of
datais sufficient this method does nothing. If the capacity is insufficient then an attempt is made to replacedatawith a newByteBufferwhose capacity is sufficient. Data up to the current position is copied to the new buffer.- Parameters:
length- The length of the write that must be accommodated, in bytes.- Throws:
DecoderInputBuffer.InsufficientCapacityException- If there is insufficient capacity to accommodate the write andbufferReplacementModeisBUFFER_REPLACEMENT_MODE_DISABLED.
-
isEncrypted
public final boolean isEncrypted()
Returns whether theC.BUFFER_FLAG_ENCRYPTEDflag is set.
-
flip
public final void flip()
FlipsdataandsupplementalDatain preparation for being queued to a decoder.- See Also:
Buffer.flip()
-
-