From cda495fb57cf6fbc6931e6b36bfe4ac5923c98c8 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 28 Sep 2016 14:42:52 -0700 Subject: [PATCH] Add default_language flag Setting this flag will tag any matching tracks with kRoleMain. The player will then know which tracks should be default when there is not a language match. Closes #155 Change-Id: I827304c49e345d07b1e76f7a46421b60f228f0ba --- packager/app/mpd_flags.cc | 5 +++++ packager/app/mpd_flags.h | 1 + packager/app/packager_util.cc | 1 + packager/mpd/base/mpd_builder.cc | 6 +++++- packager/mpd/base/mpd_options.h | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packager/app/mpd_flags.cc b/packager/app/mpd_flags.cc index bfa3864518..63bb9232e7 100644 --- a/packager/app/mpd_flags.cc +++ b/packager/app/mpd_flags.cc @@ -43,6 +43,11 @@ DEFINE_double(suggested_presentation_delay, 0.0, "Specifies a delay, in seconds, to be added to the media " "presentation time. This value is used for live profile only."); +DEFINE_string(default_language, + "", + "Any tracks tagged with this language will have " + " in the manifest. This allows the " + "player to choose the correct default language for the content."); DEFINE_bool(generate_dash_if_iop_compliant_mpd, false, "Try to generate DASH-IF IOPv3 compliant MPD. This is best effort " diff --git a/packager/app/mpd_flags.h b/packager/app/mpd_flags.h index ff76e9b838..ba7f657e3a 100644 --- a/packager/app/mpd_flags.h +++ b/packager/app/mpd_flags.h @@ -19,6 +19,7 @@ DECLARE_double(minimum_update_period); DECLARE_double(min_buffer_time); DECLARE_double(time_shift_buffer_depth); DECLARE_double(suggested_presentation_delay); +DECLARE_string(default_language); DECLARE_bool(generate_dash_if_iop_compliant_mpd); #endif // APP_MPD_FLAGS_H_ diff --git a/packager/app/packager_util.cc b/packager/app/packager_util.cc index ca7cf13003..f55224f8cf 100644 --- a/packager/app/packager_util.cc +++ b/packager/app/packager_util.cc @@ -177,6 +177,7 @@ bool GetMpdOptions(MpdOptions* mpd_options) { mpd_options->time_shift_buffer_depth = FLAGS_time_shift_buffer_depth; mpd_options->suggested_presentation_delay = FLAGS_suggested_presentation_delay; + mpd_options->default_language = FLAGS_default_language; return true; } diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index c92a772f1a..5bb3482e1f 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -413,8 +413,12 @@ AdaptationSet* MpdBuilder::AddAdaptationSet(const std::string& lang) { std::unique_ptr adaptation_set( new AdaptationSet(adaptation_set_counter_.GetNext(), lang, mpd_options_, type_, &representation_counter_)); - DCHECK(adaptation_set); + + if (!lang.empty() && lang == mpd_options_.default_language) { + adaptation_set->AddRole(AdaptationSet::kRoleMain); + } + adaptation_sets_.push_back(std::move(adaptation_set)); return adaptation_sets_.back().get(); } diff --git a/packager/mpd/base/mpd_options.h b/packager/mpd/base/mpd_options.h index 28cfac91a4..03bf117961 100644 --- a/packager/mpd/base/mpd_options.h +++ b/packager/mpd/base/mpd_options.h @@ -28,6 +28,7 @@ struct MpdOptions { double min_buffer_time; double time_shift_buffer_depth; double suggested_presentation_delay; + std::string default_language; }; } // namespace shaka