mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1487416 - Handle cbcs data from mp4parse-rust. r=jya
Handle mp4parse-rust providing cbcs data in the track metadata. Explicitly check the crypto scheme we get in the metadata and error if we encounter something outside of cenc and cbcs -- catch unexpected data early. Differential Revision: https://phabricator.services.mozilla.com/D15878 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
150ebe3741
commit
01a302ea14
@ -47,15 +47,29 @@ bool MP4AudioInfo::IsValid() const {
|
||||
mExtendedProfile > 0);
|
||||
}
|
||||
|
||||
static void UpdateTrackProtectedInfo(mozilla::TrackInfo& aConfig,
|
||||
const Mp4parseSinfInfo& aSinf) {
|
||||
static MediaResult UpdateTrackProtectedInfo(mozilla::TrackInfo& aConfig,
|
||||
const Mp4parseSinfInfo& aSinf) {
|
||||
if (aSinf.is_encrypted != 0) {
|
||||
// We currently only handle cenc, but this should be updated once we parse
|
||||
// cbcs encryption data.
|
||||
aConfig.mCrypto.mCryptoScheme = CryptoScheme::Cenc;
|
||||
if (aSinf.scheme_type == MP4_PARSE_ENCRYPTION_SCHEME_TYPE_CENC) {
|
||||
aConfig.mCrypto.mCryptoScheme = CryptoScheme::Cenc;
|
||||
} else if (aSinf.scheme_type == MP4_PARSE_ENCRYPTION_SCHEME_TYPE_CBCS) {
|
||||
aConfig.mCrypto.mCryptoScheme = CryptoScheme::Cbcs;
|
||||
} else {
|
||||
// Unsupported encryption type;
|
||||
return MediaResult(
|
||||
NS_ERROR_DOM_MEDIA_METADATA_ERR,
|
||||
RESULT_DETAIL(
|
||||
"Unsupported encryption scheme encountered aSinf.scheme_type=%d",
|
||||
static_cast<int>(aSinf.scheme_type)));
|
||||
}
|
||||
aConfig.mCrypto.mIVSize = aSinf.iv_size;
|
||||
aConfig.mCrypto.mKeyId.AppendElements(aSinf.kid.data, aSinf.kid.length);
|
||||
aConfig.mCrypto.mCryptByteBlock = aSinf.crypt_byte_block;
|
||||
aConfig.mCrypto.mSkipByteBlock = aSinf.skip_byte_block;
|
||||
aConfig.mCrypto.mConstantIV.AppendElements(aSinf.constant_iv.data,
|
||||
aSinf.constant_iv.length);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MediaResult MP4AudioInfo::Update(const Mp4parseTrackInfo* track,
|
||||
@ -88,7 +102,9 @@ MediaResult MP4AudioInfo::Update(const Mp4parseTrackInfo* track,
|
||||
RESULT_DETAIL(
|
||||
"Multiple crypto info encountered while updating audio track"));
|
||||
}
|
||||
UpdateTrackProtectedInfo(*this, audio->sample_info[i].protected_data);
|
||||
auto rv =
|
||||
UpdateTrackProtectedInfo(*this, audio->sample_info[i].protected_data);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
hasCrypto = true;
|
||||
}
|
||||
}
|
||||
@ -172,7 +188,9 @@ MediaResult MP4VideoInfo::Update(const Mp4parseTrackInfo* track,
|
||||
RESULT_DETAIL(
|
||||
"Multiple crypto info encountered while updating video track"));
|
||||
}
|
||||
UpdateTrackProtectedInfo(*this, video->sample_info[i].protected_data);
|
||||
auto rv =
|
||||
UpdateTrackProtectedInfo(*this, video->sample_info[i].protected_data);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
hasCrypto = true;
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ MP4Metadata::ResultAndTrackInfo MP4Metadata::GetTrackInfo(
|
||||
}
|
||||
auto track = mozilla::MakeUnique<MP4AudioInfo>();
|
||||
MediaResult updateStatus = track->Update(&info, &audio);
|
||||
if (updateStatus != NS_OK) {
|
||||
if (NS_FAILED(updateStatus)) {
|
||||
MOZ_LOG(gMP4MetadataLog, LogLevel::Warning,
|
||||
("Updating audio track failed with %s",
|
||||
updateStatus.Message().get()));
|
||||
@ -378,7 +378,7 @@ MP4Metadata::ResultAndTrackInfo MP4Metadata::GetTrackInfo(
|
||||
}
|
||||
auto track = mozilla::MakeUnique<MP4VideoInfo>();
|
||||
MediaResult updateStatus = track->Update(&info, &video);
|
||||
if (updateStatus != NS_OK) {
|
||||
if (NS_FAILED(updateStatus)) {
|
||||
MOZ_LOG(gMP4MetadataLog, LogLevel::Warning,
|
||||
("Updating video track failed with %s",
|
||||
updateStatus.Message().get()));
|
||||
|
Loading…
Reference in New Issue
Block a user