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

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

Issue 2171133002: Implement opus seek preroll for MediaSourceExtensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 4 years 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
« no previous file with comments | « media/filters/source_buffer_range.h ('k') | media/filters/source_buffer_stream.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 2014 The Chromium Authors. All rights reserved. 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 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_range.h" 5 #include "media/filters/source_buffer_range.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "media/base/timestamp_constants.h" 9 #include "media/base/timestamp_constants.h"
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void SourceBufferRange::Seek(DecodeTimestamp timestamp) { 99 void SourceBufferRange::Seek(DecodeTimestamp timestamp) {
100 DCHECK(CanSeekTo(timestamp)); 100 DCHECK(CanSeekTo(timestamp));
101 DCHECK(!keyframe_map_.empty()); 101 DCHECK(!keyframe_map_.empty());
102 102
103 KeyframeMap::iterator result = GetFirstKeyframeAtOrBefore(timestamp); 103 KeyframeMap::iterator result = GetFirstKeyframeAtOrBefore(timestamp);
104 next_buffer_index_ = result->second - keyframe_map_index_base_; 104 next_buffer_index_ = result->second - keyframe_map_index_base_;
105 CHECK_LT(next_buffer_index_, static_cast<int>(buffers_.size())) 105 CHECK_LT(next_buffer_index_, static_cast<int>(buffers_.size()))
106 << next_buffer_index_ << ", size = " << buffers_.size(); 106 << next_buffer_index_ << ", size = " << buffers_.size();
107 } 107 }
108 108
109 int SourceBufferRange::GetConfigIdAtTime(DecodeTimestamp timestamp) {
110 DCHECK(CanSeekTo(timestamp));
111 DCHECK(!keyframe_map_.empty());
112
113 KeyframeMap::iterator result = GetFirstKeyframeAtOrBefore(timestamp);
114 CHECK(result != keyframe_map_.end());
115 size_t buffer_index = result->second - keyframe_map_index_base_;
116 CHECK_LT(buffer_index, buffers_.size()) << buffer_index
117 << ", size = " << buffers_.size();
118
119 return buffers_[buffer_index]->GetConfigId();
120 }
121
122 bool SourceBufferRange::SameConfigThruRange(DecodeTimestamp start,
123 DecodeTimestamp end) {
124 DCHECK(CanSeekTo(start));
125 DCHECK(CanSeekTo(end));
126 DCHECK(start <= end);
127 DCHECK(!keyframe_map_.empty());
128
129 if (start == end)
130 return true;
131
132 KeyframeMap::const_iterator result = GetFirstKeyframeAtOrBefore(start);
133 CHECK(result != keyframe_map_.end());
134 size_t buffer_index = result->second - keyframe_map_index_base_;
135 CHECK_LT(buffer_index, buffers_.size()) << buffer_index
136 << ", size = " << buffers_.size();
137
138 int start_config = buffers_[buffer_index]->GetConfigId();
139 buffer_index++;
140 while (buffer_index < buffers_.size() &&
141 buffers_[buffer_index]->GetDecodeTimestamp() <= end) {
142 if (buffers_[buffer_index]->GetConfigId() != start_config)
143 return false;
144 buffer_index++;
145 }
146
147 return true;
148 }
149
109 void SourceBufferRange::SeekAheadTo(DecodeTimestamp timestamp) { 150 void SourceBufferRange::SeekAheadTo(DecodeTimestamp timestamp) {
110 SeekAhead(timestamp, false); 151 SeekAhead(timestamp, false);
111 } 152 }
112 153
113 void SourceBufferRange::SeekAheadPast(DecodeTimestamp timestamp) { 154 void SourceBufferRange::SeekAheadPast(DecodeTimestamp timestamp) {
114 SeekAhead(timestamp, true); 155 SeekAhead(timestamp, true);
115 } 156 }
116 157
117 void SourceBufferRange::SeekAhead(DecodeTimestamp timestamp, 158 void SourceBufferRange::SeekAhead(DecodeTimestamp timestamp,
118 bool skip_given_timestamp) { 159 bool skip_given_timestamp) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 } 676 }
636 677
637 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime()) 678 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime())
638 continue; 679 continue;
639 buffers->push_back(buffer); 680 buffers->push_back(buffer);
640 } 681 }
641 return previous_size < buffers->size(); 682 return previous_size < buffers->size();
642 } 683 }
643 684
644 } // namespace media 685 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/source_buffer_range.h ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698