7 #ifndef MEDIA_FORMATS_MP4_BOX_BUFFER_H_
8 #define 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 ReadWriteFourCC(FourCC* fourcc) {
150 return reader_->ReadFourCC(fourcc);
151 writer_->
AppendInt(static_cast<uint32_t>(*fourcc));
171 CHECK(box->ReadWriteInternal(
this));
182 CHECK(box->ReadWriteInternal(
this));
192 std::vector<uint8_t> vector(num_bytes, 0);
193 writer_->AppendVector(vector);
213 #endif // MEDIA_FORMATS_MP4_BOX_BUFFER_H_