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

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

Issue 10829108: Cap sourceBuffered() on duration and truncate duration on EoS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase ToT Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/dummy_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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // If |buffer_queue_| is not empty will execute on caller's thread, otherwise 77 // If |buffer_queue_| is not empty will execute on caller's thread, otherwise
78 // will post ReadTask to execute on demuxer's thread. Read will acquire 78 // will post ReadTask to execute on demuxer's thread. Read will acquire
79 // |lock_| for the life of the function so that means |read_cb| must 79 // |lock_| for the life of the function so that means |read_cb| must
80 // not make calls into FFmpegDemuxerStream directly or that may cause a 80 // not make calls into FFmpegDemuxerStream directly or that may cause a
81 // deadlock. |read_cb| should execute as quickly as possible because 81 // deadlock. |read_cb| should execute as quickly as possible because
82 // |lock_| is held throughout the life of the callback. 82 // |lock_| is held throughout the life of the callback.
83 virtual void Read(const ReadCB& read_cb) OVERRIDE; 83 virtual void Read(const ReadCB& read_cb) OVERRIDE;
84 virtual void EnableBitstreamConverter() OVERRIDE; 84 virtual void EnableBitstreamConverter() OVERRIDE;
85 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; 85 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE;
86 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; 86 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE;
87 virtual Ranges<base::TimeDelta> GetBufferedRanges() OVERRIDE; 87
88 // Returns the range of buffered data in this stream.
89 Ranges<base::TimeDelta> GetBufferedRanges() const;
88 90
89 // Returns elapsed time based on the already queued packets. 91 // Returns elapsed time based on the already queued packets.
90 // Used to determine stream duration when it's not known ahead of time. 92 // Used to determine stream duration when it's not known ahead of time.
91 base::TimeDelta GetElapsedTime() const; 93 base::TimeDelta GetElapsedTime() const;
92 94
93 protected: 95 protected:
94 virtual ~FFmpegDemuxerStream(); 96 virtual ~FFmpegDemuxerStream();
95 97
96 private: 98 private:
97 friend class FFmpegDemuxerTest; 99 friend class FFmpegDemuxerTest;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Must be called on the demuxer thread. 205 // Must be called on the demuxer thread.
204 void StreamHasEnded(); 206 void StreamHasEnded();
205 207
206 // Wait for asynchronous read to complete and return number of bytes read. 208 // Wait for asynchronous read to complete and return number of bytes read.
207 virtual int WaitForRead(); 209 virtual int WaitForRead();
208 210
209 // Signal the blocked thread that the read has completed, with |size| bytes 211 // Signal the blocked thread that the read has completed, with |size| bytes
210 // read or kReadError in case of error. 212 // read or kReadError in case of error.
211 virtual void SignalReadCompleted(int size); 213 virtual void SignalReadCompleted(int size);
212 214
215 // Returns the stream from |streams_| that matches |type| as an
216 // FFmpegDemuxerStream.
217 scoped_refptr<FFmpegDemuxerStream> GetFFmpegStream(
218 DemuxerStream::Type type) const;
219
213 DemuxerHost* host_; 220 DemuxerHost* host_;
214 221
215 MessageLoop* message_loop_; 222 MessageLoop* message_loop_;
216 223
217 // FFmpeg context handle. 224 // FFmpeg context handle.
218 AVFormatContext* format_context_; 225 AVFormatContext* format_context_;
219 226
220 // |streams_| mirrors the AVStream array in |format_context_|. It contains 227 // |streams_| mirrors the AVStream array in |format_context_|. It contains
221 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index. 228 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index.
222 // 229 //
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Set if we know duration of the audio stream. Used when processing end of 267 // Set if we know duration of the audio stream. Used when processing end of
261 // stream -- at this moment we definitely know duration. 268 // stream -- at this moment we definitely know duration.
262 bool duration_known_; 269 bool duration_known_;
263 270
264 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 271 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
265 }; 272 };
266 273
267 } // namespace media 274 } // namespace media
268 275
269 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 276 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW
« no previous file with comments | « media/filters/dummy_demuxer.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698