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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 bool BufferReader::ReadVec(std::vector<uint8_t>* vec, uint64_t count) { | 62 bool BufferReader::ReadVec(std::vector<uint8_t>* vec, uint64_t count) { |
63 RCHECK(HasBytes(count)); | 63 RCHECK(HasBytes(count)); |
64 vec->clear(); | 64 vec->clear(); |
65 vec->insert(vec->end(), buf_ + pos_, buf_ + pos_ + count); | 65 vec->insert(vec->end(), buf_ + pos_, buf_ + pos_ + count); |
66 pos_ += count; | 66 pos_ += count; |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
| 70 bool BufferReader::ReadString(std::string* v) { |
| 71 RCHECK(v); |
| 72 *v = ""; |
| 73 uint8_t c = 0; |
| 74 while (Read1(&c) && c != 0) { |
| 75 v->push_back(c); |
| 76 } |
| 77 // Return error if we didn't find the terminating zero character. |
| 78 if (c != 0) |
| 79 return false; |
| 80 return true; |
| 81 } |
| 82 |
70 bool BufferReader::SkipBytes(uint64_t bytes) { | 83 bool BufferReader::SkipBytes(uint64_t bytes) { |
71 RCHECK(HasBytes(bytes)); | 84 RCHECK(HasBytes(bytes)); |
72 pos_ += bytes; | 85 pos_ += bytes; |
73 return true; | 86 return true; |
74 } | 87 } |
75 | 88 |
76 bool BufferReader::Read4Into8(uint64_t* v) { | 89 bool BufferReader::Read4Into8(uint64_t* v) { |
77 uint32_t tmp; | 90 uint32_t tmp; |
78 RCHECK(Read4(&tmp)); | 91 RCHECK(Read4(&tmp)); |
79 *v = tmp; | 92 *v = tmp; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 291 } |
279 | 292 |
280 // Note that the pos_ head has advanced to the byte immediately after the | 293 // Note that the pos_ head has advanced to the byte immediately after the |
281 // header, which is where we want it. | 294 // header, which is where we want it. |
282 size_ = size; | 295 size_ = size; |
283 return true; | 296 return true; |
284 } | 297 } |
285 | 298 |
286 } // namespace mp4 | 299 } // namespace mp4 |
287 } // namespace media | 300 } // namespace media |
OLD | NEW |