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

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

Issue 3026043: Full screen video Chromium patch (Closed)
Patch Set: Rename GetClient/SetClient to client/setClient to match WebKit style. Created 10 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
« 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')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/media_format.h" 10 #include "media/base/media_format.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 WebMediaPlayerImpl::~WebMediaPlayerImpl() { 235 WebMediaPlayerImpl::~WebMediaPlayerImpl() {
236 Destroy(); 236 Destroy();
237 237
238 // Finally tell the |main_loop_| we don't want to be notified of destruction 238 // Finally tell the |main_loop_| we don't want to be notified of destruction
239 // event. 239 // event.
240 if (main_loop_) { 240 if (main_loop_) {
241 main_loop_->RemoveDestructionObserver(this); 241 main_loop_->RemoveDestructionObserver(this);
242 } 242 }
243 } 243 }
244 244
245 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::client() const {
246 // TODO(boliu): Remove these? Need locks?
247 DCHECK(MessageLoop::current() == main_loop_);
248 DCHECK(client_);
249 return client_;
250 }
251
252 void WebMediaPlayerImpl::setClient(WebKit::WebMediaPlayerClient* new_client) {
253 // TODO(boliu): Remove these? Need locks?
254 DCHECK(MessageLoop::current() == main_loop_);
255 client_ = new_client;
256 }
257
245 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { 258 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
246 DCHECK(MessageLoop::current() == main_loop_); 259 DCHECK(MessageLoop::current() == main_loop_);
247 DCHECK(proxy_); 260 DCHECK(proxy_);
248 261
249 // Handle any volume changes that occured before load(). 262 // Handle any volume changes that occured before load().
250 setVolume(GetClient()->volume()); 263 setVolume(client()->volume());
251 264
252 // Initialize the pipeline. 265 // Initialize the pipeline.
253 SetNetworkState(WebKit::WebMediaPlayer::Loading); 266 SetNetworkState(WebKit::WebMediaPlayer::Loading);
254 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); 267 SetReadyState(WebKit::WebMediaPlayer::HaveNothing);
255 pipeline_->Start( 268 pipeline_->Start(
256 filter_factory_.get(), 269 filter_factory_.get(),
257 url.spec(), 270 url.spec(),
258 NewCallback(proxy_.get(), 271 NewCallback(proxy_.get(),
259 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); 272 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback));
260 } 273 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 DCHECK(MessageLoop::current() == main_loop_); 305 DCHECK(MessageLoop::current() == main_loop_);
293 306
294 // WebKit fires a seek(0) at the very start, however pipeline already does a 307 // WebKit fires a seek(0) at the very start, however pipeline already does a
295 // seek(0) internally. Avoid doing seek(0) the second time because this will 308 // seek(0) internally. Avoid doing seek(0) the second time because this will
296 // cause extra pre-rolling and will break servers without range request 309 // cause extra pre-rolling and will break servers without range request
297 // support. 310 // support.
298 // 311 //
299 // We still have to notify WebKit that time has changed otherwise 312 // We still have to notify WebKit that time has changed otherwise
300 // HTMLMediaElement gets into an inconsistent state. 313 // HTMLMediaElement gets into an inconsistent state.
301 if (pipeline_->GetCurrentTime().ToInternalValue() == 0 && seconds == 0) { 314 if (pipeline_->GetCurrentTime().ToInternalValue() == 0 && seconds == 0) {
302 GetClient()->timeChanged(); 315 client()->timeChanged();
303 return; 316 return;
304 } 317 }
305 318
306 // Drop our ready state if the media file isn't fully loaded. 319 // Drop our ready state if the media file isn't fully loaded.
307 if (!pipeline_->IsLoaded()) { 320 if (!pipeline_->IsLoaded()) {
308 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); 321 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
309 } 322 }
310 323
311 // Try to preserve as much accuracy as possible. 324 // Try to preserve as much accuracy as possible.
312 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; 325 float microseconds = seconds * base::Time::kMicrosecondsPerSecond;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 return WebKit::WebMediaPlayer::Unknown; 575 return WebKit::WebMediaPlayer::Unknown;
563 } 576 }
564 577
565 void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { 578 void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() {
566 Destroy(); 579 Destroy();
567 main_loop_ = NULL; 580 main_loop_ = NULL;
568 } 581 }
569 582
570 void WebMediaPlayerImpl::Repaint() { 583 void WebMediaPlayerImpl::Repaint() {
571 DCHECK(MessageLoop::current() == main_loop_); 584 DCHECK(MessageLoop::current() == main_loop_);
572 GetClient()->repaint(); 585 client()->repaint();
573 } 586 }
574 587
575 void WebMediaPlayerImpl::OnPipelineInitialize() { 588 void WebMediaPlayerImpl::OnPipelineInitialize() {
576 DCHECK(MessageLoop::current() == main_loop_); 589 DCHECK(MessageLoop::current() == main_loop_);
577 if (pipeline_->GetError() == media::PIPELINE_OK) { 590 if (pipeline_->GetError() == media::PIPELINE_OK) {
578 // Only keep one time range starting from 0. 591 // Only keep one time range starting from 0.
579 WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1)); 592 WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1));
580 new_buffered[0].start = 0.0f; 593 new_buffered[0].start = 0.0f;
581 new_buffered[0].end = 594 new_buffered[0].end =
582 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); 595 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF());
(...skipping 22 matching lines...) Expand all
605 618
606 void WebMediaPlayerImpl::OnPipelineSeek() { 619 void WebMediaPlayerImpl::OnPipelineSeek() {
607 DCHECK(MessageLoop::current() == main_loop_); 620 DCHECK(MessageLoop::current() == main_loop_);
608 if (pipeline_->GetError() == media::PIPELINE_OK) { 621 if (pipeline_->GetError() == media::PIPELINE_OK) {
609 // Update our paused time. 622 // Update our paused time.
610 if (paused_) { 623 if (paused_) {
611 paused_time_ = pipeline_->GetCurrentTime(); 624 paused_time_ = pipeline_->GetCurrentTime();
612 } 625 }
613 626
614 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); 627 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
615 GetClient()->timeChanged(); 628 client()->timeChanged();
616 } 629 }
617 } 630 }
618 631
619 void WebMediaPlayerImpl::OnPipelineEnded() { 632 void WebMediaPlayerImpl::OnPipelineEnded() {
620 DCHECK(MessageLoop::current() == main_loop_); 633 DCHECK(MessageLoop::current() == main_loop_);
621 if (pipeline_->GetError() == media::PIPELINE_OK) { 634 if (pipeline_->GetError() == media::PIPELINE_OK) {
622 GetClient()->timeChanged(); 635 client()->timeChanged();
623 } 636 }
624 } 637 }
625 638
626 void WebMediaPlayerImpl::OnPipelineError() { 639 void WebMediaPlayerImpl::OnPipelineError() {
627 DCHECK(MessageLoop::current() == main_loop_); 640 DCHECK(MessageLoop::current() == main_loop_);
628 switch (pipeline_->GetError()) { 641 switch (pipeline_->GetError()) {
629 case media::PIPELINE_OK: 642 case media::PIPELINE_OK:
630 case media::PIPELINE_ERROR_INITIALIZATION_FAILED: 643 case media::PIPELINE_ERROR_INITIALIZATION_FAILED:
631 case media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING: 644 case media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING:
632 case media::PIPELINE_ERROR_COULD_NOT_RENDER: 645 case media::PIPELINE_ERROR_COULD_NOT_RENDER:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 SetNetworkState(WebKit::WebMediaPlayer::Idle); 681 SetNetworkState(WebKit::WebMediaPlayer::Idle);
669 } 682 }
670 } 683 }
671 } 684 }
672 685
673 void WebMediaPlayerImpl::SetNetworkState( 686 void WebMediaPlayerImpl::SetNetworkState(
674 WebKit::WebMediaPlayer::NetworkState state) { 687 WebKit::WebMediaPlayer::NetworkState state) {
675 DCHECK(MessageLoop::current() == main_loop_); 688 DCHECK(MessageLoop::current() == main_loop_);
676 // Always notify to ensure client has the latest value. 689 // Always notify to ensure client has the latest value.
677 network_state_ = state; 690 network_state_ = state;
678 GetClient()->networkStateChanged(); 691 client()->networkStateChanged();
679 } 692 }
680 693
681 void WebMediaPlayerImpl::SetReadyState( 694 void WebMediaPlayerImpl::SetReadyState(
682 WebKit::WebMediaPlayer::ReadyState state) { 695 WebKit::WebMediaPlayer::ReadyState state) {
683 DCHECK(MessageLoop::current() == main_loop_); 696 DCHECK(MessageLoop::current() == main_loop_);
684 // Always notify to ensure client has the latest value. 697 // Always notify to ensure client has the latest value.
685 ready_state_ = state; 698 ready_state_ = state;
686 GetClient()->readyStateChanged(); 699 client()->readyStateChanged();
687 } 700 }
688 701
689 void WebMediaPlayerImpl::Destroy() { 702 void WebMediaPlayerImpl::Destroy() {
690 DCHECK(MessageLoop::current() == main_loop_); 703 DCHECK(MessageLoop::current() == main_loop_);
691 704
692 // Make sure to kill the pipeline so there's no more media threads running. 705 // Make sure to kill the pipeline so there's no more media threads running.
693 // Note: stopping the pipeline might block for a long time. 706 // Note: stopping the pipeline might block for a long time.
694 pipeline_->Stop(NewCallback(this, 707 pipeline_->Stop(NewCallback(this,
695 &WebMediaPlayerImpl::PipelineStoppedCallback)); 708 &WebMediaPlayerImpl::PipelineStoppedCallback));
696 pipeline_stopped_.Wait(); 709 pipeline_stopped_.Wait();
697 pipeline_thread_.Stop(); 710 pipeline_thread_.Stop();
698 711
699 // And then detach the proxy, it may live on the render thread for a little 712 // And then detach the proxy, it may live on the render thread for a little
700 // longer until all the tasks are finished. 713 // longer until all the tasks are finished.
701 if (proxy_) { 714 if (proxy_) {
702 proxy_->Detach(); 715 proxy_->Detach();
703 proxy_ = NULL; 716 proxy_ = NULL;
704 } 717 }
705 } 718 }
706 719
707 void WebMediaPlayerImpl::PipelineStoppedCallback() { 720 void WebMediaPlayerImpl::PipelineStoppedCallback() {
708 pipeline_stopped_.Signal(); 721 pipeline_stopped_.Signal();
709 } 722 }
710 723
711 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
712 DCHECK(MessageLoop::current() == main_loop_);
713 DCHECK(client_);
714 return client_;
715 }
716
717 } // namespace webkit_glue 724 } // 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