Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: content/browser/renderer_host/media/video_capture_host_unittest.cc

Issue 22875047: EVEA cleanup: use video utility functions in media::* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: b2b1b2ee Last comments. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_ = media::VideoFrame::AllocationSize(
62 media::VideoFrame::I420, gfx::Size(width, height));
61 } 63 }
62 void NewVideoFrame(const void* buffer) { 64 void NewVideoFrame(const void* buffer) {
63 if (file_.get() != NULL) { 65 if (file_.get() != NULL) {
64 fwrite(buffer, expected_size_, 1, file_.get()); 66 fwrite(buffer, expected_size_, 1, file_.get());
65 } 67 }
66 } 68 }
67 69
68 private: 70 private:
69 file_util::ScopedFILE file_; 71 file_util::ScopedFILE file_;
70 int expected_size_; 72 int expected_size_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 IPC_END_MESSAGE_MAP() 141 IPC_END_MESSAGE_MAP()
140 EXPECT_TRUE(handled); 142 EXPECT_TRUE(handled);
141 143
142 delete message; 144 delete message;
143 return true; 145 return true;
144 } 146 }
145 147
146 // These handler methods do minimal things and delegate to the mock methods. 148 // These handler methods do minimal things and delegate to the mock methods.
147 void OnNewBufferCreatedDispatch(int device_id, 149 void OnNewBufferCreatedDispatch(int device_id,
148 base::SharedMemoryHandle handle, 150 base::SharedMemoryHandle handle,
149 int length, int buffer_id) { 151 uint32 length,
152 int buffer_id) {
150 OnNewBufferCreated(device_id, handle, length, buffer_id); 153 OnNewBufferCreated(device_id, handle, length, buffer_id);
151 base::SharedMemory* dib = new base::SharedMemory(handle, false); 154 base::SharedMemory* dib = new base::SharedMemory(handle, false);
152 dib->Map(length); 155 dib->Map(length);
153 filled_dib_[buffer_id] = dib; 156 filled_dib_[buffer_id] = dib;
154 } 157 }
155 158
156 void OnBufferFilledDispatch(int device_id, int buffer_id, 159 void OnBufferFilledDispatch(int device_id, int buffer_id,
157 base::Time timestamp) { 160 base::Time timestamp) {
158 if (dump_video_) { 161 if (dump_video_) {
159 base::SharedMemory* dib = filled_dib_[buffer_id]; 162 base::SharedMemory* dib = filled_dib_[buffer_id];
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 #ifdef DUMP_VIDEO 365 #ifdef DUMP_VIDEO
363 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { 366 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
364 CaptureAndDumpVideo(640, 480, 30); 367 CaptureAndDumpVideo(640, 480, 30);
365 } 368 }
366 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { 369 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
367 CaptureAndDumpVideo(1280, 720, 30); 370 CaptureAndDumpVideo(1280, 720, 30);
368 } 371 }
369 #endif 372 #endif
370 373
371 } // namespace content 374 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698