Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: webkit/glue/webmediaplayer_impl.cc

Issue 164201: Merge 22075 - Pipeline will execute a callback whenever an runtime error has ... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/webkit/glue/webmediaplayer_impl.cc:r22075
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/webmediaplayer_impl.h" 5 #include "webkit/glue/webmediaplayer_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "media/base/media_format.h" 9 #include "media/base/media_format.h"
10 #include "media/filters/ffmpeg_audio_decoder.h" 10 #include "media/filters/ffmpeg_audio_decoder.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void WebMediaPlayerImpl::Proxy::PipelineInitializationCallback() { 86 void WebMediaPlayerImpl::Proxy::PipelineInitializationCallback() {
87 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 87 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
88 &WebMediaPlayerImpl::Proxy::PipelineInitializationTask)); 88 &WebMediaPlayerImpl::Proxy::PipelineInitializationTask));
89 } 89 }
90 90
91 void WebMediaPlayerImpl::Proxy::PipelineSeekCallback() { 91 void WebMediaPlayerImpl::Proxy::PipelineSeekCallback() {
92 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 92 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
93 &WebMediaPlayerImpl::Proxy::PipelineSeekTask)); 93 &WebMediaPlayerImpl::Proxy::PipelineSeekTask));
94 } 94 }
95 95
96 void WebMediaPlayerImpl::Proxy::PipelineErrorCallback() {
97 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
98 &WebMediaPlayerImpl::Proxy::PipelineErrorTask));
99 }
100
96 void WebMediaPlayerImpl::Proxy::RepaintTask() { 101 void WebMediaPlayerImpl::Proxy::RepaintTask() {
97 DCHECK(MessageLoop::current() == render_loop_); 102 DCHECK(MessageLoop::current() == render_loop_);
98 { 103 {
99 AutoLock auto_lock(lock_); 104 AutoLock auto_lock(lock_);
100 --outstanding_repaints_; 105 --outstanding_repaints_;
101 DCHECK_GE(outstanding_repaints_, 0); 106 DCHECK_GE(outstanding_repaints_, 0);
102 } 107 }
103 if (webmediaplayer_) { 108 if (webmediaplayer_) {
104 webmediaplayer_->Repaint(); 109 webmediaplayer_->Repaint();
105 } 110 }
106 } 111 }
107 112
108 void WebMediaPlayerImpl::Proxy::PipelineInitializationTask() { 113 void WebMediaPlayerImpl::Proxy::PipelineInitializationTask() {
109 DCHECK(MessageLoop::current() == render_loop_); 114 DCHECK(MessageLoop::current() == render_loop_);
110 if (webmediaplayer_) { 115 if (webmediaplayer_) {
111 webmediaplayer_->OnPipelineInitialize(); 116 webmediaplayer_->OnPipelineInitialize();
112 } 117 }
113 } 118 }
114 119
115 void WebMediaPlayerImpl::Proxy::PipelineSeekTask() { 120 void WebMediaPlayerImpl::Proxy::PipelineSeekTask() {
116 DCHECK(MessageLoop::current() == render_loop_); 121 DCHECK(MessageLoop::current() == render_loop_);
117 if (webmediaplayer_) { 122 if (webmediaplayer_) {
118 webmediaplayer_->OnPipelineSeek(); 123 webmediaplayer_->OnPipelineSeek();
119 } 124 }
120 } 125 }
121 126
127 void WebMediaPlayerImpl::Proxy::PipelineErrorTask() {
128 DCHECK(MessageLoop::current() == render_loop_);
129 if (webmediaplayer_) {
130 webmediaplayer_->OnPipelineError();
131 }
132 }
133
122 ///////////////////////////////////////////////////////////////////////////// 134 /////////////////////////////////////////////////////////////////////////////
123 // WebMediaPlayerImpl implementation 135 // WebMediaPlayerImpl implementation
124 136
125 WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, 137 WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client,
126 media::FilterFactoryCollection* factory) 138 media::FilterFactoryCollection* factory)
127 : network_state_(WebKit::WebMediaPlayer::Empty), 139 : network_state_(WebKit::WebMediaPlayer::Empty),
128 ready_state_(WebKit::WebMediaPlayer::HaveNothing), 140 ready_state_(WebKit::WebMediaPlayer::HaveNothing),
129 main_loop_(NULL), 141 main_loop_(NULL),
130 filter_factory_(factory), 142 filter_factory_(factory),
131 pipeline_thread_("PipelineThread"), 143 pipeline_thread_("PipelineThread"),
132 paused_(true), 144 paused_(true),
133 playback_rate_(0.0f), 145 playback_rate_(0.0f),
134 client_(client) { 146 client_(client) {
135 // Saves the current message loop. 147 // Saves the current message loop.
136 DCHECK(!main_loop_); 148 DCHECK(!main_loop_);
137 main_loop_ = MessageLoop::current(); 149 main_loop_ = MessageLoop::current();
138 150
139 // Create the pipeline and its thread. 151 // Create the pipeline and its thread.
140 if (!pipeline_thread_.Start()) { 152 if (!pipeline_thread_.Start()) {
141 NOTREACHED() << "Could not start PipelineThread"; 153 NOTREACHED() << "Could not start PipelineThread";
142 } else { 154 return;
143 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
144 } 155 }
145 156
157 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
158
146 // Also we want to be notified of |main_loop_| destruction. 159 // Also we want to be notified of |main_loop_| destruction.
147 main_loop_->AddDestructionObserver(this); 160 main_loop_->AddDestructionObserver(this);
148 161
149 // Creates the proxy. 162 // Creates the proxy.
150 proxy_ = new Proxy(main_loop_, this); 163 proxy_ = new Proxy(main_loop_, this);
151 164
165 // Sets the pipeline's error reporting callback.
166 pipeline_->SetPipelineErrorCallback(NewCallback(proxy_.get(),
167 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback));
168
152 // Add in the default filter factories. 169 // Add in the default filter factories.
153 filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory()); 170 filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory());
154 filter_factory_->AddFactory(media::FFmpegAudioDecoder::CreateFactory()); 171 filter_factory_->AddFactory(media::FFmpegAudioDecoder::CreateFactory());
155 filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory()); 172 filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory());
156 filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory()); 173 filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory());
157 filter_factory_->AddFactory(VideoRendererImpl::CreateFactory(proxy_)); 174 filter_factory_->AddFactory(VideoRendererImpl::CreateFactory(proxy_));
158 } 175 }
159 176
160 WebMediaPlayerImpl::~WebMediaPlayerImpl() { 177 WebMediaPlayerImpl::~WebMediaPlayerImpl() {
161 Destroy(); 178 Destroy();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 414 }
398 } 415 }
399 416
400 void WebMediaPlayerImpl::OnPipelineSeek() { 417 void WebMediaPlayerImpl::OnPipelineSeek() {
401 DCHECK(MessageLoop::current() == main_loop_); 418 DCHECK(MessageLoop::current() == main_loop_);
402 if (pipeline_->GetError() == media::PIPELINE_OK) { 419 if (pipeline_->GetError() == media::PIPELINE_OK) {
403 GetClient()->timeChanged(); 420 GetClient()->timeChanged();
404 } 421 }
405 } 422 }
406 423
424 void WebMediaPlayerImpl::OnPipelineError() {
425 DCHECK(MessageLoop::current() == main_loop_);
426 switch (pipeline_->GetError()) {
427 case media::PIPELINE_OK:
428 case media::PIPELINE_STOPPING:
429 NOTREACHED() << "We shouldn't get called with these non-errors";
430 break;
431
432 case media::PIPELINE_ERROR_INITIALIZATION_FAILED:
433 case media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING:
434 case media::PIPELINE_ERROR_COULD_NOT_RENDER:
435 // Format error.
436 SetNetworkState(WebMediaPlayer::FormatError);
437 break;
438
439 case media::PIPELINE_ERROR_URL_NOT_FOUND:
440 case media::PIPELINE_ERROR_NETWORK:
441 case media::PIPELINE_ERROR_DECODE:
442 case media::PIPELINE_ERROR_ABORT:
443 case media::PIPELINE_ERROR_OUT_OF_MEMORY:
444 case media::PIPELINE_ERROR_READ:
445 case media::PIPELINE_ERROR_AUDIO_HARDWARE:
446 case media::DEMUXER_ERROR_COULD_NOT_OPEN:
447 case media::DEMUXER_ERROR_COULD_NOT_PARSE:
448 case media::DEMUXER_ERROR_NO_SUPPORTED_STREAMS:
449 case media::DEMUXER_ERROR_COULD_NOT_CREATE_THREAD:
450 // Decode error.
451 SetNetworkState(WebMediaPlayer::DecodeError);
452 break;
453 }
454 }
455
407 void WebMediaPlayerImpl::SetNetworkState( 456 void WebMediaPlayerImpl::SetNetworkState(
408 WebKit::WebMediaPlayer::NetworkState state) { 457 WebKit::WebMediaPlayer::NetworkState state) {
409 DCHECK(MessageLoop::current() == main_loop_); 458 DCHECK(MessageLoop::current() == main_loop_);
410 if (network_state_ != state) { 459 if (network_state_ != state) {
411 network_state_ = state; 460 network_state_ = state;
412 GetClient()->networkStateChanged(); 461 GetClient()->networkStateChanged();
413 } 462 }
414 } 463 }
415 464
416 void WebMediaPlayerImpl::SetReadyState( 465 void WebMediaPlayerImpl::SetReadyState(
(...skipping 21 matching lines...) Expand all
438 } 487 }
439 } 488 }
440 489
441 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 490 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
442 DCHECK(MessageLoop::current() == main_loop_); 491 DCHECK(MessageLoop::current() == main_loop_);
443 DCHECK(client_); 492 DCHECK(client_);
444 return client_; 493 return client_;
445 } 494 }
446 495
447 } // namespace webkit_glue 496 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698