7 #ifndef PACKAGER_MEDIA_FORMATS_MP4_BOX_BUFFER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP4_BOX_BUFFER_H_
12 #include "packager/base/compiler_specific.h"
13 #include "packager/media/base/buffer_writer.h"
14 #include "packager/media/formats/mp4/box.h"
15 #include "packager/media/formats/mp4/box_reader.h"
40 bool Reading()
const {
return reader_ != NULL; }
46 return reader_->pos();
47 return writer_->Size();
56 return reader_->size();
57 return writer_->Size();
64 return reader_->size() - reader_->pos();
70 bool ReadWriteUInt8(uint8_t* v) {
72 return reader_->
Read1(v);
76 bool ReadWriteUInt16(uint16_t* v) {
78 return reader_->Read2(v);
82 bool ReadWriteUInt32(uint32_t* v) {
84 return reader_->Read4(v);
88 bool ReadWriteUInt64(uint64_t* v) {
90 return reader_->Read8(v);
94 bool ReadWriteInt16(int16_t* v) {
96 return reader_->Read2s(v);
100 bool ReadWriteInt32(int32_t* v) {
102 return reader_->Read4s(v);
106 bool ReadWriteInt64(int64_t* v) {
108 return reader_->Read8s(v);
123 bool ReadWriteInt64NBytes(int64_t* v,
size_t num_bytes) {
125 return reader_->ReadNBytesInto8s(v, num_bytes);
129 bool ReadWriteVector(std::vector<uint8_t>* vector,
size_t count) {
131 return reader_->ReadToVector(vector, count);
132 DCHECK_EQ(vector->size(), count);
133 writer_->AppendArray(vector->data(), count);
141 return reader_->ReadToString(str, size);
142 DCHECK_EQ(str->size(), size);
143 writer_->AppendArray(
reinterpret_cast<const uint8_t*
>(str->data()),
148 bool ReadWriteCString(std::string* str) {
152 DCHECK_EQ(str->find(
'\0'), std::string::npos);
153 writer_->AppendString(*str);
154 writer_->
AppendInt(
static_cast<uint8_t
>(
'\0'));
158 bool ReadWriteFourCC(FourCC* fourcc) {
160 return reader_->ReadFourCC(fourcc);
161 writer_->
AppendInt(
static_cast<uint32_t
>(*fourcc));
181 CHECK(box->ReadWriteInternal(
this));
192 CHECK(box->ReadWriteInternal(
this));
202 std::vector<uint8_t> vector(num_bytes, 0);
203 writer_->AppendVector(vector);
All the methods that are virtual are virtual for mocking.