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

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: Updated test 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
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Must be called on the demuxer thread. 206 // Must be called on the demuxer thread.
205 void StreamHasEnded(); 207 void StreamHasEnded();
206 208
207 // Wait for asynchronous read to complete and return number of bytes read. 209 // Wait for asynchronous read to complete and return number of bytes read.
208 virtual int WaitForRead(); 210 virtual int WaitForRead();
209 211
210 // Signal the blocked thread that the read has completed, with |size| bytes 212 // Signal the blocked thread that the read has completed, with |size| bytes
211 // read or kReadError in case of error. 213 // read or kReadError in case of error.
212 virtual void SignalReadCompleted(int size); 214 virtual void SignalReadCompleted(int size);
213 215
216 // Returns the stream from |streams_| that matches |type| as an
217 // FFmpegDemuxerStream.
218 scoped_refptr<FFmpegDemuxerStream> GetFFmpegStream(
219 DemuxerStream::Type type) const;
220
214 DemuxerHost* host_; 221 DemuxerHost* host_;
215 222
216 MessageLoop* message_loop_; 223 MessageLoop* message_loop_;
217 224
218 // FFmpeg context handle. 225 // FFmpeg context handle.
219 AVFormatContext* format_context_; 226 AVFormatContext* format_context_;
220 227
221 // |streams_| mirrors the AVStream array in |format_context_|. It contains 228 // |streams_| mirrors the AVStream array in |format_context_|. It contains
222 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index. 229 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index.
223 // 230 //
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Set if we know duration of the audio stream. Used when processing end of 268 // Set if we know duration of the audio stream. Used when processing end of
262 // stream -- at this moment we definitely know duration. 269 // stream -- at this moment we definitely know duration.
263 bool duration_known_; 270 bool duration_known_;
264 271
265 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 272 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
266 }; 273 };
267 274
268 } // namespace media 275 } // namespace media
269 276
270 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 277 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698