| 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 // 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 Loading... |
| 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( |
| 98 DecodeTimestamp media_time, |
| 99 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 100 |
| 96 // Changes the SourceBufferStream's state so that it will start returning | 101 // Changes the SourceBufferStream's state so that it will start returning |
| 97 // buffers starting from the closest keyframe before |timestamp|. | 102 // buffers starting from the closest keyframe before |timestamp|. |
| 98 void Seek(base::TimeDelta timestamp); | 103 void Seek(base::TimeDelta timestamp); |
| 99 | 104 |
| 100 // Returns true if the SourceBufferStream has seeked to a time without | 105 // Returns true if the SourceBufferStream has seeked to a time without |
| 101 // buffered data and is waiting for more data to be appended. | 106 // buffered data and is waiting for more data to be appended. |
| 102 bool IsSeekPending() const; | 107 bool IsSeekPending() const; |
| 103 | 108 |
| 104 // Notifies the SourceBufferStream that the media duration has been changed to | 109 // Notifies the SourceBufferStream that the media duration has been changed to |
| 105 // |duration| so it should drop any data past that point. | 110 // |duration| so it should drop any data past that point. |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 bool last_appended_buffer_is_keyframe_ = false; | 428 bool last_appended_buffer_is_keyframe_ = false; |
| 424 | 429 |
| 425 // The decode timestamp on the last buffer returned by the most recent | 430 // The decode timestamp on the last buffer returned by the most recent |
| 426 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't | 431 // GetNextBuffer() call. Set to kNoDecodeTimestamp() if GetNextBuffer() hasn't |
| 427 // been called yet or a seek has happened since the last GetNextBuffer() call. | 432 // been called yet or a seek has happened since the last GetNextBuffer() call. |
| 428 DecodeTimestamp last_output_buffer_timestamp_; | 433 DecodeTimestamp last_output_buffer_timestamp_; |
| 429 | 434 |
| 430 // Stores the largest distance between two adjacent buffers in this stream. | 435 // Stores the largest distance between two adjacent buffers in this stream. |
| 431 base::TimeDelta max_interbuffer_distance_; | 436 base::TimeDelta max_interbuffer_distance_; |
| 432 | 437 |
| 438 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level_ = |
| 439 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; |
| 440 |
| 433 // The maximum amount of data in bytes the stream will keep in memory. | 441 // The maximum amount of data in bytes the stream will keep in memory. |
| 434 size_t memory_limit_; | 442 size_t memory_limit_; |
| 435 | 443 |
| 436 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() | 444 // Indicates that a kConfigChanged status has been reported by GetNextBuffer() |
| 437 // and GetCurrentXXXDecoderConfig() must be called to update the current | 445 // and GetCurrentXXXDecoderConfig() must be called to update the current |
| 438 // config. GetNextBuffer() must not be called again until | 446 // config. GetNextBuffer() must not be called again until |
| 439 // GetCurrentXXXDecoderConfig() has been called. | 447 // GetCurrentXXXDecoderConfig() has been called. |
| 440 bool config_change_pending_ = false; | 448 bool config_change_pending_ = false; |
| 441 | 449 |
| 442 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is | 450 // Used by HandleNextBufferWithPreroll() when a buffer with preroll is |
| 443 // returned from GetNextBufferInternal(). | 451 // returned from GetNextBufferInternal(). |
| 444 scoped_refptr<StreamParserBuffer> pending_buffer_; | 452 scoped_refptr<StreamParserBuffer> pending_buffer_; |
| 445 | 453 |
| 446 // Indicates that all buffers before |pending_buffer_| have been handed out. | 454 // Indicates that all buffers before |pending_buffer_| have been handed out. |
| 447 bool pending_buffers_complete_ = false; | 455 bool pending_buffers_complete_ = false; |
| 448 | 456 |
| 449 // To prevent log spam, count the number of logs for different log scenarios. | 457 // To prevent log spam, count the number of logs for different log scenarios. |
| 450 int num_splice_logs_ = 0; | 458 int num_splice_logs_ = 0; |
| 451 int num_track_buffer_gap_warning_logs_ = 0; | 459 int num_track_buffer_gap_warning_logs_ = 0; |
| 452 int num_garbage_collect_algorithm_logs_ = 0; | 460 int num_garbage_collect_algorithm_logs_ = 0; |
| 453 int num_strange_same_timestamps_logs_ = 0; | 461 int num_strange_same_timestamps_logs_ = 0; |
| 454 | 462 |
| 455 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); | 463 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream); |
| 456 }; | 464 }; |
| 457 | 465 |
| 458 } // namespace media | 466 } // namespace media |
| 459 | 467 |
| 460 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ | 468 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_ |
| OLD | NEW |