Class DecoderInputBuffer

java.lang.Object
com.castlabs.sdk.base.subtitles.buffer.Buffer
com.castlabs.sdk.base.subtitles.buffer.DecoderInputBuffer
Direct Known Subclasses:
BaseSubtitleInputBuffer

public class DecoderInputBuffer extends Buffer
Holds input for a decoder.
  • Field Details

    • BUFFER_REPLACEMENT_MODE_DISABLED

      public static final int BUFFER_REPLACEMENT_MODE_DISABLED
      Disallows buffer replacement.
      See Also:
    • BUFFER_REPLACEMENT_MODE_NORMAL

      public static final int BUFFER_REPLACEMENT_MODE_NORMAL
      Allows buffer replacement using ByteBuffer.allocate(int).
      See Also:
    • BUFFER_REPLACEMENT_MODE_DIRECT

      public static final int BUFFER_REPLACEMENT_MODE_DIRECT
      Allows buffer replacement using ByteBuffer.allocateDirect(int).
      See Also:
    • BUFFER_REPLACEMENT_MODE_SHARED

      public static final int BUFFER_REPLACEMENT_MODE_SHARED
      Allows buffer replacement using Android Shared Memory.
      See Also:
    • cryptoInfo

      public CryptoInfo cryptoInfo
      CryptoInfo for encrypted data.
    • shmemRegion

      @Nullable public SharedMemory shmemRegion
    • data

      @Nullable public ByteBuffer data
      The buffer's data, or null if 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.
    • subsamples

      @Nullable public int[] subsamples
      Subsamples contained in the buffer. This corresponds to the 'subs' MP4 box. May be null if such box was not present in the sample.
    • supplementalData

      @Nullable public ByteBuffer supplementalData
      Supplemental data related to the buffer, if Buffer.hasSupplementalData() returns true. If present, the buffer is populated with supplemental data from position 0 to its limit.
  • Constructor Details

  • Method Details

    • newFlagsOnlyInstance

      public static DecoderInputBuffer newFlagsOnlyInstance()
      Creates a new instance for which isFlagsOnly() will return true.
      Returns:
      A new flags only input buffer.
    • newSharedMemoryInstance

      public static DecoderInputBuffer newSharedMemoryInstance(String debugName, int regionSize)
      Creates a new instance for which isSharedMemoryBuffer() will return true.
      Parameters:
      debugName - The debug name on the Android system of this piece of shared memory that is allocated.
      regionSize - Size of the Shared memory region to be allocated in bytes.
      Returns:
      A new shared memory based input buffer.
    • resetSupplementalData

      @EnsuresNonNull("supplementalData") public void resetSupplementalData(int length)
      Clears supplementalData and ensures that it's large enough to accommodate length bytes.
      Parameters:
      length - The length of the supplemental data that must be accommodated, in bytes.
    • ensureSpaceForWrite

      @EnsuresNonNull("data") public void ensureSpaceForWrite(int length)
      Ensures that data 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 replace data with a new ByteBuffer 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 is BUFFER_REPLACEMENT_MODE_DISABLED.
    • isFlagsOnly

      public final boolean isFlagsOnly()
      Returns whether the buffer is only able to hold flags, meaning data is null and its replacement mode is BUFFER_REPLACEMENT_MODE_DISABLED.
    • isSharedMemoryBuffer

      public final boolean isSharedMemoryBuffer()
    • isEncrypted

      public final boolean isEncrypted()
      Returns whether the Constants.BUFFER_FLAG_ENCRYPTED flag is set.
    • flip

      public final void flip()
      Flips data and supplementalData in preparation for being queued to a decoder.
      See Also:
    • clear

      public void clear()
      Description copied from class: Buffer
      Clears the buffer.
      Overrides:
      clear in class Buffer
    • unmapByteBuffer

      public void unmapByteBuffer()
    • releaseSharedMemoryBuffer

      public void releaseSharedMemoryBuffer()