1 // Copyright 2014 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.
5 #include "media/filters/source_buffer_range.h"
11 // Comparison operators for std::upper_bound() and std::lower_bound().
12 static bool CompareTimeDeltaToStreamParserBuffer(
13 const DecodeTimestamp
& decode_timestamp
,
14 const scoped_refptr
<StreamParserBuffer
>& buffer
) {
15 return decode_timestamp
< buffer
->GetDecodeTimestamp();
17 static bool CompareStreamParserBufferToTimeDelta(
18 const scoped_refptr
<StreamParserBuffer
>& buffer
,
19 const DecodeTimestamp
& decode_timestamp
) {
20 return buffer
->GetDecodeTimestamp() < decode_timestamp
;
23 bool SourceBufferRange::AllowSameTimestamp(
24 bool prev_is_keyframe
, bool current_is_keyframe
) {
25 return prev_is_keyframe
|| !current_is_keyframe
;
28 SourceBufferRange::SourceBufferRange(
29 GapPolicy gap_policy
, const BufferQueue
& new_buffers
,
30 DecodeTimestamp media_segment_start_time
,
31 const InterbufferDistanceCB
& interbuffer_distance_cb
)
32 : gap_policy_(gap_policy
),
33 keyframe_map_index_base_(0),
34 next_buffer_index_(-1),
35 media_segment_start_time_(media_segment_start_time
),
36 interbuffer_distance_cb_(interbuffer_distance_cb
),
38 CHECK(!new_buffers
.empty());
39 DCHECK(new_buffers
.front()->is_key_frame());
40 DCHECK(!interbuffer_distance_cb
.is_null());
41 AppendBuffersToEnd(new_buffers
);
44 SourceBufferRange::~SourceBufferRange() {}
46 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue
& new_buffers
) {
47 DCHECK(buffers_
.empty() || CanAppendBuffersToEnd(new_buffers
));
48 DCHECK(media_segment_start_time_
== kNoDecodeTimestamp() ||
49 media_segment_start_time_
<=
50 new_buffers
.front()->GetDecodeTimestamp());
52 AdjustEstimatedDurationForNewAppend(new_buffers
);
54 for (BufferQueue::const_iterator itr
= new_buffers
.begin();
55 itr
!= new_buffers
.end();
57 DCHECK((*itr
)->GetDecodeTimestamp() != kNoDecodeTimestamp());
58 buffers_
.push_back(*itr
);
59 DCHECK_GE((*itr
)->data_size(), 0);
60 size_in_bytes_
+= (*itr
)->data_size();
62 if ((*itr
)->is_key_frame()) {
64 std::make_pair((*itr
)->GetDecodeTimestamp(),
65 buffers_
.size() - 1 + keyframe_map_index_base_
));
70 void SourceBufferRange::AdjustEstimatedDurationForNewAppend(
71 const BufferQueue
& new_buffers
) {
72 if (buffers_
.empty() || new_buffers
.empty()) {
76 // If the last of the previously appended buffers contains estimated duration,
77 // we now refine that estimate by taking the PTS delta from the first new
78 // buffer being appended.
79 const auto& last_appended_buffer
= buffers_
.back();
80 if (last_appended_buffer
->is_duration_estimated()) {
81 base::TimeDelta timestamp_delta
=
82 new_buffers
.front()->timestamp() - last_appended_buffer
->timestamp();
83 DCHECK(timestamp_delta
> base::TimeDelta());
84 if (last_appended_buffer
->duration() != timestamp_delta
) {
85 DVLOG(1) << "Replacing estimated duration ("
86 << last_appended_buffer
->duration()
87 << ") from previous range-end with derived duration ("
88 << timestamp_delta
<< ").";
89 last_appended_buffer
->set_duration(timestamp_delta
);
94 void SourceBufferRange::Seek(DecodeTimestamp timestamp
) {
95 DCHECK(CanSeekTo(timestamp
));
96 DCHECK(!keyframe_map_
.empty());
98 KeyframeMap::iterator result
= GetFirstKeyframeAtOrBefore(timestamp
);
99 next_buffer_index_
= result
->second
- keyframe_map_index_base_
;
100 DCHECK_LT(next_buffer_index_
, static_cast<int>(buffers_
.size()));
103 void SourceBufferRange::SeekAheadTo(DecodeTimestamp timestamp
) {
104 SeekAhead(timestamp
, false);
107 void SourceBufferRange::SeekAheadPast(DecodeTimestamp timestamp
) {
108 SeekAhead(timestamp
, true);
111 void SourceBufferRange::SeekAhead(DecodeTimestamp timestamp
,
112 bool skip_given_timestamp
) {
113 DCHECK(!keyframe_map_
.empty());
115 KeyframeMap::iterator result
=
116 GetFirstKeyframeAt(timestamp
, skip_given_timestamp
);
118 // If there isn't a keyframe after |timestamp|, then seek to end and return
119 // kNoTimestamp to signal such.
120 if (result
== keyframe_map_
.end()) {
121 next_buffer_index_
= -1;
124 next_buffer_index_
= result
->second
- keyframe_map_index_base_
;
125 DCHECK_LT(next_buffer_index_
, static_cast<int>(buffers_
.size()));
128 void SourceBufferRange::SeekToStart() {
129 DCHECK(!buffers_
.empty());
130 next_buffer_index_
= 0;
133 SourceBufferRange
* SourceBufferRange::SplitRange(DecodeTimestamp timestamp
) {
134 CHECK(!buffers_
.empty());
136 // Find the first keyframe at or after |timestamp|.
137 KeyframeMap::iterator new_beginning_keyframe
=
138 GetFirstKeyframeAt(timestamp
, false);
140 // If there is no keyframe after |timestamp|, we can't split the range.
141 if (new_beginning_keyframe
== keyframe_map_
.end())
144 // Remove the data beginning at |keyframe_index| from |buffers_| and save it
145 // into |removed_buffers|.
147 new_beginning_keyframe
->second
- keyframe_map_index_base_
;
148 DCHECK_LT(keyframe_index
, static_cast<int>(buffers_
.size()));
149 BufferQueue::iterator starting_point
= buffers_
.begin() + keyframe_index
;
150 BufferQueue
removed_buffers(starting_point
, buffers_
.end());
152 DecodeTimestamp new_range_start_timestamp
= kNoDecodeTimestamp();
153 if (GetStartTimestamp() < buffers_
.front()->GetDecodeTimestamp() &&
154 timestamp
< removed_buffers
.front()->GetDecodeTimestamp()) {
155 // The split is in the gap between |media_segment_start_time_| and
156 // the first buffer of the new range so we should set the start
157 // time of the new range to |timestamp| so we preserve part of the
158 // gap in the new range.
159 new_range_start_timestamp
= timestamp
;
162 keyframe_map_
.erase(new_beginning_keyframe
, keyframe_map_
.end());
163 FreeBufferRange(starting_point
, buffers_
.end());
165 // Create a new range with |removed_buffers|.
166 SourceBufferRange
* split_range
=
167 new SourceBufferRange(
168 gap_policy_
, removed_buffers
, new_range_start_timestamp
,
169 interbuffer_distance_cb_
);
171 // If the next buffer position is now in |split_range|, update the state of
172 // this range and |split_range| accordingly.
173 if (next_buffer_index_
>= static_cast<int>(buffers_
.size())) {
174 split_range
->next_buffer_index_
= next_buffer_index_
- keyframe_index
;
175 ResetNextBufferPosition();
181 SourceBufferRange::BufferQueue::iterator
SourceBufferRange::GetBufferItrAt(
182 DecodeTimestamp timestamp
,
183 bool skip_given_timestamp
) {
184 return skip_given_timestamp
185 ? std::upper_bound(buffers_
.begin(),
188 CompareTimeDeltaToStreamParserBuffer
)
189 : std::lower_bound(buffers_
.begin(),
192 CompareStreamParserBufferToTimeDelta
);
195 SourceBufferRange::KeyframeMap::iterator
196 SourceBufferRange::GetFirstKeyframeAt(DecodeTimestamp timestamp
,
197 bool skip_given_timestamp
) {
198 return skip_given_timestamp
?
199 keyframe_map_
.upper_bound(timestamp
) :
200 keyframe_map_
.lower_bound(timestamp
);
203 SourceBufferRange::KeyframeMap::iterator
204 SourceBufferRange::GetFirstKeyframeAtOrBefore(DecodeTimestamp timestamp
) {
205 KeyframeMap::iterator result
= keyframe_map_
.lower_bound(timestamp
);
206 // lower_bound() returns the first element >= |timestamp|, so we want the
207 // previous element if it did not return the element exactly equal to
209 if (result
!= keyframe_map_
.begin() &&
210 (result
== keyframe_map_
.end() || result
->first
!= timestamp
)) {
216 void SourceBufferRange::DeleteAll(BufferQueue
* removed_buffers
) {
217 TruncateAt(buffers_
.begin(), removed_buffers
);
220 bool SourceBufferRange::TruncateAt(
221 DecodeTimestamp timestamp
, BufferQueue
* removed_buffers
,
223 // Find the place in |buffers_| where we will begin deleting data.
224 BufferQueue::iterator starting_point
=
225 GetBufferItrAt(timestamp
, is_exclusive
);
226 return TruncateAt(starting_point
, removed_buffers
);
229 size_t SourceBufferRange::DeleteGOPFromFront(BufferQueue
* deleted_buffers
) {
230 DCHECK(!FirstGOPContainsNextBufferPosition());
231 DCHECK(deleted_buffers
);
233 int buffers_deleted
= 0;
234 size_t total_bytes_deleted
= 0;
236 KeyframeMap::iterator front
= keyframe_map_
.begin();
237 DCHECK(front
!= keyframe_map_
.end());
239 // Delete the keyframe at the start of |keyframe_map_|.
240 keyframe_map_
.erase(front
);
242 // Now we need to delete all the buffers that depend on the keyframe we've
244 int end_index
= keyframe_map_
.size() > 0 ?
245 keyframe_map_
.begin()->second
- keyframe_map_index_base_
:
248 // Delete buffers from the beginning of the buffered range up until (but not
249 // including) the next keyframe.
250 for (int i
= 0; i
< end_index
; i
++) {
251 DCHECK_GE(buffers_
.front()->data_size(), 0);
252 size_t bytes_deleted
= buffers_
.front()->data_size();
253 DCHECK_GE(size_in_bytes_
, bytes_deleted
);
254 size_in_bytes_
-= bytes_deleted
;
255 total_bytes_deleted
+= bytes_deleted
;
256 deleted_buffers
->push_back(buffers_
.front());
257 buffers_
.pop_front();
261 // Update |keyframe_map_index_base_| to account for the deleted buffers.
262 keyframe_map_index_base_
+= buffers_deleted
;
264 if (next_buffer_index_
> -1) {
265 next_buffer_index_
-= buffers_deleted
;
266 DCHECK_GE(next_buffer_index_
, 0);
269 // Invalidate media segment start time if we've deleted the first buffer of
271 if (buffers_deleted
> 0)
272 media_segment_start_time_
= kNoDecodeTimestamp();
274 return total_bytes_deleted
;
277 size_t SourceBufferRange::DeleteGOPFromBack(BufferQueue
* deleted_buffers
) {
278 DCHECK(!LastGOPContainsNextBufferPosition());
279 DCHECK(deleted_buffers
);
281 // Remove the last GOP's keyframe from the |keyframe_map_|.
282 KeyframeMap::iterator back
= keyframe_map_
.end();
283 DCHECK_GT(keyframe_map_
.size(), 0u);
286 // The index of the first buffer in the last GOP is equal to the new size of
287 // |buffers_| after that GOP is deleted.
288 size_t goal_size
= back
->second
- keyframe_map_index_base_
;
289 keyframe_map_
.erase(back
);
291 size_t total_bytes_deleted
= 0;
292 while (buffers_
.size() != goal_size
) {
293 DCHECK_GE(buffers_
.back()->data_size(), 0);
294 size_t bytes_deleted
= buffers_
.back()->data_size();
295 DCHECK_GE(size_in_bytes_
, bytes_deleted
);
296 size_in_bytes_
-= bytes_deleted
;
297 total_bytes_deleted
+= bytes_deleted
;
298 // We're removing buffers from the back, so push each removed buffer to the
299 // front of |deleted_buffers| so that |deleted_buffers| are in nondecreasing
301 deleted_buffers
->push_front(buffers_
.back());
305 return total_bytes_deleted
;
308 size_t SourceBufferRange::GetRemovalGOP(
309 DecodeTimestamp start_timestamp
, DecodeTimestamp end_timestamp
,
310 size_t total_bytes_to_free
, DecodeTimestamp
* removal_end_timestamp
) {
311 size_t bytes_removed
= 0;
313 KeyframeMap::iterator gop_itr
= GetFirstKeyframeAt(start_timestamp
, false);
314 if (gop_itr
== keyframe_map_
.end())
316 int keyframe_index
= gop_itr
->second
- keyframe_map_index_base_
;
317 BufferQueue::iterator buffer_itr
= buffers_
.begin() + keyframe_index
;
318 KeyframeMap::iterator gop_end
= keyframe_map_
.end();
319 if (end_timestamp
< GetBufferedEndTimestamp())
320 gop_end
= GetFirstKeyframeAtOrBefore(end_timestamp
);
322 // Check if the removal range is within a GOP and skip the loop if so.
323 // [keyframe]...[start_timestamp]...[end_timestamp]...[keyframe]
324 KeyframeMap::iterator gop_itr_prev
= gop_itr
;
325 if (gop_itr_prev
!= keyframe_map_
.begin() && --gop_itr_prev
== gop_end
)
328 while (gop_itr
!= gop_end
&& bytes_removed
< total_bytes_to_free
) {
332 int next_gop_index
= gop_itr
== keyframe_map_
.end() ?
333 buffers_
.size() : gop_itr
->second
- keyframe_map_index_base_
;
334 BufferQueue::iterator next_gop_start
= buffers_
.begin() + next_gop_index
;
335 for (; buffer_itr
!= next_gop_start
; ++buffer_itr
) {
336 DCHECK_GE((*buffer_itr
)->data_size(), 0);
337 gop_size
+= (*buffer_itr
)->data_size();
340 bytes_removed
+= gop_size
;
342 if (bytes_removed
> 0) {
343 *removal_end_timestamp
= gop_itr
== keyframe_map_
.end() ?
344 GetBufferedEndTimestamp() : gop_itr
->first
;
346 return bytes_removed
;
349 bool SourceBufferRange::FirstGOPContainsNextBufferPosition() const {
350 if (!HasNextBufferPosition())
353 // If there is only one GOP, it must contain the next buffer position.
354 if (keyframe_map_
.size() == 1u)
357 KeyframeMap::const_iterator second_gop
= keyframe_map_
.begin();
359 return next_buffer_index_
< second_gop
->second
- keyframe_map_index_base_
;
362 bool SourceBufferRange::LastGOPContainsNextBufferPosition() const {
363 if (!HasNextBufferPosition())
366 // If there is only one GOP, it must contain the next buffer position.
367 if (keyframe_map_
.size() == 1u)
370 KeyframeMap::const_iterator last_gop
= keyframe_map_
.end();
372 return last_gop
->second
- keyframe_map_index_base_
<= next_buffer_index_
;
375 void SourceBufferRange::FreeBufferRange(
376 const BufferQueue::iterator
& starting_point
,
377 const BufferQueue::iterator
& ending_point
) {
378 for (BufferQueue::iterator itr
= starting_point
;
379 itr
!= ending_point
; ++itr
) {
380 DCHECK_GE((*itr
)->data_size(), 0);
381 size_t itr_data_size
= static_cast<size_t>((*itr
)->data_size());
382 DCHECK_GE(size_in_bytes_
, itr_data_size
);
383 size_in_bytes_
-= itr_data_size
;
385 buffers_
.erase(starting_point
, ending_point
);
388 bool SourceBufferRange::TruncateAt(
389 const BufferQueue::iterator
& starting_point
, BufferQueue
* removed_buffers
) {
390 DCHECK(!removed_buffers
|| removed_buffers
->empty());
392 // Return if we're not deleting anything.
393 if (starting_point
== buffers_
.end())
394 return buffers_
.empty();
396 // Reset the next buffer index if we will be deleting the buffer that's next
398 if (HasNextBufferPosition()) {
399 DecodeTimestamp next_buffer_timestamp
= GetNextTimestamp();
400 if (next_buffer_timestamp
== kNoDecodeTimestamp() ||
401 next_buffer_timestamp
>= (*starting_point
)->GetDecodeTimestamp()) {
402 if (HasNextBuffer() && removed_buffers
) {
403 int starting_offset
= starting_point
- buffers_
.begin();
404 int next_buffer_offset
= next_buffer_index_
- starting_offset
;
405 DCHECK_GE(next_buffer_offset
, 0);
406 BufferQueue
saved(starting_point
+ next_buffer_offset
, buffers_
.end());
407 removed_buffers
->swap(saved
);
409 ResetNextBufferPosition();
413 // Remove keyframes from |starting_point| onward.
414 KeyframeMap::iterator starting_point_keyframe
=
415 keyframe_map_
.lower_bound((*starting_point
)->GetDecodeTimestamp());
416 keyframe_map_
.erase(starting_point_keyframe
, keyframe_map_
.end());
418 // Remove everything from |starting_point| onward.
419 FreeBufferRange(starting_point
, buffers_
.end());
420 return buffers_
.empty();
423 bool SourceBufferRange::GetNextBuffer(
424 scoped_refptr
<StreamParserBuffer
>* out_buffer
) {
425 if (!HasNextBuffer())
428 *out_buffer
= buffers_
[next_buffer_index_
];
429 next_buffer_index_
++;
433 bool SourceBufferRange::HasNextBuffer() const {
434 return next_buffer_index_
>= 0 &&
435 next_buffer_index_
< static_cast<int>(buffers_
.size());
438 int SourceBufferRange::GetNextConfigId() const {
439 DCHECK(HasNextBuffer());
440 // If the next buffer is an audio splice frame, the next effective config id
441 // comes from the first fade out preroll buffer.
442 return buffers_
[next_buffer_index_
]->GetSpliceBufferConfigId(0);
445 DecodeTimestamp
SourceBufferRange::GetNextTimestamp() const {
446 DCHECK(!buffers_
.empty());
447 DCHECK(HasNextBufferPosition());
449 if (next_buffer_index_
>= static_cast<int>(buffers_
.size())) {
450 return kNoDecodeTimestamp();
453 return buffers_
[next_buffer_index_
]->GetDecodeTimestamp();
456 bool SourceBufferRange::HasNextBufferPosition() const {
457 return next_buffer_index_
>= 0;
460 void SourceBufferRange::ResetNextBufferPosition() {
461 next_buffer_index_
= -1;
464 void SourceBufferRange::AppendRangeToEnd(const SourceBufferRange
& range
,
465 bool transfer_current_position
) {
466 DCHECK(CanAppendRangeToEnd(range
));
467 DCHECK(!buffers_
.empty());
469 if (transfer_current_position
&& range
.next_buffer_index_
>= 0)
470 next_buffer_index_
= range
.next_buffer_index_
+ buffers_
.size();
472 AppendBuffersToEnd(range
.buffers_
);
475 bool SourceBufferRange::CanAppendRangeToEnd(
476 const SourceBufferRange
& range
) const {
477 return CanAppendBuffersToEnd(range
.buffers_
);
480 bool SourceBufferRange::CanAppendBuffersToEnd(
481 const BufferQueue
& buffers
) const {
482 DCHECK(!buffers_
.empty());
483 return IsNextInSequence(buffers
.front()->GetDecodeTimestamp(),
484 buffers
.front()->is_key_frame());
487 bool SourceBufferRange::BelongsToRange(DecodeTimestamp timestamp
) const {
488 DCHECK(!buffers_
.empty());
490 return (IsNextInSequence(timestamp
, false) ||
491 (GetStartTimestamp() <= timestamp
&& timestamp
<= GetEndTimestamp()));
494 bool SourceBufferRange::CanSeekTo(DecodeTimestamp timestamp
) const {
495 DecodeTimestamp start_timestamp
=
496 std::max(DecodeTimestamp(), GetStartTimestamp() - GetFudgeRoom());
497 return !keyframe_map_
.empty() && start_timestamp
<= timestamp
&&
498 timestamp
< GetBufferedEndTimestamp();
501 bool SourceBufferRange::CompletelyOverlaps(
502 const SourceBufferRange
& range
) const {
503 return GetStartTimestamp() <= range
.GetStartTimestamp() &&
504 GetEndTimestamp() >= range
.GetEndTimestamp();
507 bool SourceBufferRange::EndOverlaps(const SourceBufferRange
& range
) const {
508 return range
.GetStartTimestamp() <= GetEndTimestamp() &&
509 GetEndTimestamp() < range
.GetEndTimestamp();
512 DecodeTimestamp
SourceBufferRange::GetStartTimestamp() const {
513 DCHECK(!buffers_
.empty());
514 DecodeTimestamp start_timestamp
= media_segment_start_time_
;
515 if (start_timestamp
== kNoDecodeTimestamp())
516 start_timestamp
= buffers_
.front()->GetDecodeTimestamp();
517 return start_timestamp
;
520 DecodeTimestamp
SourceBufferRange::GetEndTimestamp() const {
521 DCHECK(!buffers_
.empty());
522 return buffers_
.back()->GetDecodeTimestamp();
525 DecodeTimestamp
SourceBufferRange::GetBufferedEndTimestamp() const {
526 DCHECK(!buffers_
.empty());
527 base::TimeDelta duration
= buffers_
.back()->duration();
528 if (duration
== kNoTimestamp() || duration
== base::TimeDelta())
529 duration
= GetApproximateDuration();
530 return GetEndTimestamp() + duration
;
533 DecodeTimestamp
SourceBufferRange::NextKeyframeTimestamp(
534 DecodeTimestamp timestamp
) {
535 DCHECK(!keyframe_map_
.empty());
537 if (timestamp
< GetStartTimestamp() || timestamp
>= GetBufferedEndTimestamp())
538 return kNoDecodeTimestamp();
540 KeyframeMap::iterator itr
= GetFirstKeyframeAt(timestamp
, false);
541 if (itr
== keyframe_map_
.end())
542 return kNoDecodeTimestamp();
544 // If the timestamp is inside the gap between the start of the media
545 // segment and the first buffer, then just pretend there is a
546 // keyframe at the specified timestamp.
547 if (itr
== keyframe_map_
.begin() &&
548 timestamp
> media_segment_start_time_
&&
549 timestamp
< itr
->first
) {
556 DecodeTimestamp
SourceBufferRange::KeyframeBeforeTimestamp(
557 DecodeTimestamp timestamp
) {
558 DCHECK(!keyframe_map_
.empty());
560 if (timestamp
< GetStartTimestamp() || timestamp
>= GetBufferedEndTimestamp())
561 return kNoDecodeTimestamp();
563 return GetFirstKeyframeAtOrBefore(timestamp
)->first
;
566 bool SourceBufferRange::IsNextInSequence(
567 DecodeTimestamp timestamp
, bool is_key_frame
) const {
568 DecodeTimestamp end
= buffers_
.back()->GetDecodeTimestamp();
569 if (end
< timestamp
&&
570 (gap_policy_
== ALLOW_GAPS
||
571 timestamp
<= end
+ GetFudgeRoom())) {
575 return timestamp
== end
&& AllowSameTimestamp(
576 buffers_
.back()->is_key_frame(), is_key_frame
);
579 base::TimeDelta
SourceBufferRange::GetFudgeRoom() const {
580 // Because we do not know exactly when is the next timestamp, any buffer
581 // that starts within 2x the approximate duration of a buffer is considered
582 // within this range.
583 return 2 * GetApproximateDuration();
586 base::TimeDelta
SourceBufferRange::GetApproximateDuration() const {
587 base::TimeDelta max_interbuffer_distance
= interbuffer_distance_cb_
.Run();
588 DCHECK(max_interbuffer_distance
!= kNoTimestamp());
589 return max_interbuffer_distance
;
592 bool SourceBufferRange::GetBuffersInRange(DecodeTimestamp start
,
594 BufferQueue
* buffers
) {
595 // Find the nearest buffer with a decode timestamp <= start.
596 const DecodeTimestamp first_timestamp
= KeyframeBeforeTimestamp(start
);
597 if (first_timestamp
== kNoDecodeTimestamp())
600 // Find all buffers involved in the range.
601 const size_t previous_size
= buffers
->size();
602 for (BufferQueue::iterator it
= GetBufferItrAt(first_timestamp
, false);
603 it
!= buffers_
.end();
605 const scoped_refptr
<StreamParserBuffer
>& buffer
= *it
;
606 // Buffers without duration are not supported, so bail if we encounter any.
607 if (buffer
->duration() == kNoTimestamp() ||
608 buffer
->duration() <= base::TimeDelta()) {
611 if (buffer
->end_of_stream() ||
612 buffer
->timestamp() >= end
.ToPresentationTime()) {
616 if (buffer
->timestamp() + buffer
->duration() <= start
.ToPresentationTime())
618 buffers
->push_back(buffer
);
620 return previous_size
< buffers
->size();