diff --git a/app/muxer_flags.h b/app/muxer_flags.h index b002bc2578..eefb6db551 100644 --- a/app/muxer_flags.h +++ b/app/muxer_flags.h @@ -67,4 +67,18 @@ DEFINE_string(temp_file, "not specified, a new file will be created in an OS-dependent " "temporary directory."); +// Flags for MuxerListener. +DEFINE_bool(output_media_info, + true, + "Create a human readable format of MediaInfo. The output file name " + "will be the name specified by output flag, suffixed with " + "'.media_info'."); +DEFINE_string(scheme_id_uri, + "", + "This flag only applies if output_media_info is true. This value " + "will be set in MediaInfo if the stream is encrypted. " + "Use scheme_id_uri when you generate an MPD. If the " + "stream is encrypted, MPD requires a " + "element which requires the schemeIdUri attribute."); + #endif // APP_MUXER_FLAGS_H_ diff --git a/app/packager_main.cc b/app/packager_main.cc index 8083d19059..09c3c328b6 100644 --- a/app/packager_main.cc +++ b/app/packager_main.cc @@ -18,7 +18,9 @@ #include "media/base/muxer_options.h" #include "media/base/request_signer.h" #include "media/base/stream_info.h" +#include "media/event/vod_media_info_dump_muxer_listener.h" #include "media/file/file.h" +#include "media/file/file_closer.h" #include "media/mp4/mp4_muxer.h" DEFINE_bool(dump_stream_info, false, "Dump demuxed stream info."); @@ -171,6 +173,24 @@ bool RunPackager(const std::string& input) { return false; scoped_ptr muxer(new mp4::MP4Muxer(muxer_options)); + scoped_ptr muxer_listener; + scoped_ptr mpd_file; + if (FLAGS_output_media_info) { + std::string output_mpd_file_name = FLAGS_output + ".media_info"; + mpd_file.reset(File::Open(output_mpd_file_name.c_str(), "w")); + if (!mpd_file) { + LOG(ERROR) << "Failed to open " << output_mpd_file_name; + return false; + } + + scoped_ptr media_info_muxer_listener( + new event::VodMediaInfoDumpMuxerListener(mpd_file.get())); + media_info_muxer_listener->SetContentProtectionSchemeIdUri( + FLAGS_scheme_id_uri); + muxer_listener = media_info_muxer_listener.Pass(); + muxer->SetMuxerListener(muxer_listener.get()); + } + if (!AddStreamToMuxer(demuxer.streams(), muxer.get())) return false; diff --git a/media/event/muxer_listener.h b/media/event/muxer_listener.h index d24b811a96..9220b1bb77 100644 --- a/media/event/muxer_listener.h +++ b/media/event/muxer_listener.h @@ -24,6 +24,8 @@ class MuxerListener { kContainerWebM }; + virtual ~MuxerListener() {}; + // Called when muxing starts. This event happens before any other events. // For MPEG DASH Live profile, the initialization segment information is // available from StreamInfo. @@ -64,7 +66,6 @@ class MuxerListener { uint64 segment_file_size) = 0; protected: MuxerListener() {}; - virtual ~MuxerListener() {}; }; } // namespace event diff --git a/packager.gyp b/packager.gyp index 53af15b001..9956781ad4 100644 --- a/packager.gyp +++ b/packager.gyp @@ -297,6 +297,7 @@ ], 'dependencies': [ 'file', + 'media_event', 'mp4', 'third_party/gflags/gflags.gyp:gflags', ],