Chromium Code Reviews| 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 "cc/layers/video_layer.h" | 10 #include "cc/layers/video_layer.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 has_size_info_(false), | 47 has_size_info_(false), |
| 48 stream_texture_factory_(factory), | 48 stream_texture_factory_(factory), |
| 49 needs_external_surface_(false), | 49 needs_external_surface_(false), |
| 50 video_frame_provider_client_(NULL) { | 50 video_frame_provider_client_(NULL) { |
| 51 main_loop_->AddDestructionObserver(this); | 51 main_loop_->AddDestructionObserver(this); |
| 52 if (manager_) | 52 if (manager_) |
| 53 player_id_ = manager_->RegisterMediaPlayer(this); | 53 player_id_ = manager_->RegisterMediaPlayer(this); |
| 54 | 54 |
| 55 if (CommandLine::ForCurrentProcess()->HasSwitch( | 55 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 56 switches::kUseExternalVideoSurface)) { | 56 switches::kUseExternalVideoSurface)) { |
| 57 #if defined(GOOGLE_TV) | |
| 57 needs_external_surface_ = true; | 58 needs_external_surface_ = true; |
| 58 SetNeedsEstablishPeer(false); | 59 SetNeedsEstablishPeer(false); |
| 59 ReallocateVideoFrame(); | 60 ReallocateVideoFrame(); |
| 61 #endif | |
|
ycheo
2013/04/12 07:54:32
'#else'?
wonsik
2013/04/12 09:58:54
Done.
| |
| 62 NOTIMPLEMENTED() << "No external video surface rendering support"; | |
| 60 } else if (stream_texture_factory_.get()) { | 63 } else if (stream_texture_factory_.get()) { |
| 61 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); | 64 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); |
| 62 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); | 65 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); |
| 63 ReallocateVideoFrame(); | 66 ReallocateVideoFrame(); |
| 64 } | 67 } |
| 65 } | 68 } |
| 66 | 69 |
| 67 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { | 70 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
| 68 SetVideoFrameProviderClient(NULL); | 71 SetVideoFrameProviderClient(NULL); |
| 69 client_->setWebLayer(NULL); | 72 client_->setWebLayer(NULL); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 91 WebMediaSource* media_source, | 94 WebMediaSource* media_source, |
| 92 CORSMode cors_mode) { | 95 CORSMode cors_mode) { |
| 93 NOTIMPLEMENTED(); | 96 NOTIMPLEMENTED(); |
| 94 } | 97 } |
| 95 | 98 |
| 96 void WebMediaPlayerAndroid::cancelLoad() { | 99 void WebMediaPlayerAndroid::cancelLoad() { |
| 97 NOTIMPLEMENTED(); | 100 NOTIMPLEMENTED(); |
| 98 } | 101 } |
| 99 | 102 |
| 100 void WebMediaPlayerAndroid::play() { | 103 void WebMediaPlayerAndroid::play() { |
| 104 #if defined(GOOGLE_TV) | |
| 101 if (hasVideo() && needs_external_surface_) { | 105 if (hasVideo() && needs_external_surface_) { |
| 102 DCHECK(!needs_establish_peer_); | 106 DCHECK(!needs_establish_peer_); |
| 103 RequestExternalSurface(); | 107 RequestExternalSurface(); |
| 104 } | 108 } |
| 109 #endif | |
| 105 if (hasVideo() && needs_establish_peer_) | 110 if (hasVideo() && needs_establish_peer_) |
| 106 EstablishSurfaceTexturePeer(); | 111 EstablishSurfaceTexturePeer(); |
| 107 | 112 |
| 108 PlayInternal(); | 113 PlayInternal(); |
| 109 is_playing_ = true; | 114 is_playing_ = true; |
| 110 } | 115 } |
| 111 | 116 |
| 112 void WebMediaPlayerAndroid::pause() { | 117 void WebMediaPlayerAndroid::pause() { |
| 113 PauseInternal(); | 118 PauseInternal(); |
| 114 is_playing_ = false; | 119 is_playing_ = false; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 } | 478 } |
| 474 | 479 |
| 475 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { | 480 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { |
| 476 needs_establish_peer_ = needs_establish_peer; | 481 needs_establish_peer_ = needs_establish_peer; |
| 477 } | 482 } |
| 478 | 483 |
| 479 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { | 484 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { |
| 480 is_playing_ = is_playing; | 485 is_playing_ = is_playing; |
| 481 } | 486 } |
| 482 | 487 |
| 488 #if defined(GOOGLE_TV) | |
| 489 bool WebMediaPlayerAndroid::GetGeometryChange(gfx::RectF* rect) { | |
| 490 if (!video_weblayer_) | |
| 491 return false; | |
| 492 | |
| 493 // Compute the geometry of video frame layer. | |
| 494 cc::Layer* layer = video_weblayer_->layer(); | |
| 495 rect->set_size(layer->bounds()); | |
| 496 while (layer) { | |
| 497 rect->Offset(layer->position().OffsetFromOrigin()); | |
| 498 layer = layer->parent(); | |
| 499 } | |
| 500 | |
| 501 // Return false when the geometry hasn't been changed from the last time. | |
| 502 if (last_computed_rect_ == *rect) | |
| 503 return false; | |
| 504 | |
| 505 // Store the changed geometry information when it is actually changed. | |
| 506 last_computed_rect_ = *rect; | |
| 507 return true; | |
| 508 } | |
| 509 #endif | |
| 510 | |
| 483 } // namespace webkit_media | 511 } // namespace webkit_media |
| OLD | NEW |