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

Side by Side Diff: media/filters/ffmpeg_demuxer.h

Issue 2267963002: Add support for cancellation of demuxer reads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add tests. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Implements the Demuxer interface using FFmpeg's libavformat. At this time 5 // Implements the Demuxer interface using FFmpeg's libavformat. At this time
6 // will support demuxing any audio/video format thrown at it. The streams 6 // will support demuxing any audio/video format thrown at it. The streams
7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer 7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer
8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs 8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs
9 // can be used to create and initialize the corresponding FFmpeg decoder. 9 // can be used to create and initialize the corresponding FFmpeg decoder.
10 // 10 //
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Enters the end of stream state. After delivering remaining queued buffers 79 // Enters the end of stream state. After delivering remaining queued buffers
80 // only end of stream buffers will be delivered. 80 // only end of stream buffers will be delivered.
81 void SetEndOfStream(); 81 void SetEndOfStream();
82 82
83 // Drops queued buffers and clears end of stream state. 83 // Drops queued buffers and clears end of stream state.
84 void FlushBuffers(); 84 void FlushBuffers();
85 85
86 // Empties the queues and ignores any additional calls to Read(). 86 // Empties the queues and ignores any additional calls to Read().
87 void Stop(); 87 void Stop();
88 88
89 // Aborts any pending reads.
90 void Abort();
91
89 base::TimeDelta duration() const { return duration_; } 92 base::TimeDelta duration() const { return duration_; }
90 93
91 // Enables fixes for files with negative timestamps. Normally all timestamps 94 // Enables fixes for files with negative timestamps. Normally all timestamps
92 // are rebased against FFmpegDemuxer::start_time() whenever that value is 95 // are rebased against FFmpegDemuxer::start_time() whenever that value is
93 // negative. When this fix is enabled, only AUDIO stream packets will be 96 // negative. When this fix is enabled, only AUDIO stream packets will be
94 // rebased to time zero, all other stream types will use the muxed timestamp. 97 // rebased to time zero, all other stream types will use the muxed timestamp.
95 // 98 //
96 // Further, when no codec delay is present, all AUDIO packets which originally 99 // Further, when no codec delay is present, all AUDIO packets which originally
97 // had negative timestamps will be marked for post-decode discard. When codec 100 // had negative timestamps will be marked for post-decode discard. When codec
98 // delay is present, it is assumed the decoder will handle discard and does 101 // delay is present, it is assumed the decoder will handle discard and does
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, 207 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb,
205 const MediaTracksUpdatedCB& media_tracks_updated_cb, 208 const MediaTracksUpdatedCB& media_tracks_updated_cb,
206 const scoped_refptr<MediaLog>& media_log); 209 const scoped_refptr<MediaLog>& media_log);
207 ~FFmpegDemuxer() override; 210 ~FFmpegDemuxer() override;
208 211
209 // Demuxer implementation. 212 // Demuxer implementation.
210 std::string GetDisplayName() const override; 213 std::string GetDisplayName() const override;
211 void Initialize(DemuxerHost* host, 214 void Initialize(DemuxerHost* host,
212 const PipelineStatusCB& status_cb, 215 const PipelineStatusCB& status_cb,
213 bool enable_text_tracks) override; 216 bool enable_text_tracks) override;
217 void AbortPendingReads() override;
214 void Stop() override; 218 void Stop() override;
215 void StartWaitingForSeek(base::TimeDelta seek_time) override; 219 void StartWaitingForSeek(base::TimeDelta seek_time) override;
216 void CancelPendingSeek(base::TimeDelta seek_time) override; 220 void CancelPendingSeek(base::TimeDelta seek_time) override;
217 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; 221 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override;
218 base::Time GetTimelineOffset() const override; 222 base::Time GetTimelineOffset() const override;
219 DemuxerStream* GetStream(DemuxerStream::Type type) override; 223 DemuxerStream* GetStream(DemuxerStream::Type type) override;
220 base::TimeDelta GetStartTime() const override; 224 base::TimeDelta GetStartTime() const override;
221 int64_t GetMemoryUsage() const override; 225 int64_t GetMemoryUsage() const override;
222 226
223 // Calls |encrypted_media_init_data_cb_| with the initialization data 227 // Calls |encrypted_media_init_data_cb_| with the initialization data
(...skipping 19 matching lines...) Expand all
243 247
244 private: 248 private:
245 // To allow tests access to privates. 249 // To allow tests access to privates.
246 friend class FFmpegDemuxerTest; 250 friend class FFmpegDemuxerTest;
247 251
248 // FFmpeg callbacks during initialization. 252 // FFmpeg callbacks during initialization.
249 void OnOpenContextDone(const PipelineStatusCB& status_cb, bool result); 253 void OnOpenContextDone(const PipelineStatusCB& status_cb, bool result);
250 void OnFindStreamInfoDone(const PipelineStatusCB& status_cb, int result); 254 void OnFindStreamInfoDone(const PipelineStatusCB& status_cb, int result);
251 255
252 // FFmpeg callbacks during seeking. 256 // FFmpeg callbacks during seeking.
253 void OnSeekFrameDone(const PipelineStatusCB& cb, int result); 257 void OnSeekFrameDone(int result);
254 258
255 // FFmpeg callbacks during reading + helper method to initiate reads. 259 // FFmpeg callbacks during reading + helper method to initiate reads.
256 void ReadFrameIfNeeded(); 260 void ReadFrameIfNeeded();
257 void OnReadFrameDone(ScopedAVPacket packet, int result); 261 void OnReadFrameDone(ScopedAVPacket packet, int result);
258 262
259 // Returns true iff any stream has additional capacity. Note that streams can 263 // Returns true iff any stream has additional capacity. Note that streams can
260 // go over capacity depending on how the file is muxed. 264 // go over capacity depending on how the file is muxed.
261 bool StreamsHaveAvailableCapacity(); 265 bool StreamsHaveAvailableCapacity();
262 266
263 // Returns true if the maximum allowed memory usage has been reached. 267 // Returns true if the maximum allowed memory usage has been reached.
(...skipping 23 matching lines...) Expand all
287 base::Thread blocking_thread_; 291 base::Thread blocking_thread_;
288 292
289 // Tracks if there's an outstanding av_read_frame() operation. 293 // Tracks if there's an outstanding av_read_frame() operation.
290 // 294 //
291 // TODO(scherkus): Allow more than one read in flight for higher read 295 // TODO(scherkus): Allow more than one read in flight for higher read
292 // throughput using demuxer_bench to verify improvements. 296 // throughput using demuxer_bench to verify improvements.
293 bool pending_read_; 297 bool pending_read_;
294 298
295 // Tracks if there's an outstanding av_seek_frame() operation. Used to discard 299 // Tracks if there's an outstanding av_seek_frame() operation. Used to discard
296 // results of pre-seek av_read_frame() operations. 300 // results of pre-seek av_read_frame() operations.
297 bool pending_seek_; 301 PipelineStatusCB pending_seek_cb_;
298 302
299 // |streams_| mirrors the AVStream array in AVFormatContext. It contains 303 // |streams_| mirrors the AVStream array in AVFormatContext. It contains
300 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index. 304 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index.
301 // 305 //
302 // Since we only support a single audio and video stream, |streams_| will 306 // Since we only support a single audio and video stream, |streams_| will
303 // contain NULL entries for additional audio/video streams as well as for 307 // contain NULL entries for additional audio/video streams as well as for
304 // stream types that we do not currently support. 308 // stream types that we do not currently support.
305 // 309 //
306 // Once initialized, operations on FFmpegDemuxerStreams should be carried out 310 // Once initialized, operations on FFmpegDemuxerStreams should be carried out
307 // on the demuxer thread. 311 // on the demuxer thread.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 355
352 // NOTE: Weak pointers must be invalidated before all other member variables. 356 // NOTE: Weak pointers must be invalidated before all other member variables.
353 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; 357 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_;
354 358
355 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 359 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
356 }; 360 };
357 361
358 } // namespace media 362 } // namespace media
359 363
360 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 364 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698