MFSampleExtension_Encryption_ProtectionScheme attribute
[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]
Specifies the protection scheme for encrypted samples.
Data type
UINT32
Remarks
The value of this attribute is a member of the MFSampleEncryptionProtectionScheme enumeration. In cases where the media source is MP4-based, the value is set based off the value of the scheme_type field within the scheme type box (‘schm’) in the MP4 header (‘moov’ or ‘moof’).
If the scheme_type field in an MP4-based file, or stream, is set to ‘cenc’ or ‘cbc1’, then the MFSampleExtension_Encryption_ProtectionScheme attribute should be set to PROTECTION_SCHEME_AES_CTR or PROTECTION_SCHEME_CBC, respectively, and no values should be set for MFSampleExtension_Encryption_CryptByteBlock and MFSampleExtension_Encryption_SkipByteBlock.
If the scheme_type field in an MP4-based file, or stream, is set to ‘cens’ or ‘cbcs’, then the MFSampleExtension_Encryption_ProtectionScheme attribute should be set to PROTECTION_SCHEME_AES_CTR or PROTECTION_SCHEME_CBC, respectively, and MFSampleExtension_Encryption_CryptByteBlock and MFSampleExtension_Encryption_SkipByteBlock must be set using the values in the ‘tenc’ box.
Examples
The following example shows how to set the MFSampleExtension_Encryption_ProtectionScheme and the associated MFSampleExtension_Encryption_CryptByteBlock and MFSampleExtension_Encryption_SkipByteBlock attributes.
HRESULT AddEncryptionAttributes(_In_ IMFSample* pSample, _In_ bool fIsEncrypted) { HRESULT hr = S_OK; if (fIsEncrypted) { //Set Encryption Protection Scheme hr = pSample->UINT32(MFSampleExtension_Encryption_ProtectionScheme, SAMPLE_ENCRYPTION_PROTECTION_SCHEME_AES_CBC); if (FAILED(hr)) return hr; //Set the Initialization Vector (IV) //(spSampleEncryptionData is omitted from this example for simplicity.) hr = pSample->SetBlob(MFSampleExtension_Encryption_SampleID, (BYTE*)(spSampleEncryptionData->m_pInitializationVector), spSampleEncryptionData->m_bIVSize); if (FAILED(hr)) return hr; //Set crypt and skip byte blocks for pattern encryption hr = pSample->SetUINT32(MFSampleExtension_Encryption_CryptByteBlock, 1); if (FAILED(hr)) return hr; hr = pSample->SetUINT32(MFSampleExtension_Encryption_SkipByteBlock, 9); if (FAILED(hr)) return hr; } return hr; }
Requirements
|
Minimum supported client |
Windows 10, version 1709 [desktop apps only] |
|---|---|
|
Minimum supported server |
None supported |
|
Header |
|