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