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::GetWallClockTime(base::TimeDelta time) { |
206 // No BelongsToCurrentThread() checking because this can be called from other | 206 // No BelongsToCurrentThread() checking because this can be called from other |
207 // threads. | 207 // threads. |
208 // | 208 // |
209 // TODO(scherkus): Currently called from VideoRendererImpl's internal thread, | 209 // TODO(scherkus): Currently called from VideoRendererImpl's internal thread, |
210 // which should go away at some point http://crbug.com/110814 | 210 // which should go away at some point http://crbug.com/110814 |
211 if (clockless_video_playback_enabled_for_testing_) | 211 if (clockless_video_playback_enabled_for_testing_) |
212 return base::TimeDelta::Max(); | 212 return base::TimeTicks::Now(); |
213 | 213 |
214 return time_source_->CurrentMediaTimeForSyncingVideo(); | 214 return time_source_->GetWallClockTime(time); |
215 } | 215 } |
216 | 216 |
217 void RendererImpl::SetDecryptorReadyCallback( | 217 void RendererImpl::SetDecryptorReadyCallback( |
218 const DecryptorReadyCB& decryptor_ready_cb) { | 218 const DecryptorReadyCB& decryptor_ready_cb) { |
219 // Cancels the previous decryptor request. | 219 // Cancels the previous decryptor request. |
220 if (decryptor_ready_cb.is_null()) { | 220 if (decryptor_ready_cb.is_null()) { |
221 if (!decryptor_ready_cb_.is_null()) { | 221 if (!decryptor_ready_cb_.is_null()) { |
222 base::ResetAndReturn(&decryptor_ready_cb_) | 222 base::ResetAndReturn(&decryptor_ready_cb_) |
223 .Run(nullptr, base::Bind(IgnoreCdmAttached)); | 223 .Run(nullptr, base::Bind(IgnoreCdmAttached)); |
224 } | 224 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 video_renderer_->Initialize( | 304 video_renderer_->Initialize( |
305 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO), done_cb, | 305 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO), done_cb, |
306 base::Bind(&RendererImpl::SetDecryptorReadyCallback, weak_this_), | 306 base::Bind(&RendererImpl::SetDecryptorReadyCallback, weak_this_), |
307 base::Bind(&RendererImpl::OnUpdateStatistics, weak_this_), | 307 base::Bind(&RendererImpl::OnUpdateStatistics, weak_this_), |
308 base::Bind(&RendererImpl::OnBufferingStateChanged, weak_this_, | 308 base::Bind(&RendererImpl::OnBufferingStateChanged, weak_this_, |
309 &video_buffering_state_), | 309 &video_buffering_state_), |
310 base::ResetAndReturn(&paint_cb_), | 310 base::ResetAndReturn(&paint_cb_), |
311 base::Bind(&RendererImpl::OnVideoRendererEnded, weak_this_), | 311 base::Bind(&RendererImpl::OnVideoRendererEnded, weak_this_), |
312 base::Bind(&RendererImpl::OnError, weak_this_), | 312 base::Bind(&RendererImpl::OnError, weak_this_), |
313 base::Bind(&RendererImpl::GetMediaTimeForSyncingVideo, | 313 base::Bind(&RendererImpl::GetWallClockTime, base::Unretained(this)), |
314 base::Unretained(this)), | |
315 waiting_for_decryption_key_cb_); | 314 waiting_for_decryption_key_cb_); |
316 } | 315 } |
317 | 316 |
318 void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { | 317 void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { |
319 DVLOG(1) << __FUNCTION__ << ": " << status; | 318 DVLOG(1) << __FUNCTION__ << ": " << status; |
320 DCHECK(task_runner_->BelongsToCurrentThread()); | 319 DCHECK(task_runner_->BelongsToCurrentThread()); |
321 | 320 |
322 // OnError() may be fired at any time by the renderers, even if they thought | 321 // OnError() may be fired at any time by the renderers, even if they thought |
323 // they initialized successfully (due to delayed output device setup). | 322 // they initialized successfully (due to delayed output device setup). |
324 if (state_ != STATE_INITIALIZING) { | 323 if (state_ != STATE_INITIALIZING) { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 } | 571 } |
573 | 572 |
574 // After OnError() returns, the pipeline may destroy |this|. | 573 // After OnError() returns, the pipeline may destroy |this|. |
575 base::ResetAndReturn(&error_cb_).Run(error); | 574 base::ResetAndReturn(&error_cb_).Run(error); |
576 | 575 |
577 if (!flush_cb_.is_null()) | 576 if (!flush_cb_.is_null()) |
578 base::ResetAndReturn(&flush_cb_).Run(); | 577 base::ResetAndReturn(&flush_cb_).Run(); |
579 } | 578 } |
580 | 579 |
581 } // namespace media | 580 } // namespace media |
OLD | NEW |