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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 WebMediaSource* media_source, | 87 WebMediaSource* media_source, |
88 CORSMode cors_mode) { | 88 CORSMode cors_mode) { |
89 NOTIMPLEMENTED(); | 89 NOTIMPLEMENTED(); |
90 } | 90 } |
91 | 91 |
92 void WebMediaPlayerAndroid::cancelLoad() { | 92 void WebMediaPlayerAndroid::cancelLoad() { |
93 NOTIMPLEMENTED(); | 93 NOTIMPLEMENTED(); |
94 } | 94 } |
95 | 95 |
96 void WebMediaPlayerAndroid::play() { | 96 void WebMediaPlayerAndroid::play() { |
| 97 #if defined(GOOGLE_TV) |
97 if (hasVideo() && needs_external_surface_) { | 98 if (hasVideo() && needs_external_surface_) { |
98 DCHECK(!needs_establish_peer_); | 99 DCHECK(!needs_establish_peer_); |
99 RequestExternalSurface(); | 100 RequestExternalSurface(); |
100 } | 101 } |
| 102 #endif |
101 if (hasVideo() && needs_establish_peer_) | 103 if (hasVideo() && needs_establish_peer_) |
102 EstablishSurfaceTexturePeer(); | 104 EstablishSurfaceTexturePeer(); |
103 | 105 |
104 PlayInternal(); | 106 PlayInternal(); |
105 is_playing_ = true; | 107 is_playing_ = true; |
106 } | 108 } |
107 | 109 |
108 void WebMediaPlayerAndroid::pause() { | 110 void WebMediaPlayerAndroid::pause() { |
109 PauseInternal(); | 111 PauseInternal(); |
110 is_playing_ = false; | 112 is_playing_ = false; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 break; | 380 break; |
379 } | 381 } |
380 client_->repaint(); | 382 client_->repaint(); |
381 } | 383 } |
382 | 384 |
383 void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { | 385 void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { |
384 has_size_info_ = true; | 386 has_size_info_ = true; |
385 if (natural_size_.width == width && natural_size_.height == height) | 387 if (natural_size_.width == width && natural_size_.height == height) |
386 return; | 388 return; |
387 | 389 |
| 390 #if defined(GOOGLE_TV) |
388 static bool has_switch = CommandLine::ForCurrentProcess()->HasSwitch( | 391 static bool has_switch = CommandLine::ForCurrentProcess()->HasSwitch( |
389 switches::kUseExternalVideoSurfaceThresholdInPixels); | 392 switches::kUseExternalVideoSurfaceThresholdInPixels); |
390 static int threshold = 0; | 393 static int threshold = 0; |
391 static bool parsed_arg = | 394 static bool parsed_arg = |
392 has_switch && | 395 has_switch && |
393 base::StringToInt( | 396 base::StringToInt( |
394 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 397 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
395 switches::kUseExternalVideoSurfaceThresholdInPixels), | 398 switches::kUseExternalVideoSurfaceThresholdInPixels), |
396 &threshold); | 399 &threshold); |
397 | 400 |
398 if (parsed_arg && threshold <= width * height) { | 401 if (parsed_arg && threshold <= width * height) { |
399 needs_external_surface_ = true; | 402 needs_external_surface_ = true; |
400 SetNeedsEstablishPeer(false); | 403 SetNeedsEstablishPeer(false); |
401 if (!paused()) | 404 if (!paused()) |
402 RequestExternalSurface(); | 405 RequestExternalSurface(); |
403 } | 406 } |
| 407 #endif |
404 | 408 |
405 natural_size_.width = width; | 409 natural_size_.width = width; |
406 natural_size_.height = height; | 410 natural_size_.height = height; |
407 ReallocateVideoFrame(); | 411 ReallocateVideoFrame(); |
408 } | 412 } |
409 | 413 |
410 void WebMediaPlayerAndroid::UpdateNetworkState( | 414 void WebMediaPlayerAndroid::UpdateNetworkState( |
411 WebMediaPlayer::NetworkState state) { | 415 WebMediaPlayer::NetworkState state) { |
412 network_state_ = state; | 416 network_state_ = state; |
413 client_->networkStateChanged(); | 417 client_->networkStateChanged(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 } | 522 } |
519 | 523 |
520 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { | 524 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { |
521 needs_establish_peer_ = needs_establish_peer; | 525 needs_establish_peer_ = needs_establish_peer; |
522 } | 526 } |
523 | 527 |
524 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { | 528 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { |
525 is_playing_ = is_playing; | 529 is_playing_ = is_playing; |
526 } | 530 } |
527 | 531 |
| 532 #if defined(GOOGLE_TV) |
| 533 bool WebMediaPlayerAndroid::RetrieveGeometryChange(gfx::RectF* rect) { |
| 534 if (!video_weblayer_) |
| 535 return false; |
| 536 |
| 537 // Compute the geometry of video frame layer. |
| 538 cc::Layer* layer = video_weblayer_->layer(); |
| 539 rect->set_size(layer->bounds()); |
| 540 while (layer) { |
| 541 rect->Offset(layer->position().OffsetFromOrigin()); |
| 542 layer = layer->parent(); |
| 543 } |
| 544 |
| 545 // Return false when the geometry hasn't been changed from the last time. |
| 546 if (last_computed_rect_ == *rect) |
| 547 return false; |
| 548 |
| 549 // Store the changed geometry information when it is actually changed. |
| 550 last_computed_rect_ = *rect; |
| 551 return true; |
| 552 } |
| 553 #endif |
| 554 |
528 } // namespace webkit_media | 555 } // namespace webkit_media |
OLD | NEW |