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(); | |
wolenetz
2014/07/09 22:42:16
nit: add dur to logging
acolwell GONE FROM CHROMIUM
2014/07/15 18:49:26
Done.
| |
109 DCHECK(!end_of_stream()); | 113 DCHECK(!end_of_stream()); |
110 | 114 |
111 // Make a copy of this first, before making any changes. | 115 // Make a copy of this first, before making any changes. |
112 scoped_refptr<StreamParserBuffer> overlapping_buffer = CopyBuffer(*this); | 116 scoped_refptr<StreamParserBuffer> overlapping_buffer = CopyBuffer(*this); |
113 overlapping_buffer->set_splice_timestamp(kNoTimestamp()); | 117 overlapping_buffer->set_splice_timestamp(kNoTimestamp()); |
114 | 118 |
115 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = | 119 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = |
116 pre_splice_buffers.front(); | 120 pre_splice_buffers.front(); |
117 | 121 |
118 // Ensure the given buffers are actually before the splice point. | 122 // Ensure the given buffers are actually before the splice point. |
(...skipping 13 matching lines...) Expand all Loading... | |
132 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); | 136 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); |
133 SetConfigId(first_splice_buffer->GetConfigId()); | 137 SetConfigId(first_splice_buffer->GetConfigId()); |
134 set_timestamp(first_splice_buffer->timestamp()); | 138 set_timestamp(first_splice_buffer->timestamp()); |
135 is_keyframe_ = first_splice_buffer->IsKeyframe(); | 139 is_keyframe_ = first_splice_buffer->IsKeyframe(); |
136 type_ = first_splice_buffer->type(); | 140 type_ = first_splice_buffer->type(); |
137 track_id_ = first_splice_buffer->track_id(); | 141 track_id_ = first_splice_buffer->track_id(); |
138 set_splice_timestamp(overlapping_buffer->timestamp()); | 142 set_splice_timestamp(overlapping_buffer->timestamp()); |
139 | 143 |
140 // The splice duration is the duration of all buffers before the splice plus | 144 // The splice duration is the duration of all buffers before the splice plus |
141 // the highest ending timestamp after the splice point. | 145 // the highest ending timestamp after the splice point. |
146 DCHECK(overlapping_buffer->duration() > base::TimeDelta()); | |
147 DCHECK(pre_splice_buffers.back()->duration() > base::TimeDelta()); | |
142 set_duration( | 148 set_duration( |
143 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), | 149 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), |
144 pre_splice_buffers.back()->timestamp() + | 150 pre_splice_buffers.back()->timestamp() + |
145 pre_splice_buffers.back()->duration()) - | 151 pre_splice_buffers.back()->duration()) - |
146 first_splice_buffer->timestamp()); | 152 first_splice_buffer->timestamp()); |
147 | 153 |
148 // Copy all pre splice buffers into our wrapper buffer. | 154 // Copy all pre splice buffers into our wrapper buffer. |
149 for (BufferQueue::const_iterator it = pre_splice_buffers.begin(); | 155 for (BufferQueue::const_iterator it = pre_splice_buffers.begin(); |
150 it != pre_splice_buffers.end(); | 156 it != pre_splice_buffers.end(); |
151 ++it) { | 157 ++it) { |
(...skipping 30 matching lines...) Expand all Loading... | |
182 std::make_pair(kInfiniteDuration(), base::TimeDelta())); | 188 std::make_pair(kInfiniteDuration(), base::TimeDelta())); |
183 } | 189 } |
184 | 190 |
185 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { | 191 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { |
186 DecoderBuffer::set_timestamp(timestamp); | 192 DecoderBuffer::set_timestamp(timestamp); |
187 if (preroll_buffer_) | 193 if (preroll_buffer_) |
188 preroll_buffer_->set_timestamp(timestamp); | 194 preroll_buffer_->set_timestamp(timestamp); |
189 } | 195 } |
190 | 196 |
191 } // namespace media | 197 } // namespace media |
OLD | NEW |