7 #ifndef PACKAGER_MEDIA_FORMATS_MP4_BOX_BUFFER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP4_BOX_BUFFER_H_
12 #include <absl/log/check.h>
14 #include <packager/macros/classes.h>
15 #include <packager/media/base/buffer_writer.h>
16 #include <packager/media/formats/mp4/box.h>
17 #include <packager/media/formats/mp4/box_reader.h>
42 bool Reading()
const {
return reader_ != NULL; }
48 return reader_->pos();
49 return writer_->Size();
58 return reader_->size();
59 return writer_->Size();
66 return reader_->size() - reader_->pos();
72 bool ReadWriteUInt8(uint8_t* v) {
74 return reader_->
Read1(v);
78 bool ReadWriteUInt16(uint16_t* v) {
80 return reader_->Read2(v);
84 bool ReadWriteUInt32(uint32_t* v) {
86 return reader_->Read4(v);
90 bool ReadWriteUInt64(uint64_t* v) {
92 return reader_->Read8(v);
96 bool ReadWriteInt16(int16_t* v) {
98 return reader_->Read2s(v);
102 bool ReadWriteInt32(int32_t* v) {
104 return reader_->Read4s(v);
108 bool ReadWriteInt64(int64_t* v) {
110 return reader_->Read8s(v);
125 bool ReadWriteInt64NBytes(int64_t* v,
size_t num_bytes) {
127 return reader_->ReadNBytesInto8s(v, num_bytes);
131 bool ReadWriteVector(std::vector<uint8_t>* vector,
size_t count) {
133 return reader_->ReadToVector(vector, count);
134 DCHECK_EQ(vector->size(), count);
135 writer_->AppendArray(vector->data(), count);
143 return reader_->ReadToString(str, size);
144 DCHECK_EQ(str->size(), size);
145 writer_->AppendArray(
reinterpret_cast<const uint8_t*
>(str->data()),
150 bool ReadWriteCString(std::string* str) {
154 DCHECK_EQ(str->find(
'\0'), std::string::npos);
155 writer_->AppendString(*str);
156 writer_->
AppendInt(
static_cast<uint8_t
>(
'\0'));
160 bool ReadWriteFourCC(FourCC* fourcc) {
162 return reader_->ReadFourCC(fourcc);
163 writer_->
AppendInt(
static_cast<uint32_t
>(*fourcc));
183 CHECK(box->ReadWriteInternal(
this));
194 CHECK(box->ReadWriteInternal(
this));
204 std::vector<uint8_t> vector(num_bytes, 0);
205 writer_->AppendVector(vector);
All the methods that are virtual are virtual for mocking.