OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/base/test_data_util.h" |
| 6 |
| 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" |
| 9 |
| 10 namespace media { |
| 11 |
| 12 void ReadTestDataFile(const std::string& name, scoped_array<uint8>* buffer, |
| 13 int* size) { |
| 14 FilePath file_path; |
| 15 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); |
| 16 |
| 17 file_path = file_path.Append(FILE_PATH_LITERAL("media")) |
| 18 .Append(FILE_PATH_LITERAL("test")) |
| 19 .Append(FILE_PATH_LITERAL("data")) |
| 20 .AppendASCII(name); |
| 21 |
| 22 int64 tmp = 0; |
| 23 CHECK(file_util::GetFileSize(file_path, &tmp)) |
| 24 << "Failed to get file size for '" << name << "'"; |
| 25 |
| 26 int file_size = static_cast<int>(tmp); |
| 27 buffer->reset(new uint8[file_size]); |
| 28 |
| 29 CHECK(file_size == file_util::ReadFile(file_path, |
| 30 reinterpret_cast<char*>(buffer->get()), |
| 31 file_size)) |
| 32 << "Failed to read '" << name << "'"; |
| 33 *size = file_size; |
| 34 } |
| 35 |
| 36 void ReadTestDataFile(const std::string& name, scoped_refptr<Buffer>* buffer) { |
| 37 scoped_array<uint8> buf; |
| 38 int buf_size; |
| 39 ReadTestDataFile(name, &buf, &buf_size); |
| 40 *buffer = new DataBuffer(buf.release(), buf_size); |
| 41 } |
| 42 |
| 43 } // namespace media |
OLD | NEW |