Bug 1898588 - part3 : add encryption scheme 'cbcs-1-9'. r=media-playback-reviewers,padenot

We've implemented support for cbcs-1-9 in bug 1683737 before, and we
should add into CryptoScheme as well.

Differential Revision: https://phabricator.services.mozilla.com/D211644
This commit is contained in:
alwu 2024-05-29 18:27:03 +00:00
parent 01ff3ac17a
commit 6dfee59a8f
7 changed files with 18 additions and 6 deletions

View file

@ -602,6 +602,8 @@ const char* CryptoSchemeToString(const CryptoScheme& aScheme) {
return "cenc";
case CryptoScheme::Cbcs:
return "cbcs";
case CryptoScheme::Cbcs_1_9:
return "cbcs-1-9";
default:
MOZ_ASSERT_UNREACHABLE("not supported scheme!");
return "not supported scheme!";
@ -615,7 +617,9 @@ CryptoScheme StringToCryptoScheme(const nsAString& aString) {
if (aString.EqualsLiteral("cbcs")) {
return CryptoScheme::Cbcs;
}
// TODO : support cbcs-1-9?
if (aString.EqualsLiteral("cbcs-1-9")) {
return CryptoScheme::Cbcs_1_9;
}
return CryptoScheme::None;
}

View file

@ -582,10 +582,12 @@ class VideoData : public MediaData {
media::TimeUnit mNextKeyFrameTime;
};
// See https://w3c.github.io/encrypted-media/#scheme-cenc
enum class CryptoScheme : uint8_t {
None,
Cenc,
Cbcs,
Cbcs_1_9,
};
using CryptoSchemeSet = EnumSet<CryptoScheme, uint8_t>;

View file

@ -341,6 +341,7 @@ bool ChromiumCDMParent::InitCDMInputBuffer(gmp::CDMInputBuffer& aBuffer,
encryptionScheme = cdm::EncryptionScheme::kCenc;
break;
case CryptoScheme::Cbcs:
case CryptoScheme::Cbcs_1_9:
encryptionScheme = cdm::EncryptionScheme::kCbcs;
break;
default:

View file

@ -29,9 +29,9 @@ struct ParamTraits<mozilla::KeySystemConfig::SessionType>
template <>
struct ParamTraits<mozilla::CryptoScheme>
: public ContiguousEnumSerializerInclusive<mozilla::CryptoScheme,
mozilla::CryptoScheme::None,
mozilla::CryptoScheme::Cbcs> {};
: public ContiguousEnumSerializerInclusive<
mozilla::CryptoScheme, mozilla::CryptoScheme::None,
mozilla::CryptoScheme::Cbcs_1_9> {};
template <>
struct ParamTraits<mozilla::dom::MediaKeyMessageType>

View file

@ -108,6 +108,7 @@ RefPtr<MediaDataDecoder::InitPromise> ChromiumCDMVideoDecoder::Init() {
config.mEncryptionScheme() = cdm::EncryptionScheme::kCenc;
break;
case CryptoScheme::Cbcs:
case CryptoScheme::Cbcs_1_9:
config.mEncryptionScheme() = cdm::EncryptionScheme::kCbcs;
break;
default:

View file

@ -967,7 +967,9 @@ static CryptoInfoResult GetCryptoInfoFromSample(const MediaRawData* aSample) {
}
static bool supportsCBCS = java::CodecProxy::SupportsCBCS();
if (cryptoObj.mCryptoScheme == CryptoScheme::Cbcs && !supportsCBCS) {
if ((cryptoObj.mCryptoScheme == CryptoScheme::Cbcs ||
cryptoObj.mCryptoScheme == CryptoScheme::Cbcs_1_9) &&
!supportsCBCS) {
return CryptoInfoResult(NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR);
}
@ -1014,6 +1016,7 @@ static CryptoInfoResult GetCryptoInfoFromSample(const MediaRawData* aSample) {
tempIV.AppendElements(cryptoObj.mIV);
break;
case CryptoScheme::Cbcs:
case CryptoScheme::Cbcs_1_9:
mode = java::sdk::MediaCodec::CRYPTO_MODE_AES_CBC;
MOZ_ASSERT(cryptoObj.mConstantIV.Length() <= kExpectedIVLength);
tempIV.AppendElements(cryptoObj.mConstantIV);

View file

@ -400,7 +400,8 @@ HRESULT MFMediaEngineStream::AddEncryptAttributes(
if (aCryptoConfig.mCryptoScheme == CryptoScheme::Cenc) {
protectionScheme = MFSampleEncryptionProtectionScheme::
MF_SAMPLE_ENCRYPTION_PROTECTION_SCHEME_AES_CTR;
} else if (aCryptoConfig.mCryptoScheme == CryptoScheme::Cbcs) {
} else if (aCryptoConfig.mCryptoScheme == CryptoScheme::Cbcs ||
aCryptoConfig.mCryptoScheme == CryptoScheme::Cbcs_1_9) {
protectionScheme = MFSampleEncryptionProtectionScheme::
MF_SAMPLE_ENCRYPTION_PROTECTION_SCHEME_AES_CBC;
} else {