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 /webkit/glue/webmediaplayer_impl.cc | |
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 'webkit/glue/webmediaplayer_impl.cc')
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index 7bf5c1e..2f9306f 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -123,6 +123,11 @@ void WebMediaPlayerImpl::Proxy::PipelineErrorCallback() { &WebMediaPlayerImpl::Proxy::PipelineErrorTask)); } +void WebMediaPlayerImpl::Proxy::NetworkEventCallback() { + render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, + &WebMediaPlayerImpl::Proxy::NetworkEventTask)); +} + void WebMediaPlayerImpl::Proxy::RepaintTask() { DCHECK(MessageLoop::current() == render_loop_); { @@ -163,6 +168,13 @@ void WebMediaPlayerImpl::Proxy::PipelineErrorTask() { } } +void WebMediaPlayerImpl::Proxy::NetworkEventTask() { + DCHECK(MessageLoop::current() == render_loop_); + if (webmediaplayer_) { + webmediaplayer_->OnNetworkEvent(); + } +} + ///////////////////////////////////////////////////////////////////////////// // WebMediaPlayerImpl implementation @@ -199,6 +211,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, &WebMediaPlayerImpl::Proxy::PipelineEndedCallback)); pipeline_->SetPipelineErrorCallback(NewCallback(proxy_.get(), &WebMediaPlayerImpl::Proxy::PipelineErrorCallback)); + pipeline_->SetNetworkEventCallback(NewCallback(proxy_.get(), + &WebMediaPlayerImpl::Proxy::NetworkEventCallback)); // Add in the default filter factories. filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory()); @@ -505,10 +519,10 @@ void WebMediaPlayerImpl::OnPipelineInitialize() { DCHECK(MessageLoop::current() == main_loop_); if (pipeline_->GetError() == media::PIPELINE_OK) { // Only keep one time range starting from 0. - WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1)); + WebKit::WebTimeRanges new_buffered(1u); new_buffered[0].start = 0.0f; new_buffered[0].end = - static_cast<float>(pipeline_->GetBufferedTime().InSecondsF()); + static_cast<float>(pipeline_->GetDuration().InSecondsF()); buffered_.swap(new_buffered); // Since we have initialized the pipeline, say we have everything. @@ -583,6 +597,16 @@ void WebMediaPlayerImpl::OnPipelineError() { Repaint(); } +void WebMediaPlayerImpl::OnNetworkEvent() { + DCHECK(MessageLoop::current() == main_loop_); + if (pipeline_->GetError() == media::PIPELINE_OK) { + if (pipeline_->IsNetworkActive()) + SetNetworkState(WebKit::WebMediaPlayer::Loading); + else + SetNetworkState(WebKit::WebMediaPlayer::Idle); + } +} + void WebMediaPlayerImpl::SetNetworkState( WebKit::WebMediaPlayer::NetworkState state) { DCHECK(MessageLoop::current() == main_loop_); |