| OLD | NEW |
| 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 26 matching lines...) Expand all Loading... |
| 37 StreamTextureFactory* factory) | 37 StreamTextureFactory* factory) |
| 38 : client_(client), | 38 : client_(client), |
| 39 buffered_(1u), | 39 buffered_(1u), |
| 40 main_loop_(MessageLoop::current()), | 40 main_loop_(MessageLoop::current()), |
| 41 pending_seek_(0), | 41 pending_seek_(0), |
| 42 seeking_(false), | 42 seeking_(false), |
| 43 did_loading_progress_(false), | 43 did_loading_progress_(false), |
| 44 manager_(manager), | 44 manager_(manager), |
| 45 network_state_(WebMediaPlayer::NetworkStateEmpty), | 45 network_state_(WebMediaPlayer::NetworkStateEmpty), |
| 46 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 46 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 47 texture_id_(0), |
| 48 texture_mailbox_sync_point_(0), |
| 49 stream_id_(0), |
| 47 is_playing_(false), | 50 is_playing_(false), |
| 48 needs_establish_peer_(true), | 51 needs_establish_peer_(true), |
| 49 has_size_info_(false), | 52 has_size_info_(false), |
| 50 stream_texture_factory_(factory), | 53 stream_texture_factory_(factory), |
| 51 needs_external_surface_(false), | 54 needs_external_surface_(false), |
| 52 video_frame_provider_client_(NULL) { | 55 video_frame_provider_client_(NULL) { |
| 53 main_loop_->AddDestructionObserver(this); | 56 main_loop_->AddDestructionObserver(this); |
| 54 if (manager_) | 57 if (manager_) |
| 55 player_id_ = manager_->RegisterMediaPlayer(this); | 58 player_id_ = manager_->RegisterMediaPlayer(this); |
| 56 | 59 |
| 57 if (stream_texture_factory_.get()) { | 60 if (stream_texture_factory_.get()) { |
| 58 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); | 61 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); |
| 59 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); | 62 stream_id_ = stream_texture_factory_->CreateStreamTexture( |
| 63 kGLTextureExternalOES, |
| 64 &texture_id_, |
| 65 &texture_mailbox_, |
| 66 &texture_mailbox_sync_point_); |
| 60 ReallocateVideoFrame(); | 67 ReallocateVideoFrame(); |
| 61 } | 68 } |
| 62 } | 69 } |
| 63 | 70 |
| 64 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { | 71 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
| 65 SetVideoFrameProviderClient(NULL); | 72 SetVideoFrameProviderClient(NULL); |
| 66 client_->setWebLayer(NULL); | 73 client_->setWebLayer(NULL); |
| 67 | 74 |
| 68 if (stream_id_) | 75 if (stream_id_) |
| 69 stream_texture_factory_->DestroyStreamTexture(texture_id_); | 76 stream_texture_factory_->DestroyStreamTexture(texture_id_); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 if (needs_external_surface_) { | 510 if (needs_external_surface_) { |
| 504 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. | 511 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. |
| 505 #if defined(GOOGLE_TV) | 512 #if defined(GOOGLE_TV) |
| 506 if (!natural_size_.isEmpty()) | 513 if (!natural_size_.isEmpty()) |
| 507 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); | 514 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); |
| 508 #else | 515 #else |
| 509 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; | 516 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; |
| 510 #endif | 517 #endif |
| 511 } else if (texture_id_) { | 518 } else if (texture_id_) { |
| 512 current_frame_ = VideoFrame::WrapNativeTexture( | 519 current_frame_ = VideoFrame::WrapNativeTexture( |
| 513 texture_id_, kGLTextureExternalOES, natural_size_, | 520 texture_mailbox_, texture_mailbox_sync_point_, |
| 521 kGLTextureExternalOES, natural_size_, |
| 514 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), | 522 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), |
| 515 VideoFrame::ReadPixelsCB(), | 523 VideoFrame::ReadPixelsCB(), |
| 524 VideoFrame::TextureNoLongerNeededCallback(), |
| 516 base::Closure()); | 525 base::Closure()); |
| 517 } | 526 } |
| 518 } | 527 } |
| 519 | 528 |
| 520 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( | 529 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( |
| 521 cc::VideoFrameProvider::Client* client) { | 530 cc::VideoFrameProvider::Client* client) { |
| 522 // This is called from both the main renderer thread and the compositor | 531 // This is called from both the main renderer thread and the compositor |
| 523 // thread (when the main thread is blocked). | 532 // thread (when the main thread is blocked). |
| 524 if (video_frame_provider_client_) | 533 if (video_frame_provider_client_) |
| 525 video_frame_provider_client_->StopUsingProvider(); | 534 video_frame_provider_client_->StopUsingProvider(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 if (last_computed_rect_ == *rect) | 584 if (last_computed_rect_ == *rect) |
| 576 return false; | 585 return false; |
| 577 | 586 |
| 578 // Store the changed geometry information when it is actually changed. | 587 // Store the changed geometry information when it is actually changed. |
| 579 last_computed_rect_ = *rect; | 588 last_computed_rect_ = *rect; |
| 580 return true; | 589 return true; |
| 581 } | 590 } |
| 582 #endif | 591 #endif |
| 583 | 592 |
| 584 } // namespace webkit_media | 593 } // namespace webkit_media |
| OLD | NEW |