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

Unified Diff: media/filters/video_renderer_base.cc

Issue 10829200: Fix VideoRendererBase end of stream logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/video_renderer_base.cc
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index e4d90c78d2fe70e6fccb40691f393122791d533e..fa41ffa6214003b676ffae61697097c40c686bfd 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -15,6 +15,10 @@
namespace media {
+base::TimeDelta VideoRendererBase::kMaxLastFrameDuration() {
+ return base::TimeDelta::FromMilliseconds(250);
+}
+
VideoRendererBase::VideoRendererBase(const base::Closure& paint_cb,
const SetOpaqueCB& set_opaque_cb,
bool drop_frames)
@@ -484,13 +488,30 @@ void VideoRendererBase::AddReadyFrame(const scoped_refptr<VideoFrame>& frame) {
// frame rate. Another way for this to happen is for the container to state a
// smaller duration than the largest packet timestamp.
base::TimeDelta duration = get_duration_cb_.Run();
- if (frame->GetTimestamp() > duration || frame->IsEndOfStream()) {
+ if (frame->IsEndOfStream()) {
+ base::TimeDelta end_timestamp = kNoTimestamp();
+ if (!ready_frames_.empty()) {
+ end_timestamp = std::min(
+ duration,
+ ready_frames_.back()->GetTimestamp() + kMaxLastFrameDuration());
+ } else if (current_frame_) {
+ end_timestamp =
+ std::min(duration,
+ current_frame_->GetTimestamp() + kMaxLastFrameDuration());
+ }
+ frame->SetTimestamp(end_timestamp);
+ } else if (frame->GetTimestamp() > duration) {
frame->SetTimestamp(duration);
}
ready_frames_.push_back(frame);
DCHECK_LE(NumFrames_Locked(), limits::kMaxVideoFrames);
- time_cb_.Run(frame->GetTimestamp());
+ if (frame->IsEndOfStream()) {
DaleCurtis 2012/08/07 21:20:46 Could collapse into a ternary if you like.
acolwell GONE FROM CHROMIUM 2012/08/07 22:25:06 Done.
+ time_cb_.Run(duration);
+ } else {
+ DCHECK(frame->GetTimestamp() != kNoTimestamp());
+ time_cb_.Run(frame->GetTimestamp());
+ }
frame_available_.Signal();
}

Powered by Google App Engine
This is Rietveld 408576698