44 const size_t buf_size,
56 [[nodiscard]]
static bool StartBox(
const uint8_t* buf,
57 const size_t buf_size,
83 [[nodiscard]]
bool ReadChildren(std::vector<T>* children);
96 bool ReadFourCC(FourCC* fourcc) {
100 *fourcc =
static_cast<FourCC
>(val);
104 FourCC type()
const {
return type_; }
107 BoxReader(
const uint8_t* buf,
size_t size);
116 bool ReadHeader(
bool* err);
120 typedef std::multimap<FourCC, std::unique_ptr<BoxReader>> ChildMap;
140 DCHECK(children->empty());
143 FourCC child_type = (*children)[0].BoxType();
145 ChildMap::iterator start_itr = children_.lower_bound(child_type);
146 ChildMap::iterator end_itr = children_.upper_bound(child_type);
147 children->resize(std::distance(start_itr, end_itr));
148 typename std::vector<T>::iterator child_itr = children->begin();
149 for (ChildMap::iterator itr = start_itr; itr != end_itr; ++itr) {
150 RCHECK(child_itr->Parse(itr->second.get()));
153 children_.erase(start_itr, end_itr);
155 DVLOG(2) <<
"Found " << children->size() <<
" " << FourCCToString(child_type)
165 while (pos() < size()) {
166 BoxReader child_reader(&data()[pos()], size() - pos());
168 if (!child_reader.ReadHeader(&err))
172 RCHECK(child.Parse(&child_reader));
173 children->push_back(child);