Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderers/renderer_impl.h" | 5 #include "media/renderers/renderer_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 void RendererImpl::EnableClocklessVideoPlaybackForTesting() { | 195 void RendererImpl::EnableClocklessVideoPlaybackForTesting() { |
| 196 DVLOG(1) << __FUNCTION__; | 196 DVLOG(1) << __FUNCTION__; |
| 197 DCHECK(task_runner_->BelongsToCurrentThread()); | 197 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 198 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 198 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
| 199 DCHECK(underflow_disabled_for_testing_) | 199 DCHECK(underflow_disabled_for_testing_) |
| 200 << "Underflow must be disabled for clockless video playback"; | 200 << "Underflow must be disabled for clockless video playback"; |
| 201 | 201 |
| 202 clockless_video_playback_enabled_for_testing_ = true; | 202 clockless_video_playback_enabled_for_testing_ = true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 base::TimeDelta RendererImpl::GetMediaTimeForSyncingVideo() { | 205 base::TimeTicks RendererImpl::GetWallclockTimeForMediaTime( |
| 206 base::TimeDelta time) { | |
| 206 // No BelongsToCurrentThread() checking because this can be called from other | 207 // No BelongsToCurrentThread() checking because this can be called from other |
| 207 // threads. | 208 // threads. |
| 208 // | 209 // |
| 209 // TODO(scherkus): Currently called from VideoRendererImpl's internal thread, | 210 // TODO(scherkus): Currently called from VideoRendererImpl's internal thread, |
| 210 // which should go away at some point http://crbug.com/110814 | 211 // which should go away at some point http://crbug.com/110814 |
| 211 if (clockless_video_playback_enabled_for_testing_) | 212 if (clockless_video_playback_enabled_for_testing_) |
| 212 return base::TimeDelta::Max(); | 213 return base::TimeTicks::Now(); |
| 213 | 214 |
| 214 return time_source_->CurrentMediaTimeForSyncingVideo(); | 215 return time_source_->GetWallclockTimeForMediaTime(time); |
| 215 } | 216 } |
| 216 | 217 |
| 217 void RendererImpl::SetDecryptorReadyCallback( | 218 void RendererImpl::SetDecryptorReadyCallback( |
| 218 const DecryptorReadyCB& decryptor_ready_cb) { | 219 const DecryptorReadyCB& decryptor_ready_cb) { |
| 219 // Cancels the previous decryptor request. | 220 // Cancels the previous decryptor request. |
| 220 if (decryptor_ready_cb.is_null()) { | 221 if (decryptor_ready_cb.is_null()) { |
| 221 if (!decryptor_ready_cb_.is_null()) { | 222 if (!decryptor_ready_cb_.is_null()) { |
| 222 base::ResetAndReturn(&decryptor_ready_cb_) | 223 base::ResetAndReturn(&decryptor_ready_cb_) |
| 223 .Run(nullptr, base::Bind(IgnoreCdmAttached)); | 224 .Run(nullptr, base::Bind(IgnoreCdmAttached)); |
| 224 } | 225 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 | 304 |
| 304 video_renderer_->Initialize( | 305 video_renderer_->Initialize( |
| 305 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO), done_cb, | 306 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO), done_cb, |
| 306 base::Bind(&RendererImpl::SetDecryptorReadyCallback, weak_this_), | 307 base::Bind(&RendererImpl::SetDecryptorReadyCallback, weak_this_), |
| 307 base::Bind(&RendererImpl::OnUpdateStatistics, weak_this_), | 308 base::Bind(&RendererImpl::OnUpdateStatistics, weak_this_), |
| 308 base::Bind(&RendererImpl::OnBufferingStateChanged, weak_this_, | 309 base::Bind(&RendererImpl::OnBufferingStateChanged, weak_this_, |
| 309 &video_buffering_state_), | 310 &video_buffering_state_), |
| 310 base::ResetAndReturn(&paint_cb_), | 311 base::ResetAndReturn(&paint_cb_), |
| 311 base::Bind(&RendererImpl::OnVideoRendererEnded, weak_this_), | 312 base::Bind(&RendererImpl::OnVideoRendererEnded, weak_this_), |
| 312 base::Bind(&RendererImpl::OnError, weak_this_), | 313 base::Bind(&RendererImpl::OnError, weak_this_), |
| 313 base::Bind(&RendererImpl::GetMediaTimeForSyncingVideo, | 314 base::Bind(&RendererImpl::GetWallclockTimeForMediaTime, |
| 314 base::Unretained(this)), | 315 base::Unretained(this)), |
| 315 waiting_for_decryption_key_cb_); | 316 waiting_for_decryption_key_cb_); |
| 316 } | 317 } |
| 317 | 318 |
| 318 void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { | 319 void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { |
| 319 DVLOG(1) << __FUNCTION__ << ": " << status; | 320 DVLOG(1) << __FUNCTION__ << ": " << status; |
| 320 DCHECK(task_runner_->BelongsToCurrentThread()); | 321 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 321 | 322 |
| 322 // OnError() may be fired at any time by the renderers, even if they thought | 323 // OnError() may be fired at any time by the renderers, even if they thought |
| 323 // they initialized successfully (due to delayed output device setup). | 324 // they initialized successfully (due to delayed output device setup). |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 StartPlayback(); | 450 StartPlayback(); |
| 450 buffering_state_cb_.Run(BUFFERING_HAVE_ENOUGH); | 451 buffering_state_cb_.Run(BUFFERING_HAVE_ENOUGH); |
| 451 return; | 452 return; |
| 452 } | 453 } |
| 453 } | 454 } |
| 454 | 455 |
| 455 bool RendererImpl::WaitingForEnoughData() const { | 456 bool RendererImpl::WaitingForEnoughData() const { |
| 456 DCHECK(task_runner_->BelongsToCurrentThread()); | 457 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 457 if (state_ != STATE_PLAYING) | 458 if (state_ != STATE_PLAYING) |
| 458 return false; | 459 return false; |
| 460 // If playback has started and we have both an audio and video renderer, | |
| 461 // prefer the buffering state of the audio renderer. | |
| 462 if (time_ticking_ && audio_renderer_ && video_renderer_ && | |
| 463 audio_buffering_state_ == BUFFERING_HAVE_ENOUGH) { | |
| 464 return false; | |
| 465 } | |
|
xhwang
2015/03/23 22:20:14
So for a audio/video content, if the video is way
DaleCurtis
2015/03/25 00:31:45
Correct, though in a meeting yesterday strobe@ bro
xhwang
2015/03/25 04:10:50
I can think of some corner cases where we want to
DaleCurtis
2015/03/26 18:32:56
Actually it turns out I misunderstood the code her
| |
| 459 if (audio_renderer_ && audio_buffering_state_ != BUFFERING_HAVE_ENOUGH) | 466 if (audio_renderer_ && audio_buffering_state_ != BUFFERING_HAVE_ENOUGH) |
| 460 return true; | 467 return true; |
| 461 if (video_renderer_ && video_buffering_state_ != BUFFERING_HAVE_ENOUGH) | 468 if (video_renderer_ && video_buffering_state_ != BUFFERING_HAVE_ENOUGH) |
| 462 return true; | 469 return true; |
| 463 return false; | 470 return false; |
| 464 } | 471 } |
| 465 | 472 |
| 466 void RendererImpl::PausePlayback() { | 473 void RendererImpl::PausePlayback() { |
| 467 DVLOG(1) << __FUNCTION__; | 474 DVLOG(1) << __FUNCTION__; |
| 468 DCHECK(task_runner_->BelongsToCurrentThread()); | 475 DCHECK(task_runner_->BelongsToCurrentThread()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 } | 579 } |
| 573 | 580 |
| 574 // After OnError() returns, the pipeline may destroy |this|. | 581 // After OnError() returns, the pipeline may destroy |this|. |
| 575 base::ResetAndReturn(&error_cb_).Run(error); | 582 base::ResetAndReturn(&error_cb_).Run(error); |
| 576 | 583 |
| 577 if (!flush_cb_.is_null()) | 584 if (!flush_cb_.is_null()) |
| 578 base::ResetAndReturn(&flush_cb_).Run(); | 585 base::ResetAndReturn(&flush_cb_).Run(); |
| 579 } | 586 } |
| 580 | 587 |
| 581 } // namespace media | 588 } // namespace media |
| OLD | NEW |