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

Side by Side Diff: media/renderers/video_renderer_impl.cc

Issue 1129323003: Allow callers of TimeSource::GetWallClockTime() to suspend time. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 7 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/renderers/video_renderer_impl.h ('k') | media/renderers/video_renderer_impl_unittest.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/renderers/video_renderer_impl.h" 5 #include "media/renderers/video_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/command_line.h" 10 #include "base/command_line.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 void VideoRendererImpl::Initialize( 125 void VideoRendererImpl::Initialize(
126 DemuxerStream* stream, 126 DemuxerStream* stream,
127 const PipelineStatusCB& init_cb, 127 const PipelineStatusCB& init_cb,
128 const SetDecryptorReadyCB& set_decryptor_ready_cb, 128 const SetDecryptorReadyCB& set_decryptor_ready_cb,
129 const StatisticsCB& statistics_cb, 129 const StatisticsCB& statistics_cb,
130 const BufferingStateCB& buffering_state_cb, 130 const BufferingStateCB& buffering_state_cb,
131 const base::Closure& ended_cb, 131 const base::Closure& ended_cb,
132 const PipelineStatusCB& error_cb, 132 const PipelineStatusCB& error_cb,
133 const WallClockTimeCB& wall_clock_time_cb, 133 const TimeSource::WallClockTimeCB& wall_clock_time_cb,
134 const base::Closure& waiting_for_decryption_key_cb) { 134 const base::Closure& waiting_for_decryption_key_cb) {
135 DCHECK(task_runner_->BelongsToCurrentThread()); 135 DCHECK(task_runner_->BelongsToCurrentThread());
136 base::AutoLock auto_lock(lock_); 136 base::AutoLock auto_lock(lock_);
137 DCHECK(stream); 137 DCHECK(stream);
138 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); 138 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO);
139 DCHECK(!init_cb.is_null()); 139 DCHECK(!init_cb.is_null());
140 DCHECK(!statistics_cb.is_null()); 140 DCHECK(!statistics_cb.is_null());
141 DCHECK(!buffering_state_cb.is_null()); 141 DCHECK(!buffering_state_cb.is_null());
142 DCHECK(!ended_cb.is_null()); 142 DCHECK(!ended_cb.is_null());
143 DCHECK(!wall_clock_time_cb.is_null()); 143 DCHECK(!wall_clock_time_cb.is_null());
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 task_runner_->PostTask( 326 task_runner_->PostTask(
327 FROM_HERE, base::Bind(buffering_state_cb_, BUFFERING_HAVE_NOTHING)); 327 FROM_HERE, base::Bind(buffering_state_cb_, BUFFERING_HAVE_NOTHING));
328 } else { 328 } else {
329 wait_time = std::min(kIdleTimeDelta, latest_possible_paint_time_ - now); 329 wait_time = std::min(kIdleTimeDelta, latest_possible_paint_time_ - now);
330 } 330 }
331 331
332 UpdateStatsAndWait_Locked(wait_time); 332 UpdateStatsAndWait_Locked(wait_time);
333 continue; 333 continue;
334 } 334 }
335 335
336 base::TimeTicks target_paint_time = 336 base::TimeTicks target_paint_time = wall_clock_time_cb_.Run(
337 wall_clock_time_cb_.Run(ready_frames_.front()->timestamp()); 337 ready_frames_.front()->timestamp(), TimeSource::SINGLE_TIMESTAMP);
338 338
339 // If media time has stopped, don't attempt to paint any more frames. 339 // If media time has stopped, don't attempt to paint any more frames.
340 if (target_paint_time.is_null()) { 340 if (target_paint_time.is_null()) {
341 UpdateStatsAndWait_Locked(kIdleTimeDelta); 341 UpdateStatsAndWait_Locked(kIdleTimeDelta);
342 continue; 342 continue;
343 } 343 }
344 344
345 // Deadline is defined as the duration between this frame and the next 345 // Deadline is defined as the duration between this frame and the next
346 // frame, using the delta between this frame and the previous frame as the 346 // frame, using the delta between this frame and the previous frame as the
347 // assumption for frame duration. 347 // assumption for frame duration.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 401 }
402 } 402 }
403 403
404 void VideoRendererImpl::PaintNextReadyFrame_Locked() { 404 void VideoRendererImpl::PaintNextReadyFrame_Locked() {
405 DCHECK(!use_new_video_renderering_path_); 405 DCHECK(!use_new_video_renderering_path_);
406 lock_.AssertAcquired(); 406 lock_.AssertAcquired();
407 407
408 scoped_refptr<VideoFrame> next_frame = ready_frames_.front(); 408 scoped_refptr<VideoFrame> next_frame = ready_frames_.front();
409 ready_frames_.pop_front(); 409 ready_frames_.pop_front();
410 410
411 last_media_time_ = wall_clock_time_cb_.Run(next_frame->timestamp()); 411 last_media_time_ = wall_clock_time_cb_.Run(next_frame->timestamp(),
412 TimeSource::SINGLE_TIMESTAMP);
412 413
413 paint_cb_.Run(next_frame); 414 paint_cb_.Run(next_frame);
414 415
415 task_runner_->PostTask( 416 task_runner_->PostTask(
416 FROM_HERE, 417 FROM_HERE,
417 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr())); 418 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr()));
418 } 419 }
419 420
420 void VideoRendererImpl::DropNextReadyFrame_Locked() { 421 void VideoRendererImpl::DropNextReadyFrame_Locked() {
421 DCHECK(!use_new_video_renderering_path_); 422 DCHECK(!use_new_video_renderering_path_);
422 TRACE_EVENT0("media", "VideoRendererImpl:frameDropped"); 423 TRACE_EVENT0("media", "VideoRendererImpl:frameDropped");
423 424
424 lock_.AssertAcquired(); 425 lock_.AssertAcquired();
425 426
426 last_media_time_ = 427 last_media_time_ = wall_clock_time_cb_.Run(ready_frames_.front()->timestamp(),
427 wall_clock_time_cb_.Run(ready_frames_.front()->timestamp()); 428 TimeSource::SINGLE_TIMESTAMP);
428 429
429 ready_frames_.pop_front(); 430 ready_frames_.pop_front();
430 frames_dropped_++; 431 frames_dropped_++;
431 432
432 task_runner_->PostTask( 433 task_runner_->PostTask(
433 FROM_HERE, 434 FROM_HERE,
434 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr())); 435 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr()));
435 } 436 }
436 437
437 void VideoRendererImpl::FrameReady(VideoFrameStream::Status status, 438 void VideoRendererImpl::FrameReady(VideoFrameStream::Status status,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 (algorithm_->frames_queued() == 1u && 724 (algorithm_->frames_queued() == 1u &&
724 algorithm_->average_frame_duration() == base::TimeDelta())) { 725 algorithm_->average_frame_duration() == base::TimeDelta())) {
725 rendered_end_of_stream_ = true; 726 rendered_end_of_stream_ = true;
726 task_runner_->PostTask(FROM_HERE, ended_cb_); 727 task_runner_->PostTask(FROM_HERE, ended_cb_);
727 } 728 }
728 729
729 return effective_frames; 730 return effective_frames;
730 } 731 }
731 732
732 } // namespace media 733 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.h ('k') | media/renderers/video_renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698