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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void OnSeekFrameDone(const PipelineStatusCB& cb, int result); | 226 void OnSeekFrameDone(const PipelineStatusCB& cb, int result); |
227 | 227 |
228 // FFmpeg callbacks during reading + helper method to initiate reads. | 228 // FFmpeg callbacks during reading + helper method to initiate reads. |
229 void ReadFrameIfNeeded(); | 229 void ReadFrameIfNeeded(); |
230 void OnReadFrameDone(ScopedAVPacket packet, int result); | 230 void OnReadFrameDone(ScopedAVPacket packet, int result); |
231 | 231 |
232 // Returns true iff any stream has additional capacity. Note that streams can | 232 // Returns true iff any stream has additional capacity. Note that streams can |
233 // go over capacity depending on how the file is muxed. | 233 // go over capacity depending on how the file is muxed. |
234 bool StreamsHaveAvailableCapacity(); | 234 bool StreamsHaveAvailableCapacity(); |
235 | 235 |
236 // Updates |stream_memory_usage_| to the memory usage in bytes of all | 236 // Returns true if the maximum allowed memory usage has been reached. |
237 // FFmpegDemuxerStreams. Returns the current memory usage. | 237 bool IsMaxMemoryUsageReached() const; |
238 int64_t UpdateMemoryUsage(); | |
239 | 238 |
240 // Signal all FFmpegDemuxerStreams that the stream has ended. | 239 // Signal all FFmpegDemuxerStreams that the stream has ended. |
241 void StreamHasEnded(); | 240 void StreamHasEnded(); |
242 | 241 |
243 // Called by |url_protocol_| whenever |data_source_| returns a read error. | 242 // Called by |url_protocol_| whenever |data_source_| returns a read error. |
244 void OnDataSourceError(); | 243 void OnDataSourceError(); |
245 | 244 |
246 // Returns the stream from |streams_| that matches |type| as an | 245 // Returns the stream from |streams_| that matches |type| as an |
247 // FFmpegDemuxerStream. | 246 // FFmpegDemuxerStream. |
248 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; | 247 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Set if we know duration of the audio stream. Used when processing end of | 316 // Set if we know duration of the audio stream. Used when processing end of |
318 // stream -- at this moment we definitely know duration. | 317 // stream -- at this moment we definitely know duration. |
319 bool duration_known_; | 318 bool duration_known_; |
320 | 319 |
321 // FFmpegURLProtocol implementation and corresponding glue bits. | 320 // FFmpegURLProtocol implementation and corresponding glue bits. |
322 scoped_ptr<BlockingUrlProtocol> url_protocol_; | 321 scoped_ptr<BlockingUrlProtocol> url_protocol_; |
323 scoped_ptr<FFmpegGlue> glue_; | 322 scoped_ptr<FFmpegGlue> glue_; |
324 | 323 |
325 const EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | 324 const EncryptedMediaInitDataCB encrypted_media_init_data_cb_; |
326 | 325 |
327 // Last stream size as calculated by UpdateMemoryUsage(). | |
328 mutable base::Lock stream_memory_usage_lock_; | |
329 int64_t stream_memory_usage_; | |
330 | |
331 // NOTE: Weak pointers must be invalidated before all other member variables. | 326 // NOTE: Weak pointers must be invalidated before all other member variables. |
332 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; | 327 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; |
333 | 328 |
334 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 329 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
335 }; | 330 }; |
336 | 331 |
337 } // namespace media | 332 } // namespace media |
338 | 333 |
339 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 334 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |