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_; |