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

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

Issue 2387293007: Register MediaPlayerRenderer service (Closed)
Patch Set: Typo. 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
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/mojo/clients/mojo_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
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"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 #if defined(OS_ANDROID) // WMPI_CAST 220 #if defined(OS_ANDROID) // WMPI_CAST
220 cast_impl_(this, client_, params.context_3d_cb()), 221 cast_impl_(this, client_, params.context_3d_cb()),
221 #endif 222 #endif
222 volume_(1.0), 223 volume_(1.0),
223 volume_multiplier_(1.0), 224 volume_multiplier_(1.0),
224 renderer_factory_(std::move(renderer_factory)), 225 renderer_factory_(std::move(renderer_factory)),
225 surface_manager_(params.surface_manager()), 226 surface_manager_(params.surface_manager()),
226 overlay_surface_id_(SurfaceManager::kNoSurfaceID), 227 overlay_surface_id_(SurfaceManager::kNoSurfaceID),
227 suppress_destruction_errors_(false), 228 suppress_destruction_errors_(false),
228 can_suspend_state_(CanSuspendState::UNKNOWN), 229 can_suspend_state_(CanSuspendState::UNKNOWN),
230 use_fallback_path_(false),
229 is_encrypted_(false), 231 is_encrypted_(false),
230 underflow_count_(0), 232 underflow_count_(0),
231 observer_(params.media_observer()) { 233 observer_(params.media_observer()) {
232 DCHECK(!adjust_allocated_memory_cb_.is_null()); 234 DCHECK(!adjust_allocated_memory_cb_.is_null());
233 DCHECK(renderer_factory_); 235 DCHECK(renderer_factory_);
234 DCHECK(client_); 236 DCHECK(client_);
235 237
236 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 238 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
237 switches::kForceVideoOverlays); 239 switches::kForceVideoOverlays);
238 240
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 CORSMode cors_mode) { 353 CORSMode cors_mode) {
352 DVLOG(1) << __func__; 354 DVLOG(1) << __func__;
353 DCHECK(main_task_runner_->BelongsToCurrentThread()); 355 DCHECK(main_task_runner_->BelongsToCurrentThread());
354 356
355 GURL gurl(url); 357 GURL gurl(url);
356 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); 358 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin());
357 359
358 // Set subresource URL for crash reporting. 360 // Set subresource URL for crash reporting.
359 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); 361 base::debug::SetCrashKeyValue("subresource_url", gurl.spec());
360 362
363 if (use_fallback_path_)
364 fallback_url_ = gurl;
365
361 load_type_ = load_type; 366 load_type_ = load_type;
362 367
363 SetNetworkState(WebMediaPlayer::NetworkStateLoading); 368 SetNetworkState(WebMediaPlayer::NetworkStateLoading);
364 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); 369 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing);
365 media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8())); 370 media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8()));
366 371
367 // Media source pipelines can start immediately. 372 // Media source pipelines can start immediately.
368 if (load_type == LoadTypeMediaSource) { 373 if (load_type == LoadTypeMediaSource) {
369 supports_save_ = false; 374 supports_save_ = false;
370 StartPipeline(); 375 StartPipeline();
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 return video_weblayer_->bounds(); 1391 return video_weblayer_->bounds();
1387 } 1392 }
1388 1393
1389 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { 1394 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) {
1390 cast_impl_.SetDeviceScaleFactor(scale_factor); 1395 cast_impl_.SetDeviceScaleFactor(scale_factor);
1391 } 1396 }
1392 1397
1393 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { 1398 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) {
1394 cast_impl_.setPoster(poster); 1399 cast_impl_.setPoster(poster);
1395 } 1400 }
1401
1402 void WebMediaPlayerImpl::SetUseFallbackPath(bool use_fallback_path) {
1403 use_fallback_path_ = use_fallback_path;
1404 }
1396 #endif // defined(OS_ANDROID) // WMPI_CAST 1405 #endif // defined(OS_ANDROID) // WMPI_CAST
1397 1406
1398 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { 1407 void WebMediaPlayerImpl::DataSourceInitialized(bool success) {
1399 DVLOG(1) << __func__; 1408 DVLOG(1) << __func__;
1400 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1409 DCHECK(main_task_runner_->BelongsToCurrentThread());
1401 1410
1402 #if defined(OS_ANDROID) 1411 #if defined(OS_ANDROID)
1403 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are 1412 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are
1404 // encountered, instruct the HTML media element to create a new WebMediaPlayer 1413 // encountered, instruct the HTML media element to create a new WebMediaPlayer
1405 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. 1414 // instance with the correct URL to trigger WebMediaPlayerAndroid creation.
1406 // 1415 //
1407 // TODO(tguilbert): Remove this code path once we have the ability to host a 1416 // TODO(tguilbert): Remove this code path once we have the ability to host a
1408 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 1417 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626
1409 if (data_source_) { 1418 if (data_source_ && !use_fallback_path_) {
1410 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects(); 1419 const GURL url_after_redirects = data_source_->GetUrlAfterRedirects();
1411 if (MediaCodecUtil::IsHLSURL(url_after_redirects)) { 1420 if (MediaCodecUtil::IsHLSURL(url_after_redirects)) {
1412 client_->requestReload(url_after_redirects); 1421 client_->requestReload(url_after_redirects);
1413 // |this| may be destructed, do nothing after this. 1422 // |this| may be destructed, do nothing after this.
1414 return; 1423 return;
1415 } 1424 }
1416 } 1425 }
1417 #endif 1426 #endif
1418 1427
1419 if (!success) { 1428 if (!success) {
(...skipping 28 matching lines...) Expand all
1448 overlay_surface_id_ = surface_id; 1457 overlay_surface_id_ = surface_id;
1449 if (!pending_surface_request_cb_.is_null()) 1458 if (!pending_surface_request_cb_.is_null())
1450 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); 1459 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id);
1451 } 1460 }
1452 1461
1453 // TODO(watk): Move this state management out of WMPI. 1462 // TODO(watk): Move this state management out of WMPI.
1454 void WebMediaPlayerImpl::OnSurfaceRequested( 1463 void WebMediaPlayerImpl::OnSurfaceRequested(
1455 const SurfaceCreatedCB& surface_created_cb) { 1464 const SurfaceCreatedCB& surface_created_cb) {
1456 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1465 DCHECK(main_task_runner_->BelongsToCurrentThread());
1457 DCHECK(surface_manager_); 1466 DCHECK(surface_manager_);
1467 DCHECK(!use_fallback_path_);
1458 1468
1459 // A null callback indicates that the decoder is going away. 1469 // A null callback indicates that the decoder is going away.
1460 if (surface_created_cb.is_null()) { 1470 if (surface_created_cb.is_null()) {
1461 decoder_requires_restart_for_overlay_ = false; 1471 decoder_requires_restart_for_overlay_ = false;
1462 pending_surface_request_cb_.Reset(); 1472 pending_surface_request_cb_.Reset();
1463 return; 1473 return;
1464 } 1474 }
1465 1475
1466 // If we're getting a surface request it means GVD is initializing, so until 1476 // If we're getting a surface request it means GVD is initializing, so until
1467 // we get a null surface request, GVD is the active decoder. While that's the 1477 // we get a null surface request, GVD is the active decoder. While that's the
(...skipping 27 matching lines...) Expand all
1495 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), 1505 media_task_runner_, worker_task_runner_, audio_source_provider_.get(),
1496 compositor_, request_surface_cb); 1506 compositor_, request_surface_cb);
1497 } 1507 }
1498 1508
1499 void WebMediaPlayerImpl::StartPipeline() { 1509 void WebMediaPlayerImpl::StartPipeline() {
1500 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1510 DCHECK(main_task_runner_->BelongsToCurrentThread());
1501 1511
1502 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = 1512 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
1503 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); 1513 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData);
1504 1514
1515 if (use_fallback_path_) {
1516 demuxer_.reset(new MediaUrlDemuxer(media_task_runner_, fallback_url_));
1517 pipeline_controller_.Start(demuxer_.get(), this, false, false);
1518 return;
1519 }
1520
1505 // Figure out which demuxer to use. 1521 // Figure out which demuxer to use.
1506 if (load_type_ != LoadTypeMediaSource) { 1522 if (load_type_ != LoadTypeMediaSource) {
1507 DCHECK(!chunk_demuxer_); 1523 DCHECK(!chunk_demuxer_);
1508 DCHECK(data_source_); 1524 DCHECK(data_source_);
1509 1525
1510 #if !defined(MEDIA_DISABLE_FFMPEG) 1526 #if !defined(MEDIA_DISABLE_FFMPEG)
1511 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = 1527 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb =
1512 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); 1528 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated);
1513 1529
1514 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), 1530 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 pipeline_metadata_.natural_size, 1881 pipeline_metadata_.natural_size,
1866 base::Bind(&GetCurrentTimeInternal, this))); 1882 base::Bind(&GetCurrentTimeInternal, this)));
1867 watch_time_reporter_->OnVolumeChange(volume_); 1883 watch_time_reporter_->OnVolumeChange(volume_);
1868 if (delegate_ && delegate_->IsHidden()) 1884 if (delegate_ && delegate_->IsHidden())
1869 watch_time_reporter_->OnHidden(); 1885 watch_time_reporter_->OnHidden();
1870 else 1886 else
1871 watch_time_reporter_->OnShown(); 1887 watch_time_reporter_->OnShown();
1872 } 1888 }
1873 1889
1874 } // namespace media 1890 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/mojo/clients/mojo_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698