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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 54 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
| 55 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" | 55 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" |
| 56 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 56 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
| 57 #include "third_party/WebKit/public/platform/WebMediaSource.h" | 57 #include "third_party/WebKit/public/platform/WebMediaSource.h" |
| 58 #include "third_party/WebKit/public/platform/WebRect.h" | 58 #include "third_party/WebKit/public/platform/WebRect.h" |
| 59 #include "third_party/WebKit/public/platform/WebRuntimeFeatures.h" | 59 #include "third_party/WebKit/public/platform/WebRuntimeFeatures.h" |
| 60 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 60 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 61 #include "third_party/WebKit/public/platform/WebSize.h" | 61 #include "third_party/WebKit/public/platform/WebSize.h" |
| 62 #include "third_party/WebKit/public/platform/WebString.h" | 62 #include "third_party/WebKit/public/platform/WebString.h" |
| 63 #include "third_party/WebKit/public/platform/WebURL.h" | 63 #include "third_party/WebKit/public/platform/WebURL.h" |
| 64 #include "third_party/WebKit/public/platform/WebVideoSurfaceLayerBridge.h" | |
| 64 #include "third_party/WebKit/public/web/WebDocument.h" | 65 #include "third_party/WebKit/public/web/WebDocument.h" |
| 65 #include "third_party/WebKit/public/web/WebFrame.h" | 66 #include "third_party/WebKit/public/web/WebFrame.h" |
| 66 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 67 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 67 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 68 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 68 #include "third_party/WebKit/public/web/WebView.h" | 69 #include "third_party/WebKit/public/web/WebView.h" |
| 69 | 70 |
| 70 #if defined(OS_ANDROID) | 71 #if defined(OS_ANDROID) |
| 71 #include "media/base/android/media_codec_util.h" | 72 #include "media/base/android/media_codec_util.h" |
| 72 #endif | 73 #endif |
| 73 | 74 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 volume_(1.0), | 245 volume_(1.0), |
| 245 volume_multiplier_(1.0), | 246 volume_multiplier_(1.0), |
| 246 renderer_factory_selector_(std::move(renderer_factory_selector)), | 247 renderer_factory_selector_(std::move(renderer_factory_selector)), |
| 247 surface_manager_(params->surface_manager()), | 248 surface_manager_(params->surface_manager()), |
| 248 overlay_surface_id_(SurfaceManager::kNoSurfaceID), | 249 overlay_surface_id_(SurfaceManager::kNoSurfaceID), |
| 249 suppress_destruction_errors_(false), | 250 suppress_destruction_errors_(false), |
| 250 suspend_enabled_(params->allow_suspend()), | 251 suspend_enabled_(params->allow_suspend()), |
| 251 is_encrypted_(false), | 252 is_encrypted_(false), |
| 252 preroll_attempt_pending_(false), | 253 preroll_attempt_pending_(false), |
| 253 observer_(params->media_observer()), | 254 observer_(params->media_observer()), |
| 255 bridge_( | |
| 256 base::WrapUnique(blink::WebVideoSurfaceLayerBridge::Create(this))), | |
|
liberato (no reviews please)
2017/06/26 22:39:30
maybe only do this if |kVideoSurface|?
CJ
2017/06/29 19:51:33
Done.
| |
| 254 max_keyframe_distance_to_disable_background_video_( | 257 max_keyframe_distance_to_disable_background_video_( |
| 255 params->max_keyframe_distance_to_disable_background_video()), | 258 params->max_keyframe_distance_to_disable_background_video()), |
| 256 max_keyframe_distance_to_disable_background_video_mse_( | 259 max_keyframe_distance_to_disable_background_video_mse_( |
| 257 params->max_keyframe_distance_to_disable_background_video_mse()), | 260 params->max_keyframe_distance_to_disable_background_video_mse()), |
| 258 enable_instant_source_buffer_gc_( | 261 enable_instant_source_buffer_gc_( |
| 259 params->enable_instant_source_buffer_gc()), | 262 params->enable_instant_source_buffer_gc()), |
| 260 embedded_media_experience_enabled_( | 263 embedded_media_experience_enabled_( |
| 261 params->embedded_media_experience_enabled()), | 264 params->embedded_media_experience_enabled()), |
| 262 request_routing_token_cb_(params->request_routing_token_cb()), | 265 request_routing_token_cb_(params->request_routing_token_cb()), |
| 263 overlay_routing_token_(OverlayInfo::RoutingToken()) { | 266 overlay_routing_token_(OverlayInfo::RoutingToken()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 watch_time_reporter_.reset(); | 319 watch_time_reporter_.reset(); |
| 317 | 320 |
| 318 // The underlying Pipeline must be stopped before it is destroyed. | 321 // The underlying Pipeline must be stopped before it is destroyed. |
| 319 pipeline_controller_.Stop(); | 322 pipeline_controller_.Stop(); |
| 320 | 323 |
| 321 if (last_reported_memory_usage_) | 324 if (last_reported_memory_usage_) |
| 322 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); | 325 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); |
| 323 | 326 |
| 324 // Destruct compositor resources in the proper order. | 327 // Destruct compositor resources in the proper order. |
| 325 client_->SetWebLayer(nullptr); | 328 client_->SetWebLayer(nullptr); |
| 326 if (video_weblayer_) | 329 if (video_weblayer_ && !base::FeatureList::IsEnabled(kVideoSurface)) |
| 327 static_cast<cc::VideoLayer*>(video_weblayer_->layer())->StopUsingProvider(); | 330 static_cast<cc::VideoLayer*>(video_weblayer_->layer())->StopUsingProvider(); |
| 328 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); | 331 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); |
| 329 | 332 |
| 330 media_log_->AddEvent( | 333 media_log_->AddEvent( |
| 331 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 334 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
| 332 } | 335 } |
| 333 | 336 |
| 334 void WebMediaPlayerImpl::Load(LoadType load_type, | 337 void WebMediaPlayerImpl::Load(LoadType load_type, |
| 335 const blink::WebMediaPlayerSource& source, | 338 const blink::WebMediaPlayerSource& source, |
| 336 CORSMode cors_mode) { | 339 CORSMode cors_mode) { |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1342 // SurfaceView doesn't support rotated video, so transition back if | 1345 // SurfaceView doesn't support rotated video, so transition back if |
| 1343 // the video is now rotated. If |force_video_overlays_|, we keep the | 1346 // the video is now rotated. If |force_video_overlays_|, we keep the |
| 1344 // overlay anyway so that the state machine keeps working. | 1347 // overlay anyway so that the state machine keeps working. |
| 1345 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) | 1348 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) |
| 1346 DisableOverlay(); | 1349 DisableOverlay(); |
| 1347 else if (surface_manager_) | 1350 else if (surface_manager_) |
| 1348 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1351 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); |
| 1349 } | 1352 } |
| 1350 | 1353 |
| 1351 DCHECK(!video_weblayer_); | 1354 DCHECK(!video_weblayer_); |
| 1352 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1355 if (base::FeatureList::IsEnabled(media::kVideoSurface)) { |
| 1353 compositor_, pipeline_metadata_.video_rotation))); | 1356 video_weblayer_.reset(new cc_blink::WebLayerImpl(bridge_->GetLayer())); |
|
liberato (no reviews please)
2017/06/26 15:04:03
for your SurfaceLayer ownership question, i'd expe
enne (OOO)
2017/06/26 18:35:58
Yes, I think the same ownership model should apply
CJ
2017/06/29 19:51:33
So, to summarize, we want to pull out all SurfaceL
enne (OOO)
2017/06/29 20:29:29
I was suggesting that you don't need a bridge at a
CJ
2017/06/29 20:46:06
So, is this just a naming issue? (Sorry if I keep
| |
| 1357 } else { | |
| 1358 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | |
| 1359 compositor_, pipeline_metadata_.video_rotation))); | |
| 1360 } | |
| 1354 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1361 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
| 1355 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1362 video_weblayer_->SetContentsOpaqueIsFixed(true); |
| 1356 client_->SetWebLayer(video_weblayer_.get()); | 1363 client_->SetWebLayer(video_weblayer_.get()); |
| 1357 } | 1364 } |
| 1358 | 1365 |
| 1359 if (observer_) | 1366 if (observer_) |
| 1360 observer_->OnMetadataChanged(pipeline_metadata_); | 1367 observer_->OnMetadataChanged(pipeline_metadata_); |
| 1361 | 1368 |
| 1362 CreateWatchTimeReporter(); | 1369 CreateWatchTimeReporter(); |
| 1363 UpdatePlayState(); | 1370 UpdatePlayState(); |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2376 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { | 2383 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const { |
| 2377 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; | 2384 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0; |
| 2378 } | 2385 } |
| 2379 | 2386 |
| 2380 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { | 2387 void WebMediaPlayerImpl::ActivateViewportIntersectionMonitoring(bool activate) { |
| 2381 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2388 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 2382 | 2389 |
| 2383 client_->ActivateViewportIntersectionMonitoring(activate); | 2390 client_->ActivateViewportIntersectionMonitoring(activate); |
| 2384 } | 2391 } |
| 2385 | 2392 |
| 2393 void WebMediaPlayerImpl::OnWebLayerReplaced() {} | |
| 2394 | |
| 2386 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { | 2395 bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { |
| 2387 // If suspending background video, pause any video that's not remoted or | 2396 // If suspending background video, pause any video that's not remoted or |
| 2388 // not unlocked to play in the background. | 2397 // not unlocked to play in the background. |
| 2389 if (IsBackgroundedSuspendEnabled()) { | 2398 if (IsBackgroundedSuspendEnabled()) { |
| 2390 if (!HasVideo()) | 2399 if (!HasVideo()) |
| 2391 return false; | 2400 return false; |
| 2392 | 2401 |
| 2393 #if defined(OS_ANDROID) | 2402 #if defined(OS_ANDROID) |
| 2394 if (IsRemote()) | 2403 if (IsRemote()) |
| 2395 return false; | 2404 return false; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2590 } | 2599 } |
| 2591 | 2600 |
| 2592 #undef UMA_HISTOGRAM_VIDEO_HEIGHT | 2601 #undef UMA_HISTOGRAM_VIDEO_HEIGHT |
| 2593 | 2602 |
| 2594 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { | 2603 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { |
| 2595 tick_clock_.reset(tick_clock); | 2604 tick_clock_.reset(tick_clock); |
| 2596 buffered_data_source_host_.SetTickClockForTest(tick_clock); | 2605 buffered_data_source_host_.SetTickClockForTest(tick_clock); |
| 2597 } | 2606 } |
| 2598 | 2607 |
| 2599 } // namespace media | 2608 } // namespace media |
| OLD | NEW |