| 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 // Returns true if the maximum allowed memory usage has been reached. | 236 // Updates |stream_memory_usage_| to the memory usage in bytes of all |
| 237 bool IsMaxMemoryUsageReached() const; | 237 // FFmpegDemuxerStreams. Returns the current memory usage. |
| 238 int64_t UpdateMemoryUsage(); |
| 238 | 239 |
| 239 // Signal all FFmpegDemuxerStreams that the stream has ended. | 240 // Signal all FFmpegDemuxerStreams that the stream has ended. |
| 240 void StreamHasEnded(); | 241 void StreamHasEnded(); |
| 241 | 242 |
| 242 // Called by |url_protocol_| whenever |data_source_| returns a read error. | 243 // Called by |url_protocol_| whenever |data_source_| returns a read error. |
| 243 void OnDataSourceError(); | 244 void OnDataSourceError(); |
| 244 | 245 |
| 245 // Returns the stream from |streams_| that matches |type| as an | 246 // Returns the stream from |streams_| that matches |type| as an |
| 246 // FFmpegDemuxerStream. | 247 // FFmpegDemuxerStream. |
| 247 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; | 248 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // Set if we know duration of the audio stream. Used when processing end of | 317 // Set if we know duration of the audio stream. Used when processing end of |
| 317 // stream -- at this moment we definitely know duration. | 318 // stream -- at this moment we definitely know duration. |
| 318 bool duration_known_; | 319 bool duration_known_; |
| 319 | 320 |
| 320 // FFmpegURLProtocol implementation and corresponding glue bits. | 321 // FFmpegURLProtocol implementation and corresponding glue bits. |
| 321 scoped_ptr<BlockingUrlProtocol> url_protocol_; | 322 scoped_ptr<BlockingUrlProtocol> url_protocol_; |
| 322 scoped_ptr<FFmpegGlue> glue_; | 323 scoped_ptr<FFmpegGlue> glue_; |
| 323 | 324 |
| 324 const EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | 325 const EncryptedMediaInitDataCB encrypted_media_init_data_cb_; |
| 325 | 326 |
| 327 // Last stream size as calculated by UpdateMemoryUsage(). |
| 328 mutable base::Lock stream_memory_usage_lock_; |
| 329 int64_t stream_memory_usage_; |
| 330 |
| 326 // NOTE: Weak pointers must be invalidated before all other member variables. | 331 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 327 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; | 332 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; |
| 328 | 333 |
| 329 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 334 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 330 }; | 335 }; |
| 331 | 336 |
| 332 } // namespace media | 337 } // namespace media |
| 333 | 338 |
| 334 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 339 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |