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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); | 61 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); |
62 virtual ~FFmpegDemuxerStream(); | 62 ~FFmpegDemuxerStream() override; |
63 | 63 |
64 // 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 |
65 // SetEndOfStream() has been called. | 65 // SetEndOfStream() has been called. |
66 void EnqueuePacket(ScopedAVPacket packet); | 66 void EnqueuePacket(ScopedAVPacket packet); |
67 | 67 |
68 // Enters the end of stream state. After delivering remaining queued buffers | 68 // Enters the end of stream state. After delivering remaining queued buffers |
69 // only end of stream buffers will be delivered. | 69 // only end of stream buffers will be delivered. |
70 void SetEndOfStream(); | 70 void SetEndOfStream(); |
71 | 71 |
72 // Drops queued buffers and clears end of stream state. | 72 // Drops queued buffers and clears end of stream state. |
73 void FlushBuffers(); | 73 void FlushBuffers(); |
74 | 74 |
75 // Empties the queues and ignores any additional calls to Read(). | 75 // Empties the queues and ignores any additional calls to Read(). |
76 void Stop(); | 76 void Stop(); |
77 | 77 |
78 base::TimeDelta duration() const { return duration_; } | 78 base::TimeDelta duration() const { return duration_; } |
79 | 79 |
80 // Enables fixes for ogg files with negative timestamps. For AUDIO streams, | 80 // Enables fixes for ogg files with negative timestamps. For AUDIO streams, |
81 // all packets with negative timestamps will be marked for post-decode | 81 // all packets with negative timestamps will be marked for post-decode |
82 // discard. For all other stream types, if FFmpegDemuxer::start_time() is | 82 // discard. For all other stream types, if FFmpegDemuxer::start_time() is |
83 // negative, it will not be used to shift timestamps during EnqueuePacket(). | 83 // negative, it will not be used to shift timestamps during EnqueuePacket(). |
84 void enable_negative_timestamp_fixups_for_ogg() { | 84 void enable_negative_timestamp_fixups_for_ogg() { |
85 fixup_negative_ogg_timestamps_ = true; | 85 fixup_negative_ogg_timestamps_ = true; |
86 } | 86 } |
87 | 87 |
88 // DemuxerStream implementation. | 88 // DemuxerStream implementation. |
89 virtual Type type() override; | 89 Type type() override; |
90 virtual void Read(const ReadCB& read_cb) override; | 90 void Read(const ReadCB& read_cb) override; |
91 virtual void EnableBitstreamConverter() override; | 91 void EnableBitstreamConverter() override; |
92 virtual bool SupportsConfigChanges() override; | 92 bool SupportsConfigChanges() override; |
93 virtual AudioDecoderConfig audio_decoder_config() override; | 93 AudioDecoderConfig audio_decoder_config() override; |
94 virtual VideoDecoderConfig video_decoder_config() override; | 94 VideoDecoderConfig video_decoder_config() override; |
95 virtual VideoRotation video_rotation() override; | 95 VideoRotation video_rotation() override; |
96 | 96 |
97 // Returns the range of buffered data in this stream. | 97 // Returns the range of buffered data in this stream. |
98 Ranges<base::TimeDelta> GetBufferedRanges() const; | 98 Ranges<base::TimeDelta> GetBufferedRanges() const; |
99 | 99 |
100 // Returns elapsed time based on the already queued packets. | 100 // Returns elapsed time based on the already queued packets. |
101 // Used to determine stream duration when it's not known ahead of time. | 101 // Used to determine stream duration when it's not known ahead of time. |
102 base::TimeDelta GetElapsedTime() const; | 102 base::TimeDelta GetElapsedTime() const; |
103 | 103 |
104 // Returns true if this stream has capacity for additional data. | 104 // Returns true if this stream has capacity for additional data. |
105 bool HasAvailableCapacity(); | 105 bool HasAvailableCapacity(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); | 152 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); |
153 }; | 153 }; |
154 | 154 |
155 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { | 155 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { |
156 public: | 156 public: |
157 FFmpegDemuxer(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 157 FFmpegDemuxer(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
158 DataSource* data_source, | 158 DataSource* data_source, |
159 const NeedKeyCB& need_key_cb, | 159 const NeedKeyCB& need_key_cb, |
160 const scoped_refptr<MediaLog>& media_log); | 160 const scoped_refptr<MediaLog>& media_log); |
161 virtual ~FFmpegDemuxer(); | 161 ~FFmpegDemuxer() override; |
162 | 162 |
163 // Demuxer implementation. | 163 // Demuxer implementation. |
164 virtual void Initialize(DemuxerHost* host, | 164 void Initialize(DemuxerHost* host, |
165 const PipelineStatusCB& status_cb, | 165 const PipelineStatusCB& status_cb, |
166 bool enable_text_tracks) override; | 166 bool enable_text_tracks) override; |
167 virtual void Stop() override; | 167 void Stop() override; |
168 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; | 168 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; |
169 virtual base::Time GetTimelineOffset() const override; | 169 base::Time GetTimelineOffset() const override; |
170 virtual DemuxerStream* GetStream(DemuxerStream::Type type) override; | 170 DemuxerStream* GetStream(DemuxerStream::Type type) override; |
171 virtual base::TimeDelta GetStartTime() const override; | 171 base::TimeDelta GetStartTime() const override; |
172 virtual Liveness GetLiveness() const override; | 172 Liveness GetLiveness() const override; |
173 | 173 |
174 // Calls |need_key_cb_| with the initialization data encountered in the file. | 174 // Calls |need_key_cb_| with the initialization data encountered in the file. |
175 void FireNeedKey(const std::string& init_data_type, | 175 void FireNeedKey(const std::string& init_data_type, |
176 const std::string& encryption_key_id); | 176 const std::string& encryption_key_id); |
177 | 177 |
178 // Allow FFmpegDemuxerStream to notify us when there is updated information | 178 // Allow FFmpegDemuxerStream to notify us when there is updated information |
179 // about capacity and what buffered data is available. | 179 // about capacity and what buffered data is available. |
180 void NotifyCapacityAvailable(); | 180 void NotifyCapacityAvailable(); |
181 void NotifyBufferingChanged(); | 181 void NotifyBufferingChanged(); |
182 | 182 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 // NOTE: Weak pointers must be invalidated before all other member variables. | 298 // NOTE: Weak pointers must be invalidated before all other member variables. |
299 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; | 299 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; |
300 | 300 |
301 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 301 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
302 }; | 302 }; |
303 | 303 |
304 } // namespace media | 304 } // namespace media |
305 | 305 |
306 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 306 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |