OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "content/browser/browser_thread_impl.h" | 15 #include "content/browser/browser_thread_impl.h" |
16 #include "content/browser/renderer_host/media/media_stream_manager.h" | 16 #include "content/browser/renderer_host/media/media_stream_manager.h" |
17 #include "content/browser/renderer_host/media/video_capture_host.h" | 17 #include "content/browser/renderer_host/media/video_capture_host.h" |
18 #include "content/browser/renderer_host/media/video_capture_manager.h" | 18 #include "content/browser/renderer_host/media/video_capture_manager.h" |
19 #include "content/common/media/video_capture_messages.h" | 19 #include "content/common/media/video_capture_messages.h" |
20 #include "content/public/test/mock_resource_context.h" | 20 #include "content/public/test/mock_resource_context.h" |
21 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
22 #include "media/audio/audio_manager.h" | 22 #include "media/audio/audio_manager.h" |
| 23 #include "media/base/video_frame.h" |
23 #include "media/video/capture/video_capture_types.h" | 24 #include "media/video/capture/video_capture_types.h" |
24 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 using ::testing::_; | 29 using ::testing::_; |
29 using ::testing::AtLeast; | 30 using ::testing::AtLeast; |
30 using ::testing::AnyNumber; | 31 using ::testing::AnyNumber; |
31 using ::testing::DoAll; | 32 using ::testing::DoAll; |
32 using ::testing::InSequence; | 33 using ::testing::InSequence; |
(...skipping 17 matching lines...) Expand all Loading... |
50 | 51 |
51 // Simple class used for dumping video to a file. This can be used for | 52 // Simple class used for dumping video to a file. This can be used for |
52 // verifying the output. | 53 // verifying the output. |
53 class DumpVideo { | 54 class DumpVideo { |
54 public: | 55 public: |
55 DumpVideo() : expected_size_(0) {} | 56 DumpVideo() : expected_size_(0) {} |
56 void StartDump(int width, int height) { | 57 void StartDump(int width, int height) { |
57 base::FilePath file_name = base::FilePath(base::StringPrintf( | 58 base::FilePath file_name = base::FilePath(base::StringPrintf( |
58 FILE_PATH_LITERAL("dump_w%d_h%d.yuv"), width, height)); | 59 FILE_PATH_LITERAL("dump_w%d_h%d.yuv"), width, height)); |
59 file_.reset(file_util::OpenFile(file_name, "wb")); | 60 file_.reset(file_util::OpenFile(file_name, "wb")); |
60 expected_size_ = width * height * 3 / 2; | 61 expected_size_ = |
| 62 media::VideoFrame::AllocationSize(media::VideoFrame::I420, |
| 63 gfx::Size(width, height)); |
61 } | 64 } |
62 void NewVideoFrame(const void* buffer) { | 65 void NewVideoFrame(const void* buffer) { |
63 if (file_.get() != NULL) { | 66 if (file_.get() != NULL) { |
64 fwrite(buffer, expected_size_, 1, file_.get()); | 67 fwrite(buffer, expected_size_, 1, file_.get()); |
65 } | 68 } |
66 } | 69 } |
67 | 70 |
68 private: | 71 private: |
69 file_util::ScopedFILE file_; | 72 file_util::ScopedFILE file_; |
70 int expected_size_; | 73 int expected_size_; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 #ifdef DUMP_VIDEO | 366 #ifdef DUMP_VIDEO |
364 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 367 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
365 CaptureAndDumpVideo(640, 480, 30); | 368 CaptureAndDumpVideo(640, 480, 30); |
366 } | 369 } |
367 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 370 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
368 CaptureAndDumpVideo(1280, 720, 30); | 371 CaptureAndDumpVideo(1280, 720, 30); |
369 } | 372 } |
370 #endif | 373 #endif |
371 | 374 |
372 } // namespace content | 375 } // namespace content |
OLD | NEW |