Class DecoderInputBuffer
java.lang.Object
com.castlabs.sdk.base.subtitles.buffer.Buffer
com.castlabs.sdk.base.subtitles.buffer.DecoderInputBuffer
- Direct Known Subclasses:
BaseSubtitleInputBuffer
Holds input for a decoder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceThe buffer replacement mode, which may disable replacement. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAllows buffer replacement usingByteBuffer.allocateDirect(int).static final intDisallows buffer replacement.static final intAllows buffer replacement usingByteBuffer.allocate(int).static final intAllows buffer replacement using Android Shared Memory.CryptoInfofor encrypted data.The buffer's data, ornullif no data has been set.int[]Subsamples contained in the buffer.Supplemental data related to the buffer, ifBuffer.hasSupplementalData()returns true.longThe time at which the sample should be presented.booleanWhether 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the buffer.voidensureSpaceForWrite(int length) Ensures thatdatais large enough to accommodate a write of a given length at its current position.final voidflip()FlipsdataandsupplementalDatain preparation for being queued to a decoder.final booleanReturns whether theConstants.BUFFER_FLAG_ENCRYPTEDflag is set.final booleanReturns whether the buffer is only able to hold flags, meaningdatais null and its replacement mode isBUFFER_REPLACEMENT_MODE_DISABLED.final booleanstatic DecoderInputBufferCreates a new instance for whichisFlagsOnly()will return true.static DecoderInputBuffernewSharedMemoryInstance(String debugName, int regionSize) Creates a new instance for whichisSharedMemoryBuffer()will return true.voidvoidresetSupplementalData(int length) ClearssupplementalDataand ensures that it's large enough to accommodatelengthbytes.voidMethods inherited from class com.castlabs.sdk.base.subtitles.buffer.Buffer
addFlag, clearFlag, getFlag, hasSupplementalData, isDecodeOnly, isEndOfStream, isKeyFrame, setFlags
-
Field Details
-
BUFFER_REPLACEMENT_MODE_DISABLED
public static final int BUFFER_REPLACEMENT_MODE_DISABLEDDisallows buffer replacement.- See Also:
-
BUFFER_REPLACEMENT_MODE_NORMAL
public static final int BUFFER_REPLACEMENT_MODE_NORMALAllows buffer replacement usingByteBuffer.allocate(int).- See Also:
-
BUFFER_REPLACEMENT_MODE_DIRECT
public static final int BUFFER_REPLACEMENT_MODE_DIRECTAllows buffer replacement usingByteBuffer.allocateDirect(int).- See Also:
-
BUFFER_REPLACEMENT_MODE_SHARED
public static final int BUFFER_REPLACEMENT_MODE_SHAREDAllows buffer replacement using Android Shared Memory.- See Also:
-
cryptoInfo
CryptoInfofor encrypted data. -
shmemRegion
-
data
The buffer's data, ornullif no data has been set. -
waitingForKeys
public boolean waitingForKeysWhether 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 timeUsThe time at which the sample should be presented. -
subsamples
@Nullable public int[] subsamplesSubsamples contained in the buffer. This corresponds to the 'subs' MP4 box. May be null if such box was not present in the sample. -
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 Details
-
DecoderInputBuffer
- Parameters:
bufferReplacementMode- Determines the behavior ofensureSpaceForWrite(int). One ofBUFFER_REPLACEMENT_MODE_DISABLED,BUFFER_REPLACEMENT_MODE_NORMALandBUFFER_REPLACEMENT_MODE_DIRECT.
-
-
Method Details
-
newFlagsOnlyInstance
Creates a new instance for whichisFlagsOnly()will return true.- Returns:
- A new flags only input buffer.
-
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:
IllegalStateException- If there is insufficient capacity to accommodate the write and the buffer replacement mode of the holder isBUFFER_REPLACEMENT_MODE_DISABLED.
-
isFlagsOnly
public final boolean isFlagsOnly()Returns whether the buffer is only able to hold flags, meaningdatais null and its replacement mode isBUFFER_REPLACEMENT_MODE_DISABLED. -
isEncrypted
public final boolean isEncrypted()Returns whether theConstants.BUFFER_FLAG_ENCRYPTEDflag is set. -
flip
public final void flip()FlipsdataandsupplementalDatain preparation for being queued to a decoder.- See Also:
-
clear
public void clear()Description copied from class:BufferClears the buffer. -
unmapByteBuffer
public void unmapByteBuffer()
-