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 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() { | 12 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() { |
13 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, false)); | 13 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false)); |
14 } | 14 } |
15 | 15 |
16 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( | 16 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( |
17 const uint8* data, int data_size, bool is_keyframe) { | 17 const uint8* data, int data_size, bool is_keyframe) { |
18 return make_scoped_refptr( | 18 return make_scoped_refptr( |
19 new StreamParserBuffer(data, data_size, is_keyframe)); | 19 new StreamParserBuffer(data, data_size, NULL, 0, is_keyframe)); |
| 20 } |
| 21 |
| 22 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( |
| 23 const uint8* data, int data_size, |
| 24 const uint8* side_data, int side_data_size, bool is_keyframe) { |
| 25 return make_scoped_refptr( |
| 26 new StreamParserBuffer(data, data_size, side_data, side_data_size, |
| 27 is_keyframe)); |
20 } | 28 } |
21 | 29 |
22 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { | 30 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { |
23 if (decode_timestamp_ == kNoTimestamp()) | 31 if (decode_timestamp_ == kNoTimestamp()) |
24 return GetTimestamp(); | 32 return GetTimestamp(); |
25 return decode_timestamp_; | 33 return decode_timestamp_; |
26 } | 34 } |
27 | 35 |
28 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) { | 36 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) { |
29 decode_timestamp_ = timestamp; | 37 decode_timestamp_ = timestamp; |
30 } | 38 } |
31 | 39 |
32 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, | 40 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, |
33 bool is_keyframe) | 41 const uint8* side_data, |
34 : DecoderBuffer(data, data_size), | 42 int side_data_size, bool is_keyframe) |
| 43 : DecoderBuffer(data, data_size, side_data, side_data_size), |
35 is_keyframe_(is_keyframe), | 44 is_keyframe_(is_keyframe), |
36 decode_timestamp_(kNoTimestamp()), | 45 decode_timestamp_(kNoTimestamp()), |
37 config_id_(kInvalidConfigId) { | 46 config_id_(kInvalidConfigId) { |
38 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and | 47 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and |
39 // duration to force clients to set them? Today they end up being zero which | 48 // duration to force clients to set them? Today they end up being zero which |
40 // is both a common and valid value and could lead to bugs. | 49 // is both a common and valid value and could lead to bugs. |
41 if (data) { | 50 if (data) { |
42 SetDuration(kNoTimestamp()); | 51 SetDuration(kNoTimestamp()); |
43 } | 52 } |
44 } | 53 } |
45 | 54 |
46 StreamParserBuffer::~StreamParserBuffer() { | 55 StreamParserBuffer::~StreamParserBuffer() { |
47 } | 56 } |
48 | 57 |
49 int StreamParserBuffer::GetConfigId() const { | 58 int StreamParserBuffer::GetConfigId() const { |
50 return config_id_; | 59 return config_id_; |
51 } | 60 } |
52 | 61 |
53 void StreamParserBuffer::SetConfigId(int config_id) { | 62 void StreamParserBuffer::SetConfigId(int config_id) { |
54 config_id_ = config_id; | 63 config_id_ = config_id; |
55 } | 64 } |
56 | 65 |
57 } // namespace media | 66 } // namespace media |
OLD | NEW |