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

Unified Diff: media/filters/ffmpeg_demuxer.h

Issue 2855373002: Use ffmpeg packet.pos for restarting reading after reenabling video
Patch Set: reset pending_seek_position_ after calling the pending_seek_cb_ Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer.cc » ('j') | media/filters/ffmpeg_demuxer.cc » ('J')
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 bd223ab9ccb8c5fb115e67bd409bd5d80d1bb65c..3b16693bd3d46041090aed2c1ba3b94177b29af5 100644
--- a/media/filters/ffmpeg_demuxer.h
+++ b/media/filters/ffmpeg_demuxer.h
@@ -200,6 +200,8 @@ class MEDIA_EXPORT FFmpegDemuxerStream : public DemuxerStream {
std::string encryption_key_id_;
bool fixup_negative_timestamps_;
+ base::TimeDelta stream_capacity_;
+
DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream);
};
@@ -271,6 +273,10 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
// FFmpeg callbacks during seeking.
void OnSeekFrameDone(int result);
+ // Called when FFmpeg completes the seek initiated in
+ // OnSelectedVideoTrackChanged in order to restart the |stream|.
+ void OnSeekDoneForRestartingStream(FFmpegDemuxerStream* stream, int result);
+
// FFmpeg callbacks during reading + helper method to initiate reads.
void ReadFrameIfNeeded();
void OnReadFrameDone(ScopedAVPacket packet, int result);
@@ -299,6 +305,16 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
void SetLiveness(DemuxerStream::Liveness liveness);
+ // Do an FFmpeg seek such that the read position is adjusted to be able to
+ // restart playback from the |time| position. If the |preferred_stream| is not
+ // null then it is used for seeking, otherwise the preferred stream is
+ // selected by FindPreferredStreamForSeeking function. When the seek is
+ // completed the |ffmpeg_seek_done_cb| will be called with FFmpeg result.
+ using FFmpegSeekDoneCB = base::Callback<void(int ffmpeg_result)>;
+ void SeekInternal(base::TimeDelta time,
+ FFmpegDemuxerStream* preferred_stream,
+ const FFmpegSeekDoneCB& ffmpeg_seek_done_cb);
DaleCurtis 2017/05/24 22:24:18 pass by value nowadays.
servolk 2017/05/24 22:58:20 Done.
+
DemuxerHost* host_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
@@ -319,6 +335,7 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
// Tracks if there's an outstanding av_seek_frame() operation. Used to discard
// results of pre-seek av_read_frame() operations.
PipelineStatusCB pending_seek_cb_;
+ base::TimeDelta pending_seek_position_;
// |streams_| mirrors the AVStream array in AVFormatContext. It contains
// FFmpegDemuxerStreams encapsluating AVStream objects at the same index.
@@ -357,6 +374,12 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
// fallback option.
FFmpegDemuxerStream* FindPreferredStreamForSeeking(base::TimeDelta seek_time);
+ // Restarts a previous pending seek if a video stream got re-enabled while a
+ // pending seek was in progress.
+ void RestartPendingSeek(base::TimeDelta time,
+ const PipelineStatusCB& cb,
DaleCurtis 2017/05/24 22:24:18 Ditto.
+ PipelineStatus prev_seek_status);
+
// 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_;
@@ -379,6 +402,9 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
std::map<MediaTrack::Id, FFmpegDemuxerStream*> track_id_to_demux_stream_map_;
+ int64_t last_audio_packet_pos_;
+ FFmpegDemuxerStream* restarting_stream_;
+
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtr<FFmpegDemuxer> weak_this_;
base::WeakPtrFactory<FFmpegDemuxer> cancel_pending_seek_factory_;
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer.cc » ('j') | media/filters/ffmpeg_demuxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698