OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 CloneDataIfReferenced(buffer_->capacity()); | 83 CloneDataIfReferenced(buffer_->capacity()); |
84 return buffer_->data<T>(); | 84 return buffer_->data<T>(); |
85 } | 85 } |
86 | 86 |
87 // Get const pointer to the data. This will not create a copy of the | 87 // Get const pointer to the data. This will not create a copy of the |
88 // underlying data if it is shared with other buffers. | 88 // underlying data if it is shared with other buffers. |
89 template <typename T = uint8_t, | 89 template <typename T = uint8_t, |
90 typename std::enable_if< | 90 typename std::enable_if< |
91 internal::BufferCompat<uint8_t, T>::value>::type* = nullptr> | 91 internal::BufferCompat<uint8_t, T>::value>::type* = nullptr> |
92 T* cdata() const { | 92 const T* cdata() const { |
93 RTC_DCHECK(IsConsistent()); | 93 RTC_DCHECK(IsConsistent()); |
94 if (!buffer_) { | 94 if (!buffer_) { |
95 return nullptr; | 95 return nullptr; |
96 } | 96 } |
97 return buffer_->data<T>(); | 97 return buffer_->data<T>(); |
98 } | 98 } |
99 | 99 |
100 size_t size() const { | 100 size_t size() const { |
101 RTC_DCHECK(IsConsistent()); | 101 RTC_DCHECK(IsConsistent()); |
102 return buffer_ ? buffer_->size() : 0; | 102 return buffer_ ? buffer_->size() : 0; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return (!buffer_ || buffer_->capacity() > 0); | 283 return (!buffer_ || buffer_->capacity() > 0); |
284 } | 284 } |
285 | 285 |
286 // buffer_ is either null, or points to an rtc::Buffer with capacity > 0. | 286 // buffer_ is either null, or points to an rtc::Buffer with capacity > 0. |
287 scoped_refptr<RefCountedObject<Buffer>> buffer_; | 287 scoped_refptr<RefCountedObject<Buffer>> buffer_; |
288 }; | 288 }; |
289 | 289 |
290 } // namespace rtc | 290 } // namespace rtc |
291 | 291 |
292 #endif // WEBRTC_BASE_COPYONWRITEBUFFER_H_ | 292 #endif // WEBRTC_BASE_COPYONWRITEBUFFER_H_ |
OLD | NEW |