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

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

Issue 11442056: Add external surface rendering mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separated GLRenderer change out; refined messaging scheme. Created 7 years, 10 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
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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/base/android/media_player_bridge.h" 9 #include "media/base/android/media_player_bridge.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 25 matching lines...) Expand all
36 main_loop_(MessageLoop::current()), 36 main_loop_(MessageLoop::current()),
37 pending_seek_(0), 37 pending_seek_(0),
38 seeking_(false), 38 seeking_(false),
39 did_loading_progress_(false), 39 did_loading_progress_(false),
40 manager_(manager), 40 manager_(manager),
41 network_state_(WebMediaPlayer::NetworkStateEmpty), 41 network_state_(WebMediaPlayer::NetworkStateEmpty),
42 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 42 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
43 is_playing_(false), 43 is_playing_(false),
44 needs_establish_peer_(true), 44 needs_establish_peer_(true),
45 has_size_info_(false), 45 has_size_info_(false),
46 is_in_video_view_(false),
46 stream_texture_factory_(factory) { 47 stream_texture_factory_(factory) {
47 main_loop_->AddDestructionObserver(this); 48 main_loop_->AddDestructionObserver(this);
48 if (manager_) 49 if (manager_)
49 player_id_ = manager_->RegisterMediaPlayer(this); 50 player_id_ = manager_->RegisterMediaPlayer(this);
50 51
51 if (stream_texture_factory_.get()) { 52 if (stream_texture_factory_.get()) {
52 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); 53 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
53 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); 54 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_);
54 ReallocateVideoFrame(); 55 ReallocateVideoFrame();
55 } 56 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 stream_texture_factory_->DestroyStreamTexture(texture_id_); 374 stream_texture_factory_->DestroyStreamTexture(texture_id_);
374 stream_id_ = 0; 375 stream_id_ = 0;
375 } 376 }
376 377
377 video_frame_.reset(); 378 video_frame_.reset();
378 379
379 manager_ = NULL; 380 manager_ = NULL;
380 } 381 }
381 382
382 void WebMediaPlayerAndroid::ReallocateVideoFrame() { 383 void WebMediaPlayerAndroid::ReallocateVideoFrame() {
383 if (texture_id_) { 384 unsigned int texture_id = texture_id_;
384 video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture( 385 if (is_in_video_view_) {
385 texture_id_, kGLTextureExternalOES, natural_size_, 386 texture_id = 0;
386 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), 387 } else if (texture_id_ == 0) {
387 VideoFrame::ReadPixelsCB(), 388 return;
388 base::Closure())));
389 } 389 }
390 video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture(
391 texture_id, kGLTextureExternalOES, natural_size_,
392 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(),
393 VideoFrame::ReadPixelsCB(),
394 base::Closure())));
390 } 395 }
391 396
392 WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() { 397 WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() {
393 if (stream_texture_proxy_.get() && !stream_texture_proxy_->IsInitialized() 398 if (stream_texture_proxy_.get() && !stream_texture_proxy_->IsInitialized()
394 && stream_id_) { 399 && stream_id_) {
395 stream_texture_proxy_->Initialize( 400 stream_texture_proxy_->Initialize(
396 stream_id_, video_frame_->width(), video_frame_->height()); 401 stream_id_, video_frame_->width(), video_frame_->height());
397 } 402 }
398 403
399 return video_frame_.get(); 404 return video_frame_.get();
(...skipping 12 matching lines...) Expand all
412 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { 417 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() {
413 if (stream_texture_factory_.get() && stream_id_) 418 if (stream_texture_factory_.get() && stream_id_)
414 stream_texture_factory_->EstablishPeer(stream_id_, player_id_); 419 stream_texture_factory_->EstablishPeer(stream_id_, player_id_);
415 needs_establish_peer_ = false; 420 needs_establish_peer_ = false;
416 } 421 }
417 422
418 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { 423 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) {
419 needs_establish_peer_ = needs_establish_peer; 424 needs_establish_peer_ = needs_establish_peer;
420 } 425 }
421 426
427 void WebMediaPlayerAndroid::SetIsInVideoView(bool is_in_video_view) {
428 is_in_video_view_ = is_in_video_view;;
429 ReallocateVideoFrame();
430 }
431
422 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { 432 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) {
423 is_playing_ = is_playing; 433 is_playing_ = is_playing;
424 } 434 }
425 435
426 } // namespace webkit_media 436 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/android/webmediaplayer_android.h ('k') | webkit/media/android/webmediaplayer_impl_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698