Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: media/filters/source_buffer_stream.cc

Issue 10703125: Fix SplitRange() logic in SourceBufferRange to transfer next buffer position appropriately (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 BufferQueue::iterator starting_point = buffers_.begin() + keyframe_index; 818 BufferQueue::iterator starting_point = buffers_.begin() + keyframe_index;
819 BufferQueue removed_buffers(starting_point, buffers_.end()); 819 BufferQueue removed_buffers(starting_point, buffers_.end());
820 keyframe_map_.erase(new_beginning_keyframe, keyframe_map_.end()); 820 keyframe_map_.erase(new_beginning_keyframe, keyframe_map_.end());
821 buffers_.erase(starting_point, buffers_.end()); 821 buffers_.erase(starting_point, buffers_.end());
822 822
823 // Create a new range with |removed_buffers|. 823 // Create a new range with |removed_buffers|.
824 SourceBufferRange* split_range = 824 SourceBufferRange* split_range =
825 new SourceBufferRange( 825 new SourceBufferRange(
826 removed_buffers, kNoTimestamp(), interbuffer_distance_cb_); 826 removed_buffers, kNoTimestamp(), interbuffer_distance_cb_);
827 827
828 // If |next_buffer_index_| points to a buffer in |split_range|, update the 828 // If the next buffer position is now in |split_range|, update the state of
829 // |next_buffer_index_| of this range and |split_range| accordingly. 829 // this range and |split_range| accordingly.
830 if (next_buffer_index_ >= static_cast<int>(buffers_.size())) { 830 if (next_buffer_index_ >= static_cast<int>(buffers_.size())) {
831 DCHECK(!waiting_for_keyframe_);
831 split_range->next_buffer_index_ = next_buffer_index_ - keyframe_index; 832 split_range->next_buffer_index_ = next_buffer_index_ - keyframe_index;
832 next_buffer_index_ = -1; 833 ResetNextBufferPosition();
834 } else if (waiting_for_keyframe_) {
835 split_range->waiting_for_keyframe_ = true;
836 split_range->next_keyframe_timestamp_ = next_keyframe_timestamp_;
837 ResetNextBufferPosition();
833 } 838 }
839
834 return split_range; 840 return split_range;
835 } 841 }
836 842
837 SourceBufferRange::KeyframeMap::iterator 843 SourceBufferRange::KeyframeMap::iterator
838 SourceBufferRange::GetFirstKeyframeAt(base::TimeDelta timestamp, 844 SourceBufferRange::GetFirstKeyframeAt(base::TimeDelta timestamp,
839 bool skip_given_timestamp) { 845 bool skip_given_timestamp) {
840 KeyframeMap::iterator result = keyframe_map_.lower_bound(timestamp); 846 KeyframeMap::iterator result = keyframe_map_.lower_bound(timestamp);
841 // lower_bound() returns the first element >= |timestamp|, so if we don't want 847 // lower_bound() returns the first element >= |timestamp|, so if we don't want
842 // to include keyframes == |timestamp|, we have to increment the iterator 848 // to include keyframes == |timestamp|, we have to increment the iterator
843 // accordingly. 849 // accordingly.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 base::TimeDelta next_buffer_timestamp = GetNextTimestamp(); 884 base::TimeDelta next_buffer_timestamp = GetNextTimestamp();
879 if (next_buffer_timestamp == kNoTimestamp() || 885 if (next_buffer_timestamp == kNoTimestamp() ||
880 next_buffer_timestamp >= (*starting_point)->GetDecodeTimestamp()) { 886 next_buffer_timestamp >= (*starting_point)->GetDecodeTimestamp()) {
881 if (HasNextBuffer()) { 887 if (HasNextBuffer()) {
882 int starting_offset = starting_point - buffers_.begin(); 888 int starting_offset = starting_point - buffers_.begin();
883 int next_buffer_offset = next_buffer_index_ - starting_offset; 889 int next_buffer_offset = next_buffer_index_ - starting_offset;
884 DCHECK_GE(next_buffer_offset, 0); 890 DCHECK_GE(next_buffer_offset, 0);
885 BufferQueue saved(starting_point + next_buffer_offset, buffers_.end()); 891 BufferQueue saved(starting_point + next_buffer_offset, buffers_.end());
886 removed_buffers->swap(saved); 892 removed_buffers->swap(saved);
887 } 893 }
888 next_buffer_index_ = -1; 894 ResetNextBufferPosition();
889 removed_next_buffer = true; 895 removed_next_buffer = true;
890 } 896 }
891 } 897 }
892 898
893 // Remove keyframes from |starting_point| onward. 899 // Remove keyframes from |starting_point| onward.
894 KeyframeMap::iterator starting_point_keyframe = 900 KeyframeMap::iterator starting_point_keyframe =
895 keyframe_map_.lower_bound((*starting_point)->GetDecodeTimestamp()); 901 keyframe_map_.lower_bound((*starting_point)->GetDecodeTimestamp());
896 keyframe_map_.erase(starting_point_keyframe, keyframe_map_.end()); 902 keyframe_map_.erase(starting_point_keyframe, keyframe_map_.end());
897 903
898 // Remove everything from |starting_point| onward. 904 // Remove everything from |starting_point| onward.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 return 2 * GetApproximateDuration(); 1028 return 2 * GetApproximateDuration();
1023 } 1029 }
1024 1030
1025 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { 1031 base::TimeDelta SourceBufferRange::GetApproximateDuration() const {
1026 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run(); 1032 base::TimeDelta max_interbuffer_distance = interbuffer_distance_cb_.Run();
1027 DCHECK(max_interbuffer_distance != kNoTimestamp()); 1033 DCHECK(max_interbuffer_distance != kNoTimestamp());
1028 return max_interbuffer_distance; 1034 return max_interbuffer_distance;
1029 } 1035 }
1030 1036
1031 } // namespace media 1037 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698