Package com.castlabs.sdk.base.subtitles.buffer

# Class CryptoInfo

java.lang.Object
com.castlabs.sdk.base.subtitles.buffer.CryptoInfo

public final class CryptoInfo extends Object
Compatibility wrapper for `MediaCodec.CryptoInfo`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `int`
  `clearBlocks`
  `byte[]`
  `ecmData`
  `int`
  `encryptedBlocks`
  `byte[]`
  `iv`
  The 16 byte initialization vector.
  `byte[]`
  `key`
  The 16 byte key id.
  `int`
  `mode`
  The type of encryption that has been applied.
  `int[]`
  `numBytesOfClearData`
  The number of leading unencrypted bytes in each sub-sample.
  `int[]`
  `numBytesOfEncryptedData`
  The number of trailing encrypted bytes in each sub-sample.
  `int`
  `numSubSamples`
  The number of subSamples that make up the buffer's contents.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CryptoInfo()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MediaCodec.CryptoInfo`
  `getFrameworkCryptoInfo()`
  Returns an equivalent `MediaCodec.CryptoInfo` instance.
  `MediaCodec.CryptoInfo`
  `getFrameworkCryptoInfoV16()`
  Deprecated.
  Use `getFrameworkCryptoInfo()`.
  `void`
  `increaseClearDataFirstSubSampleBy(int count)`
  Increases the number of clear data for the first sub sample by `count`.
  `void`
  `set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData, byte[] key, byte[] iv, int mode, int encryptedBlocks, int clearBlocks)`
  `void`
  `set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData, byte[] key, byte[] iv, int mode, int encryptedBlocks, int clearBlocks, byte[] ecmData)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### iv

    public byte[] iv
    The 16 byte initialization vector. If the initialization vector of the content is shorter than 16 bytes, 0 byte padding is appended to extend the vector to the required 16 byte length.
    See Also:
      - `MediaCodec.CryptoInfo.iv`

  - ### key

    public byte[] key
    The 16 byte key id.
    See Also:
      - `MediaCodec.CryptoInfo.key`

  - ### mode

    @CryptoMode public int mode
    The type of encryption that has been applied. Must be one of the `Constants.CryptoMode` values.
    See Also:
      - `MediaCodec.CryptoInfo.mode`

  - ### numBytesOfClearData

    @Nullable public int[] numBytesOfClearData
    The number of leading unencrypted bytes in each sub-sample. If null, all bytes are treated as encrypted and `numBytesOfEncryptedData` must be specified.
    See Also:
      - `MediaCodec.CryptoInfo.numBytesOfClearData`

  - ### numBytesOfEncryptedData

    public int[] numBytesOfEncryptedData
    The number of trailing encrypted bytes in each sub-sample. If null, all bytes are treated as clear and `numBytesOfClearData` must be specified.
    See Also:
      - `MediaCodec.CryptoInfo.numBytesOfEncryptedData`

  - ### numSubSamples

    public int numSubSamples
    The number of subSamples that make up the buffer's contents.
    See Also:
      - `MediaCodec.CryptoInfo.numSubSamples`

  - ### encryptedBlocks

    public int encryptedBlocks
    See Also:
      - `MediaCodec.CryptoInfo.Pattern`

  - ### clearBlocks

    public int clearBlocks
    See Also:
      - `MediaCodec.CryptoInfo.Pattern`

  - ### ecmData

    @Nullable public byte[] ecmData

- ## Constructor Details

  - ### CryptoInfo

    public CryptoInfo()

- ## Method Details

  - ### set

    public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData, byte[] key, byte[] iv, @CryptoMode int mode, int encryptedBlocks, int clearBlocks)
    See Also:
      - `MediaCodec.CryptoInfo.set(int, int[], int[], byte[], byte[], int)`

  - ### set

    public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData, byte[] key, byte[] iv, @CryptoMode int mode, int encryptedBlocks, int clearBlocks, byte[] ecmData)

  - ### getFrameworkCryptoInfo

    public MediaCodec.CryptoInfo getFrameworkCryptoInfo()
    Returns an equivalent `MediaCodec.CryptoInfo` instance.

    Successive calls to this method on a single `CryptoInfo` will return the same instance. Changes to the `CryptoInfo` will be reflected in the returned object. The return object should not be modified directly.

    Returns:
      The equivalent `MediaCodec.CryptoInfo` instance.

  - ### increaseClearDataFirstSubSampleBy

    public void increaseClearDataFirstSubSampleBy(int count)
    Increases the number of clear data for the first sub sample by `count`.

    If `count` is 0, this method is a no-op. Otherwise, it adds `count` to `numBytesOfClearData`[0].

    If `numBytesOfClearData` is null (which is permitted), this method will instantiate it to a new `int[1]`.

    Parameters:
      `count` - The number of bytes to be added to the first subSample of `numBytesOfClearData`.

  - ### getFrameworkCryptoInfoV16

    @Deprecated public MediaCodec.CryptoInfo getFrameworkCryptoInfoV16()
    Deprecated.
    Use `getFrameworkCryptoInfo()`.