OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 OpenVideoCaptureDevice(0, &capture_observer)); | 205 OpenVideoCaptureDevice(0, &capture_observer)); |
206 ASSERT_TRUE(module.get() != NULL); | 206 ASSERT_TRUE(module.get() != NULL); |
207 | 207 |
208 VideoCaptureCapability capability; | 208 VideoCaptureCapability capability; |
209 #ifndef WEBRTC_MAC | 209 #ifndef WEBRTC_MAC |
210 device_info_->GetCapability(module->CurrentDeviceName(), 0, capability); | 210 device_info_->GetCapability(module->CurrentDeviceName(), 0, capability); |
211 #else | 211 #else |
212 capability.width = kTestWidth; | 212 capability.width = kTestWidth; |
213 capability.height = kTestHeight; | 213 capability.height = kTestHeight; |
214 capability.maxFPS = kTestFramerate; | 214 capability.maxFPS = kTestFramerate; |
215 capability.rawType = webrtc::kVideoUnknown; | 215 capability.videoType = webrtc::VideoType::kUnknown; |
216 #endif | 216 #endif |
217 capture_observer.SetExpectedCapability(capability); | 217 capture_observer.SetExpectedCapability(capability); |
218 ASSERT_NO_FATAL_FAILURE(StartCapture(module.get(), capability)); | 218 ASSERT_NO_FATAL_FAILURE(StartCapture(module.get(), capability)); |
219 | 219 |
220 // Less than 4s to start the camera. | 220 // Less than 4s to start the camera. |
221 EXPECT_LE(rtc::TimeMillis() - start_time, 4000); | 221 EXPECT_LE(rtc::TimeMillis() - start_time, 4000); |
222 | 222 |
223 // Make sure 5 frames are captured. | 223 // Make sure 5 frames are captured. |
224 EXPECT_TRUE_WAIT(capture_observer.incoming_frames() >= 5, kTimeOut); | 224 EXPECT_TRUE_WAIT(capture_observer.incoming_frames() >= 5, kTimeOut); |
225 | 225 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 rtc::scoped_refptr<VideoCaptureModule> module1( | 312 rtc::scoped_refptr<VideoCaptureModule> module1( |
313 OpenVideoCaptureDevice(0, &capture_observer1)); | 313 OpenVideoCaptureDevice(0, &capture_observer1)); |
314 ASSERT_TRUE(module1.get() != NULL); | 314 ASSERT_TRUE(module1.get() != NULL); |
315 VideoCaptureCapability capability1; | 315 VideoCaptureCapability capability1; |
316 #ifndef WEBRTC_MAC | 316 #ifndef WEBRTC_MAC |
317 device_info_->GetCapability(module1->CurrentDeviceName(), 0, capability1); | 317 device_info_->GetCapability(module1->CurrentDeviceName(), 0, capability1); |
318 #else | 318 #else |
319 capability1.width = kTestWidth; | 319 capability1.width = kTestWidth; |
320 capability1.height = kTestHeight; | 320 capability1.height = kTestHeight; |
321 capability1.maxFPS = kTestFramerate; | 321 capability1.maxFPS = kTestFramerate; |
322 capability1.rawType = webrtc::kVideoUnknown; | 322 capability1.videoType = webrtc::VideoType::kUnknown; |
323 #endif | 323 #endif |
324 capture_observer1.SetExpectedCapability(capability1); | 324 capture_observer1.SetExpectedCapability(capability1); |
325 | 325 |
326 TestVideoCaptureCallback capture_observer2; | 326 TestVideoCaptureCallback capture_observer2; |
327 rtc::scoped_refptr<VideoCaptureModule> module2( | 327 rtc::scoped_refptr<VideoCaptureModule> module2( |
328 OpenVideoCaptureDevice(1, &capture_observer2)); | 328 OpenVideoCaptureDevice(1, &capture_observer2)); |
329 ASSERT_TRUE(module1.get() != NULL); | 329 ASSERT_TRUE(module1.get() != NULL); |
330 | 330 |
331 | 331 |
332 VideoCaptureCapability capability2; | 332 VideoCaptureCapability capability2; |
333 #ifndef WEBRTC_MAC | 333 #ifndef WEBRTC_MAC |
334 device_info_->GetCapability(module2->CurrentDeviceName(), 0, capability2); | 334 device_info_->GetCapability(module2->CurrentDeviceName(), 0, capability2); |
335 #else | 335 #else |
336 capability2.width = kTestWidth; | 336 capability2.width = kTestWidth; |
337 capability2.height = kTestHeight; | 337 capability2.height = kTestHeight; |
338 capability2.maxFPS = kTestFramerate; | 338 capability2.maxFPS = kTestFramerate; |
339 capability2.rawType = webrtc::kVideoUnknown; | 339 capability2.videoType = webrtc::VideoType::kUnknown; |
340 #endif | 340 #endif |
341 capture_observer2.SetExpectedCapability(capability2); | 341 capture_observer2.SetExpectedCapability(capability2); |
342 | 342 |
343 ASSERT_NO_FATAL_FAILURE(StartCapture(module1.get(), capability1)); | 343 ASSERT_NO_FATAL_FAILURE(StartCapture(module1.get(), capability1)); |
344 ASSERT_NO_FATAL_FAILURE(StartCapture(module2.get(), capability2)); | 344 ASSERT_NO_FATAL_FAILURE(StartCapture(module2.get(), capability2)); |
345 EXPECT_TRUE_WAIT(capture_observer1.incoming_frames() >= 5, kTimeOut); | 345 EXPECT_TRUE_WAIT(capture_observer1.incoming_frames() >= 5, kTimeOut); |
346 EXPECT_TRUE_WAIT(capture_observer2.incoming_frames() >= 5, kTimeOut); | 346 EXPECT_TRUE_WAIT(capture_observer2.incoming_frames() >= 5, kTimeOut); |
347 EXPECT_EQ(0, module2->StopCapture()); | 347 EXPECT_EQ(0, module2->StopCapture()); |
348 EXPECT_EQ(0, module1->StopCapture()); | 348 EXPECT_EQ(0, module1->StopCapture()); |
349 } | 349 } |
350 | 350 |
351 // Test class for testing external capture and capture feedback information | 351 // Test class for testing external capture and capture feedback information |
352 // such as frame rate and picture alarm. | 352 // such as frame rate and picture alarm. |
353 class VideoCaptureExternalTest : public testing::Test { | 353 class VideoCaptureExternalTest : public testing::Test { |
354 public: | 354 public: |
355 void SetUp() { | 355 void SetUp() { |
356 capture_module_ = VideoCaptureFactory::Create(capture_input_interface_); | 356 capture_module_ = VideoCaptureFactory::Create(capture_input_interface_); |
357 | 357 |
358 VideoCaptureCapability capability; | 358 VideoCaptureCapability capability; |
359 capability.width = kTestWidth; | 359 capability.width = kTestWidth; |
360 capability.height = kTestHeight; | 360 capability.height = kTestHeight; |
361 capability.rawType = webrtc::kVideoYV12; | 361 capability.videoType = webrtc::VideoType::kYV12; |
362 capability.maxFPS = kTestFramerate; | 362 capability.maxFPS = kTestFramerate; |
363 capture_callback_.SetExpectedCapability(capability); | 363 capture_callback_.SetExpectedCapability(capability); |
364 | 364 |
365 rtc::scoped_refptr<webrtc::I420Buffer> buffer = webrtc::I420Buffer::Create( | 365 rtc::scoped_refptr<webrtc::I420Buffer> buffer = webrtc::I420Buffer::Create( |
366 kTestWidth, kTestHeight, | 366 kTestWidth, kTestHeight, |
367 kTestWidth, ((kTestWidth + 1) / 2), (kTestWidth + 1) / 2); | 367 kTestWidth, ((kTestWidth + 1) / 2), (kTestWidth + 1) / 2); |
368 | 368 |
369 memset(buffer->MutableDataY(), 127, kTestWidth * kTestHeight); | 369 memset(buffer->MutableDataY(), 127, kTestWidth * kTestHeight); |
370 memset(buffer->MutableDataU(), 127, | 370 memset(buffer->MutableDataU(), 127, |
371 ((kTestWidth + 1) / 2) * ((kTestHeight + 1) / 2)); | 371 ((kTestWidth + 1) / 2) * ((kTestHeight + 1) / 2)); |
(...skipping 11 matching lines...) Expand all Loading... |
383 } | 383 } |
384 | 384 |
385 webrtc::VideoCaptureExternal* capture_input_interface_; | 385 webrtc::VideoCaptureExternal* capture_input_interface_; |
386 rtc::scoped_refptr<VideoCaptureModule> capture_module_; | 386 rtc::scoped_refptr<VideoCaptureModule> capture_module_; |
387 std::unique_ptr<webrtc::VideoFrame> test_frame_; | 387 std::unique_ptr<webrtc::VideoFrame> test_frame_; |
388 TestVideoCaptureCallback capture_callback_; | 388 TestVideoCaptureCallback capture_callback_; |
389 }; | 389 }; |
390 | 390 |
391 // Test input of external video frames. | 391 // Test input of external video frames. |
392 TEST_F(VideoCaptureExternalTest, TestExternalCapture) { | 392 TEST_F(VideoCaptureExternalTest, TestExternalCapture) { |
393 size_t length = webrtc::CalcBufferSize(webrtc::kI420, | 393 size_t length = webrtc::CalcBufferSize( |
394 test_frame_->width(), | 394 webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); |
395 test_frame_->height()); | |
396 std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]); | 395 std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]); |
397 webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); | 396 webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); |
398 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 397 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
399 length, capture_callback_.capability(), 0)); | 398 length, capture_callback_.capability(), 0)); |
400 EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_)); | 399 EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_)); |
401 } | 400 } |
402 | 401 |
403 TEST_F(VideoCaptureExternalTest, Rotation) { | 402 TEST_F(VideoCaptureExternalTest, Rotation) { |
404 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_0)); | 403 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_0)); |
405 size_t length = webrtc::CalcBufferSize(webrtc::kI420, | 404 size_t length = webrtc::CalcBufferSize( |
406 test_frame_->width(), | 405 webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); |
407 test_frame_->height()); | |
408 std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]); | 406 std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]); |
409 webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); | 407 webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); |
410 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 408 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
411 length, capture_callback_.capability(), 0)); | 409 length, capture_callback_.capability(), 0)); |
412 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90)); | 410 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90)); |
413 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90); | 411 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90); |
414 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 412 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
415 length, capture_callback_.capability(), 0)); | 413 length, capture_callback_.capability(), 0)); |
416 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); | 414 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); |
417 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); | 415 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); |
418 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 416 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
419 length, capture_callback_.capability(), 0)); | 417 length, capture_callback_.capability(), 0)); |
420 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); | 418 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); |
421 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); | 419 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); |
422 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 420 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
423 length, capture_callback_.capability(), 0)); | 421 length, capture_callback_.capability(), 0)); |
424 } | 422 } |
OLD | NEW |