From b33a31cd5738d1c295c30331ea2bfe0a4be2bce7 Mon Sep 17 00:00:00 2001 From: Cosmin Stejerean Date: Wed, 14 Feb 2024 19:48:42 -0800 Subject: [PATCH] updates after rebasing on main --- packager/app/packager_main.cc | 50 ++++++++++-------- .../testdata/sbd_test/bear-640x360-audio.mp4 | Bin 43736 -> 43743 bytes .../testdata/sbd_test/bear-640x360-video.mp4 | Bin 301713 -> 301720 bytes .../app/test/testdata/sbd_test/output.mpd | 12 ++--- packager/mpd/base/adaptation_set.cc | 24 ++++++--- packager/mpd/base/xml/xml_node.cc | 16 +++--- 6 files changed, 57 insertions(+), 45 deletions(-) diff --git a/packager/app/packager_main.cc b/packager/app/packager_main.cc index 8e058c67657..f8469cfd1d5 100644 --- a/packager/app/packager_main.cc +++ b/packager/app/packager_main.cc @@ -320,22 +320,21 @@ bool ParseProtectionSystems(const std::string& protection_systems_str, return true; } -void addSBDParams(std::string& sbd_url, - std::string& sbd_template, - std::string& sbd_key, - std::string content_type, +void addSBDParams(const std::string& sbd_url, + const std::string& sbd_template, + const std::string& sbd_key, + const std::string content_type, MpdParams& mpd_params) { // Get comma separted urls - auto sbd_urls = absl::StrSplit(sbd_url, ","); - auto sbd_templates = absl::StrSplit(sbd_template, ","); + std::vector sbd_urls = absl::StrSplit(sbd_url, ","); + std::vector sbd_templates = absl::StrSplit(sbd_template, ","); std::vector>> sbd_keys_all; if (!sbd_key.empty()) { - auto sbd_keys = absl::StrSplit(sbd_key, ":"); - for (auto sbd_key : sbd_keys) { - std::vector pairs = - SplitStringIntoKeyValuePairs(sbd_key, '=', ','); + std::vector sbd_keys = absl::StrSplit(sbd_key, ":"); + for (std::string key : sbd_keys) { + std::vector pairs = SplitStringIntoKeyValuePairs(key, '=', ','); if (pairs.empty()) { LOG(ERROR) << "Invalid --sbd_key keyname/defaultvalue pairs."; } @@ -552,19 +551,24 @@ std::optional GetPackagingParams() { absl::GetFlag(FLAGS_include_mspr_pro_for_playready); mpd_params.low_latency_dash_mode = absl::GetFlag(FLAGS_low_latency_dash_mode); - if (!FLAGS_sbd_url_all.empty()) - addSBDParams(FLAGS_sbd_url_all, FLAGS_sbd_template_all, FLAGS_sbd_key_all, - "all", mpd_params); - - if (!FLAGS_sbd_url_video.empty()) - addSBDParams(FLAGS_sbd_url_video, FLAGS_sbd_template_video, - FLAGS_sbd_key_video, "video", mpd_params); - if (!FLAGS_sbd_url_audio.empty()) - addSBDParams(FLAGS_sbd_url_audio, FLAGS_sbd_template_audio, - FLAGS_sbd_key_audio, "audio", mpd_params); - if (!FLAGS_sbd_url_text.empty()) - addSBDParams(FLAGS_sbd_url_text, FLAGS_sbd_template_text, - FLAGS_sbd_key_text, "text", mpd_params); + if (!absl::GetFlag(FLAGS_sbd_url_all).empty()) + addSBDParams(absl::GetFlag(FLAGS_sbd_url_all), + absl::GetFlag(FLAGS_sbd_template_all), + absl::GetFlag(FLAGS_sbd_key_all), "all", mpd_params); + + if (!absl::GetFlag(FLAGS_sbd_url_video).empty()) { + addSBDParams(absl::GetFlag(FLAGS_sbd_url_video), + absl::GetFlag(FLAGS_sbd_template_video), + absl::GetFlag(FLAGS_sbd_key_video), "video", mpd_params); + } + if (!absl::GetFlag(FLAGS_sbd_url_audio).empty()) + addSBDParams(absl::GetFlag(FLAGS_sbd_url_audio), + absl::GetFlag(FLAGS_sbd_template_audio), + absl::GetFlag(FLAGS_sbd_key_audio), "audio", mpd_params); + if (!absl::GetFlag(FLAGS_sbd_url_text).empty()) + addSBDParams(absl::GetFlag(FLAGS_sbd_url_text), + absl::GetFlag(FLAGS_sbd_template_text), + absl::GetFlag(FLAGS_sbd_key_text), "text", mpd_params); HlsParams& hls_params = packaging_params.hls_params; if (!GetHlsPlaylistType(absl::GetFlag(FLAGS_hls_playlist_type), diff --git a/packager/app/test/testdata/sbd_test/bear-640x360-audio.mp4 b/packager/app/test/testdata/sbd_test/bear-640x360-audio.mp4 index a86c776cf5fecb8e5f63e59d2104906e8b1fdfb2..10077f9af8a26f2cebbf7d1f3d100c7932b30d94 100644 GIT binary patch delta 87 zcmca{mFfOfrU`0H%nTDXiWw(PoTF`@>gi%^!~g`M$AK&s5R1V#AjmTeNINqyWR#Q? l6kF-*r)QRAlqTsV=jZAdXC!7P>J}8`XQd{WZ2W(7B>+sK8-@S? delta 81 zcmcbAmFdP+rU`0HOg|@T6f<^BoTF_K=jmc>!~g`M$AK&s5R1VrAjmTeNZT+lWR#Q? f6kF-*r)QRAlqTsV=jZCD=jW&Aq;6(oytxtp@zNN! diff --git a/packager/app/test/testdata/sbd_test/bear-640x360-video.mp4 b/packager/app/test/testdata/sbd_test/bear-640x360-video.mp4 index 04ed1816fe8b874d83fe6973d42405a0d569603c..de83807979bc96d3807ae35e7926eab1ab62678e 100644 GIT binary patch delta 103 zcmbQZRcOXmp$XcIb`y1q87EF$plzS(>0)fe00g4Pfh-mfi@`S_$TJK`J2Nn3l#~<{ xTj}ekXO?7?Cg~;T=js<{BxWb-78K=Yr6!j&Gc&d`GlDP^5HoLQW@PD`2>{zC9033T delta 96 zcmbQSRcPW?p$XcI<`Z>_8M`Jf(6)&4bTKw!00PnDKo$###o!hY)4Ya~Vqj diff --git a/packager/app/test/testdata/sbd_test/output.mpd b/packager/app/test/testdata/sbd_test/output.mpd index 57d0ecccbc0..3213d65e8e7 100644 --- a/packager/app/test/testdata/sbd_test/output.mpd +++ b/packager/app/test/testdata/sbd_test/output.mpd @@ -1,6 +1,6 @@ - - + + @@ -15,8 +15,8 @@ bear-640x360-video.mp4 - - + + @@ -34,8 +34,8 @@ bear-640x360-audio.mp4 - - + + diff --git a/packager/mpd/base/adaptation_set.cc b/packager/mpd/base/adaptation_set.cc index c4ae593e04c..a1d6e5a9b48 100644 --- a/packager/mpd/base/adaptation_set.cc +++ b/packager/mpd/base/adaptation_set.cc @@ -358,25 +358,33 @@ std::optional AdaptationSet::GetXml() { // video if (!mpd_options_.mpd_params.sbd_adaptation_set_video.empty() && content_type_ == "video") { - adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "video", - mpd_options_); + if (!adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "video", + mpd_options_)) { + return std::nullopt; + } } // audio if (!mpd_options_.mpd_params.sbd_adaptation_set_audio.empty() && content_type_ == "audio") { - adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "audio", - mpd_options_); + if (!adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "audio", + mpd_options_)) { + return std::nullopt; + } } // text if (!mpd_options_.mpd_params.sbd_adaptation_set_text.empty() && content_type_ == "text") { - adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "text", - mpd_options_); + if (!adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "text", + mpd_options_)) { + return std::nullopt; + } } // all if (!mpd_options_.mpd_params.sbd_adaptation_set_all.empty()) { - adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "all", - mpd_options_); + if (!adaptation_set.AddEssentialProperty("urn:mpeg:dash:sbd:2020", "all", + mpd_options_)) { + return std::nullopt; + } } std::string switching_ids; diff --git a/packager/mpd/base/xml/xml_node.cc b/packager/mpd/base/xml/xml_node.cc index 71fa4dc36ce..ca86a489e7d 100644 --- a/packager/mpd/base/xml/xml_node.cc +++ b/packager/mpd/base/xml/xml_node.cc @@ -291,28 +291,28 @@ bool RepresentationBaseXmlNode::AddSBDInfo( const std::string& value) { for (const auto& sbd : sbd_adaptation_set) { XmlNode descriptor(descriptor_name.c_str()); - descriptor.SetStringAttribute("schemeIdUri", scheme_id_uri); + RCHECK(descriptor.SetStringAttribute("schemeIdUri", scheme_id_uri)); if (!sbd.url_.empty()) - descriptor.SetStringAttribute("value", sbd.url_); + RCHECK(descriptor.SetStringAttribute("value", sbd.url_)); if (!sbd.template_.empty()) - descriptor.SetStringAttribute("sbd:template", sbd.template_); + RCHECK(descriptor.SetStringAttribute("sbd:template", sbd.template_)); if (!sbd.sbd_keys_.empty()) { for (auto key : sbd.sbd_keys_) { XmlNode st("sbd:Key"); - st.SetStringAttribute("name", key.first); + RCHECK(st.SetStringAttribute("name", key.first)); if (key.second.empty()) { - st.SetStringAttribute("defaultValue", "nil"); + RCHECK(st.SetStringAttribute("defaultValue", "nil")); } else { - st.SetStringAttribute("defaultValue", key.second); + RCHECK(st.SetStringAttribute("defaultValue", key.second)); } - descriptor.AddChild(st.PassScopedPtr()); + RCHECK(descriptor.AddChild(std::move(st))); } } - if (!AddChild(descriptor.PassScopedPtr())) + if (!AddChild(std::move(descriptor))) return false; } return true;