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 16 matching lines...) Expand all Loading... |
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/memory/scoped_vector.h" | 30 #include "base/memory/scoped_vector.h" |
31 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
32 #include "media/base/audio_decoder_config.h" | 32 #include "media/base/audio_decoder_config.h" |
33 #include "media/base/decoder_buffer.h" | 33 #include "media/base/decoder_buffer.h" |
34 #include "media/base/decoder_buffer_queue.h" | 34 #include "media/base/decoder_buffer_queue.h" |
35 #include "media/base/demuxer.h" | 35 #include "media/base/demuxer.h" |
36 #include "media/base/pipeline.h" | 36 #include "media/base/pipeline.h" |
| 37 #include "media/base/text_track.h" |
37 #include "media/base/video_decoder_config.h" | 38 #include "media/base/video_decoder_config.h" |
38 #include "media/filters/blocking_url_protocol.h" | 39 #include "media/filters/blocking_url_protocol.h" |
39 | 40 |
40 // FFmpeg forward declarations. | 41 // FFmpeg forward declarations. |
41 struct AVPacket; | 42 struct AVPacket; |
42 struct AVRational; | 43 struct AVRational; |
43 struct AVStream; | 44 struct AVStream; |
44 | 45 |
45 namespace media { | 46 namespace media { |
46 | 47 |
| 48 // Indicate to the player that an inband text track has been detected in |
| 49 // the media. The |index| refers to the index of the stream. |
| 50 typedef base::Callback<void(TextKind kind, |
| 51 const std::string& label, |
| 52 const std::string& language, |
| 53 int index)> FFmpegAddTextTrackCB; |
| 54 |
47 class MediaLog; | 55 class MediaLog; |
48 class FFmpegDemuxer; | 56 class FFmpegDemuxer; |
49 class FFmpegGlue; | 57 class FFmpegGlue; |
50 class FFmpegH264ToAnnexBBitstreamConverter; | 58 class FFmpegH264ToAnnexBBitstreamConverter; |
51 class ScopedPtrAVFreePacket; | 59 class ScopedPtrAVFreePacket; |
52 | 60 |
53 typedef scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket; | 61 typedef scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket; |
54 | 62 |
55 class FFmpegDemuxerStream : public DemuxerStream { | 63 class FFmpegDemuxerStream : public DemuxerStream { |
56 public: | 64 public: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 std::string encryption_key_id_; | 132 std::string encryption_key_id_; |
125 | 133 |
126 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); | 134 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); |
127 }; | 135 }; |
128 | 136 |
129 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { | 137 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { |
130 public: | 138 public: |
131 FFmpegDemuxer(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 139 FFmpegDemuxer(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
132 DataSource* data_source, | 140 DataSource* data_source, |
133 const NeedKeyCB& need_key_cb, | 141 const NeedKeyCB& need_key_cb, |
| 142 const FFmpegAddTextTrackCB& add_text_track_cb, |
134 const scoped_refptr<MediaLog>& media_log); | 143 const scoped_refptr<MediaLog>& media_log); |
135 virtual ~FFmpegDemuxer(); | 144 virtual ~FFmpegDemuxer(); |
136 | 145 |
137 // Demuxer implementation. | 146 // Demuxer implementation. |
138 virtual void Initialize(DemuxerHost* host, | 147 virtual void Initialize(DemuxerHost* host, |
139 const PipelineStatusCB& status_cb) OVERRIDE; | 148 const PipelineStatusCB& status_cb) OVERRIDE; |
140 virtual void Stop(const base::Closure& callback) OVERRIDE; | 149 virtual void Stop(const base::Closure& callback) OVERRIDE; |
141 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 150 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
142 virtual void OnAudioRendererDisabled() OVERRIDE; | 151 virtual void OnAudioRendererDisabled() OVERRIDE; |
143 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 152 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
144 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; | 153 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; |
| 154 virtual int GetStreamCount() const OVERRIDE; |
| 155 virtual DemuxerStream* GetStreamByIndex(int index) OVERRIDE; |
145 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 156 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
146 | 157 |
147 // Calls |need_key_cb_| with the initialization data encountered in the file. | 158 // Calls |need_key_cb_| with the initialization data encountered in the file. |
148 void FireNeedKey(const std::string& init_data_type, | 159 void FireNeedKey(const std::string& init_data_type, |
149 const std::string& encryption_key_id); | 160 const std::string& encryption_key_id); |
150 | 161 |
151 // Allow FFmpegDemuxerStream to notify us when there is updated information | 162 // Allow FFmpegDemuxerStream to notify us when there is updated information |
152 // about capacity and what buffered data is available. | 163 // about capacity and what buffered data is available. |
153 void NotifyCapacityAvailable(); | 164 void NotifyCapacityAvailable(); |
154 void NotifyBufferingChanged(); | 165 void NotifyBufferingChanged(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 247 |
237 // Set if we know duration of the audio stream. Used when processing end of | 248 // Set if we know duration of the audio stream. Used when processing end of |
238 // stream -- at this moment we definitely know duration. | 249 // stream -- at this moment we definitely know duration. |
239 bool duration_known_; | 250 bool duration_known_; |
240 | 251 |
241 // FFmpegURLProtocol implementation and corresponding glue bits. | 252 // FFmpegURLProtocol implementation and corresponding glue bits. |
242 BlockingUrlProtocol url_protocol_; | 253 BlockingUrlProtocol url_protocol_; |
243 scoped_ptr<FFmpegGlue> glue_; | 254 scoped_ptr<FFmpegGlue> glue_; |
244 | 255 |
245 const NeedKeyCB need_key_cb_; | 256 const NeedKeyCB need_key_cb_; |
| 257 const FFmpegAddTextTrackCB add_text_track_cb_; |
246 | 258 |
247 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 259 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
248 }; | 260 }; |
249 | 261 |
250 } // namespace media | 262 } // namespace media |
251 | 263 |
252 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 264 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |