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

Side by Side Diff: webkit/media/android/webmediaplayer_android.cc

Issue 15499006: Enable seek in fullscreen mode for MSE impl on android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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/media/android/webmediaplayer_android.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/media/android/webmediaplayer_android.h" 5 #include "webkit/media/android/webmediaplayer_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 buffered_(1u), 51 buffered_(1u),
52 main_loop_(base::MessageLoop::current()), 52 main_loop_(base::MessageLoop::current()),
53 pending_seek_(0), 53 pending_seek_(0),
54 seeking_(false), 54 seeking_(false),
55 did_loading_progress_(false), 55 did_loading_progress_(false),
56 manager_(manager), 56 manager_(manager),
57 network_state_(WebMediaPlayer::NetworkStateEmpty), 57 network_state_(WebMediaPlayer::NetworkStateEmpty),
58 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 58 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
59 is_playing_(false), 59 is_playing_(false),
60 needs_establish_peer_(true), 60 needs_establish_peer_(true),
61 stream_texture_proxy_initialized_(false),
61 has_size_info_(false), 62 has_size_info_(false),
62 stream_texture_factory_(factory), 63 stream_texture_factory_(factory),
63 needs_external_surface_(false), 64 needs_external_surface_(false),
64 video_frame_provider_client_(NULL), 65 video_frame_provider_client_(NULL),
65 proxy_(proxy), 66 proxy_(proxy),
66 current_time_(0), 67 current_time_(0),
67 media_log_(media_log) { 68 media_log_(media_log) {
68 main_loop_->AddDestructionObserver(this); 69 main_loop_->AddDestructionObserver(this);
69 if (manager_) 70 if (manager_)
70 player_id_ = manager_->RegisterMediaPlayer(this); 71 player_id_ = manager_->RegisterMediaPlayer(this);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 148 }
148 149
149 void WebMediaPlayerAndroid::pause() { 150 void WebMediaPlayerAndroid::pause() {
150 if (proxy_) 151 if (proxy_)
151 proxy_->Pause(player_id_); 152 proxy_->Pause(player_id_);
152 is_playing_ = false; 153 is_playing_ = false;
153 } 154 }
154 155
155 void WebMediaPlayerAndroid::seek(double seconds) { 156 void WebMediaPlayerAndroid::seek(double seconds) {
156 pending_seek_ = seconds; 157 pending_seek_ = seconds;
158 if (seeking_ && media_source_delegate_)
159 media_source_delegate_->CancelPendingSeek();
157 seeking_ = true; 160 seeking_ = true;
158 161
159 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); 162 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds);
163 #if defined(GOOGLE_TV)
164 // TODO(qinmin): check if GTV can also defer the seek until the browser side
165 // player is ready.
160 if (media_source_delegate_) 166 if (media_source_delegate_)
161 media_source_delegate_->Seek(seek_time); 167 media_source_delegate_->Seek(seek_time);
168 #endif
162 if (proxy_) 169 if (proxy_)
163 proxy_->Seek(player_id_, seek_time); 170 proxy_->Seek(player_id_, seek_time);
164 } 171 }
165 172
166 bool WebMediaPlayerAndroid::supportsFullscreen() const { 173 bool WebMediaPlayerAndroid::supportsFullscreen() const {
167 return true; 174 return true;
168 } 175 }
169 176
170 bool WebMediaPlayerAndroid::supportsSave() const { 177 bool WebMediaPlayerAndroid::supportsSave() const {
171 return false; 178 return false;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 void WebMediaPlayerAndroid::OnMediaPlayerPlay() { 498 void WebMediaPlayerAndroid::OnMediaPlayerPlay() {
492 UpdatePlayingState(true); 499 UpdatePlayingState(true);
493 client_->playbackStateChanged(); 500 client_->playbackStateChanged();
494 } 501 }
495 502
496 void WebMediaPlayerAndroid::OnMediaPlayerPause() { 503 void WebMediaPlayerAndroid::OnMediaPlayerPause() {
497 UpdatePlayingState(false); 504 UpdatePlayingState(false);
498 client_->playbackStateChanged(); 505 client_->playbackStateChanged();
499 } 506 }
500 507
508 void WebMediaPlayerAndroid::OnMediaSeekRequest(base::TimeDelta time_to_seek,
509 bool request_texture_peer) {
510 if (!media_source_delegate_)
511 return;
512
513 if (!seeking_)
514 media_source_delegate_->CancelPendingSeek();
515 media_source_delegate_->Seek(time_to_seek);
516 OnTimeUpdate(time_to_seek);
517 if (request_texture_peer)
518 EstablishSurfaceTexturePeer();
519 }
520
501 void WebMediaPlayerAndroid::UpdateNetworkState( 521 void WebMediaPlayerAndroid::UpdateNetworkState(
502 WebMediaPlayer::NetworkState state) { 522 WebMediaPlayer::NetworkState state) {
503 network_state_ = state; 523 network_state_ = state;
504 client_->networkStateChanged(); 524 client_->networkStateChanged();
505 } 525 }
506 526
507 void WebMediaPlayerAndroid::UpdateReadyState( 527 void WebMediaPlayerAndroid::UpdateReadyState(
508 WebMediaPlayer::ReadyState state) { 528 WebMediaPlayer::ReadyState state) {
509 ready_state_ = state; 529 ready_state_ = state;
510 client_->readyStateChanged(); 530 client_->readyStateChanged();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 if (video_frame_provider_client_) 602 if (video_frame_provider_client_)
583 video_frame_provider_client_->StopUsingProvider(); 603 video_frame_provider_client_->StopUsingProvider();
584 video_frame_provider_client_ = client; 604 video_frame_provider_client_ = client;
585 605
586 // Set the callback target when a frame is produced. 606 // Set the callback target when a frame is produced.
587 if (stream_texture_proxy_) 607 if (stream_texture_proxy_)
588 stream_texture_proxy_->SetClient(client); 608 stream_texture_proxy_->SetClient(client);
589 } 609 }
590 610
591 scoped_refptr<media::VideoFrame> WebMediaPlayerAndroid::GetCurrentFrame() { 611 scoped_refptr<media::VideoFrame> WebMediaPlayerAndroid::GetCurrentFrame() {
592 if (stream_texture_proxy_ && !stream_texture_proxy_->IsBoundToThread() && 612 if (!stream_texture_proxy_initialized_ && stream_texture_proxy_ &&
593 stream_id_ && !needs_external_surface_) { 613 stream_id_ && !needs_external_surface_) {
594 gfx::Size natural_size = current_frame_->natural_size(); 614 gfx::Size natural_size = current_frame_->natural_size();
595 stream_texture_proxy_->BindToCurrentThread( 615 stream_texture_proxy_->BindToCurrentThread(
596 stream_id_, natural_size.width(), natural_size.height()); 616 stream_id_, natural_size.width(), natural_size.height());
617 stream_texture_proxy_initialized_ = true;
597 } 618 }
598 return current_frame_; 619 return current_frame_;
599 } 620 }
600 621
601 void WebMediaPlayerAndroid::PutCurrentFrame( 622 void WebMediaPlayerAndroid::PutCurrentFrame(
602 const scoped_refptr<media::VideoFrame>& frame) { 623 const scoped_refptr<media::VideoFrame>& frame) {
603 } 624 }
604 625
605 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { 626 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() {
627 if (media_source_delegate_ && stream_texture_factory_) {
628 // MediaCodec will release the old surface when it goes away, we need to
629 // recreate a new one each time this is called.
630 stream_texture_factory_->DestroyStreamTexture(texture_id_);
631 stream_id_ = 0;
632 texture_id_ = 0;
633 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_);
634 ReallocateVideoFrame();
635 stream_texture_proxy_initialized_ = false;
636 }
606 if (stream_texture_factory_.get() && stream_id_) 637 if (stream_texture_factory_.get() && stream_id_)
607 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); 638 stream_texture_factory_->EstablishPeer(stream_id_, player_id_);
608 needs_establish_peer_ = false; 639 needs_establish_peer_ = false;
609 } 640 }
610 641
611 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { 642 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) {
612 needs_establish_peer_ = needs_establish_peer; 643 needs_establish_peer_ = needs_establish_peer;
613 } 644 }
614 645
615 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { 646 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 void WebMediaPlayerAndroid::exitFullscreen() { 721 void WebMediaPlayerAndroid::exitFullscreen() {
691 if (proxy_) 722 if (proxy_)
692 proxy_->ExitFullscreen(player_id_); 723 proxy_->ExitFullscreen(player_id_);
693 } 724 }
694 725
695 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 726 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
696 return manager_->CanEnterFullscreen(frame_); 727 return manager_->CanEnterFullscreen(frame_);
697 } 728 }
698 729
699 } // namespace webkit_media 730 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698