OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "media/base/data_buffer.h" | 6 #include "media/base/data_buffer.h" |
7 | 7 |
8 namespace media { | 8 namespace media { |
9 | 9 |
10 DataBuffer::DataBuffer(char* data, size_t buffer_size, size_t data_size, | 10 DataBuffer::DataBuffer(char* data, size_t buffer_size, size_t data_size, |
11 const base::TimeDelta& timestamp, | 11 const base::TimeDelta& timestamp, |
12 const base::TimeDelta& duration) | 12 const base::TimeDelta& duration) |
13 : data_(data), | 13 : data_(data), |
14 buffer_size_(buffer_size), | 14 buffer_size_(buffer_size), |
15 data_size_(data_size), | 15 data_size_(data_size) { |
16 timestamp_(timestamp), | |
17 duration_(duration) { | |
18 DCHECK(data); | 16 DCHECK(data); |
19 DCHECK(buffer_size >= 0); | 17 DCHECK(buffer_size >= 0); |
20 DCHECK(data_size <= buffer_size); | 18 DCHECK(data_size <= buffer_size); |
| 19 SetTimestamp(timestamp); |
| 20 SetDuration(duration); |
21 } | 21 } |
22 | 22 |
23 DataBuffer::~DataBuffer() { | 23 DataBuffer::~DataBuffer() { |
24 delete [] data_; | 24 delete [] data_; |
25 } | 25 } |
26 | 26 |
27 base::TimeDelta DataBuffer::GetTimestamp() const { | |
28 return timestamp_; | |
29 } | |
30 | |
31 void DataBuffer::SetTimestamp(const base::TimeDelta& timestamp) { | |
32 timestamp_ = timestamp; | |
33 } | |
34 | |
35 base::TimeDelta DataBuffer::GetDuration() const { | |
36 return duration_; | |
37 } | |
38 | |
39 void DataBuffer::SetDuration(const base::TimeDelta& duration) { | |
40 duration_ = duration; | |
41 } | |
42 | |
43 const char* DataBuffer::GetData() const { | 27 const char* DataBuffer::GetData() const { |
44 return data_; | 28 return data_; |
45 } | 29 } |
46 | 30 |
47 size_t DataBuffer::GetDataSize() const { | 31 size_t DataBuffer::GetDataSize() const { |
48 return data_size_; | 32 return data_size_; |
49 } | 33 } |
50 | 34 |
51 char* DataBuffer::GetWritableData() { | 35 char* DataBuffer::GetWritableData() { |
52 return data_; | 36 return data_; |
53 } | 37 } |
54 | 38 |
55 size_t DataBuffer::GetBufferSize() const { | 39 size_t DataBuffer::GetBufferSize() const { |
56 return buffer_size_; | 40 return buffer_size_; |
57 } | 41 } |
58 | 42 |
59 void DataBuffer::SetDataSize(size_t data_size) { | 43 void DataBuffer::SetDataSize(size_t data_size) { |
60 data_size_ = data_size; | 44 data_size_ = data_size; |
61 } | 45 } |
62 | 46 |
63 } // namespace media | 47 } // namespace media |
OLD | NEW |