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 "base/memory/ptr_util.h" |
8 #include "media/base/timestamp_constants.h" | 9 #include "media/base/timestamp_constants.h" |
9 | 10 |
10 namespace media { | 11 namespace media { |
11 | 12 |
12 static scoped_refptr<StreamParserBuffer> CopyBuffer( | 13 static scoped_refptr<StreamParserBuffer> CopyBuffer( |
13 const StreamParserBuffer& buffer) { | 14 const StreamParserBuffer& buffer) { |
14 if (buffer.end_of_stream()) | 15 if (buffer.end_of_stream()) |
15 return StreamParserBuffer::CreateEOSBuffer(); | 16 return StreamParserBuffer::CreateEOSBuffer(); |
16 | 17 |
17 scoped_refptr<StreamParserBuffer> copied_buffer = | 18 scoped_refptr<StreamParserBuffer> copied_buffer = |
18 StreamParserBuffer::CopyFrom(buffer.data(), | 19 StreamParserBuffer::CopyFrom(buffer.data(), |
19 buffer.data_size(), | 20 buffer.data_size(), |
20 buffer.side_data(), | 21 buffer.side_data(), |
21 buffer.side_data_size(), | 22 buffer.side_data_size(), |
22 buffer.is_key_frame(), | 23 buffer.is_key_frame(), |
23 buffer.type(), | 24 buffer.type(), |
24 buffer.track_id()); | 25 buffer.track_id()); |
25 copied_buffer->SetDecodeTimestamp(buffer.GetDecodeTimestamp()); | 26 copied_buffer->SetDecodeTimestamp(buffer.GetDecodeTimestamp()); |
26 copied_buffer->SetConfigId(buffer.GetConfigId()); | 27 copied_buffer->SetConfigId(buffer.GetConfigId()); |
27 copied_buffer->set_timestamp(buffer.timestamp()); | 28 copied_buffer->set_timestamp(buffer.timestamp()); |
28 copied_buffer->set_duration(buffer.duration()); | 29 copied_buffer->set_duration(buffer.duration()); |
29 copied_buffer->set_is_duration_estimated(buffer.is_duration_estimated()); | 30 copied_buffer->set_is_duration_estimated(buffer.is_duration_estimated()); |
30 copied_buffer->set_discard_padding(buffer.discard_padding()); | 31 copied_buffer->set_discard_padding(buffer.discard_padding()); |
31 copied_buffer->set_splice_timestamp(buffer.splice_timestamp()); | 32 copied_buffer->set_splice_timestamp(buffer.splice_timestamp()); |
32 const DecryptConfig* decrypt_config = buffer.decrypt_config(); | 33 const DecryptConfig* decrypt_config = buffer.decrypt_config(); |
33 if (decrypt_config) { | 34 if (decrypt_config) { |
34 copied_buffer->set_decrypt_config( | 35 copied_buffer->set_decrypt_config(base::WrapUnique( |
35 make_scoped_ptr(new DecryptConfig(decrypt_config->key_id(), | 36 new DecryptConfig(decrypt_config->key_id(), decrypt_config->iv(), |
36 decrypt_config->iv(), | 37 decrypt_config->subsamples()))); |
37 decrypt_config->subsamples()))); | |
38 } | 38 } |
39 | 39 |
40 return copied_buffer; | 40 return copied_buffer; |
41 } | 41 } |
42 | 42 |
43 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() { | 43 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() { |
44 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false, | 44 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false, |
45 DemuxerStream::UNKNOWN, 0)); | 45 DemuxerStream::UNKNOWN, 0)); |
46 } | 46 } |
47 | 47 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 std::make_pair(kInfiniteDuration(), base::TimeDelta())); | 233 std::make_pair(kInfiniteDuration(), base::TimeDelta())); |
234 } | 234 } |
235 | 235 |
236 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { | 236 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { |
237 DecoderBuffer::set_timestamp(timestamp); | 237 DecoderBuffer::set_timestamp(timestamp); |
238 if (preroll_buffer_.get()) | 238 if (preroll_buffer_.get()) |
239 preroll_buffer_->set_timestamp(timestamp); | 239 preroll_buffer_->set_timestamp(timestamp); |
240 } | 240 } |
241 | 241 |
242 } // namespace media | 242 } // namespace media |
OLD | NEW |