Skip to content

Commit

Permalink
updates after rebasing on main
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin committed Feb 15, 2024
1 parent 0e9e0b1 commit b33a31c
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 45 deletions.
50 changes: 27 additions & 23 deletions packager/app/packager_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> sbd_urls = absl::StrSplit(sbd_url, ",");
std::vector<std::string> sbd_templates = absl::StrSplit(sbd_template, ",");

std::vector<std::vector<std::pair<std::string, std::string>>> sbd_keys_all;

if (!sbd_key.empty()) {
auto sbd_keys = absl::StrSplit(sbd_key, ":");
for (auto sbd_key : sbd_keys) {
std::vector<KVPair> pairs =
SplitStringIntoKeyValuePairs(sbd_key, '=', ',');
std::vector<std::string> sbd_keys = absl::StrSplit(sbd_key, ":");
for (std::string key : sbd_keys) {
std::vector<KVPair> pairs = SplitStringIntoKeyValuePairs(key, '=', ',');
if (pairs.empty()) {
LOG(ERROR) << "Invalid --sbd_key keyname/defaultvalue pairs.";
}
Expand Down Expand Up @@ -552,19 +551,24 @@ std::optional<PackagingParams> 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),
Expand Down
Binary file modified packager/app/test/testdata/sbd_test/bear-640x360-audio.mp4
Binary file not shown.
Binary file modified packager/app/test/testdata/sbd_test/bear-640x360-video.mp4
Binary file not shown.
12 changes: 6 additions & 6 deletions packager/app/test/testdata/sbd_test/output.mpd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:sbd="urn:mpeg:dash:sbd:2020" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.7360665798187256S">
<!--Generated with https://github.com/shaka-project/shaka-packager version <tag>-<hash>-<test>-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:sbd="urn:mpeg:dash:sbd:2020" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.736067S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<EssentialProperty schemeIdUri="urn:mpeg:dash:sbd:2020" value="video1" sbd:template="t2">
Expand All @@ -15,8 +15,8 @@
</EssentialProperty>
<Representation id="0" bandwidth="973483" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>bear-640x360-video.mp4</BaseURL>
<SegmentBase indexRange="863-930" timescale="30000">
<Initialization range="0-862"/>
<SegmentBase indexRange="870-937" timescale="30000">
<Initialization range="0-869"/>
</SegmentBase>
</Representation>
</AdaptationSet>
Expand All @@ -34,8 +34,8 @@
<Representation id="1" bandwidth="133334" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>bear-640x360-audio.mp4</BaseURL>
<SegmentBase indexRange="797-864" timescale="44100">
<Initialization range="0-796"/>
<SegmentBase indexRange="804-871" timescale="44100">
<Initialization range="0-803"/>
</SegmentBase>
</Representation>
</AdaptationSet>
Expand Down
24 changes: 16 additions & 8 deletions packager/mpd/base/adaptation_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,33 @@ std::optional<xml::XmlNode> 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;
Expand Down
16 changes: 8 additions & 8 deletions packager/mpd/base/xml/xml_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b33a31c

Please sign in to comment.