Remove the all zero KID in manifest for key rotation

Closes b/64035941

Change-Id: I382b6478889dd73bc422decf0cbf4d32cd9bb68d
This commit is contained in:
KongQun Yang 2017-07-27 17:03:19 -07:00
parent 2539920a5d
commit b5e6cf36ab
5 changed files with 22 additions and 15 deletions

View File

@ -3,7 +3,7 @@
<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" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S"> <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" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
<Period id="0" start="PT0S"> <Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9"> <AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/> <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="0" bandwidth="876578" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1"> <Representation id="0" bandwidth="876578" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1"> <SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
@ -15,7 +15,7 @@
</Representation> </Representation>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true"> <AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/> <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="1" bandwidth="125598" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100"> <Representation id="1" bandwidth="125598" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/> <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>

View File

@ -3,7 +3,7 @@
<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" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S"> <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" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
<Period id="0" start="PT0S"> <Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9"> <AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/> <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="0" bandwidth="876109" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1"> <Representation id="0" bandwidth="876109" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1"> <SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
@ -15,7 +15,7 @@
</Representation> </Representation>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true"> <AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/> <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="1" bandwidth="125122" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100"> <Representation id="1" bandwidth="125122" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/> <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>

View File

@ -4,7 +4,7 @@
<Period id="0" start="PT0S"> <Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9"> <AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="876578" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1"> <Representation id="0" bandwidth="876578" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/> <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1"> <SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
<SegmentTimeline> <SegmentTimeline>
@ -17,7 +17,7 @@
<AdaptationSet id="1" contentType="audio" segmentAlignment="true"> <AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<Representation id="1" bandwidth="125598" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100"> <Representation id="1" bandwidth="125598" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/> <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/> <ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1"> <SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1">
<SegmentTimeline> <SegmentTimeline>

View File

@ -144,7 +144,7 @@ bool WidevinePsshToJson(const std::vector<uint8_t>& pssh_box,
return true; return true;
} }
base::Optional<MediaPlaylist::EncryptionMethod> StringToEncrypionMethod( base::Optional<MediaPlaylist::EncryptionMethod> StringToEncryptionMethod(
const std::string& method) { const std::string& method) {
if (method == "cenc") { if (method == "cenc") {
return MediaPlaylist::EncryptionMethod::kSampleAesCenc; return MediaPlaylist::EncryptionMethod::kSampleAesCenc;
@ -282,7 +282,7 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info,
const std::string& protection_scheme = const std::string& protection_scheme =
media_info.protected_content().protection_scheme(); media_info.protected_content().protection_scheme();
base::Optional<MediaPlaylist::EncryptionMethod> enc_method = base::Optional<MediaPlaylist::EncryptionMethod> enc_method =
StringToEncrypionMethod(protection_scheme); StringToEncryptionMethod(protection_scheme);
if (!enc_method) { if (!enc_method) {
LOG(ERROR) << "Failed to recognize protection scheme " LOG(ERROR) << "Failed to recognize protection scheme "
<< protection_scheme; << protection_scheme;

View File

@ -15,6 +15,14 @@
namespace shaka { namespace shaka {
namespace { namespace {
bool IsKeyRotationDefaultKeyId(const std::string& key_id) {
for (char c : key_id) {
if (c != '\0')
return false;
}
return true;
}
std::string TextCodecString(const MediaInfo& media_info) { std::string TextCodecString(const MediaInfo& media_info) {
CHECK(media_info.has_text_info()); CHECK(media_info.has_text_info());
const std::string& format = media_info.text_info().format(); const std::string& format = media_info.text_info().format();
@ -295,7 +303,8 @@ void AddContentProtectionElementsHelperTemplated(
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; std::string key_id_uuid_format;
if (protected_content.has_default_key_id()) { if (protected_content.has_default_key_id() &&
!IsKeyRotationDefaultKeyId(protected_content.default_key_id())) {
if (!HexToUUID(protected_content.default_key_id(), &key_id_uuid_format)) { if (!HexToUUID(protected_content.default_key_id(), &key_id_uuid_format)) {
LOG(ERROR) << "Failed to convert default key ID into UUID format."; LOG(ERROR) << "Failed to convert default key ID into UUID format.";
} }
@ -313,10 +322,7 @@ void AddContentProtectionElementsHelperTemplated(
parent->AddContentProtectionElement(mp4_content_protection); parent->AddContentProtectionElement(mp4_content_protection);
} }
for (int i = 0; i < protected_content.content_protection_entry().size(); for (const auto& entry : protected_content.content_protection_entry()) {
++i) {
const MediaInfo::ProtectedContent::ContentProtectionEntry& entry =
protected_content.content_protection_entry(i);
if (!entry.has_uuid()) { if (!entry.has_uuid()) {
LOG(WARNING) LOG(WARNING)
<< "ContentProtectionEntry was specified but no UUID is set for " << "ContentProtectionEntry was specified but no UUID is set for "
@ -348,8 +354,9 @@ void AddContentProtectionElementsHelperTemplated(
parent->AddContentProtectionElement(drm_content_protection); parent->AddContentProtectionElement(drm_content_protection);
} }
LOG_IF(WARNING, protected_content.content_protection_entry().size() == 0) VLOG_IF(1, protected_content.content_protection_entry().size() == 0)
<< "The media is encrypted but no content protection specified."; << "The media is encrypted but no content protection specified (can "
"happen with key rotation).";
} }
} // namespace } // namespace