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

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: video-mailbox: virtualandroid Created 7 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/media/android/webmediaplayer_android.h" 5 #include "content/renderer/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 delegate_(delegate), 76 delegate_(delegate),
77 buffered_(1u), 77 buffered_(1u),
78 main_loop_(base::MessageLoopProxy::current()), 78 main_loop_(base::MessageLoopProxy::current()),
79 ignore_metadata_duration_change_(false), 79 ignore_metadata_duration_change_(false),
80 pending_seek_(0), 80 pending_seek_(0),
81 seeking_(false), 81 seeking_(false),
82 did_loading_progress_(false), 82 did_loading_progress_(false),
83 manager_(manager), 83 manager_(manager),
84 network_state_(WebMediaPlayer::NetworkStateEmpty), 84 network_state_(WebMediaPlayer::NetworkStateEmpty),
85 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 85 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
86 texture_id_(0),
87 texture_mailbox_sync_point_(0),
88 stream_id_(0),
86 is_playing_(false), 89 is_playing_(false),
87 needs_establish_peer_(true), 90 needs_establish_peer_(true),
88 stream_texture_proxy_initialized_(false), 91 stream_texture_proxy_initialized_(false),
89 has_size_info_(false), 92 has_size_info_(false),
90 has_media_metadata_(false), 93 has_media_metadata_(false),
91 has_media_info_(false), 94 has_media_info_(false),
92 stream_texture_factory_(factory), 95 stream_texture_factory_(factory),
93 needs_external_surface_(false), 96 needs_external_surface_(false),
94 video_frame_provider_client_(NULL), 97 video_frame_provider_client_(NULL),
95 #if defined(GOOGLE_TV) 98 #if defined(GOOGLE_TV)
(...skipping 25 matching lines...) Expand all
121 } 124 }
122 125
123 // Defer stream texture creation until we are sure it's necessary. 126 // Defer stream texture creation until we are sure it's necessary.
124 stream_id_ = 0; 127 stream_id_ = 0;
125 needs_establish_peer_ = false; 128 needs_establish_peer_ = false;
126 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); 129 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1));
127 #endif 130 #endif
128 if (stream_texture_factory_) { 131 if (stream_texture_factory_) {
129 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); 132 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
130 if (needs_establish_peer_) { 133 if (needs_establish_peer_) {
131 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); 134 stream_id_ = stream_texture_factory_->CreateStreamTexture(
135 kGLTextureExternalOES,
136 &texture_id_,
137 &texture_mailbox_,
138 &texture_mailbox_sync_point_);
132 ReallocateVideoFrame(); 139 ReallocateVideoFrame();
133 } 140 }
134 } 141 }
135 142
136 if (WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) { 143 if (WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) {
137 // |decryptor_| is owned, so Unretained() is safe here. 144 // |decryptor_| is owned, so Unretained() is safe here.
138 decryptor_.reset(new ProxyDecryptor( 145 decryptor_.reset(new ProxyDecryptor(
139 #if defined(ENABLE_PEPPER_CDMS) 146 #if defined(ENABLE_PEPPER_CDMS)
140 client, 147 client,
141 frame, 148 frame,
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 if (!natural_size_.isEmpty()) { 776 if (!natural_size_.isEmpty()) {
770 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); 777 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_);
771 // Force the client to grab the hole frame. 778 // Force the client to grab the hole frame.
772 client_->repaint(); 779 client_->repaint();
773 } 780 }
774 #else 781 #else
775 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; 782 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV";
776 #endif 783 #endif
777 } else if (texture_id_) { 784 } else if (texture_id_) {
778 current_frame_ = VideoFrame::WrapNativeTexture( 785 current_frame_ = VideoFrame::WrapNativeTexture(
779 texture_id_, kGLTextureExternalOES, natural_size_, 786 new VideoFrame::MailboxHolder(
787 texture_mailbox_,
788 texture_mailbox_sync_point_,
789 VideoFrame::MailboxHolder::TextureNoLongerNeededCallback()),
790 kGLTextureExternalOES, natural_size_,
780 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), 791 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(),
781 VideoFrame::ReadPixelsCB(), 792 VideoFrame::ReadPixelsCB(),
782 base::Closure()); 793 base::Closure());
783 } 794 }
784 } 795 }
785 796
786 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( 797 void WebMediaPlayerAndroid::SetVideoFrameProviderClient(
787 cc::VideoFrameProvider::Client* client) { 798 cc::VideoFrameProvider::Client* client) {
788 // This is called from both the main renderer thread and the compositor 799 // This is called from both the main renderer thread and the compositor
789 // thread (when the main thread is blocked). 800 // thread (when the main thread is blocked).
(...skipping 21 matching lines...) Expand all
811 const scoped_refptr<media::VideoFrame>& frame) { 822 const scoped_refptr<media::VideoFrame>& frame) {
812 } 823 }
813 824
814 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { 825 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() {
815 if (media_source_delegate_ && stream_texture_factory_) { 826 if (media_source_delegate_ && stream_texture_factory_) {
816 // MediaCodec will release the old surface when it goes away, we need to 827 // MediaCodec will release the old surface when it goes away, we need to
817 // recreate a new one each time this is called. 828 // recreate a new one each time this is called.
818 stream_texture_factory_->DestroyStreamTexture(texture_id_); 829 stream_texture_factory_->DestroyStreamTexture(texture_id_);
819 stream_id_ = 0; 830 stream_id_ = 0;
820 texture_id_ = 0; 831 texture_id_ = 0;
821 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); 832 texture_mailbox_ = gpu::Mailbox();
833 texture_mailbox_sync_point_ = 0;
834 stream_id_ = stream_texture_factory_->CreateStreamTexture(
835 kGLTextureExternalOES,
836 &texture_id_,
837 &texture_mailbox_,
838 &texture_mailbox_sync_point_);
822 ReallocateVideoFrame(); 839 ReallocateVideoFrame();
823 stream_texture_proxy_initialized_ = false; 840 stream_texture_proxy_initialized_ = false;
824 } 841 }
825 if (stream_texture_factory_.get() && stream_id_) 842 if (stream_texture_factory_.get() && stream_id_)
826 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); 843 stream_texture_factory_->EstablishPeer(stream_id_, player_id_);
827 needs_establish_peer_ = false; 844 needs_establish_peer_ = false;
828 } 845 }
829 846
830 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { 847 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) {
831 needs_establish_peer_ = needs_establish_peer; 848 needs_establish_peer_ = needs_establish_peer;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 1139
1123 void WebMediaPlayerAndroid::exitFullscreen() { 1140 void WebMediaPlayerAndroid::exitFullscreen() {
1124 proxy_->ExitFullscreen(player_id_); 1141 proxy_->ExitFullscreen(player_id_);
1125 } 1142 }
1126 1143
1127 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1144 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1128 return manager_->CanEnterFullscreen(frame_); 1145 return manager_->CanEnterFullscreen(frame_);
1129 } 1146 }
1130 1147
1131 } // namespace content 1148 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | content/renderer/media/renderer_gpu_video_decoder_factories.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698