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

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: Comments. 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
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer.h
diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h
index 02682bbc8b2c38c4b3a07771a7c86558c595bfb9..ca38f1b92294f345235e16be1d68f1144c74fc46 100644
--- a/media/filters/ffmpeg_demuxer.h
+++ b/media/filters/ffmpeg_demuxer.h
@@ -23,6 +23,7 @@
#define MEDIA_FILTERS_FFMPEG_DEMUXER_H_
#include <string>
+#include <utility>
#include <vector>
#include "base/callback.h"
@@ -55,9 +56,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 +80,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 +141,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 +161,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 +173,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 +233,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 +254,22 @@ 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 index and start time of the preferred streams for seeking. Filled upon
+ // completion of OnFindStreamInfoDone(). Each info entry represents an index
+ // into |streams_| and the start time of that stream.
+ //
+ // Seek() will attempt to use |preferred_stream_for_seeking_| if the seek
+ // point occurs after its associated start time. Otherwise it will use
+ // |fallback_stream_for_seeking_|.
+ typedef std::pair<int, base::TimeDelta> StreamSeekInfo;
+ StreamSeekInfo preferred_stream_for_seeking_;
+ StreamSeekInfo fallback_stream_for_seeking_;
+
// 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_;
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698