| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 class FFmpegDemuxer; | 51 class FFmpegDemuxer; |
| 52 class FFmpegGlue; | 52 class FFmpegGlue; |
| 53 class FFmpegH264ToAnnexBBitstreamConverter; | 53 class FFmpegH264ToAnnexBBitstreamConverter; |
| 54 | 54 |
| 55 typedef scoped_ptr<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket; | 55 typedef scoped_ptr<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket; |
| 56 | 56 |
| 57 class FFmpegDemuxerStream : public DemuxerStream { | 57 class FFmpegDemuxerStream : public DemuxerStream { |
| 58 public: | 58 public: |
| 59 // Keeps a copy of |demuxer| and initializes itself using information inside | 59 // Keeps a copy of |demuxer| and initializes itself using information inside |
| 60 // |stream|. Both parameters must outlive |this|. | 60 // |stream|. Both parameters must outlive |this|. |
| 61 // |discard_negative_timestamps| tells the DemuxerStream that all packets with | 61 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); |
| 62 // negative timestamps should be marked for post-decode discard. All decoded | |
| 63 // data before time zero will be discarded. | |
| 64 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, | |
| 65 AVStream* stream, | |
| 66 bool discard_negative_timestamps); | |
| 67 virtual ~FFmpegDemuxerStream(); | 62 virtual ~FFmpegDemuxerStream(); |
| 68 | 63 |
| 69 // Enqueues the given AVPacket. It is invalid to queue a |packet| after | 64 // Enqueues the given AVPacket. It is invalid to queue a |packet| after |
| 70 // SetEndOfStream() has been called. | 65 // SetEndOfStream() has been called. |
| 71 void EnqueuePacket(ScopedAVPacket packet); | 66 void EnqueuePacket(ScopedAVPacket packet); |
| 72 | 67 |
| 73 // Enters the end of stream state. After delivering remaining queued buffers | 68 // Enters the end of stream state. After delivering remaining queued buffers |
| 74 // only end of stream buffers will be delivered. | 69 // only end of stream buffers will be delivered. |
| 75 void SetEndOfStream(); | 70 void SetEndOfStream(); |
| 76 | 71 |
| 77 // Drops queued buffers and clears end of stream state. | 72 // Drops queued buffers and clears end of stream state. |
| 78 void FlushBuffers(); | 73 void FlushBuffers(); |
| 79 | 74 |
| 80 // Empties the queues and ignores any additional calls to Read(). | 75 // Empties the queues and ignores any additional calls to Read(). |
| 81 void Stop(); | 76 void Stop(); |
| 82 | 77 |
| 83 base::TimeDelta duration() const { return duration_; } | 78 base::TimeDelta duration() const { return duration_; } |
| 84 | 79 |
| 80 // Enables fixes for ogg files with negative timestamps. For AUDIO streams, |
| 81 // all packets with negative timestamps will be marked for post-decode |
| 82 // discard. For all other stream types, if FFmpegDemuxer::start_time() is |
| 83 // negative, it will not be used to shift timestamps during EnqueuePacket(). |
| 84 void enable_negative_timestamp_fixups_for_ogg() { |
| 85 fixup_negative_ogg_timestamps_ = true; |
| 86 } |
| 87 |
| 85 // DemuxerStream implementation. | 88 // DemuxerStream implementation. |
| 86 virtual Type type() OVERRIDE; | 89 virtual Type type() OVERRIDE; |
| 87 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 90 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
| 88 virtual void EnableBitstreamConverter() OVERRIDE; | 91 virtual void EnableBitstreamConverter() OVERRIDE; |
| 89 virtual bool SupportsConfigChanges() OVERRIDE; | 92 virtual bool SupportsConfigChanges() OVERRIDE; |
| 90 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE; | 93 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE; |
| 91 virtual VideoDecoderConfig video_decoder_config() OVERRIDE; | 94 virtual VideoDecoderConfig video_decoder_config() OVERRIDE; |
| 92 | 95 |
| 93 // Returns the range of buffered data in this stream. | 96 // Returns the range of buffered data in this stream. |
| 94 Ranges<base::TimeDelta> GetBufferedRanges() const; | 97 Ranges<base::TimeDelta> GetBufferedRanges() const; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 DecoderBufferQueue buffer_queue_; | 137 DecoderBufferQueue buffer_queue_; |
| 135 ReadCB read_cb_; | 138 ReadCB read_cb_; |
| 136 | 139 |
| 137 #if defined(USE_PROPRIETARY_CODECS) | 140 #if defined(USE_PROPRIETARY_CODECS) |
| 138 scoped_ptr<FFmpegH264ToAnnexBBitstreamConverter> bitstream_converter_; | 141 scoped_ptr<FFmpegH264ToAnnexBBitstreamConverter> bitstream_converter_; |
| 139 #endif | 142 #endif |
| 140 | 143 |
| 141 bool bitstream_converter_enabled_; | 144 bool bitstream_converter_enabled_; |
| 142 | 145 |
| 143 std::string encryption_key_id_; | 146 std::string encryption_key_id_; |
| 144 const bool discard_negative_timestamps_; | 147 bool fixup_negative_ogg_timestamps_; |
| 145 | 148 |
| 146 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); | 149 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); |
| 147 }; | 150 }; |
| 148 | 151 |
| 149 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { | 152 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { |
| 150 public: | 153 public: |
| 151 FFmpegDemuxer(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 154 FFmpegDemuxer(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 152 DataSource* data_source, | 155 DataSource* data_source, |
| 153 const NeedKeyCB& need_key_cb, | 156 const NeedKeyCB& need_key_cb, |
| 154 const scoped_refptr<MediaLog>& media_log); | 157 const scoped_refptr<MediaLog>& media_log); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 295 |
| 293 // NOTE: Weak pointers must be invalidated before all other member variables. | 296 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 294 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; | 297 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; |
| 295 | 298 |
| 296 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 299 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 297 }; | 300 }; |
| 298 | 301 |
| 299 } // namespace media | 302 } // namespace media |
| 300 | 303 |
| 301 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 304 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |