Index: media/cdm/simple_cdm_buffer.cc |
diff --git a/media/cdm/simple_cdm_buffer.cc b/media/cdm/simple_cdm_buffer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4ed9f7bccebb0e3e82b78c4e3f218e437f2714cb |
--- /dev/null |
+++ b/media/cdm/simple_cdm_buffer.cc |
@@ -0,0 +1,52 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/cdm/simple_cdm_buffer.h" |
+ |
+#include "base/bind.h" |
+#include "base/logging.h" |
+#include "media/cdm/cdm_buffer_allocator.h" |
+#include "media/cdm/cdm_helpers.h" |
+ |
+namespace media { |
+ |
+// static |
+scoped_refptr<SimpleCdmBuffer> SimpleCdmBuffer::Create( |
+ CdmBufferAllocator* allocator, |
+ uint32_t capacity) { |
+ DCHECK(capacity); |
+ return new SimpleCdmBuffer(allocator, capacity); |
+} |
+ |
+SimpleCdmBuffer::SimpleCdmBuffer(CdmBufferAllocator* allocator, |
+ uint32_t capacity) |
+ : allocator_(allocator), buffer_(capacity), size_(0) {} |
+ |
+SimpleCdmBuffer::~SimpleCdmBuffer() {} |
+ |
+void SimpleCdmBuffer::Destroy() { |
+ // Note that the CDM called AddRef() when allocating this object. However, |
+ // passing |this| to Release() will casue the reference count to be |
+ // decremented to match that AddRef(). |
+ 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
|
+} |
+ |
+uint32_t SimpleCdmBuffer::Capacity() const { |
+ return buffer_.size(); |
+} |
+ |
+uint8_t* SimpleCdmBuffer::Data() { |
+ return buffer_.data(); |
+} |
+ |
+void SimpleCdmBuffer::SetSize(uint32_t size) { |
+ DCHECK(size <= Capacity()); |
+ size_ = size > Capacity() ? 0 : size; |
+} |
+ |
+uint32_t SimpleCdmBuffer::Size() const { |
+ return size_; |
+} |
+ |
+} // namespace media |