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

Unified Diff: media/filters/ffmpeg_demuxer.h

Issue 335273002: Fix seeking when the start time is non-zero. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes. Created 6 years, 6 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/ffmpeg_demuxer.h
diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h
index 02682bbc8b2c38c4b3a07771a7c86558c595bfb9..928e27e509db9b8378fb2c15c7f311ff1ca80580 100644
--- a/media/filters/ffmpeg_demuxer.h
+++ b/media/filters/ffmpeg_demuxer.h
@@ -55,9 +55,14 @@ typedef scoped_ptr<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket;
class FFmpegDemuxerStream : public DemuxerStream {
public:
- // Keeps a copy of |demuxer| and initializes itself using information
- // inside |stream|. Both parameters must outlive |this|.
- FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream);
+ // Keeps a copy of |demuxer| and initializes itself using information inside
+ // |stream|. Both parameters must outlive |this|.
+ // |discard_negative_timestamps| tells the DemuxerStream that all packets with
+ // negative timestamps should be marked for post-decode discard. All decoded
+ // data before time zero will be discarded.
+ FFmpegDemuxerStream(FFmpegDemuxer* demuxer,
+ AVStream* stream,
+ bool discard_negative_timestamps);
virtual ~FFmpegDemuxerStream();
// Enqueues the given AVPacket. It is invalid to queue a |packet| after
@@ -74,8 +79,7 @@ class FFmpegDemuxerStream : public DemuxerStream {
// Empties the queues and ignores any additional calls to Read().
void Stop();
- // Returns the duration of this stream.
- base::TimeDelta duration();
+ base::TimeDelta duration() const { return duration_; }
// DemuxerStream implementation.
virtual Type type() OVERRIDE;
@@ -136,6 +140,7 @@ class FFmpegDemuxerStream : public DemuxerStream {
bool bitstream_converter_enabled_;
std::string encryption_key_id_;
+ const bool discard_negative_timestamps_;
DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream);
};
@@ -155,7 +160,6 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
virtual void Stop(const base::Closure& callback) OVERRIDE;
virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE;
virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE;
- virtual base::TimeDelta GetStartTime() const OVERRIDE;
virtual base::Time GetTimelineOffset() const OVERRIDE;
virtual Liveness GetLiveness() const OVERRIDE;
@@ -168,6 +172,10 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
void NotifyCapacityAvailable();
void NotifyBufferingChanged();
+ // The lowest demuxed timestamp. DemuxerStream's must use this to adjust
+ // packet timestamps such that external clients see a zero-based timeline.
+ base::TimeDelta start_time() const { return start_time_; }
+
private:
// To allow tests access to privates.
friend class FFmpegDemuxerTest;
@@ -224,7 +232,7 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
// results of pre-seek av_read_frame() operations.
bool pending_seek_;
- // |streams_| mirrors the AVStream array in |format_context_|. It contains
+ // |streams_| mirrors the AVStream array in AVFormatContext. It contains
// FFmpegDemuxerStreams encapsluating AVStream objects at the same index.
//
// Since we only support a single audio and video stream, |streams_| will
@@ -245,11 +253,16 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
// Derived bitrate after initialization has completed.
int bitrate_;
- // The first timestamp of the opened media file. This is used to set the
- // starting clock value to match the timestamps in the media file. Default
- // is 0.
+ // The first timestamp of the audio or video stream, whichever is lower. This
+ // is used to adjust timestamps so that external consumers always see a zero
+ // based timeline.
base::TimeDelta start_time_;
+ // The starting timestamp of each stream. It contains an entry for every
+ // AVStream in the AVFormatContext. Used to determine which stream should be
+ // used for seeking.
+ std::vector<base::TimeDelta> stream_start_times_;
acolwell GONE FROM CHROMIUM 2014/06/17 17:41:22 as discussed offline, I don't think you need the v
DaleCurtis 2014/06/17 20:52:30 Done. Though I'm not sure it's clearer.
+
// The Time associated with timestamp 0. Set to a null
// time if the file doesn't have an association to Time.
base::Time timeline_offset_;

Powered by Google App Engine
This is Rietveld 408576698