45 const size_t buf_size,
57 [[nodiscard]]
static bool StartBox(
const uint8_t* buf,
58 const size_t buf_size,
84 [[nodiscard]]
bool ReadChildren(std::vector<T>* children);
97 bool ReadFourCC(FourCC* fourcc) {
101 *fourcc =
static_cast<FourCC
>(val);
105 FourCC type()
const {
return type_; }
108 BoxReader(
const uint8_t* buf,
size_t size);
117 bool ReadHeader(
bool* err);
121 typedef std::multimap<FourCC, std::unique_ptr<BoxReader>> ChildMap;
141 DCHECK(children->empty());
144 FourCC child_type = (*children)[0].BoxType();
146 ChildMap::iterator start_itr = children_.lower_bound(child_type);
147 ChildMap::iterator end_itr = children_.upper_bound(child_type);
148 children->resize(std::distance(start_itr, end_itr));
149 typename std::vector<T>::iterator child_itr = children->begin();
150 for (ChildMap::iterator itr = start_itr; itr != end_itr; ++itr) {
151 RCHECK(child_itr->Parse(itr->second.get()));
154 children_.erase(start_itr, end_itr);
156 DVLOG(2) <<
"Found " << children->size() <<
" " << FourCCToString(child_type)
166 while (pos() < size()) {
167 BoxReader child_reader(&data()[pos()], size() - pos());
169 if (!child_reader.ReadHeader(&err))
173 RCHECK(child.Parse(&child_reader));
174 children->push_back(child);