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 { |
11 | 11 |
12 static scoped_refptr<StreamParserBuffer> CopyBuffer( | 12 static scoped_refptr<StreamParserBuffer> CopyBuffer( |
13 const StreamParserBuffer& buffer) { | 13 const StreamParserBuffer& buffer) { |
14 if (buffer.end_of_stream()) | 14 if (buffer.end_of_stream()) |
15 return StreamParserBuffer::CreateEOSBuffer(); | 15 return StreamParserBuffer::CreateEOSBuffer(); |
16 | 16 |
17 scoped_refptr<StreamParserBuffer> copied_buffer = | 17 scoped_refptr<StreamParserBuffer> copied_buffer = |
18 StreamParserBuffer::CopyFrom(buffer.data(), | 18 StreamParserBuffer::CopyFrom(buffer.data(), |
19 buffer.data_size(), | 19 buffer.data_size(), |
20 buffer.side_data(), | 20 buffer.side_data(), |
21 buffer.side_data_size(), | 21 buffer.side_data_size(), |
22 buffer.IsKeyframe(), | 22 buffer.is_keyframe(), |
23 buffer.type(), | 23 buffer.type(), |
24 buffer.track_id()); | 24 buffer.track_id()); |
25 copied_buffer->SetDecodeTimestamp(buffer.GetDecodeTimestamp()); | 25 copied_buffer->SetDecodeTimestamp(buffer.GetDecodeTimestamp()); |
26 copied_buffer->SetConfigId(buffer.GetConfigId()); | 26 copied_buffer->SetConfigId(buffer.GetConfigId()); |
27 copied_buffer->set_timestamp(buffer.timestamp()); | 27 copied_buffer->set_timestamp(buffer.timestamp()); |
28 copied_buffer->set_duration(buffer.duration()); | 28 copied_buffer->set_duration(buffer.duration()); |
29 copied_buffer->set_discard_padding(buffer.discard_padding()); | 29 copied_buffer->set_discard_padding(buffer.discard_padding()); |
30 copied_buffer->set_splice_timestamp(buffer.splice_timestamp()); | 30 copied_buffer->set_splice_timestamp(buffer.splice_timestamp()); |
31 const DecryptConfig* decrypt_config = buffer.decrypt_config(); | 31 const DecryptConfig* decrypt_config = buffer.decrypt_config(); |
32 if (decrypt_config) { | 32 if (decrypt_config) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void StreamParserBuffer::SetDecodeTimestamp(DecodeTimestamp timestamp) { | 70 void StreamParserBuffer::SetDecodeTimestamp(DecodeTimestamp timestamp) { |
71 decode_timestamp_ = timestamp; | 71 decode_timestamp_ = timestamp; |
72 if (preroll_buffer_.get()) | 72 if (preroll_buffer_.get()) |
73 preroll_buffer_->SetDecodeTimestamp(timestamp); | 73 preroll_buffer_->SetDecodeTimestamp(timestamp); |
74 } | 74 } |
75 | 75 |
76 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, | 76 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, |
77 const uint8* side_data, | 77 const uint8* side_data, |
78 int side_data_size, bool is_keyframe, | 78 int side_data_size, bool is_keyframe, |
79 Type type, TrackId track_id) | 79 Type type, TrackId track_id) |
80 : DecoderBuffer(data, data_size, side_data, side_data_size), | 80 : DecoderBuffer(data, data_size, side_data, side_data_size, is_keyframe), |
81 is_keyframe_(is_keyframe), | |
82 decode_timestamp_(kNoDecodeTimestamp()), | 81 decode_timestamp_(kNoDecodeTimestamp()), |
83 config_id_(kInvalidConfigId), | 82 config_id_(kInvalidConfigId), |
84 type_(type), | 83 type_(type), |
85 track_id_(track_id) { | 84 track_id_(track_id) { |
86 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and | 85 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and |
87 // duration to force clients to set them? Today they end up being zero which | 86 // duration to force clients to set them? Today they end up being zero which |
88 // is both a common and valid value and could lead to bugs. | 87 // is both a common and valid value and could lead to bugs. |
89 if (data) { | 88 if (data) { |
90 set_duration(kNoTimestamp()); | 89 set_duration(kNoTimestamp()); |
91 } | 90 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Move over any preroll from this buffer. | 135 // Move over any preroll from this buffer. |
137 if (preroll_buffer_.get()) { | 136 if (preroll_buffer_.get()) { |
138 DCHECK(!overlapping_buffer->preroll_buffer_.get()); | 137 DCHECK(!overlapping_buffer->preroll_buffer_.get()); |
139 overlapping_buffer->preroll_buffer_.swap(preroll_buffer_); | 138 overlapping_buffer->preroll_buffer_.swap(preroll_buffer_); |
140 } | 139 } |
141 | 140 |
142 // Rewrite |this| buffer as a splice buffer. | 141 // Rewrite |this| buffer as a splice buffer. |
143 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); | 142 SetDecodeTimestamp(first_splice_buffer->GetDecodeTimestamp()); |
144 SetConfigId(first_splice_buffer->GetConfigId()); | 143 SetConfigId(first_splice_buffer->GetConfigId()); |
145 set_timestamp(first_splice_buffer->timestamp()); | 144 set_timestamp(first_splice_buffer->timestamp()); |
146 is_keyframe_ = first_splice_buffer->IsKeyframe(); | 145 set_is_keyframe(first_splice_buffer->is_keyframe()); |
147 type_ = first_splice_buffer->type(); | 146 type_ = first_splice_buffer->type(); |
148 track_id_ = first_splice_buffer->track_id(); | 147 track_id_ = first_splice_buffer->track_id(); |
149 set_splice_timestamp(overlapping_buffer->timestamp()); | 148 set_splice_timestamp(overlapping_buffer->timestamp()); |
150 | 149 |
151 // The splice duration is the duration of all buffers before the splice plus | 150 // The splice duration is the duration of all buffers before the splice plus |
152 // the highest ending timestamp after the splice point. | 151 // the highest ending timestamp after the splice point. |
153 DCHECK(overlapping_buffer->duration() > base::TimeDelta()); | 152 DCHECK(overlapping_buffer->duration() > base::TimeDelta()); |
154 DCHECK(pre_splice_buffers.back()->duration() > base::TimeDelta()); | 153 DCHECK(pre_splice_buffers.back()->duration() > base::TimeDelta()); |
155 set_duration( | 154 set_duration( |
156 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), | 155 std::max(overlapping_buffer->timestamp() + overlapping_buffer->duration(), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 std::make_pair(kInfiniteDuration(), base::TimeDelta())); | 194 std::make_pair(kInfiniteDuration(), base::TimeDelta())); |
196 } | 195 } |
197 | 196 |
198 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { | 197 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { |
199 DecoderBuffer::set_timestamp(timestamp); | 198 DecoderBuffer::set_timestamp(timestamp); |
200 if (preroll_buffer_.get()) | 199 if (preroll_buffer_.get()) |
201 preroll_buffer_->set_timestamp(timestamp); | 200 preroll_buffer_->set_timestamp(timestamp); |
202 } | 201 } |
203 | 202 |
204 } // namespace media | 203 } // namespace media |
OLD | NEW |