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

Side by Side Diff: webkit/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: No ifdefs Created 7 years, 8 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 (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/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 25 matching lines...) Expand all
36 StreamTextureFactory* factory) 36 StreamTextureFactory* factory)
37 : client_(client), 37 : client_(client),
38 buffered_(1u), 38 buffered_(1u),
39 main_loop_(MessageLoop::current()), 39 main_loop_(MessageLoop::current()),
40 pending_seek_(0), 40 pending_seek_(0),
41 seeking_(false), 41 seeking_(false),
42 did_loading_progress_(false), 42 did_loading_progress_(false),
43 manager_(manager), 43 manager_(manager),
44 network_state_(WebMediaPlayer::NetworkStateEmpty), 44 network_state_(WebMediaPlayer::NetworkStateEmpty),
45 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 45 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
46 texture_id_(0),
47 texture_mailbox_sync_point_(0),
48 stream_id_(0),
46 is_playing_(false), 49 is_playing_(false),
47 needs_establish_peer_(true), 50 needs_establish_peer_(true),
48 has_size_info_(false), 51 has_size_info_(false),
49 stream_texture_factory_(factory), 52 stream_texture_factory_(factory),
50 needs_external_surface_(false), 53 needs_external_surface_(false),
51 video_frame_provider_client_(NULL) { 54 video_frame_provider_client_(NULL) {
52 main_loop_->AddDestructionObserver(this); 55 main_loop_->AddDestructionObserver(this);
53 if (manager_) 56 if (manager_)
54 player_id_ = manager_->RegisterMediaPlayer(this); 57 player_id_ = manager_->RegisterMediaPlayer(this);
55 58
56 if (stream_texture_factory_.get()) { 59 if (stream_texture_factory_.get()) {
57 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); 60 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
58 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); 61 stream_id_ = stream_texture_factory_->CreateStreamTexture(
62 kGLTextureExternalOES,
63 &texture_id_,
64 &texture_mailbox_,
65 &texture_mailbox_sync_point_);
59 ReallocateVideoFrame(); 66 ReallocateVideoFrame();
60 } 67 }
61 } 68 }
62 69
63 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { 70 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
64 SetVideoFrameProviderClient(NULL); 71 SetVideoFrameProviderClient(NULL);
65 client_->setWebLayer(NULL); 72 client_->setWebLayer(NULL);
66 73
67 if (stream_id_) 74 if (stream_id_) {
68 stream_texture_factory_->DestroyStreamTexture(texture_id_); 75 stream_texture_factory_->DestroyStreamTexture(
76 kGLTextureExternalOES,
77 texture_id_,
78 texture_mailbox_,
79 0); // TODO(danakj): How do I get this sync point?
danakj 2013/04/18 02:38:34 Daniel/Antoine, besides "things I did horribly wro
piman 2013/04/18 04:11:19 Reading the code, my interpretation of how StreamT
no sievers 2013/04/18 17:37:08 Yep, and notice that deleting the client texture (
danakj 2013/04/19 18:03:52 Oh, I have it just deleting the client texture and
80 }
69 81
70 if (manager_) 82 if (manager_)
71 manager_->UnregisterMediaPlayer(player_id_); 83 manager_->UnregisterMediaPlayer(player_id_);
72 84
73 if (main_loop_) 85 if (main_loop_)
74 main_loop_->RemoveDestructionObserver(this); 86 main_loop_->RemoveDestructionObserver(this);
75 } 87 }
76 88
77 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { 89 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) {
78 if (cors_mode != CORSModeUnspecified) 90 if (cors_mode != CORSModeUnspecified)
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (manager_) 462 if (manager_)
451 manager_->UnregisterMediaPlayer(player_id_); 463 manager_->UnregisterMediaPlayer(player_id_);
452 Detach(); 464 Detach();
453 main_loop_ = NULL; 465 main_loop_ = NULL;
454 } 466 }
455 467
456 void WebMediaPlayerAndroid::Detach() { 468 void WebMediaPlayerAndroid::Detach() {
457 Destroy(); 469 Destroy();
458 470
459 if (stream_id_) { 471 if (stream_id_) {
460 stream_texture_factory_->DestroyStreamTexture(texture_id_); 472 stream_texture_factory_->DestroyStreamTexture(
473 kGLTextureExternalOES,
474 texture_id_,
475 texture_mailbox_,
476 0); // TODO(danakj): How do I get this sync point?
461 stream_id_ = 0; 477 stream_id_ = 0;
462 } 478 }
463 479
464 current_frame_ = NULL; 480 current_frame_ = NULL;
465 481
466 manager_ = NULL; 482 manager_ = NULL;
467 } 483 }
468 484
469 void WebMediaPlayerAndroid::ReallocateVideoFrame() { 485 void WebMediaPlayerAndroid::ReallocateVideoFrame() {
470 if (needs_external_surface_) { 486 if (needs_external_surface_) {
471 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. 487 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV.
472 #if defined(GOOGLE_TV) 488 #if defined(GOOGLE_TV)
473 if (!natural_size_.isEmpty()) 489 if (!natural_size_.isEmpty())
474 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); 490 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_);
475 #else 491 #else
476 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; 492 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV";
477 #endif 493 #endif
478 } else if (texture_id_) { 494 } else if (texture_id_) {
479 current_frame_ = VideoFrame::WrapNativeTexture( 495 current_frame_ = VideoFrame::WrapNativeTexture(
480 texture_id_, kGLTextureExternalOES, natural_size_, 496 texture_mailbox_, texture_mailbox_sync_point_,
497 kGLTextureExternalOES, natural_size_,
481 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), 498 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(),
482 VideoFrame::ReadPixelsCB(), 499 VideoFrame::ReadPixelsCB(),
500 VideoFrame::TextureNoLongerNeededCallback(),
483 base::Closure()); 501 base::Closure());
484 } 502 }
485 } 503 }
486 504
487 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( 505 void WebMediaPlayerAndroid::SetVideoFrameProviderClient(
488 cc::VideoFrameProvider::Client* client) { 506 cc::VideoFrameProvider::Client* client) {
489 // This is called from both the main renderer thread and the compositor 507 // This is called from both the main renderer thread and the compositor
490 // thread (when the main thread is blocked). 508 // thread (when the main thread is blocked).
491 if (video_frame_provider_client_) 509 if (video_frame_provider_client_)
492 video_frame_provider_client_->StopUsingProvider(); 510 video_frame_provider_client_->StopUsingProvider();
(...skipping 26 matching lines...) Expand all
519 537
520 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { 538 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) {
521 needs_establish_peer_ = needs_establish_peer; 539 needs_establish_peer_ = needs_establish_peer;
522 } 540 }
523 541
524 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { 542 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) {
525 is_playing_ = is_playing; 543 is_playing_ = is_playing;
526 } 544 }
527 545
528 } // namespace webkit_media 546 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698