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 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 #include <memory> | 14 #include <memory> |
15 #include <sstream> | 15 #include <sstream> |
16 | 16 |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "webrtc/test/gtest.h" |
18 #include "webrtc/base/scoped_ref_ptr.h" | 18 #include "webrtc/base/scoped_ref_ptr.h" |
19 #include "webrtc/base/timeutils.h" | 19 #include "webrtc/base/timeutils.h" |
20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
21 #include "webrtc/modules/utility/include/process_thread.h" | 21 #include "webrtc/modules/utility/include/process_thread.h" |
22 #include "webrtc/modules/video_capture/video_capture.h" | 22 #include "webrtc/modules/video_capture/video_capture.h" |
23 #include "webrtc/modules/video_capture/video_capture_factory.h" | 23 #include "webrtc/modules/video_capture/video_capture_factory.h" |
24 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 24 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
25 #include "webrtc/system_wrappers/include/sleep.h" | 25 #include "webrtc/system_wrappers/include/sleep.h" |
26 #include "webrtc/test/frame_utils.h" | 26 #include "webrtc/test/frame_utils.h" |
27 #include "webrtc/video_frame.h" | 27 #include "webrtc/video_frame.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ~TestVideoCaptureCallback() { | 73 ~TestVideoCaptureCallback() { |
74 if (timing_warnings_ > 0) | 74 if (timing_warnings_ > 0) |
75 printf("No of timing warnings %d\n", timing_warnings_); | 75 printf("No of timing warnings %d\n", timing_warnings_); |
76 } | 76 } |
77 | 77 |
78 virtual void OnIncomingCapturedFrame(const int32_t id, | 78 virtual void OnIncomingCapturedFrame(const int32_t id, |
79 const webrtc::VideoFrame& videoFrame) { | 79 const webrtc::VideoFrame& videoFrame) { |
80 CriticalSectionScoped cs(capture_cs_.get()); | 80 CriticalSectionScoped cs(capture_cs_.get()); |
81 int height = videoFrame.height(); | 81 int height = videoFrame.height(); |
82 int width = videoFrame.width(); | 82 int width = videoFrame.width(); |
83 #if ANDROID | 83 #if defined(ANDROID) && ANDROID |
84 // Android camera frames may be rotated depending on test device | 84 // Android camera frames may be rotated depending on test device |
85 // orientation. | 85 // orientation. |
86 EXPECT_TRUE(height == capability_.height || height == capability_.width); | 86 EXPECT_TRUE(height == capability_.height || height == capability_.width); |
87 EXPECT_TRUE(width == capability_.width || width == capability_.height); | 87 EXPECT_TRUE(width == capability_.width || width == capability_.height); |
88 #else | 88 #else |
89 EXPECT_EQ(height, capability_.height); | 89 EXPECT_EQ(height, capability_.height); |
90 EXPECT_EQ(width, capability_.width); | 90 EXPECT_EQ(width, capability_.width); |
91 EXPECT_EQ(rotate_frame_, videoFrame.rotation()); | 91 EXPECT_EQ(rotate_frame_, videoFrame.rotation()); |
92 #endif | 92 #endif |
93 // RenderTimstamp should be the time now. | 93 // RenderTimstamp should be the time now. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 continue; | 330 continue; |
331 | 331 |
332 capture_observer.SetExpectedCapability(capability); | 332 capture_observer.SetExpectedCapability(capability); |
333 ASSERT_NO_FATAL_FAILURE(StartCapture(module.get(), capability)); | 333 ASSERT_NO_FATAL_FAILURE(StartCapture(module.get(), capability)); |
334 // Make sure at least one frame is captured. | 334 // Make sure at least one frame is captured. |
335 EXPECT_TRUE_WAIT(capture_observer.incoming_frames() >= 1, kTimeOut); | 335 EXPECT_TRUE_WAIT(capture_observer.incoming_frames() >= 1, kTimeOut); |
336 | 336 |
337 EXPECT_EQ(0, module->StopCapture()); | 337 EXPECT_EQ(0, module->StopCapture()); |
338 } | 338 } |
339 | 339 |
340 #if ANDROID | 340 #if defined(ANDROID) && ANDROID |
341 // There's no reason for this to _necessarily_ be true, but in practice all | 341 // There's no reason for this to _necessarily_ be true, but in practice all |
342 // Android devices this test runs on in fact do support multiple capture | 342 // Android devices this test runs on in fact do support multiple capture |
343 // resolutions and multiple frame-rates per captured resolution, so we assert | 343 // resolutions and multiple frame-rates per captured resolution, so we assert |
344 // this fact here as a regression-test against the time that we only noticed a | 344 // this fact here as a regression-test against the time that we only noticed a |
345 // single frame-rate per resolution (bug 2974). If this test starts being run | 345 // single frame-rate per resolution (bug 2974). If this test starts being run |
346 // on devices for which this is untrue (e.g. Nexus4) then the following should | 346 // on devices for which this is untrue (e.g. Nexus4) then the following should |
347 // probably be wrapped in a base::android::BuildInfo::model()/device() check. | 347 // probably be wrapped in a base::android::BuildInfo::model()/device() check. |
348 EXPECT_GT(frame_rates_by_resolution.size(), 1U); | 348 EXPECT_GT(frame_rates_by_resolution.size(), 1U); |
349 for (FrameRatesByResolution::const_iterator it = | 349 for (FrameRatesByResolution::const_iterator it = |
350 frame_rates_by_resolution.begin(); | 350 frame_rates_by_resolution.begin(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 length, capture_callback_.capability(), 0)); | 524 length, capture_callback_.capability(), 0)); |
525 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); | 525 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); |
526 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); | 526 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); |
527 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 527 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
528 length, capture_callback_.capability(), 0)); | 528 length, capture_callback_.capability(), 0)); |
529 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); | 529 EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); |
530 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); | 530 capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); |
531 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), | 531 EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), |
532 length, capture_callback_.capability(), 0)); | 532 length, capture_callback_.capability(), 0)); |
533 } | 533 } |
OLD | NEW |