| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 #include "base/gtest_prod_util.h" | 29 #include "base/gtest_prod_util.h" |
| 30 #include "base/synchronization/waitable_event.h" | 30 #include "base/synchronization/waitable_event.h" |
| 31 #include "media/base/audio_decoder_config.h" | 31 #include "media/base/audio_decoder_config.h" |
| 32 #include "media/base/decoder_buffer.h" | 32 #include "media/base/decoder_buffer.h" |
| 33 #include "media/base/demuxer.h" | 33 #include "media/base/demuxer.h" |
| 34 #include "media/base/pipeline.h" | 34 #include "media/base/pipeline.h" |
| 35 #include "media/base/video_decoder_config.h" | 35 #include "media/base/video_decoder_config.h" |
| 36 #include "media/filters/ffmpeg_glue.h" | 36 #include "media/filters/ffmpeg_glue.h" |
| 37 | 37 |
| 38 // FFmpeg forward declarations. | 38 // FFmpeg forward declarations. |
| 39 struct AVFormatContext; | |
| 40 struct AVPacket; | 39 struct AVPacket; |
| 41 struct AVRational; | 40 struct AVRational; |
| 42 struct AVStream; | 41 struct AVStream; |
| 43 | 42 |
| 44 namespace media { | 43 namespace media { |
| 45 | 44 |
| 46 class FFmpegDemuxer; | 45 class FFmpegDemuxer; |
| 47 class FFmpegH264ToAnnexBBitstreamConverter; | 46 class FFmpegH264ToAnnexBBitstreamConverter; |
| 48 class ScopedPtrAVFreePacket; | 47 class ScopedPtrAVFreePacket; |
| 49 | 48 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 const PipelineStatusCB& status_cb) OVERRIDE; | 151 const PipelineStatusCB& status_cb) OVERRIDE; |
| 153 virtual void Stop(const base::Closure& callback) OVERRIDE; | 152 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 154 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 153 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 155 virtual void OnAudioRendererDisabled() OVERRIDE; | 154 virtual void OnAudioRendererDisabled() OVERRIDE; |
| 156 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 155 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
| 157 virtual scoped_refptr<DemuxerStream> GetStream( | 156 virtual scoped_refptr<DemuxerStream> GetStream( |
| 158 DemuxerStream::Type type) OVERRIDE; | 157 DemuxerStream::Type type) OVERRIDE; |
| 159 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 158 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
| 160 | 159 |
| 161 // FFmpegURLProtocol implementation. | 160 // FFmpegURLProtocol implementation. |
| 162 virtual size_t Read(size_t size, uint8* data) OVERRIDE; | 161 virtual int Read(int size, uint8* data) OVERRIDE; |
| 163 virtual bool GetPosition(int64* position_out) OVERRIDE; | 162 virtual bool GetPosition(int64* position_out) OVERRIDE; |
| 164 virtual bool SetPosition(int64 position) OVERRIDE; | 163 virtual bool SetPosition(int64 position) OVERRIDE; |
| 165 virtual bool GetSize(int64* size_out) OVERRIDE; | 164 virtual bool GetSize(int64* size_out) OVERRIDE; |
| 166 virtual bool IsStreaming() OVERRIDE; | 165 virtual bool IsStreaming() OVERRIDE; |
| 167 | 166 |
| 168 // Provide access to FFmpegDemuxerStream. | 167 // Provide access to FFmpegDemuxerStream. |
| 169 scoped_refptr<base::MessageLoopProxy> message_loop(); | 168 scoped_refptr<base::MessageLoopProxy> message_loop(); |
| 170 | 169 |
| 171 // Allow FFmpegDemuxerStream to notify us when there is updated information | 170 // Allow FFmpegDemuxerStream to notify us when there is updated information |
| 172 // about what buffered data is available. | 171 // about what buffered data is available. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 213 |
| 215 // Returns the stream from |streams_| that matches |type| as an | 214 // Returns the stream from |streams_| that matches |type| as an |
| 216 // FFmpegDemuxerStream. | 215 // FFmpegDemuxerStream. |
| 217 scoped_refptr<FFmpegDemuxerStream> GetFFmpegStream( | 216 scoped_refptr<FFmpegDemuxerStream> GetFFmpegStream( |
| 218 DemuxerStream::Type type) const; | 217 DemuxerStream::Type type) const; |
| 219 | 218 |
| 220 DemuxerHost* host_; | 219 DemuxerHost* host_; |
| 221 | 220 |
| 222 scoped_refptr<base::MessageLoopProxy> message_loop_; | 221 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 223 | 222 |
| 224 // FFmpeg context handle. | |
| 225 AVFormatContext* format_context_; | |
| 226 | |
| 227 // |streams_| mirrors the AVStream array in |format_context_|. It contains | 223 // |streams_| mirrors the AVStream array in |format_context_|. It contains |
| 228 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index. | 224 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index. |
| 229 // | 225 // |
| 230 // Since we only support a single audio and video stream, |streams_| will | 226 // Since we only support a single audio and video stream, |streams_| will |
| 231 // contain NULL entries for additional audio/video streams as well as for | 227 // contain NULL entries for additional audio/video streams as well as for |
| 232 // stream types that we do not currently support. | 228 // stream types that we do not currently support. |
| 233 // | 229 // |
| 234 // Once initialized, operations on FFmpegDemuxerStreams should be carried out | 230 // Once initialized, operations on FFmpegDemuxerStreams should be carried out |
| 235 // on the demuxer thread. | 231 // on the demuxer thread. |
| 236 typedef std::vector<scoped_refptr<FFmpegDemuxerStream> > StreamVector; | 232 typedef std::vector<scoped_refptr<FFmpegDemuxerStream> > StreamVector; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 261 base::TimeDelta start_time_; | 257 base::TimeDelta start_time_; |
| 262 | 258 |
| 263 // Whether audio has been disabled for this demuxer (in which case this class | 259 // Whether audio has been disabled for this demuxer (in which case this class |
| 264 // drops packets destined for AUDIO demuxer streams on the floor). | 260 // drops packets destined for AUDIO demuxer streams on the floor). |
| 265 bool audio_disabled_; | 261 bool audio_disabled_; |
| 266 | 262 |
| 267 // Set if we know duration of the audio stream. Used when processing end of | 263 // Set if we know duration of the audio stream. Used when processing end of |
| 268 // stream -- at this moment we definitely know duration. | 264 // stream -- at this moment we definitely know duration. |
| 269 bool duration_known_; | 265 bool duration_known_; |
| 270 | 266 |
| 267 scoped_ptr<FFmpegGlue> glue_; |
| 268 |
| 271 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 269 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 272 }; | 270 }; |
| 273 | 271 |
| 274 } // namespace media | 272 } // namespace media |
| 275 | 273 |
| 276 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 274 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |