diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd index b0dbafdd3b..e9c4348da4 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd @@ -3,7 +3,7 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd index fd2258b125..9265f2e191 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd @@ -3,7 +3,7 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd index 53338d584b..81eb4d90d5 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd @@ -4,7 +4,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/packager/hls/base/simple_hls_notifier.cc b/packager/hls/base/simple_hls_notifier.cc index e1c4674c57..eb49a116ed 100644 --- a/packager/hls/base/simple_hls_notifier.cc +++ b/packager/hls/base/simple_hls_notifier.cc @@ -144,7 +144,7 @@ bool WidevinePsshToJson(const std::vector& pssh_box, return true; } -base::Optional StringToEncrypionMethod( +base::Optional StringToEncryptionMethod( const std::string& method) { if (method == "cenc") { return MediaPlaylist::EncryptionMethod::kSampleAesCenc; @@ -282,7 +282,7 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info, const std::string& protection_scheme = media_info.protected_content().protection_scheme(); base::Optional enc_method = - StringToEncrypionMethod(protection_scheme); + StringToEncryptionMethod(protection_scheme); if (!enc_method) { LOG(ERROR) << "Failed to recognize protection scheme " << protection_scheme; diff --git a/packager/mpd/base/mpd_utils.cc b/packager/mpd/base/mpd_utils.cc index 47ef3e1929..a491c0e076 100644 --- a/packager/mpd/base/mpd_utils.cc +++ b/packager/mpd/base/mpd_utils.cc @@ -15,6 +15,14 @@ namespace shaka { 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) { CHECK(media_info.has_text_info()); const std::string& format = media_info.text_info().format(); @@ -295,7 +303,8 @@ void AddContentProtectionElementsHelperTemplated( 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 (protected_content.has_default_key_id() && + !IsKeyRotationDefaultKeyId(protected_content.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."; } @@ -313,10 +322,7 @@ void AddContentProtectionElementsHelperTemplated( parent->AddContentProtectionElement(mp4_content_protection); } - for (int i = 0; i < protected_content.content_protection_entry().size(); - ++i) { - const MediaInfo::ProtectedContent::ContentProtectionEntry& entry = - protected_content.content_protection_entry(i); + for (const auto& entry : protected_content.content_protection_entry()) { if (!entry.has_uuid()) { LOG(WARNING) << "ContentProtectionEntry was specified but no UUID is set for " @@ -348,8 +354,9 @@ void AddContentProtectionElementsHelperTemplated( parent->AddContentProtectionElement(drm_content_protection); } - LOG_IF(WARNING, protected_content.content_protection_entry().size() == 0) - << "The media is encrypted but no content protection specified."; + VLOG_IF(1, protected_content.content_protection_entry().size() == 0) + << "The media is encrypted but no content protection specified (can " + "happen with key rotation)."; } } // namespace