OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 surface_created_cb_.Cancel(); | 339 surface_created_cb_.Cancel(); |
340 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; | 340 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; |
341 | 341 |
342 if (decoder_requires_restart_for_overlay_) | 342 if (decoder_requires_restart_for_overlay_) |
343 ScheduleRestart(); | 343 ScheduleRestart(); |
344 else if (!set_surface_cb_.is_null()) | 344 else if (!set_surface_cb_.is_null()) |
345 set_surface_cb_.Run(overlay_surface_id_); | 345 set_surface_cb_.Run(overlay_surface_id_); |
346 } | 346 } |
347 | 347 |
348 void WebMediaPlayerImpl::enteredFullscreen() { | 348 void WebMediaPlayerImpl::enteredFullscreen() { |
349 if (!force_video_overlays_ && enable_fullscreen_video_overlays_) | 349 // |force_video_overlays_| implies that we're already in overlay mode, so take |
| 350 // no action here. Otherwise, switch to an overlay if it's allowed and if |
| 351 // it will display properly. |
| 352 if (!force_video_overlays_ && enable_fullscreen_video_overlays_ && |
| 353 DoesOverlaySupportMetadata()) { |
350 EnableOverlay(); | 354 EnableOverlay(); |
| 355 } |
351 if (observer_) | 356 if (observer_) |
352 observer_->OnEnteredFullscreen(); | 357 observer_->OnEnteredFullscreen(); |
353 } | 358 } |
354 | 359 |
355 void WebMediaPlayerImpl::exitedFullscreen() { | 360 void WebMediaPlayerImpl::exitedFullscreen() { |
356 if (!force_video_overlays_ && enable_fullscreen_video_overlays_) | 361 // If we're in overlay mode, then exit it unless we're supposed to be in |
| 362 // overlay mode all the time. |
| 363 if (!force_video_overlays_ && overlay_enabled_) |
357 DisableOverlay(); | 364 DisableOverlay(); |
358 if (observer_) | 365 if (observer_) |
359 observer_->OnExitedFullscreen(); | 366 observer_->OnExitedFullscreen(); |
360 } | 367 } |
361 | 368 |
362 void WebMediaPlayerImpl::becameDominantVisibleContent(bool isDominant) { | 369 void WebMediaPlayerImpl::becameDominantVisibleContent(bool isDominant) { |
363 if (observer_) | 370 if (observer_) |
364 observer_->OnBecameDominantVisibleContent(isDominant); | 371 observer_->OnBecameDominantVisibleContent(isDominant); |
365 } | 372 } |
366 | 373 |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 pipeline_metadata_ = metadata; | 1155 pipeline_metadata_ = metadata; |
1149 | 1156 |
1150 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 1157 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
1151 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 1158 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, |
1152 VIDEO_ROTATION_MAX + 1); | 1159 VIDEO_ROTATION_MAX + 1); |
1153 | 1160 |
1154 if (hasVideo()) { | 1161 if (hasVideo()) { |
1155 pipeline_metadata_.natural_size = GetRotatedVideoSize( | 1162 pipeline_metadata_.natural_size = GetRotatedVideoSize( |
1156 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); | 1163 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); |
1157 | 1164 |
1158 if (overlay_enabled_ && surface_manager_) | 1165 if (overlay_enabled_) { |
1159 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1166 // SurfaceView doesn't support rotated video, so transition back if |
| 1167 // the video is now rotated. If |force_video_overlays_|, we keep the |
| 1168 // overlay anyway so that the state machine keeps working. |
| 1169 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) |
| 1170 DisableOverlay(); |
| 1171 else if (surface_manager_) |
| 1172 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); |
| 1173 } |
1160 | 1174 |
1161 DCHECK(!video_weblayer_); | 1175 DCHECK(!video_weblayer_); |
1162 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1176 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( |
1163 compositor_, pipeline_metadata_.video_rotation))); | 1177 compositor_, pipeline_metadata_.video_rotation))); |
1164 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1178 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
1165 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1179 video_weblayer_->SetContentsOpaqueIsFixed(true); |
1166 client_->setWebLayer(video_weblayer_.get()); | 1180 client_->setWebLayer(video_weblayer_.get()); |
1167 } | 1181 } |
1168 | 1182 |
1169 if (observer_) | 1183 if (observer_) |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 else | 2018 else |
2005 watch_time_reporter_->OnShown(); | 2019 watch_time_reporter_->OnShown(); |
2006 } | 2020 } |
2007 | 2021 |
2008 bool WebMediaPlayerImpl::IsHidden() const { | 2022 bool WebMediaPlayerImpl::IsHidden() const { |
2009 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2023 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
2010 | 2024 |
2011 return delegate_ && delegate_->IsHidden(); | 2025 return delegate_ && delegate_->IsHidden(); |
2012 } | 2026 } |
2013 | 2027 |
| 2028 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { |
| 2029 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; |
| 2030 } |
| 2031 |
2014 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { | 2032 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { |
2015 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2033 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
2016 | 2034 |
2017 client_->activateViewportIntersectionMonitoring(activate); | 2035 client_->activateViewportIntersectionMonitoring(activate); |
2018 } | 2036 } |
2019 | 2037 |
2020 } // namespace media | 2038 } // namespace media |
OLD | NEW |