Files
platform-external-webrtc/webrtc/api/remotevideocapturer_unittest.cc
perkj 162c3393be Revert of Make cricket::VideoCapturer implement VideoSourceInterface (patchset #14 id:300001 of https://codereview.webrtc.org/1655793003/ )
Reason for revert:
Needs to revert again unfortunately.
There are multiple implementations in Chrome of cricket::VideoCapturer.

One is ./../remoting/protocol/webrtc_video_capturer_adapter.cc...

https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/9581/steps/compile/logs/stdio

Fun times - I will have to modify this cl after trying it manually out in Chrome.

Original issue's description:
> This cl introduce a VideoSourceInterface and let cricket::VideoCapturer implement it.
> Further more, it adds a VideoBroadcaster than is used for delivering frames to multiple sinks.
>
> BUG=webrtc:5426
> R=nisse@webrtc.org, pthatcher@webrtc.org
>
> Committed: https://crrev.com/4d19c5b010473615fa181afa84c6f4b3104e3171
> Cr-Commit-Position: refs/heads/master@{#11567}

TBR=pthatcher@google.com,nisse@webrtc.org,pthatcher@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5426

Review URL: https://codereview.webrtc.org/1690893002

Cr-Commit-Position: refs/heads/master@{#11568}
2016-02-11 10:56:41 +00:00

116 lines
3.4 KiB
C++

/*
* Copyright 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <string>
#include "webrtc/api/remotevideocapturer.h"
#include "webrtc/base/gunit.h"
#include "webrtc/media/webrtc/webrtcvideoframe.h"
using cricket::CaptureState;
using cricket::VideoCapturer;
using cricket::VideoFormat;
using cricket::VideoFormatPod;
using cricket::VideoFrame;
static const int kMaxWaitMs = 1000;
static const VideoFormatPod kTestFormat =
{640, 480, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY};
class RemoteVideoCapturerTest : public testing::Test,
public sigslot::has_slots<> {
protected:
RemoteVideoCapturerTest()
: captured_frame_num_(0),
capture_state_(cricket::CS_STOPPED) {}
virtual void SetUp() {
capturer_.SignalStateChange.connect(
this, &RemoteVideoCapturerTest::OnStateChange);
capturer_.SignalVideoFrame.connect(
this, &RemoteVideoCapturerTest::OnVideoFrame);
}
~RemoteVideoCapturerTest() {
capturer_.SignalStateChange.disconnect(this);
capturer_.SignalVideoFrame.disconnect(this);
}
int captured_frame_num() const {
return captured_frame_num_;
}
CaptureState capture_state() const {
return capture_state_;
}
webrtc::RemoteVideoCapturer capturer_;
private:
void OnStateChange(VideoCapturer* capturer,
CaptureState capture_state) {
EXPECT_EQ(&capturer_, capturer);
capture_state_ = capture_state;
}
void OnVideoFrame(VideoCapturer* capturer, const VideoFrame* frame) {
EXPECT_EQ(&capturer_, capturer);
++captured_frame_num_;
}
int captured_frame_num_;
CaptureState capture_state_;
};
TEST_F(RemoteVideoCapturerTest, StartStop) {
// Start
EXPECT_TRUE(
capturer_.StartCapturing(VideoFormat(kTestFormat)));
EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs);
EXPECT_EQ(VideoFormat(kTestFormat),
*capturer_.GetCaptureFormat());
EXPECT_TRUE(capturer_.IsRunning());
// Stop
capturer_.Stop();
EXPECT_TRUE_WAIT((cricket::CS_STOPPED == capture_state()), kMaxWaitMs);
EXPECT_TRUE(NULL == capturer_.GetCaptureFormat());
}
TEST_F(RemoteVideoCapturerTest, GetPreferredFourccs) {
EXPECT_FALSE(capturer_.GetPreferredFourccs(NULL));
std::vector<uint32_t> fourccs;
EXPECT_TRUE(capturer_.GetPreferredFourccs(&fourccs));
EXPECT_EQ(1u, fourccs.size());
EXPECT_EQ(cricket::FOURCC_I420, fourccs.at(0));
}
TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) {
VideoFormat desired = VideoFormat(kTestFormat);
EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL));
VideoFormat expected_format = VideoFormat(kTestFormat);
expected_format.fourcc = cricket::FOURCC_I420;
VideoFormat best_format;
EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format));
EXPECT_EQ(expected_format, best_format);
}
TEST_F(RemoteVideoCapturerTest, InputFrame) {
EXPECT_EQ(0, captured_frame_num());
cricket::WebRtcVideoFrame test_frame;
capturer_.SignalVideoFrame(&capturer_, &test_frame);
EXPECT_EQ(1, captured_frame_num());
capturer_.SignalVideoFrame(&capturer_, &test_frame);
EXPECT_EQ(2, captured_frame_num());
}