diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index 891d3999c1..3bd90625c5 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -139,6 +139,15 @@ class PackagerAppTest(unittest.TestCase): self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4') self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-golden.mpd') + def testPackageWebmWithEncryption(self): + self.packager.Package( + self._GetStreams(['video'], + output_format='webm', + test_files=['bear-640x360.webm']), + self._GetFlags(encryption=True)) + self._DiffGold(self.output[0], 'bear-640x360-vp8-cenc-golden.webm') + self._DiffGold(self.mpd_output, 'bear-640x360-vp8-cenc-webm-golden.mpd') + def testPackageHevcWithEncryption(self): self.packager.Package( self._GetStreams(['video'], diff --git a/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm b/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm new file mode 100644 index 0000000000..0111edcc04 Binary files /dev/null and b/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.webm differ diff --git a/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd b/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd new file mode 100644 index 0000000000..914e633901 --- /dev/null +++ b/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd @@ -0,0 +1,17 @@ + + + + + + + + AAAAMHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABAxMjM0NTY3ODkwMTIzNDU2 + + output_video.webm + + + + + + + diff --git a/packager/mpd/base/mpd_utils.cc b/packager/mpd/base/mpd_utils.cc index 2369969051..893a262d00 100644 --- a/packager/mpd/base/mpd_utils.cc +++ b/packager/mpd/base/mpd_utils.cc @@ -227,18 +227,20 @@ void AddContentProtectionElementsHelperTemplated( // (MP4) files. const bool is_mp4_container = media_info.container_type() == MediaInfo::CONTAINER_MP4; + std::string key_id_uuid_format; + if (protected_content.has_default_key_id()) { + if (!HexToUUID(protected_content.default_key_id(), &key_id_uuid_format)) { + LOG(ERROR) << "Failed to convert default key ID into UUID format."; + } + } + if (is_mp4_container) { ContentProtectionElement mp4_content_protection; mp4_content_protection.scheme_id_uri = kEncryptedMp4Scheme; mp4_content_protection.value = kEncryptedMp4Value; - if (protected_content.has_default_key_id()) { - std::string key_id_uuid_format; - if (HexToUUID(protected_content.default_key_id(), &key_id_uuid_format)) { - mp4_content_protection.additional_attributes["cenc:default_KID"] = - key_id_uuid_format; - } else { - LOG(ERROR) << "Failed to convert default key ID into UUID format."; - } + if (!key_id_uuid_format.empty()) { + mp4_content_protection.additional_attributes["cenc:default_KID"] = + key_id_uuid_format; } parent->AddContentProtectionElement(mp4_content_protection); @@ -269,6 +271,11 @@ void AddContentProtectionElementsHelperTemplated( drm_content_protection.subelements.push_back(cenc_pssh); } + if (!key_id_uuid_format.empty() && !is_mp4_container) { + drm_content_protection.additional_attributes["cenc:default_KID"] = + key_id_uuid_format; + } + parent->AddContentProtectionElement(drm_content_protection); }