Outputs default_KID for non-MP4 ContentProtection elements.

Now outputs cenc:default_KID attributes on all ContentProtection
elements for non-MP4 streams.  For MP4 streams, it will still output
the default ContentProtection element.

Closes #69

Change-Id: I38b24297aa3c2ccbcbde38b44279b56c37a388f7
This commit is contained in:
Jacob Trimble 2016-01-20 16:14:24 -08:00
parent 22498e125a
commit cd74066bb4
4 changed files with 41 additions and 8 deletions

View File

@ -139,6 +139,15 @@ class PackagerAppTest(unittest.TestCase):
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4') self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-golden.mpd') 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): def testPackageHevcWithEncryption(self):
self.packager.Package( self.packager.Package(
self._GetStreams(['video'], self._GetStreams(['video'],

Binary file not shown.

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/edash-packager version <tag>-<hash>-<test>-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" minBufferTime="PT2S" type="static" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" mediaPresentationDuration="PT2.7360000610351562S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="1000000/33000" par="16:9">
<Representation id="0" bandwidth="336974" codecs="vp8" mimeType="video/webm" sar="1:1">
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" cenc:default_KID="31323334-3536-3738-3930-313233343536">
<cenc:pssh>AAAAMHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABAxMjM0NTY3ODkwMTIzNDU2</cenc:pssh>
</ContentProtection>
<BaseURL>output_video.webm</BaseURL>
<SegmentBase indexRange="115195-115245" timescale="1000000">
<Initialization range="0-339"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>

View File

@ -227,18 +227,20 @@ void AddContentProtectionElementsHelperTemplated(
// (MP4) files. // (MP4) files.
const bool is_mp4_container = const bool is_mp4_container =
media_info.container_type() == MediaInfo::CONTAINER_MP4; 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) { if (is_mp4_container) {
ContentProtectionElement mp4_content_protection; ContentProtectionElement mp4_content_protection;
mp4_content_protection.scheme_id_uri = kEncryptedMp4Scheme; mp4_content_protection.scheme_id_uri = kEncryptedMp4Scheme;
mp4_content_protection.value = kEncryptedMp4Value; mp4_content_protection.value = kEncryptedMp4Value;
if (protected_content.has_default_key_id()) { if (!key_id_uuid_format.empty()) {
std::string key_id_uuid_format; mp4_content_protection.additional_attributes["cenc:default_KID"] =
if (HexToUUID(protected_content.default_key_id(), &key_id_uuid_format)) { 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.";
}
} }
parent->AddContentProtectionElement(mp4_content_protection); parent->AddContentProtectionElement(mp4_content_protection);
@ -269,6 +271,11 @@ void AddContentProtectionElementsHelperTemplated(
drm_content_protection.subelements.push_back(cenc_pssh); 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); parent->AddContentProtectionElement(drm_content_protection);
} }