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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 embedded_media_experience_enabled_( | 261 embedded_media_experience_enabled_( |
261 params->embedded_media_experience_enabled()), | 262 params->embedded_media_experience_enabled()), |
262 request_routing_token_cb_(params->request_routing_token_cb()), | 263 request_routing_token_cb_(params->request_routing_token_cb()), |
263 overlay_routing_token_(OverlayInfo::RoutingToken()) { | 264 overlay_routing_token_(OverlayInfo::RoutingToken()) { |
264 DVLOG(1) << __func__; | 265 DVLOG(1) << __func__; |
265 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 266 DCHECK(!adjust_allocated_memory_cb_.is_null()); |
266 DCHECK(renderer_factory_selector_); | 267 DCHECK(renderer_factory_selector_); |
267 DCHECK(client_); | 268 DCHECK(client_); |
268 DCHECK(delegate_); | 269 DCHECK(delegate_); |
269 | 270 |
| 271 if (base::FeatureList::IsEnabled(media::kVideoSurface)) |
| 272 bridge_ = base::WrapUnique(blink::WebVideoSurfaceLayerBridge::Create()); |
| 273 |
270 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 274 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
271 switches::kForceVideoOverlays); | 275 switches::kForceVideoOverlays); |
272 | 276 |
273 if (base::FeatureList::IsEnabled(media::kOverlayFullscreenVideo)) { | 277 if (base::FeatureList::IsEnabled(media::kOverlayFullscreenVideo)) { |
274 bool use_android_overlay = | 278 bool use_android_overlay = |
275 base::FeatureList::IsEnabled(media::kUseAndroidOverlay); | 279 base::FeatureList::IsEnabled(media::kUseAndroidOverlay); |
276 overlay_mode_ = use_android_overlay ? OverlayMode::kUseAndroidOverlay | 280 overlay_mode_ = use_android_overlay ? OverlayMode::kUseAndroidOverlay |
277 : OverlayMode::kUseContentVideoView; | 281 : OverlayMode::kUseContentVideoView; |
278 } else { | 282 } else { |
279 overlay_mode_ = OverlayMode::kNoOverlays; | 283 overlay_mode_ = OverlayMode::kNoOverlays; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 watch_time_reporter_.reset(); | 320 watch_time_reporter_.reset(); |
317 | 321 |
318 // The underlying Pipeline must be stopped before it is destroyed. | 322 // The underlying Pipeline must be stopped before it is destroyed. |
319 pipeline_controller_.Stop(); | 323 pipeline_controller_.Stop(); |
320 | 324 |
321 if (last_reported_memory_usage_) | 325 if (last_reported_memory_usage_) |
322 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); | 326 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); |
323 | 327 |
324 // Destruct compositor resources in the proper order. | 328 // Destruct compositor resources in the proper order. |
325 client_->SetWebLayer(nullptr); | 329 client_->SetWebLayer(nullptr); |
326 if (video_weblayer_) | 330 if (video_weblayer_ && !base::FeatureList::IsEnabled(kVideoSurface)) |
327 static_cast<cc::VideoLayer*>(video_weblayer_->layer())->StopUsingProvider(); | 331 static_cast<cc::VideoLayer*>(video_weblayer_->layer())->StopUsingProvider(); |
328 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); | 332 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); |
329 | 333 |
330 media_log_->AddEvent( | 334 media_log_->AddEvent( |
331 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 335 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
332 } | 336 } |
333 | 337 |
334 void WebMediaPlayerImpl::Load(LoadType load_type, | 338 void WebMediaPlayerImpl::Load(LoadType load_type, |
335 const blink::WebMediaPlayerSource& source, | 339 const blink::WebMediaPlayerSource& source, |
336 CORSMode cors_mode) { | 340 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 | 1346 // SurfaceView doesn't support rotated video, so transition back if |
1343 // the video is now rotated. If |force_video_overlays_|, we keep the | 1347 // the video is now rotated. If |force_video_overlays_|, we keep the |
1344 // overlay anyway so that the state machine keeps working. | 1348 // overlay anyway so that the state machine keeps working. |
1345 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) | 1349 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) |
1346 DisableOverlay(); | 1350 DisableOverlay(); |
1347 else if (surface_manager_) | 1351 else if (surface_manager_) |
1348 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1352 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); |
1349 } | 1353 } |
1350 | 1354 |
1351 DCHECK(!video_weblayer_); | 1355 DCHECK(!video_weblayer_); |
1352 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1356 if (base::FeatureList::IsEnabled(media::kVideoSurface)) { |
1353 compositor_, pipeline_metadata_.video_rotation))); | 1357 video_weblayer_.reset(new cc_blink::WebLayerImpl(bridge_->GetLayer())); |
| 1358 } else { |
| 1359 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( |
| 1360 compositor_, pipeline_metadata_.video_rotation))); |
| 1361 } |
1354 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1362 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
1355 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1363 video_weblayer_->SetContentsOpaqueIsFixed(true); |
1356 client_->SetWebLayer(video_weblayer_.get()); | 1364 client_->SetWebLayer(video_weblayer_.get()); |
1357 } | 1365 } |
1358 | 1366 |
1359 if (observer_) | 1367 if (observer_) |
1360 observer_->OnMetadataChanged(pipeline_metadata_); | 1368 observer_->OnMetadataChanged(pipeline_metadata_); |
1361 | 1369 |
1362 CreateWatchTimeReporter(); | 1370 CreateWatchTimeReporter(); |
1363 UpdatePlayState(); | 1371 UpdatePlayState(); |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 } | 2598 } |
2591 | 2599 |
2592 #undef UMA_HISTOGRAM_VIDEO_HEIGHT | 2600 #undef UMA_HISTOGRAM_VIDEO_HEIGHT |
2593 | 2601 |
2594 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { | 2602 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { |
2595 tick_clock_.reset(tick_clock); | 2603 tick_clock_.reset(tick_clock); |
2596 buffered_data_source_host_.SetTickClockForTest(tick_clock); | 2604 buffered_data_source_host_.SetTickClockForTest(tick_clock); |
2597 } | 2605 } |
2598 | 2606 |
2599 } // namespace media | 2607 } // namespace media |
OLD | NEW |