diff --git a/packager/app/packager_main.cc b/packager/app/packager_main.cc index 0f76e66f0a..2e9f1aeaac 100644 --- a/packager/app/packager_main.cc +++ b/packager/app/packager_main.cc @@ -104,9 +104,7 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, const MuxerOptions& muxer_options, KeySource* key_source, MpdNotifier* mpd_notifier, - std::vector* muxer_listeners, std::vector* remux_jobs) { - DCHECK(muxer_listeners); DCHECK(remux_jobs); std::string previous_input; @@ -181,10 +179,8 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, muxer_listener = mpd_notify_muxer_listener.Pass(); } - if (muxer_listener) { - muxer_listeners->push_back(muxer_listener.release()); - muxer->SetMuxerListener(muxer_listeners->back()); - } + if (muxer_listener) + muxer->SetMuxerListener(muxer_listener.Pass()); if (!AddStreamToMuxer(remux_jobs->back()->demuxer()->streams(), stream_iter->stream_selector, @@ -274,17 +270,12 @@ bool RunPackager(const StreamDescriptorList& stream_descriptors) { } } - // TODO(kqyang): Should Muxer::SetMuxerListener take owership of the - // muxer_listeners object? Then we can get rid of |muxer_listeners|. - std::vector muxer_listeners; - STLElementDeleter > deleter(&muxer_listeners); std::vector remux_jobs; STLElementDeleter > scoped_jobs_deleter(&remux_jobs); if (!CreateRemuxJobs(stream_descriptors, muxer_options, encryption_key_source.get(), mpd_notifier.get(), - &muxer_listeners, &remux_jobs)) { return false; } diff --git a/packager/media/base/muxer.cc b/packager/media/base/muxer.cc index 588d34024d..65f69e817f 100644 --- a/packager/media/base/muxer.cc +++ b/packager/media/base/muxer.cc @@ -20,7 +20,6 @@ Muxer::Muxer(const MuxerOptions& options) clear_lead_in_seconds_(0), crypto_period_duration_in_seconds_(0), cancelled_(false), - muxer_listener_(NULL), clock_(NULL) {} Muxer::~Muxer() {} @@ -80,8 +79,8 @@ void Muxer::Cancel() { cancelled_ = true; } -void Muxer::SetMuxerListener(media::event::MuxerListener* muxer_listener) { - muxer_listener_ = muxer_listener; +void Muxer::SetMuxerListener(scoped_ptr muxer_listener) { + muxer_listener_ = muxer_listener.Pass(); } Status Muxer::AddSample(const MediaStream* stream, diff --git a/packager/media/base/muxer.h b/packager/media/base/muxer.h index 0acd5d5e73..d91926c21a 100644 --- a/packager/media/base/muxer.h +++ b/packager/media/base/muxer.h @@ -16,6 +16,7 @@ #include "packager/base/time/clock.h" #include "packager/media/base/muxer_options.h" #include "packager/media/base/status.h" +#include "packager/media/event/muxer_listener.h" namespace edash_packager { namespace media { @@ -24,10 +25,6 @@ class KeySource; class MediaSample; class MediaStream; -namespace event { -class MuxerListener; -} - /// Muxer is responsible for taking elementary stream samples and producing /// media containers. An optional KeySource can be provided to Muxer /// to generate encrypted outputs. @@ -63,7 +60,7 @@ class Muxer { /// Set a MuxerListener event handler for this object. /// @param muxer_listener should not be NULL. - void SetMuxerListener(event::MuxerListener* muxer_listener); + void SetMuxerListener(scoped_ptr muxer_listener); const std::vector& streams() const { return streams_; } @@ -87,7 +84,7 @@ class Muxer { double crypto_period_duration_in_seconds() const { return crypto_period_duration_in_seconds_; } - event::MuxerListener* muxer_listener() { return muxer_listener_; } + event::MuxerListener* muxer_listener() { return muxer_listener_.get(); } base::Clock* clock() { return clock_; } private: @@ -116,7 +113,7 @@ class Muxer { double crypto_period_duration_in_seconds_; bool cancelled_; - event::MuxerListener* muxer_listener_; + scoped_ptr muxer_listener_; // An external injected clock, can be NULL. base::Clock* clock_;