5 #ifndef MEDIA_FORMATS_MP4_BOX_READER_H_
6 #define MEDIA_FORMATS_MP4_BOX_READER_H_
11 #include "packager/base/compiler_specific.h"
12 #include "packager/base/logging.h"
13 #include "packager/media/base/buffer_reader.h"
14 #include "packager/media/base/fourccs.h"
15 #include "packager/media/base/rcheck.h"
39 const size_t buf_size,
52 const size_t buf_size,
55 bool* err) WARN_UNUSED_RESULT;
84 bool ReadChildren(std::vector<T>* children) WARN_UNUSED_RESULT;
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, BoxReader*> ChildMap;
132 template <
typename T>
138 template <
typename T>
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));
155 children_.erase(start_itr, end_itr);
157 DVLOG(2) <<
"Found " << children->size() <<
" " << FourCCToString(child_type)
162 template <
typename T>
167 while (pos() < size()) {
168 BoxReader child_reader(&data()[pos()], size() - pos());
170 if (!child_reader.ReadHeader(&err))
174 RCHECK(child.Parse(&child_reader));
175 children->push_back(child);
186 #endif // MEDIA_FORMATS_MP4_BOX_READER_H_