OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 12 matching lines...) Expand all Loading... |
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/buffers.h" | 31 #include "media/base/buffers.h" |
32 #include "media/base/filters.h" | 32 #include "media/base/filters.h" |
| 33 #include "media/base/pipeline.h" |
33 #include "media/base/media_format.h" | 34 #include "media/base/media_format.h" |
34 #include "media/filters/ffmpeg_glue.h" | 35 #include "media/filters/ffmpeg_glue.h" |
35 #include "media/filters/ffmpeg_interfaces.h" | 36 #include "media/filters/ffmpeg_interfaces.h" |
36 | 37 |
37 // FFmpeg forward declarations. | 38 // FFmpeg forward declarations. |
38 struct AVFormatContext; | 39 struct AVFormatContext; |
39 struct AVPacket; | 40 struct AVPacket; |
40 struct AVRational; | 41 struct AVRational; |
41 struct AVStream; | 42 struct AVStream; |
42 | 43 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 121 |
121 class FFmpegDemuxer : public Demuxer, | 122 class FFmpegDemuxer : public Demuxer, |
122 public FFmpegURLProtocol { | 123 public FFmpegURLProtocol { |
123 public: | 124 public: |
124 explicit FFmpegDemuxer(MessageLoop* message_loop); | 125 explicit FFmpegDemuxer(MessageLoop* message_loop); |
125 virtual ~FFmpegDemuxer(); | 126 virtual ~FFmpegDemuxer(); |
126 | 127 |
127 // Posts a task to perform additional demuxing. | 128 // Posts a task to perform additional demuxing. |
128 virtual void PostDemuxTask(); | 129 virtual void PostDemuxTask(); |
129 | 130 |
| 131 void Initialize( |
| 132 DataSource* data_source, PipelineStatusCallback* callback); |
| 133 |
130 // Filter implementation. | 134 // Filter implementation. |
131 virtual void Stop(FilterCallback* callback); | 135 virtual void Stop(FilterCallback* callback); |
132 virtual void Seek(base::TimeDelta time, FilterCallback* callback); | 136 virtual void Seek(base::TimeDelta time, FilterCallback* callback); |
133 virtual void OnAudioRendererDisabled(); | 137 virtual void OnAudioRendererDisabled(); |
| 138 virtual void set_host(FilterHost* filter_host); |
134 | 139 |
135 // Demuxer implementation. | 140 // Demuxer implementation. |
136 virtual void Initialize(DataSource* data_source, FilterCallback* callback); | |
137 virtual size_t GetNumberOfStreams(); | 141 virtual size_t GetNumberOfStreams(); |
138 virtual scoped_refptr<DemuxerStream> GetStream(int stream_id); | 142 virtual scoped_refptr<DemuxerStream> GetStream(int stream_id); |
139 | 143 |
140 // FFmpegProtocol implementation. | 144 // FFmpegProtocol implementation. |
141 virtual int Read(int size, uint8* data); | 145 virtual int Read(int size, uint8* data); |
142 virtual bool GetPosition(int64* position_out); | 146 virtual bool GetPosition(int64* position_out); |
143 virtual bool SetPosition(int64 position); | 147 virtual bool SetPosition(int64 position); |
144 virtual bool GetSize(int64* size_out); | 148 virtual bool GetSize(int64* size_out); |
145 virtual bool IsStreaming(); | 149 virtual bool IsStreaming(); |
146 | 150 |
147 // Provide access to FFmpegDemuxerStream. | 151 // Provide access to FFmpegDemuxerStream. |
148 MessageLoop* message_loop(); | 152 MessageLoop* message_loop(); |
149 | 153 |
150 private: | 154 private: |
151 // Only allow a factory to create this class. | 155 // Only allow a factory to create this class. |
152 friend class MockFFmpegDemuxer; | 156 friend class MockFFmpegDemuxer; |
153 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); | 157 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); |
154 | 158 |
155 // Carries out initialization on the demuxer thread. | 159 // Carries out initialization on the demuxer thread. |
156 void InitializeTask(DataSource* data_source, FilterCallback* callback); | 160 void InitializeTask( |
| 161 DataSource* data_source, PipelineStatusCallback* callback); |
157 | 162 |
158 // Carries out a seek on the demuxer thread. | 163 // Carries out a seek on the demuxer thread. |
159 void SeekTask(base::TimeDelta time, FilterCallback* callback); | 164 void SeekTask(base::TimeDelta time, FilterCallback* callback); |
160 | 165 |
161 // Carries out demuxing and satisfying stream reads on the demuxer thread. | 166 // Carries out demuxing and satisfying stream reads on the demuxer thread. |
162 void DemuxTask(); | 167 void DemuxTask(); |
163 | 168 |
164 // Carries out stopping the demuxer streams on the demuxer thread. | 169 // Carries out stopping the demuxer streams on the demuxer thread. |
165 void StopTask(FilterCallback* callback); | 170 void StopTask(FilterCallback* callback); |
166 | 171 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // signaled when the demuxer is being stopped. | 224 // signaled when the demuxer is being stopped. |
220 base::WaitableEvent read_event_; | 225 base::WaitableEvent read_event_; |
221 | 226 |
222 // Flag to indicate if read has ever failed. Once set to true, it will | 227 // Flag to indicate if read has ever failed. Once set to true, it will |
223 // never be reset. This flag is set true and accessed in Read(). | 228 // never be reset. This flag is set true and accessed in Read(). |
224 bool read_has_failed_; | 229 bool read_has_failed_; |
225 | 230 |
226 size_t last_read_bytes_; | 231 size_t last_read_bytes_; |
227 int64 read_position_; | 232 int64 read_position_; |
228 | 233 |
| 234 // Initialization can happen before set_host() is called, in which case we |
| 235 // store these bits for deferred reporting to the FilterHost when we get one. |
| 236 base::TimeDelta max_duration_; |
| 237 PipelineError deferred_status_; |
| 238 |
229 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 239 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
230 }; | 240 }; |
231 | 241 |
232 } // namespace media | 242 } // namespace media |
233 | 243 |
234 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 244 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |