diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 01:29:50 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 01:29:50 +0000 |
commit | 4f92fbc2765f3bd2db6d076c9b4d17410b847538 (patch) | |
tree | 2b4977e589b6cebefea29f3d425bd5d0a34c46b6 /media | |
parent | 30973dfd8a5c23cce0d726c6fdd8c298ad94f324 (diff) | |
download | chromium_src-4f92fbc2765f3bd2db6d076c9b4d17410b847538.zip chromium_src-4f92fbc2765f3bd2db6d076c9b4d17410b847538.tar.gz chromium_src-4f92fbc2765f3bd2db6d076c9b4d17410b847538.tar.bz2 |
Report stalled event correctly for <video>
BUG=20127
BUG=13568
TEST=Opens a web page, stalled event should be fire only if network
is actuall stalled.
What this patch does:
1. Report Loading / Idle according to whether we are actively
receiving data in the BuffereResourceLoader. This is done by
signaling the network events to BufferedDataSource and then
to the media playback pipeline.
2. Report byteLoaded() as the last byte position buffered. This
will enable an actual ticking progress for the progress event.
With this value actually ticking, stalled event is suppressed.
Review URL: http://codereview.chromium.org/269002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29235 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/filter_host.h | 5 | ||||
-rw-r--r-- | media/base/mock_filter_host.h | 1 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 28 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 12 |
4 files changed, 45 insertions, 1 deletions
diff --git a/media/base/filter_host.h b/media/base/filter_host.h index 2b288d2..4ac939b 100644 --- a/media/base/filter_host.h +++ b/media/base/filter_host.h @@ -64,7 +64,10 @@ class FilterHost { // Sets the flag to indicate that our media is now loaded. virtual void SetLoaded(bool loaded) = 0; - // Broadcast a message of type |message| to all other filters from |source|. + // Sets the flag to indicate current network activity. + virtual void SetNetworkActivity(bool network_activity) = 0; + + // Broadcast a message of type |message| to all filters. virtual void BroadcastMessage(FilterMessage message) = 0; protected: diff --git a/media/base/mock_filter_host.h b/media/base/mock_filter_host.h index dfcf403..0ec6912 100644 --- a/media/base/mock_filter_host.h +++ b/media/base/mock_filter_host.h @@ -38,6 +38,7 @@ class MockFilterHost : public FilterHost { MOCK_METHOD2(SetVideoSize, void(size_t width, size_t height)); MOCK_METHOD1(SetStreaming, void(bool streamed)); MOCK_METHOD1(SetLoaded, void(bool loaded)); + MOCK_METHOD1(SetNetworkActivity, void(bool network_activity)); MOCK_METHOD0(NotifyEnded, void()); MOCK_METHOD1(BroadcastMessage, void(FilterMessage message)); diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 49ebe4a..2b38269 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -157,6 +157,11 @@ bool PipelineImpl::IsInitialized() const { } } +bool PipelineImpl::IsNetworkActive() const { + AutoLock auto_lock(lock_); + return network_activity_; +} + bool PipelineImpl::IsRendered(const std::string& major_mime_type) const { AutoLock auto_lock(lock_); bool is_rendered = (rendered_mime_types_.find(major_mime_type) != @@ -284,6 +289,12 @@ void PipelineImpl::SetPipelineErrorCallback(PipelineCallback* error_callback) { 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; @@ -417,6 +428,16 @@ void PipelineImpl::SetLoaded(bool loaded) { loaded_ = loaded; } +void PipelineImpl::SetNetworkActivity(bool network_activity) { + DCHECK(IsRunning()); + { + AutoLock auto_lock(lock_); + network_activity_ = network_activity; + } + message_loop_->PostTask(FROM_HERE, + NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask)); +} + void PipelineImpl::BroadcastMessage(FilterMessage message) { DCHECK(IsRunning()); @@ -718,6 +739,13 @@ void PipelineImpl::NotifyEndedTask() { } } +void PipelineImpl::NotifyNetworkEventTask() { + DCHECK_EQ(MessageLoop::current(), message_loop_); + if (network_callback_.get()) { + network_callback_->Run(); + } +} + void PipelineImpl::BroadcastMessageTask(FilterMessage message) { DCHECK_EQ(MessageLoop::current(), message_loop_); diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index 891404a..92eceaa 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -72,6 +72,7 @@ class PipelineImpl : public Pipeline, public FilterHost { virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback); virtual bool IsRunning() const; virtual bool IsInitialized() const; + virtual bool IsNetworkActive() const; virtual bool IsRendered(const std::string& major_mime_type) const; virtual float GetPlaybackRate() const; virtual void SetPlaybackRate(float playback_rate); @@ -96,6 +97,9 @@ class PipelineImpl : public Pipeline, public FilterHost { // 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 { @@ -145,6 +149,7 @@ class PipelineImpl : public Pipeline, public FilterHost { virtual void SetVideoSize(size_t width, size_t height); virtual void SetStreaming(bool streamed); virtual void SetLoaded(bool loaded); + virtual void SetNetworkActivity(bool network_activity); virtual void NotifyEnded(); virtual void BroadcastMessage(FilterMessage message); @@ -194,6 +199,9 @@ class PipelineImpl : public Pipeline, public FilterHost { // Carries out handling a notification from a filter that it has ended. void NotifyEndedTask(); + // Carries out handling a notification of network event. + void NotifyNetworkEventTask(); + // Carries out message broadcasting on the message loop. void BroadcastMessageTask(FilterMessage message); @@ -299,6 +307,9 @@ class PipelineImpl : public Pipeline, public FilterHost { // loaded source. bool loaded_; + // Sets by the filters to indicate whether network is active. + bool network_activity_; + // Current volume level (from 0.0f to 1.0f). This value is set immediately // via SetVolume() and a task is dispatched on the message loop to notify the // filters. @@ -356,6 +367,7 @@ class PipelineImpl : public Pipeline, public FilterHost { scoped_ptr<PipelineCallback> stop_callback_; scoped_ptr<PipelineCallback> ended_callback_; scoped_ptr<PipelineCallback> error_callback_; + scoped_ptr<PipelineCallback> network_callback_; // Vector of our filters and map maintaining the relationship between the // FilterType and the filter itself. |