| 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" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return_buffers_(false), | 112 return_buffers_(false), |
| 113 dump_video_(false) {} | 113 dump_video_(false) {} |
| 114 | 114 |
| 115 // A list of mock methods. | 115 // A list of mock methods. |
| 116 MOCK_METHOD4(OnNewBufferCreated, | 116 MOCK_METHOD4(OnNewBufferCreated, |
| 117 void(int device_id, base::SharedMemoryHandle handle, | 117 void(int device_id, base::SharedMemoryHandle handle, |
| 118 int length, int buffer_id)); | 118 int length, int buffer_id)); |
| 119 MOCK_METHOD2(OnBufferFreed, | 119 MOCK_METHOD2(OnBufferFreed, |
| 120 void(int device_id, int buffer_id)); | 120 void(int device_id, int buffer_id)); |
| 121 MOCK_METHOD4(OnBufferFilled, | 121 MOCK_METHOD4(OnBufferFilled, |
| 122 void(int device_id, int buffer_id, base::Time timestamp, | 122 void(int device_id, |
| 123 int buffer_id, |
| 124 base::TimeTicks timestamp, |
| 123 const media::VideoCaptureFormat& format)); | 125 const media::VideoCaptureFormat& format)); |
| 124 MOCK_METHOD2(OnStateChanged, void(int device_id, VideoCaptureState state)); | 126 MOCK_METHOD2(OnStateChanged, void(int device_id, VideoCaptureState state)); |
| 125 | 127 |
| 126 // Use class DumpVideo to write I420 video to file. | 128 // Use class DumpVideo to write I420 video to file. |
| 127 void SetDumpVideo(bool enable) { | 129 void SetDumpVideo(bool enable) { |
| 128 dump_video_ = enable; | 130 dump_video_ = enable; |
| 129 } | 131 } |
| 130 | 132 |
| 131 void SetReturnReceivedDibs(bool enable) { | 133 void SetReturnReceivedDibs(bool enable) { |
| 132 return_buffers_ = enable; | 134 return_buffers_ = enable; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 198 |
| 197 std::map<int, base::SharedMemory*>::iterator it = | 199 std::map<int, base::SharedMemory*>::iterator it = |
| 198 filled_dib_.find(buffer_id); | 200 filled_dib_.find(buffer_id); |
| 199 ASSERT_TRUE(it != filled_dib_.end()); | 201 ASSERT_TRUE(it != filled_dib_.end()); |
| 200 delete it->second; | 202 delete it->second; |
| 201 filled_dib_.erase(it); | 203 filled_dib_.erase(it); |
| 202 } | 204 } |
| 203 | 205 |
| 204 void OnBufferFilledDispatch(int device_id, | 206 void OnBufferFilledDispatch(int device_id, |
| 205 int buffer_id, | 207 int buffer_id, |
| 206 base::Time timestamp, | 208 base::TimeTicks timestamp, |
| 207 const media::VideoCaptureFormat& frame_format) { | 209 const media::VideoCaptureFormat& frame_format) { |
| 208 base::SharedMemory* dib = filled_dib_[buffer_id]; | 210 base::SharedMemory* dib = filled_dib_[buffer_id]; |
| 209 ASSERT_TRUE(dib != NULL); | 211 ASSERT_TRUE(dib != NULL); |
| 210 if (dump_video_) { | 212 if (dump_video_) { |
| 211 if (!format_.IsValid()) { | 213 if (!format_.IsValid()) { |
| 212 dumper_.StartDump(frame_format.frame_size.width(), | 214 dumper_.StartDump(frame_format.frame_size.width(), |
| 213 frame_format.frame_size.height()); | 215 frame_format.frame_size.height()); |
| 214 format_ = frame_format; | 216 format_ = frame_format; |
| 215 } | 217 } |
| 216 ASSERT_EQ(format_.frame_size.width(), frame_format.frame_size.width()) | 218 ASSERT_EQ(format_.frame_size.width(), frame_format.frame_size.width()) |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 #ifdef DUMP_VIDEO | 503 #ifdef DUMP_VIDEO |
| 502 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 504 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
| 503 CaptureAndDumpVideo(640, 480, 30); | 505 CaptureAndDumpVideo(640, 480, 30); |
| 504 } | 506 } |
| 505 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 507 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
| 506 CaptureAndDumpVideo(1280, 720, 30); | 508 CaptureAndDumpVideo(1280, 720, 30); |
| 507 } | 509 } |
| 508 #endif | 510 #endif |
| 509 | 511 |
| 510 } // namespace content | 512 } // namespace content |
| OLD | NEW |