diff --git a/app/muxer_flags.cc b/app/muxer_flags.cc index 744a191368..f70283043c 100644 --- a/app/muxer_flags.cc +++ b/app/muxer_flags.cc @@ -8,10 +8,14 @@ #include "app/muxer_flags.h" +DEFINE_string(profile, + "", + "Specify the target DASH profile: on-demand or live. This will " + "set proper option values to ensure conformance to the desired " + "profile."); DEFINE_double(clear_lead, 10.0f, "Clear lead in seconds if encryption is enabled."); - DEFINE_bool(single_segment, true, "Generate a single segment for the media presentation. This option " diff --git a/app/muxer_flags.h b/app/muxer_flags.h index 8b598573c5..b35a6992b4 100644 --- a/app/muxer_flags.h +++ b/app/muxer_flags.h @@ -11,8 +11,8 @@ #include +DECLARE_string(profile); DECLARE_double(clear_lead); - DECLARE_bool(single_segment); DECLARE_double(segment_duration); DECLARE_bool(segment_sap_aligned); diff --git a/app/packager_main.cc b/app/packager_main.cc index cba40f1f53..283dcaecd7 100644 --- a/app/packager_main.cc +++ b/app/packager_main.cc @@ -210,6 +210,9 @@ bool RunPackager(const StringVector& stream_descriptors) { return false; } + if (!AssignFlagsFromProfile()) + return false; + // Get basic muxer options. MuxerOptions muxer_options; if (!GetMuxerOptions(&muxer_options)) diff --git a/app/packager_util.cc b/app/packager_util.cc index 980a425196..6d4dfe5b48 100644 --- a/app/packager_util.cc +++ b/app/packager_util.cc @@ -86,6 +86,35 @@ scoped_ptr CreateEncryptionKeySource() { return encryption_key_source.Pass(); } +bool AssignFlagsFromProfile() { + bool single_segment = FLAGS_single_segment; + bool normalize_pts = FLAGS_normalize_presentation_timestamp; + if (FLAGS_profile == "on-demand") { + single_segment = true; + normalize_pts = true; + } else if (FLAGS_profile == "live") { + single_segment = false; + normalize_pts = false; + } else if (FLAGS_profile != "") { + fprintf(stderr, "ERROR: --profile '%s' is not supported.\n", + FLAGS_profile.c_str()); + return false; + } + + if (FLAGS_single_segment != single_segment) { + FLAGS_single_segment = single_segment; + fprintf(stdout, "Profile %s: set --single_segment to %s.\n", + FLAGS_profile.c_str(), single_segment ? "true" : "false"); + } + if (FLAGS_normalize_presentation_timestamp != normalize_pts) { + FLAGS_normalize_presentation_timestamp = normalize_pts; + fprintf(stdout, + "Profile %s: set --normalize_presentation_timestamp to %s.\n", + FLAGS_profile.c_str(), normalize_pts ? "true" : "false"); + } + return true; +} + bool GetMuxerOptions(MuxerOptions* muxer_options) { DCHECK(muxer_options); diff --git a/app/packager_util.h b/app/packager_util.h index 0e617d7932..4845c9fee3 100644 --- a/app/packager_util.h +++ b/app/packager_util.h @@ -33,6 +33,9 @@ void DumpStreamInfo(const std::vector& streams); /// encryption is not required. scoped_ptr CreateEncryptionKeySource(); +/// Set flags according to profile. +bool AssignFlagsFromProfile(); + /// Fill MuxerOptions members using provided command line options. bool GetMuxerOptions(MuxerOptions* muxer_options);