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/base/stream_parser_buffer.h" | 5 #include "media/base/stream_parser_buffer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/buffers.h" | 8 #include "media/base/buffers.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 void StreamParserBuffer::SetConfigId(int config_id) { | 100 void StreamParserBuffer::SetConfigId(int config_id) { |
101 config_id_ = config_id; | 101 config_id_ = config_id; |
102 if (preroll_buffer_) | 102 if (preroll_buffer_) |
103 preroll_buffer_->SetConfigId(config_id); | 103 preroll_buffer_->SetConfigId(config_id); |
104 } | 104 } |
105 | 105 |
106 void StreamParserBuffer::ConvertToSpliceBuffer( | 106 void StreamParserBuffer::ConvertToSpliceBuffer( |
107 const BufferQueue& pre_splice_buffers) { | 107 const BufferQueue& pre_splice_buffers) { |
108 DCHECK(splice_buffers_.empty()); | 108 DCHECK(splice_buffers_.empty()); |
109 DCHECK(duration() > base::TimeDelta()) | |
110 << "Only buffers with a valid duration can convert to a splice buffer." | |
111 << " pts " << timestamp().InSecondsF() | |
112 << " dts " << GetDecodeTimestamp().InSecondsF() | |
113 << " dur " << duration().InSecondsF(); | |
114 DCHECK(!end_of_stream()); | 109 DCHECK(!end_of_stream()); |
115 | 110 |
116 // Make a copy of this first, before making any changes. | 111 // Make a copy of this first, before making any changes. |
117 scoped_refptr<StreamParserBuffer> overlapping_buffer = CopyBuffer(*this); | 112 scoped_refptr<StreamParserBuffer> overlapping_buffer = CopyBuffer(*this); |
118 overlapping_buffer->set_splice_timestamp(kNoTimestamp()); | 113 overlapping_buffer->set_splice_timestamp(kNoTimestamp()); |
119 | 114 |
120 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = | 115 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = |
121 pre_splice_buffers.front(); | 116 pre_splice_buffers.front(); |
122 | 117 |
123 // Ensure the given buffers are actually before the splice point. | 118 // Ensure the given buffers are actually before the splice point. |
(...skipping 13 matching lines...) Expand all Loading... |
137 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); | 132 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); |
138 SetConfigId(first_splice_buffer->GetConfigId()); | 133 SetConfigId(first_splice_buffer->GetConfigId()); |
139 set_timestamp(first_splice_buffer->timestamp()); | 134 set_timestamp(first_splice_buffer->timestamp()); |
140 is_keyframe_ = first_splice_buffer->IsKeyframe(); | 135 is_keyframe_ = first_splice_buffer->IsKeyframe(); |
141 type_ = first_splice_buffer->type(); | 136 type_ = first_splice_buffer->type(); |
142 track_id_ = first_splice_buffer->track_id(); | 137 track_id_ = first_splice_buffer->track_id(); |
143 set_splice_timestamp(overlapping_buffer->timestamp()); | 138 set_splice_timestamp(overlapping_buffer->timestamp()); |
144 | 139 |
145 // The splice duration is the duration of all buffers before the splice plus | 140 // The splice duration is the duration of all buffers before the splice plus |
146 // the highest ending timestamp after the splice point. | 141 // the highest ending timestamp after the splice point. |
147 DCHECK(overlapping_buffer->duration() > base::TimeDelta()); | |
148 DCHECK(pre_splice_buffers.back()->duration() > base::TimeDelta()); | |
149 set_duration( | 142 set_duration( |
150 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), | 143 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), |
151 pre_splice_buffers.back()->timestamp() + | 144 pre_splice_buffers.back()->timestamp() + |
152 pre_splice_buffers.back()->duration()) - | 145 pre_splice_buffers.back()->duration()) - |
153 first_splice_buffer->timestamp()); | 146 first_splice_buffer->timestamp()); |
154 | 147 |
155 // Copy all pre splice buffers into our wrapper buffer. | 148 // Copy all pre splice buffers into our wrapper buffer. |
156 for (BufferQueue::const_iterator it = pre_splice_buffers.begin(); | 149 for (BufferQueue::const_iterator it = pre_splice_buffers.begin(); |
157 it != pre_splice_buffers.end(); | 150 it != pre_splice_buffers.end(); |
158 ++it) { | 151 ++it) { |
(...skipping 30 matching lines...) Expand all Loading... |
189 std::make_pair(kInfiniteDuration(), base::TimeDelta())); | 182 std::make_pair(kInfiniteDuration(), base::TimeDelta())); |
190 } | 183 } |
191 | 184 |
192 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { | 185 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { |
193 DecoderBuffer::set_timestamp(timestamp); | 186 DecoderBuffer::set_timestamp(timestamp); |
194 if (preroll_buffer_) | 187 if (preroll_buffer_) |
195 preroll_buffer_->set_timestamp(timestamp); | 188 preroll_buffer_->set_timestamp(timestamp); |
196 } | 189 } |
197 | 190 |
198 } // namespace media | 191 } // namespace media |
OLD | NEW |