Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: media/cdm/simple_cdm_buffer.cc

Issue 1673383002: Add allocator interface for use by cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simple classes Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698