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 17 matching lines...) Expand all Loading... | |
28 #include "cc/blink/web_layer_impl.h" | 28 #include "cc/blink/web_layer_impl.h" |
29 #include "cc/layers/video_layer.h" | 29 #include "cc/layers/video_layer.h" |
30 #include "media/audio/null_audio_sink.h" | 30 #include "media/audio/null_audio_sink.h" |
31 #include "media/base/bind_to_current_loop.h" | 31 #include "media/base/bind_to_current_loop.h" |
32 #include "media/base/cdm_context.h" | 32 #include "media/base/cdm_context.h" |
33 #include "media/base/limits.h" | 33 #include "media/base/limits.h" |
34 #include "media/base/media_content_type.h" | 34 #include "media/base/media_content_type.h" |
35 #include "media/base/media_keys.h" | 35 #include "media/base/media_keys.h" |
36 #include "media/base/media_log.h" | 36 #include "media/base/media_log.h" |
37 #include "media/base/media_switches.h" | 37 #include "media/base/media_switches.h" |
38 #include "media/base/media_url_demuxer.h" | |
38 #include "media/base/text_renderer.h" | 39 #include "media/base/text_renderer.h" |
39 #include "media/base/timestamp_constants.h" | 40 #include "media/base/timestamp_constants.h" |
40 #include "media/base/video_frame.h" | 41 #include "media/base/video_frame.h" |
41 #include "media/blink/texttrack_impl.h" | 42 #include "media/blink/texttrack_impl.h" |
42 #include "media/blink/watch_time_reporter.h" | 43 #include "media/blink/watch_time_reporter.h" |
43 #include "media/blink/webaudiosourceprovider_impl.h" | 44 #include "media/blink/webaudiosourceprovider_impl.h" |
44 #include "media/blink/webcontentdecryptionmodule_impl.h" | 45 #include "media/blink/webcontentdecryptionmodule_impl.h" |
45 #include "media/blink/webinbandtexttrack_impl.h" | 46 #include "media/blink/webinbandtexttrack_impl.h" |
46 #include "media/blink/webmediaplayer_delegate.h" | 47 #include "media/blink/webmediaplayer_delegate.h" |
47 #include "media/blink/webmediaplayer_util.h" | 48 #include "media/blink/webmediaplayer_util.h" |
48 #include "media/blink/webmediasource_impl.h" | 49 #include "media/blink/webmediasource_impl.h" |
49 #include "media/filters/chunk_demuxer.h" | 50 #include "media/filters/chunk_demuxer.h" |
50 #include "media/filters/ffmpeg_demuxer.h" | 51 #include "media/filters/ffmpeg_demuxer.h" |
52 #include "media/media_features.h" | |
tguilbert
2016/10/11 18:54:33
Will remove.
tguilbert
2016/10/12 21:46:25
Done.
| |
51 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" | 53 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" |
52 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 54 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
53 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" | 55 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" |
54 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 56 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
55 #include "third_party/WebKit/public/platform/WebMediaSource.h" | 57 #include "third_party/WebKit/public/platform/WebMediaSource.h" |
56 #include "third_party/WebKit/public/platform/WebRect.h" | 58 #include "third_party/WebKit/public/platform/WebRect.h" |
57 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 59 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
58 #include "third_party/WebKit/public/platform/WebSize.h" | 60 #include "third_party/WebKit/public/platform/WebSize.h" |
59 #include "third_party/WebKit/public/platform/WebString.h" | 61 #include "third_party/WebKit/public/platform/WebString.h" |
60 #include "third_party/WebKit/public/platform/WebURL.h" | 62 #include "third_party/WebKit/public/platform/WebURL.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 #if defined(OS_ANDROID) // WMPI_CAST | 221 #if defined(OS_ANDROID) // WMPI_CAST |
220 cast_impl_(this, client_, params.context_3d_cb()), | 222 cast_impl_(this, client_, params.context_3d_cb()), |
221 #endif | 223 #endif |
222 volume_(1.0), | 224 volume_(1.0), |
223 volume_multiplier_(1.0), | 225 volume_multiplier_(1.0), |
224 renderer_factory_(std::move(renderer_factory)), | 226 renderer_factory_(std::move(renderer_factory)), |
225 surface_manager_(params.surface_manager()), | 227 surface_manager_(params.surface_manager()), |
226 overlay_surface_id_(SurfaceManager::kNoSurfaceID), | 228 overlay_surface_id_(SurfaceManager::kNoSurfaceID), |
227 suppress_destruction_errors_(false), | 229 suppress_destruction_errors_(false), |
228 can_suspend_state_(CanSuspendState::UNKNOWN), | 230 can_suspend_state_(CanSuspendState::UNKNOWN), |
231 use_fallback_path_(false), | |
229 is_encrypted_(false), | 232 is_encrypted_(false), |
230 underflow_count_(0) { | 233 underflow_count_(0) { |
231 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 234 DCHECK(!adjust_allocated_memory_cb_.is_null()); |
232 DCHECK(renderer_factory_); | 235 DCHECK(renderer_factory_); |
233 DCHECK(client_); | 236 DCHECK(client_); |
234 | 237 |
235 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 238 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
236 switches::kForceVideoOverlays); | 239 switches::kForceVideoOverlays); |
237 | 240 |
238 disable_fullscreen_video_overlays_ = | 241 disable_fullscreen_video_overlays_ = |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 CORSMode cors_mode) { | 349 CORSMode cors_mode) { |
347 DVLOG(1) << __func__; | 350 DVLOG(1) << __func__; |
348 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 351 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
349 | 352 |
350 GURL gurl(url); | 353 GURL gurl(url); |
351 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); | 354 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); |
352 | 355 |
353 // Set subresource URL for crash reporting. | 356 // Set subresource URL for crash reporting. |
354 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); | 357 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); |
355 | 358 |
359 if (use_fallback_path_) | |
360 fallback_url_ = gurl; | |
361 | |
356 load_type_ = load_type; | 362 load_type_ = load_type; |
357 | 363 |
358 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 364 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
359 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 365 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
360 media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8())); | 366 media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8())); |
361 | 367 |
362 // Media source pipelines can start immediately. | 368 // Media source pipelines can start immediately. |
363 if (load_type == LoadTypeMediaSource) { | 369 if (load_type == LoadTypeMediaSource) { |
364 supports_save_ = false; | 370 supports_save_ = false; |
365 StartPipeline(); | 371 StartPipeline(); |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1366 return video_weblayer_->bounds(); | 1372 return video_weblayer_->bounds(); |
1367 } | 1373 } |
1368 | 1374 |
1369 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { | 1375 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { |
1370 cast_impl_.SetDeviceScaleFactor(scale_factor); | 1376 cast_impl_.SetDeviceScaleFactor(scale_factor); |
1371 } | 1377 } |
1372 | 1378 |
1373 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { | 1379 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { |
1374 cast_impl_.setPoster(poster); | 1380 cast_impl_.setPoster(poster); |
1375 } | 1381 } |
1382 | |
1383 void WebMediaPlayerImpl::SetUseFallbackPath(bool use_fallback_path) { | |
1384 use_fallback_path = true; | |
1385 } | |
1376 #endif // defined(OS_ANDROID) // WMPI_CAST | 1386 #endif // defined(OS_ANDROID) // WMPI_CAST |
1377 | 1387 |
1378 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { | 1388 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { |
1379 DVLOG(1) << __func__; | 1389 DVLOG(1) << __func__; |
1380 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1390 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1381 | 1391 |
1382 #if defined(OS_ANDROID) | 1392 #if defined(OS_ANDROID) |
1383 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are | 1393 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are |
1384 // encountered, instruct the HTML media element to create a new WebMediaPlayer | 1394 // encountered, instruct the HTML media element to create a new WebMediaPlayer |
1385 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. | 1395 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. |
1386 // | 1396 // |
1387 // TODO(tguilbert): Remove this code path once we have the ability to host a | 1397 // TODO(tguilbert): Remove this code path once we have the ability to host a |
1388 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 | 1398 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 |
1389 if (data_source_) { | 1399 if (data_source_ && !use_fallback_path_) { |
1390 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects(); | 1400 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects(); |
1391 if (MediaCodecUtil::IsHLSPath(url_after_redirects)) { | 1401 if (MediaCodecUtil::IsHLSPath(url_after_redirects)) { |
1392 client_->requestReload(url_after_redirects); | 1402 client_->requestReload(url_after_redirects); |
1393 // |this| may be destructed, do nothing after this. | 1403 // |this| may be destructed, do nothing after this. |
1394 return; | 1404 return; |
1395 } | 1405 } |
1396 } | 1406 } |
1397 #endif | 1407 #endif |
1398 | 1408 |
1399 if (!success) { | 1409 if (!success) { |
(...skipping 28 matching lines...) Expand all Loading... | |
1428 overlay_surface_id_ = surface_id; | 1438 overlay_surface_id_ = surface_id; |
1429 if (!pending_surface_request_cb_.is_null()) | 1439 if (!pending_surface_request_cb_.is_null()) |
1430 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); | 1440 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); |
1431 } | 1441 } |
1432 | 1442 |
1433 // TODO(watk): Move this state management out of WMPI. | 1443 // TODO(watk): Move this state management out of WMPI. |
1434 void WebMediaPlayerImpl::OnSurfaceRequested( | 1444 void WebMediaPlayerImpl::OnSurfaceRequested( |
1435 const SurfaceCreatedCB& surface_created_cb) { | 1445 const SurfaceCreatedCB& surface_created_cb) { |
1436 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1446 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1437 DCHECK(surface_manager_); | 1447 DCHECK(surface_manager_); |
1448 DCHECK(!use_fallback_path_); | |
1438 | 1449 |
1439 // A null callback indicates that the decoder is going away. | 1450 // A null callback indicates that the decoder is going away. |
1440 if (surface_created_cb.is_null()) { | 1451 if (surface_created_cb.is_null()) { |
1441 decoder_requires_restart_for_overlay_ = false; | 1452 decoder_requires_restart_for_overlay_ = false; |
1442 pending_surface_request_cb_.Reset(); | 1453 pending_surface_request_cb_.Reset(); |
1443 return; | 1454 return; |
1444 } | 1455 } |
1445 | 1456 |
1446 // If we're getting a surface request it means GVD is initializing, so until | 1457 // If we're getting a surface request it means GVD is initializing, so until |
1447 // we get a null surface request, GVD is the active decoder. While that's the | 1458 // we get a null surface request, GVD is the active decoder. While that's the |
(...skipping 27 matching lines...) Expand all Loading... | |
1475 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), | 1486 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), |
1476 compositor_, request_surface_cb); | 1487 compositor_, request_surface_cb); |
1477 } | 1488 } |
1478 | 1489 |
1479 void WebMediaPlayerImpl::StartPipeline() { | 1490 void WebMediaPlayerImpl::StartPipeline() { |
1480 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1491 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1481 | 1492 |
1482 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = | 1493 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = |
1483 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); | 1494 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); |
1484 | 1495 |
1496 if (use_fallback_path_) { | |
1497 demuxer_.reset(new MediaUrlDemuxer(media_task_runner_, fallback_url_)); | |
1498 | |
1499 // TODO(tguilbert): For reviewers -- What are the proper values for | |
1500 // |is_streaming| and |is_static|? | |
liberato (no reviews please)
2016/10/12 15:15:18
false, false i think is fine. i think that it mat
tguilbert
2016/10/12 21:46:25
Done.
| |
1501 pipeline_controller_.Start(demuxer_.get(), this, false, false); | |
1502 return; | |
1503 } | |
1504 | |
1485 // Figure out which demuxer to use. | 1505 // Figure out which demuxer to use. |
1486 if (load_type_ != LoadTypeMediaSource) { | 1506 if (load_type_ != LoadTypeMediaSource) { |
1487 DCHECK(!chunk_demuxer_); | 1507 DCHECK(!chunk_demuxer_); |
1488 DCHECK(data_source_); | 1508 DCHECK(data_source_); |
1489 | 1509 |
1490 #if !defined(MEDIA_DISABLE_FFMPEG) | 1510 #if !defined(MEDIA_DISABLE_FFMPEG) |
1491 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = | 1511 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = |
1492 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); | 1512 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); |
1493 | 1513 |
1494 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), | 1514 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1836 pipeline_metadata_.natural_size, | 1856 pipeline_metadata_.natural_size, |
1837 base::Bind(&GetCurrentTimeInternal, this))); | 1857 base::Bind(&GetCurrentTimeInternal, this))); |
1838 watch_time_reporter_->OnVolumeChange(volume_); | 1858 watch_time_reporter_->OnVolumeChange(volume_); |
1839 if (delegate_ && delegate_->IsHidden()) | 1859 if (delegate_ && delegate_->IsHidden()) |
1840 watch_time_reporter_->OnHidden(); | 1860 watch_time_reporter_->OnHidden(); |
1841 else | 1861 else |
1842 watch_time_reporter_->OnShown(); | 1862 watch_time_reporter_->OnShown(); |
1843 } | 1863 } |
1844 | 1864 |
1845 } // namespace media | 1865 } // namespace media |
OLD | NEW |