| 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/data_buffer.h" | 5 #include "media/base/data_buffer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 scoped_refptr<DataBuffer> DataBuffer::CopyFrom(const uint8* data, int size) { | 42 scoped_refptr<DataBuffer> DataBuffer::CopyFrom(const uint8* data, int size) { |
| 43 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. | 43 // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. |
| 44 CHECK(data); | 44 CHECK(data); |
| 45 return make_scoped_refptr(new DataBuffer(data, size)); | 45 return make_scoped_refptr(new DataBuffer(data, size)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // static | 48 // static |
| 49 scoped_refptr<DataBuffer> DataBuffer::CreateEOSBuffer() { | 49 scoped_refptr<DataBuffer> DataBuffer::CreateEOSBuffer() { |
| 50 return make_scoped_refptr(new DataBuffer(NULL, 0)); | 50 return make_scoped_refptr(new DataBuffer(NULL, 0)); |
| 51 } | 51 } |
| 52 | |
| 53 base::TimeDelta DataBuffer::GetTimestamp() const { | |
| 54 DCHECK(!IsEndOfStream()); | |
| 55 return timestamp_; | |
| 56 } | |
| 57 | |
| 58 void DataBuffer::SetTimestamp(const base::TimeDelta& timestamp) { | |
| 59 DCHECK(!IsEndOfStream()); | |
| 60 timestamp_ = timestamp; | |
| 61 } | |
| 62 | |
| 63 base::TimeDelta DataBuffer::GetDuration() const { | |
| 64 DCHECK(!IsEndOfStream()); | |
| 65 return duration_; | |
| 66 } | |
| 67 | |
| 68 void DataBuffer::SetDuration(const base::TimeDelta& duration) { | |
| 69 DCHECK(!IsEndOfStream()); | |
| 70 duration_ = duration; | |
| 71 } | |
| 72 | |
| 73 bool DataBuffer::IsEndOfStream() const { | |
| 74 return data_ == NULL; | |
| 75 } | |
| 76 | |
| 77 const uint8* DataBuffer::GetData() const { | |
| 78 DCHECK(!IsEndOfStream()); | |
| 79 return data_.get(); | |
| 80 } | |
| 81 | |
| 82 uint8* DataBuffer::GetWritableData() { | |
| 83 DCHECK(!IsEndOfStream()); | |
| 84 return data_.get(); | |
| 85 } | |
| 86 | |
| 87 int DataBuffer::GetDataSize() const { | |
| 88 DCHECK(!IsEndOfStream()); | |
| 89 return data_size_; | |
| 90 } | |
| 91 | |
| 92 void DataBuffer::SetDataSize(int data_size) { | |
| 93 DCHECK(!IsEndOfStream()); | |
| 94 CHECK_LE(data_size, buffer_size_); | |
| 95 data_size_ = data_size; | |
| 96 } | |
| 97 | |
| 98 } // namespace media | 52 } // namespace media |
| OLD | NEW |