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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 media_log_->AddEvent( | 258 media_log_->AddEvent( |
259 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 259 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
260 } | 260 } |
261 | 261 |
262 void WebMediaPlayerImpl::load(LoadType load_type, | 262 void WebMediaPlayerImpl::load(LoadType load_type, |
263 const blink::WebMediaPlayerSource& source, | 263 const blink::WebMediaPlayerSource& source, |
264 CORSMode cors_mode) { | 264 CORSMode cors_mode) { |
265 // Only URL or MSE blob URL is supported. | 265 // Only URL or MSE blob URL is supported. |
266 DCHECK(source.isURL()); | 266 DCHECK(source.isURL()); |
267 blink::WebURL url = source.getAsURL(); | 267 blink::WebURL url = source.getAsURL(); |
268 DVLOG(1) << __FUNCTION__ << "(" << load_type << ", " << url << ", " | 268 DVLOG(1) << __func__ << "(" << load_type << ", " << url << ", " << cors_mode |
269 << cors_mode << ")"; | 269 << ")"; |
270 if (!defer_load_cb_.is_null()) { | 270 if (!defer_load_cb_.is_null()) { |
271 defer_load_cb_.Run(base::Bind( | 271 defer_load_cb_.Run(base::Bind( |
272 &WebMediaPlayerImpl::DoLoad, AsWeakPtr(), load_type, url, cors_mode)); | 272 &WebMediaPlayerImpl::DoLoad, AsWeakPtr(), load_type, url, cors_mode)); |
273 return; | 273 return; |
274 } | 274 } |
275 DoLoad(load_type, url, cors_mode); | 275 DoLoad(load_type, url, cors_mode); |
276 } | 276 } |
277 | 277 |
278 bool WebMediaPlayerImpl::supportsOverlayFullscreenVideo() { | 278 bool WebMediaPlayerImpl::supportsOverlayFullscreenVideo() { |
279 #if defined(OS_ANDROID) | 279 #if defined(OS_ANDROID) |
(...skipping 19 matching lines...) Expand all Loading... |
299 fullscreen_ = false; | 299 fullscreen_ = false; |
300 surface_created_cb_.Cancel(); | 300 surface_created_cb_.Cancel(); |
301 fullscreen_surface_id_ = SurfaceManager::kNoSurfaceID; | 301 fullscreen_surface_id_ = SurfaceManager::kNoSurfaceID; |
302 if (decoder_requires_restart_for_fullscreen_) | 302 if (decoder_requires_restart_for_fullscreen_) |
303 ScheduleRestart(); | 303 ScheduleRestart(); |
304 } | 304 } |
305 | 305 |
306 void WebMediaPlayerImpl::DoLoad(LoadType load_type, | 306 void WebMediaPlayerImpl::DoLoad(LoadType load_type, |
307 const blink::WebURL& url, | 307 const blink::WebURL& url, |
308 CORSMode cors_mode) { | 308 CORSMode cors_mode) { |
309 DVLOG(1) << __FUNCTION__; | 309 DVLOG(1) << __func__; |
310 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 310 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
311 | 311 |
312 GURL gurl(url); | 312 GURL gurl(url); |
313 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); | 313 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); |
314 | 314 |
315 // Set subresource URL for crash reporting. | 315 // Set subresource URL for crash reporting. |
316 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); | 316 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); |
317 | 317 |
318 load_type_ = load_type; | 318 load_type_ = load_type; |
319 | 319 |
(...skipping 29 matching lines...) Expand all Loading... |
349 data_source_->Initialize( | 349 data_source_->Initialize( |
350 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); | 350 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); |
351 } | 351 } |
352 | 352 |
353 #if defined(OS_ANDROID) // WMPI_CAST | 353 #if defined(OS_ANDROID) // WMPI_CAST |
354 cast_impl_.Initialize(url, frame_, delegate_id_); | 354 cast_impl_.Initialize(url, frame_, delegate_id_); |
355 #endif | 355 #endif |
356 } | 356 } |
357 | 357 |
358 void WebMediaPlayerImpl::play() { | 358 void WebMediaPlayerImpl::play() { |
359 DVLOG(1) << __FUNCTION__; | 359 DVLOG(1) << __func__; |
360 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 360 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
361 | 361 |
362 #if defined(OS_ANDROID) // WMPI_CAST | 362 #if defined(OS_ANDROID) // WMPI_CAST |
363 if (isRemote()) { | 363 if (isRemote()) { |
364 cast_impl_.play(); | 364 cast_impl_.play(); |
365 return; | 365 return; |
366 } | 366 } |
367 #endif | 367 #endif |
368 | 368 |
369 paused_ = false; | 369 paused_ = false; |
370 is_idle_ = false; | 370 is_idle_ = false; |
371 pipeline_.SetPlaybackRate(playback_rate_); | 371 pipeline_.SetPlaybackRate(playback_rate_); |
372 | 372 |
373 if (data_source_) | 373 if (data_source_) |
374 data_source_->MediaIsPlaying(); | 374 data_source_->MediaIsPlaying(); |
375 | 375 |
376 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); | 376 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); |
377 UpdatePlayState(); | 377 UpdatePlayState(); |
378 } | 378 } |
379 | 379 |
380 void WebMediaPlayerImpl::pause() { | 380 void WebMediaPlayerImpl::pause() { |
381 DVLOG(1) << __FUNCTION__; | 381 DVLOG(1) << __func__; |
382 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 382 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
383 | 383 |
384 // We update the paused state even when casting, since we expect pause() to be | 384 // We update the paused state even when casting, since we expect pause() to be |
385 // called when casting begins, and when we exit casting we should end up in a | 385 // called when casting begins, and when we exit casting we should end up in a |
386 // paused state. | 386 // paused state. |
387 paused_ = true; | 387 paused_ = true; |
388 | 388 |
389 #if defined(OS_ANDROID) // WMPI_CAST | 389 #if defined(OS_ANDROID) // WMPI_CAST |
390 if (isRemote()) { | 390 if (isRemote()) { |
391 cast_impl_.pause(); | 391 cast_impl_.pause(); |
(...skipping 13 matching lines...) Expand all Loading... |
405 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); | 405 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); |
406 UpdatePlayState(); | 406 UpdatePlayState(); |
407 } | 407 } |
408 | 408 |
409 bool WebMediaPlayerImpl::supportsSave() const { | 409 bool WebMediaPlayerImpl::supportsSave() const { |
410 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 410 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
411 return supports_save_; | 411 return supports_save_; |
412 } | 412 } |
413 | 413 |
414 void WebMediaPlayerImpl::seek(double seconds) { | 414 void WebMediaPlayerImpl::seek(double seconds) { |
415 DVLOG(1) << __FUNCTION__ << "(" << seconds << "s)"; | 415 DVLOG(1) << __func__ << "(" << seconds << "s)"; |
416 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 416 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
417 DoSeek(base::TimeDelta::FromSecondsD(seconds), true); | 417 DoSeek(base::TimeDelta::FromSecondsD(seconds), true); |
418 } | 418 } |
419 | 419 |
420 void WebMediaPlayerImpl::DoSeek(base::TimeDelta time, bool time_updated) { | 420 void WebMediaPlayerImpl::DoSeek(base::TimeDelta time, bool time_updated) { |
421 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 421 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
422 | 422 |
423 #if defined(OS_ANDROID) // WMPI_CAST | 423 #if defined(OS_ANDROID) // WMPI_CAST |
424 if (isRemote()) { | 424 if (isRemote()) { |
425 cast_impl_.seek(time); | 425 cast_impl_.seek(time); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 if (paused_) | 462 if (paused_) |
463 paused_time_ = time; | 463 paused_time_ = time; |
464 pipeline_controller_.Seek(time, time_updated); | 464 pipeline_controller_.Seek(time, time_updated); |
465 | 465 |
466 // This needs to be called after Seek() so that if a resume is triggered, it | 466 // This needs to be called after Seek() so that if a resume is triggered, it |
467 // is to the correct time. | 467 // is to the correct time. |
468 UpdatePlayState(); | 468 UpdatePlayState(); |
469 } | 469 } |
470 | 470 |
471 void WebMediaPlayerImpl::setRate(double rate) { | 471 void WebMediaPlayerImpl::setRate(double rate) { |
472 DVLOG(1) << __FUNCTION__ << "(" << rate << ")"; | 472 DVLOG(1) << __func__ << "(" << rate << ")"; |
473 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 473 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
474 | 474 |
475 // TODO(kylep): Remove when support for negatives is added. Also, modify the | 475 // TODO(kylep): Remove when support for negatives is added. Also, modify the |
476 // following checks so rewind uses reasonable values also. | 476 // following checks so rewind uses reasonable values also. |
477 if (rate < 0.0) | 477 if (rate < 0.0) |
478 return; | 478 return; |
479 | 479 |
480 // Limit rates to reasonable values by clamping. | 480 // Limit rates to reasonable values by clamping. |
481 if (rate != 0.0) { | 481 if (rate != 0.0) { |
482 if (rate < kMinRate) | 482 if (rate < kMinRate) |
483 rate = kMinRate; | 483 rate = kMinRate; |
484 else if (rate > kMaxRate) | 484 else if (rate > kMaxRate) |
485 rate = kMaxRate; | 485 rate = kMaxRate; |
486 } | 486 } |
487 | 487 |
488 playback_rate_ = rate; | 488 playback_rate_ = rate; |
489 if (!paused_) { | 489 if (!paused_) { |
490 pipeline_.SetPlaybackRate(rate); | 490 pipeline_.SetPlaybackRate(rate); |
491 if (data_source_) | 491 if (data_source_) |
492 data_source_->MediaPlaybackRateChanged(rate); | 492 data_source_->MediaPlaybackRateChanged(rate); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 void WebMediaPlayerImpl::setVolume(double volume) { | 496 void WebMediaPlayerImpl::setVolume(double volume) { |
497 DVLOG(1) << __FUNCTION__ << "(" << volume << ")"; | 497 DVLOG(1) << __func__ << "(" << volume << ")"; |
498 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 498 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
499 volume_ = volume; | 499 volume_ = volume; |
500 pipeline_.SetVolume(volume_ * volume_multiplier_); | 500 pipeline_.SetVolume(volume_ * volume_multiplier_); |
501 } | 501 } |
502 | 502 |
503 void WebMediaPlayerImpl::setSinkId( | 503 void WebMediaPlayerImpl::setSinkId( |
504 const blink::WebString& sink_id, | 504 const blink::WebString& sink_id, |
505 const blink::WebSecurityOrigin& security_origin, | 505 const blink::WebSecurityOrigin& security_origin, |
506 blink::WebSetSinkIdCallbacks* web_callback) { | 506 blink::WebSetSinkIdCallbacks* web_callback) { |
507 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 507 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
508 DVLOG(1) << __FUNCTION__; | 508 DVLOG(1) << __func__; |
509 | 509 |
510 media::OutputDeviceStatusCB callback = | 510 media::OutputDeviceStatusCB callback = |
511 media::ConvertToOutputDeviceStatusCB(web_callback); | 511 media::ConvertToOutputDeviceStatusCB(web_callback); |
512 media_task_runner_->PostTask( | 512 media_task_runner_->PostTask( |
513 FROM_HERE, | 513 FROM_HERE, |
514 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, | 514 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, |
515 sink_id.utf8(), static_cast<url::Origin>(security_origin), | 515 sink_id.utf8(), static_cast<url::Origin>(security_origin), |
516 callback)); | 516 callback)); |
517 } | 517 } |
518 | 518 |
519 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE); | 519 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE); |
520 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData, | 520 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData, |
521 BufferedDataSource::METADATA); | 521 BufferedDataSource::METADATA); |
522 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadAuto, BufferedDataSource::AUTO); | 522 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadAuto, BufferedDataSource::AUTO); |
523 | 523 |
524 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { | 524 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { |
525 DVLOG(1) << __FUNCTION__ << "(" << preload << ")"; | 525 DVLOG(1) << __func__ << "(" << preload << ")"; |
526 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 526 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
527 | 527 |
528 preload_ = static_cast<BufferedDataSource::Preload>(preload); | 528 preload_ = static_cast<BufferedDataSource::Preload>(preload); |
529 if (data_source_) | 529 if (data_source_) |
530 data_source_->SetPreload(preload_); | 530 data_source_->SetPreload(preload_); |
531 } | 531 } |
532 | 532 |
533 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Normal, | 533 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Normal, |
534 BufferedDataSource::BUFFERING_STRATEGY_NORMAL); | 534 BufferedDataSource::BUFFERING_STRATEGY_NORMAL); |
535 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Aggressive, | 535 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Aggressive, |
536 BufferedDataSource::BUFFERING_STRATEGY_AGGRESSIVE); | 536 BufferedDataSource::BUFFERING_STRATEGY_AGGRESSIVE); |
537 | 537 |
538 void WebMediaPlayerImpl::setBufferingStrategy( | 538 void WebMediaPlayerImpl::setBufferingStrategy( |
539 WebMediaPlayer::BufferingStrategy buffering_strategy) { | 539 WebMediaPlayer::BufferingStrategy buffering_strategy) { |
540 DVLOG(1) << __FUNCTION__; | 540 DVLOG(1) << __func__; |
541 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 541 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
542 | 542 |
543 #if defined(OS_ANDROID) | 543 #if defined(OS_ANDROID) |
544 // We disallow aggressive buffering on Android since it matches the behavior | 544 // We disallow aggressive buffering on Android since it matches the behavior |
545 // of the platform media player and may have data usage penalties. | 545 // of the platform media player and may have data usage penalties. |
546 // TODO(dalecurtis, hubbe): We should probably stop using "pause-and-buffer" | 546 // TODO(dalecurtis, hubbe): We should probably stop using "pause-and-buffer" |
547 // everywhere. See http://crbug.com/594669 for more details. | 547 // everywhere. See http://crbug.com/594669 for more details. |
548 buffering_strategy_ = BufferedDataSource::BUFFERING_STRATEGY_NORMAL; | 548 buffering_strategy_ = BufferedDataSource::BUFFERING_STRATEGY_NORMAL; |
549 #else | 549 #else |
550 buffering_strategy_ = | 550 buffering_strategy_ = |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 } | 950 } |
951 } | 951 } |
952 | 952 |
953 void WebMediaPlayerImpl::OnDemuxerOpened() { | 953 void WebMediaPlayerImpl::OnDemuxerOpened() { |
954 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 954 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
955 client_->mediaSourceOpened( | 955 client_->mediaSourceOpened( |
956 new WebMediaSourceImpl(chunk_demuxer_, media_log_)); | 956 new WebMediaSourceImpl(chunk_demuxer_, media_log_)); |
957 } | 957 } |
958 | 958 |
959 void WebMediaPlayerImpl::OnError(PipelineStatus status) { | 959 void WebMediaPlayerImpl::OnError(PipelineStatus status) { |
960 DVLOG(1) << __FUNCTION__; | 960 DVLOG(1) << __func__; |
961 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 961 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
962 DCHECK_NE(status, PIPELINE_OK); | 962 DCHECK_NE(status, PIPELINE_OK); |
963 | 963 |
964 if (suppress_destruction_errors_) | 964 if (suppress_destruction_errors_) |
965 return; | 965 return; |
966 | 966 |
967 ReportPipelineError(load_type_, frame_->getSecurityOrigin(), status); | 967 ReportPipelineError(load_type_, frame_->getSecurityOrigin(), status); |
968 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status)); | 968 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status)); |
969 | 969 |
970 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { | 970 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { |
971 // Any error that occurs before reaching ReadyStateHaveMetadata should | 971 // Any error that occurs before reaching ReadyStateHaveMetadata should |
972 // be considered a format error. | 972 // be considered a format error. |
973 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); | 973 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); |
974 } else { | 974 } else { |
975 SetNetworkState(PipelineErrorToNetworkState(status)); | 975 SetNetworkState(PipelineErrorToNetworkState(status)); |
976 } | 976 } |
977 | 977 |
978 UpdatePlayState(); | 978 UpdatePlayState(); |
979 } | 979 } |
980 | 980 |
981 void WebMediaPlayerImpl::OnEnded() { | 981 void WebMediaPlayerImpl::OnEnded() { |
982 DVLOG(1) << __FUNCTION__; | 982 DVLOG(1) << __func__; |
983 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 983 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
984 | 984 |
985 // Ignore state changes until we've completed all outstanding operations. | 985 // Ignore state changes until we've completed all outstanding operations. |
986 if (!pipeline_controller_.IsStable()) | 986 if (!pipeline_controller_.IsStable()) |
987 return; | 987 return; |
988 | 988 |
989 ended_ = true; | 989 ended_ = true; |
990 client_->timeChanged(); | 990 client_->timeChanged(); |
991 | 991 |
992 // We don't actually want this to run until |client_| calls seek() or pause(), | 992 // We don't actually want this to run until |client_| calls seek() or pause(), |
993 // but that should have already happened in timeChanged() and so this is | 993 // but that should have already happened in timeChanged() and so this is |
994 // expected to be a no-op. | 994 // expected to be a no-op. |
995 UpdatePlayState(); | 995 UpdatePlayState(); |
996 } | 996 } |
997 | 997 |
998 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { | 998 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { |
999 DVLOG(1) << __FUNCTION__; | 999 DVLOG(1) << __func__; |
1000 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1000 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1001 | 1001 |
1002 pipeline_metadata_ = metadata; | 1002 pipeline_metadata_ = metadata; |
1003 | 1003 |
1004 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 1004 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, |
1005 VIDEO_ROTATION_MAX + 1); | 1005 VIDEO_ROTATION_MAX + 1); |
1006 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 1006 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
1007 | 1007 |
1008 if (hasVideo()) { | 1008 if (hasVideo()) { |
1009 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || | 1009 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || |
(...skipping 10 matching lines...) Expand all Loading... |
1020 compositor_, pipeline_metadata_.video_rotation))); | 1020 compositor_, pipeline_metadata_.video_rotation))); |
1021 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1021 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
1022 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1022 video_weblayer_->SetContentsOpaqueIsFixed(true); |
1023 client_->setWebLayer(video_weblayer_.get()); | 1023 client_->setWebLayer(video_weblayer_.get()); |
1024 } | 1024 } |
1025 | 1025 |
1026 UpdatePlayState(); | 1026 UpdatePlayState(); |
1027 } | 1027 } |
1028 | 1028 |
1029 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { | 1029 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { |
1030 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1030 DVLOG(1) << __func__ << "(" << state << ")"; |
1031 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1031 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1032 | 1032 |
1033 // Ignore buffering state changes until we've completed all outstanding | 1033 // Ignore buffering state changes until we've completed all outstanding |
1034 // operations. | 1034 // operations. |
1035 if (!pipeline_controller_.IsStable()) | 1035 if (!pipeline_controller_.IsStable()) |
1036 return; | 1036 return; |
1037 | 1037 |
1038 if (state == BUFFERING_HAVE_ENOUGH) { | 1038 if (state == BUFFERING_HAVE_ENOUGH) { |
1039 // TODO(chcunningham): Monitor playback position vs buffered. Potentially | 1039 // TODO(chcunningham): Monitor playback position vs buffered. Potentially |
1040 // transition to HAVE_FUTURE_DATA here if not enough is buffered. | 1040 // transition to HAVE_FUTURE_DATA here if not enough is buffered. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 | 1202 |
1203 void WebMediaPlayerImpl::requestRemotePlayback() { | 1203 void WebMediaPlayerImpl::requestRemotePlayback() { |
1204 cast_impl_.requestRemotePlayback(); | 1204 cast_impl_.requestRemotePlayback(); |
1205 } | 1205 } |
1206 | 1206 |
1207 void WebMediaPlayerImpl::requestRemotePlaybackControl() { | 1207 void WebMediaPlayerImpl::requestRemotePlaybackControl() { |
1208 cast_impl_.requestRemotePlaybackControl(); | 1208 cast_impl_.requestRemotePlaybackControl(); |
1209 } | 1209 } |
1210 | 1210 |
1211 void WebMediaPlayerImpl::OnRemotePlaybackEnded() { | 1211 void WebMediaPlayerImpl::OnRemotePlaybackEnded() { |
1212 DVLOG(1) << __FUNCTION__; | 1212 DVLOG(1) << __func__; |
1213 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1213 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1214 | 1214 |
1215 ended_ = true; | 1215 ended_ = true; |
1216 client_->timeChanged(); | 1216 client_->timeChanged(); |
1217 } | 1217 } |
1218 | 1218 |
1219 void WebMediaPlayerImpl::OnDisconnectedFromRemoteDevice(double t) { | 1219 void WebMediaPlayerImpl::OnDisconnectedFromRemoteDevice(double t) { |
1220 DoSeek(base::TimeDelta::FromSecondsD(t), false); | 1220 DoSeek(base::TimeDelta::FromSecondsD(t), false); |
1221 | 1221 |
1222 // We already told the delegate we're paused when remoting started. | 1222 // We already told the delegate we're paused when remoting started. |
(...skipping 23 matching lines...) Expand all Loading... |
1246 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { | 1246 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { |
1247 cast_impl_.SetDeviceScaleFactor(scale_factor); | 1247 cast_impl_.SetDeviceScaleFactor(scale_factor); |
1248 } | 1248 } |
1249 | 1249 |
1250 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { | 1250 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { |
1251 cast_impl_.setPoster(poster); | 1251 cast_impl_.setPoster(poster); |
1252 } | 1252 } |
1253 #endif // defined(OS_ANDROID) // WMPI_CAST | 1253 #endif // defined(OS_ANDROID) // WMPI_CAST |
1254 | 1254 |
1255 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { | 1255 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { |
1256 DVLOG(1) << __FUNCTION__; | 1256 DVLOG(1) << __func__; |
1257 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1257 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1258 | 1258 |
1259 #if defined(OS_ANDROID) | 1259 #if defined(OS_ANDROID) |
1260 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are | 1260 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are |
1261 // encountered, instruct the HTML media element to create a new WebMediaPlayer | 1261 // encountered, instruct the HTML media element to create a new WebMediaPlayer |
1262 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. | 1262 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. |
1263 // | 1263 // |
1264 // TODO(tguilbert): Remove this code path once we have the ability to host a | 1264 // TODO(tguilbert): Remove this code path once we have the ability to host a |
1265 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 | 1265 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 |
1266 if (data_source_) { | 1266 if (data_source_) { |
(...skipping 13 matching lines...) Expand all Loading... |
1280 // least this makes sure that the error handling code is in sync. | 1280 // least this makes sure that the error handling code is in sync. |
1281 UpdatePlayState(); | 1281 UpdatePlayState(); |
1282 | 1282 |
1283 return; | 1283 return; |
1284 } | 1284 } |
1285 | 1285 |
1286 StartPipeline(); | 1286 StartPipeline(); |
1287 } | 1287 } |
1288 | 1288 |
1289 void WebMediaPlayerImpl::NotifyDownloading(bool is_downloading) { | 1289 void WebMediaPlayerImpl::NotifyDownloading(bool is_downloading) { |
1290 DVLOG(1) << __FUNCTION__; | 1290 DVLOG(1) << __func__; |
1291 if (!is_downloading && network_state_ == WebMediaPlayer::NetworkStateLoading) | 1291 if (!is_downloading && network_state_ == WebMediaPlayer::NetworkStateLoading) |
1292 SetNetworkState(WebMediaPlayer::NetworkStateIdle); | 1292 SetNetworkState(WebMediaPlayer::NetworkStateIdle); |
1293 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) | 1293 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) |
1294 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 1294 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
1295 media_log_->AddEvent( | 1295 media_log_->AddEvent( |
1296 media_log_->CreateBooleanEvent( | 1296 media_log_->CreateBooleanEvent( |
1297 MediaLogEvent::NETWORK_ACTIVITY_SET, | 1297 MediaLogEvent::NETWORK_ACTIVITY_SET, |
1298 "is_downloading_data", is_downloading)); | 1298 "is_downloading_data", is_downloading)); |
1299 } | 1299 } |
1300 | 1300 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 | 1385 |
1386 // ... and we're ready to go! | 1386 // ... and we're ready to go! |
1387 seeking_ = true; | 1387 seeking_ = true; |
1388 | 1388 |
1389 // TODO(sandersd): On Android, defer Start() if the tab is not visible. | 1389 // TODO(sandersd): On Android, defer Start() if the tab is not visible. |
1390 bool is_streaming = (data_source_ && data_source_->IsStreaming()); | 1390 bool is_streaming = (data_source_ && data_source_->IsStreaming()); |
1391 pipeline_controller_.Start(demuxer_.get(), this, is_streaming, is_static); | 1391 pipeline_controller_.Start(demuxer_.get(), this, is_streaming, is_static); |
1392 } | 1392 } |
1393 | 1393 |
1394 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { | 1394 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { |
1395 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1395 DVLOG(1) << __func__ << "(" << state << ")"; |
1396 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1396 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1397 network_state_ = state; | 1397 network_state_ = state; |
1398 // Always notify to ensure client has the latest value. | 1398 // Always notify to ensure client has the latest value. |
1399 client_->networkStateChanged(); | 1399 client_->networkStateChanged(); |
1400 } | 1400 } |
1401 | 1401 |
1402 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { | 1402 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { |
1403 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1403 DVLOG(1) << __func__ << "(" << state << ")"; |
1404 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1404 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1405 | 1405 |
1406 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && data_source_ && | 1406 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && data_source_ && |
1407 data_source_->assume_fully_buffered() && | 1407 data_source_->assume_fully_buffered() && |
1408 network_state_ == WebMediaPlayer::NetworkStateLoading) | 1408 network_state_ == WebMediaPlayer::NetworkStateLoading) |
1409 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); | 1409 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); |
1410 | 1410 |
1411 ready_state_ = state; | 1411 ready_state_ = state; |
1412 highest_ready_state_ = std::max(highest_ready_state_, ready_state_); | 1412 highest_ready_state_ = std::max(highest_ready_state_, ready_state_); |
1413 | 1413 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 if (isRemote()) | 1698 if (isRemote()) |
1699 return; | 1699 return; |
1700 #endif | 1700 #endif |
1701 | 1701 |
1702 // Idle timeout chosen arbitrarily. | 1702 // Idle timeout chosen arbitrarily. |
1703 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 1703 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), |
1704 this, &WebMediaPlayerImpl::OnPause); | 1704 this, &WebMediaPlayerImpl::OnPause); |
1705 } | 1705 } |
1706 | 1706 |
1707 } // namespace media | 1707 } // namespace media |
OLD | NEW |