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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 media_log_->AddEvent( | 261 media_log_->AddEvent( |
262 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 262 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
263 } | 263 } |
264 | 264 |
265 void WebMediaPlayerImpl::load(LoadType load_type, | 265 void WebMediaPlayerImpl::load(LoadType load_type, |
266 const blink::WebMediaPlayerSource& source, | 266 const blink::WebMediaPlayerSource& source, |
267 CORSMode cors_mode) { | 267 CORSMode cors_mode) { |
268 // Only URL or MSE blob URL is supported. | 268 // Only URL or MSE blob URL is supported. |
269 DCHECK(source.isURL()); | 269 DCHECK(source.isURL()); |
270 blink::WebURL url = source.getAsURL(); | 270 blink::WebURL url = source.getAsURL(); |
271 DVLOG(1) << __FUNCTION__ << "(" << load_type << ", " << url << ", " | 271 DVLOG(1) << __func__ << "(" << load_type << ", " << url << ", " << cors_mode |
272 << cors_mode << ")"; | 272 << ")"; |
273 if (!defer_load_cb_.is_null()) { | 273 if (!defer_load_cb_.is_null()) { |
274 defer_load_cb_.Run(base::Bind( | 274 defer_load_cb_.Run(base::Bind( |
275 &WebMediaPlayerImpl::DoLoad, AsWeakPtr(), load_type, url, cors_mode)); | 275 &WebMediaPlayerImpl::DoLoad, AsWeakPtr(), load_type, url, cors_mode)); |
276 return; | 276 return; |
277 } | 277 } |
278 DoLoad(load_type, url, cors_mode); | 278 DoLoad(load_type, url, cors_mode); |
279 } | 279 } |
280 | 280 |
281 bool WebMediaPlayerImpl::supportsOverlayFullscreenVideo() { | 281 bool WebMediaPlayerImpl::supportsOverlayFullscreenVideo() { |
282 #if defined(OS_ANDROID) | 282 #if defined(OS_ANDROID) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 void WebMediaPlayerImpl::exitedFullscreen() { | 316 void WebMediaPlayerImpl::exitedFullscreen() { |
317 if (!force_video_overlays_) | 317 if (!force_video_overlays_) |
318 DisableOverlay(); | 318 DisableOverlay(); |
319 } | 319 } |
320 | 320 |
321 void WebMediaPlayerImpl::DoLoad(LoadType load_type, | 321 void WebMediaPlayerImpl::DoLoad(LoadType load_type, |
322 const blink::WebURL& url, | 322 const blink::WebURL& url, |
323 CORSMode cors_mode) { | 323 CORSMode cors_mode) { |
324 DVLOG(1) << __FUNCTION__; | 324 DVLOG(1) << __func__; |
325 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 325 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
326 | 326 |
327 GURL gurl(url); | 327 GURL gurl(url); |
328 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); | 328 ReportMetrics(load_type, gurl, frame_->getSecurityOrigin()); |
329 | 329 |
330 // Set subresource URL for crash reporting. | 330 // Set subresource URL for crash reporting. |
331 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); | 331 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); |
332 | 332 |
333 load_type_ = load_type; | 333 load_type_ = load_type; |
334 | 334 |
(...skipping 29 matching lines...) Expand all Loading... |
364 data_source_->Initialize( | 364 data_source_->Initialize( |
365 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); | 365 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); |
366 } | 366 } |
367 | 367 |
368 #if defined(OS_ANDROID) // WMPI_CAST | 368 #if defined(OS_ANDROID) // WMPI_CAST |
369 cast_impl_.Initialize(url, frame_, delegate_id_); | 369 cast_impl_.Initialize(url, frame_, delegate_id_); |
370 #endif | 370 #endif |
371 } | 371 } |
372 | 372 |
373 void WebMediaPlayerImpl::play() { | 373 void WebMediaPlayerImpl::play() { |
374 DVLOG(1) << __FUNCTION__; | 374 DVLOG(1) << __func__; |
375 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 375 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
376 | 376 |
377 #if defined(OS_ANDROID) // WMPI_CAST | 377 #if defined(OS_ANDROID) // WMPI_CAST |
378 if (isRemote()) { | 378 if (isRemote()) { |
379 cast_impl_.play(); | 379 cast_impl_.play(); |
380 return; | 380 return; |
381 } | 381 } |
382 #endif | 382 #endif |
383 | 383 |
384 paused_ = false; | 384 paused_ = false; |
385 is_idle_ = false; | 385 is_idle_ = false; |
386 pipeline_.SetPlaybackRate(playback_rate_); | 386 pipeline_.SetPlaybackRate(playback_rate_); |
387 | 387 |
388 if (data_source_) | 388 if (data_source_) |
389 data_source_->MediaIsPlaying(); | 389 data_source_->MediaIsPlaying(); |
390 | 390 |
391 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); | 391 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); |
392 UpdatePlayState(); | 392 UpdatePlayState(); |
393 } | 393 } |
394 | 394 |
395 void WebMediaPlayerImpl::pause() { | 395 void WebMediaPlayerImpl::pause() { |
396 DVLOG(1) << __FUNCTION__; | 396 DVLOG(1) << __func__; |
397 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 397 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
398 | 398 |
399 // We update the paused state even when casting, since we expect pause() to be | 399 // We update the paused state even when casting, since we expect pause() to be |
400 // called when casting begins, and when we exit casting we should end up in a | 400 // called when casting begins, and when we exit casting we should end up in a |
401 // paused state. | 401 // paused state. |
402 paused_ = true; | 402 paused_ = true; |
403 | 403 |
404 #if defined(OS_ANDROID) // WMPI_CAST | 404 #if defined(OS_ANDROID) // WMPI_CAST |
405 if (isRemote()) { | 405 if (isRemote()) { |
406 cast_impl_.pause(); | 406 cast_impl_.pause(); |
(...skipping 13 matching lines...) Expand all Loading... |
420 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); | 420 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); |
421 UpdatePlayState(); | 421 UpdatePlayState(); |
422 } | 422 } |
423 | 423 |
424 bool WebMediaPlayerImpl::supportsSave() const { | 424 bool WebMediaPlayerImpl::supportsSave() const { |
425 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 425 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
426 return supports_save_; | 426 return supports_save_; |
427 } | 427 } |
428 | 428 |
429 void WebMediaPlayerImpl::seek(double seconds) { | 429 void WebMediaPlayerImpl::seek(double seconds) { |
430 DVLOG(1) << __FUNCTION__ << "(" << seconds << "s)"; | 430 DVLOG(1) << __func__ << "(" << seconds << "s)"; |
431 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 431 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
432 DoSeek(base::TimeDelta::FromSecondsD(seconds), true); | 432 DoSeek(base::TimeDelta::FromSecondsD(seconds), true); |
433 } | 433 } |
434 | 434 |
435 void WebMediaPlayerImpl::DoSeek(base::TimeDelta time, bool time_updated) { | 435 void WebMediaPlayerImpl::DoSeek(base::TimeDelta time, bool time_updated) { |
436 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 436 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
437 | 437 |
438 #if defined(OS_ANDROID) // WMPI_CAST | 438 #if defined(OS_ANDROID) // WMPI_CAST |
439 if (isRemote()) { | 439 if (isRemote()) { |
440 cast_impl_.seek(time); | 440 cast_impl_.seek(time); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 if (paused_) | 477 if (paused_) |
478 paused_time_ = time; | 478 paused_time_ = time; |
479 pipeline_controller_.Seek(time, time_updated); | 479 pipeline_controller_.Seek(time, time_updated); |
480 | 480 |
481 // This needs to be called after Seek() so that if a resume is triggered, it | 481 // This needs to be called after Seek() so that if a resume is triggered, it |
482 // is to the correct time. | 482 // is to the correct time. |
483 UpdatePlayState(); | 483 UpdatePlayState(); |
484 } | 484 } |
485 | 485 |
486 void WebMediaPlayerImpl::setRate(double rate) { | 486 void WebMediaPlayerImpl::setRate(double rate) { |
487 DVLOG(1) << __FUNCTION__ << "(" << rate << ")"; | 487 DVLOG(1) << __func__ << "(" << rate << ")"; |
488 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 488 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
489 | 489 |
490 // TODO(kylep): Remove when support for negatives is added. Also, modify the | 490 // TODO(kylep): Remove when support for negatives is added. Also, modify the |
491 // following checks so rewind uses reasonable values also. | 491 // following checks so rewind uses reasonable values also. |
492 if (rate < 0.0) | 492 if (rate < 0.0) |
493 return; | 493 return; |
494 | 494 |
495 // Limit rates to reasonable values by clamping. | 495 // Limit rates to reasonable values by clamping. |
496 if (rate != 0.0) { | 496 if (rate != 0.0) { |
497 if (rate < kMinRate) | 497 if (rate < kMinRate) |
498 rate = kMinRate; | 498 rate = kMinRate; |
499 else if (rate > kMaxRate) | 499 else if (rate > kMaxRate) |
500 rate = kMaxRate; | 500 rate = kMaxRate; |
501 } | 501 } |
502 | 502 |
503 playback_rate_ = rate; | 503 playback_rate_ = rate; |
504 if (!paused_) { | 504 if (!paused_) { |
505 pipeline_.SetPlaybackRate(rate); | 505 pipeline_.SetPlaybackRate(rate); |
506 if (data_source_) | 506 if (data_source_) |
507 data_source_->MediaPlaybackRateChanged(rate); | 507 data_source_->MediaPlaybackRateChanged(rate); |
508 } | 508 } |
509 } | 509 } |
510 | 510 |
511 void WebMediaPlayerImpl::setVolume(double volume) { | 511 void WebMediaPlayerImpl::setVolume(double volume) { |
512 DVLOG(1) << __FUNCTION__ << "(" << volume << ")"; | 512 DVLOG(1) << __func__ << "(" << volume << ")"; |
513 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 513 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
514 volume_ = volume; | 514 volume_ = volume; |
515 pipeline_.SetVolume(volume_ * volume_multiplier_); | 515 pipeline_.SetVolume(volume_ * volume_multiplier_); |
516 } | 516 } |
517 | 517 |
518 void WebMediaPlayerImpl::setSinkId( | 518 void WebMediaPlayerImpl::setSinkId( |
519 const blink::WebString& sink_id, | 519 const blink::WebString& sink_id, |
520 const blink::WebSecurityOrigin& security_origin, | 520 const blink::WebSecurityOrigin& security_origin, |
521 blink::WebSetSinkIdCallbacks* web_callback) { | 521 blink::WebSetSinkIdCallbacks* web_callback) { |
522 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 522 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
523 DVLOG(1) << __FUNCTION__; | 523 DVLOG(1) << __func__; |
524 | 524 |
525 media::OutputDeviceStatusCB callback = | 525 media::OutputDeviceStatusCB callback = |
526 media::ConvertToOutputDeviceStatusCB(web_callback); | 526 media::ConvertToOutputDeviceStatusCB(web_callback); |
527 media_task_runner_->PostTask( | 527 media_task_runner_->PostTask( |
528 FROM_HERE, | 528 FROM_HERE, |
529 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, | 529 base::Bind(&SetSinkIdOnMediaThread, audio_source_provider_, |
530 sink_id.utf8(), static_cast<url::Origin>(security_origin), | 530 sink_id.utf8(), static_cast<url::Origin>(security_origin), |
531 callback)); | 531 callback)); |
532 } | 532 } |
533 | 533 |
534 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE); | 534 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadNone, BufferedDataSource::NONE); |
535 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData, | 535 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadMetaData, |
536 BufferedDataSource::METADATA); | 536 BufferedDataSource::METADATA); |
537 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadAuto, BufferedDataSource::AUTO); | 537 STATIC_ASSERT_ENUM(WebMediaPlayer::PreloadAuto, BufferedDataSource::AUTO); |
538 | 538 |
539 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { | 539 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { |
540 DVLOG(1) << __FUNCTION__ << "(" << preload << ")"; | 540 DVLOG(1) << __func__ << "(" << preload << ")"; |
541 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 541 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
542 | 542 |
543 preload_ = static_cast<BufferedDataSource::Preload>(preload); | 543 preload_ = static_cast<BufferedDataSource::Preload>(preload); |
544 if (data_source_) | 544 if (data_source_) |
545 data_source_->SetPreload(preload_); | 545 data_source_->SetPreload(preload_); |
546 } | 546 } |
547 | 547 |
548 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Normal, | 548 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Normal, |
549 BufferedDataSource::BUFFERING_STRATEGY_NORMAL); | 549 BufferedDataSource::BUFFERING_STRATEGY_NORMAL); |
550 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Aggressive, | 550 STATIC_ASSERT_ENUM(WebMediaPlayer::BufferingStrategy::Aggressive, |
551 BufferedDataSource::BUFFERING_STRATEGY_AGGRESSIVE); | 551 BufferedDataSource::BUFFERING_STRATEGY_AGGRESSIVE); |
552 | 552 |
553 void WebMediaPlayerImpl::setBufferingStrategy( | 553 void WebMediaPlayerImpl::setBufferingStrategy( |
554 WebMediaPlayer::BufferingStrategy buffering_strategy) { | 554 WebMediaPlayer::BufferingStrategy buffering_strategy) { |
555 DVLOG(1) << __FUNCTION__; | 555 DVLOG(1) << __func__; |
556 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 556 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
557 | 557 |
558 #if defined(OS_ANDROID) | 558 #if defined(OS_ANDROID) |
559 // We disallow aggressive buffering on Android since it matches the behavior | 559 // We disallow aggressive buffering on Android since it matches the behavior |
560 // of the platform media player and may have data usage penalties. | 560 // of the platform media player and may have data usage penalties. |
561 // TODO(dalecurtis, hubbe): We should probably stop using "pause-and-buffer" | 561 // TODO(dalecurtis, hubbe): We should probably stop using "pause-and-buffer" |
562 // everywhere. See http://crbug.com/594669 for more details. | 562 // everywhere. See http://crbug.com/594669 for more details. |
563 buffering_strategy_ = BufferedDataSource::BUFFERING_STRATEGY_NORMAL; | 563 buffering_strategy_ = BufferedDataSource::BUFFERING_STRATEGY_NORMAL; |
564 #else | 564 #else |
565 buffering_strategy_ = | 565 buffering_strategy_ = |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 966 } |
967 } | 967 } |
968 | 968 |
969 void WebMediaPlayerImpl::OnDemuxerOpened() { | 969 void WebMediaPlayerImpl::OnDemuxerOpened() { |
970 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 970 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
971 client_->mediaSourceOpened( | 971 client_->mediaSourceOpened( |
972 new WebMediaSourceImpl(chunk_demuxer_, media_log_)); | 972 new WebMediaSourceImpl(chunk_demuxer_, media_log_)); |
973 } | 973 } |
974 | 974 |
975 void WebMediaPlayerImpl::OnError(PipelineStatus status) { | 975 void WebMediaPlayerImpl::OnError(PipelineStatus status) { |
976 DVLOG(1) << __FUNCTION__; | 976 DVLOG(1) << __func__; |
977 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 977 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
978 DCHECK_NE(status, PIPELINE_OK); | 978 DCHECK_NE(status, PIPELINE_OK); |
979 | 979 |
980 if (suppress_destruction_errors_) | 980 if (suppress_destruction_errors_) |
981 return; | 981 return; |
982 | 982 |
983 ReportPipelineError(load_type_, frame_->getSecurityOrigin(), status); | 983 ReportPipelineError(load_type_, frame_->getSecurityOrigin(), status); |
984 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status)); | 984 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status)); |
985 | 985 |
986 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { | 986 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { |
987 // Any error that occurs before reaching ReadyStateHaveMetadata should | 987 // Any error that occurs before reaching ReadyStateHaveMetadata should |
988 // be considered a format error. | 988 // be considered a format error. |
989 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); | 989 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); |
990 } else { | 990 } else { |
991 SetNetworkState(PipelineErrorToNetworkState(status)); | 991 SetNetworkState(PipelineErrorToNetworkState(status)); |
992 } | 992 } |
993 | 993 |
994 UpdatePlayState(); | 994 UpdatePlayState(); |
995 } | 995 } |
996 | 996 |
997 void WebMediaPlayerImpl::OnEnded() { | 997 void WebMediaPlayerImpl::OnEnded() { |
998 DVLOG(1) << __FUNCTION__; | 998 DVLOG(1) << __func__; |
999 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 999 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1000 | 1000 |
1001 // Ignore state changes until we've completed all outstanding operations. | 1001 // Ignore state changes until we've completed all outstanding operations. |
1002 if (!pipeline_controller_.IsStable()) | 1002 if (!pipeline_controller_.IsStable()) |
1003 return; | 1003 return; |
1004 | 1004 |
1005 ended_ = true; | 1005 ended_ = true; |
1006 client_->timeChanged(); | 1006 client_->timeChanged(); |
1007 | 1007 |
1008 // We don't actually want this to run until |client_| calls seek() or pause(), | 1008 // We don't actually want this to run until |client_| calls seek() or pause(), |
1009 // but that should have already happened in timeChanged() and so this is | 1009 // but that should have already happened in timeChanged() and so this is |
1010 // expected to be a no-op. | 1010 // expected to be a no-op. |
1011 UpdatePlayState(); | 1011 UpdatePlayState(); |
1012 } | 1012 } |
1013 | 1013 |
1014 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { | 1014 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { |
1015 DVLOG(1) << __FUNCTION__; | 1015 DVLOG(1) << __func__; |
1016 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1016 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1017 | 1017 |
1018 pipeline_metadata_ = metadata; | 1018 pipeline_metadata_ = metadata; |
1019 | 1019 |
1020 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 1020 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, |
1021 VIDEO_ROTATION_MAX + 1); | 1021 VIDEO_ROTATION_MAX + 1); |
1022 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 1022 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
1023 | 1023 |
1024 if (hasVideo()) { | 1024 if (hasVideo()) { |
1025 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || | 1025 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || |
(...skipping 10 matching lines...) Expand all Loading... |
1036 compositor_, pipeline_metadata_.video_rotation))); | 1036 compositor_, pipeline_metadata_.video_rotation))); |
1037 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1037 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
1038 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1038 video_weblayer_->SetContentsOpaqueIsFixed(true); |
1039 client_->setWebLayer(video_weblayer_.get()); | 1039 client_->setWebLayer(video_weblayer_.get()); |
1040 } | 1040 } |
1041 | 1041 |
1042 UpdatePlayState(); | 1042 UpdatePlayState(); |
1043 } | 1043 } |
1044 | 1044 |
1045 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { | 1045 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { |
1046 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1046 DVLOG(1) << __func__ << "(" << state << ")"; |
1047 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1047 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1048 | 1048 |
1049 // Ignore buffering state changes until we've completed all outstanding | 1049 // Ignore buffering state changes until we've completed all outstanding |
1050 // operations. | 1050 // operations. |
1051 if (!pipeline_controller_.IsStable()) | 1051 if (!pipeline_controller_.IsStable()) |
1052 return; | 1052 return; |
1053 | 1053 |
1054 if (state == BUFFERING_HAVE_ENOUGH) { | 1054 if (state == BUFFERING_HAVE_ENOUGH) { |
1055 // TODO(chcunningham): Monitor playback position vs buffered. Potentially | 1055 // TODO(chcunningham): Monitor playback position vs buffered. Potentially |
1056 // transition to HAVE_FUTURE_DATA here if not enough is buffered. | 1056 // transition to HAVE_FUTURE_DATA here if not enough is buffered. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 | 1218 |
1219 void WebMediaPlayerImpl::requestRemotePlayback() { | 1219 void WebMediaPlayerImpl::requestRemotePlayback() { |
1220 cast_impl_.requestRemotePlayback(); | 1220 cast_impl_.requestRemotePlayback(); |
1221 } | 1221 } |
1222 | 1222 |
1223 void WebMediaPlayerImpl::requestRemotePlaybackControl() { | 1223 void WebMediaPlayerImpl::requestRemotePlaybackControl() { |
1224 cast_impl_.requestRemotePlaybackControl(); | 1224 cast_impl_.requestRemotePlaybackControl(); |
1225 } | 1225 } |
1226 | 1226 |
1227 void WebMediaPlayerImpl::OnRemotePlaybackEnded() { | 1227 void WebMediaPlayerImpl::OnRemotePlaybackEnded() { |
1228 DVLOG(1) << __FUNCTION__; | 1228 DVLOG(1) << __func__; |
1229 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1229 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1230 | 1230 |
1231 ended_ = true; | 1231 ended_ = true; |
1232 client_->timeChanged(); | 1232 client_->timeChanged(); |
1233 } | 1233 } |
1234 | 1234 |
1235 void WebMediaPlayerImpl::OnDisconnectedFromRemoteDevice(double t) { | 1235 void WebMediaPlayerImpl::OnDisconnectedFromRemoteDevice(double t) { |
1236 DoSeek(base::TimeDelta::FromSecondsD(t), false); | 1236 DoSeek(base::TimeDelta::FromSecondsD(t), false); |
1237 | 1237 |
1238 // We already told the delegate we're paused when remoting started. | 1238 // We already told the delegate we're paused when remoting started. |
(...skipping 23 matching lines...) Expand all Loading... |
1262 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { | 1262 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { |
1263 cast_impl_.SetDeviceScaleFactor(scale_factor); | 1263 cast_impl_.SetDeviceScaleFactor(scale_factor); |
1264 } | 1264 } |
1265 | 1265 |
1266 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { | 1266 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { |
1267 cast_impl_.setPoster(poster); | 1267 cast_impl_.setPoster(poster); |
1268 } | 1268 } |
1269 #endif // defined(OS_ANDROID) // WMPI_CAST | 1269 #endif // defined(OS_ANDROID) // WMPI_CAST |
1270 | 1270 |
1271 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { | 1271 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { |
1272 DVLOG(1) << __FUNCTION__; | 1272 DVLOG(1) << __func__; |
1273 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1273 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1274 | 1274 |
1275 #if defined(OS_ANDROID) | 1275 #if defined(OS_ANDROID) |
1276 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are | 1276 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are |
1277 // encountered, instruct the HTML media element to create a new WebMediaPlayer | 1277 // encountered, instruct the HTML media element to create a new WebMediaPlayer |
1278 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. | 1278 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. |
1279 // | 1279 // |
1280 // TODO(tguilbert): Remove this code path once we have the ability to host a | 1280 // TODO(tguilbert): Remove this code path once we have the ability to host a |
1281 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 | 1281 // MediaPlayer within a Mojo media renderer. http://crbug.com/580626 |
1282 if (data_source_) { | 1282 if (data_source_) { |
(...skipping 13 matching lines...) Expand all Loading... |
1296 // least this makes sure that the error handling code is in sync. | 1296 // least this makes sure that the error handling code is in sync. |
1297 UpdatePlayState(); | 1297 UpdatePlayState(); |
1298 | 1298 |
1299 return; | 1299 return; |
1300 } | 1300 } |
1301 | 1301 |
1302 StartPipeline(); | 1302 StartPipeline(); |
1303 } | 1303 } |
1304 | 1304 |
1305 void WebMediaPlayerImpl::NotifyDownloading(bool is_downloading) { | 1305 void WebMediaPlayerImpl::NotifyDownloading(bool is_downloading) { |
1306 DVLOG(1) << __FUNCTION__; | 1306 DVLOG(1) << __func__; |
1307 if (!is_downloading && network_state_ == WebMediaPlayer::NetworkStateLoading) | 1307 if (!is_downloading && network_state_ == WebMediaPlayer::NetworkStateLoading) |
1308 SetNetworkState(WebMediaPlayer::NetworkStateIdle); | 1308 SetNetworkState(WebMediaPlayer::NetworkStateIdle); |
1309 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) | 1309 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) |
1310 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 1310 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
1311 media_log_->AddEvent( | 1311 media_log_->AddEvent( |
1312 media_log_->CreateBooleanEvent( | 1312 media_log_->CreateBooleanEvent( |
1313 MediaLogEvent::NETWORK_ACTIVITY_SET, | 1313 MediaLogEvent::NETWORK_ACTIVITY_SET, |
1314 "is_downloading_data", is_downloading)); | 1314 "is_downloading_data", is_downloading)); |
1315 } | 1315 } |
1316 | 1316 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 | 1407 |
1408 // ... and we're ready to go! | 1408 // ... and we're ready to go! |
1409 seeking_ = true; | 1409 seeking_ = true; |
1410 | 1410 |
1411 // TODO(sandersd): On Android, defer Start() if the tab is not visible. | 1411 // TODO(sandersd): On Android, defer Start() if the tab is not visible. |
1412 bool is_streaming = (data_source_ && data_source_->IsStreaming()); | 1412 bool is_streaming = (data_source_ && data_source_->IsStreaming()); |
1413 pipeline_controller_.Start(demuxer_.get(), this, is_streaming, is_static); | 1413 pipeline_controller_.Start(demuxer_.get(), this, is_streaming, is_static); |
1414 } | 1414 } |
1415 | 1415 |
1416 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { | 1416 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { |
1417 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1417 DVLOG(1) << __func__ << "(" << state << ")"; |
1418 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1418 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1419 network_state_ = state; | 1419 network_state_ = state; |
1420 // Always notify to ensure client has the latest value. | 1420 // Always notify to ensure client has the latest value. |
1421 client_->networkStateChanged(); | 1421 client_->networkStateChanged(); |
1422 } | 1422 } |
1423 | 1423 |
1424 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { | 1424 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { |
1425 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1425 DVLOG(1) << __func__ << "(" << state << ")"; |
1426 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1426 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1427 | 1427 |
1428 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && data_source_ && | 1428 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && data_source_ && |
1429 data_source_->assume_fully_buffered() && | 1429 data_source_->assume_fully_buffered() && |
1430 network_state_ == WebMediaPlayer::NetworkStateLoading) | 1430 network_state_ == WebMediaPlayer::NetworkStateLoading) |
1431 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); | 1431 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); |
1432 | 1432 |
1433 ready_state_ = state; | 1433 ready_state_ = state; |
1434 highest_ready_state_ = std::max(highest_ready_state_, ready_state_); | 1434 highest_ready_state_ = std::max(highest_ready_state_, ready_state_); |
1435 | 1435 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 if (isRemote()) | 1720 if (isRemote()) |
1721 return; | 1721 return; |
1722 #endif | 1722 #endif |
1723 | 1723 |
1724 // Idle timeout chosen arbitrarily. | 1724 // Idle timeout chosen arbitrarily. |
1725 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 1725 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), |
1726 this, &WebMediaPlayerImpl::OnPause); | 1726 this, &WebMediaPlayerImpl::OnPause); |
1727 } | 1727 } |
1728 | 1728 |
1729 } // namespace media | 1729 } // namespace media |
OLD | NEW |