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

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

Issue 1136513004: Switch GetWallClockTime to using vectors for input and output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 void VideoRendererImpl::Initialize( 139 void VideoRendererImpl::Initialize(
140 DemuxerStream* stream, 140 DemuxerStream* stream,
141 const PipelineStatusCB& init_cb, 141 const PipelineStatusCB& init_cb,
142 const SetDecryptorReadyCB& set_decryptor_ready_cb, 142 const SetDecryptorReadyCB& set_decryptor_ready_cb,
143 const StatisticsCB& statistics_cb, 143 const StatisticsCB& statistics_cb,
144 const BufferingStateCB& buffering_state_cb, 144 const BufferingStateCB& buffering_state_cb,
145 const base::Closure& ended_cb, 145 const base::Closure& ended_cb,
146 const PipelineStatusCB& error_cb, 146 const PipelineStatusCB& error_cb,
147 const WallClockTimeCB& wall_clock_time_cb, 147 const TimeSource::WallClockTimeCB& wall_clock_time_cb,
148 const base::Closure& waiting_for_decryption_key_cb) { 148 const base::Closure& waiting_for_decryption_key_cb) {
149 DCHECK(task_runner_->BelongsToCurrentThread()); 149 DCHECK(task_runner_->BelongsToCurrentThread());
150 base::AutoLock auto_lock(lock_); 150 base::AutoLock auto_lock(lock_);
151 DCHECK(stream); 151 DCHECK(stream);
152 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); 152 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO);
153 DCHECK(!init_cb.is_null()); 153 DCHECK(!init_cb.is_null());
154 DCHECK(!statistics_cb.is_null()); 154 DCHECK(!statistics_cb.is_null());
155 DCHECK(!buffering_state_cb.is_null()); 155 DCHECK(!buffering_state_cb.is_null());
156 DCHECK(!ended_cb.is_null()); 156 DCHECK(!ended_cb.is_null());
157 DCHECK(!wall_clock_time_cb.is_null()); 157 DCHECK(!wall_clock_time_cb.is_null());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 FROM_HERE, base::Bind(buffering_state_cb_, BUFFERING_HAVE_NOTHING)); 341 FROM_HERE, base::Bind(buffering_state_cb_, BUFFERING_HAVE_NOTHING));
342 } else { 342 } else {
343 wait_time = std::min(kIdleTimeDelta, latest_possible_paint_time_ - now); 343 wait_time = std::min(kIdleTimeDelta, latest_possible_paint_time_ - now);
344 } 344 }
345 345
346 UpdateStatsAndWait_Locked(wait_time); 346 UpdateStatsAndWait_Locked(wait_time);
347 continue; 347 continue;
348 } 348 }
349 349
350 base::TimeTicks target_paint_time = 350 base::TimeTicks target_paint_time =
351 wall_clock_time_cb_.Run(ready_frames_.front()->timestamp()); 351 ConvertMediaTimestamp(ready_frames_.front()->timestamp());
352 352
353 // If media time has stopped, don't attempt to paint any more frames. 353 // If media time has stopped, don't attempt to paint any more frames.
354 if (target_paint_time.is_null()) { 354 if (target_paint_time.is_null()) {
355 UpdateStatsAndWait_Locked(kIdleTimeDelta); 355 UpdateStatsAndWait_Locked(kIdleTimeDelta);
356 continue; 356 continue;
357 } 357 }
358 358
359 // Deadline is defined as the duration between this frame and the next 359 // Deadline is defined as the duration between this frame and the next
360 // frame, using the delta between this frame and the previous frame as the 360 // frame, using the delta between this frame and the previous frame as the
361 // assumption for frame duration. 361 // assumption for frame duration.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 } 416 }
417 417
418 void VideoRendererImpl::PaintNextReadyFrame_Locked() { 418 void VideoRendererImpl::PaintNextReadyFrame_Locked() {
419 DCHECK(!use_new_video_renderering_path_); 419 DCHECK(!use_new_video_renderering_path_);
420 lock_.AssertAcquired(); 420 lock_.AssertAcquired();
421 421
422 scoped_refptr<VideoFrame> next_frame = ready_frames_.front(); 422 scoped_refptr<VideoFrame> next_frame = ready_frames_.front();
423 ready_frames_.pop_front(); 423 ready_frames_.pop_front();
424 424
425 last_media_time_ = wall_clock_time_cb_.Run(next_frame->timestamp()); 425 last_media_time_ = ConvertMediaTimestamp(next_frame->timestamp());
426 426
427 paint_cb_.Run(next_frame); 427 paint_cb_.Run(next_frame);
428 428
429 task_runner_->PostTask( 429 task_runner_->PostTask(
430 FROM_HERE, 430 FROM_HERE,
431 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr())); 431 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr()));
432 } 432 }
433 433
434 void VideoRendererImpl::DropNextReadyFrame_Locked() { 434 void VideoRendererImpl::DropNextReadyFrame_Locked() {
435 DCHECK(!use_new_video_renderering_path_); 435 DCHECK(!use_new_video_renderering_path_);
436 TRACE_EVENT0("media", "VideoRendererImpl:frameDropped"); 436 TRACE_EVENT0("media", "VideoRendererImpl:frameDropped");
437 437
438 lock_.AssertAcquired(); 438 lock_.AssertAcquired();
439 439
440 last_media_time_ = 440 last_media_time_ = ConvertMediaTimestamp(ready_frames_.front()->timestamp());
441 wall_clock_time_cb_.Run(ready_frames_.front()->timestamp());
442 441
443 ready_frames_.pop_front(); 442 ready_frames_.pop_front();
444 frames_dropped_++; 443 frames_dropped_++;
445 444
446 task_runner_->PostTask( 445 task_runner_->PostTask(
447 FROM_HERE, 446 FROM_HERE,
448 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr())); 447 base::Bind(&VideoRendererImpl::AttemptRead, weak_factory_.GetWeakPtr()));
449 } 448 }
450 449
451 void VideoRendererImpl::FrameReady(VideoFrameStream::Status status, 450 void VideoRendererImpl::FrameReady(VideoFrameStream::Status status,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 if (!effective_frames || 735 if (!effective_frames ||
737 (algorithm_->frames_queued() == 1u && 736 (algorithm_->frames_queued() == 1u &&
738 algorithm_->average_frame_duration() == base::TimeDelta())) { 737 algorithm_->average_frame_duration() == base::TimeDelta())) {
739 rendered_end_of_stream_ = true; 738 rendered_end_of_stream_ = true;
740 task_runner_->PostTask(FROM_HERE, ended_cb_); 739 task_runner_->PostTask(FROM_HERE, ended_cb_);
741 } 740 }
742 741
743 return effective_frames; 742 return effective_frames;
744 } 743 }
745 744
745 base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp(
746 base::TimeDelta media_time) {
747 std::vector<base::TimeDelta> media_times(1, media_time);
748 std::vector<base::TimeTicks> wall_clock_times;
749 if (!wall_clock_time_cb_.Run(media_times, &wall_clock_times))
750 return base::TimeTicks();
751 return wall_clock_times[0];
752 }
753
746 } // namespace media 754 } // 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