summaryrefslogtreecommitdiffstats
path: root/media/base/data_buffer.cc
blob: c5c290dff6c5fcff143b86f587c9e44377f5fbc4 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2006-2008 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 "base/logging.h"
#include "media/base/data_buffer.h"

namespace media {

DataBuffer::DataBuffer(char* data, size_t buffer_size, size_t data_size,
                       int64 timestamp, int64 duration)
    : data_(data),
      buffer_size_(buffer_size),
      data_size_(data_size),
      timestamp_(timestamp),
      duration_(duration) {
  DCHECK(data);
  DCHECK(buffer_size >= 0);
  DCHECK(data_size <= buffer_size);
}

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

int64 DataBuffer::GetTimestamp() const {
  return timestamp_;
}

void DataBuffer::SetTimestamp(int64 timestamp) {
  timestamp_ = timestamp;
}

int64 DataBuffer::GetDuration() const {
  return duration_;
}

void DataBuffer::SetDuration(int64 duration) {
  duration_ = duration;
}

const char* DataBuffer::GetData() const {
  return data_;
}

size_t DataBuffer::GetDataSize() const {
  return data_size_;
}

char* DataBuffer::GetWritableData() {
  return data_;
}

size_t DataBuffer::GetBufferSize() const {
  return buffer_size_;
}

void DataBuffer::SetDataSize(size_t data_size) {
  data_size_ = data_size;
}

}  // namespace media