Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2387293007: Register MediaPlayerRenderer service (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 #include "build/build_config.h" 27 #include "build/build_config.h"
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_log.h" 35 #include "media/base/media_log.h"
36 #include "media/base/media_switches.h" 36 #include "media/base/media_switches.h"
37 #include "media/base/media_url_demuxer.h"
37 #include "media/base/text_renderer.h" 38 #include "media/base/text_renderer.h"
38 #include "media/base/timestamp_constants.h" 39 #include "media/base/timestamp_constants.h"
39 #include "media/base/video_frame.h" 40 #include "media/base/video_frame.h"
40 #include "media/blink/texttrack_impl.h" 41 #include "media/blink/texttrack_impl.h"
41 #include "media/blink/watch_time_reporter.h" 42 #include "media/blink/watch_time_reporter.h"
42 #include "media/blink/webaudiosourceprovider_impl.h" 43 #include "media/blink/webaudiosourceprovider_impl.h"
43 #include "media/blink/webcontentdecryptionmodule_impl.h" 44 #include "media/blink/webcontentdecryptionmodule_impl.h"
44 #include "media/blink/webinbandtexttrack_impl.h" 45 #include "media/blink/webinbandtexttrack_impl.h"
45 #include "media/blink/webmediaplayer_delegate.h" 46 #include "media/blink/webmediaplayer_delegate.h"
46 #include "media/blink/webmediaplayer_util.h" 47 #include "media/blink/webmediaplayer_util.h"
47 #include "media/blink/webmediasource_impl.h" 48 #include "media/blink/webmediasource_impl.h"
48 #include "media/filters/chunk_demuxer.h" 49 #include "media/filters/chunk_demuxer.h"
49 #include "media/filters/ffmpeg_demuxer.h" 50 #include "media/filters/ffmpeg_demuxer.h"
51 #include "media/media_features.h"
50 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" 52 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h"
51 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 53 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
52 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" 54 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h"
53 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" 55 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h"
54 #include "third_party/WebKit/public/platform/WebMediaSource.h" 56 #include "third_party/WebKit/public/platform/WebMediaSource.h"
55 #include "third_party/WebKit/public/platform/WebRect.h" 57 #include "third_party/WebKit/public/platform/WebRect.h"
56 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 58 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
57 #include "third_party/WebKit/public/platform/WebSize.h" 59 #include "third_party/WebKit/public/platform/WebSize.h"
58 #include "third_party/WebKit/public/platform/WebString.h" 60 #include "third_party/WebKit/public/platform/WebString.h"
59 #include "third_party/WebKit/public/platform/WebURL.h" 61 #include "third_party/WebKit/public/platform/WebURL.h"
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 1217
1216 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); 1218 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged");
1217 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( 1219 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(
1218 rotated_size.width(), rotated_size.height())); 1220 rotated_size.width(), rotated_size.height()));
1219 1221
1220 if (overlay_enabled_ && surface_manager_) 1222 if (overlay_enabled_ && surface_manager_)
1221 surface_manager_->NaturalSizeChanged(rotated_size); 1223 surface_manager_->NaturalSizeChanged(rotated_size);
1222 1224
1223 pipeline_metadata_.natural_size = rotated_size; 1225 pipeline_metadata_.natural_size = rotated_size;
1224 client_->sizeChanged(); 1226 client_->sizeChanged();
1227
1228 // Re-create the WatchTimeReporter, since it was created using an initial
1229 // video size of (0,0).
1230 if (use_fallback_path_)
liberato (no reviews please) 2016/10/07 20:17:38 if we aren't doing this on every natural size chan
tguilbert 2016/10/11 18:54:33 Ok. I need to do an HLS related UMA cleanup anyway
1231 CreateWatchTimeReporter();
1225 } 1232 }
1226 1233
1227 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { 1234 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) {
1228 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1235 DCHECK(main_task_runner_->BelongsToCurrentThread());
1229 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 1236 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
1230 1237
1231 opaque_ = opaque; 1238 opaque_ = opaque;
1232 // Modify content opaqueness of cc::Layer directly so that 1239 // Modify content opaqueness of cc::Layer directly so that
1233 // SetContentsOpaqueIsFixed is ignored. 1240 // SetContentsOpaqueIsFixed is ignored.
1234 if (video_weblayer_) 1241 if (video_weblayer_)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 return video_weblayer_->bounds(); 1352 return video_weblayer_->bounds();
1346 } 1353 }
1347 1354
1348 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { 1355 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) {
1349 cast_impl_.SetDeviceScaleFactor(scale_factor); 1356 cast_impl_.SetDeviceScaleFactor(scale_factor);
1350 } 1357 }
1351 1358
1352 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { 1359 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) {
1353 cast_impl_.setPoster(poster); 1360 cast_impl_.setPoster(poster);
1354 } 1361 }
1362
1363 void WebMediaPlayerImpl::EnableFallbackMediaPlayer(const GURL& url) {
liberato (no reviews please) 2016/10/07 20:17:37 this is very implementation-detail-like for an ext
tguilbert 2016/10/11 18:54:33 Right now, as of this patch, |use_fallback_path_|
1364 fallback_url_ = url;
liberato (no reviews please) 2016/10/06 14:55:46 what's the difference between this and the one use
tguilbert 2016/10/11 18:54:33 None. Updated :)
1365 use_fallback_path_ = true;
1366 }
1355 #endif // defined(OS_ANDROID) // WMPI_CAST 1367 #endif // defined(OS_ANDROID) // WMPI_CAST
1356 1368
1357 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { 1369 void WebMediaPlayerImpl::DataSourceInitialized(bool success) {
1358 DVLOG(1) << __func__; 1370 DVLOG(1) << __func__;
1359 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1371 DCHECK(main_task_runner_->BelongsToCurrentThread());
1360 1372
1361 #if defined(OS_ANDROID) 1373 #if defined(OS_ANDROID) && !BUILDFLAG(ENABLE_MOJO_MEDIA_PLAYER_RENDERER)
1362 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are 1374 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are
1363 // encountered, instruct the HTML media element to create a new WebMediaPlayer 1375 // encountered, instruct the HTML media element to create a new WebMediaPlayer
1364 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. 1376 // instance with the correct URL to trigger WebMediaPlayerAndroid creation.
1365 // 1377 //
1366 // TODO(tguilbert): Remove this code path once we have the ability to host a 1378 // TODO(tguilbert): Remove this code path once we have the ability to host a
1367 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 1379 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626
1368 if (data_source_) { 1380 if (data_source_) {
1369 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects(); 1381 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects();
1370 if (MediaCodecUtil::IsHLSPath(url_after_redirects)) { 1382 if (MediaCodecUtil::IsHLSPath(url_after_redirects)) {
1371 client_->requestReload(url_after_redirects); 1383 client_->requestReload(url_after_redirects);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 overlay_surface_id_ = surface_id; 1419 overlay_surface_id_ = surface_id;
1408 if (!pending_surface_request_cb_.is_null()) 1420 if (!pending_surface_request_cb_.is_null())
1409 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); 1421 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id);
1410 } 1422 }
1411 1423
1412 // TODO(watk): Move this state management out of WMPI. 1424 // TODO(watk): Move this state management out of WMPI.
1413 void WebMediaPlayerImpl::OnSurfaceRequested( 1425 void WebMediaPlayerImpl::OnSurfaceRequested(
1414 const SurfaceCreatedCB& surface_created_cb) { 1426 const SurfaceCreatedCB& surface_created_cb) {
1415 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1427 DCHECK(main_task_runner_->BelongsToCurrentThread());
1416 DCHECK(surface_manager_); 1428 DCHECK(surface_manager_);
1429 DCHECK(!use_fallback_path_);
1417 1430
1418 // A null callback indicates that the decoder is going away. 1431 // A null callback indicates that the decoder is going away.
1419 if (surface_created_cb.is_null()) { 1432 if (surface_created_cb.is_null()) {
1420 decoder_requires_restart_for_overlay_ = false; 1433 decoder_requires_restart_for_overlay_ = false;
1421 pending_surface_request_cb_.Reset(); 1434 pending_surface_request_cb_.Reset();
1422 return; 1435 return;
1423 } 1436 }
1424 1437
1425 // If we're getting a surface request it means GVD is initializing, so until 1438 // If we're getting a surface request it means GVD is initializing, so until
1426 // we get a null surface request, GVD is the active decoder. While that's the 1439 // we get a null surface request, GVD is the active decoder. While that's the
(...skipping 27 matching lines...) Expand all
1454 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), 1467 media_task_runner_, worker_task_runner_, audio_source_provider_.get(),
1455 compositor_, request_surface_cb); 1468 compositor_, request_surface_cb);
1456 } 1469 }
1457 1470
1458 void WebMediaPlayerImpl::StartPipeline() { 1471 void WebMediaPlayerImpl::StartPipeline() {
1459 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1472 DCHECK(main_task_runner_->BelongsToCurrentThread());
1460 1473
1461 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = 1474 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
1462 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); 1475 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData);
1463 1476
1477 if (use_fallback_path_) {
1478 demuxer_.reset(new MediaUrlDemuxer(media_task_runner_, fallback_url_));
1479
1480 // TODO(tguilbert): For reviewers -- What are the proper values for
1481 // |is_streaming| and |is_static|?
1482 pipeline_controller_.Start(demuxer_.get(), this, false, false);
1483 return;
1484 }
1485
1464 // Figure out which demuxer to use. 1486 // Figure out which demuxer to use.
1465 if (load_type_ != LoadTypeMediaSource) { 1487 if (load_type_ != LoadTypeMediaSource) {
1466 DCHECK(!chunk_demuxer_); 1488 DCHECK(!chunk_demuxer_);
1467 DCHECK(data_source_); 1489 DCHECK(data_source_);
1468 1490
1469 #if !defined(MEDIA_DISABLE_FFMPEG) 1491 #if !defined(MEDIA_DISABLE_FFMPEG)
1470 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = 1492 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb =
1471 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); 1493 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated);
1472 1494
1473 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), 1495 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 pipeline_metadata_.natural_size, 1837 pipeline_metadata_.natural_size,
1816 base::Bind(&GetCurrentTimeInternal, this))); 1838 base::Bind(&GetCurrentTimeInternal, this)));
1817 watch_time_reporter_->OnVolumeChange(volume_); 1839 watch_time_reporter_->OnVolumeChange(volume_);
1818 if (delegate_ && delegate_->IsHidden()) 1840 if (delegate_ && delegate_->IsHidden())
1819 watch_time_reporter_->OnHidden(); 1841 watch_time_reporter_->OnHidden();
1820 else 1842 else
1821 watch_time_reporter_->OnShown(); 1843 watch_time_reporter_->OnShown();
1822 } 1844 }
1823 1845
1824 } // namespace media 1846 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698