# Print output for @column tags ?>
public
static
final
class
MediaCodec.CryptoInfo
extends Object
java.lang.Object | |
↳ | android.media.MediaCodec.CryptoInfo |
Metadata describing the structure of an encrypted input sample.
A buffer's data is considered to be partitioned into "subSamples". Each subSample starts with
a run of plain, unencrypted bytes followed by a run of encrypted bytes. Either of these runs
may be empty. If pattern encryption applies, each of the encrypted runs is encrypted only
partly, according to a repeating pattern of "encrypt" and "skip" blocks.
numBytesOfClearData
can be null to indicate that all data is encrypted, and
numBytesOfEncryptedData
can be null to indicate that all data is clear. At least one
of numBytesOfClearData
and numBytesOfEncryptedData
must be non-null.
This information encapsulates per-sample metadata as outlined in ISO/IEC FDIS 23001-7:2016 "Common encryption in ISO base media file format files".
AES-CTR | AES-CBC | |
---|---|---|
Without Patterns | cenc | cbc1 |
With Patterns | cens | cbcs |
CryptoInfo
, the scheme is selected implicitly by the combination of the
mode
field and the value set with setPattern(MediaCodec.CryptoInfo.Pattern)
. For the pattern, setting the
pattern to all zeroes (that is, both blocksToEncrypt
and blocksToSkip
are
zero) is interpreted as turning patterns off completely. A scheme that does not use patterns
will be selected, either cenc or cbc1. Setting the pattern to any nonzero value will choose
one of the pattern-supporting schemes, cens or cbcs. The default pattern if
setPattern(MediaCodec.CryptoInfo.Pattern)
is never called is all zeroes.
setPattern(MediaCodec.CryptoInfo.Pattern)
is used to set the pattern
to all zeroes, this will be interpreted as selecting the cbc1 scheme. The cbc1 scheme cannot
successfully decrypt HLS SAMPLE-AES audio because of differences in how the IVs are handled.
For this reason, it is recommended that a pattern of 1
encrypted block and 0
skip blocks be used with HLS SAMPLE-AES audio. This will trigger decryption to use cbcs mode
while still decrypting every block.
Nested classes | |
---|---|
class |
MediaCodec.CryptoInfo.Pattern
Metadata describing an encryption pattern for the protected bytes in a subsample. |
Fields | |
---|---|
public
byte[] |
iv
A 16-byte initialization vector |
public
byte[] |
key
A 16-byte key id |
public
int |
mode
The type of encryption that has been applied,
see |
public
int[] |
numBytesOfClearData
The number of leading unencrypted bytes in each subSample. |
public
int[] |
numBytesOfEncryptedData
The number of trailing encrypted bytes in each subSample. |
public
int |
numSubSamples
The number of subSamples that make up the buffer's contents. |
Public constructors | |
---|---|
CryptoInfo()
|
Public methods | |
---|---|
MediaCodec.CryptoInfo.Pattern
|
getPattern()
Returns the |
void
|
set(int newNumSubSamples, int[] newNumBytesOfClearData, int[] newNumBytesOfEncryptedData, byte[] newKey, byte[] newIV, int newMode)
Set the subsample count, clear/encrypted sizes, key, IV and mode fields of
a |
void
|
setPattern(MediaCodec.CryptoInfo.Pattern newPattern)
Set the encryption pattern on a |
String
|
toString()
Returns a string representation of the object. |
Inherited methods | |
---|---|
public byte[] iv
A 16-byte initialization vector
public byte[] key
A 16-byte key id
public int mode
The type of encryption that has been applied,
see MediaCodec.CRYPTO_MODE_UNENCRYPTED
, MediaCodec.CRYPTO_MODE_AES_CTR
and MediaCodec.CRYPTO_MODE_AES_CBC
public int[] numBytesOfClearData
The number of leading unencrypted bytes in each subSample. If null, all bytes are treated
as encrypted and numBytesOfEncryptedData
must be specified.
public int[] numBytesOfEncryptedData
The number of trailing encrypted bytes in each subSample. If null, all bytes are treated
as clear and numBytesOfClearData
must be specified.
public int numSubSamples
The number of subSamples that make up the buffer's contents.
public CryptoInfo ()
public MediaCodec.CryptoInfo.Pattern getPattern ()
Returns the encryption pattern
.
Returns | |
---|---|
MediaCodec.CryptoInfo.Pattern |
This value cannot be null . |
public void set (int newNumSubSamples, int[] newNumBytesOfClearData, int[] newNumBytesOfEncryptedData, byte[] newKey, byte[] newIV, int newMode)
Set the subsample count, clear/encrypted sizes, key, IV and mode fields of
a MediaCodec.CryptoInfo
instance.
Parameters | |
---|---|
newNumSubSamples |
int |
newNumBytesOfClearData |
int : This value cannot be null . |
newNumBytesOfEncryptedData |
int : This value cannot be null . |
newKey |
byte : This value cannot be null . |
newIV |
byte : This value cannot be null . |
newMode |
int |
public void setPattern (MediaCodec.CryptoInfo.Pattern newPattern)
Set the encryption pattern on a MediaCodec.CryptoInfo
instance.
See Pattern
.
Parameters | |
---|---|
newPattern |
MediaCodec.CryptoInfo.Pattern |
public String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
a string representation of the object. |