| Index: webrtc/modules/video_capture/test/video_capture_unittest.cc
|
| diff --git a/webrtc/modules/video_capture/test/video_capture_unittest.cc b/webrtc/modules/video_capture/test/video_capture_unittest.cc
|
| index 0f9f0aea41604c04578890a78b99aa7285f889d7..10b16f4d6c8b476efeb231ddb8311c1761f4ad6f 100644
|
| --- a/webrtc/modules/video_capture/test/video_capture_unittest.cc
|
| +++ b/webrtc/modules/video_capture/test/video_capture_unittest.cc
|
| @@ -29,11 +29,8 @@
|
| using webrtc::CriticalSectionWrapper;
|
| using webrtc::CriticalSectionScoped;
|
| using webrtc::SleepMs;
|
| -using webrtc::VideoCaptureAlarm;
|
| using webrtc::VideoCaptureCapability;
|
| -using webrtc::VideoCaptureDataCallback;
|
| using webrtc::VideoCaptureFactory;
|
| -using webrtc::VideoCaptureFeedBack;
|
| using webrtc::VideoCaptureModule;
|
|
|
|
|
| @@ -60,7 +57,8 @@ static const int kTestHeight = 288;
|
| static const int kTestWidth = 352;
|
| static const int kTestFramerate = 30;
|
|
|
| -class TestVideoCaptureCallback : public VideoCaptureDataCallback {
|
| +class TestVideoCaptureCallback
|
| + : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
| public:
|
| TestVideoCaptureCallback()
|
| : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
| @@ -75,8 +73,7 @@ class TestVideoCaptureCallback : public VideoCaptureDataCallback {
|
| printf("No of timing warnings %d\n", timing_warnings_);
|
| }
|
|
|
| - virtual void OnIncomingCapturedFrame(const int32_t id,
|
| - const webrtc::VideoFrame& videoFrame) {
|
| + void OnFrame(const webrtc::VideoFrame& videoFrame) override {
|
| CriticalSectionScoped cs(capture_cs_.get());
|
| int height = videoFrame.height();
|
| int width = videoFrame.width();
|
| @@ -109,12 +106,6 @@ class TestVideoCaptureCallback : public VideoCaptureDataCallback {
|
| last_frame_ = videoFrame.video_frame_buffer();
|
| }
|
|
|
| - virtual void OnCaptureDelayChanged(const int32_t id,
|
| - const int32_t delay) {
|
| - CriticalSectionScoped cs(capture_cs_.get());
|
| - capture_delay_ = delay;
|
| - }
|
| -
|
| void SetExpectedCapability(VideoCaptureCapability capability) {
|
| CriticalSectionScoped cs(capture_cs_.get());
|
| capability_= capability;
|
| @@ -162,47 +153,12 @@ class TestVideoCaptureCallback : public VideoCaptureDataCallback {
|
| webrtc::VideoRotation rotate_frame_;
|
| };
|
|
|
| -class TestVideoCaptureFeedBack : public VideoCaptureFeedBack {
|
| - public:
|
| - TestVideoCaptureFeedBack() :
|
| - capture_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
| - frame_rate_(0),
|
| - alarm_(webrtc::Cleared) {
|
| - }
|
| -
|
| - virtual void OnCaptureFrameRate(const int32_t id,
|
| - const uint32_t frameRate) {
|
| - CriticalSectionScoped cs(capture_cs_.get());
|
| - frame_rate_ = frameRate;
|
| - }
|
| -
|
| - virtual void OnNoPictureAlarm(const int32_t id,
|
| - const VideoCaptureAlarm reported_alarm) {
|
| - CriticalSectionScoped cs(capture_cs_.get());
|
| - alarm_ = reported_alarm;
|
| - }
|
| - int frame_rate() {
|
| - CriticalSectionScoped cs(capture_cs_.get());
|
| - return frame_rate_;
|
| -
|
| - }
|
| - VideoCaptureAlarm alarm() {
|
| - CriticalSectionScoped cs(capture_cs_.get());
|
| - return alarm_;
|
| - }
|
| -
|
| - private:
|
| - std::unique_ptr<CriticalSectionWrapper> capture_cs_;
|
| - unsigned int frame_rate_;
|
| - VideoCaptureAlarm alarm_;
|
| -};
|
| -
|
| class VideoCaptureTest : public testing::Test {
|
| public:
|
| VideoCaptureTest() : number_of_devices_(0) {}
|
|
|
| void SetUp() {
|
| - device_info_.reset(VideoCaptureFactory::CreateDeviceInfo(0));
|
| + device_info_.reset(VideoCaptureFactory::CreateDeviceInfo());
|
| assert(device_info_.get());
|
| number_of_devices_ = device_info_->NumberOfDevices();
|
| ASSERT_GT(number_of_devices_, 0u);
|
| @@ -210,7 +166,7 @@ class VideoCaptureTest : public testing::Test {
|
|
|
| rtc::scoped_refptr<VideoCaptureModule> OpenVideoCaptureDevice(
|
| unsigned int device,
|
| - VideoCaptureDataCallback* callback) {
|
| + rtc::VideoSinkInterface<webrtc::VideoFrame>* callback) {
|
| char device_name[256];
|
| char unique_name[256];
|
|
|
| @@ -218,13 +174,13 @@ class VideoCaptureTest : public testing::Test {
|
| device, device_name, 256, unique_name, 256));
|
|
|
| rtc::scoped_refptr<VideoCaptureModule> module(
|
| - VideoCaptureFactory::Create(device, unique_name));
|
| + VideoCaptureFactory::Create(unique_name));
|
| if (module.get() == NULL)
|
| return NULL;
|
|
|
| EXPECT_FALSE(module->CaptureStarted());
|
|
|
| - module->RegisterCaptureDataCallback(*callback);
|
| + module->RegisterCaptureDataCallback(callback);
|
| return module;
|
| }
|
|
|
| @@ -408,7 +364,7 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) {
|
| class VideoCaptureExternalTest : public testing::Test {
|
| public:
|
| void SetUp() {
|
| - capture_module_ = VideoCaptureFactory::Create(0, capture_input_interface_);
|
| + capture_module_ = VideoCaptureFactory::Create(capture_input_interface_);
|
| process_module_ = webrtc::ProcessThread::Create("ProcessThread");
|
| process_module_->Start();
|
| process_module_->RegisterModule(capture_module_);
|
| @@ -434,10 +390,7 @@ class VideoCaptureExternalTest : public testing::Test {
|
|
|
| SleepMs(1); // Wait 1ms so that two tests can't have the same timestamp.
|
|
|
| - capture_module_->RegisterCaptureDataCallback(capture_callback_);
|
| - capture_module_->RegisterCaptureCallback(capture_feedback_);
|
| - capture_module_->EnableFrameRateCallback(true);
|
| - capture_module_->EnableNoPictureAlarm(true);
|
| + capture_module_->RegisterCaptureDataCallback(&capture_callback_);
|
| }
|
|
|
| void TearDown() {
|
| @@ -449,7 +402,6 @@ class VideoCaptureExternalTest : public testing::Test {
|
| std::unique_ptr<webrtc::ProcessThread> process_module_;
|
| std::unique_ptr<webrtc::VideoFrame> test_frame_;
|
| TestVideoCaptureCallback capture_callback_;
|
| - TestVideoCaptureFeedBack capture_feedback_;
|
| };
|
|
|
| // Test input of external video frames.
|
| @@ -464,51 +416,6 @@ TEST_F(VideoCaptureExternalTest, TestExternalCapture) {
|
| EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_));
|
| }
|
|
|
| -// Test frame rate and no picture alarm.
|
| -// Flaky on Win32, see webrtc:3270.
|
| -#if defined(WEBRTC_WIN) || defined(WEBRTC_MAC)
|
| -#define MAYBE_FrameRate DISABLED_FrameRate
|
| -#else
|
| -#define MAYBE_FrameRate FrameRate
|
| -#endif
|
| -TEST_F(VideoCaptureExternalTest, MAYBE_FrameRate) {
|
| - int64_t testTime = 3 * rtc::kNumNanosecsPerSec;
|
| - int64_t startTime = rtc::TimeNanos();
|
| -
|
| - while ((rtc::TimeNanos() - startTime) < testTime) {
|
| - size_t length = webrtc::CalcBufferSize(webrtc::kI420,
|
| - test_frame_->width(),
|
| - test_frame_->height());
|
| - std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
|
| - webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get());
|
| - EXPECT_EQ(
|
| - 0, capture_input_interface_->IncomingFrame(
|
| - test_buffer.get(), length, capture_callback_.capability(), 0));
|
| - SleepMs(100);
|
| - }
|
| - EXPECT_TRUE(capture_feedback_.frame_rate() >= 8 &&
|
| - capture_feedback_.frame_rate() <= 10);
|
| - SleepMs(500);
|
| - EXPECT_EQ(webrtc::Raised, capture_feedback_.alarm());
|
| -
|
| - startTime = rtc::TimeNanos();
|
| - while ((rtc::TimeNanos() - startTime) < testTime) {
|
| - size_t length = webrtc::CalcBufferSize(webrtc::kI420,
|
| - test_frame_->width(),
|
| - test_frame_->height());
|
| - std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
|
| - webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get());
|
| - EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
|
| - length, capture_callback_.capability(), 0));
|
| - SleepMs(1000 / 30);
|
| - }
|
| - EXPECT_EQ(webrtc::Cleared, capture_feedback_.alarm());
|
| - // Frame rate might be less than 33 since we have paused providing
|
| - // frames for a while.
|
| - EXPECT_TRUE(capture_feedback_.frame_rate() >= 25 &&
|
| - capture_feedback_.frame_rate() <= 33);
|
| -}
|
| -
|
| TEST_F(VideoCaptureExternalTest, Rotation) {
|
| EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_0));
|
| size_t length = webrtc::CalcBufferSize(webrtc::kI420,
|
|
|