summaryrefslogtreecommitdiffstats
path: root/media/omx/input_buffer.cc
blob: 97e202233c60bc9c363d0f9df88ac94841049fb7 (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
44
// Copyright (c) 2009 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 <algorithm>

#include "base/logging.h"
#include "media/omx/input_buffer.h"

namespace media {

InputBuffer::InputBuffer()
    : data_(NULL),
      size_(0),
      used_(0) {
}

InputBuffer::InputBuffer(uint8* data, int size)
    : data_(data),
      size_(size),
      used_(0) {
  DCHECK_GE(size, 0);
}

InputBuffer::~InputBuffer() {
  delete [] data_;
}

int InputBuffer::Read(uint8* output_data, int output_size) {
  int copy = std::min(output_size, size_ - used_);
  memcpy(output_data, data_ + used_, copy);
  used_ += copy;
  return copy;
}

bool InputBuffer::Used() {
  return used_ == size_;
}

bool InputBuffer::Eos() {
  return data_ == NULL || size_ == 0;
}

}  // namespace media