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

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

Issue 12443003: Implement out-of-band video compositing on Android: Step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit2 Created 7 years, 9 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/command_line.h"
7 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "media/base/android/media_player_bridge.h" 10 #include "media/base/android/media_player_bridge.h"
10 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
11 #include "net/base/mime_util.h" 12 #include "net/base/mime_util.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient. h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient. h"
13 #include "webkit/media/android/stream_texture_factory_android.h" 14 #include "webkit/media/android/stream_texture_factory_android.h"
14 #include "webkit/media/android/webmediaplayer_manager_android.h" 15 #include "webkit/media/android/webmediaplayer_manager_android.h"
16 #include "webkit/media/media_switches.h"
15 #include "webkit/media/webmediaplayer_util.h" 17 #include "webkit/media/webmediaplayer_util.h"
16 #include "webkit/media/webvideoframe_impl.h" 18 #include "webkit/media/webvideoframe_impl.h"
17 19
18 static const uint32 kGLTextureExternalOES = 0x8D65; 20 static const uint32 kGLTextureExternalOES = 0x8D65;
19 21
20 using WebKit::WebMediaPlayer; 22 using WebKit::WebMediaPlayer;
21 using WebKit::WebMediaSource; 23 using WebKit::WebMediaSource;
22 using WebKit::WebSize; 24 using WebKit::WebSize;
23 using WebKit::WebTimeRanges; 25 using WebKit::WebTimeRanges;
24 using WebKit::WebURL; 26 using WebKit::WebURL;
(...skipping 12 matching lines...) Expand all
37 main_loop_(MessageLoop::current()), 39 main_loop_(MessageLoop::current()),
38 pending_seek_(0), 40 pending_seek_(0),
39 seeking_(false), 41 seeking_(false),
40 did_loading_progress_(false), 42 did_loading_progress_(false),
41 manager_(manager), 43 manager_(manager),
42 network_state_(WebMediaPlayer::NetworkStateEmpty), 44 network_state_(WebMediaPlayer::NetworkStateEmpty),
43 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 45 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
44 is_playing_(false), 46 is_playing_(false),
45 needs_establish_peer_(true), 47 needs_establish_peer_(true),
46 has_size_info_(false), 48 has_size_info_(false),
47 stream_texture_factory_(factory) { 49 stream_texture_factory_(factory),
50 needs_external_surface_(false) {
48 main_loop_->AddDestructionObserver(this); 51 main_loop_->AddDestructionObserver(this);
49 if (manager_) 52 if (manager_)
50 player_id_ = manager_->RegisterMediaPlayer(this); 53 player_id_ = manager_->RegisterMediaPlayer(this);
51 54
52 if (stream_texture_factory_.get()) { 55 if (CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kUseExternalVideoSurface)) {
57 needs_external_surface_ = true;
58 SetNeedsEstablishPeer(false);
59 ReallocateVideoFrame();
60 } else if (stream_texture_factory_.get()) {
53 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); 61 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
54 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); 62 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_);
55 ReallocateVideoFrame(); 63 ReallocateVideoFrame();
56 } 64 }
57 } 65 }
58 66
59 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { 67 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
60 if (stream_id_) 68 if (stream_id_)
61 stream_texture_factory_->DestroyStreamTexture(texture_id_); 69 stream_texture_factory_->DestroyStreamTexture(texture_id_);
62 70
(...skipping 17 matching lines...) Expand all
80 WebMediaSource* media_source, 88 WebMediaSource* media_source,
81 CORSMode cors_mode) { 89 CORSMode cors_mode) {
82 NOTIMPLEMENTED(); 90 NOTIMPLEMENTED();
83 } 91 }
84 92
85 void WebMediaPlayerAndroid::cancelLoad() { 93 void WebMediaPlayerAndroid::cancelLoad() {
86 NOTIMPLEMENTED(); 94 NOTIMPLEMENTED();
87 } 95 }
88 96
89 void WebMediaPlayerAndroid::play() { 97 void WebMediaPlayerAndroid::play() {
98 if (hasVideo() && needs_external_surface_) {
99 DCHECK(!needs_establish_peer_);
100 RequestExternalSurface();
101 }
90 if (hasVideo() && needs_establish_peer_) 102 if (hasVideo() && needs_establish_peer_)
91 EstablishSurfaceTexturePeer(); 103 EstablishSurfaceTexturePeer();
92 104
93 PlayInternal(); 105 PlayInternal();
94 is_playing_ = true; 106 is_playing_ = true;
95 } 107 }
96 108
97 void WebMediaPlayerAndroid::pause() { 109 void WebMediaPlayerAndroid::pause() {
98 PauseInternal(); 110 PauseInternal();
99 is_playing_ = false; 111 is_playing_ = false;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 stream_texture_factory_->DestroyStreamTexture(texture_id_); 392 stream_texture_factory_->DestroyStreamTexture(texture_id_);
381 stream_id_ = 0; 393 stream_id_ = 0;
382 } 394 }
383 395
384 web_video_frame_.reset(); 396 web_video_frame_.reset();
385 397
386 manager_ = NULL; 398 manager_ = NULL;
387 } 399 }
388 400
389 void WebMediaPlayerAndroid::ReallocateVideoFrame() { 401 void WebMediaPlayerAndroid::ReallocateVideoFrame() {
390 if (texture_id_) { 402 if (needs_external_surface_) {
403 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV.
404 #if defined(GOOGLE_TV)
405 if (!natural_size_.isEmpty())
ycheo 2013/03/14 09:45:52 For multi-lines, you need a bracket.
wonsik 2013/03/14 10:57:01 Done.
406 web_video_frame_.reset(new WebVideoFrameImpl(VideoFrame::CreateHoleFrame(
407 natural_size_)));
408 #else
409 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV";
410 #endif
411 } else if (texture_id_) {
391 web_video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture( 412 web_video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture(
392 texture_id_, kGLTextureExternalOES, natural_size_, 413 texture_id_, kGLTextureExternalOES, natural_size_,
393 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), 414 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(),
394 VideoFrame::ReadPixelsCB(), 415 VideoFrame::ReadPixelsCB(),
395 base::Closure()))); 416 base::Closure())));
396 } 417 }
397 } 418 }
398 419
399 WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() { 420 WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() {
400 if (stream_texture_proxy_.get() && !stream_texture_proxy_->IsInitialized() 421 if (stream_texture_proxy_.get() && !stream_texture_proxy_->IsInitialized()
401 && stream_id_) { 422 && stream_id_ && !needs_external_surface_) {
402 gfx::Size natural_size = web_video_frame_->video_frame->natural_size(); 423 gfx::Size natural_size = web_video_frame_->video_frame->natural_size();
403 stream_texture_proxy_->Initialize( 424 stream_texture_proxy_->Initialize(
404 stream_id_, natural_size.width(), natural_size.height()); 425 stream_id_, natural_size.width(), natural_size.height());
405 } 426 }
406 427
407 return web_video_frame_.get(); 428 return web_video_frame_.get();
408 } 429 }
409 430
410 void WebMediaPlayerAndroid::putCurrentFrame( 431 void WebMediaPlayerAndroid::putCurrentFrame(
411 WebVideoFrame* web_video_frame) { 432 WebVideoFrame* web_video_frame) {
(...skipping 13 matching lines...) Expand all
425 446
426 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { 447 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) {
427 needs_establish_peer_ = needs_establish_peer; 448 needs_establish_peer_ = needs_establish_peer;
428 } 449 }
429 450
430 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { 451 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) {
431 is_playing_ = is_playing; 452 is_playing_ = is_playing;
432 } 453 }
433 454
434 } // namespace webkit_media 455 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698