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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 : DecoderBuffer(data, data_size, side_data, side_data_size), | 93 : DecoderBuffer(data, data_size, side_data, side_data_size), |
94 decode_timestamp_(kNoDecodeTimestamp()), | 94 decode_timestamp_(kNoDecodeTimestamp()), |
95 config_id_(kInvalidConfigId), | 95 config_id_(kInvalidConfigId), |
96 type_(type), | 96 type_(type), |
97 track_id_(track_id), | 97 track_id_(track_id), |
98 is_duration_estimated_(false) { | 98 is_duration_estimated_(false) { |
99 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and | 99 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and |
100 // duration to force clients to set them? Today they end up being zero which | 100 // duration to force clients to set them? Today they end up being zero which |
101 // is both a common and valid value and could lead to bugs. | 101 // is both a common and valid value and could lead to bugs. |
102 if (data) { | 102 if (data) { |
103 set_duration(kNoTimestamp()); | 103 set_duration(kNoTimestamp); |
104 } | 104 } |
105 | 105 |
106 if (is_key_frame) | 106 if (is_key_frame) |
107 set_is_key_frame(true); | 107 set_is_key_frame(true); |
108 } | 108 } |
109 | 109 |
110 StreamParserBuffer::~StreamParserBuffer() {} | 110 StreamParserBuffer::~StreamParserBuffer() {} |
111 | 111 |
112 int StreamParserBuffer::GetConfigId() const { | 112 int StreamParserBuffer::GetConfigId() const { |
113 return config_id_; | 113 return config_id_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 << " dur " << duration().InSecondsF(); | 153 << " dur " << duration().InSecondsF(); |
154 DCHECK(!end_of_stream()); | 154 DCHECK(!end_of_stream()); |
155 | 155 |
156 // Splicing requires non-estimated sample accurate durations to be confident | 156 // Splicing requires non-estimated sample accurate durations to be confident |
157 // things will sound smooth. Also, we cannot be certain whether estimated | 157 // things will sound smooth. Also, we cannot be certain whether estimated |
158 // overlap is really a splice scenario, or just over estimation. | 158 // overlap is really a splice scenario, or just over estimation. |
159 DCHECK(!is_duration_estimated_); | 159 DCHECK(!is_duration_estimated_); |
160 | 160 |
161 // Make a copy of this first, before making any changes. | 161 // Make a copy of this first, before making any changes. |
162 scoped_refptr<StreamParserBuffer> overlapping_buffer = CopyBuffer(*this); | 162 scoped_refptr<StreamParserBuffer> overlapping_buffer = CopyBuffer(*this); |
163 overlapping_buffer->set_splice_timestamp(kNoTimestamp()); | 163 overlapping_buffer->set_splice_timestamp(kNoTimestamp); |
164 | 164 |
165 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = | 165 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = |
166 pre_splice_buffers.front(); | 166 pre_splice_buffers.front(); |
167 | 167 |
168 // Ensure the given buffers are actually before the splice point. | 168 // Ensure the given buffers are actually before the splice point. |
169 DCHECK(first_splice_buffer->timestamp() <= overlapping_buffer->timestamp()); | 169 DCHECK(first_splice_buffer->timestamp() <= overlapping_buffer->timestamp()); |
170 | 170 |
171 // TODO(dalecurtis): We should also clear |data| and |side_data|, but since | 171 // TODO(dalecurtis): We should also clear |data| and |side_data|, but since |
172 // that implies EOS care must be taken to ensure there are no clients relying | 172 // that implies EOS care must be taken to ensure there are no clients relying |
173 // on that behavior. | 173 // on that behavior. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 splice_buffers_.push_back(overlapping_buffer); | 213 splice_buffers_.push_back(overlapping_buffer); |
214 } | 214 } |
215 | 215 |
216 void StreamParserBuffer::SetPrerollBuffer( | 216 void StreamParserBuffer::SetPrerollBuffer( |
217 const scoped_refptr<StreamParserBuffer>& preroll_buffer) { | 217 const scoped_refptr<StreamParserBuffer>& preroll_buffer) { |
218 DCHECK(!preroll_buffer_.get()); | 218 DCHECK(!preroll_buffer_.get()); |
219 DCHECK(!end_of_stream()); | 219 DCHECK(!end_of_stream()); |
220 DCHECK(!preroll_buffer->end_of_stream()); | 220 DCHECK(!preroll_buffer->end_of_stream()); |
221 DCHECK(!preroll_buffer->preroll_buffer_.get()); | 221 DCHECK(!preroll_buffer->preroll_buffer_.get()); |
222 DCHECK(preroll_buffer->splice_timestamp() == kNoTimestamp()); | 222 DCHECK(preroll_buffer->splice_timestamp() == kNoTimestamp); |
223 DCHECK(preroll_buffer->splice_buffers().empty()); | 223 DCHECK(preroll_buffer->splice_buffers().empty()); |
224 DCHECK(preroll_buffer->timestamp() <= timestamp()); | 224 DCHECK(preroll_buffer->timestamp() <= timestamp()); |
225 DCHECK(preroll_buffer->discard_padding() == DecoderBuffer::DiscardPadding()); | 225 DCHECK(preroll_buffer->discard_padding() == DecoderBuffer::DiscardPadding()); |
226 DCHECK_EQ(preroll_buffer->type(), type()); | 226 DCHECK_EQ(preroll_buffer->type(), type()); |
227 DCHECK_EQ(preroll_buffer->track_id(), track_id()); | 227 DCHECK_EQ(preroll_buffer->track_id(), track_id()); |
228 | 228 |
229 preroll_buffer_ = preroll_buffer; | 229 preroll_buffer_ = preroll_buffer; |
230 preroll_buffer_->set_timestamp(timestamp()); | 230 preroll_buffer_->set_timestamp(timestamp()); |
231 preroll_buffer_->SetDecodeTimestamp(GetDecodeTimestamp()); | 231 preroll_buffer_->SetDecodeTimestamp(GetDecodeTimestamp()); |
232 | 232 |
233 // Mark the entire buffer for discard. | 233 // Mark the entire buffer for discard. |
234 preroll_buffer_->set_discard_padding( | 234 preroll_buffer_->set_discard_padding( |
235 std::make_pair(kInfiniteDuration(), base::TimeDelta())); | 235 std::make_pair(kInfiniteDuration, base::TimeDelta())); |
236 } | 236 } |
237 | 237 |
238 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { | 238 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { |
239 DecoderBuffer::set_timestamp(timestamp); | 239 DecoderBuffer::set_timestamp(timestamp); |
240 if (preroll_buffer_.get()) | 240 if (preroll_buffer_.get()) |
241 preroll_buffer_->set_timestamp(timestamp); | 241 preroll_buffer_->set_timestamp(timestamp); |
242 } | 242 } |
243 | 243 |
244 } // namespace media | 244 } // namespace media |
OLD | NEW |