Rewrote vie_auto_test to use googletest macros.

Removed error counting entirely - that's completely managed by googletest now, except for custom call, loopback and simulcast call.

Rewrote remaining tests to use GTest asserts.

Rewrote more tests to use GTest macros. The External Codec module is now in the build by default.

Merge branch 'master' into macro_improvements

Rewrote some more code to use GTest asserts.

The manual standard tests now also go through gtest.

BUG=
TEST=

Review URL: http://webrtc-codereview.appspot.com/287002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1004 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org 2011-11-23 15:23:11 +00:00
parent 0c80c7fec8
commit c4c56ed20b
37 changed files with 2095 additions and 5299 deletions

View File

@ -12,7 +12,7 @@
#define WEBRTC_VIDEO_ENGINE_MAIN_INTERFACE_VIE_ERRORS_H_
enum ViEErrors {
enum ViEErrors {
//ViEBase
kViENotInitialized = 12000, // Init has not been called successfully.
@ -45,7 +45,7 @@ enum ViEErrors {
//ViECapture
kViECaptureDeviceAlreadyConnected = 12300, // ConnectCaptureDevice - A capture device has already been connected to this video channel.
kViECaptureDeviceDoesnNotExist, // No capture device exist with the provided capture id or unique name.
kViECaptureDeviceDoesNotExist, // No capture device exist with the provided capture id or unique name.
kViECaptureDeviceInvalidChannelId, // ConnectCaptureDevice, DisconnectCaptureDevice- No Channel exist with the provided channel id.
kViECaptureDeviceNotConnected, // DisconnectCaptureDevice- No capture device is connected to the channel.
kViECaptureDeviceNotStarted, // Stop- The capture device is not started.

View File

@ -22,39 +22,39 @@ class ViEApiIntegrationTest: public ViEIntegrationTest {
};
TEST_F(ViEApiIntegrationTest, RunsBaseTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEBaseAPITest());
tests_->ViEBaseAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsCaptureTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECaptureAPITest());
tests_->ViECaptureAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsCodecTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECodecAPITest());
tests_->ViECodecAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsEncryptionTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEEncryptionAPITest());
tests_->ViEEncryptionAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsFileTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEFileAPITest());
tests_->ViEFileAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsImageProcessTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEImageProcessAPITest());
tests_->ViEImageProcessAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsNetworkTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViENetworkAPITest());
tests_->ViENetworkAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsRenderTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERenderAPITest());
tests_->ViERenderAPITest();
}
TEST_F(ViEApiIntegrationTest, RunsRtpRtcpTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERtpRtcpAPITest());
tests_->ViERtpRtcpAPITest();
}
} // namespace

View File

@ -22,39 +22,39 @@ class ViEExtendedIntegrationTest: public ViEIntegrationTest {
};
TEST_F(ViEExtendedIntegrationTest, RunsBaseTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEBaseExtendedTest());
tests_->ViEBaseExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsCaptureTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECaptureExtendedTest());
tests_->ViECaptureExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsCodecTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECodecExtendedTest());
tests_->ViECodecExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsEncryptionTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEEncryptionExtendedTest());
tests_->ViEEncryptionExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsFileTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEFileExtendedTest());
tests_->ViEFileExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsImageProcessTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEImageProcessExtendedTest());
tests_->ViEImageProcessExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsNetworkTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViENetworkExtendedTest());
tests_->ViENetworkExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsRenderTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERenderExtendedTest());
tests_->ViERenderExtendedTest();
}
TEST_F(ViEExtendedIntegrationTest, RunsRtpRtcpTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERtpRtcpExtendedTest());
tests_->ViERtpRtcpExtendedTest();
}
} // namespace

View File

@ -22,8 +22,7 @@ void ViEIntegrationTest::SetUpTestCase() {
// Create the test cases
tests_ = new ViEAutoTest(window_manager->GetWindow1(),
window_manager->GetWindow2(),
ViETest::kUseGTestExpectsForTestErrors);
window_manager->GetWindow2());
}
void ViEIntegrationTest::TearDownTestCase() {

View File

@ -33,39 +33,39 @@ class ViEStandardIntegrationTest: public ViEIntegrationTest {
};
TEST_F(ViEStandardIntegrationTest, RunsBaseTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEBaseStandardTest());
tests_->ViEBaseStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsCodecTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECodecStandardTest());
tests_->ViECodecStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsCaptureTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViECaptureStandardTest());
tests_->ViECaptureStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsEncryptionTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEEncryptionStandardTest());
tests_->ViEEncryptionStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsFileTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEFileStandardTest());
tests_->ViEFileStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsImageProcessTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViEImageProcessStandardTest());
tests_->ViEImageProcessStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsNetworkTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViENetworkStandardTest());
tests_->ViENetworkStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsRenderTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERenderStandardTest());
tests_->ViERenderStandardTest();
}
TEST_F(ViEStandardIntegrationTest, RunsRtpRctpTestWithoutErrors) {
ASSERT_EQ(0, tests_->ViERtpRtcpStandardTest());
tests_->ViERtpRtcpStandardTest();
}
} // namespace

View File

@ -17,14 +17,13 @@
class TbCaptureDevice
{
public:
TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors);
TbCaptureDevice(TbInterfaces& Engine);
~TbCaptureDevice(void);
int captureId;
void ConnectTo(int videoChannel);
void Disconnect(int videoChannel);
private:
int& numberOfErrors;
TbInterfaces& ViE;
webrtc::VideoCaptureModule* vcpm_;
};

View File

@ -30,7 +30,7 @@
class TbInterfaces
{
public:
TbInterfaces(const char* test_name, int& number_of_errors);
TbInterfaces(const char* test_name);
~TbInterfaces(void);
webrtc::VideoEngine* video_engine;
@ -43,13 +43,9 @@ public:
webrtc::ViEImageProcess* image_process;
webrtc::ViEEncryption* encryption;
int LastError()
{
int LastError() {
return base->LastError();
}
private:
int& numberOfErrors;
};
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_INTERFACES_H_

View File

@ -12,15 +12,15 @@
#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_VIDEO_CHANNEL_H_
#include "tb_interfaces.h"
class tbVideoChannel
class TbVideoChannel
{
public:
tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors,
TbVideoChannel(TbInterfaces& Engine,
webrtc::VideoCodecType sendCodec = webrtc::kVideoCodecVP8,
int width = 352, int height = 288, int frameRate = 30,
int startBitrate = 300);
~tbVideoChannel(void);
~TbVideoChannel(void);
void SetFrameSettings(int width, int height, int frameRate);
@ -35,7 +35,6 @@ public:
int videoChannel;
private:
int& numberOfErrors;
TbInterfaces& ViE;
};

View File

@ -42,68 +42,73 @@
class TbInterfaces;
class ViEToFileRenderer;
// This class provides a bunch of methods, implemented across several .cc
// files, which runs tests on the video engine. All methods will report
// errors using standard googletest macros, except when marked otherwise.
class ViEAutoTest
{
public:
ViEAutoTest(void* window1, void* window2,
ViETest::TestErrorMode testErrorMode);
ViEAutoTest(void* window1, void* window2);
~ViEAutoTest();
int ViEStandardTest();
int ViEExtendedTest();
int ViEAPITest();
// These three are special and should not be run in a googletest harness.
// They keep track of their errors by themselves and return the number
// of errors.
int ViELoopbackCall();
int ViESimulcastCall();
// custom call and helper functions
int ViECustomCall();
// All following functions are meant to run in a googletest harness.
void ViEStandardTest();
void ViEExtendedTest();
void ViEAPITest();
// vie_autotest_base.cc
int ViEBaseStandardTest();
int ViEBaseExtendedTest();
int ViEBaseAPITest();
void ViEBaseStandardTest();
void ViEBaseExtendedTest();
void ViEBaseAPITest();
// vie_autotest_capture.cc
int ViECaptureStandardTest();
int ViECaptureExtendedTest();
int ViECaptureAPITest();
int ViECaptureExternalCaptureTest();
void ViECaptureStandardTest();
void ViECaptureExtendedTest();
void ViECaptureAPITest();
void ViECaptureExternalCaptureTest();
// vie_autotest_codec.cc
int ViECodecStandardTest();
int ViECodecExtendedTest();
int ViECodecExternalCodecTest();
int ViECodecAPITest();
void ViECodecStandardTest();
void ViECodecExtendedTest();
void ViECodecExternalCodecTest();
void ViECodecAPITest();
// vie_autotest_encryption.cc
int ViEEncryptionStandardTest();
int ViEEncryptionExtendedTest();
int ViEEncryptionAPITest();
void ViEEncryptionStandardTest();
void ViEEncryptionExtendedTest();
void ViEEncryptionAPITest();
// vie_autotest_file.ccs
int ViEFileStandardTest();
int ViEFileExtendedTest();
int ViEFileAPITest();
void ViEFileStandardTest();
void ViEFileExtendedTest();
void ViEFileAPITest();
// vie_autotest_image_process.cc
int ViEImageProcessStandardTest();
int ViEImageProcessExtendedTest();
int ViEImageProcessAPITest();
void ViEImageProcessStandardTest();
void ViEImageProcessExtendedTest();
void ViEImageProcessAPITest();
// vie_autotest_network.cc
int ViENetworkStandardTest();
int ViENetworkExtendedTest();
int ViENetworkAPITest();
void ViENetworkStandardTest();
void ViENetworkExtendedTest();
void ViENetworkAPITest();
// vie_autotest_render.cc
int ViERenderStandardTest();
int ViERenderExtendedTest();
int ViERenderAPITest();
void ViERenderStandardTest();
void ViERenderExtendedTest();
void ViERenderAPITest();
// vie_autotest_rtp_rtcp.cc
int ViERtpRtcpStandardTest();
int ViERtpRtcpExtendedTest();
int ViERtpRtcpAPITest();
void ViERtpRtcpStandardTest();
void ViERtpRtcpExtendedTest();
void ViERtpRtcpAPITest();
private:
void PrintAudioCodec(const webrtc::CodecInst audioCodec);

View File

@ -95,14 +95,8 @@ struct AutoTestRect {
// ============================================
class ViETest {
public:
enum TestErrorMode {
kUseGTestExpectsForTestErrors, kUseAssertsForTestErrors
};
// The test error mode tells how we should assert when an error
// occurs, provided that VIE_ASSERT_ERROR is defined.
static int Init(TestErrorMode test_error_mode) {
public:
static int Init() {
#ifdef VIE_LOG_TO_FILE
log_file_ = fopen(VIE_LOG_FILE_NAME, "w+t");
#else
@ -110,8 +104,6 @@ public:
#endif
log_str_ = new char[kMaxLogSize];
memset(log_str_, 0, kMaxLogSize);
test_error_mode_ = test_error_mode;
return 0;
}
@ -156,14 +148,8 @@ public:
#endif
}
static int TestError(bool expr) {
if (!expr) {
AssertError("");
return 1;
}
return 0;
}
// Deprecated(qhogpat): Prefer to use googletest macros in all cases
// except the custom call case.
static int TestError(bool expr, const char* fmt, ...) {
if (!expr) {
va_list va;
@ -185,15 +171,7 @@ public:
private:
static void AssertError(const char* message) {
#ifdef VIE_ASSERT_ERROR
if (test_error_mode_ == kUseAssertsForTestErrors) {
assert(false);
} else if (test_error_mode_ == kUseGTestExpectsForTestErrors) {
// Note that the failure gets added here, but information about where
// the real error occurred is usually in the message.
ADD_FAILURE() << message ;
} else {
assert(false && "Internal test framework logical error: unknown mode");
}
assert(false);
#endif
}
@ -202,8 +180,6 @@ private:
kMaxLogSize = 512
};
static char* log_str_;
static TestErrorMode test_error_mode_;
};
// milliseconds

View File

@ -12,24 +12,39 @@
#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_
#include <string>
#include <map>
class ViEAutoTestMain
{
public:
ViEAutoTestMain();
bool BeginOSIndependentTesting();
bool GetAnswer(int index, std::string* answer);
int GetClassTestSelection();
bool GetNextAnswer(std::string& answer);
bool IsUsingAnswerFile();
bool UseAnswerFile(const char* fileName);
class ViEAutoTestMain {
public:
ViEAutoTestMain();
bool BeginOSIndependentTesting();
bool GetAnswer(int index, std::string* answer);
int AskUserForTestCase();
bool GetNextAnswer(std::string& answer);
bool IsUsingAnswerFile();
bool UseAnswerFile(const char* fileName);
private:
private:
std::string answers_[1024];
int answers_count_;
int answers_index_;
bool use_answer_file_;
std::map<int, std::string> index_to_test_method_map_;
std::string _answers[1024];
int _answersCount;
int _answersIndex;
bool _useAnswerFile;
static const int kInvalidChoice = -1;
// Prompts the user for a specific test method in the provided test case.
// Returns 0 on success, nonzero otherwise.
int RunSpecificTestCaseIn(const std::string test_case_name);
// Retrieves a number from the user in the interval
// [min_allowed, max_allowed]. Returns kInvalidChoice on failure.
int AskUserForNumber(int min_allowed, int max_allowed);
// Runs all tests matching the provided filter. * are wildcards.
// Returns the test runner result (0 == OK).
int RunTestMatching(const std::string test_case,
const std::string test_method);
// Runs a non-gtest test case. Choice must be [7,9]. Returns 0 on success.
int RunSpecialTestCase(int choice);
};
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_

View File

@ -31,9 +31,6 @@ class ViEToFileRenderer;
// input is restarted between stages.
class ViEComparisonTests {
public:
ViEComparisonTests();
~ViEComparisonTests();
// Test a typical simple call setup.
void TestCallSetup(
const std::string& i420_test_video_path,
@ -49,7 +46,6 @@ class ViEComparisonTests {
int height,
ViEToFileRenderer* local_file_renderer,
ViEToFileRenderer* remote_file_renderer);
};
#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_COMPARISON_TESTS_H_

View File

@ -18,68 +18,44 @@ void TestI420CallSetup(webrtc::ViECodec* codec_interface,
webrtc::VideoEngine* video_engine,
webrtc::ViEBase* base_interface,
webrtc::ViENetwork* network_interface,
int* number_of_errors,
int video_channel,
const unsigned char *device_name) {
int error;
webrtc::VideoCodec video_codec;
memset(&video_codec, 0, sizeof(webrtc::VideoCodec));
// Set up the codec interface with all known receive codecs and with
// I420 as the send codec.
for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) {
error = codec_interface->GetCodec(i, video_codec);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec));
// Try to keep the test frame size small when I420.
if (video_codec.codecType == webrtc::kVideoCodecI420) {
video_codec.width = 176;
video_codec.height = 144;
error = codec_interface->SetSendCodec(video_channel, video_codec);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, video_codec));
}
error = codec_interface->SetReceiveCodec(video_channel, video_codec);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec));
}
// Verify that we really found the I420 codec.
error = codec_interface->GetSendCodec(video_channel, video_codec);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
*number_of_errors += ViETest::TestError(
video_codec.codecType == webrtc::kVideoCodecI420,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->GetSendCodec(video_channel, video_codec));
EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType);
// Set up senders and receivers.
char version[1024] = "";
error = base_interface->GetVersion(version);
EXPECT_EQ(0, base_interface->GetVersion(version));
ViETest::Log("\nUsing WebRTC Video Engine version: %s", version);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
const char *ipAddress = "127.0.0.1";
WebRtc_UWord16 rtpPortListen = 6100;
WebRtc_UWord16 rtpPortSend = 6100;
error = network_interface->SetLocalReceiver(video_channel, rtpPortListen);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->StartReceive(video_channel);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = network_interface->SetSendDestination(video_channel, ipAddress,
rtpPortSend);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->StartSend(video_channel);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, network_interface->SetLocalReceiver(video_channel,
rtpPortListen));
EXPECT_EQ(0, base_interface->StartReceive(video_channel));
EXPECT_EQ(0, network_interface->SetSendDestination(video_channel, ipAddress,
rtpPortSend));
EXPECT_EQ(0, base_interface->StartSend(video_channel));
// Call started.
ViETest::Log("Call started");
@ -89,7 +65,5 @@ void TestI420CallSetup(webrtc::ViECodec* codec_interface,
AutoTestSleep(KAutoTestSleepTimeMs);
// Done.
error = base_interface->StopSend(video_channel);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, base_interface->StopSend(video_channel));
}

View File

@ -26,7 +26,6 @@ void TestI420CallSetup(webrtc::ViECodec* codec_interface,
webrtc::VideoEngine* video_engine,
webrtc::ViEBase* base_interface,
webrtc::ViENetwork* network_interface,
int* number_of_errors,
int video_channel,
const unsigned char *device_name);

View File

@ -43,19 +43,12 @@ void SetSuitableResolution(webrtc::VideoCodec* video_codec,
void TestCodecImageProcess(webrtc::VideoCodec video_codec,
webrtc::ViECodec* codec_interface,
int video_channel,
int* number_of_errors,
webrtc::ViEImageProcess* image_process) {
int error = codec_interface->SetSendCodec(video_channel, video_codec);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, video_codec));
ViEAutoTestEffectFilter frame_counter;
error = image_process->RegisterRenderEffectFilter(video_channel,
frame_counter);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, image_process->RegisterRenderEffectFilter(video_channel,
frame_counter));
AutoTestSleep (KAutoTestSleepTimeMs);
int max_number_of_rendered_frames = video_codec.maxFramerate *
@ -65,27 +58,16 @@ void TestCodecImageProcess(webrtc::VideoCodec video_codec,
// Due to that I420 needs a huge bandwidth, rate control can set
// frame rate very low. This happen since we use the same channel
// as we just tested with vp8.
*number_of_errors += ViETest::TestError(frame_counter.numFrames > 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_GT(frame_counter.numFrames, 0);
} else {
#ifdef WEBRTC_ANDROID
// Special case to get the autotest to pass on some slow devices
*number_of_errors += ViETest::TestError(frameCounter.numFrames
> max_number_of_rendered_frames / 6,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_GT(frame_counter.numFrames, max_number_of_rendered_frames / 6);
#else
*number_of_errors += ViETest::TestError(frame_counter.numFrames
> max_number_of_rendered_frames / 4,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_GT(frame_counter.numFrames, max_number_of_rendered_frames / 4);
#endif
}
error = image_process->DeregisterRenderEffectFilter(video_channel);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, image_process->DeregisterRenderEffectFilter(video_channel));
}
// Test switching from i420 to VP8 as send codec and make sure that
@ -93,64 +75,47 @@ void TestCodecImageProcess(webrtc::VideoCodec video_codec,
void TestCodecCallbacks(webrtc::ViEBase *& base_interface,
webrtc::ViECodec *codec_interface,
int video_channel,
int* number_of_errors,
int forced_codec_width,
int forced_codec_height) {
// Set I420 as send codec so we don't make any assumptions about what
// we currently have as send codec:
SetSendCodec(webrtc::kVideoCodecI420, codec_interface, video_channel,
number_of_errors, forced_codec_width, forced_codec_height);
forced_codec_width, forced_codec_height);
// Register the observer:
ViEAutotestCodecObserver codec_observer;
int error = codec_interface->RegisterEncoderObserver(video_channel,
codec_observer);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = codec_interface->RegisterDecoderObserver(video_channel,
codec_observer);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->RegisterEncoderObserver(video_channel,
codec_observer));
EXPECT_EQ(0, codec_interface->RegisterDecoderObserver(video_channel,
codec_observer));
// Make the switch
// Make the switch.
ViETest::Log("Testing codec callbacks...");
SetSendCodec(webrtc::kVideoCodecVP8, codec_interface, video_channel,
number_of_errors, forced_codec_width, forced_codec_height);
forced_codec_width, forced_codec_height);
AutoTestSleep (KAutoTestSleepTimeMs);
// Verify that we got the right codec
*number_of_errors += ViETest::TestError(
codec_observer.incomingCodec.codecType == webrtc::kVideoCodecVP8,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
// Verify that we got the right codec.
EXPECT_EQ(webrtc::kVideoCodecVP8, codec_observer.incomingCodec.codecType);
// Clean up
error = codec_interface->DeregisterEncoderObserver(video_channel);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = codec_interface->DeregisterDecoderObserver(video_channel);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
*number_of_errors += ViETest::TestError(
codec_observer.incomingCodecCalled > 0,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
*number_of_errors += ViETest::TestError(
codec_observer.incomingRatecalled > 0,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
*number_of_errors += ViETest::TestError(
codec_observer.outgoingRatecalled > 0,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
// Clean up.
EXPECT_EQ(0, codec_interface->DeregisterEncoderObserver(video_channel));
EXPECT_EQ(0, codec_interface->DeregisterDecoderObserver(video_channel));
// Verify results.
EXPECT_GT(codec_observer.incomingCodecCalled, 0);
EXPECT_GT(codec_observer.incomingRatecalled, 0);
EXPECT_GT(codec_observer.outgoingRatecalled, 0);
}
void TestCodecs(const TbInterfaces& interfaces,
int & number_of_errors,
int capture_id,
int video_channel,
int forced_codec_width,
int forced_codec_height) {
int error;
webrtc::VideoEngine *video_engine_interface = interfaces.video_engine;
webrtc::ViEBase *base_interface = interfaces.base;
webrtc::ViECapture *capture_interface = interfaces.capture;
@ -167,46 +132,30 @@ void TestCodecs(const TbInterfaces& interfaces,
// Set up all receive codecs. This basically trains the codec interface
// to be able to recognize all receive codecs based on payload type.
for (int idx = 0; idx < codec_interface->NumberOfCodecs(); idx++) {
error = codec_interface->GetCodec(idx, video_codec);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->GetCodec(idx, video_codec));
SetSuitableResolution(&video_codec,
forced_codec_width,
forced_codec_height);
error = codec_interface->SetReceiveCodec(video_channel, video_codec);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec));
}
const char *ip_address = "127.0.0.1";
const unsigned short rtp_port = 6000;
error = network_interface->SetLocalReceiver(video_channel, rtp_port);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->StartReceive(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = network_interface->SetSendDestination(video_channel, ip_address,
rtp_port);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->StartSend(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, network_interface->SetLocalReceiver(video_channel, rtp_port));
EXPECT_EQ(0, base_interface->StartReceive(video_channel));
EXPECT_EQ(0, network_interface->SetSendDestination(video_channel, ip_address,
rtp_port));
EXPECT_EQ(0, base_interface->StartSend(video_channel));
// Run all found codecs
webrtc::ViEImageProcess *image_process =
webrtc::ViEImageProcess::GetInterface(video_engine_interface);
number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(image_process != NULL);
ViETest::Log("Loop through all codecs for %d seconds",
KAutoTestSleepTimeMs / 1000);
for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) {
error = codec_interface->GetCodec(i, video_codec);
number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec));
if (video_codec.codecType == webrtc::kVideoCodecMPEG4 ||
video_codec.codecType == webrtc::kVideoCodecRED ||
@ -214,67 +163,45 @@ void TestCodecs(const TbInterfaces& interfaces,
ViETest::Log("\t %d. %s not tested", i, video_codec.plName);
} else {
ViETest::Log("\t %d. %s", i, video_codec.plName);
SetSuitableResolution(&video_codec,
forced_codec_width, forced_codec_height);
SetSuitableResolution(&video_codec, forced_codec_width,
forced_codec_height);
TestCodecImageProcess(video_codec, codec_interface, video_channel,
&number_of_errors, image_process);
image_process);
}
}
image_process->Release();
TestCodecCallbacks(base_interface, codec_interface, video_channel,
&number_of_errors, forced_codec_width,
forced_codec_height);
forced_codec_width, forced_codec_height);
ViETest::Log("Done!");
// ***************************************************************
// Testing finished. Tear down Video Engine
// ***************************************************************
error = base_interface->StopSend(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->StopReceive(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->StopRender(capture_id);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->StopRender(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->RemoveRenderer(capture_id);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->RemoveRenderer(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = capture_interface->DisconnectCaptureDevice(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->DeleteChannel(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, base_interface->StopSend(video_channel));
EXPECT_EQ(0, base_interface->StopReceive(video_channel));
EXPECT_EQ(0, render_interface->StopRender(capture_id));
EXPECT_EQ(0, render_interface->StopRender(video_channel));
EXPECT_EQ(0, render_interface->RemoveRenderer(capture_id));
EXPECT_EQ(0, render_interface->RemoveRenderer(video_channel));
EXPECT_EQ(0, capture_interface->DisconnectCaptureDevice(video_channel));
EXPECT_EQ(0, base_interface->DeleteChannel(video_channel));
}
void SetSendCodec(webrtc::VideoCodecType of_type,
webrtc::ViECodec* codec_interface,
int video_channel,
int* number_of_errors,
int forced_codec_width,
int forced_codec_height) {
webrtc::VideoCodec codec;
bool ok = FindSpecificCodec(of_type, codec_interface, &codec);
*number_of_errors += ViETest::TestError(ok == true, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
bool ok;
EXPECT_TRUE(ok = FindSpecificCodec(of_type, codec_interface, &codec));
if (!ok) {
return;
}
SetSuitableResolution(&codec, forced_codec_width, forced_codec_height);
int error = codec_interface->SetSendCodec(video_channel, codec);
*number_of_errors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, codec));
}

View File

@ -27,7 +27,6 @@ const int kDoNotForceResolution = 0;
// be seen as a end-user-visible quality measure - it is more a sanity check
// that the codec at least gets some frames through.
void TestCodecs(const TbInterfaces& interfaces,
int & number_of_errors,
int capture_id,
int video_channel,
int forced_codec_width,
@ -39,7 +38,6 @@ void TestCodecs(const TbInterfaces& interfaces,
void SetSendCodec(webrtc::VideoCodecType of_type,
webrtc::ViECodec* codec_interface,
int video_channel,
int* number_of_errors,
int forced_codec_width,
int forced_codec_height);

View File

@ -19,7 +19,6 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture,
unsigned char* device_name,
unsigned int device_name_length,
int* device_id,
int* number_of_errors,
webrtc::VideoCaptureModule** device_video) {
bool capture_device_set = false;
@ -31,18 +30,15 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture,
memset(unique_id, 0, kMaxUniqueIdLength);
for (unsigned int i = 0; i < dev_info->NumberOfDevices(); i++) {
int error = dev_info->GetDeviceName(i, device_name, device_name_length,
unique_id, kMaxUniqueIdLength);
*number_of_errors += ViETest::TestError(
error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__);
*device_video =
webrtc::VideoCaptureFactory::Create(4571, unique_id);
EXPECT_EQ(0, dev_info->GetDeviceName(i, device_name, device_name_length,
unique_id, kMaxUniqueIdLength));
*device_video = webrtc::VideoCaptureFactory::Create(4571, unique_id);
EXPECT_TRUE(*device_video != NULL);
*number_of_errors += ViETest::TestError(
*device_video != NULL, "ERROR: %s at line %d", __FUNCTION__, __LINE__);
(*device_video)->AddRef();
error = capture->AllocateCaptureDevice(**device_video, *device_id);
int error = capture->AllocateCaptureDevice(**device_video, *device_id);
if (error == 0) {
ViETest::Log("Using capture device: %s, captureId: %d.",
device_name, *device_id);
@ -54,69 +50,43 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture,
}
}
delete dev_info;
*number_of_errors += ViETest::TestError(
capture_device_set, "ERROR: %s at line %d - Could not set capture device",
__FUNCTION__, __LINE__);
EXPECT_TRUE(capture_device_set) << "Found no suitable camera on your system.";
}
void RenderInWindow(webrtc::ViERender* video_render_interface,
int* numberOfErrors,
int frame_provider_id,
void* os_window,
float z_index) {
int error = video_render_interface->AddRenderer(frame_provider_id, os_window,
z_index, 0.0, 0.0, 1.0, 1.0);
*numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = video_render_interface->StartRender(frame_provider_id);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0,
video_render_interface->AddRenderer(frame_provider_id, os_window,
z_index, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, video_render_interface->StartRender(frame_provider_id));
}
void RenderToFile(webrtc::ViERender* renderer_interface,
int frame_provider_id,
ViEToFileRenderer *to_file_renderer) {
int result = renderer_interface->AddRenderer(frame_provider_id,
webrtc::kVideoI420,
to_file_renderer);
ViETest::TestError(result == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
result = renderer_interface->StartRender(frame_provider_id);
ViETest::TestError(result == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, renderer_interface->AddRenderer(
frame_provider_id, webrtc::kVideoI420, to_file_renderer));
EXPECT_EQ(0, renderer_interface->StartRender(frame_provider_id));
}
void StopAndRemoveRenderers(webrtc::ViEBase* base_interface,
webrtc::ViERender* render_interface,
int* number_of_errors,
int channel_id,
int capture_id) {
int error = render_interface->StopRender(channel_id);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->RemoveRenderer(channel_id);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->RemoveRenderer(capture_id);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, render_interface->StopRender(channel_id));
EXPECT_EQ(0, render_interface->RemoveRenderer(channel_id));
EXPECT_EQ(0, render_interface->RemoveRenderer(capture_id));
}
void ConfigureRtpRtcp(webrtc::ViERTP_RTCP* rtcp_interface,
int* number_of_errors,
int video_channel) {
int error = rtcp_interface->SetRTCPStatus(
video_channel, webrtc::kRtcpCompound_RFC4585);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = rtcp_interface->SetKeyFrameRequestMethod(
video_channel, webrtc::kViEKeyFrameRequestPliRtcp);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = rtcp_interface->SetTMMBRStatus(video_channel, true);
*number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, rtcp_interface->SetRTCPStatus(video_channel,
webrtc::kRtcpCompound_RFC4585));
EXPECT_EQ(0, rtcp_interface->SetKeyFrameRequestMethod(
video_channel, webrtc::kViEKeyFrameRequestPliRtcp));
EXPECT_EQ(0, rtcp_interface->SetTMMBRStatus(video_channel, true));
}
bool FindSpecificCodec(webrtc::VideoCodecType of_type,

View File

@ -33,7 +33,6 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture,
unsigned char* device_name,
const unsigned int kDeviceNameLength,
int* device_id,
int* number_of_errors,
webrtc::VideoCaptureModule** device_video);
// Sets up rendering in a window previously created using a Window Manager
@ -41,7 +40,6 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture,
// those). The frame provider id is a source of video frames, for instance
// a capture device or a video channel.
void RenderInWindow(webrtc::ViERender* video_render_interface,
int* numberOfErrors,
int frame_provider_id,
void* os_window,
float z_index);
@ -57,13 +55,11 @@ void RenderToFile(webrtc::ViERender* renderer_interface,
// and a video channel set up for rendering.
void StopAndRemoveRenderers(webrtc::ViEBase* base_interface,
webrtc::ViERender* render_interface,
int* number_of_errors,
int channel_id,
int capture_id);
// Configures RTP-RTCP.
void ConfigureRtpRtcp(webrtc::ViERTP_RTCP* rtcp_interface,
int* number_of_errors,
int video_channel);
// Finds a codec in the codec list. Returns true on success, false otherwise.

View File

@ -10,9 +10,8 @@
#include "tb_capture_device.h"
TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) :
TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine) :
captureId(-1),
numberOfErrors(nrOfErrors),
ViE(Engine),
vcpm_(NULL)
{
@ -23,7 +22,6 @@ TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) :
WebRtc_UWord8 uniqueId[KMaxUniqueIdLength];
memset(uniqueId, 0, KMaxUniqueIdLength);
int error;
bool captureDeviceSet = false;
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
@ -32,22 +30,19 @@ TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) :
captureIdx < devInfo->NumberOfDevices();
captureIdx++)
{
error = devInfo->GetDeviceName(captureIdx, deviceName,
KMaxDeviceNameLength, uniqueId,
KMaxUniqueIdLength);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, devInfo->GetDeviceName(captureIdx, deviceName,
KMaxDeviceNameLength, uniqueId,
KMaxUniqueIdLength));
vcpm_ = webrtc::VideoCaptureFactory::Create(
captureIdx, uniqueId);
if (vcpm_ == NULL) // Failed to open this device. Try next.
if (vcpm_ == NULL) // Failed to open this device. Try next.
{
continue;
}
vcpm_->AddRef();
error = ViE.capture->AllocateCaptureDevice(*vcpm_, captureId);
int error = ViE.capture->AllocateCaptureDevice(*vcpm_, captureId);
if (error == 0)
{
ViETest::Log("Using capture device: %s, captureId: %d", deviceName,
@ -57,44 +52,30 @@ TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) :
}
}
delete devInfo;
numberOfErrors += ViETest::TestError(
captureDeviceSet, "ERROR: %s at line %d - Could not set capture device",
__FUNCTION__, __LINE__);
EXPECT_TRUE(captureDeviceSet);
if (!captureDeviceSet) {
return;
}
ViETest::Log("Starting capture device %s with captureId %d\n", deviceName,
captureId);
error = ViE.capture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->StartCapture(captureId));
}
TbCaptureDevice::~TbCaptureDevice(void)
{
ViETest::Log("Stopping capture device with id %d\n", captureId);
int error;
error = ViE.capture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.capture->ReleaseCaptureDevice(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->StopCapture(captureId));
EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId));
vcpm_->Release();
}
void TbCaptureDevice::ConnectTo(int videoChannel)
{
int error;
error = ViE.capture->ConnectCaptureDevice(captureId, videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, videoChannel));
}
void TbCaptureDevice::Disconnect(int videoChannel)
{
int error = 0;
error = ViE.capture->DisconnectCaptureDevice(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->DisconnectCaptureDevice(videoChannel));
}

View File

@ -10,9 +10,9 @@
#include "tb_interfaces.h"
TbInterfaces::TbInterfaces(const char* testName, int& nrOfErrors) :
numberOfErrors(nrOfErrors)
{
#include "gtest/gtest.h"
TbInterfaces::TbInterfaces(const char* testName) {
char traceFile[256] = "";
#ifdef WEBRTC_ANDROID
@ -24,111 +24,50 @@ TbInterfaces::TbInterfaces(const char* testName, int& nrOfErrors) :
ViETest::Log("Creating ViE Interfaces for test %s\n", testName);
video_engine = webrtc::VideoEngine::Create();
numberOfErrors += ViETest::TestError(video_engine != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(video_engine != NULL);
int error = video_engine->SetTraceFile(traceFile);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = video_engine->SetTraceFilter(webrtc::kTraceAll);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, video_engine->SetTraceFile(traceFile));
EXPECT_EQ(0, video_engine->SetTraceFilter(webrtc::kTraceAll));
base = webrtc::ViEBase::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(base != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(base != NULL);
error = base->Init();
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, base->Init());
capture = webrtc::ViECapture::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(capture != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(capture != NULL);
rtp_rtcp = webrtc::ViERTP_RTCP::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(rtp_rtcp != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(rtp_rtcp != NULL);
render = webrtc::ViERender::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(render != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(render != NULL);
codec = webrtc::ViECodec::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(codec != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(codec != NULL);
network = webrtc::ViENetwork::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(network != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(network != NULL);
image_process = webrtc::ViEImageProcess::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(image_process != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(image_process != NULL);
encryption = webrtc::ViEEncryption::GetInterface(video_engine);
numberOfErrors += ViETest::TestError(encryption != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(encryption != NULL);
}
TbInterfaces::~TbInterfaces(void)
{
int numberOfErrors = 0;
int remainingInterfaces = 0;
remainingInterfaces = encryption->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = image_process->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = codec->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = capture->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = render->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = rtp_rtcp->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = network->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
remainingInterfaces = base->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
bool deleted = webrtc::VideoEngine::Delete(video_engine);
numberOfErrors += ViETest::TestError(deleted == true,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(0, encryption->Release());
EXPECT_EQ(0, image_process->Release());
EXPECT_EQ(0, codec->Release());
EXPECT_EQ(0, capture->Release());
EXPECT_EQ(0, render->Release());
EXPECT_EQ(0, rtp_rtcp->Release());
EXPECT_EQ(0, network->Release());
EXPECT_EQ(0, base->Release());
EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)) <<
"Since we have released all interfaces at this point, deletion "
"should be successful.";
}

View File

@ -10,25 +10,19 @@
#include "tb_video_channel.h"
tbVideoChannel::tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors,
TbVideoChannel::TbVideoChannel(TbInterfaces& Engine,
webrtc::VideoCodecType sendCodec, int width,
int height, int frameRate, int startBitrate) :
videoChannel(-1), numberOfErrors(nrOfErrors), ViE(Engine)
videoChannel(-1), ViE(Engine)
{
int error;
error = ViE.base->CreateChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.base->CreateChannel(videoChannel));
webrtc::VideoCodec videoCodec;
memset(&videoCodec, 0, sizeof(webrtc::VideoCodec));
bool sendCodecSet = false;
for (int idx = 0; idx < ViE.codec->NumberOfCodecs(); idx++)
{
error = ViE.codec->GetCodec(idx, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.codec->GetCodec(idx, videoCodec));
videoCodec.width = width;
videoCodec.height = height;
videoCodec.maxFramerate = frameRate;
@ -40,10 +34,7 @@ tbVideoChannel::tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors,
videoCodec.startBitrate = startBitrate;
videoCodec.maxBitrate = startBitrate * 3;
}
error = ViE.codec->SetSendCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.codec->SetSendCodec(videoChannel, videoCodec));
sendCodecSet = true;
}
if (videoCodec.codecType == webrtc::kVideoCodecVP8)
@ -51,84 +42,49 @@ tbVideoChannel::tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors,
videoCodec.width = 352;
videoCodec.height = 288;
}
error = ViE.codec->SetReceiveCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel, videoCodec));
}
numberOfErrors += ViETest::TestError(sendCodecSet == true,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(sendCodecSet);
}
tbVideoChannel::~tbVideoChannel(void)
TbVideoChannel::~TbVideoChannel(void)
{
int error;
error = ViE.base->DeleteChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.base->DeleteChannel(videoChannel));
}
void tbVideoChannel::StartSend(const unsigned short rtpPort /*= 11000*/,
void TbVideoChannel::StartSend(const unsigned short rtpPort /*= 11000*/,
const char* ipAddress /*= "127.0.0.1"*/)
{
int error;
error = ViE.network->SetSendDestination(videoChannel, ipAddress,
rtpPort);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.network->SetSendDestination(videoChannel, ipAddress,
rtpPort));
error = ViE.base->StartSend(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.base->StartSend(videoChannel));
}
void tbVideoChannel::SetFrameSettings(int width, int height, int frameRate)
void TbVideoChannel::SetFrameSettings(int width, int height, int frameRate)
{
int error;
webrtc::VideoCodec videoCodec;
error = ViE.codec->GetSendCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.codec->GetSendCodec(videoChannel, videoCodec));
videoCodec.width = width;
videoCodec.height = height;
videoCodec.maxFramerate = frameRate;
error = ViE.codec->SetSendCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.codec->SetReceiveCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.codec->SetSendCodec(videoChannel, videoCodec));
EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel, videoCodec));
}
void tbVideoChannel::StopSend()
void TbVideoChannel::StopSend()
{
int error;
error = ViE.base->StopSend(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.base->StopSend(videoChannel));
}
void tbVideoChannel::StartReceive(const unsigned short rtpPort /*= 11000*/)
void TbVideoChannel::StartReceive(const unsigned short rtpPort /*= 11000*/)
{
int error;
error = ViE.network->SetLocalReceiver(videoChannel, rtpPort);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.base->StartReceive(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.network->SetLocalReceiver(videoChannel, rtpPort));
EXPECT_EQ(0, ViE.base->StartReceive(videoChannel));
}
void tbVideoChannel::StopReceive()
void TbVideoChannel::StopReceive()
{
int error;
error = ViE.base->StopReceive(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.base->StopReceive(videoChannel));
}

View File

@ -21,10 +21,8 @@
FILE* ViETest::log_file_ = NULL;
char* ViETest::log_str_ = NULL;
ViETest::TestErrorMode ViETest::test_error_mode_;
ViEAutoTest::ViEAutoTest(void* window1, void* window2,
ViETest::TestErrorMode testErrorMode) :
ViEAutoTest::ViEAutoTest(void* window1, void* window2) :
_window1(window1),
_window2(window2),
_renderType(webrtc::kRenderDefault),
@ -35,8 +33,6 @@ ViEAutoTest::ViEAutoTest(void* window1, void* window2,
{
assert(_vrm1);
assert(_vrm2);
ViETest::Init(testErrorMode);
}
ViEAutoTest::~ViEAutoTest()
@ -45,71 +41,45 @@ ViEAutoTest::~ViEAutoTest()
_vrm1 = NULL;
webrtc::VideoRender::DestroyVideoRender(_vrm2);
_vrm2 = NULL;
ViETest::Terminate();
}
int ViEAutoTest::ViEStandardTest()
void ViEAutoTest::ViEStandardTest()
{
int numErrors = 0;
numErrors += ViEBaseStandardTest();
numErrors += ViECaptureStandardTest();
numErrors += ViECodecStandardTest();
numErrors += ViEEncryptionStandardTest();
numErrors += ViEFileStandardTest();
numErrors += ViEImageProcessStandardTest();
numErrors += ViENetworkStandardTest();
numErrors += ViERenderStandardTest();
numErrors += ViERtpRtcpStandardTest();
if (numErrors > 0)
{
ViETest::Log("Standard Test Failed, with %d erros\n", numErrors);
return numErrors;
}
return numErrors;
ViEBaseStandardTest();
ViECaptureStandardTest();
ViECodecStandardTest();
ViEEncryptionStandardTest();
ViEFileStandardTest();
ViEImageProcessStandardTest();
ViENetworkStandardTest();
ViERenderStandardTest();
ViERtpRtcpStandardTest();
}
int ViEAutoTest::ViEExtendedTest()
void ViEAutoTest::ViEExtendedTest()
{
int numErrors = 0;
numErrors += ViEBaseExtendedTest();
numErrors += ViECaptureExtendedTest();
numErrors += ViECodecExtendedTest();
numErrors += ViEEncryptionExtendedTest();
numErrors += ViEFileExtendedTest();
numErrors += ViEImageProcessExtendedTest();
numErrors += ViENetworkExtendedTest();
numErrors += ViERenderExtendedTest();
numErrors += ViERtpRtcpExtendedTest();
if (numErrors > 0)
{
ViETest::Log("Extended Test Failed, with %d erros\n", numErrors);
return numErrors;
}
return numErrors;
ViEBaseExtendedTest();
ViECaptureExtendedTest();
ViECodecExtendedTest();
ViEEncryptionExtendedTest();
ViEFileExtendedTest();
ViEImageProcessExtendedTest();
ViENetworkExtendedTest();
ViERenderExtendedTest();
ViERtpRtcpExtendedTest();
}
int ViEAutoTest::ViEAPITest()
void ViEAutoTest::ViEAPITest()
{
int numErrors = 0;
numErrors += ViEBaseAPITest();
numErrors += ViECaptureAPITest();
numErrors += ViECodecAPITest();
numErrors += ViEEncryptionAPITest();
numErrors += ViEFileAPITest();
numErrors += ViEImageProcessAPITest();
numErrors += ViENetworkAPITest();
numErrors += ViERenderAPITest();
numErrors += ViERtpRtcpAPITest();
if (numErrors > 0)
{
ViETest::Log("API Test Failed, with %d erros\n", numErrors);
return numErrors;
}
return 0;
ViEBaseAPITest();
ViECaptureAPITest();
ViECodecAPITest();
ViEEncryptionAPITest();
ViEFileAPITest();
ViEImageProcessAPITest();
ViENetworkAPITest();
ViERenderAPITest();
ViERtpRtcpAPITest();
}
void ViEAutoTest::PrintVideoCodec(const webrtc::VideoCodec videoCodec)

View File

@ -27,26 +27,18 @@ class BaseObserver : public webrtc::ViEBaseObserver {
unsigned int cpu_load_;
};
int ViEAutoTest::ViEBaseStandardTest() {
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEBase Standard Test");
void ViEAutoTest::ViEBaseStandardTest() {
// ***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
// ***************************************************************
int number_of_errors = 0;
TbInterfaces interfaces("ViEBaseStandardTest", number_of_errors);
TbInterfaces interfaces("ViEBaseStandardTest");
// ***************************************************************
// Engine ready. Set up the test case:
// ***************************************************************
int video_channel = -1;
int error = interfaces.base->CreateChannel(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel));
webrtc::VideoCaptureModule* video_capture_module(NULL);
const unsigned int kMaxDeviceNameLength = 128;
@ -62,294 +54,152 @@ int ViEAutoTest::ViEBaseStandardTest() {
device_name,
kMaxDeviceNameLength,
&capture_id,
&number_of_errors,
&video_capture_module);
error = capture_interface->ConnectCaptureDevice(capture_id,
video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, capture_interface->ConnectCaptureDevice(capture_id,
video_channel));
EXPECT_EQ(0, capture_interface->StartCapture(capture_id));
error = capture_interface->StartCapture(capture_id);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
ConfigureRtpRtcp(interfaces.rtp_rtcp, video_channel);
ConfigureRtpRtcp(interfaces.rtp_rtcp, &number_of_errors, video_channel);
EXPECT_EQ(0, render_interface->RegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, render_interface->RegisterVideoRenderModule(*_vrm2));
error = render_interface->RegisterVideoRenderModule(*_vrm1);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->RegisterVideoRenderModule(*_vrm2);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
RenderInWindow(render_interface, &number_of_errors, capture_id,
_window1, 0);
RenderInWindow(render_interface, &number_of_errors, video_channel,
_window2, 1);
RenderInWindow(render_interface, capture_id, _window1, 0);
RenderInWindow(render_interface, video_channel, _window2, 1);
// ***************************************************************
// Run the actual test:
// ***************************************************************
TestI420CallSetup(interfaces.codec, interfaces.video_engine,
base_interface, interfaces.network, &number_of_errors,
video_channel, device_name);
::TestI420CallSetup(interfaces.codec, interfaces.video_engine,
base_interface, interfaces.network, video_channel,
device_name);
// ***************************************************************
// Testing finished. Tear down Video Engine
// ***************************************************************
error = capture_interface->StopCapture(capture_id);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = base_interface->StopReceive(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, capture_interface->StopCapture(capture_id));
EXPECT_EQ(0, base_interface->StopReceive(video_channel));
StopAndRemoveRenderers(base_interface, render_interface, &number_of_errors,
video_channel, capture_id);
StopAndRemoveRenderers(base_interface, render_interface, video_channel,
capture_id);
error = render_interface->DeRegisterVideoRenderModule(*_vrm1);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = render_interface->DeRegisterVideoRenderModule(*_vrm2);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, render_interface->DeRegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, render_interface->DeRegisterVideoRenderModule(*_vrm2));
error = capture_interface->ReleaseCaptureDevice(capture_id);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, capture_interface->ReleaseCaptureDevice(capture_id));
video_capture_module->Release();
video_capture_module = NULL;
error = base_interface->DeleteChannel(video_channel);
number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
if (number_of_errors > 0) {
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViEBase Standard Test FAILED!");
ViETest::Log(" Number of errors: %d", number_of_errors);
ViETest::Log("========================================");
ViETest::Log(" ");
return number_of_errors;
}
ViETest::Log(" ");
ViETest::Log(" ViEBase Standard Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
EXPECT_EQ(0, base_interface->DeleteChannel(video_channel));
}
int ViEAutoTest::ViEBaseExtendedTest() {
void ViEAutoTest::ViEBaseExtendedTest() {
// Start with standard test
ViEBaseAPITest();
ViEBaseStandardTest();
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEBase Extended Test");
// ***************************************************************
// Test BaseObserver
// ***************************************************************
// TODO(mflodman) Add test for base observer. Cpu load must be over 75%.
// BaseObserver base_observer;
// error = ptrViEBase->RegisterObserver(base_observer);
// numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
// __FUNCTION__, __LINE__);
// EXPECT_EQ(ptrViEBase->RegisterObserver(base_observer), 0);
//
// AutoTestSleep(KAutoTestSleepTimeMs);
//
// error = ptrViEBase->DeregisterObserver();
// numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
// __FUNCTION__, __LINE__);
// numberOfErrors += ViETest::TestError(base_observer.cpu_load_ > 0,
// "ERROR: %s at line %d",
// __FUNCTION__, __LINE__);
ViETest::Log(" ");
ViETest::Log(" ViEBase Extended Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
// EXPECT_EQ(ptrViEBase->DeregisterObserver(), 0);
// EXPECT_GT(base_observer.cpu_load, 0);
}
int ViEAutoTest::ViEBaseAPITest() {
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEBase API Test");
void ViEAutoTest::ViEBaseAPITest() {
// ***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
// ***************************************************************
int error = 0;
int numberOfErrors = 0;
webrtc::VideoEngine* ptrViE = NULL;
webrtc::ViEBase* ptrViEBase = NULL;
// Get the ViEBase API
ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE);
numberOfErrors += ViETest::TestError(ptrViEBase == NULL);
webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(NULL);
EXPECT_EQ(NULL, ptrViEBase) << "Should return null for a bad ViE pointer";
ptrViE = webrtc::VideoEngine::Create();
numberOfErrors += ViETest::TestError(ptrViE != NULL, "VideoEngine::Create");
webrtc::VideoEngine* ptrViE = webrtc::VideoEngine::Create();
EXPECT_TRUE(NULL != ptrViE);
#ifdef WEBRTC_ANDROID
error = video_engine->SetTraceFile("/sdcard/WebRTC/ViEBaseAPI_trace.txt");
numberOfErrors += ViETest::TestError(error == 0, "SetTraceFile error");
EXPECT_EQ(0,
video_engine->SetTraceFile("/sdcard/WebRTC/ViEBaseAPI_trace.txt"));
#else
error = ptrViE->SetTraceFile("ViEBaseAPI_trace.txt");
numberOfErrors += ViETest::TestError(error == 0, "SetTraceFile error");
EXPECT_EQ(0, ptrViE->SetTraceFile("ViEBaseAPI_trace.txt"));
#endif
ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE);
numberOfErrors += ViETest::TestError(ptrViEBase != NULL);
EXPECT_TRUE(NULL != ptrViEBase);
// ***************************************************************
// Engine ready. Begin testing class
// ***************************************************************
char version[1024] = "";
error = ptrViEBase->GetVersion(version);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ptrViEBase->LastError();
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEBase->GetVersion(version));
EXPECT_EQ(0, ptrViEBase->LastError());
// Create without init
int videoChannel = -1;
error = ptrViEBase->CreateChannel(videoChannel);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ptrViEBase->Init();
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ptrViEBase->CreateChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ptrViEBase->CreateChannel(videoChannel)) <<
"Should fail since Init has not been called yet";
EXPECT_EQ(0, ptrViEBase->Init());
EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel));
int videoChannel2 = -1;
error = ptrViEBase->CreateChannel(videoChannel2);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(videoChannel != videoChannel2,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel2));
EXPECT_NE(videoChannel, videoChannel2) <<
"Should allocate new number for independent channel";
error = ptrViEBase->DeleteChannel(videoChannel2);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel2));
// Channel doesn't exist
error = ptrViEBase->CreateChannel(videoChannel2, videoChannel + 1);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(-1, ptrViEBase->CreateChannel(videoChannel2, videoChannel + 1)) <<
"Should fail since neither channel exists (the second must)";
// Channel doesn't exist
error = ptrViEBase->CreateChannel(videoChannel2, videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel2, videoChannel));
// VoiceEngine
// Test Voice Engine integration with Video Engine.
webrtc::VoiceEngine* ptrVoE = NULL;
webrtc::VoEBase* ptrVoEBase = NULL;
int audioChannel = -1;
ptrVoE = webrtc::VoiceEngine::Create();
numberOfErrors += ViETest::TestError(ptrVoE != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(NULL != ptrVoE);
ptrVoEBase = webrtc::VoEBase::GetInterface(ptrVoE);
numberOfErrors += ViETest::TestError(ptrVoEBase != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
error = ptrVoEBase->Init();
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(NULL != ptrVoEBase);
EXPECT_EQ(0, ptrVoEBase->Init());
audioChannel = ptrVoEBase->CreateChannel();
numberOfErrors += ViETest::TestError(audioChannel != -1,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_NE(-1, audioChannel);
// Connect before setting VoE
error = ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Connect before setting VoE.
EXPECT_NE(0, ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel)) <<
"Should fail since Voice Engine is not set yet.";
error = ptrViEBase->SetVoiceEngine(ptrVoE);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Then do it right.
EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(ptrVoE));
EXPECT_EQ(0, ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel));
// ***************************************************************
// Testing finished. Tear down Video Engine
// ***************************************************************
error = ptrViEBase->DisconnectAudioChannel(videoChannel + 5);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ptrViEBase->DisconnectAudioChannel(videoChannel + 5)) <<
"Should fail: disconnecting bogus channel";
error = ptrViEBase->DisconnectAudioChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ptrViEBase->SetVoiceEngine(NULL);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEBase->DisconnectAudioChannel(videoChannel));
EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(NULL));
webrtc::ViEBase* ptrViEBase2 = webrtc::ViEBase::GetInterface(ptrViE);
numberOfErrors += ViETest::TestError(ptrViEBase2 != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(NULL != ptrViEBase2);
int remainingInterfaces = ptrViEBase->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 1,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(1, ptrViEBase->Release()) << "There should be one interface left.";
bool vieDeleted = webrtc::VideoEngine::Delete(ptrViE);
numberOfErrors += ViETest::TestError(vieDeleted == false,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_FALSE(webrtc::VideoEngine::Delete(ptrViE)) <<
"Should fail since there are interfaces left.";
remainingInterfaces = ptrViEBase->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
vieDeleted = webrtc::VideoEngine::Delete(ptrViE);
numberOfErrors += ViETest::TestError(vieDeleted == true,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
if (numberOfErrors > 0) {
ViETest::Log(" ");
ViETest::Log(" ERROR ViEBase API Test FAILED! ");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViEBase API Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
EXPECT_EQ(0, ptrViEBase->Release());
EXPECT_TRUE(webrtc::VideoEngine::Delete(ptrViE));
}

View File

@ -85,73 +85,56 @@ public:
unsigned char _frameRate;
};
class CaptureEffectFilter: public webrtc::ViEEffectFilter
class CaptureEffectFilter: public webrtc::ViEEffectFilter {
public:
CaptureEffectFilter(unsigned int expected_width, unsigned int expected_height)
: number_of_captured_frames_(0),
expected_width_(expected_width),
expected_height_(expected_height) {
}
// Implements ViEEffectFilter
virtual int Transform(int size, unsigned char* frameBuffer,
unsigned int timeStamp90KHz, unsigned int width,
unsigned int height) {
EXPECT_TRUE(frameBuffer != NULL);
EXPECT_EQ(expected_width_, width);
EXPECT_EQ(expected_height_, height);
++number_of_captured_frames_;
return 0;
}
int number_of_captured_frames_;
protected:
unsigned int expected_width_;
unsigned int expected_height_;
};
void ViEAutoTest::ViECaptureStandardTest()
{
public:
CaptureEffectFilter(unsigned int reqWidth, unsigned int reqHeight,
int& numberOfErrors) :
_numberOfCapturedFrames(0),
_reqWidth(reqWidth),
_reqHeight(reqHeight),
_numberOfErrors(numberOfErrors)
{
}
// Implements ViEEffectFilter
virtual int Transform(int size, unsigned char* frameBuffer,
unsigned int timeStamp90KHz, unsigned int width,
unsigned int height)
{
_numberOfErrors += ViETest::TestError(
frameBuffer != 0
&& width == _reqWidth
&& height == _reqHeight,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
++_numberOfCapturedFrames;
return 0;
}
int _numberOfCapturedFrames;
protected:
unsigned int _reqWidth;
unsigned int _reqHeight;
int& _numberOfErrors;
};
int ViEAutoTest::ViECaptureStandardTest()
{
int numberOfErrors = 0;
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViECapture StandardTest Test\n");
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
//***************************************************************
// Engine ready. Begin testing class
//***************************************************************
int error = 0;
TbInterfaces ViE("ViECaptureStandardTest", numberOfErrors);
TbInterfaces ViE("ViECaptureStandardTest");
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
webrtc::VideoCaptureFactory::CreateDeviceInfo(0);
int numberOfCaptureDevices = devInfo->NumberOfDevices();
ViETest::Log("Number of capture devices %d", numberOfCaptureDevices);
numberOfErrors += ViETest::TestError(numberOfCaptureDevices > 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_GT(numberOfCaptureDevices, 0);
int captureDeviceId[10];
webrtc::VideoCaptureModule* vcpms[10];
memset(vcpms, 0, sizeof(vcpms));
//Check capabilities
// Check capabilities
for (int deviceIndex = 0;
deviceIndex < numberOfCaptureDevices;
++deviceIndex)
@ -159,42 +142,33 @@ int ViEAutoTest::ViECaptureStandardTest()
WebRtc_UWord8 deviceName[128];
WebRtc_UWord8 deviceUniqueName[512];
error = devInfo->GetDeviceName(deviceIndex, deviceName,
sizeof(deviceName), deviceUniqueName,
sizeof(deviceUniqueName));
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, devInfo->GetDeviceName(deviceIndex,
deviceName,
sizeof(deviceName),
deviceUniqueName,
sizeof(deviceUniqueName)));
ViETest::Log("Found capture device %s\nUnique name %s", deviceName,
deviceUniqueName);
// not supported on MAC (is part of capture capabilites
// not supported on MAC (is part of capture capabilities)
#if !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC_INTEL)
error = ViE.capture->ShowCaptureSettingsDialogBox(
(char*) deviceUniqueName,
(unsigned int) (strlen((char*) deviceUniqueName)),
"WebRTCViECapture StandardTest");
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0,
ViE.capture->ShowCaptureSettingsDialogBox(
(char*) deviceUniqueName,
(unsigned int) (strlen((char*) deviceUniqueName)),
"WebRTCViECapture StandardTest"));
#endif
#if !defined(WEBRTC_MAC_INTEL) // these functions will return -1
unsigned int numberOfCapabilities =
#if !defined(WEBRTC_MAC_INTEL) // these functions will return -1
int numberOfCapabilities =
devInfo->NumberOfCapabilities(deviceUniqueName);
numberOfErrors += ViETest::TestError(numberOfCapabilities > 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_GT(numberOfCapabilities, 0);
for (unsigned int capIndex = 0;
capIndex < numberOfCapabilities;
++capIndex)
for (int capIndex = 0; capIndex < numberOfCapabilities; ++capIndex)
{
webrtc::VideoCaptureCapability capability;
error = devInfo->GetCapability(deviceUniqueName, capIndex,
capability);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, devInfo->GetCapability(deviceUniqueName, capIndex,
capability));
ViETest::Log("Capture capability %d (of %u)", capIndex + 1,
numberOfCapabilities);
ViETest::Log("witdh %d, height %d, frame rate %d",
@ -202,12 +176,11 @@ int ViEAutoTest::ViECaptureStandardTest()
ViETest::Log("expected delay %d, color type %d, encoding %d",
capability.expectedCaptureDelay, capability.rawType,
capability.codecType);
numberOfErrors += ViETest::TestError(
capability.width > 0
&& capability.height > 0
&& capability.maxFPS >= 0
&& capability.expectedCaptureDelay > 0,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
EXPECT_GT(capability.width, 0);
EXPECT_GT(capability.height, 0);
EXPECT_GT(capability.maxFPS, -1); // >= 0
EXPECT_GT(capability.expectedCaptureDelay, 0);
}
#endif
}
@ -222,39 +195,30 @@ int ViEAutoTest::ViECaptureStandardTest()
WebRtc_UWord8 deviceName[128];
WebRtc_UWord8 deviceUniqueName[512];
error = devInfo->GetDeviceName(deviceIndex, deviceName,
sizeof(deviceName), deviceUniqueName,
sizeof(deviceUniqueName));
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, devInfo->GetDeviceName(deviceIndex,
deviceName,
sizeof(deviceName),
deviceUniqueName,
sizeof(deviceUniqueName)));
webrtc::VideoCaptureModule* vcpm =
webrtc::VideoCaptureFactory::Create(
deviceIndex, deviceUniqueName);
EXPECT_TRUE(vcpm != NULL);
vcpm->AddRef();
numberOfErrors += ViETest::TestError(vcpm != NULL,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
vcpms[deviceIndex] = vcpm;
error = ViE.capture->AllocateCaptureDevice(
*vcpm, captureDeviceId[deviceIndex]);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(
*vcpm, captureDeviceId[deviceIndex]));
webrtc::VideoCaptureCapability capability;
error = devInfo->GetCapability(deviceUniqueName, 0, capability);
EXPECT_EQ(0, devInfo->GetCapability(deviceUniqueName, 0, capability));
// Test that the camera select the closest capability to the selected
// width and height.
CaptureEffectFilter filter(capability.width, capability.height,
numberOfErrors);
error = ViE.image_process->RegisterCaptureEffectFilter(
captureDeviceId[deviceIndex], filter);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
CaptureEffectFilter filter(capability.width, capability.height);
EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(
captureDeviceId[deviceIndex], filter));
ViETest::Log("Testing Device %s capability width %d height %d",
deviceUniqueName, capability.width, capability.height);
@ -273,31 +237,26 @@ int ViEAutoTest::ViECaptureStandardTest()
vieCapability.maxFPS = capability.maxFPS;
vieCapability.rawType = capability.rawType;
error = ViE.capture->StartCapture(captureDeviceId[deviceIndex],
vieCapability);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->StartCapture(captureDeviceId[deviceIndex],
vieCapability));
webrtc::TickTime startTime = webrtc::TickTime::Now();
while (filter._numberOfCapturedFrames < 10
while (filter.number_of_captured_frames_ < 10
&& (webrtc::TickTime::Now() - startTime).Milliseconds() < 10000)
{
AutoTestSleep(100);
}
numberOfErrors += ViETest::TestError(filter._numberOfCapturedFrames
>= 10, "ERROR: %s at line %d", __FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterCaptureEffectFilter(
captureDeviceId[deviceIndex]);
#ifdef WEBRTC_ANDROID // Can only allocate one camera at the time on Android
error = ViE.capture->StopCapture(captureDeviceId[deviceIndex]);
numberOfErrors += ViETest::TestError(error==0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_GT(filter.number_of_captured_frames_, 9) <<
"Should capture at least some frames";
error = ViE.capture->ReleaseCaptureDevice(
captureDeviceId[deviceIndex]);
numberOfErrors += ViETest::TestError(error==0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter(
captureDeviceId[deviceIndex]));
#ifdef WEBRTC_ANDROID // Can only allocate one camera at the time on Android.
EXPECT_EQ(0, ViE.capture->StopCapture(captureDeviceId[deviceIndex]));
EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(
captureDeviceId[deviceIndex]));
#endif
}
@ -306,84 +265,38 @@ int ViEAutoTest::ViECaptureStandardTest()
//***************************************************************
// stop all started capture devices
for (int deviceIndex = 0; deviceIndex < numberOfCaptureDevices; ++deviceIndex)
{
error = ViE.capture->StopCapture(captureDeviceId[deviceIndex]);
#ifdef WEBRTC_ANDROID
// Camera already stoped on Android since we can only allocate one
// camera at the time.
numberOfErrors += ViETest::TestError(error==-1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
#else
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
#endif
error = ViE.capture->ReleaseCaptureDevice(
captureDeviceId[deviceIndex]);
#ifdef WEBRTC_ANDROID
// Camera already stoped on Android since we can only allocate one
// camera at the time
numberOfErrors += ViETest::TestError(error==-1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
#else
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
#endif
vcpms[deviceIndex]->Release();
// Stop all started capture devices.
for (int deviceIndex = 0;
deviceIndex < numberOfCaptureDevices;
++deviceIndex) {
#if !defined(WEBRTC_ANDROID)
// Don't stop on Android since we can only allocate one camera.
EXPECT_EQ(0, ViE.capture->StopCapture(
captureDeviceId[deviceIndex]));
EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(
captureDeviceId[deviceIndex]));
#endif // !WEBRTC_ANDROID
vcpms[deviceIndex]->Release();
}
#endif
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViECapture Standard Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
delete devInfo;
ViETest::Log(" ");
ViETest::Log(" ViECapture Standard Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
#endif // !WEBRTC_MAC_INTEL
}
int ViEAutoTest::ViECaptureExtendedTest()
{
// Test
int numberOfErrors = 0;
numberOfErrors += ViECaptureStandardTest();
numberOfErrors += ViECaptureAPITest();
numberOfErrors += ViECaptureExternalCaptureTest();
return 0;
void ViEAutoTest::ViECaptureExtendedTest() {
ViECaptureStandardTest();
ViECaptureAPITest();
ViECaptureExternalCaptureTest();
}
int ViEAutoTest::ViECaptureAPITest()
void ViEAutoTest::ViECaptureAPITest()
{
int numberOfErrors = 0;
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViECapture API Test\n");
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
//***************************************************************
// Engine ready. Begin testing class
//***************************************************************
int error = 0;
TbInterfaces ViE("ViECaptureAPITest", numberOfErrors);
TbInterfaces ViE("ViECaptureAPITest");
ViE.capture->NumberOfCaptureDevices();
@ -393,292 +306,165 @@ int ViEAutoTest::ViECaptureAPITest()
webrtc::VideoCaptureModule::DeviceInfo* devInfo =
webrtc::VideoCaptureFactory::CreateDeviceInfo(0);
numberOfErrors += ViETest::TestError(devInfo != NULL,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_TRUE(devInfo != NULL);
// Get the first capture device
error = devInfo->GetDeviceName(0, deviceName, sizeof(deviceName),
deviceUniqueName, sizeof(deviceUniqueName));
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, devInfo->GetDeviceName(0, deviceName,
sizeof(deviceName),
deviceUniqueName,
sizeof(deviceUniqueName)));
webrtc::VideoCaptureModule* vcpm =
webrtc::VideoCaptureFactory::Create(
0, deviceUniqueName);
webrtc::VideoCaptureFactory::Create(0, deviceUniqueName);
vcpm->AddRef();
numberOfErrors += ViETest::TestError(vcpm != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(vcpm != NULL);
// Allocate capture device
error = ViE.capture->AllocateCaptureDevice(*vcpm, captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Allocate capture device.
EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId));
// Start the capture device
error = ViE.capture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Start the capture device.
EXPECT_EQ(0, ViE.capture->StartCapture(captureId));
// Start again. Should fail
error = ViE.capture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceAlreadyStarted, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Start again. Should fail.
EXPECT_NE(0, ViE.capture->StartCapture(captureId));
EXPECT_EQ(kViECaptureDeviceAlreadyStarted, ViE.LastError());
// Start invalid capture device
error = ViE.capture->StartCapture(captureId + 1);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Start invalid capture device.
EXPECT_NE(0, ViE.capture->StartCapture(captureId + 1));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
// Stop invalide capture device
error = ViE.capture->StopCapture(captureId + 1);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Stop invalid capture device.
EXPECT_NE(0, ViE.capture->StopCapture(captureId + 1));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
// Stop the capture device
error = ViE.capture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Stop the capture device.
EXPECT_EQ(0, ViE.capture->StopCapture(captureId));
// Stop the capture device again
error = ViE.capture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceNotStarted, "ERROR: %s at line %d", __FUNCTION__,
__LINE__);
// Stop the capture device again.
EXPECT_NE(0, ViE.capture->StopCapture(captureId));
EXPECT_EQ(kViECaptureDeviceNotStarted, ViE.LastError());
// Connect to invalid channel
error = ViE.capture->ConnectCaptureDevice(captureId, 0);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceInvalidChannelId, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Connect to invalid channel.
EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId, 0));
EXPECT_EQ(kViECaptureDeviceInvalidChannelId, ViE.LastError());
tbVideoChannel channel(ViE, numberOfErrors);
TbVideoChannel channel(ViE);
// Connect invalid captureId
error = ViE.capture->ConnectCaptureDevice(captureId + 1,
channel.videoChannel);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceDoesnNotExist,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
// Connect invalid captureId.
EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId + 1,
channel.videoChannel));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
// Connect the capture device to the channel
error = ViE.capture->ConnectCaptureDevice(captureId,
channel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Connect the capture device to the channel.
EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId,
channel.videoChannel));
// Connect the channel again
error = ViE.capture->ConnectCaptureDevice(captureId,
channel.videoChannel);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceAlreadyConnected, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Connect the channel again.
EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId,
channel.videoChannel));
EXPECT_EQ(kViECaptureDeviceAlreadyConnected, ViE.LastError());
// Start the capture device
error = ViE.capture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Start the capture device.
EXPECT_EQ(0, ViE.capture->StartCapture(captureId));
// Release invalid capture device.
error = ViE.capture->ReleaseCaptureDevice(captureId + 1);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId + 1));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
// Release the capture device
error = ViE.capture->ReleaseCaptureDevice(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Release the capture device.
EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId));
// Release the capture device again
error = ViE.capture->ReleaseCaptureDevice(captureId);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(ViE.LastError()
== kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Release the capture device again.
EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
// Test GetOrientation
// Test GetOrientation.
webrtc::VideoCaptureRotation orientation;
WebRtc_UWord8 dummy_name[5];
error = devInfo->GetOrientation(dummy_name, orientation);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, devInfo->GetOrientation(dummy_name, orientation));
//Test SetRotation
error = ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_90);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(
ViE.LastError() == kViECaptureDeviceDoesnNotExist,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
// Test SetRotation.
EXPECT_NE(0, ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_90));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
// Allocate capture device
error = ViE.capture->AllocateCaptureDevice(*vcpm, captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Allocate capture device.
EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId));
error = ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_90);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_180);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_270);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_0));
EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_90));
EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_180));
EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames(
captureId, webrtc::RotateCapturedFrame_270));
// Release the capture device
error = ViE.capture->ReleaseCaptureDevice(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
delete devInfo;
vcpm->Release();
EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId));
//***************************************************************
// Testing finished. Tear down Video Engine
//***************************************************************
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR WebRTCViECapture API Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" WebRTCViECapture API Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
delete devInfo;
vcpm->Release();
}
int ViEAutoTest::ViECaptureExternalCaptureTest()
void ViEAutoTest::ViECaptureExternalCaptureTest()
{
int numberOfErrors = 0;
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" WebRTCViECapture External Capture Test\n");
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
int error = 0;
TbInterfaces ViE("ViECaptureExternalCaptureTest", numberOfErrors);
tbVideoChannel channel(ViE, numberOfErrors);
TbInterfaces ViE("ViECaptureExternalCaptureTest");
TbVideoChannel channel(ViE);
channel.StartReceive();
channel.StartSend();
webrtc::VideoCaptureExternal* externalCapture;
int captureId = 0;
// Allocate the external capture device
webrtc::VideoCaptureModule* vcpm =
webrtc::VideoCaptureFactory::Create(
0, externalCapture);
// Allocate the external capture device.
webrtc::VideoCaptureModule* vcpm = webrtc::VideoCaptureFactory::Create(
0, externalCapture);
EXPECT_TRUE(vcpm != NULL);
EXPECT_TRUE(externalCapture != NULL);
vcpm->AddRef();
numberOfErrors += ViETest::TestError(vcpm != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.capture->AllocateCaptureDevice(*vcpm, captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(externalCapture != 0,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId));
// Connect the capture device to the channel
error = ViE.capture->ConnectCaptureDevice(captureId,
channel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Connect the capture device to the channel.
EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId,
channel.videoChannel));
// Render the local capture
error = ViE.render->AddRenderer(captureId, _window1, 1, 0.0, 0.0,
1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Render the local capture.
EXPECT_EQ(0, ViE.render->AddRenderer(captureId, _window1, 1, 0.0, 0.0,
1.0, 1.0));
// Render the remote capture
error = ViE.render->AddRenderer(channel.videoChannel, _window2, 1,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Render the remote capture.
EXPECT_EQ(0, ViE.render->AddRenderer(channel.videoChannel, _window2, 1,
0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(captureId));
EXPECT_EQ(0, ViE.render->StartRender(channel.videoChannel));
error = ViE.render->StartRender(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(channel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Register observer
// Register observer.
CaptureObserver observer;
error = ViE.capture->RegisterObserver(captureId, observer);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->RegisterObserver(captureId, observer));
// Enable brighness alarm
error = ViE.capture->EnableBrightnessAlarm(captureId, true);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Enable brightness alarm.
EXPECT_EQ(0, ViE.capture->EnableBrightnessAlarm(captureId, true));
CaptureEffectFilter effectFilter(176, 144, numberOfErrors);
error = ViE.image_process->RegisterCaptureEffectFilter(captureId,
effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Call started
CaptureEffectFilter effectFilter(176, 144);
EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(captureId,
effectFilter));
// Call started.
ViETest::Log("You should see local preview from external capture\n"
"in window 1 and the remote video in window 2.\n");
//***************************************************************
// Engine ready. Begin testing class
//***************************************************************
const unsigned int videoFrameLength = (176 * 144 * 3) / 2;
unsigned char* videoFrame = new unsigned char[videoFrameLength];
memset(videoFrame, 128, 176 * 144);
@ -701,21 +487,17 @@ int ViEAutoTest::ViECaptureExternalCaptureTest()
// while (fread(videoFrame, videoFrameLength, 1, foreman) == 1)
while (frameCount < 120)
{
externalCapture->IncomingFrame(
videoFrame, videoFrameLength, capability,
webrtc::TickTime::Now().MillisecondTimestamp());
AutoTestSleep(33);
if (effectFilter._numberOfCapturedFrames > 2)
if (effectFilter.number_of_captured_frames_ > 2)
{
// make sure brigthness or no picture alarm has not been triggered
numberOfErrors += ViETest::TestError(
observer._brightness == webrtc::Normal, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(
observer._alarm == webrtc::AlarmCleared, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(webrtc::Normal, observer._brightness) <<
"Brightness or picture alarm should not have been called yet.";
EXPECT_EQ(webrtc::AlarmCleared, observer._alarm) <<
"Brightness or picture alarm should not have been called yet.";
}
frameCount++;
}
@ -737,9 +519,8 @@ int ViEAutoTest::ViECaptureExternalCaptureTest()
webrtc::TickTime::Now().MillisecondTimestamp());
AutoTestSleep(33);
}
numberOfErrors += ViETest::TestError(observer._brightness == webrtc::Bright,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(webrtc::Bright, observer._brightness) <<
"Should be bright at this point since we are using a bright image.";
// Test Dark image
for (int i = 0; i < 176 * 144; ++i)
@ -753,27 +534,22 @@ int ViEAutoTest::ViECaptureExternalCaptureTest()
webrtc::TickTime::Now().MillisecondTimestamp());
AutoTestSleep(33);
}
numberOfErrors += ViETest::TestError(observer._brightness == webrtc::Dark,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(webrtc::Dark, observer._brightness) <<
"Should be dark at this point since we are using a dark image.";
EXPECT_GT(effectFilter.number_of_captured_frames_, 150) <<
"Frames should have been played.";
// Test that frames were played
numberOfErrors += ViETest::TestError(
effectFilter._numberOfCapturedFrames > 150,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
// Test frame rate callback
numberOfErrors += ViETest::TestError(observer._frameRate >= 29
&& observer._frameRate <= 30,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_GE(observer._frameRate, 29) <<
"Frame rate callback should be approximately correct.";
EXPECT_LE(observer._frameRate, 30) <<
"Frame rate callback should be approximately correct.";
// Test no picture alarm
ViETest::Log("Testing NoPictureAlarm.");
AutoTestSleep(1050);
numberOfErrors += ViETest::TestError(observer._alarm == webrtc::AlarmRaised,
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
EXPECT_EQ(webrtc::AlarmRaised, observer._alarm) <<
"No picture alarm should be raised.";
for (int frame = 0; frame < 10; ++frame)
{
externalCapture->IncomingFrame(
@ -781,45 +557,20 @@ int ViEAutoTest::ViECaptureExternalCaptureTest()
webrtc::TickTime::Now().MillisecondTimestamp());
AutoTestSleep(33);
}
numberOfErrors += ViETest::TestError(
observer._alarm == webrtc::AlarmCleared, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(webrtc::AlarmCleared, observer._alarm) <<
"Alarm should be cleared since ge just got some data.";
delete videoFrame;
// Release the capture device
error = ViE.capture->ReleaseCaptureDevice(captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId));
// Release the capture device again
error = ViE.capture->ReleaseCaptureDevice(captureId);
numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(
ViE.LastError() == kViECaptureDeviceDoesnNotExist,
"ERROR: %s at line %d", __FUNCTION__, __LINE__);
EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId));
EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError());
vcpm->Release();
//***************************************************************
// Testing finished. Tear down Video Engine
//***************************************************************
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR WebRTCViECapture External Capture Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" WebRTCViECapture External Capture Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}

File diff suppressed because it is too large Load Diff

View File

@ -167,7 +167,7 @@ int ViEAutoTest::ViECustomCall()
"ERROR: %s at line %d", __FUNCTION__,
__LINE__);
webrtc::VoEHardware* ptrVEHardware =
webrtc::VoEHardware* ptrVEHardware =
webrtc::VoEHardware::GetInterface(ptrVE);
numberOfErrors += ViETest::TestError(ptrVEHardware != NULL,
"ERROR: %s at line %d", __FUNCTION__,
@ -194,7 +194,7 @@ int ViEAutoTest::ViECustomCall()
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
webrtc::ViECapture* ptrViECapture =
webrtc::ViECapture* ptrViECapture =
webrtc::ViECapture::GetInterface(ptrViE);
numberOfErrors += ViETest::TestError(ptrViECapture != NULL,
"ERROR: %s at line %d", __FUNCTION__,
@ -240,7 +240,7 @@ int ViEAutoTest::ViECustomCall()
webrtc::CodecInst audioCodec;
int audioChannel = -1;
int protectionMethod = 0;
// TODO (amyfong): Change the observers to pointers, use NULL checks to
// TODO (amyfong): Change the observers to pointers, use NULL checks to
// toggle between registered or deregistered
bool isEncoderObserverRegistered = false;
bool isDecoderObserverRegistered = false;
@ -434,8 +434,8 @@ int ViEAutoTest::ViECustomCall()
__FUNCTION__, __LINE__);
// Set all video protection to false initially
// shouldn't be nessecary as ViE protection modes are all off
// initially.
// TODO(amyfong): Remove the set to false and use
// initially.
// TODO(amyfong): Remove the set to false and use
// SetVideoProtection instead.
error = ptrViERtpRtcp->SetHybridNACKFECStatus(videoChannel, false,
VCM_RED_PAYLOAD_TYPE,
@ -454,11 +454,11 @@ int ViEAutoTest::ViECustomCall()
"ERROR: %s at line %d",
__FUNCTION__, __LINE__);
// Set video protection for FEC, NACK or Hybrid.
// TODO(amyfong): Use SetVideoProtection instead, need to
// TODO(amyfong): Use SetVideoProtection instead, need to
// move the set protection method after the first SetReceiveCodec
// also should change and use videoSendCodec & videoReceiveCodec
// instead of just videoCodec. Helps check what exactly the call
// setup is onces the call is up and running.
// setup is onces the call is up and running.
switch (protectionMethod) {
case 0: // None
// No protection selected, all protection already at false
@ -525,7 +525,7 @@ int ViEAutoTest::ViECustomCall()
__FUNCTION__, __LINE__);
// Set receive codecs for FEC and hybrid NACK/FEC.
// TODO(amyfong): Use SetVideoProtection instead, need to
// TODO(amyfong): Use SetVideoProtection instead, need to
// move the set protection method after the first SetReceiveCodec
// also should change and use videoSendCodec & videoReceiveCodec
// instead of just videoCodec. Helps check what exactly the call
@ -638,14 +638,14 @@ int ViEAutoTest::ViECustomCall()
std::cout << " 5. Record Incoming Call" << std::endl;
std::cout << " 6. Record Outgoing Call" << std::endl;
std::cout << " 7. Play File on Video Channel"
<< "(Assumes you recorded incoming & outgoing call)"
<< "(Assumes you recorded incoming & outgoing call)"
<< std::endl;
std::cout << " 8. Change Video Protection Method" << std::endl;
std::cout << " 9. Toggle Encoder Observer" << std::endl;
std::cout << " 10. Toggle Decoder Observer" << std::endl;
std::cout << " 11. Print Call Information" << std::endl;
std::cout << " 12. Print Call Statistics" << std::endl;
std::cout << " 13. Toggle Image Scaling "
std::cout << " 13. Toggle Image Scaling "
<< "(Warning high CPU usage when enabled)"
<< std::endl;
std::cout << "What do you want to do? ";
@ -664,7 +664,7 @@ int ViEAutoTest::ViECustomCall()
modify_call = false;
break;
case 1:
// Change video Codec
// Change video Codec
SetVideoCodecType(ptrViECodec, videoCodec);
SetVideoCodecSize(ptrViECodec, videoCodec);
SetVideoCodecBitrate(ptrViECodec, videoCodec);
@ -778,7 +778,7 @@ int ViEAutoTest::ViECustomCall()
break;
case 5:
// Record the incoming call
std::cout << "Start Recording Incoming Video "
std::cout << "Start Recording Incoming Video "
<< DEFAULT_INCOMING_FILE_NAME << std::endl;
error = ptrViEFile->StartRecordIncomingVideo(
videoChannel, DEFAULT_INCOMING_FILE_NAME,
@ -794,7 +794,7 @@ int ViEAutoTest::ViECustomCall()
break;
case 6:
// Record the outgoing call
std::cout << "Start Recording Outgoing Video "
std::cout << "Start Recording Outgoing Video "
<< DEFAULT_OUTGOING_FILE_NAME << std::endl;
error = ptrViEFile->StartRecordOutgoingVideo(
videoChannel, DEFAULT_OUTGOING_FILE_NAME,
@ -814,7 +814,7 @@ int ViEAutoTest::ViECustomCall()
std::cout << "Available files to play" << std::endl;
std::cout << " 0. " << DEFAULT_INCOMING_FILE_NAME << std::endl;
std::cout << " 1. " << DEFAULT_OUTGOING_FILE_NAME << std::endl;
std::cout << "Press enter for default ("
std::cout << "Press enter for default ("
<< DEFAULT_INCOMING_FILE_NAME << "): ";
std::getline(std::cin, str);
file_selection = atoi(str.c_str());
@ -824,7 +824,7 @@ int ViEAutoTest::ViECustomCall()
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
if (file_selection == 1)
if (file_selection == 1)
error = ptrViEFile->StartPlayFile(DEFAULT_OUTGOING_FILE_NAME,
fileId, true);
else
@ -841,7 +841,7 @@ int ViEAutoTest::ViECustomCall()
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
std::cout << std::endl;
std::cout << "Start sending the file that is played in a loop "
std::cout << "Start sending the file that is played in a loop "
<< std::endl;
error = ptrViEFile->SendFileOnChannel(fileId, videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
@ -887,7 +887,7 @@ int ViEAutoTest::ViECustomCall()
audioCodec, audioTxPort,
audioRxPort);
modify_call = true;
break;
break;
case 9:
// Toggle Encoder Observer
if (!isEncoderObserverRegistered) {
@ -936,7 +936,7 @@ int ViEAutoTest::ViECustomCall()
audioCodec, audioTxPort,
audioRxPort);
PrintVideoStreamInformation(ptrViECodec,
videoChannel);
videoChannel);
modify_call = true;
break;
case 12:
@ -965,7 +965,7 @@ int ViEAutoTest::ViECustomCall()
modify_call = true;
break;
default:
// invalid selection, shows options menu again
// invalid selection, shows options menu again
std::cout << "Invalid selection. Select Again." << std::endl;
break;
}
@ -1505,7 +1505,7 @@ bool GetAudioCodec(webrtc::VoECodec* ptrVeCodec,
std::cout << "ERROR: Code = " << error << " Invalid selection"
<< std::endl;
continue;
}
}
return true;
}
}
@ -1579,7 +1579,7 @@ bool SetVideoCodecType(webrtc::ViECodec* ptrViECodec,
if (strcmp(videoCodec.plName, DEFAULT_VIDEO_CODEC) == 0) {
defaultCodecIdx = codecIdx;
}
std::cout << " " << codecIdx+1 << ". " << videoCodec.plName
std::cout << " " << codecIdx+1 << ". " << videoCodec.plName
<< std::endl;
}
std::cout << std::endl;
@ -1638,7 +1638,7 @@ bool SetVideoCodecResolution(webrtc::ViECodec* ptrViECodec,
std::getline(std::cin, str);
sizeOption = atoi(str.c_str());
switch (sizeOption) {
case 1:
videoCodec.width = 128;

View File

@ -33,26 +33,16 @@ public:
}
};
int ViEAutoTest::ViEFileStandardTest()
void ViEAutoTest::ViEFileStandardTest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEFile Standard Test\n");
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
int error = 0;
int numberOfErrors = 0;
{
ViETest::Log("Starting a loopback call...");
TbInterfaces interfaces = TbInterfaces("ViEFileStandardTest",
numberOfErrors);
TbInterfaces interfaces = TbInterfaces("ViEFileStandardTest");
webrtc::VideoEngine* ptrViE = interfaces.video_engine;
webrtc::ViEBase* ptrViEBase = interfaces.base;
@ -62,112 +52,50 @@ int ViEAutoTest::ViEFileStandardTest()
webrtc::ViERTP_RTCP* ptrViERtpRtcp = interfaces.rtp_rtcp;
webrtc::ViENetwork* ptrViENetwork = interfaces.network;
TbCaptureDevice captureDevice = TbCaptureDevice(interfaces,
numberOfErrors);
TbCaptureDevice captureDevice = TbCaptureDevice(interfaces);
int captureId = captureDevice.captureId;
int videoChannel = -1;
error = ptrViEBase->CreateChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel));
EXPECT_EQ(0, ptrViECapture->ConnectCaptureDevice(
captureId, videoChannel));
error = ptrViECapture->ConnectCaptureDevice(captureId, videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViERtpRtcp->SetRTCPStatus(
videoChannel, webrtc::kRtcpCompound_RFC4585));
EXPECT_EQ(0, ptrViERtpRtcp->SetKeyFrameRequestMethod(
videoChannel, webrtc::kViEKeyFrameRequestPliRtcp));
EXPECT_EQ(0, ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true));
error = ptrViERtpRtcp->SetRTCPStatus(videoChannel,
webrtc::kRtcpCompound_RFC4585);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERtpRtcp->SetKeyFrameRequestMethod(
videoChannel, webrtc::kViEKeyFrameRequestPliRtcp);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->AddRenderer(captureId, _window1, 0, 0.0, 0.0,
1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->AddRenderer(videoChannel, _window2, 1, 0.0, 0.0,
1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StartRender(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StartRender(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViERender->AddRenderer(
captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ptrViERender->AddRenderer(
videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ptrViERender->StartRender(captureId));
EXPECT_EQ(0, ptrViERender->StartRender(videoChannel));
webrtc::VideoCodec videoCodec;
memset(&videoCodec, 0, sizeof(webrtc::VideoCodec));
for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++)
{
error = ptrViECodec->GetCodec(idx, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec));
EXPECT_EQ(0, ptrViECodec->SetReceiveCodec(videoChannel,
videoCodec));
}
// Find the codec used for encoding the channel
for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++)
{
error = ptrViECodec->GetCodec(idx, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec));
if (videoCodec.codecType == webrtc::kVideoCodecVP8)
{
error = ptrViECodec->SetSendCodec(videoChannel, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECodec->SetSendCodec(videoChannel, videoCodec));
break;
}
}
// Find the codec used for recording.
for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++)
{
error = ptrViECodec->GetCodec(idx, videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec));
if (videoCodec.codecType == webrtc::kVideoCodecI420)
{
break;
@ -177,36 +105,13 @@ int ViEAutoTest::ViEFileStandardTest()
const char* ipAddress = "127.0.0.1";
const unsigned short rtpPort = 6000;
error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEBase->StartReceive(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViENetwork->SetSendDestination(videoChannel, ipAddress,
rtpPort);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEBase->StartSend(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort));
EXPECT_EQ(0, ptrViEBase->StartReceive(videoChannel));
EXPECT_EQ(0, ptrViENetwork->SetSendDestination(
videoChannel, ipAddress, rtpPort));
EXPECT_EQ(0, ptrViEBase->StartSend(videoChannel));
webrtc::ViEFile* ptrViEFile = webrtc::ViEFile::GetInterface(ptrViE);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_TRUE(ptrViEFile != NULL);
webrtc::VoiceEngine* ptrVEEngine = webrtc::VoiceEngine::Create();
webrtc::VoEBase* ptrVEBase = webrtc::VoEBase::GetInterface(ptrVEEngine);
@ -245,14 +150,20 @@ int ViEAutoTest::ViEFileStandardTest()
const int VIDEO_LENGTH = 5000;
const char renderStartImage[1024] = VIE_TEST_FILES_ROOT "renderStartImage.jpg";
const char captureDeviceImage[1024] = VIE_TEST_FILES_ROOT "captureDeviceImage.jpg";
const char renderTimeoutFile[1024] = VIE_TEST_FILES_ROOT "renderTimeoutImage.jpg";
const char snapshotCaptureDeviceFileName[256] = VIE_TEST_FILES_ROOT
"snapshotCaptureDevice.jpg";
const char incomingVideo[1024] = VIE_TEST_FILES_ROOT "incomingVideo.avi";
const char outgoingVideo[1024] = VIE_TEST_FILES_ROOT "outgoingVideo.avi";
char snapshotRenderFileName[256] = VIE_TEST_FILES_ROOT "snapshotRenderer.jpg";
const char renderStartImage[1024] =
VIE_TEST_FILES_ROOT "renderStartImage.jpg";
const char captureDeviceImage[1024] =
VIE_TEST_FILES_ROOT "captureDeviceImage.jpg";
const char renderTimeoutFile[1024] =
VIE_TEST_FILES_ROOT "renderTimeoutImage.jpg";
const char snapshotCaptureDeviceFileName[256] =
VIE_TEST_FILES_ROOT "snapshotCaptureDevice.jpg";
const char incomingVideo[1024] =
VIE_TEST_FILES_ROOT "incomingVideo.avi";
const char outgoingVideo[1024] =
VIE_TEST_FILES_ROOT "outgoingVideo.avi";
char snapshotRenderFileName[256] =
VIE_TEST_FILES_ROOT "snapshotRenderer.jpg";
webrtc::ViEPicture capturePicture;
webrtc::ViEPicture renderPicture;
@ -268,24 +179,14 @@ int ViEAutoTest::ViEFileStandardTest()
ViETest::Log("Recording incoming video (currently no audio) for %d "
"seconds", VIDEO_LENGTH);
error = ptrViEFile->StartRecordIncomingVideo(videoChannel,
incomingVideo,
webrtc::NO_AUDIO,
audioCodec2,
videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StartRecordIncomingVideo(
videoChannel, incomingVideo, webrtc::NO_AUDIO,
audioCodec2, videoCodec));
AutoTestSleep(VIDEO_LENGTH);
ViETest::Log("Stop recording incoming video");
error = ptrViEFile->StopRecordIncomingVideo(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StopRecordIncomingVideo(videoChannel));
ViETest::Log("Done\n");
}
@ -297,13 +198,8 @@ int ViEAutoTest::ViEFileStandardTest()
webrtc::CodecInst fileAudioCodec;
ViETest::Log("Reading video file information");
error = ptrViEFile->GetFileInformation(incomingVideo,
fileVideoCodec,
fileAudioCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->GetFileInformation(
incomingVideo, fileVideoCodec, fileAudioCodec));
PrintAudioCodec(fileAudioCodec);
PrintVideoCodec(fileVideoCodec);
}
@ -311,23 +207,10 @@ int ViEAutoTest::ViEFileStandardTest()
// testing StartPlayFile and RegisterObserver
{
ViETest::Log("Start playing file: %s with observer", incomingVideo);
error = ptrViEFile->StartPlayFile(incomingVideo, fileId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StartPlayFile(incomingVideo, fileId));
ViETest::Log("Registering file observer");
error = ptrViEFile->RegisterObserver(fileId, fileObserver);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->RegisterObserver(fileId, fileObserver));
ViETest::Log("Done\n");
}
@ -335,33 +218,17 @@ int ViEAutoTest::ViEFileStandardTest()
{
ViETest::Log("Sending video on channel");
// should fail since we are sending the capture device.
error = ptrViEFile->SendFileOnChannel(fileId, videoChannel);
numberOfErrors += ViETest::TestError(error == -1,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_NE(0, ptrViEFile->SendFileOnChannel(fileId, videoChannel));
// Disconnect the camera
error = ptrViECapture->DisconnectCaptureDevice(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->DisconnectCaptureDevice(videoChannel));
// And try playing the file again.
error = ptrViEFile->SendFileOnChannel(fileId, videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->SendFileOnChannel(fileId, videoChannel));
AutoTestSleep(VIDEO_LENGTH);
ViETest::Log("Stopped sending video on channel");
error = ptrViEFile->StopSendFileOnChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StopSendFileOnChannel(videoChannel));
ViETest::Log("Done\n");
}
@ -370,54 +237,32 @@ int ViEAutoTest::ViEFileStandardTest()
// stop playing the file
{
ViETest::Log("Stop playing the file.");
error = ptrViEFile->StopPlayFile(fileId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StopPlayFile(fileId));
ViETest::Log("Done\n");
}
// testing StartRecordOutgoingVideo and StopRecordOutgoingVideo
{
// connect the camera to the output.
error = ptrViECapture->ConnectCaptureDevice(captureId,
videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->ConnectCaptureDevice(
captureId, videoChannel));
ViETest::Log("Recording outgoing video (currently no audio) for %d "
"seconds", VIDEO_LENGTH);
error = ptrViEFile->StartRecordOutgoingVideo(videoChannel,
outgoingVideo,
webrtc::NO_AUDIO,
audioCodec2,
videoCodec);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StartRecordOutgoingVideo(
videoChannel, outgoingVideo, webrtc::NO_AUDIO,
audioCodec2, videoCodec));
AutoTestSleep(VIDEO_LENGTH);
ViETest::Log("Stop recording outgoing video");
error = ptrViEFile->StopRecordOutgoingVideo(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->StopRecordOutgoingVideo(videoChannel));
ViETest::Log("Done\n");
}
// again testing GetFileInformation
{
error = ptrViEFile->GetFileInformation(incomingVideo, videoCodec,
audioCodec2);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->GetFileInformation(
incomingVideo, videoCodec, audioCodec2));
PrintAudioCodec(audioCodec2);
PrintVideoCodec(videoCodec);
}
@ -438,13 +283,9 @@ int ViEAutoTest::ViEFileStandardTest()
ViETest::Log("...1");
AutoTestSleep(1000);
ViETest::Log("...Taking picture!");
error = ptrViEFile->GetCaptureDeviceSnapshot(captureId,
capturePicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
ViETest::Log("Remove paper. Picture has been taken");
EXPECT_EQ(0, ptrViEFile->GetCaptureDeviceSnapshot(
captureId, capturePicture));
ViETest::Log("Picture has been taken.");
AutoTestSleep(TEST_SPACING);
ViETest::Log("Done\n");
@ -457,13 +298,9 @@ int ViEAutoTest::ViEFileStandardTest()
ViETest::Log("Testing GetRenderSnapshot(int, char*)");
ViETest::Log("Taking snapshot of videoChannel %d", captureId);
error = ptrViEFile->GetRenderSnapshot(captureId,
snapshotRenderFileName);
EXPECT_EQ(0, ptrViEFile->GetRenderSnapshot(
captureId, snapshotRenderFileName));
ViETest::Log("Wrote image to file %s", snapshotRenderFileName);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
ViETest::Log("Done\n");
AutoTestSleep(TEST_SPACING);
}
@ -471,11 +308,8 @@ int ViEAutoTest::ViEFileStandardTest()
// GetRenderSnapshot
{
ViETest::Log("Testing GetRenderSnapshot(int, ViEPicture)");
error = ptrViEFile->GetRenderSnapshot(captureId, renderPicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->GetRenderSnapshot(
captureId, renderPicture));
ViETest::Log("Done\n");
}
@ -485,14 +319,10 @@ int ViEAutoTest::ViEFileStandardTest()
{
ViETest::Log("Testing GetCaptureDeviceSnapshot(int, char*)");
ViETest::Log("Taking snapshot from capture device %d", captureId);
error = ptrViEFile->GetCaptureDeviceSnapshot(
captureId, snapshotCaptureDeviceFileName);
EXPECT_EQ(0, ptrViEFile->GetCaptureDeviceSnapshot(
captureId, snapshotCaptureDeviceFileName));
ViETest::Log("Wrote image to file %s",
snapshotCaptureDeviceFileName);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
ViETest::Log("Done\n");
}
@ -501,26 +331,13 @@ int ViEAutoTest::ViEFileStandardTest()
// Testing: SetCaptureDeviceImage
{
ViETest::Log("Testing SetCaptureDeviceImage(int, char*)");
error = ptrViECapture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEFile->SetCaptureDeviceImage(captureId,
captureDeviceImage);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
EXPECT_EQ(0, ptrViEFile->SetCaptureDeviceImage(
captureId, captureDeviceImage));
ViETest::Log("you should see the capture device image now");
AutoTestSleep(2 * RENDER_TIMEOUT);
error = ptrViECapture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StartCapture(captureId));
ViETest::Log("Done\n");
}
@ -529,26 +346,13 @@ int ViEAutoTest::ViEFileStandardTest()
// Testing: SetCaptureDeviceImage
{
ViETest::Log("Testing SetCaptureDeviceImage(int, ViEPicture)");
error = ptrViECapture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error
= ptrViEFile->SetCaptureDeviceImage(captureId, capturePicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
EXPECT_EQ(0, ptrViEFile->SetCaptureDeviceImage(
captureId, capturePicture));
ViETest::Log("you should see the capture device image now");
AutoTestSleep(2 * RENDER_TIMEOUT);
error = ptrViECapture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StartCapture(captureId));
ViETest::Log("Done\n");
}
@ -560,38 +364,17 @@ int ViEAutoTest::ViEFileStandardTest()
// set render image, then stop capture and stop render to display it
ViETest::Log("Stoping renderer, setting start image, then "
"restarting");
error = ptrViEFile->SetRenderStartImage(videoChannel,
renderStartImage);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViECapture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StopRender(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->SetRenderStartImage(
videoChannel, renderStartImage));
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
EXPECT_EQ(0, ptrViERender->StopRender(videoChannel));
ViETest::Log("Render start image should be displayed.");
AutoTestSleep(RENDER_TIMEOUT);
// restarting capture and render
error = ptrViECapture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StartRender(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StartCapture(captureId));
EXPECT_EQ(0, ptrViERender->StartRender(videoChannel));
ViETest::Log("Done\n");
}
@ -603,37 +386,17 @@ int ViEAutoTest::ViEFileStandardTest()
// set render image, then stop capture and stop render to display it
ViETest::Log("Stoping renderer, setting start image, then "
"restarting");
error = ptrViEFile->SetRenderStartImage(videoChannel,
capturePicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViECapture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StopRender(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->SetRenderStartImage(
videoChannel, capturePicture));
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
EXPECT_EQ(0, ptrViERender->StopRender(videoChannel));
ViETest::Log("Render start image should be displayed.");
AutoTestSleep(RENDER_TIMEOUT);
// restarting capture and render
error = ptrViECapture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StartRender(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StartCapture(captureId));
EXPECT_EQ(0, ptrViERender->StartRender(videoChannel));
ViETest::Log("Done\n");
}
@ -645,32 +408,19 @@ int ViEAutoTest::ViEFileStandardTest()
ViETest::Log("Testing SetRenderTimeoutImage(int, char*)");
ViETest::Log("Stopping capture device to induce timeout of %d ms",
RENDER_TIMEOUT);
error = ptrViEFile->SetRenderTimeoutImage(videoChannel,
renderTimeoutFile,
RENDER_TIMEOUT);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->SetRenderTimeoutImage(
videoChannel, renderTimeoutFile, RENDER_TIMEOUT));
// now stop sending frames to the remote renderer and wait for
// timeout
error = ptrViECapture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
AutoTestSleep(RENDER_TIMEOUT);
ViETest::Log("Timeout image should be displayed now for %d ms",
RENDER_TIMEOUT * 2);
AutoTestSleep(RENDER_TIMEOUT * 2);
// restart the capture device to undo the timeout
error = ptrViECapture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StartCapture(captureId));
ViETest::Log("Restarting capture device");
AutoTestSleep(RENDER_TIMEOUT);
ViETest::Log("Done\n");
@ -685,32 +435,19 @@ int ViEAutoTest::ViEFileStandardTest()
ViETest::Log("Testing SetRenderTimeoutImage(int, ViEPicture)");
ViETest::Log("Stopping capture device to induce timeout of %d",
RENDER_TIMEOUT);
error = ptrViEFile->SetRenderTimeoutImage(videoChannel,
capturePicture,
RENDER_TIMEOUT);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEFile->SetRenderTimeoutImage(
videoChannel, capturePicture, RENDER_TIMEOUT));
// now stop sending frames to the remote renderer and wait for
// timeout
error = ptrViECapture->StopCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
AutoTestSleep(RENDER_TIMEOUT);
ViETest::Log("Timeout image should be displayed now for %d",
RENDER_TIMEOUT * 2);
AutoTestSleep(RENDER_TIMEOUT * 2);
// restart the capture device to undo the timeout
error = ptrViECapture->StartCapture(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViECapture->StartCapture(captureId));
ViETest::Log("Restarting capture device");
ViETest::Log("Done\n");
}
@ -719,11 +456,7 @@ int ViEAutoTest::ViEFileStandardTest()
{
ViETest::Log("Deregistering file observer");
// Should fail since we don't observe this file.
error = ptrViEFile->DeregisterObserver(fileId, fileObserver);
numberOfErrors += ViETest::TestError(error == -1,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_NE(0, ptrViEFile->DeregisterObserver(fileId, fileObserver));
}
//***************************************************************
@ -731,126 +464,26 @@ int ViEAutoTest::ViEFileStandardTest()
//***************************************************************
error = ptrViEBase->StopReceive(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ptrViEBase->StopReceive(videoChannel));
EXPECT_EQ(0, ptrViEBase->StopSend(videoChannel));
EXPECT_EQ(0, ptrViERender->StopRender(videoChannel));
EXPECT_EQ(0, ptrViERender->RemoveRenderer(captureId));
EXPECT_EQ(0, ptrViERender->RemoveRenderer(videoChannel));
EXPECT_EQ(0, ptrViECapture->DisconnectCaptureDevice(videoChannel));
EXPECT_EQ(0, ptrViEFile->FreePicture(capturePicture));
EXPECT_EQ(0, ptrViEFile->FreePicture(renderPicture));
EXPECT_EQ(0, ptrViEFile->FreePicture(renderTimeoutPicture));
EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel));
error = ptrViEBase->StopSend(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->StopRender(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->RemoveRenderer(captureId);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViERender->RemoveRenderer(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViECapture->DisconnectCaptureDevice(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEFile->FreePicture(capturePicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEFile->FreePicture(renderPicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEFile->FreePicture(renderTimeoutPicture);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
error = ptrViEBase->DeleteChannel(videoChannel);
numberOfErrors += ViETest::TestError(error == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
int remainingInterfaces = 0;
remainingInterfaces = ptrViEFile->Release();
numberOfErrors += ViETest::TestError(remainingInterfaces == 0,
"ERROR:%d %s at line %d",
ptrViEBase->LastError(),
__FUNCTION__, __LINE__);
}
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViEFile API Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
EXPECT_EQ(0, ptrViEFile->Release());
}
#endif
ViETest::Log(" ");
ViETest::Log(" ViEFile Standard Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
}
int ViEAutoTest::ViEFileExtendedTest()
void ViEAutoTest::ViEFileExtendedTest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEFile Extended Test\n");
ViETest::Log(" ");
ViETest::Log(" ViEFile Extended Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
}
int ViEAutoTest::ViEFileAPITest()
void ViEAutoTest::ViEFileAPITest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEFile API Test- nothing tested. Only tested in Standard test.\n");
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
ViETest::Log(" ");
ViETest::Log(" ViEFile API Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
}

View File

@ -38,27 +38,18 @@ public:
}
};
int ViEAutoTest::ViEImageProcessStandardTest()
void ViEAutoTest::ViEImageProcessStandardTest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEImageProcess Standard Test\n");
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
int error = 0;
int numberOfErrors = 0;
int rtpPort = 6000;
// Create VIE
TbInterfaces ViE("ViEImageProcessAPITest", numberOfErrors);
TbInterfaces ViE("ViEImageProcessAPITest");
// Create a video channel
tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8);
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
// Create a capture device
TbCaptureDevice tbCapture(ViE, numberOfErrors);
TbCaptureDevice tbCapture(ViE);
tbCapture.ConnectTo(tbChannel.videoChannel);
tbChannel.StartReceive(rtpPort);
@ -66,23 +57,12 @@ int ViEAutoTest::ViEImageProcessStandardTest()
MyEffectFilter effectFilter;
error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel));
ViETest::Log("Capture device is renderered in Window 1");
ViETest::Log("Remote stream is renderered in Window 2");
@ -93,154 +73,80 @@ int ViEAutoTest::ViEImageProcessStandardTest()
//***************************************************************
error = ViE.image_process->RegisterCaptureEffectFilter(tbCapture.captureId,
effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter));
ViETest::Log("Black and white filter registered for capture device, "
"affects both windows");
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId));
error = ViE.image_process->RegisterRenderEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterRenderEffectFilter(
tbChannel.videoChannel, effectFilter));
ViETest::Log("Remove capture effect filter, adding filter for incoming "
"stream");
ViETest::Log("Only Window 2 should be black and white");
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->StopRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
int rtpPort2 = rtpPort + 100;
// Create a video channel
tbVideoChannel tbChannel2(ViE, numberOfErrors, webrtc::kVideoCodecVP8);
TbVideoChannel tbChannel2(ViE, webrtc::kVideoCodecVP8);
tbCapture.ConnectTo(tbChannel2.videoChannel);
tbChannel2.StartReceive(rtpPort2);
tbChannel2.StartSend(rtpPort2);
error = ViE.render->AddRenderer(tbChannel2.videoChannel, _window1, 1,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbChannel2.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterRenderEffectFilter(
tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->AddRenderer(
tbChannel2.videoChannel, _window1, 1, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbChannel2.videoChannel));
EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter(
tbChannel.videoChannel));
ViETest::Log("Local renderer removed, added new channel and rendering in "
"Window1.");
error = ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter));
ViETest::Log("Black and white filter registered for capture device, "
"affects both windows");
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId));
error = ViE.image_process->RegisterSendEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterSendEffectFilter(
tbChannel.videoChannel, effectFilter));
ViETest::Log("Capture filter removed.");
ViETest::Log("Black and white filter registered for one channel, Window2 "
"should be black and white");
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.image_process->DeregisterSendEffectFilter(
tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter(
tbChannel.videoChannel));
//***************************************************************
// Testing finished. Tear down Video Engine
//***************************************************************
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViEImageProcess Standard Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViEImageProcess Standard Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
}
int ViEAutoTest::ViEImageProcessExtendedTest()
void ViEAutoTest::ViEImageProcessExtendedTest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEImageProcess Extended Test\n");
int numberOfErrors = 0;
numberOfErrors = ViEImageProcessStandardTest();
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViEImageProcess Extended Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViEImageProcess Extended Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
ViEImageProcessStandardTest();
}
int ViEAutoTest::ViEImageProcessAPITest()
void ViEAutoTest::ViEImageProcessAPITest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViEImageProcess API Test\n");
int error = 0;
int numberOfErrors = 0;
TbInterfaces ViE("ViEImageProcessAPITest", numberOfErrors);
tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8);
TbCaptureDevice tbCapture(ViE, numberOfErrors);
TbInterfaces ViE("ViEImageProcessAPITest");
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
TbCaptureDevice tbCapture(ViE);
tbCapture.ConnectTo(tbChannel.videoChannel);
@ -250,165 +156,90 @@ int ViEAutoTest::ViEImageProcessAPITest()
// Capture effect filter
//
// Add effect filter
error = ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter));
// Add again -> error
error = ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ViE.image_process->RegisterCaptureEffectFilter(
tbCapture.captureId, effectFilter));
EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId));
// Double deregister
error = ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ViE.image_process->DeregisterCaptureEffectFilter(
tbCapture.captureId));
// Non-existing capture device
error = ViE.image_process->RegisterCaptureEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ViE.image_process->RegisterCaptureEffectFilter(
tbChannel.videoChannel, effectFilter));
//
// Render effect filter
//
error = ViE.image_process->RegisterRenderEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->RegisterRenderEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterRenderEffectFilter(
tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterRenderEffectFilter(
tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterRenderEffectFilter(
tbChannel.videoChannel, effectFilter));
EXPECT_NE(0, ViE.image_process->RegisterRenderEffectFilter(
tbChannel.videoChannel, effectFilter));
EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter(
tbChannel.videoChannel));
EXPECT_NE(0, ViE.image_process->DeregisterRenderEffectFilter(
tbChannel.videoChannel));
// Non-existing channel id
error = ViE.image_process->RegisterRenderEffectFilter(
tbCapture.captureId, effectFilter);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_NE(0, ViE.image_process->RegisterRenderEffectFilter(
tbCapture.captureId, effectFilter));
//
// Send effect filter
//
error = ViE.image_process->RegisterSendEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->RegisterSendEffectFilter(
tbChannel.videoChannel, effectFilter);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterSendEffectFilter(
tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->DeregisterSendEffectFilter(
tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->RegisterSendEffectFilter(
tbCapture.captureId, effectFilter);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->RegisterSendEffectFilter(
tbChannel.videoChannel, effectFilter));
EXPECT_NE(0, ViE.image_process->RegisterSendEffectFilter(
tbChannel.videoChannel, effectFilter));
EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter(
tbChannel.videoChannel));
EXPECT_NE(0, ViE.image_process->DeregisterSendEffectFilter(
tbChannel.videoChannel));
EXPECT_NE(0, ViE.image_process->RegisterSendEffectFilter(
tbCapture.captureId, effectFilter));
//
// Denoising
//
error = ViE.image_process->EnableDenoising(tbCapture.captureId, true);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDenoising(tbCapture.captureId, true);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDenoising(tbCapture.captureId, false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDenoising(tbCapture.captureId, false);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDenoising(tbChannel.videoChannel,
true);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->EnableDenoising(tbCapture.captureId, true));
EXPECT_NE(0, ViE.image_process->EnableDenoising(tbCapture.captureId, true));
EXPECT_EQ(0, ViE.image_process->EnableDenoising(
tbCapture.captureId, false));
EXPECT_NE(0, ViE.image_process->EnableDenoising(
tbCapture.captureId, false));
EXPECT_NE(0, ViE.image_process->EnableDenoising(
tbChannel.videoChannel, true));
//
// Deflickering
//
error = ViE.image_process->EnableDeflickering(tbCapture.captureId,
true);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDeflickering(tbCapture.captureId,
true);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDeflickering(tbCapture.captureId,
false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDeflickering(tbCapture.captureId,
false);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableDeflickering(tbChannel.videoChannel,
true);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.image_process->EnableDeflickering(
tbCapture.captureId, true));
EXPECT_NE(0, ViE.image_process->EnableDeflickering(
tbCapture.captureId, true));
EXPECT_EQ(0, ViE.image_process->EnableDeflickering(
tbCapture.captureId, false));
EXPECT_NE(0, ViE.image_process->EnableDeflickering(
tbCapture.captureId, false));
EXPECT_NE(0, ViE.image_process->EnableDeflickering(
tbChannel.videoChannel, true));
//
// Color enhancement
//
error = ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, true);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, true);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, false);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.image_process->EnableColorEnhancement(tbCapture.captureId,
true);
numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViEImageProcess Extended Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViEImageProcess Extended Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, false));
EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, true));
EXPECT_NE(0, ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, true));
EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, false));
EXPECT_NE(0, ViE.image_process->EnableColorEnhancement(
tbChannel.videoChannel, false));
EXPECT_NE(0, ViE.image_process->EnableColorEnhancement(
tbCapture.captureId, true));
}

View File

@ -23,6 +23,8 @@
#include "critical_section_wrapper.h"
#include "thread_wrapper.h"
DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode.");
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
: _hdsp1(NULL),
_hdsp2(NULL) {
@ -136,24 +138,24 @@ bool ViEAutoTestWindowManager::SetTopmostWindow() {
}
int main(int argc, char** argv) {
// This command-line flag is a transitory solution until we
// manage to rewrite all tests to GUnit tests. This flag is
// currently only supported in Linux.
if (argc > 1 && std::string(argv[1]) == "--automated") {
// Let GTest and GFlags handle flags from now on
argc -= 1;
argv += 1;
// Initialize logging
ViETest::Init();
// Initialize the testing framework
testing::InitGoogleTest(&argc, argv);
// Parse remaining flags:
google::ParseCommandLineFlags(&argc, &argv, true);
// Initialize the testing framework
testing::InitGoogleTest(&argc, argv);
// Parse remaining flags:
google::ParseCommandLineFlags(&argc, &argv, true);
// Run tests
return RUN_ALL_TESTS();
int result;
if (FLAGS_automated) {
// Run in automated mode
result = RUN_ALL_TESTS();
} else {
// Run in interactive mode
ViEAutoTestMain autoTest;
autoTest.UseAnswerFile("answers.txt");
result = autoTest.BeginOSIndependentTesting();
}
// Default: run in classic interactive mode.
ViEAutoTestMain autoTest;
autoTest.UseAnswerFile("answers.txt");
return autoTest.BeginOSIndependentTesting();
ViETest::Terminate();
return result;
}

View File

@ -10,338 +10,209 @@
#include "vie_autotest_main.h"
#include "gtest/gtest.h"
#include "vie_autotest_window_manager_interface.h"
#include "vie_window_creator.h"
#include "vie_autotest.h"
static const std::string kStandardTest = "ViEStandardIntegrationTest";
static const std::string kExtendedTest = "ViEExtendedIntegrationTest";
static const std::string kApiTest = "ViEApiIntegrationTest";
ViEAutoTestMain::ViEAutoTestMain()
: _answers(),
_answersCount(0),
_useAnswerFile() {
: answers_(),
answers_count_(0),
use_answer_file_() {
index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors";
index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors";
index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors";
index_to_test_method_map_[4] = "RunsEncryptionTestWithoutErrors";
index_to_test_method_map_[5] = "RunsFileTestWithoutErrors";
index_to_test_method_map_[6] = "RunsImageProcessTestWithoutErrors";
index_to_test_method_map_[7] = "RunsNetworkTestWithoutErrors";
index_to_test_method_map_[8] = "RunsRenderTestWithoutErrors";
index_to_test_method_map_[9] = "RunsRtpRtcpTestWithoutErrors";
}
int ViEAutoTestMain::AskUserForTestCase() {
int choice;
std::string answer;
do {
ViETest::Log("\nSpecific tests:");
ViETest::Log("\t 0. Go back to previous menu.");
// Print all test method choices. Assumes that map sorts on its key.
int last_valid_choice;
std::map<int, std::string>::const_iterator iterator;
for (iterator = index_to_test_method_map_.begin();
iterator != index_to_test_method_map_.end();
++iterator) {
ViETest::Log("\t %d. %s", iterator->first, iterator->second.c_str());
last_valid_choice = iterator->first;
}
ViETest::Log("Choose specific test:");
choice = AskUserForNumber(0, last_valid_choice);
} while (choice == kInvalidChoice);
return choice;
}
int ViEAutoTestMain::AskUserForNumber(int min_allowed, int max_allowed) {
int result;
if (use_answer_file_) {
assert(0 && "Answer files are not implemented");
return kInvalidChoice;
}
if (scanf("%d", &result) <= 0) {
ViETest::Log("\nPlease enter a number instead, then hit enter.");
getchar();
return kInvalidChoice;
}
getchar(); // Consume enter key.
if (result < min_allowed || result > max_allowed) {
ViETest::Log("%d-%d are valid choices. Please try again.", min_allowed,
max_allowed);
return kInvalidChoice;
}
return result;
}
int ViEAutoTestMain::RunTestMatching(const std::string test_case,
const std::string test_method) {
testing::FLAGS_gtest_filter = test_case + "." + test_method;
return RUN_ALL_TESTS();
}
int ViEAutoTestMain::RunSpecificTestCaseIn(const std::string test_case_name)
{
// If user says 0, it means don't run anything.
int specific_choice = AskUserForTestCase();
if (specific_choice != 0){
return RunTestMatching(test_case_name,
index_to_test_method_map_[specific_choice]);
}
return 0;
}
int ViEAutoTestMain::RunSpecialTestCase(int choice) {
// 7-9 don't run in GTest and need to initialize by themselves.
assert(choice >= 7 && choice <= 9);
// Create the windows
ViEWindowCreator windowCreator;
ViEAutoTestWindowManagerInterface* windowManager =
windowCreator.CreateTwoWindows();
// Create the test cases
ViEAutoTest vieAutoTest(windowManager->GetWindow1(),
windowManager->GetWindow2());
int errors;
switch (choice) {
case 7: errors = vieAutoTest.ViELoopbackCall(); break;
case 8: errors = vieAutoTest.ViECustomCall(); break;
case 9: errors = vieAutoTest.ViESimulcastCall(); break;
}
windowCreator.TerminateWindows();
return errors;
}
bool ViEAutoTestMain::BeginOSIndependentTesting() {
// Create the windows
ViEWindowCreator windowCreator;
ViEAutoTestWindowManagerInterface* windowManager =
windowCreator.CreateTwoWindows();
// Create the test cases
ViEAutoTest
vieAutoTest(windowManager->GetWindow1(),
windowManager->GetWindow2(),
ViETest::kUseAssertsForTestErrors);
ViETest::Log(" ============================== ");
ViETest::Log(" WebRTC ViE 3.x Autotest ");
ViETest::Log(" ============================== \n");
ViETest::Log(" ============================== ");
ViETest::Log(" WebRTC ViE 3.x Autotest ");
ViETest::Log(" ============================== \n");
int choice = 0;
int errors = 0;
do {
ViETest::Log("Test types: ");
ViETest::Log("\t 0. Quit");
ViETest::Log("\t 1. All standard tests (delivery test)");
ViETest::Log("\t 2. All API tests");
ViETest::Log("\t 3. All extended test");
ViETest::Log("\t 4. Specific standard test");
ViETest::Log("\t 5. Specific API test");
ViETest::Log("\t 6. Specific extended test");
ViETest::Log("\t 7. Simple loopback call");
ViETest::Log("\t 8. Custom configure a call");
ViETest::Log("\t 9. Simulcast in loopback");
ViETest::Log("Select type of test:");
int testType = 0;
int testErrors = 0;
do {
ViETest::Log("Test types: ");
ViETest::Log("\t 0. Quit");
ViETest::Log("\t 1. All standard tests (delivery test)");
ViETest::Log("\t 2. All API tests");
ViETest::Log("\t 3. All extended test");
ViETest::Log("\t 4. Specific standard test");
ViETest::Log("\t 5. Specific API test");
ViETest::Log("\t 6. Specific extended test");
ViETest::Log("\t 7. Simple loopback call");
ViETest::Log("\t 8. Custom configure a call");
ViETest::Log("\t 9. Simulcast in loopback");
ViETest::Log("Select type of test: ");
if (_useAnswerFile) {
// GetNextAnswer(str);
} else {
if (scanf("%d", &testType) <= 0) {
ViETest::Log("ERROR: unable to read selection. Try again\n");
testType = -1;
getchar();
continue;
}
getchar();
}
ViETest::Log("");
if (testType < 0 || testType > 8) {
ViETest::Log("ERROR: Invalid selection. Try again\n");
continue;
}
switch (testType) {
case 0:
break;
case 1:
{
int deliveryErrors = testErrors;
testErrors += vieAutoTest.ViEStandardTest();
if (testErrors == deliveryErrors) {
// No errors found in delivery test, create delivery
ViETest::Log("Standard/delivery passed.");
} else {
// Didn't pass, don't create delivery files
ViETest::Log("\nStandard/delivery test failed!\n");
}
break;
}
case 2:
testErrors += vieAutoTest.ViEAPITest();
break;
case 3:
testErrors += vieAutoTest.ViEExtendedTest();
break;
case 4: // Specific Standard
testType = GetClassTestSelection();
switch (testType) {
case 1: // base
testErrors += vieAutoTest.ViEBaseStandardTest();
break;
case 2: // capture
testErrors += vieAutoTest.ViECaptureStandardTest();
break;
case 3: // codec
testErrors += vieAutoTest.ViECodecStandardTest();
break;
case 5: // encryption
testErrors += vieAutoTest.ViEEncryptionStandardTest();
break;
case 6: // file
testErrors += vieAutoTest.ViEFileStandardTest();
break;
case 7: // image process
testErrors += vieAutoTest.ViEImageProcessStandardTest();
break;
case 8: // network
testErrors += vieAutoTest.ViENetworkStandardTest();
break;
case 9: // Render
testErrors += vieAutoTest.ViERenderStandardTest();
break;
case 10: // RTP/RTCP
testErrors += vieAutoTest.ViERtpRtcpStandardTest();
break;
case 11:
break;
default:
break;
}
break;
case 5: // specific API
testType = GetClassTestSelection();
switch (testType) {
case 1: // base
testErrors += vieAutoTest.ViEBaseAPITest();
break;
case 2: // capture
testErrors += vieAutoTest.ViECaptureAPITest();
break;
case 3: // codec
testErrors += vieAutoTest.ViECodecAPITest();
break;
case 5: // encryption
testErrors += vieAutoTest.ViEEncryptionAPITest();
break;
case 6: // file
testErrors += vieAutoTest.ViEFileAPITest();
break;
case 7: // image process
testErrors += vieAutoTest.ViEImageProcessAPITest();
break;
case 8: // network
testErrors += vieAutoTest.ViENetworkAPITest();
break;
case 9: // Render
testErrors += vieAutoTest.ViERenderAPITest();
break;
case 10: // RTP/RTCP
testErrors += vieAutoTest.ViERtpRtcpAPITest();
break;
case 11:
break;
default:
break;
}
break;
case 6: // specific extended
testType = GetClassTestSelection();
switch (testType) {
case 1: // base
testErrors += vieAutoTest.ViEBaseExtendedTest();
break;
case 2: // capture
testErrors += vieAutoTest.ViECaptureExtendedTest();
break;
case 3: // codec
testErrors += vieAutoTest.ViECodecExtendedTest();
break;
case 5: // encryption
testErrors += vieAutoTest.ViEEncryptionExtendedTest();
break;
case 6: // file
testErrors += vieAutoTest.ViEFileExtendedTest();
break;
case 7: // image process
testErrors += vieAutoTest.ViEImageProcessExtendedTest();
break;
case 8: // network
testErrors += vieAutoTest.ViENetworkExtendedTest();
break;
case 9: // Render
testErrors += vieAutoTest.ViERenderExtendedTest();
break;
case 10: // RTP/RTCP
testErrors += vieAutoTest.ViERtpRtcpExtendedTest();
break;
case 11:
break;
default:
break;
}
break;
case 7:
testErrors += vieAutoTest.ViELoopbackCall();
break;
case 8:
testErrors += vieAutoTest.ViECustomCall();
break;
case 9:
testErrors += vieAutoTest.ViESimulcastCall();
break;
default:
ViETest::Log("ERROR: Invalid selection. Try again\n");
continue;
}
} while (testType != 0);
windowCreator.TerminateWindows();
if (testErrors) {
ViETest::Log("Test done with errors, see ViEAutotestLog.txt for test "
"result.\n");
} else {
ViETest::Log("Test done without errors, see ViEAutotestLog.txt for "
"test result.\n");
choice = AskUserForNumber(0, 9);
if (choice == kInvalidChoice) {
continue;
}
printf("Press enter to quit...");
char c;
while ((c = getchar()) != '\n' && c != EOF) {
/* discard */
switch (choice) {
case 0: break;
case 1: errors = RunTestMatching(kStandardTest, "*"); break;
case 2: errors = RunTestMatching(kApiTest, "*"); break;
case 3: errors = RunTestMatching(kExtendedTest, "*"); break;
case 4: errors = RunSpecificTestCaseIn(kStandardTest); break;
case 5: errors = RunSpecificTestCaseIn(kApiTest); break;
case 6: errors = RunSpecificTestCaseIn(kExtendedTest); break;
default: errors = RunSpecialTestCase(choice); break;
}
} while (choice != 0);
return true;
}
int ViEAutoTestMain::GetClassTestSelection() {
int testType = 0;
std::string answer;
while (1) {
ViETest::Log("Choose specific test: ");
ViETest::Log("\t 1. Base ");
ViETest::Log("\t 2. Capture");
ViETest::Log("\t 3. Codec");
ViETest::Log("\t 5. Encryption");
ViETest::Log("\t 6. File");
ViETest::Log("\t 7. Image Process");
ViETest::Log("\t 8. Network");
ViETest::Log("\t 9. Render");
ViETest::Log("\t 10. RTP/RTCP");
ViETest::Log("\t 11. Go back to previous menu");
ViETest::Log("Select type of test: ");
int items_read = 0;
if (_useAnswerFile) {
// GetNextAnswer(answer);
} else {
items_read = scanf("%d", &testType);
getchar();
}
ViETest::Log("\n");
if (items_read == 1 && testType >= 1 && testType <= 13) {
return testType;
}
ViETest::Log("ERROR: Invalid selection. Try again");
}
return -1;
if (errors) {
ViETest::Log("Test done with errors, see ViEAutotestLog.txt for test "
"result.\n");
} else {
ViETest::Log("Test done without errors, see ViEAutotestLog.txt for "
"test result.\n");
}
return true;
}
bool ViEAutoTestMain::GetAnswer(int index, std::string* answer) {
if (!_useAnswerFile || index > _answersCount) {
return false;
}
*answer = _answers[index];
return true;
if (!use_answer_file_ || index > answers_count_) {
return false;
}
*answer = answers_[index];
return true;
}
bool ViEAutoTestMain::IsUsingAnswerFile() {
return _useAnswerFile;
return use_answer_file_;
}
// TODO(unknown): write without stl
// TODO(unknown): implement?
bool ViEAutoTestMain::UseAnswerFile(const char* fileName) {
return false;
/*
_useAnswerFile = false;
return false;
/*
use_answer_file_ = false;
ViETest::Log("Opening answer file: %s...", fileName);
ifstream answerFile(fileName);
if(!answerFile)
{
ViETest::Log("failed! X(\n");
return false;
ViETest::Log("failed! X(\n");
return false;
}
_answersCount = 1;
_answersIndex = 1;
answers_count_ = 1;
answers_index_ = 1;
char lineContent[128] = "";
while(!answerFile.eof())
{
answerFile.getline(lineContent, 128);
_answers[_answersCount++] = string(lineContent);
answerFile.getline(lineContent, 128);
answers_[answers_Count++] = string(lineContent);
}
answerFile.close();
cout << "Success :)" << endl << endl;
_useAnswerFile = true;
use_answer_file_ = true;
return _useAnswerFile;
*/
return use_answer_file_;
*/
}

File diff suppressed because it is too large Load Diff

View File

@ -76,144 +76,82 @@ private:
int _width, _height;
};
int ViEAutoTest::ViERenderStandardTest()
void ViEAutoTest::ViERenderStandardTest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViERender Standard Test\n");
//***************************************************************
// Begin create/initialize WebRTC Video Engine for testing
//***************************************************************
int error = 0;
int numberOfErrors = 0;
int rtpPort = 6000;
TbInterfaces ViE("ViERenderStandardTest", numberOfErrors);
TbInterfaces ViE("ViERenderStandardTest");
// Create a video channel
tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8);
TbCaptureDevice tbCapture(ViE, numberOfErrors); // Create a capture device
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
TbCaptureDevice tbCapture(ViE); // Create a capture device
tbCapture.ConnectTo(tbChannel.videoChannel);
tbChannel.StartReceive(rtpPort);
tbChannel.StartSend(rtpPort);
error = ViE.render->RegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RegisterVideoRenderModule(*_vrm2);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm2));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel));
ViETest::Log("\nCapture device is renderered in Window 1");
ViETest::Log("Remote stream is renderered in Window 2");
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->StopRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
// PIP and full screen rendering is not supported on Android
#ifndef WEBRTC_ANDROID
error = ViE.render->DeRegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbCapture.captureId, _window2, 0,
0.75, 0.75, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, _window2, 0, 0.75, 0.75, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
ViETest::Log("\nCapture device is now rendered in Window 2, PiP.");
ViETest::Log("Switching to full screen rendering in %d seconds.\n",
KAutoTestSleepTimeMs / 1000);
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RemoveRenderer(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->DeRegisterVideoRenderModule(*_vrm2);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm2));
// Destroy render module and create new in full screen mode
webrtc::VideoRender::DestroyVideoRender(_vrm1);
_vrm1 = NULL;
_vrm1 = webrtc::VideoRender::CreateVideoRender(
4563, _window1, true, _renderType);
numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(_vrm1 != NULL);
error = ViE.render->RegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0,
0.75f, 0.75f, 1.0f, 1.0f);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbChannel.videoChannel, _window1, 1,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, _window1, 0, 0.75f, 0.75f, 1.0f, 1.0f));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbChannel.videoChannel, _window1, 1, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel));
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
error = ViE.render->RemoveRenderer(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->DeRegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1));
// Destroy full screen render module and create new in normal mode
webrtc::VideoRender::DestroyVideoRender(_vrm1);
_vrm1 = NULL;
_vrm1 = webrtc::VideoRender::CreateVideoRender(
4561, _window1, false, _renderType);
numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(_vrm1 != NULL);
#endif
//***************************************************************
@ -224,72 +162,30 @@ int ViEAutoTest::ViERenderStandardTest()
//***************************************************************
// Testing finished. Tear down Video Engine
//***************************************************************
tbCapture.Disconnect(tbChannel.videoChannel);
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViERender Standard Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViERender Standard Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
}
int ViEAutoTest::ViERenderExtendedTest()
void ViEAutoTest::ViERenderExtendedTest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViERender Extended Test\n");
int error = 0;
int numberOfErrors = 0;
int rtpPort = 6000;
TbInterfaces ViE("ViERenderExtendedTest", numberOfErrors);
TbInterfaces ViE("ViERenderExtendedTest");
// Create a video channel
tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8);
TbCaptureDevice tbCapture(ViE, numberOfErrors); // Create a capture device
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
TbCaptureDevice tbCapture(ViE); // Create a capture device
tbCapture.ConnectTo(tbChannel.videoChannel);
tbChannel.StartReceive(rtpPort);
tbChannel.StartSend(rtpPort);
error = ViE.render->RegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RegisterVideoRenderModule(*_vrm2);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1,
0.0, 0.0, 1.0, 1.0);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm2));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0));
EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel));
ViETest::Log("\nCapture device is renderered in Window 1");
ViETest::Log("Remote stream is renderered in Window 2");
@ -298,207 +194,102 @@ int ViEAutoTest::ViERenderExtendedTest()
#ifdef _WIN32
ViETest::Log("\nConfiguring Window2");
ViETest::Log("you will see video only in first quadrant");
error = ViE.render->ConfigureRender(tbChannel.videoChannel, 0, 0.0f,
0.0f, 0.5f, 0.5f);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->ConfigureRender(
tbChannel.videoChannel, 0, 0.0f, 0.0f, 0.5f, 0.5f));
AutoTestSleep(KAutoTestSleepTimeMs);
ViETest::Log("you will see video only in fourth quadrant");
error = ViE.render->ConfigureRender(tbChannel.videoChannel, 0, 0.5f,
0.5f, 1.0f, 1.0f);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->ConfigureRender(
tbChannel.videoChannel, 0, 0.5f, 0.5f, 1.0f, 1.0f));
AutoTestSleep(KAutoTestSleepTimeMs);
ViETest::Log("normal video on Window2");
error = ViE.render->ConfigureRender(tbChannel.videoChannel, 0, 0.0f,
0.0f, 1.0f, 1.0f);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->ConfigureRender(
tbChannel.videoChannel, 0, 0.0f, 0.0f, 1.0f, 1.0f));
AutoTestSleep(KAutoTestSleepTimeMs);
#endif
ViETest::Log("Mirroring Local Preview (Window1) Left-Right");
error = ViE.render->MirrorRenderStream(tbCapture.captureId, true,
false, true);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbCapture.captureId, true, false, true));
AutoTestSleep(KAutoTestSleepTimeMs);
ViETest::Log("\nMirroring Local Preview (Window1) Left-Right and Up-Down");
error = ViE.render->MirrorRenderStream(tbCapture.captureId, true,
true, true);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbCapture.captureId, true, true, true));
AutoTestSleep(KAutoTestSleepTimeMs);
ViETest::Log("\nMirroring Remote Window(Window2) Up-Down");
error = ViE.render->MirrorRenderStream(tbChannel.videoChannel, true,
true, false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbChannel.videoChannel, true, true, false));
AutoTestSleep(KAutoTestSleepTimeMs);
ViETest::Log("Disabling Mirroing on Window1 and Window2");
error = ViE.render->MirrorRenderStream(tbCapture.captureId, false,
false, false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbCapture.captureId, false, false, false));
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->MirrorRenderStream(tbChannel.videoChannel, false,
false, false);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbChannel.videoChannel, false, false, false));
AutoTestSleep(KAutoTestSleepTimeMs);
ViETest::Log("\nEnabling Full Screen render in 5 sec");
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->DeRegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RemoveRenderer(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->DeRegisterVideoRenderModule(*_vrm2);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel));
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm2));
// Destroy render module and create new in full screen mode
webrtc::VideoRender::DestroyVideoRender(_vrm1);
_vrm1 = NULL;
_vrm1 = webrtc::VideoRender::CreateVideoRender(
4563, _window1, true, _renderType);
numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(_vrm1 != NULL);
error = ViE.render->RegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0,
0.0f, 0.0f, 1.0f, 1.0f);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1));
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, _window1, 0, 0.0f, 0.0f, 1.0f, 1.0f));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->StopRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
/* error = ViE.ptrViERender->StopRender(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__);
*/
ViETest::Log("\nStop renderer");
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
/* error = ViE.ptrViERender->RemoveRenderer(tbChannel.videoChannel);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__);
*/
EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId));
ViETest::Log("\nRemove renderer");
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
error = ViE.render->DeRegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1));
// Destroy full screen render module and create new for external rendering
webrtc::VideoRender::DestroyVideoRender(_vrm1);
_vrm1 = NULL;
_vrm1 = webrtc::VideoRender::CreateVideoRender(4564, NULL, false,
_renderType);
numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_TRUE(_vrm1 != NULL);
error = ViE.render->RegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1));
ViETest::Log("\nExternal Render Test");
ViEAutoTestExternalRenderer externalRenderObj;
error = ViE.render->AddRenderer(tbCapture.captureId,
webrtc::kVideoI420,
&externalRenderObj);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->StartRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->AddRenderer(
tbCapture.captureId, webrtc::kVideoI420, &externalRenderObj));
EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId));
AutoTestSleep(KAutoTestSleepTimeMs);
error = ViE.render->StopRender(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->RemoveRenderer(tbCapture.captureId);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = ViE.render->DeRegisterVideoRenderModule(*_vrm1);
numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));
EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1));
// Destroy render module for external rendering and create new in normal
// mode
webrtc::VideoRender::DestroyVideoRender(_vrm1);
_vrm1 = NULL;
_vrm1 = webrtc::VideoRender::CreateVideoRender(4561, _window1, false,
_renderType);
numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
_vrm1 = webrtc::VideoRender::CreateVideoRender(
4561, _window1, false, _renderType);
EXPECT_TRUE(_vrm1 != NULL);
tbCapture.Disconnect(tbChannel.videoChannel);
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViERender Extended Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViERender Extended Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
}
int ViEAutoTest::ViERenderAPITest()
void ViEAutoTest::ViERenderAPITest()
{
ViETest::Log(" ");
ViETest::Log("========================================");
ViETest::Log(" ViERender API Test\n");
int numberOfErrors = 0;
//TODO add the real tests cases
if (numberOfErrors > 0)
{
// Test failed
ViETest::Log(" ");
ViETest::Log(" ERROR ViERender API Test FAILED!");
ViETest::Log(" Number of errors: %d", numberOfErrors);
ViETest::Log("========================================");
ViETest::Log(" ");
return numberOfErrors;
}
ViETest::Log(" ");
ViETest::Log(" ViERender API Test PASSED!");
ViETest::Log("========================================");
ViETest::Log(" ");
return 0;
// TODO(unknown): add the real tests cases
}

View File

@ -18,49 +18,36 @@
#include "vie_fake_camera.h"
#include "vie_to_file_renderer.h"
ViEComparisonTests::ViEComparisonTests() {
ViETest::Init(ViETest::kUseGTestExpectsForTestErrors);
}
ViEComparisonTests::~ViEComparisonTests() {
ViETest::Terminate();
}
void ViEComparisonTests::TestCallSetup(
const std::string& i420_test_video_path,
const std::string& i420_video_file,
int width,
int height,
ViEToFileRenderer* local_file_renderer,
ViEToFileRenderer* remote_file_renderer) {
int ignored;
TbInterfaces interfaces("TestCallSetup", ignored);
TbInterfaces interfaces("TestCallSetup");
int video_channel = -1;
int error = interfaces.base->CreateChannel(video_channel);
ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel));
ViEFakeCamera fake_camera(interfaces.capture);
if (!fake_camera.StartCameraInNewThread(i420_test_video_path,
if (!fake_camera.StartCameraInNewThread(i420_video_file,
width,
height)) {
// No point in continuing if we have no proper video source
ViETest::TestError(false, "ERROR: %s at line %d: "
"Could not open input video %s: aborting test...",
__FUNCTION__, __LINE__, i420_test_video_path.c_str());
ADD_FAILURE() << "Could not open input video " << i420_video_file <<
": aborting test...";
return;
}
int capture_id = fake_camera.capture_id();
// Apparently, we need to connect external capture devices, but we should
// not start them since the external device is not a proper device.
error = interfaces.capture->ConnectCaptureDevice(capture_id,
video_channel);
ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice(
capture_id, video_channel));
ConfigureRtpRtcp(interfaces.rtp_rtcp, &ignored, video_channel);
ConfigureRtpRtcp(interfaces.rtp_rtcp, video_channel);
webrtc::ViERender *render_interface = interfaces.render;
@ -72,17 +59,15 @@ void ViEComparisonTests::TestCallSetup(
reinterpret_cast<const WebRtc_UWord8*>("Fake Capture Device");
::TestI420CallSetup(interfaces.codec, interfaces.video_engine,
interfaces.base, interfaces.network,
&ignored, video_channel, device_name);
interfaces.base, interfaces.network, video_channel,
device_name);
AutoTestSleep(KAutoTestSleepTimeMs);
error = interfaces.base->StopReceive(video_channel);
ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, interfaces.base->StopReceive(video_channel));
StopAndRemoveRenderers(interfaces.base, render_interface, &ignored,
video_channel, capture_id);
StopAndRemoveRenderers(interfaces.base, render_interface, video_channel,
capture_id);
interfaces.capture->DisconnectCaptureDevice(video_channel);
@ -92,9 +77,7 @@ void ViEComparisonTests::TestCallSetup(
// data after rendering has been stopped.
fake_camera.StopCamera();
error = interfaces.base->DeleteChannel(video_channel);
ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, interfaces.base->DeleteChannel(video_channel));
}
void ViEComparisonTests::TestCodecs(
@ -103,37 +86,32 @@ void ViEComparisonTests::TestCodecs(
int height,
ViEToFileRenderer* local_file_renderer,
ViEToFileRenderer* remote_file_renderer) {
int ignored = 0;
TbInterfaces interfaces = TbInterfaces("TestCodecs", ignored);
TbInterfaces interfaces = TbInterfaces("TestCodecs");
ViEFakeCamera fake_camera(interfaces.capture);
if (!fake_camera.StartCameraInNewThread(i420_video_file, width, height)) {
// No point in continuing if we have no proper video source
ViETest::TestError(false, "ERROR: %s at line %d: "
"Could not open input video %s: aborting test...",
__FUNCTION__, __LINE__, i420_video_file.c_str());
ADD_FAILURE() << "Could not open input video " << i420_video_file <<
": aborting test...";
return;
}
int video_channel = -1;
int capture_id = fake_camera.capture_id();
int error = interfaces.base->CreateChannel(video_channel);
ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
error = interfaces.capture->ConnectCaptureDevice(capture_id, video_channel);
ViETest::TestError(error == 0, "ERROR: %s at line %d",
__FUNCTION__, __LINE__);
EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel));
EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice(
capture_id, video_channel));
ConfigureRtpRtcp(interfaces.rtp_rtcp, &ignored, video_channel);
ConfigureRtpRtcp(interfaces.rtp_rtcp, video_channel);
RenderToFile(interfaces.render, capture_id, local_file_renderer);
RenderToFile(interfaces.render, video_channel, remote_file_renderer);
// Force the codec resolution to what our input video is so we can make
// comparisons later. Our comparison algorithms wouldn't like scaling.
::TestCodecs(interfaces, ignored, fake_camera.capture_id(), video_channel,
::TestCodecs(interfaces, fake_camera.capture_id(), video_channel,
width, height);
fake_camera.StopCamera();

View File

@ -265,7 +265,7 @@ int ViECaptureImpl::ReleaseCaptureDevice(const int captureId)
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(_instanceId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
@ -302,7 +302,7 @@ int ViECaptureImpl::ConnectCaptureDevice(const int captureId,
ViEId(_instanceId, videoChannel),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
@ -424,7 +424,7 @@ int ViECaptureImpl::StartCapture(const int captureId,
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (ptrViECapture->Started())
@ -458,7 +458,7 @@ int ViECaptureImpl::StopCapture(const int captureId)
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (!ptrViECapture->Started())
@ -513,7 +513,7 @@ int ViECaptureImpl::SetRotateCapturedFrames(const int captureId,
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (ptrViECapture->SetRotateCapturedFrames(rotation) != 0)
@ -548,7 +548,7 @@ int ViECaptureImpl::SetCaptureDelay(const int captureId,
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
@ -711,7 +711,7 @@ int ViECaptureImpl::EnableBrightnessAlarm(const int captureId,
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (ptrViECapture->EnableBrightnessAlarm(enable) != 0)
@ -738,7 +738,7 @@ int ViECaptureImpl::RegisterObserver(const int captureId,
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (ptrViECapture->IsObserverRegistered())
@ -773,7 +773,7 @@ int ViECaptureImpl::DeregisterObserver(const int captureId)
ViEId(_instanceId, captureId),
"%s: Capture device %d doesn't exist", __FUNCTION__,
captureId);
SetLastError(kViECaptureDeviceDoesnNotExist);
SetLastError(kViECaptureDeviceDoesNotExist);
return -1;
}
if (!ptrViECapture->IsObserverRegistered())

View File

@ -295,7 +295,7 @@ int ViEInputManager::CreateCaptureDevice(const WebRtc_UWord8* deviceUniqueIdUTF8
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideo, ViEId(_engineId),
"%s:%d Capture device NOT found by unique ID: %s. Returning",
__FUNCTION__, __LINE__, deviceUniqueIdUTF8);
return kViECaptureDeviceDoesnNotExist;
return kViECaptureDeviceDoesNotExist;
}
int newcaptureId = 0;