Chromium Code Reviews| 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 if (!force_video_overlays_ && enable_fullscreen_video_overlays_ && |
| 350 DoesOverlaySupportMetadata()) | |
|
watk
2017/01/03 20:33:03
needs braces now
liberato (no reviews please)
2017/01/03 22:53:45
Done.
| |
| 350 EnableOverlay(); | 351 EnableOverlay(); |
| 351 if (observer_) | 352 if (observer_) |
| 352 observer_->OnEnteredFullscreen(); | 353 observer_->OnEnteredFullscreen(); |
| 353 } | 354 } |
| 354 | 355 |
| 355 void WebMediaPlayerImpl::exitedFullscreen() { | 356 void WebMediaPlayerImpl::exitedFullscreen() { |
| 356 if (!force_video_overlays_ && enable_fullscreen_video_overlays_) | 357 if (overlay_enabled_) |
|
watk
2017/01/03 20:33:02
I don't think we should do this when force_video_o
liberato (no reviews please)
2017/01/03 22:53:45
good catch. not sure why i thought that was okay.
| |
| 357 DisableOverlay(); | 358 DisableOverlay(); |
| 358 if (observer_) | 359 if (observer_) |
| 359 observer_->OnExitedFullscreen(); | 360 observer_->OnExitedFullscreen(); |
| 360 } | 361 } |
| 361 | 362 |
| 362 void WebMediaPlayerImpl::becameDominantVisibleContent(bool isDominant) { | 363 void WebMediaPlayerImpl::becameDominantVisibleContent(bool isDominant) { |
| 363 if (observer_) | 364 if (observer_) |
| 364 observer_->OnBecameDominantVisibleContent(isDominant); | 365 observer_->OnBecameDominantVisibleContent(isDominant); |
| 365 } | 366 } |
| 366 | 367 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 pipeline_metadata_ = metadata; | 1149 pipeline_metadata_ = metadata; |
| 1149 | 1150 |
| 1150 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 1151 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 1151 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 1152 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, |
| 1152 VIDEO_ROTATION_MAX + 1); | 1153 VIDEO_ROTATION_MAX + 1); |
| 1153 | 1154 |
| 1154 if (hasVideo()) { | 1155 if (hasVideo()) { |
| 1155 pipeline_metadata_.natural_size = GetRotatedVideoSize( | 1156 pipeline_metadata_.natural_size = GetRotatedVideoSize( |
| 1156 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); | 1157 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); |
| 1157 | 1158 |
| 1158 if (overlay_enabled_ && surface_manager_) | 1159 if (overlay_enabled_) { |
| 1159 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1160 // SurfaceView doesn't support rotated video, so transition back if |
| 1161 // the video is now rotated. | |
| 1162 if (!DoesOverlaySupportMetadata()) | |
| 1163 DisableOverlay(); | |
|
watk
2017/01/03 20:33:03
I don't think we should do this for force_video_ov
liberato (no reviews please)
2017/01/03 22:53:45
yeah, though we're kinda going to be wrong either
| |
| 1164 else if (surface_manager_) | |
| 1165 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | |
| 1166 } | |
| 1160 | 1167 |
| 1161 DCHECK(!video_weblayer_); | 1168 DCHECK(!video_weblayer_); |
| 1162 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1169 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( |
| 1163 compositor_, pipeline_metadata_.video_rotation))); | 1170 compositor_, pipeline_metadata_.video_rotation))); |
| 1164 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1171 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
| 1165 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1172 video_weblayer_->SetContentsOpaqueIsFixed(true); |
| 1166 client_->setWebLayer(video_weblayer_.get()); | 1173 client_->setWebLayer(video_weblayer_.get()); |
| 1167 } | 1174 } |
| 1168 | 1175 |
| 1169 if (observer_) | 1176 if (observer_) |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2004 else | 2011 else |
| 2005 watch_time_reporter_->OnShown(); | 2012 watch_time_reporter_->OnShown(); |
| 2006 } | 2013 } |
| 2007 | 2014 |
| 2008 bool WebMediaPlayerImpl::IsHidden() const { | 2015 bool WebMediaPlayerImpl::IsHidden() const { |
| 2009 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2016 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2010 | 2017 |
| 2011 return delegate_ && delegate_->IsHidden(); | 2018 return delegate_ && delegate_->IsHidden(); |
| 2012 } | 2019 } |
| 2013 | 2020 |
| 2021 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { | |
| 2022 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; | |
| 2023 } | |
| 2024 | |
| 2014 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { | 2025 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { |
| 2015 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2026 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2016 | 2027 |
| 2017 client_->activateViewportIntersectionMonitoring(activate); | 2028 client_->activateViewportIntersectionMonitoring(activate); |
| 2018 } | 2029 } |
| 2019 | 2030 |
| 2020 } // namespace media | 2031 } // namespace media |
| OLD | NEW |