43 const size_t buf_size,
55 [[nodiscard]]
static bool StartBox(
const uint8_t* buf,
56 const size_t buf_size,
82 [[nodiscard]]
bool ReadChildren(std::vector<T>* children);
95 bool ReadFourCC(FourCC* fourcc) {
99 *fourcc =
static_cast<FourCC
>(val);
103 FourCC type()
const {
return type_; }
106 BoxReader(
const uint8_t* buf,
size_t size);
115 bool ReadHeader(
bool* err);
119 typedef std::multimap<FourCC, std::unique_ptr<BoxReader>> ChildMap;
139 DCHECK(children->empty());
142 FourCC child_type = (*children)[0].BoxType();
144 ChildMap::iterator start_itr = children_.lower_bound(child_type);
145 ChildMap::iterator end_itr = children_.upper_bound(child_type);
146 children->resize(std::distance(start_itr, end_itr));
147 typename std::vector<T>::iterator child_itr = children->begin();
148 for (ChildMap::iterator itr = start_itr; itr != end_itr; ++itr) {
149 RCHECK(child_itr->Parse(itr->second.get()));
152 children_.erase(start_itr, end_itr);
154 DVLOG(2) <<
"Found " << children->size() <<
" " << FourCCToString(child_type)
164 while (pos() < size()) {
165 BoxReader child_reader(&data()[pos()], size() - pos());
167 if (!child_reader.ReadHeader(&err))
171 RCHECK(child.Parse(&child_reader));
172 children->push_back(child);