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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // will post ReadTask to execute on demuxer's thread. Read will acquire | 77 // will post ReadTask to execute on demuxer's thread. Read will acquire |
78 // |lock_| for the life of the function so that means |read_cb| must | 78 // |lock_| for the life of the function so that means |read_cb| must |
79 // not make calls into FFmpegDemuxerStream directly or that may cause a | 79 // not make calls into FFmpegDemuxerStream directly or that may cause a |
80 // deadlock. |read_cb| should execute as quickly as possible because | 80 // deadlock. |read_cb| should execute as quickly as possible because |
81 // |lock_| is held throughout the life of the callback. | 81 // |lock_| is held throughout the life of the callback. |
82 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 82 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
83 virtual void EnableBitstreamConverter() OVERRIDE; | 83 virtual void EnableBitstreamConverter() OVERRIDE; |
84 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; | 84 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; |
85 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; | 85 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; |
86 | 86 |
| 87 protected: |
| 88 virtual ~FFmpegDemuxerStream(); |
| 89 |
87 private: | 90 private: |
88 friend class FFmpegDemuxerTest; | 91 friend class FFmpegDemuxerTest; |
89 virtual ~FFmpegDemuxerStream(); | |
90 | 92 |
91 // Carries out enqueuing a pending read on the demuxer thread. | 93 // Carries out enqueuing a pending read on the demuxer thread. |
92 void ReadTask(const ReadCB& read_cb); | 94 void ReadTask(const ReadCB& read_cb); |
93 | 95 |
94 // Attempts to fulfill a single pending read by dequeueing a buffer and read | 96 // Attempts to fulfill a single pending read by dequeueing a buffer and read |
95 // callback pair and executing the callback. The calling function must | 97 // callback pair and executing the callback. The calling function must |
96 // acquire |lock_| before calling this function. | 98 // acquire |lock_| before calling this function. |
97 void FulfillPendingRead(); | 99 void FulfillPendingRead(); |
98 | 100 |
99 // Converts an FFmpeg stream timestamp into a base::TimeDelta. | 101 // Converts an FFmpeg stream timestamp into a base::TimeDelta. |
(...skipping 25 matching lines...) Expand all Loading... |
125 // |read_queue_|, or |stopped_|. | 127 // |read_queue_|, or |stopped_|. |
126 base::Lock lock_; | 128 base::Lock lock_; |
127 | 129 |
128 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); | 130 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); |
129 }; | 131 }; |
130 | 132 |
131 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol { | 133 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol { |
132 public: | 134 public: |
133 FFmpegDemuxer(MessageLoop* message_loop, | 135 FFmpegDemuxer(MessageLoop* message_loop, |
134 const scoped_refptr<DataSource>& data_source); | 136 const scoped_refptr<DataSource>& data_source); |
135 virtual ~FFmpegDemuxer(); | |
136 | 137 |
137 // Posts a task to perform additional demuxing. | 138 // Posts a task to perform additional demuxing. |
138 virtual void PostDemuxTask(); | 139 virtual void PostDemuxTask(); |
139 | 140 |
140 // Demuxer implementation. | 141 // Demuxer implementation. |
141 virtual void Initialize(DemuxerHost* host, | 142 virtual void Initialize(DemuxerHost* host, |
142 const PipelineStatusCB& status_cb) OVERRIDE; | 143 const PipelineStatusCB& status_cb) OVERRIDE; |
143 virtual void Stop(const base::Closure& callback) OVERRIDE; | 144 virtual void Stop(const base::Closure& callback) OVERRIDE; |
144 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 145 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
145 virtual void OnAudioRendererDisabled() OVERRIDE; | 146 virtual void OnAudioRendererDisabled() OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... |
156 virtual bool GetSize(int64* size_out) OVERRIDE; | 157 virtual bool GetSize(int64* size_out) OVERRIDE; |
157 virtual bool IsStreaming() OVERRIDE; | 158 virtual bool IsStreaming() OVERRIDE; |
158 | 159 |
159 // Provide access to FFmpegDemuxerStream. | 160 // Provide access to FFmpegDemuxerStream. |
160 MessageLoop* message_loop(); | 161 MessageLoop* message_loop(); |
161 | 162 |
162 private: | 163 private: |
163 // To allow tests access to privates. | 164 // To allow tests access to privates. |
164 friend class FFmpegDemuxerTest; | 165 friend class FFmpegDemuxerTest; |
165 | 166 |
| 167 virtual ~FFmpegDemuxer(); |
| 168 |
166 // Carries out initialization on the demuxer thread. | 169 // Carries out initialization on the demuxer thread. |
167 void InitializeTask(DemuxerHost* host, const PipelineStatusCB& status_cb); | 170 void InitializeTask(DemuxerHost* host, const PipelineStatusCB& status_cb); |
168 | 171 |
169 // Carries out a seek on the demuxer thread. | 172 // Carries out a seek on the demuxer thread. |
170 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb); | 173 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb); |
171 | 174 |
172 // Carries out demuxing and satisfying stream reads on the demuxer thread. | 175 // Carries out demuxing and satisfying stream reads on the demuxer thread. |
173 void DemuxTask(); | 176 void DemuxTask(); |
174 | 177 |
175 // Carries out stopping the demuxer streams on the demuxer thread. | 178 // Carries out stopping the demuxer streams on the demuxer thread. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // Whether audio has been disabled for this demuxer (in which case this class | 246 // Whether audio has been disabled for this demuxer (in which case this class |
244 // drops packets destined for AUDIO demuxer streams on the floor). | 247 // drops packets destined for AUDIO demuxer streams on the floor). |
245 bool audio_disabled_; | 248 bool audio_disabled_; |
246 | 249 |
247 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 250 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
248 }; | 251 }; |
249 | 252 |
250 } // namespace media | 253 } // namespace media |
251 | 254 |
252 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 255 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |