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

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

Issue 165472: Merge 23255 - Implemented endofstream callback for media::PipelineImpl.... (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:r23255
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::PipelineEndedCallback() {
97 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
98 &WebMediaPlayerImpl::Proxy::PipelineEndedTask));
99 }
100
96 void WebMediaPlayerImpl::Proxy::PipelineErrorCallback() { 101 void WebMediaPlayerImpl::Proxy::PipelineErrorCallback() {
97 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 102 render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
98 &WebMediaPlayerImpl::Proxy::PipelineErrorTask)); 103 &WebMediaPlayerImpl::Proxy::PipelineErrorTask));
99 } 104 }
100 105
101 void WebMediaPlayerImpl::Proxy::RepaintTask() { 106 void WebMediaPlayerImpl::Proxy::RepaintTask() {
102 DCHECK(MessageLoop::current() == render_loop_); 107 DCHECK(MessageLoop::current() == render_loop_);
103 { 108 {
104 AutoLock auto_lock(lock_); 109 AutoLock auto_lock(lock_);
105 --outstanding_repaints_; 110 --outstanding_repaints_;
(...skipping 11 matching lines...) Expand all
117 } 122 }
118 } 123 }
119 124
120 void WebMediaPlayerImpl::Proxy::PipelineSeekTask() { 125 void WebMediaPlayerImpl::Proxy::PipelineSeekTask() {
121 DCHECK(MessageLoop::current() == render_loop_); 126 DCHECK(MessageLoop::current() == render_loop_);
122 if (webmediaplayer_) { 127 if (webmediaplayer_) {
123 webmediaplayer_->OnPipelineSeek(); 128 webmediaplayer_->OnPipelineSeek();
124 } 129 }
125 } 130 }
126 131
132 void WebMediaPlayerImpl::Proxy::PipelineEndedTask() {
133 DCHECK(MessageLoop::current() == render_loop_);
134 if (webmediaplayer_) {
135 webmediaplayer_->OnPipelineEnded();
136 }
137 }
138
127 void WebMediaPlayerImpl::Proxy::PipelineErrorTask() { 139 void WebMediaPlayerImpl::Proxy::PipelineErrorTask() {
128 DCHECK(MessageLoop::current() == render_loop_); 140 DCHECK(MessageLoop::current() == render_loop_);
129 if (webmediaplayer_) { 141 if (webmediaplayer_) {
130 webmediaplayer_->OnPipelineError(); 142 webmediaplayer_->OnPipelineError();
131 } 143 }
132 } 144 }
133 145
134 ///////////////////////////////////////////////////////////////////////////// 146 /////////////////////////////////////////////////////////////////////////////
135 // WebMediaPlayerImpl implementation 147 // WebMediaPlayerImpl implementation
136 148
(...skipping 18 matching lines...) Expand all
155 } 167 }
156 168
157 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop()); 169 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
158 170
159 // Also we want to be notified of |main_loop_| destruction. 171 // Also we want to be notified of |main_loop_| destruction.
160 main_loop_->AddDestructionObserver(this); 172 main_loop_->AddDestructionObserver(this);
161 173
162 // Creates the proxy. 174 // Creates the proxy.
163 proxy_ = new Proxy(main_loop_, this); 175 proxy_ = new Proxy(main_loop_, this);
164 176
165 // Sets the pipeline's error reporting callback. 177 // Set our pipeline callbacks.
178 pipeline_->SetPipelineEndedCallback(NewCallback(proxy_.get(),
179 &WebMediaPlayerImpl::Proxy::PipelineEndedCallback));
166 pipeline_->SetPipelineErrorCallback(NewCallback(proxy_.get(), 180 pipeline_->SetPipelineErrorCallback(NewCallback(proxy_.get(),
167 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback)); 181 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback));
168 182
169 // Add in the default filter factories. 183 // Add in the default filter factories.
170 filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory()); 184 filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory());
171 filter_factory_->AddFactory(media::FFmpegAudioDecoder::CreateFactory()); 185 filter_factory_->AddFactory(media::FFmpegAudioDecoder::CreateFactory());
172 filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory()); 186 filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory());
173 filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory()); 187 filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory());
174 filter_factory_->AddFactory(VideoRendererImpl::CreateFactory(proxy_)); 188 filter_factory_->AddFactory(VideoRendererImpl::CreateFactory(proxy_));
175 } 189 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 236 }
223 237
224 bool WebMediaPlayerImpl::supportsSave() const { 238 bool WebMediaPlayerImpl::supportsSave() const {
225 DCHECK(MessageLoop::current() == main_loop_); 239 DCHECK(MessageLoop::current() == main_loop_);
226 return true; 240 return true;
227 } 241 }
228 242
229 void WebMediaPlayerImpl::seek(float seconds) { 243 void WebMediaPlayerImpl::seek(float seconds) {
230 DCHECK(MessageLoop::current() == main_loop_); 244 DCHECK(MessageLoop::current() == main_loop_);
231 245
246 // TODO(scherkus): WebKit fires a seek(0) at the very start, however pipeline
247 // already does a seek(0) internally. Investigate whether doing two seek(0)
248 // at the start impacts startup latency.
249
232 // Try to preserve as much accuracy as possible. 250 // Try to preserve as much accuracy as possible.
233 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; 251 float microseconds = seconds * base::Time::kMicrosecondsPerSecond;
234 if (seconds != 0)
235 pipeline_->Seek( 252 pipeline_->Seek(
236 base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)), 253 base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)),
237 NewCallback(proxy_.get(), 254 NewCallback(proxy_.get(),
238 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback)); 255 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback));
239 } 256 }
240 257
241 void WebMediaPlayerImpl::setEndTime(float seconds) { 258 void WebMediaPlayerImpl::setEndTime(float seconds) {
242 DCHECK(MessageLoop::current() == main_loop_); 259 DCHECK(MessageLoop::current() == main_loop_);
243 260
244 // TODO(hclam): add method call when it has been implemented. 261 // TODO(hclam): add method call when it has been implemented.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 431 }
415 } 432 }
416 433
417 void WebMediaPlayerImpl::OnPipelineSeek() { 434 void WebMediaPlayerImpl::OnPipelineSeek() {
418 DCHECK(MessageLoop::current() == main_loop_); 435 DCHECK(MessageLoop::current() == main_loop_);
419 if (pipeline_->GetError() == media::PIPELINE_OK) { 436 if (pipeline_->GetError() == media::PIPELINE_OK) {
420 GetClient()->timeChanged(); 437 GetClient()->timeChanged();
421 } 438 }
422 } 439 }
423 440
441 void WebMediaPlayerImpl::OnPipelineEnded() {
442 DCHECK(MessageLoop::current() == main_loop_);
443 if (pipeline_->GetError() == media::PIPELINE_OK) {
444 GetClient()->timeChanged();
445 }
446 }
447
424 void WebMediaPlayerImpl::OnPipelineError() { 448 void WebMediaPlayerImpl::OnPipelineError() {
425 DCHECK(MessageLoop::current() == main_loop_); 449 DCHECK(MessageLoop::current() == main_loop_);
426 switch (pipeline_->GetError()) { 450 switch (pipeline_->GetError()) {
427 case media::PIPELINE_OK: 451 case media::PIPELINE_OK:
428 case media::PIPELINE_STOPPING: 452 case media::PIPELINE_STOPPING:
429 NOTREACHED() << "We shouldn't get called with these non-errors"; 453 NOTREACHED() << "We shouldn't get called with these non-errors";
430 break; 454 break;
431 455
432 case media::PIPELINE_ERROR_INITIALIZATION_FAILED: 456 case media::PIPELINE_ERROR_INITIALIZATION_FAILED:
433 case media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING: 457 case media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 511 }
488 } 512 }
489 513
490 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 514 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
491 DCHECK(MessageLoop::current() == main_loop_); 515 DCHECK(MessageLoop::current() == main_loop_);
492 DCHECK(client_); 516 DCHECK(client_);
493 return client_; 517 return client_;
494 } 518 }
495 519
496 } // namespace webkit_glue 520 } // 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