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

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

Issue 2605993002: Experiment with more aggressive MSE GC on memory pressure (Closed)
Patch Set: rebase/resolve conflicts 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
« no previous file with comments | « media/filters/source_buffer_state.cc ('k') | media/filters/source_buffer_stream.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 // 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 // Gets invoked when the system is experiencing memory pressure, i.e. there's
98 // not enough free memory. The |media_time| is the media playback position at
99 // the time of memory pressure notification (needed for accurate GC). The
100 // |memory_pressure_listener| indicates memory pressure severity. The
101 // |force_instant_gc| is used to force the MSE garbage collection algorithm to
102 // be run right away, without waiting for the next append.
103 void OnMemoryPressure(
104 DecodeTimestamp media_time,
105 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
106 bool force_instant_gc);
107
96 // Changes the SourceBufferStream's state so that it will start returning 108 // Changes the SourceBufferStream's state so that it will start returning
97 // buffers starting from the closest keyframe before |timestamp|. 109 // buffers starting from the closest keyframe before |timestamp|.
98 void Seek(base::TimeDelta timestamp); 110 void Seek(base::TimeDelta timestamp);
99 111
100 // Returns true if the SourceBufferStream has seeked to a time without 112 // Returns true if the SourceBufferStream has seeked to a time without
101 // buffered data and is waiting for more data to be appended. 113 // buffered data and is waiting for more data to be appended.
102 bool IsSeekPending() const; 114 bool IsSeekPending() const;
103 115
104 // Notifies the SourceBufferStream that the media duration has been changed to 116 // Notifies the SourceBufferStream that the media duration has been changed to
105 // |duration| so it should drop any data past that point. 117 // |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; 435 bool last_appended_buffer_is_keyframe_ = false;
424 436
425 // The decode timestamp on the last buffer returned by the most recent 437 // The decode timestamp on the last buffer returned by the most recent
426 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't 438 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't
427 // been called yet or a seek has happened since the last GetNextBuffer() call. 439 // been called yet or a seek has happened since the last GetNextBuffer() call.
428 DecodeTimestamp last_output_buffer_timestamp_; 440 DecodeTimestamp last_output_buffer_timestamp_;
429 441
430 // Stores the largest distance between two adjacent buffers in this stream. 442 // Stores the largest distance between two adjacent buffers in this stream.
431 base::TimeDelta max_interbuffer_distance_; 443 base::TimeDelta max_interbuffer_distance_;
432 444
445 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level_ =
446 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE;
447
433 // The maximum amount of data in bytes the stream will keep in memory. 448 // The maximum amount of data in bytes the stream will keep in memory.
434 size_t memory_limit_; 449 size_t memory_limit_;
435 450
436 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() 451 // Indicates that a kConfigChanged status has been reported by GetNextBuffer()
437 // and GetCurrentXXXDecoderConfig() must be called to update the current 452 // and GetCurrentXXXDecoderConfig() must be called to update the current
438 // config. GetNextBuffer() must not be called again until 453 // config. GetNextBuffer() must not be called again until
439 // GetCurrentXXXDecoderConfig() has been called. 454 // GetCurrentXXXDecoderConfig() has been called.
440 bool config_change_pending_ = false; 455 bool config_change_pending_ = false;
441 456
442 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is 457 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is
443 // returned from GetNextBufferInternal(). 458 // returned from GetNextBufferInternal().
444 scoped_refptr<StreamParserBuffer> pending_buffer_; 459 scoped_refptr<StreamParserBuffer> pending_buffer_;
445 460
446 // Indicates that all buffers before |pending_buffer_| have been handed out. 461 // Indicates that all buffers before |pending_buffer_| have been handed out.
447 bool pending_buffers_complete_ = false; 462 bool pending_buffers_complete_ = false;
448 463
449 // To prevent log spam, count the number of logs for different log scenarios. 464 // To prevent log spam, count the number of logs for different log scenarios.
450 int num_splice_logs_ = 0; 465 int num_splice_logs_ = 0;
451 int num_track_buffer_gap_warning_logs_ = 0; 466 int num_track_buffer_gap_warning_logs_ = 0;
452 int num_garbage_collect_algorithm_logs_ = 0; 467 int num_garbage_collect_algorithm_logs_ = 0;
453 int num_strange_same_timestamps_logs_ = 0; 468 int num_strange_same_timestamps_logs_ = 0;
454 469
455 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); 470 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
456 }; 471 };
457 472
458 } // namespace media 473 } // namespace media
459 474
460 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ 475 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/source_buffer_state.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698