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::kUseSurfaceLayerForVideo)) |
| 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_ && |
| 331 !base::FeatureList::IsEnabled(media::kUseSurfaceLayerForVideo)) |
327 static_cast<cc::VideoLayer*>(video_weblayer_->layer())->StopUsingProvider(); | 332 static_cast<cc::VideoLayer*>(video_weblayer_->layer())->StopUsingProvider(); |
328 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); | 333 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); |
329 | 334 |
330 media_log_->AddEvent( | 335 media_log_->AddEvent( |
331 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 336 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
332 } | 337 } |
333 | 338 |
334 void WebMediaPlayerImpl::Load(LoadType load_type, | 339 void WebMediaPlayerImpl::Load(LoadType load_type, |
335 const blink::WebMediaPlayerSource& source, | 340 const blink::WebMediaPlayerSource& source, |
336 CORSMode cors_mode) { | 341 CORSMode cors_mode) { |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 // SurfaceView doesn't support rotated video, so transition back if | 1348 // SurfaceView doesn't support rotated video, so transition back if |
1344 // the video is now rotated. If |force_video_overlays_|, we keep the | 1349 // the video is now rotated. If |force_video_overlays_|, we keep the |
1345 // overlay anyway so that the state machine keeps working. | 1350 // overlay anyway so that the state machine keeps working. |
1346 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) | 1351 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) |
1347 DisableOverlay(); | 1352 DisableOverlay(); |
1348 else if (surface_manager_) | 1353 else if (surface_manager_) |
1349 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1354 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); |
1350 } | 1355 } |
1351 | 1356 |
1352 DCHECK(!video_weblayer_); | 1357 DCHECK(!video_weblayer_); |
1353 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1358 if (base::FeatureList::IsEnabled(media::kUseSurfaceLayerForVideo)) { |
1354 compositor_, pipeline_metadata_.video_rotation))); | 1359 video_weblayer_.reset(new cc_blink::WebLayerImpl(bridge_->GetLayer())); |
| 1360 } else { |
| 1361 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( |
| 1362 compositor_, pipeline_metadata_.video_rotation))); |
| 1363 } |
1355 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1364 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
1356 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1365 video_weblayer_->SetContentsOpaqueIsFixed(true); |
1357 client_->SetWebLayer(video_weblayer_.get()); | 1366 client_->SetWebLayer(video_weblayer_.get()); |
1358 } | 1367 } |
1359 | 1368 |
1360 if (observer_) | 1369 if (observer_) |
1361 observer_->OnMetadataChanged(pipeline_metadata_); | 1370 observer_->OnMetadataChanged(pipeline_metadata_); |
1362 | 1371 |
1363 CreateWatchTimeReporter(); | 1372 CreateWatchTimeReporter(); |
1364 UpdatePlayState(); | 1373 UpdatePlayState(); |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 } | 2611 } |
2603 | 2612 |
2604 #undef UMA_HISTOGRAM_VIDEO_HEIGHT | 2613 #undef UMA_HISTOGRAM_VIDEO_HEIGHT |
2605 | 2614 |
2606 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { | 2615 void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { |
2607 tick_clock_.reset(tick_clock); | 2616 tick_clock_.reset(tick_clock); |
2608 buffered_data_source_host_.SetTickClockForTest(tick_clock); | 2617 buffered_data_source_host_.SetTickClockForTest(tick_clock); |
2609 } | 2618 } |
2610 | 2619 |
2611 } // namespace media | 2620 } // namespace media |
OLD | NEW |