summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webmediaplayer_impl.cc
diff options
context:
space:
mode:
authorkylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 18:51:52 +0000
committerkylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 18:51:52 +0000
commitdb190487d2bc37ef9a2852d948bd8dd4548a98bd (patch)
treebba60ce128d4e214663cbd45e6620224e2cf3ae4 /webkit/glue/webmediaplayer_impl.cc
parent66f16b11638993ead4028e853d5565a74b9acba3 (diff)
downloadchromium_src-db190487d2bc37ef9a2852d948bd8dd4548a98bd.zip
chromium_src-db190487d2bc37ef9a2852d948bd8dd4548a98bd.tar.gz
chromium_src-db190487d2bc37ef9a2852d948bd8dd4548a98bd.tar.bz2
Pipeline will execute a callback whenever an run-time error has happened.
BUG=16738 TEST=pipeline_impl_unittest.cc Review URL: http://codereview.chromium.org/160298 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webmediaplayer_impl.cc')
-rw-r--r--webkit/glue/webmediaplayer_impl.cc53
1 files changed, 51 insertions, 2 deletions
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
index e31139a..8ab1f29 100644
--- a/webkit/glue/webmediaplayer_impl.cc
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -93,6 +93,11 @@ void WebMediaPlayerImpl::Proxy::PipelineSeekCallback() {
&WebMediaPlayerImpl::Proxy::PipelineSeekTask));
}
+void WebMediaPlayerImpl::Proxy::PipelineErrorCallback() {
+ render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
+ &WebMediaPlayerImpl::Proxy::PipelineErrorTask));
+}
+
void WebMediaPlayerImpl::Proxy::RepaintTask() {
DCHECK(MessageLoop::current() == render_loop_);
{
@@ -119,6 +124,13 @@ void WebMediaPlayerImpl::Proxy::PipelineSeekTask() {
}
}
+void WebMediaPlayerImpl::Proxy::PipelineErrorTask() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ if (webmediaplayer_) {
+ webmediaplayer_->OnPipelineError();
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////
// WebMediaPlayerImpl implementation
@@ -139,16 +151,21 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client,
// Create the pipeline and its thread.
if (!pipeline_thread_.Start()) {
NOTREACHED() << "Could not start PipelineThread";
- } else {
- pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
+ return;
}
+ pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
+
// Also we want to be notified of |main_loop_| destruction.
main_loop_->AddDestructionObserver(this);
// Creates the proxy.
proxy_ = new Proxy(main_loop_, this);
+ // Sets the pipeline's error reporting callback.
+ pipeline_->SetPipelineErrorCallback(NewCallback(proxy_.get(),
+ &WebMediaPlayerImpl::Proxy::PipelineErrorCallback));
+
// Add in the default filter factories.
filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory());
filter_factory_->AddFactory(media::FFmpegAudioDecoder::CreateFactory());
@@ -404,6 +421,38 @@ void WebMediaPlayerImpl::OnPipelineSeek() {
}
}
+void WebMediaPlayerImpl::OnPipelineError() {
+ DCHECK(MessageLoop::current() == main_loop_);
+ switch (pipeline_->GetError()) {
+ case media::PIPELINE_OK:
+ case media::PIPELINE_STOPPING:
+ NOTREACHED() << "We shouldn't get called with these non-errors";
+ break;
+
+ case media::PIPELINE_ERROR_INITIALIZATION_FAILED:
+ case media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING:
+ case media::PIPELINE_ERROR_COULD_NOT_RENDER:
+ // Format error.
+ SetNetworkState(WebMediaPlayer::FormatError);
+ break;
+
+ case media::PIPELINE_ERROR_URL_NOT_FOUND:
+ case media::PIPELINE_ERROR_NETWORK:
+ case media::PIPELINE_ERROR_DECODE:
+ case media::PIPELINE_ERROR_ABORT:
+ case media::PIPELINE_ERROR_OUT_OF_MEMORY:
+ case media::PIPELINE_ERROR_READ:
+ case media::PIPELINE_ERROR_AUDIO_HARDWARE:
+ case media::DEMUXER_ERROR_COULD_NOT_OPEN:
+ case media::DEMUXER_ERROR_COULD_NOT_PARSE:
+ case media::DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
+ case media::DEMUXER_ERROR_COULD_NOT_CREATE_THREAD:
+ // Decode error.
+ SetNetworkState(WebMediaPlayer::DecodeError);
+ break;
+ }
+}
+
void WebMediaPlayerImpl::SetNetworkState(
WebKit::WebMediaPlayer::NetworkState state) {
DCHECK(MessageLoop::current() == main_loop_);