MediaSampleEncryption Class
How a coded frame of a media segment is encrypted (MediaCodedFrame.Encryption): the key that decrypts it, the initialization vector, and the ranges of the frame that are encrypted. The library decrypts the frame with the keys of the MediaKeys of the media element (Encrypted Media Extensions, https://w3c.github.io/encrypted-media/), and the playback waits for the key when no session has it.
public sealed class MediaSampleEncryptionConstructors
| Name | Description |
|---|---|
| MediaSampleEncryption(MediaEncryptionScheme, ReadOnlyMemory<byte>, ReadOnlyMemory<byte>, IReadOnlyList<MediaSubsample>?) | Creates the encryption of a sample. |
MediaSampleEncryption(MediaEncryptionScheme, ReadOnlyMemory<byte>, ReadOnlyMemory<byte>, IReadOnlyList<MediaSubsample>?)
MediaSampleEncryption.csCreates the encryption of a sample.
public MediaSampleEncryption(MediaEncryptionScheme scheme, ReadOnlyMemory<byte> keyId, ReadOnlyMemory<byte> initializationVector, IReadOnlyList<MediaSubsample>? subsamples = null)Parameters
schemeMediaEncryptionScheme- The protection scheme.
keyIdReadOnlyMemory<byte>- The ID of the key (16 bytes).
initializationVectorReadOnlyMemory<byte>- The initialization vector: 8 or 16 bytes for
MediaEncryptionScheme.Cenc, 16 bytes forMediaEncryptionScheme.Cbcs(the constant IV of the track, or the IV of the sample). subsamplesIReadOnlyList<MediaSubsample>?- The subsamples of the sample, or an empty list when the whole sample is encrypted.
Properties
| Name | Description |
|---|---|
| CryptByteBlock | Gets the number of encrypted 16-byte blocks of the pattern of MediaEncryptionScheme.Cbcs (the default_crypt_byte_block of the tenc box). With MediaSampleEncryption.SkipByteBlock, 0 and 0 encrypt every block. |
| InitializationVector | Gets the initialization vector of the sample. |
| KeyId | Gets the ID of the key that decrypts the sample. |
| Scheme | Gets the protection scheme. |
| SkipByteBlock | Gets the number of clear 16-byte blocks that follow the encrypted blocks of the pattern of MediaEncryptionScheme.Cbcs. |
| Subsamples | Gets the subsamples of the sample, or an empty list when the whole sample is encrypted. |
CryptByteBlock
MediaSampleEncryption.csGets the number of encrypted 16-byte blocks of the pattern of MediaEncryptionScheme.Cbcs (the default_crypt_byte_block of the tenc box). With MediaSampleEncryption.SkipByteBlock, 0 and 0 encrypt every block.
public int CryptByteBlock { get; init; }Property value
InitializationVector
MediaSampleEncryption.csGets the initialization vector of the sample.
public ReadOnlyMemory<byte> InitializationVector { get; }Property value
Gets the ID of the key that decrypts the sample.
public ReadOnlyMemory<byte> KeyId { get; }Property value
Scheme
MediaSampleEncryption.csSkipByteBlock
MediaSampleEncryption.csGets the number of clear 16-byte blocks that follow the encrypted blocks of the pattern of MediaEncryptionScheme.Cbcs.
public int SkipByteBlock { get; init; }Property value
Subsamples
MediaSampleEncryption.csGets the subsamples of the sample, or an empty list when the whole sample is encrypted.
public IReadOnlyList<MediaSubsample> Subsamples { get; }Property value
Constants
| Name | Description |
|---|---|
| KeyIdLength | The length of the key IDs and of the keys of the Common Encryption schemes, in bytes. |
KeyIdLength
The length of the key IDs and of the keys of the Common Encryption schemes, in bytes.
public const int KeyIdLength = 16