diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 17:47:15 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 17:47:15 +0000 |
commit | 583634b8cb62af00593258b64680bf6b2358d43d (patch) | |
tree | ff7976bb94f6a607c919293045169c3f235d2fd9 /media | |
parent | dcf6c130ddd91d3349ec503203ea89d1600f2462 (diff) | |
download | chromium_src-583634b8cb62af00593258b64680bf6b2358d43d.zip chromium_src-583634b8cb62af00593258b64680bf6b2358d43d.tar.gz chromium_src-583634b8cb62af00593258b64680bf6b2358d43d.tar.bz2 |
Refactor Pipeline & PipelineImpl so WebMediaPlayerImpl references a Pipeline instead of PipelineImpl
BUG=54110
TEST=PipelineImplTest
Review URL: http://codereview.chromium.org/4664005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65817 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/pipeline.h | 12 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 28 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 15 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 18 |
4 files changed, 31 insertions, 42 deletions
diff --git a/media/base/pipeline.h b/media/base/pipeline.h index ab08cc4..5b234af 100644 --- a/media/base/pipeline.h +++ b/media/base/pipeline.h @@ -48,6 +48,15 @@ typedef Callback0::Type PipelineCallback; class Pipeline : public base::RefCountedThreadSafe<Pipeline> { public: + // Initializes pipeline. Pipeline takes ownership of all callbacks passed + // into this method. + // |ended_callback| will be executed when the media reaches the end. + // |error_callback_| will be executed upon an error in the pipeline. + // |network_callback_| will be executed when there's a network event. + virtual void Init(PipelineCallback* ended_callback, + PipelineCallback* error_callback, + PipelineCallback* network_callback) = 0; + // Build a pipeline to render the given URL using the given filter collection // to construct a filter chain. Returns true if successful, false otherwise // (i.e., pipeline already started). Note that a return value of true @@ -93,6 +102,9 @@ class Pipeline : public base::RefCountedThreadSafe<Pipeline> { // for a pipeline to be started but not initialized (i.e., an error occurred). virtual bool IsInitialized() const = 0; + // Returns true if there has been network activity. + virtual bool IsNetworkActive() const = 0; + // If the |major_mime_type| exists in the pipeline and is being rendered, this // method will return true. Types are defined in media/base/media_foramt.h. // For example, to determine if a pipeline contains video: diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 516b230..7f17ff8 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -31,6 +31,16 @@ PipelineImpl::~PipelineImpl() { DCHECK(!seek_pending_); } +void PipelineImpl::Init(PipelineCallback* ended_callback, + PipelineCallback* error_callback, + PipelineCallback* network_callback) { + DCHECK(!IsRunning()) + << "Init() should be called before the pipeline has started"; + ended_callback_.reset(ended_callback); + error_callback_.reset(error_callback); + network_callback_.reset(network_callback); +} + // Creates the PipelineInternal and calls it's start method. bool PipelineImpl::Start(MediaFilterCollection* collection, const std::string& url, @@ -273,24 +283,6 @@ int64 PipelineImpl::GetCurrentReadPosition() { return current_bytes_; } -void PipelineImpl::SetPipelineEndedCallback(PipelineCallback* ended_callback) { - DCHECK(!IsRunning()) - << "Permanent callbacks should be set before the pipeline has started"; - ended_callback_.reset(ended_callback); -} - -void PipelineImpl::SetPipelineErrorCallback(PipelineCallback* error_callback) { - DCHECK(!IsRunning()) - << "Permanent callbacks should be set before the pipeline has started"; - error_callback_.reset(error_callback); -} - -void PipelineImpl::SetNetworkEventCallback(PipelineCallback* network_callback) { - DCHECK(!IsRunning()) - << "Permanent callbacks should be set before the pipeline has started"; - network_callback_.reset(network_callback); -} - void PipelineImpl::ResetState() { AutoLock auto_lock(lock_); const base::TimeDelta kZero; diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index 6dff897..f0b9c61 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -66,6 +66,9 @@ class PipelineImpl : public Pipeline, public FilterHost { explicit PipelineImpl(MessageLoop* message_loop); // Pipeline implementation. + virtual void Init(PipelineCallback* ended_callback, + PipelineCallback* error_callback, + PipelineCallback* network_callback); virtual bool Start(MediaFilterCollection* filter_collection, const std::string& uri, PipelineCallback* start_callback); @@ -89,18 +92,6 @@ class PipelineImpl : public Pipeline, public FilterHost { virtual bool IsLoaded() const; virtual PipelineError GetError() const; - // Sets a permanent callback owned by the pipeline that will be executed when - // the media reaches the end. - virtual void SetPipelineEndedCallback(PipelineCallback* ended_callback); - - // |error_callback_| will be executed upon an error in the pipeline. If - // |error_callback_| is NULL, it is ignored. The pipeline takes ownership - // of |error_callback|. - virtual void SetPipelineErrorCallback(PipelineCallback* error_callback); - - // |network_callback_| will be executed when there's a network event. - virtual void SetNetworkEventCallback(PipelineCallback* network_callback); - private: // Pipeline states, as described above. enum State { diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index 02d1165..d61da09 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -61,9 +61,12 @@ class PipelineImplTest : public ::testing::Test { public: PipelineImplTest() : pipeline_(new PipelineImpl(&message_loop_)) { - pipeline_->SetPipelineErrorCallback(NewCallback( - reinterpret_cast<CallbackHelper*>(&callbacks_), - &CallbackHelper::OnError)); + pipeline_->Init( + NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), + &CallbackHelper::OnEnded), + NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), + &CallbackHelper::OnError), + NULL); mocks_.reset(new MockFilterCollection()); } @@ -598,10 +601,6 @@ TEST_F(PipelineImplTest, DisableAudioRenderer) { streams.push_back(audio_stream()); streams.push_back(video_stream()); - pipeline_->SetPipelineEndedCallback( - NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), - &CallbackHelper::OnEnded)); - InitializeDataSource(); InitializeDemuxer(&streams, base::TimeDelta()); InitializeAudioDecoder(audio_stream()); @@ -649,11 +648,6 @@ TEST_F(PipelineImplTest, EndedCallback) { streams.push_back(audio_stream()); streams.push_back(video_stream()); - // Set our ended callback. - pipeline_->SetPipelineEndedCallback( - NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), - &CallbackHelper::OnEnded)); - InitializeDataSource(); InitializeDemuxer(&streams, base::TimeDelta()); InitializeAudioDecoder(audio_stream()); |