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

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

Issue 164233005: Cap the memory usage in FFMpegDemuxer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert to IsMaxMemoryUsage api style in FFMpegDemuxer. Created 6 years, 10 months 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
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Returns the range of buffered data in this stream. 87 // Returns the range of buffered data in this stream.
88 Ranges<base::TimeDelta> GetBufferedRanges() const; 88 Ranges<base::TimeDelta> GetBufferedRanges() const;
89 89
90 // Returns elapsed time based on the already queued packets. 90 // Returns elapsed time based on the already queued packets.
91 // Used to determine stream duration when it's not known ahead of time. 91 // Used to determine stream duration when it's not known ahead of time.
92 base::TimeDelta GetElapsedTime() const; 92 base::TimeDelta GetElapsedTime() const;
93 93
94 // Returns true if this stream has capacity for additional data. 94 // Returns true if this stream has capacity for additional data.
95 bool HasAvailableCapacity(); 95 bool HasAvailableCapacity();
96 96
97 // Returns the total buffer size FFMpegDemuxerStream is holding onto.
98 int MemoryUsage() const;
DaleCurtis 2014/02/19 18:59:25 size_t again.
damienv1 2014/02/19 20:24:33 Done.
99
97 TextKind GetTextKind() const; 100 TextKind GetTextKind() const;
98 101
99 // Returns the value associated with |key| in the metadata for the avstream. 102 // Returns the value associated with |key| in the metadata for the avstream.
100 // Returns an empty string if the key is not present. 103 // Returns an empty string if the key is not present.
101 std::string GetMetadata(const char* key) const; 104 std::string GetMetadata(const char* key) const;
102 105
103 private: 106 private:
104 friend class FFmpegDemuxerTest; 107 friend class FFmpegDemuxerTest;
105 108
106 // Runs |read_cb_| if present with the front of |buffer_queue_|, calling 109 // Runs |read_cb_| if present with the front of |buffer_queue_|, calling
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void ReadFrameIfNeeded(); 178 void ReadFrameIfNeeded();
176 void OnReadFrameDone(ScopedAVPacket packet, int result); 179 void OnReadFrameDone(ScopedAVPacket packet, int result);
177 180
178 // DataSource callbacks during stopping. 181 // DataSource callbacks during stopping.
179 void OnDataSourceStopped(const base::Closure& callback); 182 void OnDataSourceStopped(const base::Closure& callback);
180 183
181 // Returns true iff any stream has additional capacity. Note that streams can 184 // Returns true iff any stream has additional capacity. Note that streams can
182 // go over capacity depending on how the file is muxed. 185 // go over capacity depending on how the file is muxed.
183 bool StreamsHaveAvailableCapacity(); 186 bool StreamsHaveAvailableCapacity();
184 187
188 // Returns true if the maximum allowed memory usage has been reached.
189 bool IsMaxMemoryUsageReached() const;
190
185 // Signal all FFmpegDemuxerStreams that the stream has ended. 191 // Signal all FFmpegDemuxerStreams that the stream has ended.
186 void StreamHasEnded(); 192 void StreamHasEnded();
187 193
188 // Called by |url_protocol_| whenever |data_source_| returns a read error. 194 // Called by |url_protocol_| whenever |data_source_| returns a read error.
189 void OnDataSourceError(); 195 void OnDataSourceError();
190 196
191 // Returns the stream from |streams_| that matches |type| as an 197 // Returns the stream from |streams_| that matches |type| as an
192 // FFmpegDemuxerStream. 198 // FFmpegDemuxerStream.
193 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; 199 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const;
194 200
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 scoped_ptr<FFmpegGlue> glue_; 263 scoped_ptr<FFmpegGlue> glue_;
258 264
259 const NeedKeyCB need_key_cb_; 265 const NeedKeyCB need_key_cb_;
260 266
261 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 267 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
262 }; 268 };
263 269
264 } // namespace media 270 } // namespace media
265 271
266 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 272 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698