OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // Define to use a real video capture device. | 42 // Define to use a real video capture device. |
43 // #define TEST_REAL_CAPTURE_DEVICE | 43 // #define TEST_REAL_CAPTURE_DEVICE |
44 | 44 |
45 // Simple class used for dumping video to a file. This can be used for | 45 // Simple class used for dumping video to a file. This can be used for |
46 // verifying the output. | 46 // verifying the output. |
47 class DumpVideo { | 47 class DumpVideo { |
48 public: | 48 public: |
49 DumpVideo() : expected_size_(0) {} | 49 DumpVideo() : expected_size_(0) {} |
50 void StartDump(int width, int height) { | 50 void StartDump(int width, int height) { |
51 // Create an FilePath that works on all platforms. There should | 51 FilePath file_name = FilePath( |
52 // be a better way. | 52 StringPrintf(FILE_PATH_LITERAL("dump_w%d_h%d.yuv"), width, height)); |
53 FilePath file_name = | |
54 FilePath::FromWStringHack(StringPrintf(L"dump_w%d_h%d.yuv", width, | |
55 height)); | |
56 file_.reset(file_util::OpenFile(file_name, "wb")); | 53 file_.reset(file_util::OpenFile(file_name, "wb")); |
57 expected_size_ = width * height * 3 / 2; | 54 expected_size_ = width * height * 3 / 2; |
58 } | 55 } |
59 void NewVideoFrame(const void* buffer) { | 56 void NewVideoFrame(const void* buffer) { |
60 if (file_.get() != NULL) { | 57 if (file_.get() != NULL) { |
61 fwrite(buffer, expected_size_, 1, file_.get()); | 58 fwrite(buffer, expected_size_, 1, file_.get()); |
62 } | 59 } |
63 } | 60 } |
64 | 61 |
65 private: | 62 private: |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 373 } |
377 | 374 |
378 #ifdef DUMP_VIDEO | 375 #ifdef DUMP_VIDEO |
379 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 376 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
380 CaptureAndDumpVideo(640, 480, 30); | 377 CaptureAndDumpVideo(640, 480, 30); |
381 } | 378 } |
382 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 379 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
383 CaptureAndDumpVideo(1280, 720, 30); | 380 CaptureAndDumpVideo(1280, 720, 30); |
384 } | 381 } |
385 #endif | 382 #endif |
OLD | NEW |