Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: media/filters/ffmpeg_demuxer.h

Issue 1419753007: Fix race on demuxer memory usage. Reuse previous calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restyle. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/demuxer.h ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « media/base/demuxer.h ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698