| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "media/formats/mp4/box_reader.h" | 5 #include "media/formats/mp4/box_reader.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (!child.ReadHeader(&err)) break; | 176 if (!child.ReadHeader(&err)) break; |
| 177 | 177 |
| 178 children_.insert(std::pair<FourCC, BoxReader>(child.type(), child)); | 178 children_.insert(std::pair<FourCC, BoxReader>(child.type(), child)); |
| 179 pos_ += child.size(); | 179 pos_ += child.size(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 DCHECK(!err); | 182 DCHECK(!err); |
| 183 return !err && pos() == size(); | 183 return !err && pos() == size(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool BoxReader::HasChild(Box* child) { |
| 187 DCHECK(scanned_); |
| 188 DCHECK(child); |
| 189 return children_.count(child->BoxType()) > 0; |
| 190 } |
| 191 |
| 186 bool BoxReader::ReadChild(Box* child) { | 192 bool BoxReader::ReadChild(Box* child) { |
| 187 DCHECK(scanned_); | 193 DCHECK(scanned_); |
| 188 FourCC child_type = child->BoxType(); | 194 FourCC child_type = child->BoxType(); |
| 189 | 195 |
| 190 ChildMap::iterator itr = children_.find(child_type); | 196 ChildMap::iterator itr = children_.find(child_type); |
| 191 RCHECK(itr != children_.end()); | 197 RCHECK(itr != children_.end()); |
| 192 DVLOG(2) << "Found a " << FourCCToString(child_type) << " box."; | 198 DVLOG(2) << "Found a " << FourCCToString(child_type) << " box."; |
| 193 RCHECK(child->Parse(&itr->second)); | 199 RCHECK(child->Parse(&itr->second)); |
| 194 children_.erase(itr); | 200 children_.erase(itr); |
| 195 return true; | 201 return true; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 239 } |
| 234 | 240 |
| 235 // Note that the pos_ head has advanced to the byte immediately after the | 241 // Note that the pos_ head has advanced to the byte immediately after the |
| 236 // header, which is where we want it. | 242 // header, which is where we want it. |
| 237 size_ = size; | 243 size_ = size; |
| 238 return true; | 244 return true; |
| 239 } | 245 } |
| 240 | 246 |
| 241 } // namespace mp4 | 247 } // namespace mp4 |
| 242 } // namespace media | 248 } // namespace media |
| OLD | NEW |