@UnstableApi
public final class CryptoInfo


Metadata describing the structure of an encrypted input sample.

This class is a compatibility wrapper for android.media.MediaCodec.CryptoInfo.

Summary

Public fields

int
int
final MediaCodec.CryptoInfo
@Nullable byte[]

The 16 byte initialization vector.

@Nullable byte[]

The 16 byte key id.

int

The type of encryption that has been applied.

@Nullable int[]

The number of leading unencrypted bytes in each sub-sample.

@Nullable int[]

The number of trailing encrypted bytes in each sub-sample.

int

The number of subSamples that make up the buffer's contents.

Public constructors

Public methods

MediaCodec.CryptoInfo

Returns an equivalent android.media.MediaCodec.CryptoInfo instance.

void

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,
    @C.CryptoMode int mode,
    int encryptedBlocks,
    int clearBlocks
)

Public fields

clearBlocks

public int clearBlocks

encryptedBlocks

public int encryptedBlocks

frameworkCryptoInfo

public final MediaCodec.CryptoInfo frameworkCryptoInfo

iv

public @Nullable 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
iv

key

public @Nullable byte[] key

The 16 byte key id.

See also
key

mode

@C.CryptoMode
public int mode

The type of encryption that has been applied. Must be one of the C.CryptoMode values.

See also
mode

numBytesOfClearData

public @Nullable 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.

numBytesOfEncryptedData

public @Nullable 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.

numSubSamples

public int numSubSamples

The number of subSamples that make up the buffer's contents.

See also
numSubSamples

Public constructors

CryptoInfo

public CryptoInfo()

Public methods

getFrameworkCryptoInfo

public MediaCodec.CryptoInfo getFrameworkCryptoInfo()

Returns an equivalent android.media.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.

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
int count

The number of bytes to be added to the first subSample of numBytesOfClearData.

set

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