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

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

Issue 2605993002: Experiment with more aggressive MSE GC on memory pressure (Closed)
Patch Set: nits Created 3 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 // SourceBufferStream is a data structure that stores media Buffers in ranges. 5 // SourceBufferStream is a data structure that stores media Buffers in ranges.
6 // Buffers can be appended out of presentation order. Buffers are retrieved by 6 // Buffers can be appended out of presentation order. Buffers are retrieved by
7 // seeking to the desired start point and calling GetNextBuffer(). Buffers are 7 // seeking to the desired start point and calling GetNextBuffer(). Buffers are
8 // returned in sequential presentation order. 8 // returned in sequential presentation order.
9 9
10 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 10 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
11 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 11 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
12 12
13 #include <stddef.h> 13 #include <stddef.h>
14 14
15 #include <deque> 15 #include <deque>
16 #include <list> 16 #include <list>
17 #include <string> 17 #include <string>
18 #include <utility> 18 #include <utility>
19 #include <vector> 19 #include <vector>
20 20
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/memory_pressure_listener.h"
22 #include "base/memory/ref_counted.h" 23 #include "base/memory/ref_counted.h"
23 #include "media/base/audio_decoder_config.h" 24 #include "media/base/audio_decoder_config.h"
24 #include "media/base/media_export.h" 25 #include "media/base/media_export.h"
25 #include "media/base/media_log.h" 26 #include "media/base/media_log.h"
26 #include "media/base/ranges.h" 27 #include "media/base/ranges.h"
27 #include "media/base/stream_parser_buffer.h" 28 #include "media/base/stream_parser_buffer.h"
28 #include "media/base/text_track_config.h" 29 #include "media/base/text_track_config.h"
29 #include "media/base/video_decoder_config.h" 30 #include "media/base/video_decoder_config.h"
30 31
31 namespace media { 32 namespace media {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // |duration| is the current duration of the presentation. It is 87 // |duration| is the current duration of the presentation. It is
87 // required by the computation outlined in the spec. 88 // required by the computation outlined in the spec.
88 void Remove(base::TimeDelta start, base::TimeDelta end, 89 void Remove(base::TimeDelta start, base::TimeDelta end,
89 base::TimeDelta duration); 90 base::TimeDelta duration);
90 91
91 // Frees up space if the SourceBufferStream is taking up too much memory. 92 // Frees up space if the SourceBufferStream is taking up too much memory.
92 // |media_time| is current playback position. 93 // |media_time| is current playback position.
93 bool GarbageCollectIfNeeded(DecodeTimestamp media_time, 94 bool GarbageCollectIfNeeded(DecodeTimestamp media_time,
94 size_t newDataSize); 95 size_t newDataSize);
95 96
97 void OnMemoryPressure(
Alexei Svitkine (slow) 2017/01/27 18:03:19 Comment?
servolk 2017/01/28 02:23:57 Done.
98 DecodeTimestamp media_time,
99 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
100 bool force_instant_gc);
101
96 // Changes the SourceBufferStream's state so that it will start returning 102 // Changes the SourceBufferStream's state so that it will start returning
97 // buffers starting from the closest keyframe before |timestamp|. 103 // buffers starting from the closest keyframe before |timestamp|.
98 void Seek(base::TimeDelta timestamp); 104 void Seek(base::TimeDelta timestamp);
99 105
100 // Returns true if the SourceBufferStream has seeked to a time without 106 // Returns true if the SourceBufferStream has seeked to a time without
101 // buffered data and is waiting for more data to be appended. 107 // buffered data and is waiting for more data to be appended.
102 bool IsSeekPending() const; 108 bool IsSeekPending() const;
103 109
104 // Notifies the SourceBufferStream that the media duration has been changed to 110 // Notifies the SourceBufferStream that the media duration has been changed to
105 // |duration| so it should drop any data past that point. 111 // |duration| so it should drop any data past that point.
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 bool last_appended_buffer_is_keyframe_ = false; 429 bool last_appended_buffer_is_keyframe_ = false;
424 430
425 // The decode timestamp on the last buffer returned by the most recent 431 // The decode timestamp on the last buffer returned by the most recent
426 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't 432 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't
427 // been called yet or a seek has happened since the last GetNextBuffer() call. 433 // been called yet or a seek has happened since the last GetNextBuffer() call.
428 DecodeTimestamp last_output_buffer_timestamp_; 434 DecodeTimestamp last_output_buffer_timestamp_;
429 435
430 // Stores the largest distance between two adjacent buffers in this stream. 436 // Stores the largest distance between two adjacent buffers in this stream.
431 base::TimeDelta max_interbuffer_distance_; 437 base::TimeDelta max_interbuffer_distance_;
432 438
439 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level_ =
440 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE;
441
433 // The maximum amount of data in bytes the stream will keep in memory. 442 // The maximum amount of data in bytes the stream will keep in memory.
434 size_t memory_limit_; 443 size_t memory_limit_;
435 444
436 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() 445 // Indicates that a kConfigChanged status has been reported by GetNextBuffer()
437 // and GetCurrentXXXDecoderConfig() must be called to update the current 446 // and GetCurrentXXXDecoderConfig() must be called to update the current
438 // config. GetNextBuffer() must not be called again until 447 // config. GetNextBuffer() must not be called again until
439 // GetCurrentXXXDecoderConfig() has been called. 448 // GetCurrentXXXDecoderConfig() has been called.
440 bool config_change_pending_ = false; 449 bool config_change_pending_ = false;
441 450
442 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is 451 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is
443 // returned from GetNextBufferInternal(). 452 // returned from GetNextBufferInternal().
444 scoped_refptr<StreamParserBuffer> pending_buffer_; 453 scoped_refptr<StreamParserBuffer> pending_buffer_;
445 454
446 // Indicates that all buffers before |pending_buffer_| have been handed out. 455 // Indicates that all buffers before |pending_buffer_| have been handed out.
447 bool pending_buffers_complete_ = false; 456 bool pending_buffers_complete_ = false;
448 457
449 // To prevent log spam, count the number of logs for different log scenarios. 458 // To prevent log spam, count the number of logs for different log scenarios.
450 int num_splice_logs_ = 0; 459 int num_splice_logs_ = 0;
451 int num_track_buffer_gap_warning_logs_ = 0; 460 int num_track_buffer_gap_warning_logs_ = 0;
452 int num_garbage_collect_algorithm_logs_ = 0; 461 int num_garbage_collect_algorithm_logs_ = 0;
453 int num_strange_same_timestamps_logs_ = 0; 462 int num_strange_same_timestamps_logs_ = 0;
454 463
455 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 464 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
456 }; 465 };
457 466
458 } // namespace media 467 } // namespace media
459 468
460 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 469 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698