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/bind.h" | 10 #include "base/bind.h" |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
815 BufferQueue::iterator starting_point = buffers_.begin() + keyframe_index; | 815 BufferQueue::iterator starting_point = buffers_.begin() + keyframe_index; |
816 BufferQueue removed_buffers(starting_point, buffers_.end()); | 816 BufferQueue removed_buffers(starting_point, buffers_.end()); |
817 keyframe_map_.erase(new_beginning_keyframe, keyframe_map_.end()); | 817 keyframe_map_.erase(new_beginning_keyframe, keyframe_map_.end()); |
818 buffers_.erase(starting_point, buffers_.end()); | 818 buffers_.erase(starting_point, buffers_.end()); |
819 | 819 |
820 // Create a new range with |removed_buffers|. | 820 // Create a new range with |removed_buffers|. |
821 SourceBufferRange* split_range = | 821 SourceBufferRange* split_range = |
822 new SourceBufferRange( | 822 new SourceBufferRange( |
823 removed_buffers, kNoTimestamp(), interbuffer_distance_cb_); | 823 removed_buffers, kNoTimestamp(), interbuffer_distance_cb_); |
824 | 824 |
825 // If |next_buffer_index_| points to a buffer in |split_range|, update the | 825 // If the next buffer position is now in |split_range|, update the state of |
826 // |next_buffer_index_| of this range and |split_range| accordingly. | 826 // this range and |split_range| accordingly. |
827 if (next_buffer_index_ >= static_cast<int>(buffers_.size())) { | 827 if (next_buffer_index_ >= static_cast<int>(buffers_.size())) { |
828 split_range->next_buffer_index_ = next_buffer_index_ - keyframe_index; | 828 split_range->next_buffer_index_ = next_buffer_index_ - keyframe_index; |
acolwell GONE FROM CHROMIUM
2012/07/10 20:19:32
DCHECK(!waiting_for_keyframe_) ?
vrk (LEFT CHROMIUM)
2012/07/10 20:34:54
Done.
| |
829 next_buffer_index_ = -1; | 829 ResetNextBufferPosition(); |
830 } else if (waiting_for_keyframe_) { | |
831 split_range->waiting_for_keyframe_ = true; | |
832 split_range->next_keyframe_timestamp_ = next_keyframe_timestamp_; | |
833 ResetNextBufferPosition(); | |
830 } | 834 } |
835 | |
831 return split_range; | 836 return split_range; |
832 } | 837 } |
833 | 838 |
834 SourceBufferRange::KeyframeMap::iterator | 839 SourceBufferRange::KeyframeMap::iterator |
835 SourceBufferRange::GetFirstKeyframeAt(base::TimeDelta timestamp, | 840 SourceBufferRange::GetFirstKeyframeAt(base::TimeDelta timestamp, |
836 bool skip_given_timestamp) { | 841 bool skip_given_timestamp) { |
837 KeyframeMap::iterator result = keyframe_map_.lower_bound(timestamp); | 842 KeyframeMap::iterator result = keyframe_map_.lower_bound(timestamp); |
838 // lower_bound() returns the first element >= |timestamp|, so if we don't want | 843 // lower_bound() returns the first element >= |timestamp|, so if we don't want |
839 // to include keyframes == |timestamp|, we have to increment the iterator | 844 // to include keyframes == |timestamp|, we have to increment the iterator |
840 // accordingly. | 845 // accordingly. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 base::TimeDelta next_buffer_timestamp = GetNextTimestamp(); | 880 base::TimeDelta next_buffer_timestamp = GetNextTimestamp(); |
876 if (next_buffer_timestamp == kNoTimestamp() || | 881 if (next_buffer_timestamp == kNoTimestamp() || |
877 next_buffer_timestamp >= (*starting_point)->GetDecodeTimestamp()) { | 882 next_buffer_timestamp >= (*starting_point)->GetDecodeTimestamp()) { |
878 if (HasNextBuffer()) { | 883 if (HasNextBuffer()) { |
879 int starting_offset = starting_point - buffers_.begin(); | 884 int starting_offset = starting_point - buffers_.begin(); |
880 int next_buffer_offset = next_buffer_index_ - starting_offset; | 885 int next_buffer_offset = next_buffer_index_ - starting_offset; |
881 DCHECK_GE(next_buffer_offset, 0); | 886 DCHECK_GE(next_buffer_offset, 0); |
882 BufferQueue saved(starting_point + next_buffer_offset, buffers_.end()); | 887 BufferQueue saved(starting_point + next_buffer_offset, buffers_.end()); |
883 removed_buffers->swap(saved); | 888 removed_buffers->swap(saved); |
884 } | 889 } |
885 next_buffer_index_ = -1; | 890 ResetNextBufferPosition(); |
886 removed_next_buffer = true; | 891 removed_next_buffer = true; |
887 } | 892 } |
888 } | 893 } |
889 | 894 |
890 // Remove keyframes from |starting_point| onward. | 895 // Remove keyframes from |starting_point| onward. |
891 KeyframeMap::iterator starting_point_keyframe = | 896 KeyframeMap::iterator starting_point_keyframe = |
892 keyframe_map_.lower_bound((*starting_point)->GetDecodeTimestamp()); | 897 keyframe_map_.lower_bound((*starting_point)->GetDecodeTimestamp()); |
893 keyframe_map_.erase(starting_point_keyframe, keyframe_map_.end()); | 898 keyframe_map_.erase(starting_point_keyframe, keyframe_map_.end()); |
894 | 899 |
895 // Remove everything from |starting_point| onward. | 900 // Remove everything from |starting_point| onward. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1019 return 2 * GetApproximateDuration(); | 1024 return 2 * GetApproximateDuration(); |
1020 } | 1025 } |
1021 | 1026 |
1022 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { | 1027 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { |
1023 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); | 1028 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); |
1024 DCHECK(max_interbuffer_distance != kNoTimestamp()); | 1029 DCHECK(max_interbuffer_distance != kNoTimestamp()); |
1025 return max_interbuffer_distance; | 1030 return max_interbuffer_distance; |
1026 } | 1031 } |
1027 | 1032 |
1028 } // namespace media | 1033 } // namespace media |
OLD | NEW |