OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 virtual ~FFmpegDemuxer(); | 132 virtual ~FFmpegDemuxer(); |
133 | 133 |
134 // Posts a task to perform additional demuxing. | 134 // Posts a task to perform additional demuxing. |
135 virtual void PostDemuxTask(); | 135 virtual void PostDemuxTask(); |
136 | 136 |
137 void Initialize( | 137 void Initialize( |
138 DataSource* data_source, const PipelineStatusCB& callback); | 138 DataSource* data_source, const PipelineStatusCB& callback); |
139 | 139 |
140 // Demuxer implementation. | 140 // Demuxer implementation. |
141 virtual void Stop(const base::Closure& callback) OVERRIDE; | 141 virtual void Stop(const base::Closure& callback) OVERRIDE; |
142 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE; | 142 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
143 virtual void OnAudioRendererDisabled() OVERRIDE; | 143 virtual void OnAudioRendererDisabled() OVERRIDE; |
144 virtual void set_host(FilterHost* filter_host) OVERRIDE; | 144 virtual void set_host(DemuxerHost* demuxer_host) OVERRIDE; |
145 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 145 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
146 virtual scoped_refptr<DemuxerStream> GetStream( | 146 virtual scoped_refptr<DemuxerStream> GetStream( |
147 DemuxerStream::Type type) OVERRIDE; | 147 DemuxerStream::Type type) OVERRIDE; |
148 virtual void SetPreload(Preload preload) OVERRIDE; | 148 virtual void SetPreload(Preload preload) OVERRIDE; |
149 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 149 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
150 virtual int GetBitrate() OVERRIDE; | 150 virtual int GetBitrate() OVERRIDE; |
151 virtual bool IsLocalSource() OVERRIDE; | 151 virtual bool IsLocalSource() OVERRIDE; |
152 virtual bool IsSeekable() OVERRIDE; | 152 virtual bool IsSeekable() OVERRIDE; |
153 | 153 |
154 // FFmpegURLProtocol implementation. | 154 // FFmpegURLProtocol implementation. |
(...skipping 12 matching lines...) Expand all Loading... |
167 private: | 167 private: |
168 // Only allow a factory to create this class. | 168 // Only allow a factory to create this class. |
169 friend class MockFFmpegDemuxer; | 169 friend class MockFFmpegDemuxer; |
170 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); | 170 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); |
171 | 171 |
172 // Carries out initialization on the demuxer thread. | 172 // Carries out initialization on the demuxer thread. |
173 void InitializeTask( | 173 void InitializeTask( |
174 DataSource* data_source, const PipelineStatusCB& callback); | 174 DataSource* data_source, const PipelineStatusCB& callback); |
175 | 175 |
176 // Carries out a seek on the demuxer thread. | 176 // Carries out a seek on the demuxer thread. |
177 void SeekTask(base::TimeDelta time, const FilterStatusCB& cb); | 177 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb); |
178 | 178 |
179 // Carries out demuxing and satisfying stream reads on the demuxer thread. | 179 // Carries out demuxing and satisfying stream reads on the demuxer thread. |
180 void DemuxTask(); | 180 void DemuxTask(); |
181 | 181 |
182 // Carries out stopping the demuxer streams on the demuxer thread. | 182 // Carries out stopping the demuxer streams on the demuxer thread. |
183 void StopTask(const base::Closure& callback); | 183 void StopTask(const base::Closure& callback); |
184 | 184 |
185 // Carries out disabling the audio stream on the demuxer thread. | 185 // Carries out disabling the audio stream on the demuxer thread. |
186 void DisableAudioStreamTask(); | 186 void DisableAudioStreamTask(); |
187 | 187 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 base::WaitableEvent read_event_; | 242 base::WaitableEvent read_event_; |
243 | 243 |
244 // Flag to indicate if read has ever failed. Once set to true, it will | 244 // Flag to indicate if read has ever failed. Once set to true, it will |
245 // never be reset. This flag is set true and accessed in Read(). | 245 // never be reset. This flag is set true and accessed in Read(). |
246 bool read_has_failed_; | 246 bool read_has_failed_; |
247 | 247 |
248 size_t last_read_bytes_; | 248 size_t last_read_bytes_; |
249 int64 read_position_; | 249 int64 read_position_; |
250 | 250 |
251 // Initialization can happen before set_host() is called, in which case we | 251 // Initialization can happen before set_host() is called, in which case we |
252 // store these bits for deferred reporting to the FilterHost when we get one. | 252 // store these bits for deferred reporting to the DemuxerHost when we get one. |
253 base::TimeDelta max_duration_; | 253 base::TimeDelta max_duration_; |
254 PipelineStatus deferred_status_; | 254 PipelineStatus deferred_status_; |
255 | 255 |
256 // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal | 256 // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal |
257 // state. | 257 // state. |
258 bool first_seek_hack_; | 258 bool first_seek_hack_; |
259 | 259 |
260 // The first timestamp of the opened media file. This is used to set the | 260 // The first timestamp of the opened media file. This is used to set the |
261 // starting clock value to match the timestamps in the media file. Default | 261 // starting clock value to match the timestamps in the media file. Default |
262 // is 0. | 262 // is 0. |
263 base::TimeDelta start_time_; | 263 base::TimeDelta start_time_; |
264 | 264 |
265 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 265 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
266 }; | 266 }; |
267 | 267 |
268 } // namespace media | 268 } // namespace media |
269 | 269 |
270 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 270 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |