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 #include "media/filters/source_buffer_stream.h" | 5 #include "media/filters/source_buffer_stream.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // buffered timespan of |range|. | 105 // buffered timespan of |range|. |
106 bool CompletelyOverlaps(const SourceBufferRange& range) const; | 106 bool CompletelyOverlaps(const SourceBufferRange& range) const; |
107 | 107 |
108 // Returns true if the end of this range contains buffers that overlaps with | 108 // Returns true if the end of this range contains buffers that overlaps with |
109 // the beginning of |range|. | 109 // the beginning of |range|. |
110 bool EndOverlaps(const SourceBufferRange& range) const; | 110 bool EndOverlaps(const SourceBufferRange& range) const; |
111 | 111 |
112 private: | 112 private: |
113 // Helper method to delete buffers in |buffers_| starting from | 113 // Helper method to delete buffers in |buffers_| starting from |
114 // |starting_point|, an iterator in |buffers_|. | 114 // |starting_point|, an iterator in |buffers_|. |
115 void DeleteAfter(BufferQueue::iterator starting_point, | 115 void DeleteAfter(const BufferQueue::iterator& starting_point, |
116 BufferQueue* deleted_buffers, | 116 BufferQueue* deleted_buffers, |
117 BufferQueue::iterator* next_buffer); | 117 BufferQueue::iterator* next_buffer); |
118 | 118 |
119 // Returns the start timestamp of the range. | 119 // Returns the start timestamp of the range. |
120 base::TimeDelta GetStartTimestamp() const; | 120 base::TimeDelta GetStartTimestamp() const; |
121 | 121 |
122 // An ordered list of buffers in this range. | 122 // An ordered list of buffers in this range. |
123 BufferQueue buffers_; | 123 BufferQueue buffers_; |
124 | 124 |
125 // Maps keyframe timestamps to its index position in |buffers_|. | 125 // Maps keyframe timestamps to its index position in |buffers_|. |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 BufferQueue::iterator* next_buffer) { | 601 BufferQueue::iterator* next_buffer) { |
602 // Find the place in |buffers_| where we will begin deleting data. | 602 // Find the place in |buffers_| where we will begin deleting data. |
603 BufferQueue::iterator starting_point = | 603 BufferQueue::iterator starting_point = |
604 std::lower_bound(buffers_.begin(), buffers_.end(), | 604 std::lower_bound(buffers_.begin(), buffers_.end(), |
605 buffer, | 605 buffer, |
606 BufferComparator); | 606 BufferComparator); |
607 DeleteAfter(starting_point, removed_buffers, next_buffer); | 607 DeleteAfter(starting_point, removed_buffers, next_buffer); |
608 } | 608 } |
609 | 609 |
610 void SourceBufferRange::DeleteAfter( | 610 void SourceBufferRange::DeleteAfter( |
611 BufferQueue::iterator starting_point, | 611 const BufferQueue::iterator& starting_point, |
612 BufferQueue* removed_buffers, | 612 BufferQueue* removed_buffers, |
613 BufferQueue::iterator* next_buffer) { | 613 BufferQueue::iterator* next_buffer) { |
614 // Return if we're not deleting anything. | 614 // Return if we're not deleting anything. |
615 if (starting_point == buffers_.end()) | 615 if (starting_point == buffers_.end()) |
616 return; | 616 return; |
617 | 617 |
618 // Find the first keyframe after |starting_point|. | 618 // Find the first keyframe after |starting_point|. |
619 KeyframeMap::iterator starting_point_keyframe = | 619 KeyframeMap::iterator starting_point_keyframe = |
620 keyframe_map_.lower_bound((*starting_point)->GetTimestamp()); | 620 keyframe_map_.lower_bound((*starting_point)->GetTimestamp()); |
621 | 621 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 DCHECK(!buffers_.empty()); | 737 DCHECK(!buffers_.empty()); |
738 return buffers_.front()->GetTimestamp(); | 738 return buffers_.front()->GetTimestamp(); |
739 } | 739 } |
740 | 740 |
741 base::TimeDelta SourceBufferRange::GetEndTimestamp() const { | 741 base::TimeDelta SourceBufferRange::GetEndTimestamp() const { |
742 DCHECK(!buffers_.empty()); | 742 DCHECK(!buffers_.empty()); |
743 return buffers_.back()->GetEndTimestamp(); | 743 return buffers_.back()->GetEndTimestamp(); |
744 } | 744 } |
745 | 745 |
746 } // namespace media | 746 } // namespace media |
OLD | NEW |