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

Unified Diff: media/filters/video_renderer_base.cc

Issue 3032030: Implement accurate seeking by decoding audio/video until we reach our desired timestamp. (Closed)
Patch Set: Fixes Created 10 years, 5 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
« no previous file with comments | « media/filters/video_renderer_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_base.cc
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index c50dfd4ecfd708876314f2d7af5e24320f32c14c..00cf9dc9559566a837787c14f93d9ba11449dab9 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -151,6 +151,7 @@ void VideoRendererBase::Seek(base::TimeDelta time, FilterCallback* callback) {
DCHECK_EQ(0u, pending_reads_) << "Pending reads should have completed";
state_ = kSeeking;
seek_callback_.reset(callback);
+ seek_timestamp_ = time;
// Throw away everything and schedule our reads.
// TODO(jiesun): this should be guaranteed by pause/flush before seek happen.
@@ -390,10 +391,16 @@ void VideoRendererBase::OnFillBufferDone(scoped_refptr<VideoFrame> frame) {
DCHECK_GT(pending_reads_, 0u);
--pending_reads_;
- // Enqueue the frame.
- frames_queue_ready_.push_back(frame);
- DCHECK_LE(frames_queue_ready_.size(), kMaxFrames);
- frame_available_.Signal();
+ // Discard frames until we reach our desired seek timestamp.
+ if (state_ == kSeeking && !frame->IsEndOfStream() &&
+ (frame->GetTimestamp() + frame->GetDuration()) < seek_timestamp_) {
+ frames_queue_done_.push_back(frame);
+ ScheduleRead_Locked();
+ } else {
+ frames_queue_ready_.push_back(frame);
+ DCHECK_LE(frames_queue_ready_.size(), kMaxFrames);
+ frame_available_.Signal();
+ }
// Check for our preroll complete condition.
if (state_ == kSeeking) {
« no previous file with comments | « media/filters/video_renderer_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698