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

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

Issue 9860027: Remove DemuxerFactory and URL parameter from Pipeline. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fix prerender Created 8 years, 8 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // already been demuxed without having the demuxer thread sending the 123 // already been demuxed without having the demuxer thread sending the
124 // buffers. |lock_| must be acquired before any access to |buffer_queue_|, 124 // buffers. |lock_| must be acquired before any access to |buffer_queue_|,
125 // |read_queue_|, or |stopped_|. 125 // |read_queue_|, or |stopped_|.
126 base::Lock lock_; 126 base::Lock lock_;
127 127
128 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); 128 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream);
129 }; 129 };
130 130
131 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol { 131 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol {
132 public: 132 public:
133 FFmpegDemuxer(MessageLoop* message_loop, bool local_source); 133 FFmpegDemuxer(MessageLoop* message_loop,
134 const scoped_refptr<DataSource>& data_source,
135 bool local_source);
134 virtual ~FFmpegDemuxer(); 136 virtual ~FFmpegDemuxer();
135 137
136 // Posts a task to perform additional demuxing. 138 // Posts a task to perform additional demuxing.
137 virtual void PostDemuxTask(); 139 virtual void PostDemuxTask();
138 140
139 void Initialize(
140 DataSource* data_source, const PipelineStatusCB& status_cb);
141
142 // Demuxer implementation. 141 // Demuxer implementation.
142 virtual void set_host(DemuxerHost* demuxer_host) OVERRIDE;
143 virtual void Initialize(const PipelineStatusCB& status_cb) OVERRIDE;
143 virtual void Stop(const base::Closure& callback) OVERRIDE; 144 virtual void Stop(const base::Closure& callback) OVERRIDE;
144 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; 145 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE;
145 virtual void OnAudioRendererDisabled() OVERRIDE; 146 virtual void OnAudioRendererDisabled() OVERRIDE;
146 virtual void set_host(DemuxerHost* demuxer_host) OVERRIDE;
147 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; 147 virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
148 virtual scoped_refptr<DemuxerStream> GetStream( 148 virtual scoped_refptr<DemuxerStream> GetStream(
149 DemuxerStream::Type type) OVERRIDE; 149 DemuxerStream::Type type) OVERRIDE;
150 virtual base::TimeDelta GetStartTime() const OVERRIDE; 150 virtual base::TimeDelta GetStartTime() const OVERRIDE;
151 virtual int GetBitrate() OVERRIDE; 151 virtual int GetBitrate() OVERRIDE;
152 virtual bool IsLocalSource() OVERRIDE; 152 virtual bool IsLocalSource() OVERRIDE;
153 virtual bool IsSeekable() OVERRIDE; 153 virtual bool IsSeekable() OVERRIDE;
154 154
155 // FFmpegURLProtocol implementation. 155 // FFmpegURLProtocol implementation.
156 virtual size_t Read(size_t size, uint8* data) OVERRIDE; 156 virtual size_t Read(size_t size, uint8* data) OVERRIDE;
157 virtual bool GetPosition(int64* position_out) OVERRIDE; 157 virtual bool GetPosition(int64* position_out) OVERRIDE;
158 virtual bool SetPosition(int64 position) OVERRIDE; 158 virtual bool SetPosition(int64 position) OVERRIDE;
159 virtual bool GetSize(int64* size_out) OVERRIDE; 159 virtual bool GetSize(int64* size_out) OVERRIDE;
160 virtual bool IsStreaming() OVERRIDE; 160 virtual bool IsStreaming() OVERRIDE;
161 161
162 // Provide access to FFmpegDemuxerStream. 162 // Provide access to FFmpegDemuxerStream.
163 MessageLoop* message_loop(); 163 MessageLoop* message_loop();
164 164
165 // For testing purposes. 165 // For testing purposes.
166 void disable_first_seek_hack_for_testing() { first_seek_hack_ = false; } 166 void disable_first_seek_hack_for_testing() { first_seek_hack_ = false; }
167 167
168 private: 168 private:
169 // Only allow a factory to create this class. 169 // Only allow a factory to create this class.
170 friend class MockFFmpegDemuxer; 170 friend class MockFFmpegDemuxer;
171 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); 171 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead);
172 172
173 // Carries out initialization on the demuxer thread. 173 // Carries out initialization on the demuxer thread.
174 void InitializeTask( 174 void InitializeTask(const PipelineStatusCB& status_cb);
175 DataSource* data_source, const PipelineStatusCB& status_cb);
176 175
177 // Carries out a seek on the demuxer thread. 176 // Carries out a seek on the demuxer thread.
178 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb); 177 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb);
179 178
180 // Carries out demuxing and satisfying stream reads on the demuxer thread. 179 // Carries out demuxing and satisfying stream reads on the demuxer thread.
181 void DemuxTask(); 180 void DemuxTask();
182 181
183 // Carries out stopping the demuxer streams on the demuxer thread. 182 // Carries out stopping the demuxer streams on the demuxer thread.
184 void StopTask(const base::Closure& callback); 183 void StopTask(const base::Closure& callback);
185 184
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // signaled when the demuxer is being stopped. 234 // signaled when the demuxer is being stopped.
236 base::WaitableEvent read_event_; 235 base::WaitableEvent read_event_;
237 236
238 // Flag to indicate if read has ever failed. Once set to true, it will 237 // Flag to indicate if read has ever failed. Once set to true, it will
239 // never be reset. This flag is set true and accessed in Read(). 238 // never be reset. This flag is set true and accessed in Read().
240 bool read_has_failed_; 239 bool read_has_failed_;
241 240
242 int last_read_bytes_; 241 int last_read_bytes_;
243 int64 read_position_; 242 int64 read_position_;
244 243
245 // Initialization can happen before set_host() is called, in which case we 244 // Derived bitrate after initialization has completed.
246 // store these bits for deferred reporting to the DemuxerHost when we get one. 245 int bitrate_;
247 base::TimeDelta max_duration_;
248 PipelineStatus deferred_status_;
249 246
250 // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal 247 // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal
251 // state. 248 // state.
252 bool first_seek_hack_; 249 bool first_seek_hack_;
253 250
254 // The first timestamp of the opened media file. This is used to set the 251 // The first timestamp of the opened media file. This is used to set the
255 // starting clock value to match the timestamps in the media file. Default 252 // starting clock value to match the timestamps in the media file. Default
256 // is 0. 253 // is 0.
257 base::TimeDelta start_time_; 254 base::TimeDelta start_time_;
258 255
259 // Whether audio has been disabled for this demuxer (in which case this class 256 // Whether audio has been disabled for this demuxer (in which case this class
260 // drops packets destined for AUDIO demuxer streams on the floor). 257 // drops packets destined for AUDIO demuxer streams on the floor).
261 bool audio_disabled_; 258 bool audio_disabled_;
262 259
263 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 260 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
264 }; 261 };
265 262
266 } // namespace media 263 } // namespace media
267 264
268 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 265 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698