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

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: Created 4 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
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 size_t buffer_index = result->second - keyframe_map_index_base_;
115 CHECK_LT(buffer_index, buffers_.size()) << buffer_index
116 << ", size = " << buffers_.size();
117
118 return buffers_[buffer_index]->GetSpliceBufferConfigId(0);
119 }
120
121 bool SourceBufferRange::SameConfigThruRange(DecodeTimestamp start,
122 DecodeTimestamp end) {
123 DCHECK(CanSeekTo(start));
124 DCHECK(CanSeekTo(end));
125 DCHECK(start <= end);
126 DCHECK(!keyframe_map_.empty());
127
128 if (start == end)
129 return true;
wolenetz 2016/07/25 21:49:02 What if the buffer at this time contains splice bu
chcunningham 2016/12/01 17:07:16 Splicing is gone. Now just checking the config ID
wolenetz 2016/12/02 00:18:49 Acknowledged.
130
131 KeyframeMap::const_iterator result = GetFirstKeyframeAtOrBefore(start);
132 size_t buffer_index = result->second - keyframe_map_index_base_;
133 CHECK_LT(buffer_index, buffers_.size()) << buffer_index
134 << ", size = " << buffers_.size();
135
136 int start_config = buffers_[buffer_index]->GetSpliceBufferConfigId(0);
137 buffer_index++;
138 while (buffer_index < buffers_.size() &&
139 buffers_[buffer_index]->GetDecodeTimestamp() <= end) {
140 if (buffers_[buffer_index]->GetSpliceBufferConfigId(0) != start_config)
wolenetz 2016/07/25 21:49:02 Ditto: if there is a splice buffer, it/they could
chcunningham 2016/12/01 17:07:16 Ditto.
wolenetz 2016/12/02 00:18:49 Acknowledged.
141 return false;
142 buffer_index++;
143 }
144
145 return true;
146 }
147
109 void SourceBufferRange::SeekAheadTo(DecodeTimestamp timestamp) { 148 void SourceBufferRange::SeekAheadTo(DecodeTimestamp timestamp) {
110 SeekAhead(timestamp, false); 149 SeekAhead(timestamp, false);
111 } 150 }
112 151
113 void SourceBufferRange::SeekAheadPast(DecodeTimestamp timestamp) { 152 void SourceBufferRange::SeekAheadPast(DecodeTimestamp timestamp) {
114 SeekAhead(timestamp, true); 153 SeekAhead(timestamp, true);
115 } 154 }
116 155
117 void SourceBufferRange::SeekAhead(DecodeTimestamp timestamp, 156 void SourceBufferRange::SeekAhead(DecodeTimestamp timestamp,
118 bool skip_given_timestamp) { 157 bool skip_given_timestamp) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 } 674 }
636 675
637 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime()) 676 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime())
638 continue; 677 continue;
639 buffers->push_back(buffer); 678 buffers->push_back(buffer);
640 } 679 }
641 return previous_size < buffers->size(); 680 return previous_size < buffers->size();
642 } 681 }
643 682
644 } // namespace media 683 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698