Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/cdm/simple_cdm_buffer.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "media/cdm/cdm_buffer_allocator.h" | |
| 10 #include "media/cdm/cdm_helpers.h" | |
| 11 | |
| 12 namespace media { | |
| 13 | |
| 14 // static | |
| 15 scoped_refptr<SimpleCdmBuffer> SimpleCdmBuffer::Create( | |
| 16 CdmBufferAllocator* allocator, | |
| 17 uint32_t capacity) { | |
| 18 DCHECK(capacity); | |
| 19 return new SimpleCdmBuffer(allocator, capacity); | |
| 20 } | |
| 21 | |
| 22 SimpleCdmBuffer::SimpleCdmBuffer(CdmBufferAllocator* allocator, | |
| 23 uint32_t capacity) | |
| 24 : allocator_(allocator), buffer_(capacity), size_(0) {} | |
| 25 | |
| 26 SimpleCdmBuffer::~SimpleCdmBuffer() {} | |
| 27 | |
| 28 void SimpleCdmBuffer::Destroy() { | |
| 29 // Note that the CDM called AddRef() when allocating this object. However, | |
| 30 // passing |this| to Release() will casue the reference count to be | |
| 31 // decremented to match that AddRef(). | |
| 32 allocator_->Release(this); | |
|
xhwang
2016/02/11 19:24:14
See comment above. Destroy() should call Release()
jrummell
2016/02/11 22:08:16
No longer ref-counted, so we can simply call the d
| |
| 33 } | |
| 34 | |
| 35 uint32_t SimpleCdmBuffer::Capacity() const { | |
| 36 return buffer_.size(); | |
| 37 } | |
| 38 | |
| 39 uint8_t* SimpleCdmBuffer::Data() { | |
| 40 return buffer_.data(); | |
| 41 } | |
| 42 | |
| 43 void SimpleCdmBuffer::SetSize(uint32_t size) { | |
| 44 DCHECK(size <= Capacity()); | |
| 45 size_ = size > Capacity() ? 0 : size; | |
| 46 } | |
| 47 | |
| 48 uint32_t SimpleCdmBuffer::Size() const { | |
| 49 return size_; | |
| 50 } | |
| 51 | |
| 52 } // namespace media | |
| OLD | NEW |