Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = | 111 const scoped_refptr<StreamParserBuffer>& first_splice_buffer = |
| 112 pre_splice_buffers.front(); | 112 pre_splice_buffers.front(); |
| 113 | 113 |
| 114 // Ensure the given buffers are actually before the splice point. | 114 // Ensure the given buffers are actually before the splice point. |
| 115 DCHECK(first_splice_buffer->timestamp() <= overlapping_buffer->timestamp()); | 115 DCHECK(first_splice_buffer->timestamp() <= overlapping_buffer->timestamp()); |
| 116 | 116 |
| 117 // TODO(dalecurtis): We should also clear |data| and |side_data|, but since | 117 // TODO(dalecurtis): We should also clear |data| and |side_data|, but since |
| 118 // that implies EOS care must be taken to ensure there are no clients relying | 118 // that implies EOS care must be taken to ensure there are no clients relying |
| 119 // on that behavior. | 119 // on that behavior. |
| 120 | 120 |
| 121 // Move over any preroll from this buffer. | |
| 122 if (preroll_buffer_) { | |
| 123 DCHECK(!overlapping_buffer->preroll_buffer_); | |
| 124 overlapping_buffer->preroll_buffer_.swap(preroll_buffer_); | |
| 125 } | |
| 126 | |
| 121 // Rewrite |this| buffer as a splice buffer. | 127 // Rewrite |this| buffer as a splice buffer. |
| 122 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); | 128 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); |
| 123 SetConfigId(first_splice_buffer->GetConfigId()); | 129 SetConfigId(first_splice_buffer->GetConfigId()); |
| 124 set_timestamp(first_splice_buffer->timestamp()); | 130 set_timestamp(first_splice_buffer->timestamp()); |
| 125 is_keyframe_ = first_splice_buffer->IsKeyframe(); | 131 is_keyframe_ = first_splice_buffer->IsKeyframe(); |
| 126 type_ = first_splice_buffer->type(); | 132 type_ = first_splice_buffer->type(); |
| 127 track_id_ = first_splice_buffer->track_id(); | 133 track_id_ = first_splice_buffer->track_id(); |
| 128 set_splice_timestamp(overlapping_buffer->timestamp()); | 134 set_splice_timestamp(overlapping_buffer->timestamp()); |
| 129 | 135 |
| 130 // The splice duration is the duration of all buffers before the splice plus | 136 // The splice duration is the duration of all buffers before the splice plus |
| 131 // the highest ending timestamp after the splice point. | 137 // the highest ending timestamp after the splice point. |
| 132 set_duration( | 138 set_duration( |
| 133 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), | 139 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), |
| 134 pre_splice_buffers.back()->timestamp() + | 140 pre_splice_buffers.back()->timestamp() + |
| 135 pre_splice_buffers.back()->duration()) - | 141 pre_splice_buffers.back()->duration()) - |
| 136 first_splice_buffer->timestamp()); | 142 first_splice_buffer->timestamp()); |
| 137 | 143 |
| 138 // Copy all pre splice buffers into our wrapper buffer. | 144 // Copy all pre splice buffers into our wrapper buffer. |
| 139 for (BufferQueue::const_iterator it = pre_splice_buffers.begin(); | 145 for (BufferQueue::const_iterator it = pre_splice_buffers.begin(); |
| 140 it != pre_splice_buffers.end(); | 146 it != pre_splice_buffers.end(); |
| 141 ++it) { | 147 ++it) { |
| 142 const scoped_refptr<StreamParserBuffer>& buffer = *it; | 148 const scoped_refptr<StreamParserBuffer>& buffer = *it; |
| 143 DCHECK(!buffer->end_of_stream()); | 149 DCHECK(!buffer->end_of_stream()); |
| 150 DCHECK(!buffer->GetPrerollBuffer()); | |
| 144 DCHECK(buffer->get_splice_buffers().empty()); | 151 DCHECK(buffer->get_splice_buffers().empty()); |
| 145 splice_buffers_.push_back(CopyBuffer(*buffer)); | 152 splice_buffers_.push_back(CopyBuffer(*buffer)); |
| 146 splice_buffers_.back()->set_splice_timestamp(splice_timestamp()); | 153 splice_buffers_.back()->set_splice_timestamp(splice_timestamp()); |
| 147 } | 154 } |
| 148 | 155 |
| 149 splice_buffers_.push_back(overlapping_buffer); | 156 splice_buffers_.push_back(overlapping_buffer); |
| 150 } | 157 } |
| 151 | 158 |
| 159 void StreamParserBuffer::SetPrerollBuffer( | |
| 160 const scoped_refptr<StreamParserBuffer>& preroll_buffer) { | |
| 161 DCHECK(!preroll_buffer_); | |
| 162 DCHECK(!end_of_stream()); | |
| 163 DCHECK(!preroll_buffer->end_of_stream()); | |
| 164 DCHECK(!preroll_buffer->preroll_buffer_); | |
| 165 DCHECK(preroll_buffer->splice_timestamp() == kNoTimestamp()); | |
| 166 DCHECK(preroll_buffer->get_splice_buffers().empty()); | |
| 167 DCHECK(preroll_buffer->timestamp() < timestamp()); | |
|
wolenetz
2014/05/17 00:41:17
nit: Is this strictly always true, even for out-of
DaleCurtis
2014/05/17 00:55:41
Hmm, it might need to be <= since that's what the
DaleCurtis
2014/05/22 23:58:57
Done.
| |
| 168 DCHECK(preroll_buffer->discard_padding() == DecoderBuffer::DiscardPadding()); | |
| 169 DCHECK_EQ(preroll_buffer->type(), type()); | |
|
wolenetz
2014/05/17 00:41:17
Could the app cause decoder problems by causing a
DaleCurtis
2014/05/17 00:55:41
Yes this would be a problem. They must have the s
| |
| 170 | |
| 171 // Mark the entire buffer for discard. | |
| 172 // TODO(dalecurtis): This relies on accurate durations, which is a dubious | |
| 173 // assumption when working with WebM... | |
|
wolenetz
2014/05/17 00:41:17
suggestion (possibly for a different CL): could di
DaleCurtis
2014/05/17 00:55:41
That's a good idea. I'll work it into the next pa
DaleCurtis
2014/05/22 23:58:57
Done here: https://codereview.chromium.org/2930530
| |
| 174 preroll_buffer_ = preroll_buffer; | |
| 175 preroll_buffer_->set_discard_padding( | |
| 176 std::make_pair(preroll_buffer_->duration(), base::TimeDelta())); | |
| 177 } | |
| 178 | |
| 179 const scoped_refptr<StreamParserBuffer>& | |
| 180 StreamParserBuffer::GetPrerollBuffer() { | |
| 181 if (preroll_buffer_) { | |
|
wolenetz
2014/05/17 00:41:17
nit: reverse condition and return early.
DaleCurtis
2014/05/22 23:58:57
Removed completely now per acolwell's request to m
| |
| 182 // Set the timestamps and configuration to match our current buffer. It's | |
| 183 // original timestamp shouldn't be considered by any downstream components. | |
| 184 preroll_buffer_->set_timestamp(timestamp()); | |
|
acolwell GONE FROM CHROMIUM
2014/05/16 17:01:11
This seems hacky to do all this setting on a get o
DaleCurtis
2014/05/16 17:48:59
If something comes along later and calls any Set()
acolwell GONE FROM CHROMIUM
2014/05/16 20:26:05
But at least the that is a more direct reflection
DaleCurtis
2014/05/17 00:14:10
It's not that simple since set_timestamp() is a ha
| |
| 185 preroll_buffer_->SetDecodeTimestamp(GetDecodeTimestamp()); | |
| 186 preroll_buffer_->SetConfigId(GetConfigId()); | |
| 187 preroll_buffer_->track_id_ = track_id(); | |
| 188 } | |
| 189 | |
| 190 return preroll_buffer_; | |
| 191 } | |
| 192 | |
| 152 } // namespace media | 193 } // namespace media |
| OLD | NEW |