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 @interface
The buffer replacement mode, which may disable replacement. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Allows buffer replacement usingByteBuffer.allocateDirect(int)
.static final int
Disallows buffer replacement.static final int
Allows buffer replacement usingByteBuffer.allocate(int)
.static final int
Allows buffer replacement using Android Shared Memory.CryptoInfo
for encrypted data.The buffer's data, ornull
if no data has been set.int[]
Subsamples contained in the buffer.Supplemental data related to the buffer, ifBuffer.hasSupplementalData()
returns true.long
The time at which the sample should be presented.boolean
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. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the buffer.void
ensureSpaceForWrite
(int length) Ensures thatdata
is large enough to accommodate a write of a given length at its current position.final void
flip()
Flipsdata
andsupplementalData
in preparation for being queued to a decoder.final boolean
Returns whether theConstants.BUFFER_FLAG_ENCRYPTED
flag is set.final boolean
Returns whether the buffer is only able to hold flags, meaningdata
is null and its replacement mode isBUFFER_REPLACEMENT_MODE_DISABLED
.final boolean
static DecoderInputBuffer
Creates a new instance for whichisFlagsOnly()
will return true.static DecoderInputBuffer
newSharedMemoryInstance
(String debugName, int regionSize) Creates a new instance for whichisSharedMemoryBuffer()
will return true.void
void
resetSupplementalData
(int length) ClearssupplementalData
and ensures that it's large enough to accommodatelength
bytes.void
Methods 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
CryptoInfo
for encrypted data. -
shmemRegion
-
data
The buffer's data, ornull
if 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_NORMAL
andBUFFER_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) ClearssupplementalData
and ensures that it's large enough to accommodatelength
bytes.- Parameters:
length
- The length of the supplemental data that must be accommodated, in bytes.
-
ensureSpaceForWrite
@EnsuresNonNull("data") public void ensureSpaceForWrite(int length) Ensures thatdata
is large enough to accommodate a write of a given length at its current position.If the capacity of
data
is sufficient this method does nothing. If the capacity is insufficient then an attempt is made to replacedata
with a newByteBuffer
whose 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, meaningdata
is null and its replacement mode isBUFFER_REPLACEMENT_MODE_DISABLED
. -
isEncrypted
public final boolean isEncrypted()Returns whether theConstants.BUFFER_FLAG_ENCRYPTED
flag is set. -
flip
public final void flip()Flipsdata
andsupplementalData
in preparation for being queued to a decoder.- See Also:
-
clear
public void clear()Description copied from class:Buffer
Clears the buffer. -
unmapByteBuffer
public void unmapByteBuffer()
-