| 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 11 matching lines...) Expand all Loading... |
| 22 #ifndef MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 22 #ifndef MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| 23 #define MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 23 #define MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| 24 | 24 |
| 25 #include <deque> | 25 #include <deque> |
| 26 #include <vector> | 26 #include <vector> |
| 27 | 27 |
| 28 #include "base/callback.h" | 28 #include "base/callback.h" |
| 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/buffers.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; | 39 struct AVFormatContext; |
| 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 class FFmpegDemuxerStream : public DemuxerStream { | 50 class FFmpegDemuxerStream : public DemuxerStream { |
| 51 public: | 51 public: |
| 52 // Keeps a copy of |demuxer| and initializes itself using information | 52 // Keeps a copy of |demuxer| and initializes itself using information |
| 53 // inside |stream|. Both parameters must outlive |this|. | 53 // inside |stream|. Both parameters must outlive |this|. |
| 54 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); | 54 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); |
| 55 | 55 |
| 56 // Returns true is this stream has pending reads, false otherwise. | 56 // Returns true is this stream has pending reads, false otherwise. |
| 57 // | 57 // |
| 58 // Safe to call on any thread. | 58 // Safe to call on any thread. |
| 59 bool HasPendingReads(); | 59 bool HasPendingReads(); |
| 60 | 60 |
| 61 // Enqueues the given AVPacket. | 61 // Enqueues the given AVPacket. If |packet| is NULL an end of stream packet |
| 62 // is enqueued. |
| 62 void EnqueuePacket(scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet); | 63 void EnqueuePacket(scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet); |
| 63 | 64 |
| 64 // Signals to empty the buffer queue and mark next packet as discontinuous. | 65 // Signals to empty the buffer queue and mark next packet as discontinuous. |
| 65 void FlushBuffers(); | 66 void FlushBuffers(); |
| 66 | 67 |
| 67 // Empties the queues and ignores any additional calls to Read(). | 68 // Empties the queues and ignores any additional calls to Read(). |
| 68 void Stop(); | 69 void Stop(); |
| 69 | 70 |
| 70 // Returns the duration of this stream. | 71 // Returns the duration of this stream. |
| 71 base::TimeDelta duration(); | 72 base::TimeDelta duration(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 109 |
| 109 FFmpegDemuxer* demuxer_; | 110 FFmpegDemuxer* demuxer_; |
| 110 AVStream* stream_; | 111 AVStream* stream_; |
| 111 AudioDecoderConfig audio_config_; | 112 AudioDecoderConfig audio_config_; |
| 112 VideoDecoderConfig video_config_; | 113 VideoDecoderConfig video_config_; |
| 113 Type type_; | 114 Type type_; |
| 114 base::TimeDelta duration_; | 115 base::TimeDelta duration_; |
| 115 bool discontinuous_; | 116 bool discontinuous_; |
| 116 bool stopped_; | 117 bool stopped_; |
| 117 | 118 |
| 118 typedef std::deque<scoped_refptr<Buffer> > BufferQueue; | 119 typedef std::deque<scoped_refptr<DecoderBuffer> > BufferQueue; |
| 119 BufferQueue buffer_queue_; | 120 BufferQueue buffer_queue_; |
| 120 | 121 |
| 121 typedef std::deque<ReadCB> ReadQueue; | 122 typedef std::deque<ReadCB> ReadQueue; |
| 122 ReadQueue read_queue_; | 123 ReadQueue read_queue_; |
| 123 | 124 |
| 124 // Used to translate bitstream formats. | 125 // Used to translate bitstream formats. |
| 125 scoped_ptr<BitstreamConverter> bitstream_converter_; | 126 scoped_ptr<BitstreamConverter> bitstream_converter_; |
| 126 | 127 |
| 127 // Used to synchronize access to |buffer_queue_|, |read_queue_|, and | 128 // Used to synchronize access to |buffer_queue_|, |read_queue_|, and |
| 128 // |stopped_|. This is so other threads can get access to buffers that have | 129 // |stopped_|. This is so other threads can get access to buffers that have |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Set if we know duration of the audio stream. Used when processing end of | 255 // Set if we know duration of the audio stream. Used when processing end of |
| 255 // stream -- at this moment we definitely know duration. | 256 // stream -- at this moment we definitely know duration. |
| 256 bool duration_known_; | 257 bool duration_known_; |
| 257 | 258 |
| 258 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 259 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 259 }; | 260 }; |
| 260 | 261 |
| 261 } // namespace media | 262 } // namespace media |
| 262 | 263 |
| 263 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 264 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |