source_buffer_stream.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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
  3. // found in the LICENSE file.
  4. // SourceBufferStream is a data structure that stores media Buffers in ranges.
  5. // Buffers can be appended out of presentation order. Buffers are retrieved by
  6. // seeking to the desired start point and calling GetNextBuffer(). Buffers are
  7. // returned in sequential order to feed decoder, generally near presentation
  8. // order though not necessarily the same as presentation order within GOPs of
  9. // out-of-order codecs.
  10. #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
  11. #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
  12. #include <stddef.h>
  13. #include <list>
  14. #include <memory>
  15. #include <string>
  16. #include <type_traits>
  17. #include <utility>
  18. #include <vector>
  19. #include "base/memory/memory_pressure_listener.h"
  20. #include "base/memory/raw_ptr.h"
  21. #include "base/memory/ref_counted.h"
  22. #include "base/time/time.h"
  23. #include "media/base/audio_decoder_config.h"
  24. #include "media/base/media_export.h"
  25. #include "media/base/media_log.h"
  26. #include "media/base/ranges.h"
  27. #include "media/base/stream_parser_buffer.h"
  28. #include "media/base/text_track_config.h"
  29. #include "media/base/video_decoder_config.h"
  30. #include "media/filters/source_buffer_range.h"
  31. namespace media {
  32. // Status returned by GetNextBuffer().
  33. // kSuccess: Indicates that the next buffer was returned.
  34. // kNeedBuffer: Indicates that we need more data before a buffer can be
  35. // returned.
  36. // kConfigChange: Indicates that the next buffer requires a config change.
  37. enum class SourceBufferStreamStatus {
  38. kSuccess,
  39. kNeedBuffer,
  40. kConfigChange,
  41. kEndOfStream
  42. };
  43. enum class SourceBufferStreamType { kAudio, kVideo, kText };
  44. // See file-level comment for complete description.
  45. class MEDIA_EXPORT SourceBufferStream {
  46. public:
  47. using BufferQueue = StreamParser::BufferQueue;
  48. using RangeList = std::list<std::unique_ptr<SourceBufferRange>>;
  49. // Helper for PrepareRangesForNextAppend and BufferQueueToLogString that
  50. // populates |start| and |end| with the presentation interval of |buffers|.
  51. static void GetTimestampInterval(const BufferQueue& buffers,
  52. base::TimeDelta* start,
  53. base::TimeDelta* end);
  54. SourceBufferStream(const AudioDecoderConfig& audio_config,
  55. MediaLog* media_log);
  56. SourceBufferStream(const VideoDecoderConfig& video_config,
  57. MediaLog* media_log);
  58. SourceBufferStream(const TextTrackConfig& text_config, MediaLog* media_log);
  59. SourceBufferStream(const SourceBufferStream&) = delete;
  60. SourceBufferStream& operator=(const SourceBufferStream&) = delete;
  61. ~SourceBufferStream();
  62. // Signals that the next buffers appended are part of a new coded frame group
  63. // starting at |coded_frame_group_start_pts|.
  64. void OnStartOfCodedFrameGroup(base::TimeDelta coded_frame_group_start_pts);
  65. // Add the |buffers| to the SourceBufferStream. Buffers within the queue are
  66. // expected to be in order, but multiple calls to Append() may add buffers out
  67. // of order or overlapping. Assumes all buffers within |buffers| are in
  68. // presentation order and are non-overlapping.
  69. void Append(const BufferQueue& buffers);
  70. // Removes buffers between |start| and |end| according to the steps
  71. // in the "Coded Frame Removal Algorithm" in the Media Source
  72. // Extensions Spec.
  73. // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#sourcebuffer-coded-frame-removal
  74. //
  75. // |duration| is the current duration of the presentation. It is
  76. // required by the computation outlined in the spec.
  77. void Remove(base::TimeDelta start, base::TimeDelta end,
  78. base::TimeDelta duration);
  79. // Frees up space if the SourceBufferStream is taking up too much memory.
  80. // |media_time| is current playback position.
  81. bool GarbageCollectIfNeeded(base::TimeDelta media_time, size_t newDataSize);
  82. // Gets invoked when the system is experiencing memory pressure, i.e. there's
  83. // not enough free memory. The |media_time| is the media playback position at
  84. // the time of memory pressure notification (needed for accurate GC). The
  85. // |memory_pressure_level| indicates memory pressure severity. The
  86. // |force_instant_gc| is used to force the MSE garbage collection algorithm to
  87. // be run right away, without waiting for the next append.
  88. void OnMemoryPressure(
  89. base::TimeDelta media_time,
  90. base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
  91. bool force_instant_gc);
  92. // Changes the SourceBufferStream's state so that it will start returning
  93. // buffers starting from the closest keyframe before |timestamp|.
  94. void Seek(base::TimeDelta timestamp);
  95. // Returns true if the SourceBufferStream has seeked to a time without
  96. // buffered data and is waiting for more data to be appended.
  97. bool IsSeekPending() const;
  98. // Notifies the SourceBufferStream that the media duration has been changed to
  99. // |duration| so it should drop any data past that point.
  100. void OnSetDuration(base::TimeDelta duration);
  101. // Fills |out_buffer| with a new buffer. Buffers are presented in order from
  102. // the last call to Seek(), or starting with the first buffer appended if
  103. // Seek() has not been called yet.
  104. // |out_buffer|'s timestamp may be earlier than the |timestamp| passed to
  105. // the last Seek() call.
  106. // Returns kSuccess if |out_buffer| is filled with a valid buffer, kNeedBuffer
  107. // if there is not enough data buffered to fulfill the request, and
  108. // kConfigChange if the next buffer requires a config change.
  109. SourceBufferStreamStatus GetNextBuffer(
  110. scoped_refptr<StreamParserBuffer>* out_buffer);
  111. // Returns a list of the buffered time ranges.
  112. Ranges<base::TimeDelta> GetBufferedTime() const;
  113. // Returns the highest buffered PTS or base::TimeDelta() if nothing is
  114. // buffered.
  115. base::TimeDelta GetHighestPresentationTimestamp() const;
  116. // Returns the duration of the buffered ranges, which is equivalent
  117. // to the end timestamp of the last buffered range. If no data is buffered
  118. // then base::TimeDelta() is returned.
  119. base::TimeDelta GetBufferedDuration() const;
  120. // Returns the size of the buffered data in bytes.
  121. size_t GetBufferedSize() const;
  122. // Notifies this object that end of stream has been signalled.
  123. void MarkEndOfStream();
  124. // Clear the end of stream state set by MarkEndOfStream().
  125. void UnmarkEndOfStream();
  126. const AudioDecoderConfig& GetCurrentAudioDecoderConfig();
  127. const VideoDecoderConfig& GetCurrentVideoDecoderConfig();
  128. const TextTrackConfig& GetCurrentTextTrackConfig();
  129. // Notifies this object that the audio config has changed and buffers in
  130. // future Append() calls should be associated with this new config.
  131. // If the codec is allowed to change, the caller should set
  132. // |allow_codec_change| to true.
  133. bool UpdateAudioConfig(const AudioDecoderConfig& config,
  134. bool allow_codec_change);
  135. // Notifies this object that the video config has changed and buffers in
  136. // future Append() calls should be associated with this new config.
  137. // If the codec is allowed to change, the caller should set
  138. // |allow_codec_change| to true.
  139. bool UpdateVideoConfig(const VideoDecoderConfig& config,
  140. bool allow_codec_change);
  141. // Returns the largest distance between two adjacent buffers in this stream,
  142. // or an estimate if no two adjacent buffers have been appended to the stream
  143. // yet.
  144. base::TimeDelta GetMaxInterbufferDistance() const;
  145. void set_memory_limit(size_t memory_limit) {
  146. memory_limit_ = memory_limit;
  147. }
  148. private:
  149. friend class SourceBufferStreamTest;
  150. // Attempts to delete approximately |total_bytes_to_free| amount of data
  151. // |ranges_|, starting at the front of |ranges_| and moving linearly forward
  152. // through the buffers. Deletes starting from the back if |reverse_direction|
  153. // is true. |media_time| is current playback position.
  154. // Returns the number of bytes freed.
  155. size_t FreeBuffers(size_t total_bytes_to_free,
  156. base::TimeDelta media_time,
  157. bool reverse_direction);
  158. // Attempts to delete approximately |total_bytes_to_free| amount of data from
  159. // |ranges_|, starting after the last appended media
  160. // (|highest_buffered_end_time_in_append_sequence_|) but before the current
  161. // playback position |media_time|.
  162. size_t FreeBuffersAfterLastAppended(size_t total_bytes_to_free,
  163. base::TimeDelta media_time);
  164. // Gets the removal range to secure |total_bytes_to_free| from
  165. // [|start_timestamp|, |end_timestamp|).
  166. // Returns the size of buffers to secure if future
  167. // Remove(|start_timestamp|, |removal_end_timestamp|, duration) is called.
  168. // Will not update |removal_end_timestamp| if the returned size is 0.
  169. size_t GetRemovalRange(base::TimeDelta start_timestamp,
  170. base::TimeDelta end_timestamp,
  171. size_t total_bytes_to_free,
  172. base::TimeDelta* removal_end_timestamp);
  173. // Prepares |range_for_next_append_| so |new_buffers| can be appended.
  174. // This involves removing buffers between the end of the previous append
  175. // and any buffers covered by the time range in |new_buffers|.
  176. // |deleted_buffers| is an output parameter containing candidates for
  177. // |track_buffer_| if this method ends up removing the current playback
  178. // position from the range.
  179. void PrepareRangesForNextAppend(const BufferQueue& new_buffers,
  180. BufferQueue* deleted_buffers);
  181. // Removes buffers, from the |track_buffer_|, that come after |timestamp|.
  182. // Due to out-of-order decode versus presentation times for some kinds of
  183. // media, |timestamp| should be the time of a keyframe known by the caller.
  184. // |timestamp| must not be kNoTimestamp.
  185. void PruneTrackBuffer(const base::TimeDelta timestamp);
  186. // Checks to see if |range_with_new_buffers_itr| can be merged with the range
  187. // next to it, and merges them if so while preserving correctness of
  188. // |range_for_next_append_| and |selected_range_|.
  189. void MergeWithNextRangeIfNecessary(
  190. const RangeList::iterator& range_with_new_buffers_itr);
  191. // Merges any adjacent ranges while preserving correctness of
  192. // |range_for_next_append_| and |selected_range_|.
  193. void MergeAllAdjacentRanges();
  194. // Returns true if |next_gop_timestamp| follows
  195. // |highest_timestamp_in_append_sequence_| within fudge room.
  196. bool IsNextGopAdjacentToEndOfCurrentAppendSequence(
  197. base::TimeDelta next_gop_timestamp) const;
  198. // Helper method that returns the timestamp for the next buffer that
  199. // |selected_range_| will return from GetNextBuffer() call, or kNoTimestamp
  200. // if in between seeking (i.e. |selected_range_| is null).
  201. base::TimeDelta GetNextBufferTimestamp();
  202. // Finds the range that should contain a coded frame group that begins with
  203. // |start_timestamp| (presentation time) and returns the iterator pointing to
  204. // it. Returns |ranges_.end()| if there's no such existing range.
  205. RangeList::iterator FindExistingRangeFor(base::TimeDelta start_timestamp);
  206. // Inserts |new_range| into |ranges_| preserving sorted order. Returns an
  207. // iterator in |ranges_| that points to |new_range|. |new_range| becomes owned
  208. // by |ranges_|.
  209. RangeList::iterator AddToRanges(std::unique_ptr<SourceBufferRange> new_range);
  210. // Sets the |selected_range_| to |range| and resets the next buffer position
  211. // for the previous |selected_range_|.
  212. void SetSelectedRange(SourceBufferRange* range);
  213. // Seeks |range| to |seek_timestamp| and then calls SetSelectedRange() with
  214. // |range|.
  215. void SeekAndSetSelectedRange(SourceBufferRange* range,
  216. base::TimeDelta seek_timestamp);
  217. // Resets this stream back to an unseeked state.
  218. void ResetSeekState();
  219. // Reset state tracking various metadata about the last appended buffer.
  220. void ResetLastAppendedState();
  221. // Returns true if |seek_timestamp| refers to the beginning of the first range
  222. // in |ranges_|, false otherwise or if |ranges_| is empty.
  223. bool ShouldSeekToStartOfBuffered(base::TimeDelta seek_timestamp) const;
  224. // Returns true if the decode timestamps of |buffers| are monotonically
  225. // increasing (within each GOP) since the previous append to the coded frame
  226. // group, false otherwise.
  227. bool IsDtsMonotonicallyIncreasing(const BufferQueue& buffers);
  228. // Returns true if |selected_range_| is the only range in |ranges_| that
  229. // HasNextBufferPosition().
  230. bool OnlySelectedRangeIsSeeked() const;
  231. // Measures the distances between buffer decode timestamps and tracks the max.
  232. // This enables a reasonable approximation of adjacency fudge room, even for
  233. // out-of-order PTS vs DTS sequences. Returns true if
  234. // |max_interbuffer_distance_| was changed.
  235. bool UpdateMaxInterbufferDtsDistance(const BufferQueue& buffers);
  236. // Sets the config ID for each buffer to |append_config_index_|.
  237. void SetConfigIds(const BufferQueue& buffers);
  238. // Called to complete a config change. Updates |current_config_index_| to
  239. // match the index of the next buffer. Calling this method causes
  240. // GetNextBuffer() to stop returning kConfigChange and start returning
  241. // kSuccess.
  242. void CompleteConfigChange();
  243. // Sets |selected_range_| and seeks to the nearest keyframe after
  244. // |timestamp| if necessary and possible. This method only attempts to
  245. // set |selected_range_| if |seleted_range_| is null and |track_buffer_|
  246. // is empty.
  247. void SetSelectedRangeIfNeeded(const base::TimeDelta timestamp);
  248. // Find a keyframe timestamp that is >= |start_timestamp| and can be used to
  249. // find a new selected range.
  250. // Returns kNoTimestamp if an appropriate keyframe timestamp could not be
  251. // found.
  252. base::TimeDelta FindNewSelectedRangeSeekTimestamp(
  253. const base::TimeDelta start_timestamp);
  254. // Searches |ranges_| for the first keyframe timestamp that is >= |timestamp|.
  255. // If |ranges_| doesn't contain a GOP that covers |timestamp| or doesn't
  256. // have a keyframe after |timestamp| then kNoTimestamp is returned.
  257. base::TimeDelta FindKeyframeAfterTimestamp(const base::TimeDelta timestamp);
  258. // Returns "VIDEO" for a video SourceBufferStream, "AUDIO" for an audio
  259. // stream, and "TEXT" for a text stream.
  260. std::string GetStreamTypeName() const;
  261. // (Audio only) If |new_buffers| overlap existing buffers, trims end of
  262. // existing buffers to remove overlap. |new_buffers| are not modified.
  263. void TrimSpliceOverlap(const BufferQueue& new_buffers);
  264. // Returns true if end of stream has been reached, i.e. the
  265. // following conditions are met:
  266. // 1. end of stream is marked and there is nothing in the track_buffer.
  267. // 2. We don't have any ranges, or the last or no range is selected,
  268. // or there is a pending seek beyond any existing ranges.
  269. bool IsEndOfStreamReached() const;
  270. // Deletes the range pointed to by |*itr| and removes it from |ranges_|.
  271. // If |*itr| points to |selected_range_|, then |selected_range_| is set to
  272. // NULL. After the range is removed, |*itr| is to the range after the one that
  273. // was removed or to |ranges_.end()| if the last range was removed.
  274. void DeleteAndRemoveRange(RangeList::iterator* itr);
  275. // Helper function used when updating |range_for_next_append_|. Returns a
  276. // guess of what the next append timestamp will be based on
  277. // |last_appended_buffer_timestamp_|, |new_coded_frame_group_| and
  278. // |coded_frame_group_start_pts_|. Returns kNoTimestamp if unable to guess,
  279. // which can occur prior to first OnStartOfCodedFrameGroup(), or when the most
  280. // recent GOP appended to since the last OnStartOfCodedFrameGroup() is
  281. // removed.
  282. base::TimeDelta PotentialNextAppendTimestamp() const;
  283. // Helper function used by Remove() and PrepareRangesForNextAppend() to
  284. // remove buffers and ranges between |start| and |end|.
  285. // |exclude_start| - If set to true, buffers with timestamps that
  286. // match |start| are not removed. If set to false, buffers with
  287. // timestamps that match |start| will be removed.
  288. // |*deleted_buffers| - Filled with buffers for the current playback position
  289. // if the removal range included the current playback position. These buffers
  290. // can be used as candidates for placing in the |track_buffer_|.
  291. void RemoveInternal(base::TimeDelta start,
  292. base::TimeDelta end,
  293. bool exclude_start,
  294. BufferQueue* deleted_buffers);
  295. // Helper function used by RemoveInternal() to evaluate whether remove will
  296. // disrupt the last appended GOP. If disruption is expected, reset state
  297. // tracking the last append. This will trigger frame filtering in Append()
  298. // until a new key frame is provided.
  299. void UpdateLastAppendStateForRemove(base::TimeDelta remove_start,
  300. base::TimeDelta remove_end,
  301. bool exclude_start);
  302. SourceBufferStreamType GetType() const;
  303. // See GetNextBuffer() for additional details. This method handles preroll
  304. // frame processing.
  305. SourceBufferStreamStatus HandleNextBufferWithPreroll(
  306. scoped_refptr<StreamParserBuffer>* out_buffer);
  307. // See GetNextBuffer() for additional details. The internal method hands out
  308. // single buffers from the |track_buffer_| and |selected_range_| without
  309. // additional processing for preroll buffers.
  310. SourceBufferStreamStatus GetNextBufferInternal(
  311. scoped_refptr<StreamParserBuffer>* out_buffer);
  312. // If the next buffer's timestamp is significantly beyond the last output
  313. // buffer, and if we just exhausted |track_buffer_| on the previous read, this
  314. // method logs a warning to |media_log_| that there could be perceivable
  315. // delay. Apps can avoid this behavior by not overlap-appending buffers near
  316. // current playback position.
  317. void WarnIfTrackBufferExhaustionSkipsForward(
  318. scoped_refptr<StreamParserBuffer> next_buffer);
  319. // If |out_buffer| has preroll, sets |pending_buffer_| to feed out preroll and
  320. // returns true. Otherwise returns false.
  321. bool SetPendingBuffer(scoped_refptr<StreamParserBuffer>* out_buffer);
  322. // Used to report log messages that can help the web developer figure out what
  323. // is wrong with the content.
  324. raw_ptr<MediaLog> media_log_;
  325. // List of disjoint buffered ranges, ordered by start time.
  326. RangeList ranges_;
  327. // Indicates which decoder config is being used by the decoder.
  328. // GetNextBuffer() is only allows to return buffers that have a
  329. // config ID that matches this index. If there is a mismatch then
  330. // it must signal that a config change is needed.
  331. int current_config_index_ = 0;
  332. // Indicates which decoder config to associate with new buffers
  333. // being appended. Each new buffer appended has its config ID set
  334. // to the value of this field.
  335. int append_config_index_ = 0;
  336. // Holds the audio/video configs for this stream. |current_config_index_|
  337. // and |append_config_index_| represent indexes into one of these vectors.
  338. std::vector<AudioDecoderConfig> audio_configs_;
  339. std::vector<VideoDecoderConfig> video_configs_;
  340. // Holds the text config for this stream.
  341. TextTrackConfig text_track_config_;
  342. // True if more data needs to be appended before the Seek() can complete,
  343. // false if no Seek() has been requested or the Seek() is completed.
  344. bool seek_pending_ = false;
  345. // True if the end of the stream has been signalled.
  346. bool end_of_stream_ = false;
  347. // Timestamp of the last request to Seek().
  348. base::TimeDelta seek_buffer_timestamp_;
  349. // Pointer to the seeked-to Range. This is the range from which
  350. // GetNextBuffer() calls are fulfilled after the |track_buffer_| has been
  351. // emptied.
  352. raw_ptr<SourceBufferRange> selected_range_ = nullptr;
  353. // Queue of the next buffers to be returned from calls to GetNextBuffer(). If
  354. // |track_buffer_| is empty, return buffers from |selected_range_|.
  355. BufferQueue track_buffer_;
  356. // If there has been no intervening Seek, this will be true if the last
  357. // emitted buffer emptied |track_buffer_|.
  358. bool just_exhausted_track_buffer_ = false;
  359. // The start presentation time of the current coded frame group being
  360. // appended.
  361. base::TimeDelta coded_frame_group_start_pts_;
  362. // Points to the range containing the current coded frame group being
  363. // appended.
  364. RangeList::iterator range_for_next_append_;
  365. // True when the next call to Append() begins a new coded frame group.
  366. // TODO(wolenetz): Simplify by passing this flag into Append().
  367. bool new_coded_frame_group_ = false;
  368. // The timestamp of the last buffer appended to the coded frame group, set to
  369. // kNoTimestamp if the beginning of the group.
  370. base::TimeDelta last_appended_buffer_timestamp_ = kNoTimestamp;
  371. base::TimeDelta last_appended_buffer_duration_ = kNoTimestamp;
  372. bool last_appended_buffer_is_keyframe_ = false;
  373. // When buffering GOPs by keyframe PTS and intra-gop by nonkeyframe DTS, to
  374. // verify monotonically increasing intra-GOP DTS sequence and to update max
  375. // interbuffer distance also by DTS deltas within a coded frame group, the
  376. // following is needed.
  377. DecodeTimestamp last_appended_buffer_decode_timestamp_ = kNoDecodeTimestamp;
  378. // The following is the highest presentation timestamp appended so far in this
  379. // coded frame group. Due to potentially out-of-order decode versus
  380. // presentation time sequence, this isn't necessarily the most recently
  381. // appended frame. This is used as the lower bound of removing previously
  382. // buffered media when processing new appends.
  383. base::TimeDelta highest_timestamp_in_append_sequence_ = kNoTimestamp;
  384. // The following is used in determining if FreeBuffersAfterLastAppended() is
  385. // allowed during garbage collection. Due to out-of-order decode versus
  386. // presentation sequence, this isn't necessarily the end time of the most
  387. // recently appended frame.
  388. base::TimeDelta highest_buffered_end_time_in_append_sequence_ = kNoTimestamp;
  389. // The highest presentation timestamp for buffers returned by recent
  390. // GetNextBuffer() calls. Set to kNoTimestamp if GetNextBuffer() hasn't been
  391. // called yet or a seek has happened since the last GetNextBuffer() call.
  392. base::TimeDelta highest_output_buffer_timestamp_;
  393. // Stores the largest distance between two adjacent buffers in this stream.
  394. base::TimeDelta max_interbuffer_distance_;
  395. base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level_ =
  396. base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE;
  397. // The maximum amount of data in bytes the stream will keep in memory.
  398. // |memory_limit_| is initialized based on the audio/video configuration in
  399. // the constructor, but either user-setting of |memory_limit_| or
  400. // memory-pressure-based adjustment to determine effective limit in the
  401. // eviction heuristic can cause the result to vary from the value set in
  402. // constructor.
  403. size_t memory_limit_;
  404. // Indicates that a kConfigChanged status has been reported by GetNextBuffer()
  405. // and GetCurrentXXXDecoderConfig() must be called to update the current
  406. // config. GetNextBuffer() must not be called again until
  407. // GetCurrentXXXDecoderConfig() has been called.
  408. bool config_change_pending_ = false;
  409. // Used by HandleNextBufferWithPreroll() when a buffer with preroll is
  410. // returned from GetNextBufferInternal().
  411. scoped_refptr<StreamParserBuffer> pending_buffer_;
  412. // Indicates that all buffers before |pending_buffer_| have been handed out.
  413. bool pending_buffers_complete_ = false;
  414. // To prevent log spam, count the number of logs for different log scenarios.
  415. int num_splice_logs_ = 0;
  416. int num_track_buffer_gap_warning_logs_ = 0;
  417. int num_garbage_collect_algorithm_logs_ = 0;
  418. };
  419. } // namespace media
  420. #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_