Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: media/mp4/box_reader.h

Issue 10938034: Eliminate box reordering in media::mp4::BoxReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/mp4/box_definitions.cc ('k') | media/mp4/box_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_MP4_BOX_READER_H_ 5 #ifndef MEDIA_MP4_BOX_READER_H_
6 #define MEDIA_MP4_BOX_READER_H_ 6 #define MEDIA_MP4_BOX_READER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Read at least one child. False means error or no such child present. 111 // Read at least one child. False means error or no such child present.
112 template<typename T> bool ReadChildren( 112 template<typename T> bool ReadChildren(
113 std::vector<T>* children) WARN_UNUSED_RESULT; 113 std::vector<T>* children) WARN_UNUSED_RESULT;
114 114
115 // Read any number of children. False means error. 115 // Read any number of children. False means error.
116 template<typename T> bool MaybeReadChildren( 116 template<typename T> bool MaybeReadChildren(
117 std::vector<T>* children) WARN_UNUSED_RESULT; 117 std::vector<T>* children) WARN_UNUSED_RESULT;
118 118
119 // Read all children, regardless of FourCC. This is used from exactly one box, 119 // Read all children, regardless of FourCC. This is used from exactly one box,
120 // corresponding to a rather significant inconsistency in the BMFF spec. 120 // corresponding to a rather significant inconsistency in the BMFF spec.
121 // Note that this method is mutually exclusive with ScanChildren().
121 template<typename T> bool ReadAllChildren( 122 template<typename T> bool ReadAllChildren(
122 std::vector<T>* children) WARN_UNUSED_RESULT; 123 std::vector<T>* children) WARN_UNUSED_RESULT;
123 124
124 // Populate the values of 'version()' and 'flags()' from a full box header. 125 // Populate the values of 'version()' and 'flags()' from a full box header.
125 // Many boxes, but not all, use these values. This call should happen after 126 // Many boxes, but not all, use these values. This call should happen after
126 // the box has been initialized, and does not re-read the main box header. 127 // the box has been initialized, and does not re-read the main box header.
127 bool ReadFullBoxHeader() WARN_UNUSED_RESULT; 128 bool ReadFullBoxHeader() WARN_UNUSED_RESULT;
128 129
129 FourCC type() const { return type_; } 130 FourCC type() const { return type_; }
130 uint8 version() const { return version_; } 131 uint8 version() const { return version_; }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 179 }
179 children_.erase(start_itr, end_itr); 180 children_.erase(start_itr, end_itr);
180 181
181 DVLOG(2) << "Found " << children->size() << " " 182 DVLOG(2) << "Found " << children->size() << " "
182 << FourCCToString(child_type) << " boxes."; 183 << FourCCToString(child_type) << " boxes.";
183 return true; 184 return true;
184 } 185 }
185 186
186 template<typename T> 187 template<typename T>
187 bool BoxReader::ReadAllChildren(std::vector<T>* children) { 188 bool BoxReader::ReadAllChildren(std::vector<T>* children) {
188 DCHECK(scanned_); 189 DCHECK(!scanned_);
189 DCHECK(children->empty()); 190 scanned_ = true;
190 RCHECK(!children_.empty());
191 191
192 children->resize(children_.size()); 192 bool err = false;
193 typename std::vector<T>::iterator child_itr = children->begin(); 193 while (pos() < size()) {
194 for (ChildMap::iterator itr = children_.begin(); 194 BoxReader child_reader(&buf_[pos_], size_ - pos_);
195 itr != children_.end(); ++itr) { 195 if (!child_reader.ReadHeader(&err)) break;
196 RCHECK(child_itr->Parse(&itr->second)); 196 T child;
197 ++child_itr; 197 RCHECK(child.Parse(&child_reader));
198 children->push_back(child);
199 pos_ += child_reader.size();
198 } 200 }
199 children_.clear(); 201
200 return true; 202 return !err;
201 } 203 }
202 204
203 } // namespace mp4 205 } // namespace mp4
204 } // namespace media 206 } // namespace media
205 207
206 #endif // MEDIA_MP4_BOX_READER_H_ 208 #endif // MEDIA_MP4_BOX_READER_H_
OLDNEW
« no previous file with comments | « media/mp4/box_definitions.cc ('k') | media/mp4/box_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698