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