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

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

Issue 10581050: Ensure media's buffered ranges always have a range that includes currentTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Alternative implementation, introducing DataSourceHost::AddBufferedTimeRange(). Created 8 years, 6 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 29 matching lines...) Expand all
40 struct AVPacket; 40 struct AVPacket;
41 struct AVRational; 41 struct AVRational;
42 struct AVStream; 42 struct AVStream;
43 43
44 namespace media { 44 namespace media {
45 45
46 class BitstreamConverter; 46 class BitstreamConverter;
47 class FFmpegDemuxer; 47 class FFmpegDemuxer;
48 class ScopedPtrAVFreePacket; 48 class ScopedPtrAVFreePacket;
49 49
50 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> NotifyBufferedCB;
51
50 class FFmpegDemuxerStream : public DemuxerStream { 52 class FFmpegDemuxerStream : public DemuxerStream {
51 public: 53 public:
52 // Keeps a copy of |demuxer| and initializes itself using information 54 // Keeps a copy of |demuxer| and initializes itself using information
53 // inside |stream|. Both parameters must outlive |this|. 55 // inside |stream|. Both parameters must outlive |this|.
54 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); 56 FFmpegDemuxerStream(const NotifyBufferedCB& notify_buffered_cb_,
scherkus (not reviewing) 2012/06/21 21:57:04 is this needed given FDS has a pointer to FD and c
Ami GONE FROM CHROMIUM 2012/06/21 22:49:02 Yeah, I went back and forth on this. FDS has an FD
scherkus (not reviewing) 2012/06/21 23:18:42 Ah! I hadn't noticed you were binding to DemuxerHo
Ami GONE FROM CHROMIUM 2012/06/22 03:55:47 Done % still using a CB since the stream doesn't k
57 FFmpegDemuxer* demuxer, AVStream* stream);
55 58
56 // Returns true is this stream has pending reads, false otherwise. 59 // Returns true is this stream has pending reads, false otherwise.
57 // 60 //
58 // Safe to call on any thread. 61 // Safe to call on any thread.
59 bool HasPendingReads(); 62 bool HasPendingReads();
60 63
61 // Enqueues the given AVPacket. If |packet| is NULL an end of stream packet 64 // Enqueues the given AVPacket. If |packet| is NULL an end of stream packet
62 // is enqueued. 65 // is enqueued.
63 void EnqueuePacket(scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet); 66 void EnqueuePacket(scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet);
64 67
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 103
101 // Attempts to fulfill a single pending read by dequeueing a buffer and read 104 // Attempts to fulfill a single pending read by dequeueing a buffer and read
102 // callback pair and executing the callback. The calling function must 105 // callback pair and executing the callback. The calling function must
103 // acquire |lock_| before calling this function. 106 // acquire |lock_| before calling this function.
104 void FulfillPendingRead(); 107 void FulfillPendingRead();
105 108
106 // Converts an FFmpeg stream timestamp into a base::TimeDelta. 109 // Converts an FFmpeg stream timestamp into a base::TimeDelta.
107 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base, 110 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base,
108 int64 timestamp); 111 int64 timestamp);
109 112
113 NotifyBufferedCB notify_buffered_cb_;
110 FFmpegDemuxer* demuxer_; 114 FFmpegDemuxer* demuxer_;
111 AVStream* stream_; 115 AVStream* stream_;
112 AudioDecoderConfig audio_config_; 116 AudioDecoderConfig audio_config_;
113 VideoDecoderConfig video_config_; 117 VideoDecoderConfig video_config_;
114 Type type_; 118 Type type_;
115 base::TimeDelta duration_; 119 base::TimeDelta duration_;
116 bool discontinuous_; 120 bool discontinuous_;
117 bool stopped_; 121 bool stopped_;
122 base::TimeDelta last_packet_timestamp_;
118 123
119 typedef std::deque<scoped_refptr<DecoderBuffer> > BufferQueue; 124 typedef std::deque<scoped_refptr<DecoderBuffer> > BufferQueue;
120 BufferQueue buffer_queue_; 125 BufferQueue buffer_queue_;
121 126
122 typedef std::deque<ReadCB> ReadQueue; 127 typedef std::deque<ReadCB> ReadQueue;
123 ReadQueue read_queue_; 128 ReadQueue read_queue_;
124 129
125 // Used to translate bitstream formats. 130 // Used to translate bitstream formats.
126 scoped_ptr<BitstreamConverter> bitstream_converter_; 131 scoped_ptr<BitstreamConverter> bitstream_converter_;
127 132
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Set if we know duration of the audio stream. Used when processing end of 260 // Set if we know duration of the audio stream. Used when processing end of
256 // stream -- at this moment we definitely know duration. 261 // stream -- at this moment we definitely know duration.
257 bool duration_known_; 262 bool duration_known_;
258 263
259 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 264 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
260 }; 265 };
261 266
262 } // namespace media 267 } // namespace media
263 268
264 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 269 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698