| 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 |
| 9 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <memory> |
| 10 #include <set> | 12 #include <set> |
| 11 | 13 |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "media/formats/mp4/box_definitions.h" | 14 #include "media/formats/mp4/box_definitions.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 namespace mp4 { | 17 namespace mp4 { |
| 17 | 18 |
| 18 Box::~Box() {} | 19 Box::~Box() {} |
| 19 | 20 |
| 20 bool BufferReader::Read1(uint8_t* v) { | 21 bool BufferReader::Read1(uint8_t* v) { |
| 21 RCHECK(HasBytes(1)); | 22 RCHECK(HasBytes(1)); |
| 22 *v = buf_[pos_++]; | 23 *v = buf_[pos_++]; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 DVLOG(1) << "Skipping unknown box: " << FourCCToString(itr->first); | 110 DVLOG(1) << "Skipping unknown box: " << FourCCToString(itr->first); |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 | 114 |
| 114 // static | 115 // static |
| 115 BoxReader* BoxReader::ReadTopLevelBox(const uint8_t* buf, | 116 BoxReader* BoxReader::ReadTopLevelBox(const uint8_t* buf, |
| 116 const int buf_size, | 117 const int buf_size, |
| 117 const scoped_refptr<MediaLog>& media_log, | 118 const scoped_refptr<MediaLog>& media_log, |
| 118 bool* err) { | 119 bool* err) { |
| 119 scoped_ptr<BoxReader> reader(new BoxReader(buf, buf_size, media_log, false)); | 120 std::unique_ptr<BoxReader> reader( |
| 121 new BoxReader(buf, buf_size, media_log, false)); |
| 120 if (!reader->ReadHeader(err)) | 122 if (!reader->ReadHeader(err)) |
| 121 return NULL; | 123 return NULL; |
| 122 | 124 |
| 123 if (!IsValidTopLevelBox(reader->type(), media_log)) { | 125 if (!IsValidTopLevelBox(reader->type(), media_log)) { |
| 124 *err = true; | 126 *err = true; |
| 125 return NULL; | 127 return NULL; |
| 126 } | 128 } |
| 127 | 129 |
| 128 if (reader->size() <= static_cast<uint64_t>(buf_size)) | 130 if (reader->size() <= static_cast<uint64_t>(buf_size)) |
| 129 return reader.release(); | 131 return reader.release(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 282 } |
| 281 | 283 |
| 282 // Note that the pos_ head has advanced to the byte immediately after the | 284 // Note that the pos_ head has advanced to the byte immediately after the |
| 283 // header, which is where we want it. | 285 // header, which is where we want it. |
| 284 size_ = size; | 286 size_ = size; |
| 285 return true; | 287 return true; |
| 286 } | 288 } |
| 287 | 289 |
| 288 } // namespace mp4 | 290 } // namespace mp4 |
| 289 } // namespace media | 291 } // namespace media |
| OLD | NEW |