summaryrefslogtreecommitdiffstats
path: root/media/cdm/simple_cdm_buffer.cc
blob: c5f3b8bbf96d0e88d159cb81d49e299a1ad148f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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/logging.h"

namespace media {

// static
SimpleCdmBuffer* SimpleCdmBuffer::Create(uint32_t capacity) {
  DCHECK(capacity);
  return new SimpleCdmBuffer(capacity);
}

SimpleCdmBuffer::SimpleCdmBuffer(uint32_t capacity)
    : buffer_(capacity), size_(0) {}

SimpleCdmBuffer::~SimpleCdmBuffer() {}

void SimpleCdmBuffer::Destroy() {
  delete this;
}

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