diff --git a/src/video_engine/test/auto_test/source/vie_autotest_base.cc b/src/video_engine/test/auto_test/source/vie_autotest_base.cc index adc4afbfc1..0225cb6567 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_base.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_base.cc @@ -8,13 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "vie_autotest.h" - -#include "base_primitives.h" -#include "general_primitives.h" -#include "tb_interfaces.h" -#include "vie_autotest_defines.h" -#include "video_capture_factory.h" +#include "modules/video_capture/main/interface/video_capture_factory.h" +#include "video_engine/test/auto_test/interface/vie_autotest.h" +#include "video_engine/test/auto_test/interface/vie_autotest_defines.h" +#include "video_engine/test/auto_test/primitives/base_primitives.h" +#include "video_engine/test/auto_test/primitives/general_primitives.h" +#include "video_engine/test/libvietest/include/tb_interfaces.h" class BaseObserver : public webrtc::ViEBaseObserver { public: @@ -46,9 +45,9 @@ void ViEAutoTest::ViEBaseStandardTest() { memset(device_name, 0, kMaxDeviceNameLength); int capture_id; - webrtc::ViEBase *base_interface = interfaces.base; - webrtc::ViERender *render_interface = interfaces.render; - webrtc::ViECapture *capture_interface = interfaces.capture; + webrtc::ViEBase* base_interface = interfaces.base; + webrtc::ViERender* render_interface = interfaces.render; + webrtc::ViECapture* capture_interface = interfaces.capture; FindCaptureDeviceOnSystem(capture_interface, device_name, @@ -72,7 +71,7 @@ void ViEAutoTest::ViEBaseStandardTest() { // Run the actual test: // *************************************************************** ViETest::Log("You should shortly see a local preview from camera %s" - " in window 1 and the remote video in window 2.", device_name); + " in window 1 and the remote video in window 2.", device_name); ::TestI420CallSetup(interfaces.codec, interfaces.video_engine, base_interface, interfaces.network, video_channel, device_name); @@ -102,16 +101,16 @@ void ViEAutoTest::ViEBaseExtendedTest() { ViEBaseAPITest(); ViEBaseStandardTest(); - // *************************************************************** - // Test BaseObserver - // *************************************************************** - // TODO(mflodman) Add test for base observer. Cpu load must be over 75%. + // *************************************************************** + // Test BaseObserver + // *************************************************************** + // TODO(mflodman) Add test for base observer. Cpu load must be over 75%. // BaseObserver base_observer; -// EXPECT_EQ(ptrViEBase->RegisterObserver(base_observer), 0); +// EXPECT_EQ(vie_base->RegisterObserver(base_observer), 0); // // AutoTestSleep(KAutoTestSleepTimeMs); // -// EXPECT_EQ(ptrViEBase->DeregisterObserver(), 0); +// EXPECT_EQ(vie_base->DeregisterObserver(), 0); // EXPECT_GT(base_observer.cpu_load, 0); } @@ -120,114 +119,117 @@ void ViEAutoTest::ViEBaseAPITest() { // Begin create/initialize WebRTC Video Engine for testing // *************************************************************** // Get the ViEBase API - webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(NULL); - EXPECT_EQ(NULL, ptrViEBase) << "Should return null for a bad ViE pointer"; + webrtc::ViEBase* vie_base = webrtc::ViEBase::GetInterface(NULL); + EXPECT_EQ(NULL, vie_base) << "Should return null for a bad ViE pointer"; - webrtc::VideoEngine* ptrViE = webrtc::VideoEngine::Create(); - EXPECT_TRUE(NULL != ptrViE); + webrtc::VideoEngine* video_engine = webrtc::VideoEngine::Create(); + EXPECT_TRUE(NULL != video_engine); std::string trace_file_path = - ViETest::GetResultOutputPath() + "ViEBaseAPI_trace.txt"; - EXPECT_EQ(0, ptrViE->SetTraceFile(trace_file_path.c_str())); + ViETest::GetResultOutputPath() + "ViEBaseAPI_trace.txt"; + EXPECT_EQ(0, video_engine->SetTraceFile(trace_file_path.c_str())); - ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - EXPECT_TRUE(NULL != ptrViEBase); + vie_base = webrtc::ViEBase::GetInterface(video_engine); + EXPECT_TRUE(NULL != vie_base); - webrtc::ViENetwork* ptrVieNetwork = webrtc::ViENetwork::GetInterface(ptrViE); - EXPECT_TRUE(ptrVieNetwork != NULL); + webrtc::ViENetwork* vie_network = + webrtc::ViENetwork::GetInterface(video_engine); + EXPECT_TRUE(vie_network != NULL); // *************************************************************** // Engine ready. Begin testing class // *************************************************************** char version[1024] = ""; - EXPECT_EQ(0, ptrViEBase->GetVersion(version)); - EXPECT_EQ(0, ptrViEBase->LastError()); + EXPECT_EQ(0, vie_base->GetVersion(version)); + EXPECT_EQ(0, vie_base->LastError()); // Create without init - int videoChannel = -1; - EXPECT_NE(0, ptrViEBase->CreateChannel(videoChannel)) << + int video_channel = -1; + EXPECT_NE(0, vie_base->CreateChannel(video_channel)) << "Should fail since Init has not been called yet"; - EXPECT_EQ(0, ptrViEBase->Init()); - EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel)); + EXPECT_EQ(0, vie_base->Init()); + EXPECT_EQ(0, vie_base->CreateChannel(video_channel)); - int videoChannel2 = -1; - int videoChannel3 = -1; - EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel2)); - EXPECT_NE(videoChannel, videoChannel2) << + int video_channel2 = -1; + int video_channel3 = -1; + EXPECT_EQ(0, vie_base->CreateChannel(video_channel2)); + EXPECT_NE(video_channel, video_channel2) << "Should allocate new number for independent channel"; - EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel2)); + EXPECT_EQ(0, vie_base->DeleteChannel(video_channel2)); - EXPECT_EQ(-1, ptrViEBase->CreateChannel(videoChannel2, videoChannel + 1)) - << "Should fail since neither channel exists (the second must)"; + EXPECT_EQ(-1, vie_base->CreateChannel(video_channel2, video_channel + 1)) + << "Should fail since neither channel exists (the second must)"; // Create a receive only channel and a send channel. Verify we can't send on // the receive only channel. - EXPECT_EQ(0, ptrViEBase->CreateReceiveChannel(videoChannel2, videoChannel)); - EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel3, videoChannel)); + EXPECT_EQ(0, vie_base->CreateReceiveChannel(video_channel2, + video_channel)); + EXPECT_EQ(0, vie_base->CreateChannel(video_channel3, video_channel)); - const char* ipAddress = "127.0.0.1\0"; - const int sendPort = 1234; - EXPECT_EQ(0, ptrVieNetwork->SetSendDestination(videoChannel, ipAddress, - sendPort)); - EXPECT_EQ(0, ptrVieNetwork->SetSendDestination(videoChannel2,ipAddress, - sendPort + 2)); - EXPECT_EQ(0, ptrVieNetwork->SetSendDestination(videoChannel3,ipAddress, - sendPort + 4)); + const char* ip_address = "127.0.0.1\0"; + const int send_port = 1234; + EXPECT_EQ(0, vie_network->SetSendDestination(video_channel, ip_address, + send_port)); + EXPECT_EQ(0, vie_network->SetSendDestination(video_channel2, ip_address, + send_port + 2)); + EXPECT_EQ(0, vie_network->SetSendDestination(video_channel3, ip_address, + send_port + 4)); - EXPECT_EQ(0, ptrViEBase->StartSend(videoChannel)); - EXPECT_EQ(-1, ptrViEBase->StartSend(videoChannel2)); - EXPECT_EQ(0, ptrViEBase->StartSend(videoChannel3)); - EXPECT_EQ(0, ptrViEBase->StopSend(videoChannel)); - EXPECT_EQ(0, ptrViEBase->StopSend(videoChannel3)); + EXPECT_EQ(0, vie_base->StartSend(video_channel)); + EXPECT_EQ(-1, vie_base->StartSend(video_channel2)); + EXPECT_EQ(0, vie_base->StartSend(video_channel3)); + EXPECT_EQ(0, vie_base->StopSend(video_channel)); + EXPECT_EQ(0, vie_base->StopSend(video_channel3)); // Test Voice Engine integration with Video Engine. - webrtc::VoiceEngine* ptrVoE = NULL; - webrtc::VoEBase* ptrVoEBase = NULL; - int audioChannel = -1; + webrtc::VoiceEngine* voice_engine = NULL; + webrtc::VoEBase* voe_base = NULL; + int audio_channel = -1; - ptrVoE = webrtc::VoiceEngine::Create(); - EXPECT_TRUE(NULL != ptrVoE); + voice_engine = webrtc::VoiceEngine::Create(); + EXPECT_TRUE(NULL != voice_engine); - ptrVoEBase = webrtc::VoEBase::GetInterface(ptrVoE); - EXPECT_TRUE(NULL != ptrVoEBase); - EXPECT_EQ(0, ptrVoEBase->Init()); + voe_base = webrtc::VoEBase::GetInterface(voice_engine); + EXPECT_TRUE(NULL != voe_base); + EXPECT_EQ(0, voe_base->Init()); - audioChannel = ptrVoEBase->CreateChannel(); - EXPECT_NE(-1, audioChannel); + audio_channel = voe_base->CreateChannel(); + EXPECT_NE(-1, audio_channel); // Connect before setting VoE. - EXPECT_NE(0, ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel)) << - "Should fail since Voice Engine is not set yet."; + EXPECT_NE(0, vie_base->ConnectAudioChannel(video_channel, audio_channel)) + << "Should fail since Voice Engine is not set yet."; // Then do it right. - EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(ptrVoE)); - EXPECT_EQ(0, ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel)); + EXPECT_EQ(0, vie_base->SetVoiceEngine(voice_engine)); + EXPECT_EQ(0, vie_base->ConnectAudioChannel(video_channel, audio_channel)); // *************************************************************** // Testing finished. Tear down Video Engine // *************************************************************** - EXPECT_NE(0, ptrViEBase->DisconnectAudioChannel(videoChannel + 5)) << + EXPECT_NE(0, vie_base->DisconnectAudioChannel(video_channel + 5)) << "Should fail: disconnecting bogus channel"; - EXPECT_EQ(0, ptrViEBase->DisconnectAudioChannel(videoChannel)); + EXPECT_EQ(0, vie_base->DisconnectAudioChannel(video_channel)); // Clean up voice engine - EXPECT_EQ(0, ptrVieNetwork->Release()); - EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(NULL)); + EXPECT_EQ(0, vie_network->Release()); + EXPECT_EQ(0, vie_base->SetVoiceEngine(NULL)); // VoiceEngine reference counting is per object, not per interface, so // Release should return != 0. - EXPECT_NE(0, ptrVoEBase->Release()); - EXPECT_TRUE(webrtc::VoiceEngine::Delete(ptrVoE)); + EXPECT_NE(0, voe_base->Release()); + EXPECT_TRUE(webrtc::VoiceEngine::Delete(voice_engine)); - webrtc::ViEBase* ptrViEBase2 = webrtc::ViEBase::GetInterface(ptrViE); - EXPECT_TRUE(NULL != ptrViEBase2); + webrtc::ViEBase* vie_base2 = webrtc::ViEBase::GetInterface(video_engine); + EXPECT_TRUE(NULL != vie_base2); - EXPECT_EQ(1, ptrViEBase->Release()) << "There should be one interface left."; + EXPECT_EQ(1, vie_base->Release()) << + "There should be one interface left."; - EXPECT_FALSE(webrtc::VideoEngine::Delete(ptrViE)) << + EXPECT_FALSE(webrtc::VideoEngine::Delete(video_engine)) << "Should fail since there are interfaces left."; - EXPECT_EQ(0, ptrViEBase->Release()); - EXPECT_TRUE(webrtc::VideoEngine::Delete(ptrViE)); + EXPECT_EQ(0, vie_base->Release()); + EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)); } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_capture.cc b/src/video_engine/test/auto_test/source/vie_autotest_capture.cc index fb3cdb4ce7..f099898efe 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_capture.cc @@ -8,94 +8,85 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "vie_autotest.h" - -#include "common_types.h" -#include "engine_configurations.h" +#include "common_types.h" // NOLINT +#include "engine_configurations.h" // NOLINT #include "gflags/gflags.h" -#include "tb_interfaces.h" -#include "tb_video_channel.h" -#include "tick_util.h" -#include "vie_autotest_defines.h" -#include "video_capture_factory.h" -#include "vie_base.h" -#include "vie_capture.h" -#include "vie_codec.h" -#include "vie_network.h" -#include "vie_render.h" -#include "vie_rtp_rtcp.h" -#include "voe_base.h" +#include "modules/video_capture/main/interface/video_capture_factory.h" +#include "system_wrappers/interface/tick_util.h" +#include "video_engine/include/vie_base.h" +#include "video_engine/include/vie_capture.h" +#include "video_engine/include/vie_codec.h" +#include "video_engine/include/vie_network.h" +#include "video_engine/include/vie_render.h" +#include "video_engine/include/vie_rtp_rtcp.h" +#include "video_engine/test/auto_test/interface/vie_autotest.h" +#include "video_engine/test/auto_test/interface/vie_autotest_defines.h" +#include "video_engine/test/libvietest/include/tb_interfaces.h" +#include "video_engine/test/libvietest/include/tb_video_channel.h" +#include "voice_engine/main/interface/voe_base.h" DEFINE_bool(capture_test_ensure_resolution_alignment_in_capture_device, true, "If true, we will give resolutions slightly below a reasonable " "value to test the camera's ability to choose a good resolution. " "If false, we will provide reasonable resolutions instead."); -class CaptureObserver: public webrtc::ViECaptureObserver -{ -public: - CaptureObserver() : - _brightness(webrtc::Normal), - _alarm(webrtc::AlarmCleared), - _frameRate(0) {} - - virtual void BrightnessAlarm(const int captureId, - const webrtc::Brightness brightness) - { - _brightness = brightness; - switch (brightness) - { - case webrtc::Normal: - ViETest::Log(" BrightnessAlarm Normal"); - break; - case webrtc::Bright: - ViETest::Log(" BrightnessAlarm Bright"); - break; - case webrtc::Dark: - ViETest::Log(" BrightnessAlarm Dark"); - break; - } - } - - virtual void CapturedFrameRate(const int captureId, - const unsigned char frameRate) - { - ViETest::Log(" CapturedFrameRate %u", frameRate); - _frameRate = frameRate; - } - - virtual void NoPictureAlarm(const int captureId, - const webrtc::CaptureAlarm alarm) - { - _alarm = alarm; - if (alarm == webrtc::AlarmRaised) - { - ViETest::Log("NoPictureAlarm CARaised."); - } - else - { - ViETest::Log("NoPictureAlarm CACleared."); - } - } - - webrtc::Brightness _brightness; - webrtc::CaptureAlarm _alarm; - unsigned char _frameRate; -}; - -class CaptureEffectFilter: public webrtc::ViEEffectFilter { +class CaptureObserver : public webrtc::ViECaptureObserver { public: - CaptureEffectFilter(unsigned int expected_width, unsigned int expected_height) - : number_of_captured_frames_(0), - expected_width_(expected_width), - expected_height_(expected_height) { + CaptureObserver() + : brightness_(webrtc::Normal), + alarm_(webrtc::AlarmCleared), + frame_rate_(0) {} + + virtual void BrightnessAlarm(const int capture_id, + const webrtc::Brightness brightness) { + brightness_ = brightness; + switch (brightness) { + case webrtc::Normal: + ViETest::Log(" BrightnessAlarm Normal"); + break; + case webrtc::Bright: + ViETest::Log(" BrightnessAlarm Bright"); + break; + case webrtc::Dark: + ViETest::Log(" BrightnessAlarm Dark"); + break; + } } - // Implements ViEEffectFilter - virtual int Transform(int size, unsigned char* frameBuffer, - unsigned int timeStamp90KHz, unsigned int width, + virtual void CapturedFrameRate(const int capture_id, + const unsigned char frame_rate) { + ViETest::Log(" CapturedFrameRate %u", frame_rate); + frame_rate_ = frame_rate; + } + + virtual void NoPictureAlarm(const int capture_id, + const webrtc::CaptureAlarm alarm) { + alarm_ = alarm; + if (alarm == webrtc::AlarmRaised) { + ViETest::Log("NoPictureAlarm CARaised."); + } else { + ViETest::Log("NoPictureAlarm CACleared."); + } + } + + webrtc::Brightness brightness_; + webrtc::CaptureAlarm alarm_; + unsigned char frame_rate_; +}; + +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 video_engineEffectFilter. + virtual int Transform(int size, unsigned char* frame_buffer, + unsigned int time_stamp90KHz, unsigned int width, unsigned int height) { - EXPECT_TRUE(frameBuffer != NULL); + EXPECT_TRUE(frame_buffer != NULL); EXPECT_EQ(expected_width_, width); EXPECT_EQ(expected_height_, height); ++number_of_captured_frames_; @@ -107,457 +98,439 @@ class CaptureEffectFilter: public webrtc::ViEEffectFilter { protected: unsigned int expected_width_; unsigned int expected_height_; - }; +}; -void ViEAutoTest::ViECaptureStandardTest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** +void ViEAutoTest::ViECaptureStandardTest() { + /// ************************************************************** + // Begin create/initialize WebRTC Video Engine for testing + /// ************************************************************** - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** + /// ************************************************************** + // Engine ready. Begin testing class + /// ************************************************************** - TbInterfaces ViE("ViECaptureStandardTest"); + TbInterfaces video_engine("video_engineCaptureStandardTest"); - webrtc::VideoCaptureModule::DeviceInfo* devInfo = - webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - ASSERT_TRUE(devInfo != NULL); + webrtc::VideoCaptureModule::DeviceInfo* dev_info = + webrtc::VideoCaptureFactory::CreateDeviceInfo(0); + ASSERT_TRUE(dev_info != NULL); - int numberOfCaptureDevices = devInfo->NumberOfDevices(); - ViETest::Log("Number of capture devices %d", numberOfCaptureDevices); - ASSERT_GT(numberOfCaptureDevices, 0) - << "This test requires a capture device (i.e. a webcam)"; + int number_of_capture_devices = dev_info->NumberOfDevices(); + ViETest::Log("Number of capture devices %d", + number_of_capture_devices); + ASSERT_GT(number_of_capture_devices, 0) + << "This test requires a capture device (i.e. a webcam)"; - int captureDeviceId[10]; - memset(captureDeviceId, 0, sizeof(captureDeviceId)); - webrtc::VideoCaptureModule* vcpms[10]; - memset(vcpms, 0, sizeof(vcpms)); + int capture_device_id[10]; + memset(capture_device_id, 0, sizeof(capture_device_id)); + webrtc::VideoCaptureModule* vcpms[10]; + memset(vcpms, 0, sizeof(vcpms)); - // Check capabilities - for (int deviceIndex = 0; - deviceIndex < numberOfCaptureDevices; - ++deviceIndex) - { - char deviceName[128]; - char deviceUniqueName[512]; + // Check capabilities + for (int device_index = 0; device_index < number_of_capture_devices; + ++device_index) { + char device_name[128]; + char device_unique_name[512]; - EXPECT_EQ(0, devInfo->GetDeviceName(deviceIndex, - deviceName, - sizeof(deviceName), - deviceUniqueName, - sizeof(deviceUniqueName))); - ViETest::Log("Found capture device %s\nUnique name %s", deviceName, - deviceUniqueName); + EXPECT_EQ(0, dev_info->GetDeviceName(device_index, + device_name, + sizeof(device_name), + device_unique_name, + sizeof(device_unique_name))); + ViETest::Log("Found capture device %s\nUnique name %s", + device_name, device_unique_name); #if !defined(WEBRTC_MAC_INTEL) // these functions will return -1 - int numberOfCapabilities = - devInfo->NumberOfCapabilities(deviceUniqueName); - EXPECT_GT(numberOfCapabilities, 0); + int number_of_capabilities = + dev_info->NumberOfCapabilities(device_unique_name); + EXPECT_GT(number_of_capabilities, 0); - for (int capIndex = 0; capIndex < numberOfCapabilities; ++capIndex) - { - webrtc::VideoCaptureCapability capability; - 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", - capability.width, capability.height, capability.maxFPS); - ViETest::Log("expected delay %d, color type %d, encoding %d", - capability.expectedCaptureDelay, capability.rawType, - capability.codecType); - - EXPECT_GT(capability.width, 0); - EXPECT_GT(capability.height, 0); - EXPECT_GT(capability.maxFPS, -1); // >= 0 - EXPECT_GT(capability.expectedCaptureDelay, 0); - } -#endif + for (int cap_index = 0; cap_index < number_of_capabilities; ++cap_index) { + webrtc::VideoCaptureCapability capability; + EXPECT_EQ(0, dev_info->GetCapability(device_unique_name, cap_index, + capability)); + ViETest::Log("Capture capability %d (of %u)", cap_index + 1, + number_of_capabilities); + ViETest::Log("witdh %d, height %d, frame rate %d", + capability.width, capability.height, capability.maxFPS); + ViETest::Log("expected delay %d, color type %d, encoding %d", + capability.expectedCaptureDelay, capability.rawType, + capability.codecType); + EXPECT_GT(capability.width, 0); + EXPECT_GT(capability.height, 0); + EXPECT_GT(capability.maxFPS, -1); // >= 0 + EXPECT_GT(capability.expectedCaptureDelay, 0); } - // Capture Capability Functions are not supported on WEBRTC_MAC_INTEL. +#endif + } + // Capture Capability Functions are not supported on WEBRTC_MAC_INTEL. #if !defined(WEBRTC_MAC_INTEL) - // Check allocation. Try to allocate them all after each other. - for (int deviceIndex = 0; - deviceIndex < numberOfCaptureDevices; - ++deviceIndex) - { - char deviceName[128]; - char deviceUniqueName[512]; + // Check allocation. Try to allocate them all after each other. + for (int device_index = 0; device_index < number_of_capture_devices; + ++device_index) { + char device_name[128]; + char device_unique_name[512]; + EXPECT_EQ(0, dev_info->GetDeviceName(device_index, + device_name, + sizeof(device_name), + device_unique_name, + sizeof(device_unique_name))); + webrtc::VideoCaptureModule* vcpm = + webrtc::VideoCaptureFactory::Create(device_index, device_unique_name); + EXPECT_TRUE(vcpm != NULL); + vcpm->AddRef(); + vcpms[device_index] = vcpm; - EXPECT_EQ(0, devInfo->GetDeviceName(deviceIndex, - deviceName, - sizeof(deviceName), - deviceUniqueName, - sizeof(deviceUniqueName))); + EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice( + *vcpm, capture_device_id[device_index])); - webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create( - deviceIndex, deviceUniqueName); - EXPECT_TRUE(vcpm != NULL); - vcpm->AddRef(); - vcpms[deviceIndex] = vcpm; + webrtc::VideoCaptureCapability capability; + EXPECT_EQ(0, dev_info->GetCapability(device_unique_name, 0, capability)); - EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice( - *vcpm, captureDeviceId[deviceIndex])); + // Test that the camera select the closest capability to the selected + // width and height. + CaptureEffectFilter filter(capability.width, capability.height); + EXPECT_EQ(0, video_engine.image_process->RegisterCaptureEffectFilter( + capture_device_id[device_index], filter)); - webrtc::VideoCaptureCapability capability; - EXPECT_EQ(0, devInfo->GetCapability(deviceUniqueName, 0, capability)); + ViETest::Log("Testing Device %s capability width %d height %d", + device_unique_name, capability.width, capability.height); - // Test that the camera select the closest capability to the selected - // width and height. - CaptureEffectFilter filter(capability.width, capability.height); - EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( - captureDeviceId[deviceIndex], filter)); + if (FLAGS_capture_test_ensure_resolution_alignment_in_capture_device) { + // This tests that the capture device properly aligns to a + // multiple of 16 (or at least 8). + capability.height = capability.height - 2; + capability.width = capability.width - 2; + } - ViETest::Log("Testing Device %s capability width %d height %d", - deviceUniqueName, capability.width, capability.height); + webrtc::CaptureCapability vie_capability; + vie_capability.width = capability.width; + vie_capability.height = capability.height; + vie_capability.codecType = capability.codecType; + vie_capability.maxFPS = capability.maxFPS; + vie_capability.rawType = capability.rawType; - if (FLAGS_capture_test_ensure_resolution_alignment_in_capture_device) { - // This tests that the capture device properly aligns to a - // multiple of 16 (or at least 8). - capability.height = capability.height - 2; - capability.width = capability.width - 2; - } + EXPECT_EQ(0, video_engine.capture->StartCapture( + capture_device_id[device_index], vie_capability)); + webrtc::TickTime start_time = webrtc::TickTime::Now(); - webrtc::CaptureCapability vieCapability; - vieCapability.width = capability.width; - vieCapability.height = capability.height; - vieCapability.codecType = capability.codecType; - vieCapability.maxFPS = capability.maxFPS; - vieCapability.rawType = capability.rawType; + while (filter.number_of_captured_frames_ < 10 && + (webrtc::TickTime::Now() - start_time).Milliseconds() < 10000) { + AutoTestSleep(100); + } - EXPECT_EQ(0, ViE.capture->StartCapture(captureDeviceId[deviceIndex], - vieCapability)); - webrtc::TickTime startTime = webrtc::TickTime::Now(); + EXPECT_GT(filter.number_of_captured_frames_, 9) + << "Should capture at least some frames"; - while (filter.number_of_captured_frames_ < 10 - && (webrtc::TickTime::Now() - startTime).Milliseconds() < 10000) - { - AutoTestSleep(100); - } - - EXPECT_GT(filter.number_of_captured_frames_, 9) << - "Should capture at least some frames"; - - EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( - captureDeviceId[deviceIndex])); + EXPECT_EQ(0, video_engine.image_process->DeregisterCaptureEffectFilter( + capture_device_id[device_index])); #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])); + EXPECT_EQ(0, video_engine.capture->StopCapture( + capture_device_id[device_index])); + EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice( + capture_device_id[device_index])); #endif - } + } - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** + /// ************************************************************** + // Testing finished. Tear down Video Engine + /// ************************************************************** - - // Stop all started capture devices. - for (int deviceIndex = 0; - deviceIndex < numberOfCaptureDevices; - ++deviceIndex) { + // Stop all started capture devices. + for (int device_index = 0; device_index < number_of_capture_devices; + ++device_index) { #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])); + // Don't stop on Android since we can only allocate one camera. + EXPECT_EQ(0, video_engine.capture->StopCapture( + capture_device_id[device_index])); + EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice( + capture_device_id[device_index])); #endif // !WEBRTC_ANDROID - vcpms[deviceIndex]->Release(); - } + vcpms[device_index]->Release(); + } #endif // !WEBRTC_MAC_INTEL } void ViEAutoTest::ViECaptureExtendedTest() { - ViECaptureStandardTest(); - ViECaptureAPITest(); - ViECaptureExternalCaptureTest(); + ViECaptureStandardTest(); + ViECaptureAPITest(); + ViECaptureExternalCaptureTest(); } -void ViEAutoTest::ViECaptureAPITest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** +void ViEAutoTest::ViECaptureAPITest() { + /// ************************************************************** + // Begin create/initialize WebRTC Video Engine for testing + /// ************************************************************** - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** - TbInterfaces ViE("ViECaptureAPITest"); + /// ************************************************************** + // Engine ready. Begin testing class + /// ************************************************************** + TbInterfaces video_engine("video_engineCaptureAPITest"); - ViE.capture->NumberOfCaptureDevices(); + video_engine.capture->NumberOfCaptureDevices(); - char deviceName[128]; - char deviceUniqueName[512]; - int captureId = 0; + char device_name[128]; + char device_unique_name[512]; + int capture_id = 0; - webrtc::VideoCaptureModule::DeviceInfo* devInfo = - webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - ASSERT_TRUE(devInfo != NULL); - ASSERT_GT(devInfo->NumberOfDevices(), 0u) - << "This test requires a capture device (i.e. a webcam)"; + webrtc::VideoCaptureModule::DeviceInfo* dev_info = + webrtc::VideoCaptureFactory::CreateDeviceInfo(0); + ASSERT_TRUE(dev_info != NULL); + ASSERT_GT(dev_info->NumberOfDevices(), 0u) + << "This test requires a capture device (i.e. a webcam)"; - // Get the first capture device - EXPECT_EQ(0, devInfo->GetDeviceName(0, deviceName, - sizeof(deviceName), - deviceUniqueName, - sizeof(deviceUniqueName))); + // Get the first capture device + EXPECT_EQ(0, dev_info->GetDeviceName(0, device_name, + sizeof(device_name), + device_unique_name, + sizeof(device_unique_name))); - webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create(0, deviceUniqueName); - vcpm->AddRef(); - EXPECT_TRUE(vcpm != NULL); + webrtc::VideoCaptureModule* vcpm = + webrtc::VideoCaptureFactory::Create(0, device_unique_name); + vcpm->AddRef(); + EXPECT_TRUE(vcpm != NULL); - // Allocate capture device. - EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId)); + // Allocate capture device. + EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - // Start the capture device. - EXPECT_EQ(0, ViE.capture->StartCapture(captureId)); + // Start the capture device. + EXPECT_EQ(0, video_engine.capture->StartCapture(capture_id)); - // Start again. Should fail. - EXPECT_NE(0, ViE.capture->StartCapture(captureId)); - EXPECT_EQ(kViECaptureDeviceAlreadyStarted, ViE.LastError()); + // Start again. Should fail. + EXPECT_NE(0, video_engine.capture->StartCapture(capture_id)); + EXPECT_EQ(kViECaptureDeviceAlreadyStarted, video_engine.LastError()); - // Start invalid capture device. - EXPECT_NE(0, ViE.capture->StartCapture(captureId + 1)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); + // Start invalid capture device. + EXPECT_NE(0, video_engine.capture->StartCapture(capture_id + 1)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - // Stop invalid capture device. - EXPECT_NE(0, ViE.capture->StopCapture(captureId + 1)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); + // Stop invalid capture device. + EXPECT_NE(0, video_engine.capture->StopCapture(capture_id + 1)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - // Stop the capture device. - EXPECT_EQ(0, ViE.capture->StopCapture(captureId)); + // Stop the capture device. + EXPECT_EQ(0, video_engine.capture->StopCapture(capture_id)); - // Stop the capture device again. - EXPECT_NE(0, ViE.capture->StopCapture(captureId)); - EXPECT_EQ(kViECaptureDeviceNotStarted, ViE.LastError()); + // Stop the capture device again. + EXPECT_NE(0, video_engine.capture->StopCapture(capture_id)); + EXPECT_EQ(kViECaptureDeviceNotStarted, video_engine.LastError()); - // Connect to invalid channel. - EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId, 0)); - EXPECT_EQ(kViECaptureDeviceInvalidChannelId, ViE.LastError()); + // Connect to invalid channel. + EXPECT_NE(0, video_engine.capture->ConnectCaptureDevice(capture_id, 0)); + EXPECT_EQ(kViECaptureDeviceInvalidChannelId, + video_engine.LastError()); - TbVideoChannel channel(ViE); + TbVideoChannel channel(video_engine); - // Connect invalid captureId. - EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId + 1, - channel.videoChannel)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); + // Connect invalid capture_id. + EXPECT_NE(0, video_engine.capture->ConnectCaptureDevice(capture_id + 1, + channel.videoChannel)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - // Connect the capture device to the channel. - EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, - channel.videoChannel)); + // Connect the capture device to the channel. + EXPECT_EQ(0, video_engine.capture->ConnectCaptureDevice(capture_id, + channel.videoChannel)); - // Connect the channel again. - EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId, - channel.videoChannel)); - EXPECT_EQ(kViECaptureDeviceAlreadyConnected, ViE.LastError()); + // Connect the channel again. + EXPECT_NE(0, video_engine.capture->ConnectCaptureDevice(capture_id, + channel.videoChannel)); + EXPECT_EQ(kViECaptureDeviceAlreadyConnected, + video_engine.LastError()); - // Start the capture device. - EXPECT_EQ(0, ViE.capture->StartCapture(captureId)); + // Start the capture device. + EXPECT_EQ(0, video_engine.capture->StartCapture(capture_id)); - // Release invalid capture device. - EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId + 1)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); + // Release invalid capture device. + EXPECT_NE(0, video_engine.capture->ReleaseCaptureDevice(capture_id + 1)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - // Release the capture device. - EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); + // Release the capture device. + EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - // Release the capture device again. - EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); + // Release the capture device again. + EXPECT_NE(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - // Test GetOrientation. - webrtc::VideoCaptureRotation orientation; - char dummy_name[5]; - EXPECT_NE(0, devInfo->GetOrientation(dummy_name, orientation)); + // Test GetOrientation. + webrtc::VideoCaptureRotation orientation; + char dummy_name[5]; + EXPECT_NE(0, dev_info->GetOrientation(dummy_name, orientation)); - // Test SetRotation. - EXPECT_NE(0, ViE.capture->SetRotateCapturedFrames( - captureId, webrtc::RotateCapturedFrame_90)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); + // Test SetRotation. + EXPECT_NE(0, video_engine.capture->SetRotateCapturedFrames( + capture_id, webrtc::RotateCapturedFrame_90)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - // Allocate capture device. - EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId)); + // Allocate capture device. + EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - 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)); + EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( + capture_id, webrtc::RotateCapturedFrame_0)); + EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( + capture_id, webrtc::RotateCapturedFrame_90)); + EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( + capture_id, webrtc::RotateCapturedFrame_180)); + EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( + capture_id, webrtc::RotateCapturedFrame_270)); - // Release the capture device - EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); + // Release the capture device + EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** - delete devInfo; - vcpm->Release(); + /// ************************************************************** + // Testing finished. Tear down Video Engine + /// ************************************************************** + delete dev_info; + vcpm->Release(); } -void ViEAutoTest::ViECaptureExternalCaptureTest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** +void ViEAutoTest::ViECaptureExternalCaptureTest() { + /// ************************************************************** + // Begin create/initialize WebRTC Video Engine for testing + /// ************************************************************** - TbInterfaces ViE("ViECaptureExternalCaptureTest"); - TbVideoChannel channel(ViE); - channel.StartReceive(); - channel.StartSend(); + TbInterfaces video_engine("video_engineCaptureExternalCaptureTest"); + TbVideoChannel channel(video_engine); + channel.StartReceive(); + channel.StartSend(); - webrtc::VideoCaptureExternal* externalCapture; - int captureId = 0; + webrtc::VideoCaptureExternal* external_capture = NULL; + int capture_id = 0; - // Allocate the external capture device. - webrtc::VideoCaptureModule* vcpm = webrtc::VideoCaptureFactory::Create( - 0, externalCapture); - EXPECT_TRUE(vcpm != NULL); - EXPECT_TRUE(externalCapture != NULL); - vcpm->AddRef(); + // Allocate the external capture device. + webrtc::VideoCaptureModule* vcpm = + webrtc::VideoCaptureFactory::Create(0, external_capture); + EXPECT_TRUE(vcpm != NULL); + EXPECT_TRUE(external_capture != NULL); + vcpm->AddRef(); - EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId)); + EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - // Connect the capture device to the channel. - EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, - channel.videoChannel)); + // Connect the capture device to the channel. + EXPECT_EQ(0, video_engine.capture->ConnectCaptureDevice(capture_id, + channel.videoChannel)); - // Render the local capture. - EXPECT_EQ(0, ViE.render->AddRenderer(captureId, _window1, 1, 0.0, 0.0, - 1.0, 1.0)); + // Render the local capture. + EXPECT_EQ(0, video_engine.render->AddRenderer(capture_id, _window1, 1, 0.0, + 0.0, 1.0, 1.0)); - // 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)); + // Render the remote capture. + EXPECT_EQ(0, video_engine.render->AddRenderer(channel.videoChannel, _window2, + 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, video_engine.render->StartRender(capture_id)); + EXPECT_EQ(0, video_engine.render->StartRender(channel.videoChannel)); - // Register observer. - CaptureObserver observer; - EXPECT_EQ(0, ViE.capture->RegisterObserver(captureId, observer)); + // Register observer. + CaptureObserver observer; + EXPECT_EQ(0, video_engine.capture->RegisterObserver(capture_id, observer)); - // Enable brightness alarm. - EXPECT_EQ(0, ViE.capture->EnableBrightnessAlarm(captureId, true)); + // Enable brightness alarm. + EXPECT_EQ(0, video_engine.capture->EnableBrightnessAlarm(capture_id, true)); - CaptureEffectFilter effectFilter(176, 144); - EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(captureId, - effectFilter)); + CaptureEffectFilter effect_filter(176, 144); + EXPECT_EQ(0, video_engine.image_process->RegisterCaptureEffectFilter( + capture_id, effect_filter)); - // Call started. - ViETest::Log("You should see local preview from external capture\n" - "in window 1 and the remote video in window 2.\n"); + // 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); + /// ************************************************************** + // Engine ready. Begin testing class + /// ************************************************************** + const unsigned int video_frame_length = (176 * 144 * 3) / 2; + unsigned char* video_frame = new unsigned char[video_frame_length]; + memset(video_frame, 128, 176 * 144); - int frameCount = 0; - webrtc::VideoCaptureCapability capability; - capability.width = 176; - capability.height = 144; - capability.rawType = webrtc::kVideoI420; + int frame_count = 0; + webrtc::VideoCaptureCapability capability; + capability.width = 176; + capability.height = 144; + capability.rawType = webrtc::kVideoI420; - ViETest::Log("Testing external capturing and frame rate callbacks."); - // TODO: Change when using a real file! - // while (fread(videoFrame, videoFrameLength, 1, foreman) == 1) - while (frameCount < 120) - { - externalCapture->IncomingFrame( - videoFrame, videoFrameLength, capability, - webrtc::TickTime::Now().MillisecondTimestamp()); - AutoTestSleep(33); + ViETest::Log("Testing external capturing and frame rate callbacks."); + // TODO(mflodman) Change when using a real file! + // while (fread(video_frame, video_frame_length, 1, foreman) == 1) + while (frame_count < 120) { + external_capture->IncomingFrame( + video_frame, video_frame_length, capability, + webrtc::TickTime::Now().MillisecondTimestamp()); + AutoTestSleep(33); - if (effectFilter.number_of_captured_frames_ > 2) - { - 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++; + if (effect_filter.number_of_captured_frames_ > 2) { + 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."; } + frame_count++; + } - // Test brightness alarm - // Test bright image - for (int i = 0; i < 176 * 144; ++i) - { - if (videoFrame[i] <= 155) - videoFrame[i] = videoFrame[i] + 100; - else - videoFrame[i] = 255; - } - ViETest::Log("Testing Brighness alarm"); - for (int frame = 0; frame < 30; ++frame) - { - externalCapture->IncomingFrame( - videoFrame, videoFrameLength, capability, - webrtc::TickTime::Now().MillisecondTimestamp()); - AutoTestSleep(33); - } - EXPECT_EQ(webrtc::Bright, observer._brightness) << - "Should be bright at this point since we are using a bright image."; + // Test brightness alarm. + // Test bright image. + for (int i = 0; i < 176 * 144; ++i) { + if (video_frame[i] <= 155) + video_frame[i] = video_frame[i] + 100; + else + video_frame[i] = 255; + } + ViETest::Log("Testing Brighness alarm"); + for (int frame = 0; frame < 30; ++frame) { + external_capture->IncomingFrame( + video_frame, video_frame_length, capability, + webrtc::TickTime::Now().MillisecondTimestamp()); + AutoTestSleep(33); + } + 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) - { - videoFrame[i] = videoFrame[i] > 200 ? videoFrame[i] - 200 : 0; - } - for (int frame = 0; frame < 30; ++frame) - { - externalCapture->IncomingFrame( - videoFrame, videoFrameLength, capability, - webrtc::TickTime::Now().MillisecondTimestamp()); - AutoTestSleep(33); - } - 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 Dark image + for (int i = 0; i < 176 * 144; ++i) { + video_frame[i] = video_frame[i] > 200 ? video_frame[i] - 200 : 0; + } + for (int frame = 0; frame < 30; ++frame) { + external_capture->IncomingFrame( + video_frame, video_frame_length, capability, + webrtc::TickTime::Now().MillisecondTimestamp()); + AutoTestSleep(33); + } + EXPECT_EQ(webrtc::Dark, observer.brightness_) << + "Should be dark at this point since we are using a dark image."; + EXPECT_GT(effect_filter.number_of_captured_frames_, 150) << + "Frames should have been played."; - EXPECT_GE(observer._frameRate, 29) << - "Frame rate callback should be approximately correct."; - EXPECT_LE(observer._frameRate, 30) << - "Frame rate callback should be approximately correct."; + EXPECT_GE(observer.frame_rate_, 29) << + "Frame rate callback should be approximately correct."; + EXPECT_LE(observer.frame_rate_, 30) << + "Frame rate callback should be approximately correct."; - // Test no picture alarm - ViETest::Log("Testing NoPictureAlarm."); - AutoTestSleep(1050); + // Test no picture alarm + ViETest::Log("Testing NoPictureAlarm."); + AutoTestSleep(1050); - EXPECT_EQ(webrtc::AlarmRaised, observer._alarm) << - "No picture alarm should be raised."; - for (int frame = 0; frame < 10; ++frame) - { - externalCapture->IncomingFrame( - videoFrame, videoFrameLength, capability, - webrtc::TickTime::Now().MillisecondTimestamp()); - AutoTestSleep(33); - } - EXPECT_EQ(webrtc::AlarmCleared, observer._alarm) << - "Alarm should be cleared since ge just got some data."; + EXPECT_EQ(webrtc::AlarmRaised, observer.alarm_) << + "No picture alarm should be raised."; + for (int frame = 0; frame < 10; ++frame) { + external_capture->IncomingFrame( + video_frame, video_frame_length, capability, + webrtc::TickTime::Now().MillisecondTimestamp()); + AutoTestSleep(33); + } + EXPECT_EQ(webrtc::AlarmCleared, observer.alarm_) << + "Alarm should be cleared since ge just got some data."; - delete videoFrame; + delete video_frame; - // Release the capture device - EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); + // Release the capture device + EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - // Release the capture device again - EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - vcpm->Release(); + // Release the capture device again + EXPECT_NE(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); + vcpm->Release(); - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** + /// ************************************************************** + // Testing finished. Tear down Video Engine + /// ************************************************************** } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_codec.cc b/src/video_engine/test/auto_test/source/vie_autotest_codec.cc index 68c44fdfb5..077f94b66f 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_codec.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_codec.cc @@ -8,33 +8,33 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "vie_autotest_defines.h" -#include "vie_autotest.h" -#include "engine_configurations.h" +#include "common_types.h" // NOLINT +#include "engine_configurations.h" // NOLINT +#include "video_engine/test/auto_test/interface/vie_autotest_defines.h" +#include "video_engine/test/auto_test/interface/vie_autotest.h" +#include "video_engine/test/libvietest/include/tb_capture_device.h" +#include "video_engine/test/libvietest/include/tb_I420_codec.h" +#include "video_engine/test/libvietest/include/tb_interfaces.h" +#include "video_engine/test/libvietest/include/tb_video_channel.h" +#include "video_engine/include/vie_base.h" +#include "video_engine/include/vie_capture.h" +#include "video_engine/include/vie_codec.h" +#include "video_engine/include/vie_network.h" +#include "video_engine/include/vie_render.h" +#include "video_engine/include/vie_rtp_rtcp.h" +#include "voice_engine/main/interface/voe_base.h" -#include "common_types.h" -#include "tb_capture_device.h" -#include "tb_I420_codec.h" -#include "tb_interfaces.h" -#include "tb_video_channel.h" -#include "vie_base.h" -#include "vie_capture.h" -#include "vie_codec.h" -#include "vie_network.h" -#include "vie_render.h" -#include "vie_rtp_rtcp.h" -#include "voe_base.h" - -class TestCodecObserver : public webrtc::ViEEncoderObserver, +class TestCodecObserver + : public webrtc::ViEEncoderObserver, public webrtc::ViEDecoderObserver { -public: + public: int incoming_codec_called_; int incoming_rate_called_; int outgoing_rate_called_; unsigned char last_payload_type_; - unsigned short last_width_; - unsigned short last_height_; + uint16_t last_width_; + uint16_t last_height_; unsigned int last_outgoing_framerate_; unsigned int last_outgoing_bitrate_; @@ -43,49 +43,51 @@ public: webrtc::VideoCodec incoming_codec_; - TestCodecObserver() { - incoming_codec_called_ = 0; - incoming_rate_called_ = 0; - outgoing_rate_called_ = 0; - last_payload_type_ = 0; - last_width_ = 0; - last_height_ = 0; - last_outgoing_framerate_ = 0; - last_outgoing_bitrate_ = 0; - last_incoming_framerate_ = 0; - last_incoming_bitrate_ = 0; + TestCodecObserver() + : incoming_codec_called_(0), + incoming_rate_called_(0), + outgoing_rate_called_(0), + last_payload_type_(0), + last_width_(0), + last_height_(0), + last_outgoing_framerate_(0), + last_outgoing_bitrate_(0), + last_incoming_framerate_(0), + last_incoming_bitrate_(0) { memset(&incoming_codec_, 0, sizeof(incoming_codec_)); } - virtual void IncomingCodecChanged(const int videoChannel, - const webrtc::VideoCodec& videoCodec) { + virtual void IncomingCodecChanged(const int video_channel, + const webrtc::VideoCodec& video_codec) { incoming_codec_called_++; - last_payload_type_ = videoCodec.plType; - last_width_ = videoCodec.width; - last_height_ = videoCodec.height; + last_payload_type_ = video_codec.plType; + last_width_ = video_codec.width; + last_height_ = video_codec.height; - memcpy(&incoming_codec_, &videoCodec, sizeof(videoCodec)); + memcpy(&incoming_codec_, &video_codec, sizeof(video_codec)); } - virtual void IncomingRate(const int videoChannel, - const unsigned int framerate, const unsigned int bitrate) { + virtual void IncomingRate(const int video_channel, + const unsigned int framerate, + const unsigned int bitrate) { incoming_rate_called_++; last_incoming_framerate_ += framerate; last_incoming_bitrate_ += bitrate; } - virtual void OutgoingRate(const int videoChannel, - const unsigned int framerate, const unsigned int bitrate) { + virtual void OutgoingRate(const int video_channel, + const unsigned int framerate, + const unsigned int bitrate) { outgoing_rate_called_++; last_outgoing_framerate_ += framerate; last_outgoing_bitrate_ += bitrate; } - virtual void RequestNewKeyFrame(const int videoChannel) { + virtual void RequestNewKeyFrame(const int video_channel) { } }; class RenderFilter : public webrtc::ViEEffectFilter { -public: + public: int num_frames_; unsigned int last_render_width_; unsigned int last_render_height_; @@ -99,8 +101,11 @@ public: virtual ~RenderFilter() { } - virtual int Transform(int size, unsigned char* frameBuffer, - unsigned int timeStamp90KHz, unsigned int width, unsigned int height) { + virtual int Transform(int size, + unsigned char* frame_buffer, + unsigned int time_stamp90KHz, + unsigned int width, + unsigned int height) { num_frames_++; last_render_width_ = width; last_render_height_ = height; @@ -125,16 +130,16 @@ void ViEAutoTest::ViECodecStandardTest() { int video_channel = -1; EXPECT_EQ(0, base->CreateChannel(video_channel)); EXPECT_EQ(0, capture->ConnectCaptureDevice(capture_id, video_channel)); - EXPECT_EQ( 0, rtp_rtcp->SetRTCPStatus( + EXPECT_EQ(0, rtp_rtcp->SetRTCPStatus( video_channel, webrtc::kRtcpCompound_RFC4585)); EXPECT_EQ(0, rtp_rtcp->SetKeyFrameRequestMethod( video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); EXPECT_EQ(0, rtp_rtcp->SetTMMBRStatus(video_channel, true)); - EXPECT_EQ(0, render->AddRenderer( - capture_id, _window1, 0, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, render->AddRenderer( - video_channel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, render->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, 1.0, + 1.0)); + EXPECT_EQ(0, render->AddRenderer(video_channel, _window2, 1, 0.0, 0.0, 1.0, + 1.0)); EXPECT_EQ(0, render->StartRender(capture_id)); EXPECT_EQ(0, render->StartRender(video_channel)); @@ -142,7 +147,6 @@ void ViEAutoTest::ViECodecStandardTest() { memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); for (int idx = 0; idx < codec->NumberOfCodecs(); idx++) { EXPECT_EQ(0, codec->GetCodec(idx, video_codec)); - if (video_codec.codecType != webrtc::kVideoCodecI420) { video_codec.width = 640; video_codec.height = 480; @@ -163,24 +167,21 @@ void ViEAutoTest::ViECodecStandardTest() { } const char* ip_address = "127.0.0.1"; - const unsigned short rtp_port = 6000; + const uint16_t rtp_port = 6000; EXPECT_EQ(0, network->SetLocalReceiver(video_channel, rtp_port)); EXPECT_EQ(0, base->StartReceive(video_channel)); EXPECT_EQ(0, network->SetSendDestination( video_channel, ip_address, rtp_port)); EXPECT_EQ(0, base->StartSend(video_channel)); - // // Make sure all codecs runs - // { webrtc::ViEImageProcess* image_process = webrtc::ViEImageProcess::GetInterface(video_engine); TestCodecObserver codec_observer; - EXPECT_EQ(0, codec->RegisterDecoderObserver( - video_channel, codec_observer)); + EXPECT_EQ(0, codec->RegisterDecoderObserver(video_channel, codec_observer)); ViETest::Log("Loop through all codecs for %d seconds", - KAutoTestSleepTimeMs / 1000); + KAutoTestSleepTimeMs / 1000); for (int i = 0; i < codec->NumberOfCodecs() - 2; i++) { EXPECT_EQ(0, codec->GetCodec(i, video_codec)); @@ -194,13 +195,13 @@ void ViEAutoTest::ViECodecStandardTest() { ViETest::Log("\t %d. %s", i, video_codec.plName); RenderFilter frame_counter; - EXPECT_EQ(0, image_process->RegisterRenderEffectFilter( - video_channel, frame_counter)); + EXPECT_EQ(0, image_process->RegisterRenderEffectFilter(video_channel, + frame_counter)); AutoTestSleep(KAutoTestSleepTimeMs); // Verify we've received and decoded correct payload. EXPECT_EQ(video_codec.codecType, - codec_observer.incoming_codec_.codecType); + codec_observer.incoming_codec_.codecType); int max_number_of_possible_frames = video_codec.maxFramerate * KAutoTestSleepTimeMs / 1000; @@ -211,8 +212,7 @@ void ViEAutoTest::ViECodecStandardTest() { } else { #ifdef WEBRTC_ANDROID // To get the autotest to pass on some slow devices - EXPECT_GT( - frame_counter.num_frames_, max_number_of_possible_frames / 6); + EXPECT_GT(frame_counter.num_frames_, max_number_of_possible_frames / 6); #else EXPECT_GT(frame_counter.num_frames_, max_number_of_possible_frames / 4); #endif @@ -226,15 +226,10 @@ void ViEAutoTest::ViECodecStandardTest() { ViETest::Log("Done!"); } - // // Test Callbacks - // - - TestCodecObserver codecObserver; - EXPECT_EQ(0, codec->RegisterEncoderObserver( - video_channel, codecObserver)); - EXPECT_EQ(0, codec->RegisterDecoderObserver( - video_channel, codecObserver)); + TestCodecObserver codec_observer; + EXPECT_EQ(0, codec->RegisterEncoderObserver(video_channel, codec_observer)); + EXPECT_EQ(0, codec->RegisterDecoderObserver(video_channel, codec_observer)); ViETest::Log("\nTesting codec callbacks..."); @@ -251,9 +246,9 @@ void ViEAutoTest::ViECodecStandardTest() { EXPECT_EQ(0, codec->DeregisterEncoderObserver(video_channel)); EXPECT_EQ(0, codec->DeregisterDecoderObserver(video_channel)); - EXPECT_GT(codecObserver.incoming_codec_called_, 0); - EXPECT_GT(codecObserver.incoming_rate_called_, 0); - EXPECT_GT(codecObserver.outgoing_rate_called_, 0); + EXPECT_GT(codec_observer.incoming_codec_called_, 0); + EXPECT_GT(codec_observer.incoming_rate_called_, 0); + EXPECT_GT(codec_observer.outgoing_rate_called_, 0); EXPECT_EQ(0, base->StopReceive(video_channel)); EXPECT_EQ(0, render->StopRender(video_channel)); @@ -288,15 +283,15 @@ void ViEAutoTest::ViECodecExtendedTest() { EXPECT_EQ(0, base->CreateChannel(video_channel)); EXPECT_EQ(0, capture->ConnectCaptureDevice(capture_id, video_channel)); EXPECT_EQ(0, rtp_rtcp->SetRTCPStatus( - video_channel, webrtc::kRtcpCompound_RFC4585)); + video_channel, webrtc::kRtcpCompound_RFC4585)); EXPECT_EQ(0, rtp_rtcp->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); + video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); EXPECT_EQ(0, rtp_rtcp->SetTMMBRStatus(video_channel, true)); - EXPECT_EQ(0, render->AddRenderer( - capture_id, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, render->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, 1.0, + 1.0)); - EXPECT_EQ(0, render->AddRenderer( - video_channel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, render->AddRenderer(video_channel, _window2, 1, 0.0, 0.0, 1.0, + 1.0)); EXPECT_EQ(0, render->StartRender(capture_id)); EXPECT_EQ(0, render->StartRender(video_channel)); @@ -312,16 +307,14 @@ void ViEAutoTest::ViECodecExtendedTest() { } const char* ip_address = "127.0.0.1"; - const unsigned short rtp_port = 6000; + const uint16_t rtp_port = 6000; EXPECT_EQ(0, network->SetLocalReceiver(video_channel, rtp_port)); EXPECT_EQ(0, base->StartReceive(video_channel)); EXPECT_EQ(0, network->SetSendDestination( video_channel, ip_address, rtp_port)); EXPECT_EQ(0, base->StartSend(video_channel)); - // // Codec specific tests - // memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); EXPECT_EQ(0, base->StopSend(video_channel)); @@ -337,16 +330,13 @@ void ViEAutoTest::ViECodecExtendedTest() { EXPECT_EQ(0, base->DeleteChannel(video_channel)); } - // // Multiple send channels. - // { // Create two channels, where the second channel is created from the // first channel. Send different resolutions on the channels and verify // the received streams. - TbInterfaces video_engine("ViECodecExtendedTest2"); - TbCaptureDevice tbCapture(video_engine); + TbCaptureDevice tb_capture(video_engine); // Create channel 1. int video_channel_1 = -1; @@ -357,10 +347,10 @@ void ViEAutoTest::ViECodecExtendedTest() { EXPECT_EQ(0, video_engine.base->CreateChannel( video_channel_2, video_channel_1)); EXPECT_NE(video_channel_1, video_channel_2) - << "Channel 2 should be unique."; + << "Channel 2 should be unique."; - unsigned short rtp_port_1 = 12000; - unsigned short rtp_port_2 = 13000; + uint16_t rtp_port_1 = 12000; + uint16_t rtp_port_2 = 13000; EXPECT_EQ(0, video_engine.network->SetLocalReceiver( video_channel_1, rtp_port_1)); EXPECT_EQ(0, video_engine.network->SetSendDestination( @@ -369,47 +359,46 @@ void ViEAutoTest::ViECodecExtendedTest() { video_channel_2, rtp_port_2)); EXPECT_EQ(0, video_engine.network->SetSendDestination( video_channel_2, "127.0.0.1", rtp_port_2)); - - tbCapture.ConnectTo(video_channel_1); - tbCapture.ConnectTo(video_channel_2); - + tb_capture.ConnectTo(video_channel_1); + tb_capture.ConnectTo(video_channel_2); EXPECT_EQ(0, video_engine.rtp_rtcp->SetKeyFrameRequestMethod( video_channel_1, webrtc::kViEKeyFrameRequestPliRtcp)); EXPECT_EQ(0, video_engine.rtp_rtcp->SetKeyFrameRequestMethod( video_channel_2, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, video_engine.render->AddRenderer( - video_channel_1, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, video_engine.render->AddRenderer(video_channel_1, _window1, 0, + 0.0, 0.0, 1.0, 1.0)); EXPECT_EQ(0, video_engine.render->StartRender(video_channel_1)); - EXPECT_EQ(0, video_engine.render->AddRenderer( - video_channel_2, _window2, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, video_engine.render->AddRenderer(video_channel_2, _window2, 0, + 0.0, 0.0, 1.0, 1.0)); EXPECT_EQ(0, video_engine.render->StartRender(video_channel_2)); - // Set Send codec - unsigned short codecWidth = 320; - unsigned short codecHeight = 240; - bool codecSet = false; - webrtc::VideoCodec videoCodec; - webrtc::VideoCodec sendCodec1; - webrtc::VideoCodec sendCodec2; + // Set Send codec. + uint16_t codec_width = 320; + uint16_t codec_height = 240; + bool codec_set = false; + webrtc::VideoCodec video_codec; + webrtc::VideoCodec send_codec1; + webrtc::VideoCodec send_codec2; for (int idx = 0; idx < video_engine.codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, video_engine.codec->GetCodec(idx, videoCodec)); - EXPECT_EQ(0, video_engine.codec->SetReceiveCodec( - video_channel_1, videoCodec)); - if (videoCodec.codecType == webrtc::kVideoCodecVP8) { - memcpy(&sendCodec1, &videoCodec, sizeof(videoCodec)); - sendCodec1.width = codecWidth; - sendCodec1.height = codecHeight; + EXPECT_EQ(0, video_engine.codec->GetCodec(idx, video_codec)); + EXPECT_EQ(0, video_engine.codec->SetReceiveCodec(video_channel_1, + video_codec)); + if (video_codec.codecType == webrtc::kVideoCodecVP8) { + memcpy(&send_codec1, &video_codec, sizeof(video_codec)); + send_codec1.width = codec_width; + send_codec1.height = codec_height; EXPECT_EQ(0, video_engine.codec->SetSendCodec( - video_channel_1, sendCodec1)); - memcpy(&sendCodec2, &videoCodec, sizeof(videoCodec)); - sendCodec2.width = 2 * codecWidth; - sendCodec2.height = 2 * codecHeight; + video_channel_1, send_codec1)); + memcpy(&send_codec2, &video_codec, sizeof(video_codec)); + send_codec2.width = 2 * codec_width; + send_codec2.height = 2 * codec_height; EXPECT_EQ(0, video_engine.codec->SetSendCodec( - video_channel_2, sendCodec2)); - codecSet = true; + video_channel_2, send_codec2)); + codec_set = true; break; } - }EXPECT_TRUE(codecSet); + } + EXPECT_TRUE(codec_set); // We need to verify using render effect filter since we won't trigger // a decode reset in loopback (due to using the same SSRC). @@ -436,10 +425,10 @@ void ViEAutoTest::ViECodecExtendedTest() { video_channel_1)); EXPECT_EQ(0, video_engine.image_process->DeregisterRenderEffectFilter( video_channel_2)); - EXPECT_EQ(sendCodec1.width, filter1.last_render_width_); - EXPECT_EQ(sendCodec1.height, filter1.last_render_height_); - EXPECT_EQ(sendCodec2.width, filter2.last_render_width_); - EXPECT_EQ(sendCodec2.height, filter2.last_render_height_); + EXPECT_EQ(send_codec1.width, filter1.last_render_width_); + EXPECT_EQ(send_codec1.height, filter1.last_render_height_); + EXPECT_EQ(send_codec2.width, filter2.last_render_width_); + EXPECT_EQ(send_codec2.height, filter2.last_render_height_); EXPECT_EQ(0, video_engine.base->DeleteChannel(video_channel_1)); EXPECT_EQ(0, video_engine.base->DeleteChannel(video_channel_2)); @@ -467,7 +456,6 @@ void ViEAutoTest::ViECodecAPITest() { for (int i = 0; i < number_of_codecs; i++) { EXPECT_EQ(0, codec->GetCodec(i, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecVP8) { EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); break; @@ -496,263 +484,247 @@ void ViEAutoTest::ViECodecAPITest() { } #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API -#include "vie_external_codec.h" +#include "video_engine/include/vie_external_codec.h" #endif void ViEAutoTest::ViECodecExternalCodecTest() { ViETest::Log(" "); ViETest::Log("========================================"); ViETest::Log(" ViEExternalCodec Test\n"); - //*************************************************************** + /// ************************************************************** // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** + /// ************************************************************** - //*************************************************************** + /// ************************************************************** // Engine ready. Begin testing class - //*************************************************************** + /// ************************************************************** #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - int numberOfErrors=0; + int number_of_errors = 0; { - int error=0; + int error = 0; TbInterfaces ViE("ViEExternalCodec"); - TbCaptureDevice captureDevice(ViE); - TbVideoChannel channel(ViE, webrtc::kVideoCodecI420, - 352,288,30,(352*288*3*8*30)/(2*1000)); + TbCaptureDevice capture_device(ViE); + TbVideoChannel channel(ViE, webrtc::kVideoCodecI420, 352, 288, 30, + (352 * 288 * 3 * 8 * 30) / (2 * 1000)); + capture_device.ConnectTo(channel.videoChannel); - captureDevice.ConnectTo(channel.videoChannel); - - error = ViE.render->AddRenderer(channel.videoChannel, _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->AddRenderer(channel.videoChannel, _window1, 0, 0.0, 0.0, + 1.0, 1.0); + number_of_errors += 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__); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); channel.StartReceive(); channel.StartSend(); ViETest::Log("Using internal I420 codec"); - AutoTestSleep(KAutoTestSleepTimeMs/2); + AutoTestSleep(KAutoTestSleepTimeMs / 2); - webrtc::ViEExternalCodec* ptrViEExtCodec = - webrtc::ViEExternalCodec::GetInterface(ViE.video_engine); - numberOfErrors += ViETest::TestError(ptrViEExtCodec != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::ViEExternalCodec* vie_external_codec = + webrtc::ViEExternalCodec::GetInterface(ViE.video_engine); + number_of_errors += ViETest::TestError(vie_external_codec != NULL, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + webrtc::VideoCodec codec_struct; + error = ViE.codec->GetSendCodec(channel.videoChannel, codecStruct); + number_of_errors += ViETest::TestError(vie_external_codec != NULL, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - webrtc::VideoCodec codecStruct; - - error=ViE.codec->GetSendCodec(channel.videoChannel,codecStruct); - numberOfErrors += ViETest::TestError(ptrViEExtCodec != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Use external encoder instead + // Use external encoder instead. { - TbI420Encoder extEncoder; + TbI420Encoder ext_encoder; - // Test to register on wrong channel - error = ptrViEExtCodec->RegisterExternalSendCodec( - channel.videoChannel+5,codecStruct.plType,&extEncoder); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( + // Test to register on wrong channel. + error = vie_external_codec->RegisterExternalSendCodec( + channel.videoChannel + 5, codecStruct.plType, &ext_encoder); + number_of_errors += ViETest::TestError(error == -1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError( ViE.LastError() == kViECodecInvalidArgument, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ptrViEExtCodec->RegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType,&extEncoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_external_codec->RegisterExternalSendCodec( + channel.videoChannel, codecStruct.plType, &ext_encoder); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Use new external encoder - error = ViE.codec->SetSendCodec(channel.videoChannel,codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = ViE.codec->SetSendCodec(channel.videoChannel, codecStruct); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - TbI420Decoder extDecoder; - error = ptrViEExtCodec->RegisterExternalReceiveCodec( - channel.videoChannel,codecStruct.plType,&extDecoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + TbI420Decoder ext_decoder; + error = vie_external_codec->RegisterExternalReceiveCodec( + channel.videoChannel, codecStruct.plType, &ext_decoder); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ViE.codec->SetReceiveCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = ViE.codec->SetReceiveCodec(channel.videoChannel, codec_struct); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); ViETest::Log("Using external I420 codec"); AutoTestSleep(KAutoTestSleepTimeMs); // Test to deregister on wrong channel - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel+5,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", + error = vie_external_codec->DeRegisterExternalSendCodec( + channel.videoChannel + 5, codecStruct.plType); + number_of_errors += ViETest::TestError(error == -1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError( + ViE.LastError() == kViECodecInvalidArgument, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - ViE.LastError() == kViECodecInvalidArgument, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); // Test to deregister wrong payload type. - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType-1); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_external_codec->DeRegisterExternalSendCodec( + channel.videoChannel, codecStruct.plType - 1); + number_of_errors += ViETest::TestError(error == -1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Deregister external send codec - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + error = vie_external_codec->DeRegisterExternalSendCodec( + channel.videoChannel, codecStruct.plType); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViEExtCodec->DeRegisterExternalReceiveCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_external_codec->DeRegisterExternalReceiveCodec( + channel.videoChannel, codecStruct.plType); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Verify that the encoder and decoder has been used - TbI420Encoder::FunctionCalls encodeCalls = - extEncoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(encodeCalls.InitEncode == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Release == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Encode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - encodeCalls.RegisterEncodeCompleteCallback ==1, + TbI420Encoder::FunctionCalls encode_calls = + ext_encoder.GetFunctionCalls(); + number_of_errors += ViETest::TestError(encode_calls.InitEncode == 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.Release == 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.Encode > 30, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError( + encode_calls.RegisterEncodeCompleteCallback == 1, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetRates > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetPacketLoss > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.SetRates > 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.SetPacketLoss > 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - TbI420Decoder::FunctionCalls decodeCalls = - extDecoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(decodeCalls.InitDecode == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Release == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Decode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - decodeCalls.RegisterDecodeCompleteCallback ==1, + TbI420Decoder::FunctionCalls decode_calls = + ext_decoder.GetFunctionCalls(); + number_of_errors += ViETest::TestError(decode_calls.InitDecode == 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(decode_calls.Release == 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(decode_calls.Decode > 30, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError( + decode_calls.RegisterDecodeCompleteCallback == 1, "ERROR: %s at line %d", __FUNCTION__, __LINE__); ViETest::Log("Changing payload type Using external I420 codec"); - codecStruct.plType=codecStruct.plType-1; - error = ptrViEExtCodec->RegisterExternalReceiveCodec( - channel.videoChannel, codecStruct.plType, &extDecoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + codec_struct.plType = codecStruct.plType - 1; + error = vie_external_codec->RegisterExternalReceiveCodec( + channel.videoChannel, codec_struct.plType, &ext_decoder); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); error = ViE.codec->SetReceiveCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + codec_struct); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViEExtCodec->RegisterExternalSendCodec( - channel.videoChannel, codecStruct.plType, &extEncoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_external_codec->RegisterExternalSendCodec( + channel.videoChannel, codec_struct.plType, &ext_encoder); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Use new external encoder error = ViE.codec->SetSendCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + codec_struct); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - AutoTestSleep(KAutoTestSleepTimeMs/2); + AutoTestSleep(KAutoTestSleepTimeMs / 2); - //*************************************************************** + /// ************************************************************** // Testing finished. Tear down Video Engine - //*************************************************************** + /// ************************************************************** - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViEExtCodec->DeRegisterExternalReceiveCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_external_codec->DeRegisterExternalSendCodec( + channel.videoChannel, codecStruct.plType); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_external_codec->DeRegisterExternalReceiveCodec( + channel.videoChannel, codecStruct.plType); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Verify that the encoder and decoder has been used - encodeCalls = extEncoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(encodeCalls.InitEncode == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Release == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Encode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - encodeCalls.RegisterEncodeCompleteCallback == 2, + encode_calls = ext_encoder.GetFunctionCalls(); + number_of_errors += ViETest::TestError(encode_calls.InitEncode == 2, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.Release == 2, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.Encode > 30, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError( + encode_calls.RegisterEncodeCompleteCallback == 2, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetRates > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetPacketLoss > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.SetRates > 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(encode_calls.SetPacketLoss > 1, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - decodeCalls = extDecoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(decodeCalls.InitDecode == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Release == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Decode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - decodeCalls.RegisterDecodeCompleteCallback == 2, + decode_calls = ext_decoder.GetFunctionCalls(); + number_of_errors += ViETest::TestError(decode_calls.InitDecode == 2, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(decode_calls.Release == 2, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError(decode_calls.Decode > 30, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + number_of_errors += ViETest::TestError( + decode_calls.RegisterDecodeCompleteCallback == 2, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - int remainingInterfaces = ptrViEExtCodec->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } // tbI420Encoder and extDecoder goes out of scope + int remaining_interfaces = vie_external_codec->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + } // tbI420Encoder and ext_decoder goes out of scope. ViETest::Log("Using internal I420 codec"); - AutoTestSleep(KAutoTestSleepTimeMs/2); - + AutoTestSleep(KAutoTestSleepTimeMs / 2); } - if (numberOfErrors > 0) - { + if (number_of_errors > 0) { // Test failed ViETest::Log(" "); ViETest::Log(" ERROR ViEExternalCodec Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); + ViETest::Log(" Number of errors: %d", number_of_errors); ViETest::Log("========================================"); ViETest::Log(" "); return; diff --git a/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc b/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc index 9e59119103..6de40f03c2 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc @@ -8,15 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_autotest_custom_call.cc - * - */ - -#include - -#include "vie_autotest.h" -#include "vie_autotest_defines.h" +#include "video_engine/test/auto_test/interface/vie_autotest.h" +#include "video_engine/test/auto_test/interface/vie_autotest_defines.h" #define VCM_RED_PAYLOAD_TYPE 96 #define VCM_ULPFEC_PAYLOAD_TYPE 97 @@ -41,22 +34,22 @@ enum StatisticsType { kReceivedStatistic }; -class ViEAutotestFileObserver: public webrtc::ViEFileObserver { +class ViEAutotestFileObserver : public webrtc::ViEFileObserver { public: - ViEAutotestFileObserver() {}; - ~ViEAutotestFileObserver() {}; + ViEAutotestFileObserver() {} + ~ViEAutotestFileObserver() {} - void PlayFileEnded(const WebRtc_Word32 fileId) { + void PlayFileEnded(const WebRtc_Word32 file_id) { ViETest::Log("PlayFile ended"); } }; -class ViEAutotestEncoderObserver: public webrtc::ViEEncoderObserver { +class ViEAutotestEncoderObserver : public webrtc::ViEEncoderObserver { public: - ViEAutotestEncoderObserver() {}; - ~ViEAutotestEncoderObserver() {}; + ViEAutotestEncoderObserver() {} + ~ViEAutotestEncoderObserver() {} - void OutgoingRate(const int videoChannel, + void OutgoingRate(const int video_channel, const unsigned int framerate, const unsigned int bitrate) { std::cout << "Send FR: " << framerate @@ -64,244 +57,251 @@ class ViEAutotestEncoderObserver: public webrtc::ViEEncoderObserver { } }; -class ViEAutotestDecoderObserver: public webrtc::ViEDecoderObserver { +class ViEAutotestDecoderObserver : public webrtc::ViEDecoderObserver { public: - ViEAutotestDecoderObserver() {}; - ~ViEAutotestDecoderObserver() {}; + ViEAutotestDecoderObserver() {} + ~ViEAutotestDecoderObserver() {} - void IncomingRate(const int videoChannel, + void IncomingRate(const int video_channel, const unsigned int framerate, const unsigned int bitrate) { std::cout << "Received FR: " << framerate << " BR: " << bitrate << std::endl; } - void IncomingCodecChanged(const int videoChannel, + void IncomingCodecChanged(const int video_channel, const webrtc::VideoCodec& codec) {} - void RequestNewKeyFrame(const int videoChannel) { + void RequestNewKeyFrame(const int video_channel) { std::cout << "Decoder requesting a new key frame." << std::endl; } }; // The following are general helper functions. -bool GetVideoDevice(webrtc::ViEBase* ptrViEBase, - webrtc::ViECapture* ptrViECapture, - char* captureDeviceName, char* captureDeviceUniqueId); +bool GetVideoDevice(webrtc::ViEBase* vie_base, + webrtc::ViECapture* vie_capture, + char* capture_device_name, char* capture_device_unique_id); bool GetIPAddress(char* IP); -bool ValidateIP(std::string iStr); +bool ValidateIP(std::string i_str); // The following are Print to stdout functions. -void PrintCallInformation(char* IP, char* videoCaptureDeviceName, - char* videoCaptureUniqueId, - webrtc::VideoCodec videoCodec, int videoTxPort, - int videoRxPort, char* audioCaptureDeviceName, - char* audioPlaybackDeviceName, - webrtc::CodecInst audioCodec, int audioTxPort, - int audioRxPort, int protectionMethod); -void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel, StatisticsType statType); -void PrintRTPStatistics(webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel); -void PrintBandwidthUsage(webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel); -void PrintCodecStatistics(webrtc::ViECodec* ptrViECodec, int videoChannel, - StatisticsType statType); -void PrintGetDiscardedPackets(webrtc::ViECodec* ptrViECodec, int videoChannel); -void PrintVideoStreamInformation(webrtc::ViECodec* ptrViECodec, - int videoChannel); -void PrintVideoCodec(webrtc::VideoCodec videoCodec); +void PrintCallInformation(char* IP, + char* video_capture_device_name, + char* video_capture_unique_id, + webrtc::VideoCodec video_codec, + int video_tx_port, + int video_rx_port, + char* audio_capture_device_name, + char* audio_playbackDeviceName, + webrtc::CodecInst audio_codec, + int audio_tx_port, + int audio_rx_port, + int protection_method); +void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel, + StatisticsType stat_type); +void PrintRTPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel); +void PrintBandwidthUsage(webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel); +void PrintCodecStatistics(webrtc::ViECodec* vie_codec, + int video_channel, + StatisticsType stat_type); +void PrintGetDiscardedPackets(webrtc::ViECodec* vie_codec, + int video_channel); +void PrintVideoStreamInformation(webrtc::ViECodec* vie_codec, + int video_channel); +void PrintVideoCodec(webrtc::VideoCodec video_codec); // The following are video functions. -// TODO(amyfong): change to pointers as input arguments +// TODO(amyfong): change to pointers as input arguments // instead of references -bool SetVideoPorts(int* txPort, int* rxPort); -bool SetVideoCodecType(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecResolution(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecSize(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecBitrate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecMinBitrate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecMaxBitrate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecMaxFramerate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec); -bool SetVideoCodecTemporalLayer(webrtc::VideoCodec& videoCodec); +bool SetVideoPorts(int* tx_port, int* rx_port); +bool SetVideoCodecType(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecSize(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecBitrate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecMinBitrate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecMaxBitrate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecMaxFramerate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec); +bool SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec); int GetVideoProtection(); -bool SetVideoProtection(webrtc::ViECodec* ptrViECodec, - webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel, int protectionMethod); +bool SetVideoProtection(webrtc::ViECodec* vie_codec, + webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel, int protection_method); bool GetBitrateSignaling(); // The following are audio helper functions. -bool GetAudioDevices(webrtc::VoEBase* ptrVEBase, - webrtc::VoEHardware* ptrVEHardware, - char* recordingDeviceName, int& recordingDeviceIndex, - char* playbackDeviceName, int& playbackDeviceIndex); -bool GetAudioDevices(webrtc::VoEBase* ptrVEBase, - webrtc::VoEHardware* ptrVEHardware, - int& recordingDeviceIndex, int& playbackDeviceIndex); -bool GetAudioPorts(int* txPort, int* rxPort); -bool GetAudioCodec(webrtc::VoECodec* ptrVeCodec, - webrtc::CodecInst& audioCodec); +bool GetAudioDevices(webrtc::VoEBase* voe_base, + webrtc::VoEHardware* voe_hardware, + char* recording_device_name, int& recording_device_index, + char* playbackDeviceName, int& playback_device_index); +bool GetAudioDevices(webrtc::VoEBase* voe_base, + webrtc::VoEHardware* voe_hardware, + int& recording_device_index, int& playback_device_index); +bool GetAudioPorts(int* tx_port, int* rx_port); +bool GetAudioCodec(webrtc::VoECodec* voe_codec, + webrtc::CodecInst& audio_codec); -int ViEAutoTest::ViECustomCall() -{ +int ViEAutoTest::ViECustomCall() { ViETest::Log(" "); ViETest::Log("========================================"); ViETest::Log(" Enter values to use custom settings\n"); int error = 0; - int numberOfErrors = 0; + int number_of_errors = 0; std::string str; // Create the VoE and get the VoE interfaces. - webrtc::VoiceEngine* ptrVE = webrtc::VoiceEngine::Create(); - numberOfErrors += ViETest::TestError(ptrVE != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::VoiceEngine* voe = webrtc::VoiceEngine::Create(); + number_of_errors += ViETest::TestError(voe != NULL, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - webrtc::VoEBase* ptrVEBase = webrtc::VoEBase::GetInterface(ptrVE); - numberOfErrors += ViETest::TestError(ptrVEBase != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::VoEBase* voe_base = webrtc::VoEBase::GetInterface(voe); + number_of_errors += ViETest::TestError(voe_base != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - error = ptrVEBase->Init(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_base->Init(); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - webrtc::VoECodec* ptrVECodec = webrtc::VoECodec::GetInterface(ptrVE); - numberOfErrors += ViETest::TestError(ptrVECodec != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::VoECodec* voe_codec = webrtc::VoECodec::GetInterface(voe); + number_of_errors += ViETest::TestError(voe_codec != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::VoEHardware* ptrVEHardware = - webrtc::VoEHardware::GetInterface(ptrVE); - numberOfErrors += ViETest::TestError(ptrVEHardware != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::VoEHardware* voe_hardware = + webrtc::VoEHardware::GetInterface(voe); + number_of_errors += ViETest::TestError(voe_hardware != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::VoEAudioProcessing* ptrVEAPM = - webrtc::VoEAudioProcessing::GetInterface(ptrVE); - numberOfErrors += ViETest::TestError(ptrVEAPM != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::VoEAudioProcessing* voe_apm = + webrtc::VoEAudioProcessing::GetInterface(voe); + number_of_errors += ViETest::TestError(voe_apm != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); // Create the ViE and get the ViE Interfaces. - webrtc::VideoEngine* ptrViE = webrtc::VideoEngine::Create(); - numberOfErrors += ViETest::TestError(ptrViE != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::VideoEngine* vie = webrtc::VideoEngine::Create(); + number_of_errors += ViETest::TestError(vie != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViEBase != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::ViEBase* vie_base = webrtc::ViEBase::GetInterface(vie); + number_of_errors += ViETest::TestError(vie_base != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - error = ptrViEBase->Init(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->Init(); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - webrtc::ViECapture* ptrViECapture = - webrtc::ViECapture::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViECapture != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::ViECapture* vie_capture = + webrtc::ViECapture::GetInterface(vie); + number_of_errors += ViETest::TestError(vie_capture != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::ViERender* ptrViERender = webrtc::ViERender::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViERender != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::ViERender* vie_renderer = webrtc::ViERender::GetInterface(vie); + number_of_errors += ViETest::TestError(vie_renderer != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::ViECodec* ptrViECodec = webrtc::ViECodec::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViECodec != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::ViECodec* vie_codec = webrtc::ViECodec::GetInterface(vie); + number_of_errors += ViETest::TestError(vie_codec != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::ViENetwork* ptrViENetwork = - webrtc::ViENetwork::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViENetwork != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::ViENetwork* vie_network = webrtc::ViENetwork::GetInterface(vie); + number_of_errors += ViETest::TestError(vie_network != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - webrtc::ViEFile* ptrViEFile = webrtc::ViEFile::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViEFile != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + webrtc::ViEFile* vie_file = webrtc::ViEFile::GetInterface(vie); + number_of_errors += ViETest::TestError(vie_file != NULL, + "ERROR: %s at line %d", __FUNCTION__, + __LINE__); - bool startCall = false; + bool start_call = false; const unsigned int kMaxIPLength = 16; - char ipAddress[kMaxIPLength] = ""; + char ip_address[kMaxIPLength] = ""; const unsigned int KMaxUniqueIdLength = 256; - char uniqueId[KMaxUniqueIdLength] = ""; - char deviceName[KMaxUniqueIdLength] = ""; - int videoTxPort = 0; - int videoRxPort = 0; - int videoChannel = -1; - webrtc::VideoCodec videoSendCodec; - char audioCaptureDeviceName[KMaxUniqueIdLength] = ""; - char audioPlaybackDeviceName[KMaxUniqueIdLength] = ""; - int audioCaptureDeviceIndex = -1; - int audioPlaybackDeviceIndex = -1; - int audioTxPort = 0; - int audioRxPort = 0; - webrtc::CodecInst audioCodec; - int audioChannel = -1; - bool isImageScaleEnabled = false; - int protectionMethod = DEFAULT_VIDEO_PROTECTION_METHOD; + char unique_id[KMaxUniqueIdLength] = ""; + char device_name[KMaxUniqueIdLength] = ""; + int video_tx_port = 0; + int video_rx_port = 0; + int video_channel = -1; + webrtc::VideoCodec video_send_codec; + char audio_capture_device_name[KMaxUniqueIdLength] = ""; + char audio_playbackDeviceName[KMaxUniqueIdLength] = ""; + int audio_capture_device_index = -1; + int audio_playback_device_index = -1; + int audio_tx_port = 0; + int audio_rx_port = 0; + webrtc::CodecInst audio_codec; + int audio_channel = -1; + bool is_image_scale_enabled = false; + int protection_method = DEFAULT_VIDEO_PROTECTION_METHOD; bool remb = true; - while (!startCall) { + while (!start_call) { // Get the IP address to use from call. - memset(ipAddress, 0, kMaxIPLength); - GetIPAddress(ipAddress); + memset(ip_address, 0, kMaxIPLength); + GetIPAddress(ip_address); // Get the video device to use for call. - memset(deviceName, 0, KMaxUniqueIdLength); - memset(uniqueId, 0, KMaxUniqueIdLength); - GetVideoDevice(ptrViEBase, ptrViECapture, deviceName, uniqueId); + memset(device_name, 0, KMaxUniqueIdLength); + memset(unique_id, 0, KMaxUniqueIdLength); + GetVideoDevice(vie_base, vie_capture, device_name, unique_id); // Get and set the video ports for the call. - videoTxPort = 0; - videoRxPort = 0; - SetVideoPorts(&videoTxPort, &videoRxPort); + video_tx_port = 0; + video_rx_port = 0; + SetVideoPorts(&video_tx_port, &video_rx_port); // Get and set the video codec parameters for the call. - memset((void*)&videoSendCodec, 0, sizeof(webrtc::VideoCodec)); - SetVideoCodecType(ptrViECodec, videoSendCodec); - SetVideoCodecSize(ptrViECodec, videoSendCodec); - SetVideoCodecBitrate(ptrViECodec, videoSendCodec); - SetVideoCodecMinBitrate(ptrViECodec, videoSendCodec); - SetVideoCodecMaxBitrate(ptrViECodec, videoSendCodec); - SetVideoCodecMaxFramerate(ptrViECodec, videoSendCodec); - SetVideoCodecTemporalLayer(videoSendCodec); + memset(&video_send_codec, 0, sizeof(webrtc::VideoCodec)); + SetVideoCodecType(vie_codec, &video_send_codec); + SetVideoCodecSize(vie_codec, &video_send_codec); + SetVideoCodecBitrate(vie_codec, &video_send_codec); + SetVideoCodecMinBitrate(vie_codec, &video_send_codec); + SetVideoCodecMaxBitrate(vie_codec, &video_send_codec); + SetVideoCodecMaxFramerate(vie_codec, &video_send_codec); + SetVideoCodecTemporalLayer(&video_send_codec); remb = GetBitrateSignaling(); // Get the video protection method for the call. - protectionMethod = GetVideoProtection(); + protection_method = GetVideoProtection(); // Get the audio device for the call. - memset(audioCaptureDeviceName, 0, KMaxUniqueIdLength); - memset(audioPlaybackDeviceName, 0, KMaxUniqueIdLength); - GetAudioDevices(ptrVEBase, ptrVEHardware, audioCaptureDeviceName, - audioCaptureDeviceIndex, audioPlaybackDeviceName, - audioPlaybackDeviceIndex); + memset(audio_capture_device_name, 0, KMaxUniqueIdLength); + memset(audio_playbackDeviceName, 0, KMaxUniqueIdLength); + GetAudioDevices(voe_base, voe_hardware, audio_capture_device_name, + audio_capture_device_index, audio_playbackDeviceName, + audio_playback_device_index); // Get the audio port for the call. - audioTxPort = 0; - audioRxPort = 0; - GetAudioPorts(&audioTxPort, &audioRxPort); + audio_tx_port = 0; + audio_rx_port = 0; + GetAudioPorts(&audio_tx_port, &audio_rx_port); // Get the audio codec for the call. - memset((void*)&audioCodec, 0, sizeof(audioCodec)); - GetAudioCodec(ptrVECodec, audioCodec); + memset(static_cast(&audio_codec), 0, sizeof(audio_codec)); + GetAudioCodec(voe_codec, audio_codec); // Now ready to start the call. Check user wants to continue. - PrintCallInformation(ipAddress, deviceName, uniqueId, videoSendCodec, - videoTxPort, videoRxPort, audioCaptureDeviceName, - audioPlaybackDeviceName, audioCodec, audioTxPort, - audioRxPort, protectionMethod); + PrintCallInformation(ip_address, device_name, unique_id, video_send_codec, + video_tx_port, video_rx_port, + audio_capture_device_name, audio_playbackDeviceName, + audio_codec, audio_tx_port, audio_rx_port, + protection_method); std::cout << std::endl; std::cout << "1. Start the call" << std::endl; @@ -315,13 +315,13 @@ int ViEAutoTest::ViECustomCall() switch (selection) { case 0: - startCall = true; + start_call = true; break; case 1: - startCall = true; + start_call = true; break; case 2: - startCall = false; + start_call = false; break; default: // Invalid selection gets error mesage. @@ -330,201 +330,199 @@ int ViEAutoTest::ViECustomCall() continue; } } - //*************************************************************** + /// ************************************************************** // Begin create/initialize WebRTC Video Engine for testing. - //*************************************************************** - if (startCall == true) { + /// ************************************************************** + if (start_call == true) { // Configure audio channel first. - audioChannel = ptrVEBase->CreateChannel(); - error = ptrVEBase->SetSendDestination(audioChannel, audioTxPort, - ipAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + audio_channel = voe_base->CreateChannel(); + error = voe_base->SetSendDestination(audio_channel, audio_tx_port, + ip_address); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEBase->SetLocalReceiver(audioChannel, audioRxPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_base->SetLocalReceiver(audio_channel, audio_rx_port); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEHardware->SetRecordingDevice(audioCaptureDeviceIndex); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_hardware->SetRecordingDevice(audio_capture_device_index); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEHardware->SetPlayoutDevice(audioPlaybackDeviceIndex); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_hardware->SetPlayoutDevice(audio_playback_device_index); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVECodec->SetSendCodec(audioChannel, audioCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_codec->SetSendCodec(audio_channel, audio_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEAPM->SetAgcStatus(true, webrtc::kAgcDefault); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_apm->SetAgcStatus(true, webrtc::kAgcDefault); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEAPM->SetNsStatus(true, webrtc::kNsHighSuppression); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_apm->SetNsStatus(true, webrtc::kNsHighSuppression); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Now configure the video channel. - error = ptrViE->SetTraceFilter(webrtc::kTraceAll); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie->SetTraceFilter(webrtc::kTraceAll); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); std::string trace_file = ViETest::GetResultOutputPath() + "ViECustomCall_trace.txt"; - error = ptrViE->SetTraceFile(trace_file.c_str()); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie->SetTraceFile(trace_file.c_str()); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViEBase->SetVoiceEngine(ptrVE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->SetVoiceEngine(voe); + number_of_errors += 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__); + error = vie_base->CreateChannel(video_channel); + number_of_errors += 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__); + error = vie_base->ConnectAudioChannel(video_channel, audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - int captureId = 0; - error = ptrViECapture->AllocateCaptureDevice(uniqueId, - KMaxUniqueIdLength, - captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + int capture_id = 0; + error = vie_capture->AllocateCaptureDevice(unique_id, + KMaxUniqueIdLength, + capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECapture->ConnectCaptureDevice(captureId, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_capture->ConnectCaptureDevice(capture_id, video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_capture->StartCapture(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - webrtc::ViERTP_RTCP* ptrViERtpRtcp = - webrtc::ViERTP_RTCP::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViE != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::ViERTP_RTCP* vie_rtp_rtcp = + webrtc::ViERTP_RTCP::GetInterface(vie); + number_of_errors += ViETest::TestError(vie != NULL, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERtpRtcp->SetRTCPStatus(videoChannel, - webrtc::kRtcpCompound_RFC4585); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetRTCPStatus(video_channel, + webrtc::kRtcpCompound_RFC4585); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERtpRtcp->SetKeyFrameRequestMethod(videoChannel, - webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetKeyFrameRequestMethod( + video_channel, webrtc::kViEKeyFrameRequestPliRtcp); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); if (remb) { - error = ptrViERtpRtcp->SetRembStatus(videoChannel, true, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetRembStatus(video_channel, true, true); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); } else { - error = ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetTMMBRStatus(video_channel, true); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); } - error = ptrViERender->AddRenderer(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_renderer->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, 1.0, + 1.0); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERender->AddRenderer(videoChannel, _window2, 1, 0.0, 0.0, - 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViENetwork->SetSendDestination(videoChannel, ipAddress, - videoTxPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->AddRenderer(video_channel, _window2, 1, 0.0, 0.0, 1.0, + 1.0); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_network->SetSendDestination(video_channel, ip_address, + video_tx_port); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViENetwork->SetLocalReceiver(videoChannel, videoRxPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_network->SetLocalReceiver(video_channel, video_rx_port); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECodec->SetSendCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_codec->SetSendCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECodec->SetReceiveCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Set the Video Protection before start send and receive. - SetVideoProtection(ptrViECodec, ptrViERtpRtcp, - videoChannel, protectionMethod); + SetVideoProtection(vie_codec, vie_rtp_rtcp, + video_channel, protection_method); // Start Voice Playout and Receive. - error = ptrVEBase->StartReceive(audioChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_base->StartReceive(audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEBase->StartPlayout(audioChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_base->StartPlayout(audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEBase->StartSend(audioChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_base->StartSend(audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Now start the Video Send & Receive. - error = ptrViEBase->StartSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->StartSend(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViEBase->StartReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->StartReceive(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERender->StartRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->StartRender(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERender->StartRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - ViEAutotestFileObserver fileObserver; - int fileId; + error = vie_renderer->StartRender(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + ViEAutotestFileObserver file_observer; + int file_id; - ViEAutotestEncoderObserver* codecEncoderObserver = NULL; - ViEAutotestDecoderObserver* codecDecoderObserver = NULL; + ViEAutotestEncoderObserver* codec_encoder_observer = NULL; + ViEAutotestDecoderObserver* codec_decoder_observer = NULL; - //*************************************************************** - // Engine ready. Wait for input - //*************************************************************** + // Engine ready, wait for input. // Call started. std::cout << std::endl; @@ -583,153 +581,153 @@ int ViEAutoTest::ViECustomCall() modify_call = false; break; case 1: - // Change video Codec - SetVideoCodecType(ptrViECodec, videoSendCodec); - SetVideoCodecSize(ptrViECodec, videoSendCodec); - SetVideoCodecBitrate(ptrViECodec, videoSendCodec); - SetVideoCodecMinBitrate(ptrViECodec, videoSendCodec); - SetVideoCodecMaxBitrate(ptrViECodec, videoSendCodec); - SetVideoCodecMaxFramerate(ptrViECodec, videoSendCodec); - SetVideoCodecTemporalLayer(videoSendCodec); - PrintCallInformation(ipAddress, deviceName, - uniqueId, videoSendCodec, - videoTxPort, videoRxPort, - audioCaptureDeviceName, - audioPlaybackDeviceName, audioCodec, - audioTxPort, audioRxPort, protectionMethod); - error = ptrViECodec->SetSendCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECodec->SetReceiveCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Change video codec. + SetVideoCodecType(vie_codec, &video_send_codec); + SetVideoCodecSize(vie_codec, &video_send_codec); + SetVideoCodecBitrate(vie_codec, &video_send_codec); + SetVideoCodecMinBitrate(vie_codec, &video_send_codec); + SetVideoCodecMaxBitrate(vie_codec, &video_send_codec); + SetVideoCodecMaxFramerate(vie_codec, &video_send_codec); + SetVideoCodecTemporalLayer(&video_send_codec); + PrintCallInformation(ip_address, device_name, + unique_id, video_send_codec, + video_tx_port, video_rx_port, + audio_capture_device_name, + audio_playbackDeviceName, audio_codec, + audio_tx_port, audio_rx_port, protection_method); + error = vie_codec->SetSendCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); modify_call = true; break; case 2: - // Change Video codec size by common resolution - SetVideoCodecResolution(ptrViECodec, videoSendCodec); - PrintCallInformation(ipAddress, deviceName, - uniqueId, videoSendCodec, - videoTxPort, videoRxPort, - audioCaptureDeviceName, - audioPlaybackDeviceName, audioCodec, - audioTxPort, audioRxPort, protectionMethod); - error = ptrViECodec->SetSendCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECodec->SetReceiveCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Change Video codec size by common resolution. + SetVideoCodecResolution(vie_codec, &video_send_codec); + PrintCallInformation(ip_address, device_name, + unique_id, video_send_codec, + video_tx_port, video_rx_port, + audio_capture_device_name, + audio_playbackDeviceName, audio_codec, + audio_tx_port, audio_rx_port, protection_method); + error = vie_codec->SetSendCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); modify_call = true; break; case 3: - // Change Video codec by size height and width - SetVideoCodecSize(ptrViECodec, videoSendCodec); - PrintCallInformation(ipAddress, deviceName, - uniqueId, videoSendCodec, - videoTxPort, videoRxPort, - audioCaptureDeviceName, - audioPlaybackDeviceName, audioCodec, - audioTxPort, audioRxPort, protectionMethod); - error = ptrViECodec->SetSendCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECodec->SetReceiveCodec(videoChannel, videoSendCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Change video codec by size height and width. + SetVideoCodecSize(vie_codec, &video_send_codec); + PrintCallInformation(ip_address, device_name, + unique_id, video_send_codec, + video_tx_port, video_rx_port, + audio_capture_device_name, + audio_playbackDeviceName, audio_codec, + audio_tx_port, audio_rx_port, protection_method); + error = vie_codec->SetSendCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); modify_call = true; break; case 4: - error = ptrViERender->StopRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViERender->RemoveRenderer(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECapture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - memset(deviceName, 0, KMaxUniqueIdLength); - memset(uniqueId, 0, KMaxUniqueIdLength); - GetVideoDevice(ptrViEBase, ptrViECapture, deviceName, uniqueId); - captureId = 0; - error = ptrViECapture->AllocateCaptureDevice(uniqueId, - KMaxUniqueIdLength, - captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECapture->ConnectCaptureDevice(captureId, - videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViERender->AddRenderer( - captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViERender->StartRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->StopRender(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_renderer->RemoveRenderer(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_capture->StopCapture(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_capture->DisconnectCaptureDevice(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_capture->ReleaseCaptureDevice(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + memset(device_name, 0, KMaxUniqueIdLength); + memset(unique_id, 0, KMaxUniqueIdLength); + GetVideoDevice(vie_base, vie_capture, device_name, unique_id); + capture_id = 0; + error = vie_capture->AllocateCaptureDevice(unique_id, + KMaxUniqueIdLength, + capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_capture->ConnectCaptureDevice(capture_id, + video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_capture->StartCapture(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_renderer->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, + 1.0, 1.0); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_renderer->StartRender(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); modify_call = true; break; case 5: - // Record the incoming call + // Record the incoming call. std::cout << "Start Recording Incoming Video " << DEFAULT_INCOMING_FILE_NAME << std::endl; - error = ptrViEFile->StartRecordIncomingVideo( - videoChannel, DEFAULT_INCOMING_FILE_NAME, - webrtc::NO_AUDIO, audioCodec, videoSendCodec); + error = vie_file->StartRecordIncomingVideo( + video_channel, DEFAULT_INCOMING_FILE_NAME, + webrtc::NO_AUDIO, audio_codec, video_send_codec); std::cout << "Press enter to stop..."; std::getline(std::cin, str); - error = ptrViEFile->StopRecordIncomingVideo(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + error = vie_file->StopRecordIncomingVideo(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); modify_call = true; break; case 6: - // Record the outgoing call + // Record the outgoing call. std::cout << "Start Recording Outgoing Video " << DEFAULT_OUTGOING_FILE_NAME << std::endl; - error = ptrViEFile->StartRecordOutgoingVideo( - videoChannel, DEFAULT_OUTGOING_FILE_NAME, - webrtc::NO_AUDIO, audioCodec, videoSendCodec); + error = vie_file->StartRecordOutgoingVideo( + video_channel, DEFAULT_OUTGOING_FILE_NAME, + webrtc::NO_AUDIO, audio_codec, video_send_codec); std::cout << "Press enter to stop..."; std::getline(std::cin, str); - error = ptrViEFile->StopRecordOutgoingVideo(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + error = vie_file->StopRecordOutgoingVideo(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); modify_call = true; break; case 7: - // Send the file on the videoChannel + // Send the file on the video_channel. file_selection = 0; std::cout << "Available files to play" << std::endl; std::cout << " 0. " << DEFAULT_INCOMING_FILE_NAME << std::endl; @@ -738,144 +736,144 @@ int ViEAutoTest::ViECustomCall() << DEFAULT_INCOMING_FILE_NAME << "): "; std::getline(std::cin, str); file_selection = atoi(str.c_str()); - // Disconnect the camera first - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + // Disconnect the camera first. + error = vie_capture->DisconnectCaptureDevice(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); if (file_selection == 1) - error = ptrViEFile->StartPlayFile(DEFAULT_OUTGOING_FILE_NAME, - fileId, true); + error = vie_file->StartPlayFile(DEFAULT_OUTGOING_FILE_NAME, + file_id, true); else - error = ptrViEFile->StartPlayFile(DEFAULT_INCOMING_FILE_NAME, - fileId, true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + error = vie_file->StartPlayFile(DEFAULT_INCOMING_FILE_NAME, + file_id, true); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); 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__); + error = vie_file->RegisterObserver(file_id, file_observer); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); std::cout << std::endl; std::cout << "Start sending the file that is played in a loop " << std::endl; - error = ptrViEFile->SendFileOnChannel(fileId, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + error = vie_file->SendFileOnChannel(file_id, video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); std::cout << "Press enter to stop..."; std::getline(std::cin, str); 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__); + error = vie_file->StopSendFileOnChannel(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); 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__); - error = ptrViECapture->ConnectCaptureDevice(captureId, - videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - error = ptrViEFile->DeregisterObserver(fileId, fileObserver); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + error = vie_file->StopPlayFile(file_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); + error = vie_capture->ConnectCaptureDevice(capture_id, + video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); + error = vie_file->DeregisterObserver(file_id, file_observer); + number_of_errors += ViETest::TestError(error == -1, + "ERROR:%d %s at line %d", + vie_base->LastError(), + __FUNCTION__, __LINE__); modify_call = true; break; case 8: - // Change the Video Protection - protectionMethod = GetVideoProtection(); - SetVideoProtection(ptrViECodec, ptrViERtpRtcp, - videoChannel, protectionMethod); + // Change the Video Protection. + protection_method = GetVideoProtection(); + SetVideoProtection(vie_codec, vie_rtp_rtcp, + video_channel, protection_method); modify_call = true; break; case 9: - // Toggle Encoder Observer - if (!codecEncoderObserver) { + // Toggle Encoder Observer. + if (!codec_encoder_observer) { std::cout << "Registering Encoder Observer" << std::endl; - codecEncoderObserver = new ViEAutotestEncoderObserver(); - error = ptrViECodec->RegisterEncoderObserver(videoChannel, - *codecEncoderObserver); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + codec_encoder_observer = new ViEAutotestEncoderObserver(); + error = vie_codec->RegisterEncoderObserver(video_channel, + *codec_encoder_observer); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); } else { std::cout << "Deregistering Encoder Observer" << std::endl; - error = ptrViECodec->DeregisterEncoderObserver(videoChannel); - delete codecEncoderObserver; - codecEncoderObserver = NULL; - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_codec->DeregisterEncoderObserver(video_channel); + delete codec_encoder_observer; + codec_encoder_observer = NULL; + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); } modify_call = true; break; case 10: - // Toggle Decoder Observer - if (!codecDecoderObserver) { + // Toggle Decoder Observer. + if (!codec_decoder_observer) { std::cout << "Registering Decoder Observer" << std::endl; - codecDecoderObserver = new ViEAutotestDecoderObserver(); - error = ptrViECodec->RegisterDecoderObserver(videoChannel, - *codecDecoderObserver); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + codec_decoder_observer = new ViEAutotestDecoderObserver(); + error = vie_codec->RegisterDecoderObserver(video_channel, + *codec_decoder_observer); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); } else { std::cout << "Deregistering Decoder Observer" << std::endl; - error = ptrViECodec->DeregisterDecoderObserver(videoChannel); - delete codecDecoderObserver; - codecDecoderObserver = NULL; - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_codec->DeregisterDecoderObserver(video_channel); + delete codec_decoder_observer; + codec_decoder_observer = NULL; + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); } modify_call = true; break; case 11: - // Print Call information - PrintCallInformation(ipAddress, deviceName, - uniqueId, videoSendCodec, - videoTxPort, videoRxPort, - audioCaptureDeviceName, - audioPlaybackDeviceName, - audioCodec, audioTxPort, - audioRxPort, protectionMethod); - PrintVideoStreamInformation(ptrViECodec, - videoChannel); + // Print Call information.. + PrintCallInformation(ip_address, device_name, + unique_id, video_send_codec, + video_tx_port, video_rx_port, + audio_capture_device_name, + audio_playbackDeviceName, + audio_codec, audio_tx_port, + audio_rx_port, protection_method); + PrintVideoStreamInformation(vie_codec, + video_channel); modify_call = true; break; case 12: - // Print Call statistics - PrintRTCCPStatistics(ptrViERtpRtcp, videoChannel, + // Print Call statistics. + PrintRTCCPStatistics(vie_rtp_rtcp, video_channel, kSendStatistic); - PrintRTCCPStatistics(ptrViERtpRtcp, videoChannel, + PrintRTCCPStatistics(vie_rtp_rtcp, video_channel, kReceivedStatistic); - PrintRTPStatistics(ptrViERtpRtcp, videoChannel); - PrintBandwidthUsage(ptrViERtpRtcp, videoChannel); - PrintCodecStatistics(ptrViECodec, videoChannel, + PrintRTPStatistics(vie_rtp_rtcp, video_channel); + PrintBandwidthUsage(vie_rtp_rtcp, video_channel); + PrintCodecStatistics(vie_codec, video_channel, kSendStatistic); - PrintCodecStatistics(ptrViECodec, videoChannel, + PrintCodecStatistics(vie_codec, video_channel, kReceivedStatistic); - PrintGetDiscardedPackets(ptrViECodec, videoChannel); + PrintGetDiscardedPackets(vie_codec, video_channel); modify_call = true; break; case 13: - isImageScaleEnabled = !isImageScaleEnabled; - ptrViECodec->SetImageScaleStatus(videoChannel, isImageScaleEnabled); - if (isImageScaleEnabled) { + is_image_scale_enabled = !is_image_scale_enabled; + vie_codec->SetImageScaleStatus(video_channel, is_image_scale_enabled); + if (is_image_scale_enabled) { std::cout << "Image Scale is now enabled" << std::endl; } else { std::cout << "Image Scale is now disabled" << std::endl; @@ -883,361 +881,361 @@ 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; } - // modify_call is false if user does not select one of the - // modify options + // Modify_call is false if user does not select one of the modify options. if (modify_call == false) { selection = 0; } } + // Stop the Call std::cout << "Press enter to stop..."; std::getline(std::cin, str); - //*************************************************************** - // Testing finished. Tear down Voice and Video Engine. - //*************************************************************** - // Tear down the VE first. - error = ptrVEBase->StopReceive(audioChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrVEBase->StopPlayout(audioChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Testing finished. Tear down Voice and Video Engine. + // Tear down the VoE first. + error = voe_base->StopReceive(audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrVEBase->DeleteChannel(audioChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = voe_base->StopPlayout(audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + + error = voe_base->DeleteChannel(audio_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); // Now tear down the ViE engine. - error = ptrViEBase->DisconnectAudioChannel(videoChannel); + error = vie_base->DisconnectAudioChannel(video_channel); // If Encoder/Decoder Observer is running, delete them. - if (codecEncoderObserver) { - error = ptrViECodec->DeregisterEncoderObserver(videoChannel); - delete codecEncoderObserver; - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - if (codecDecoderObserver) { - error = ptrViECodec->DeregisterDecoderObserver(videoChannel); - delete codecDecoderObserver; - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - - error = ptrViEBase->StopReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->StopSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->StopRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, + if (codec_encoder_observer) { + error = vie_codec->DeregisterEncoderObserver(video_channel); + delete codec_encoder_observer; + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); + } + if (codec_decoder_observer) { + error = vie_codec->DeregisterDecoderObserver(video_channel); + delete codec_decoder_observer; + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + } - error = ptrViERender->StopRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->StopReceive(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERender->RemoveRenderer(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->StopSend(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViERender->RemoveRenderer(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->StopRender(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->StopRender(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->RemoveRenderer(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViECapture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_renderer->RemoveRenderer(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - error = ptrViEBase->DeleteChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_capture->StopCapture(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - int remainingInterfaces = 0; - remainingInterfaces = ptrViEFile->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - remainingInterfaces = ptrViECodec->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_capture->DisconnectCaptureDevice(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - remainingInterfaces = ptrViECapture->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_capture->ReleaseCaptureDevice(capture_id); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - remainingInterfaces = ptrViERtpRtcp->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_base->DeleteChannel(video_channel); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - remainingInterfaces = ptrViERender->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + int remaining_interfaces = 0; + remaining_interfaces = vie_file->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + remaining_interfaces = vie_codec->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - remainingInterfaces = ptrViENetwork->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + remaining_interfaces = vie_capture->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - remainingInterfaces = ptrViEBase->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + remaining_interfaces = vie_rtp_rtcp->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - bool deleted = webrtc::VideoEngine::Delete(ptrViE); - numberOfErrors += ViETest::TestError(deleted == true, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + remaining_interfaces = vie_renderer->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + + remaining_interfaces = vie_network->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + + remaining_interfaces = vie_base->Release(); + number_of_errors += ViETest::TestError(remaining_interfaces == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + + bool deleted = webrtc::VideoEngine::Delete(vie); + number_of_errors += ViETest::TestError(deleted == true, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); ViETest::Log(" "); ViETest::Log(" ViE Autotest Custom Call Started"); ViETest::Log("========================================"); ViETest::Log(" "); } - return numberOfErrors; + return number_of_errors; } -bool GetVideoDevice(webrtc::ViEBase* ptrViEBase, - webrtc::ViECapture* ptrViECapture, - char* captureDeviceName, - char* captureDeviceUniqueId) { +bool GetVideoDevice(webrtc::ViEBase* vie_base, + webrtc::ViECapture* vie_capture, + char* capture_device_name, + char* capture_device_unique_id) { int error = 0; - int numberOfErrors = 0; - int captureDeviceIndex = 0; + int number_of_errors = 0; + int capture_device_index = 0; std::string str; const unsigned int KMaxDeviceNameLength = 128; const unsigned int KMaxUniqueIdLength = 256; - char deviceName[KMaxDeviceNameLength]; - char uniqueId[KMaxUniqueIdLength]; + char device_name[KMaxDeviceNameLength]; + char unique_id[KMaxUniqueIdLength]; while (1) { - memset(deviceName, 0, KMaxDeviceNameLength); - memset(uniqueId, 0, KMaxUniqueIdLength); + memset(device_name, 0, KMaxDeviceNameLength); + memset(unique_id, 0, KMaxUniqueIdLength); std::cout << std::endl; std::cout << "Available video capture devices:" << std::endl; - int captureIdx = 0; - for (captureIdx = 0; - captureIdx < ptrViECapture->NumberOfCaptureDevices(); - captureIdx++) { - memset(deviceName, 0, KMaxDeviceNameLength); - memset(uniqueId, 0, KMaxUniqueIdLength); + int capture_idx = 0; + for (capture_idx = 0; + capture_idx < vie_capture->NumberOfCaptureDevices(); + capture_idx++) { + memset(device_name, 0, KMaxDeviceNameLength); + memset(unique_id, 0, KMaxUniqueIdLength); - error = ptrViECapture->GetCaptureDevice(captureIdx, deviceName, - KMaxDeviceNameLength, - uniqueId, - KMaxUniqueIdLength); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << " " << captureIdx+1 << ". " << deviceName - << "/" << uniqueId + error = vie_capture->GetCaptureDevice(capture_idx, device_name, + KMaxDeviceNameLength, + unique_id, + KMaxUniqueIdLength); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + std::cout << " " << capture_idx + 1 << ". " << device_name + << "/" << unique_id << std::endl; } - // Get the devName of the default (or first) camera for display. - error = ptrViECapture->GetCaptureDevice(0, deviceName, - KMaxDeviceNameLength, - uniqueId, - KMaxUniqueIdLength); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - std::cout << "Choose a video capture device. Press enter for default (" - << deviceName << "/" << uniqueId << "): "; - std::getline(std::cin, str); - captureDeviceIndex = atoi(str.c_str()); - - if (captureDeviceIndex == 0) { - // Use the default (or first) camera. - error = ptrViECapture->GetCaptureDevice(0, deviceName, - KMaxDeviceNameLength, - uniqueId, - KMaxUniqueIdLength); - numberOfErrors += ViETest::TestError(error == 0, + // Get the dev_name of the default (or first) camera for display. + error = vie_capture->GetCaptureDevice(0, device_name, + KMaxDeviceNameLength, + unique_id, + KMaxUniqueIdLength); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - strcpy(captureDeviceUniqueId, uniqueId); - strcpy(captureDeviceName, deviceName); + + std::cout << "Choose a video capture device. Press enter for default (" + << device_name << "/" << unique_id << "): "; + std::getline(std::cin, str); + capture_device_index = atoi(str.c_str()); + + if (capture_device_index == 0) { + // Use the default (or first) camera. + error = vie_capture->GetCaptureDevice(0, device_name, + KMaxDeviceNameLength, + unique_id, + KMaxUniqueIdLength); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + strcpy(capture_device_unique_id, unique_id); + strcpy(capture_device_name, device_name); return true; - } else if (captureDeviceIndex < 0 - || (captureDeviceIndex > - (int)ptrViECapture->NumberOfCaptureDevices())) { + } else if ( + capture_device_index < 0 || + (capture_device_index > + static_cast(vie_capture->NumberOfCaptureDevices()))) { // invalid selection continue; } else { - error = ptrViECapture->GetCaptureDevice(captureDeviceIndex - 1, - deviceName, - KMaxDeviceNameLength, - uniqueId, - KMaxUniqueIdLength); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - strcpy(captureDeviceUniqueId, uniqueId); - strcpy(captureDeviceName, deviceName); + error = vie_capture->GetCaptureDevice(capture_device_index - 1, + device_name, + KMaxDeviceNameLength, + unique_id, + KMaxUniqueIdLength); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + strcpy(capture_device_unique_id, unique_id); + strcpy(capture_device_name, device_name); return true; } } } -bool GetAudioDevices(webrtc::VoEBase* ptrVEBase, - webrtc::VoEHardware* ptrVEHardware, - char* recordingDeviceName, - int& recordingDeviceIndex, +bool GetAudioDevices(webrtc::VoEBase* voe_base, + webrtc::VoEHardware* voe_hardware, + char* recording_device_name, + int& recording_device_index, char* playbackDeviceName, - int& playbackDeviceIndex) { + int& playback_device_index) { int error = 0; - int numberOfErrors = 0; + int number_of_errors = 0; std::string str; const unsigned int KMaxDeviceNameLength = 128; const unsigned int KMaxUniqueIdLength = 128; - char recordingDeviceUniqueName[KMaxDeviceNameLength]; + char recording_device_unique_name[KMaxDeviceNameLength]; char playbackDeviceUniqueName[KMaxUniqueIdLength]; - int numberOfRecordingDevices = -1; - error = ptrVEHardware->GetNumOfRecordingDevices(numberOfRecordingDevices); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + int number_of_recording_devices = -1; + error = voe_hardware->GetNumOfRecordingDevices(number_of_recording_devices); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); while (1) { - recordingDeviceIndex = -1; + recording_device_index = -1; std::cout << std::endl; std::cout << "Available audio capture devices:" << std::endl; - int captureIdx = 0; + int capture_idx = 0; - for (captureIdx = 0; captureIdx < numberOfRecordingDevices; - captureIdx++) { - memset(recordingDeviceName, 0, KMaxDeviceNameLength); - memset(recordingDeviceUniqueName, 0, KMaxDeviceNameLength); - error = ptrVEHardware->GetRecordingDeviceName( - captureIdx, recordingDeviceName, recordingDeviceUniqueName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << " " << captureIdx+1 << ". " << recordingDeviceName + for (capture_idx = 0; capture_idx < number_of_recording_devices; + capture_idx++) { + memset(recording_device_name, 0, KMaxDeviceNameLength); + memset(recording_device_unique_name, 0, KMaxDeviceNameLength); + error = voe_hardware->GetRecordingDeviceName( + capture_idx, recording_device_name, recording_device_unique_name); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + std::cout << " " << capture_idx + 1 << ". " << recording_device_name << std::endl; } std::cout << "Choose an audio capture device. Press enter for default(" - << recordingDeviceName << "): "; + << recording_device_name << "): "; std::getline(std::cin, str); - int captureDeviceIndex = atoi(str.c_str()); + int capture_device_index = atoi(str.c_str()); - if (captureDeviceIndex == 0) { + if (capture_device_index == 0) { // Use the default (or first) recording device. - recordingDeviceIndex = 0; - error = ptrVEHardware->GetRecordingDeviceName( - recordingDeviceIndex, recordingDeviceName, - recordingDeviceUniqueName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + recording_device_index = 0; + error = voe_hardware->GetRecordingDeviceName( + recording_device_index, recording_device_name, + recording_device_unique_name); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; - } else if (captureDeviceIndex < 0 - || captureDeviceIndex > numberOfRecordingDevices) { - // invalid selection + } else if (capture_device_index < 0 || + capture_device_index > number_of_recording_devices) { + // Invalid selection. continue; } else { - recordingDeviceIndex = captureDeviceIndex - 1; - error = ptrVEHardware->GetRecordingDeviceName( - recordingDeviceIndex, recordingDeviceName, - recordingDeviceUniqueName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + recording_device_index = capture_device_index - 1; + error = voe_hardware->GetRecordingDeviceName( + recording_device_index, recording_device_name, + recording_device_unique_name); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; } } - int numberOfPlaybackDevices = -1; - error = ptrVEHardware->GetNumOfPlayoutDevices(numberOfPlaybackDevices); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + int number_of_playbackDevices = -1; + error = voe_hardware->GetNumOfPlayoutDevices(number_of_playbackDevices); + number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + __FUNCTION__, __LINE__); while (1) { - playbackDeviceIndex = -1; + playback_device_index = -1; std::cout << std::endl; std::cout << "Available audio playout devices:" << std::endl; - int captureIdx = 0; + int capture_idx = 0; - for (captureIdx = 0; captureIdx < numberOfPlaybackDevices; - captureIdx++) { + for (capture_idx = 0; capture_idx < number_of_playbackDevices; + capture_idx++) { memset(playbackDeviceName, 0, KMaxDeviceNameLength); memset(playbackDeviceUniqueName, 0, KMaxDeviceNameLength); - error = ptrVEHardware->GetPlayoutDeviceName( - captureIdx, playbackDeviceName, playbackDeviceUniqueName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << " " << captureIdx+1 << ". " << playbackDeviceName + error = voe_hardware->GetPlayoutDeviceName(capture_idx, + playbackDeviceName, + playbackDeviceUniqueName); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + std::cout << " " << capture_idx + 1 << ". " << playbackDeviceName << std::endl; } - std::cout << - "Choose an audio playback device. Press enter for default (" - << playbackDeviceName << "): "; + std::cout << "Choose an audio playback device. Press enter for default (" + << playbackDeviceName << "): "; std::getline(std::cin, str); - int captureDeviceIndex = atoi(str.c_str()); + int capture_device_index = atoi(str.c_str()); - if (captureDeviceIndex == 0) { + if (capture_device_index == 0) { // Use the default (or first) playout device. - playbackDeviceIndex = 0; - error = ptrVEHardware->GetPlayoutDeviceName( - playbackDeviceIndex, playbackDeviceName, - playbackDeviceUniqueName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + playback_device_index = 0; + error = voe_hardware->GetPlayoutDeviceName( + playback_device_index, playbackDeviceName, + playbackDeviceUniqueName); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); return true; - } else if (captureDeviceIndex < 0 - || captureDeviceIndex > numberOfPlaybackDevices) { - // invalid selection + } else if (capture_device_index < 0 + || capture_device_index > number_of_playbackDevices) { + // Invalid selection. continue; } else { - playbackDeviceIndex = captureDeviceIndex - 1; - error = ptrVEHardware->GetPlayoutDeviceName( - playbackDeviceIndex, playbackDeviceName, - playbackDeviceUniqueName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + playback_device_index = capture_device_index - 1; + error = voe_hardware->GetPlayoutDeviceName(playback_device_index, + playbackDeviceName, + playbackDeviceUniqueName); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); return true; } } @@ -1245,87 +1243,87 @@ bool GetAudioDevices(webrtc::VoEBase* ptrVEBase, // General helper functions. -bool GetIPAddress(char* iIP) { - char oIP[16] = DEFAULT_SEND_IP; +bool GetIPAddress(char* i_ip) { + char o_ip[16] = DEFAULT_SEND_IP; std::string str; while (1) { std::cout << std::endl; std::cout << "Enter destination IP. Press enter for default (" - << oIP << "): "; + << o_ip << "): "; std::getline(std::cin, str); if (str.compare("") == 0) { // use default value; - strcpy(iIP, oIP); + strcpy(i_ip, o_ip); return true; } if (ValidateIP(str) == false) { std::cout << "Invalid entry. Try again." << std::endl; continue; } - // done. Copy std::string to c_string and return - strcpy(iIP, str.c_str()); + // Done, copy std::string to c_string and return. + strcpy(i_ip, str.c_str()); return true; } assert(false); return false; } -bool ValidateIP(std::string iStr) { - if (0 == iStr.compare("")) { - return false; +bool ValidateIP(std::string i_str) { + if (0 == i_str.compare("")) { + return false; } return true; } // Video settings functions. -bool SetVideoPorts(int* txPort, int* rxPort) { +bool SetVideoPorts(int* tx_port, int* rx_port) { std::string str; int port = 0; - // set to default values - *txPort = DEFAULT_VIDEO_PORT; - *rxPort = DEFAULT_VIDEO_PORT; + // Set to default values. + *tx_port = DEFAULT_VIDEO_PORT; + *rx_port = DEFAULT_VIDEO_PORT; while (1) { std::cout << "Enter video send port. Press enter for default (" - << *txPort << "): "; + << *tx_port << "): "; std::getline(std::cin, str); port = atoi(str.c_str()); if (port == 0) { - // default value + // Default value. break; } else { - // user selection + // User selection. if (port <= 0 || port > 63556) { - // invalid selection + // Invalid selection. continue; } else { - *txPort = port; - break; // move on to rxport + *tx_port = port; + break; // Move on to rx_port. } } } while (1) { std::cout << "Enter video receive port. Press enter for default (" - << *rxPort << "): "; + << *rx_port << "): "; std::getline(std::cin, str); port = atoi(str.c_str()); if (port == 0) { - // default value + // Default value return true; } else { - // user selection + // User selection. if (port <= 0 || port > 63556) { - // invalid selection + // Invalid selection. continue; } else { - *rxPort = port; + *rx_port = port; return true; } } @@ -1336,51 +1334,51 @@ bool SetVideoPorts(int* txPort, int* rxPort) { // Audio settings functions. -bool GetAudioPorts(int* txPort, int* rxPort) { +bool GetAudioPorts(int* tx_port, int* rx_port) { int port = 0; std::string str; - // set to default values - *txPort = DEFAULT_AUDIO_PORT; - *rxPort = DEFAULT_AUDIO_PORT; + // set to default values. + *tx_port = DEFAULT_AUDIO_PORT; + *rx_port = DEFAULT_AUDIO_PORT; while (1) { std::cout << "Enter audio send port. Press enter for default (" - << *txPort << "): "; + << *tx_port << "): "; std::getline(std::cin, str); port = atoi(str.c_str()); if (port == 0) { - // default value + // Default value. break; } else { - // user selection - if (port <= 0 || port > 63556) { - // invalid selection - continue; - } else { - *txPort = port; - break; // move on to rxport - } - } + // User selection. + if (port <= 0 || port > 63556) { + // Invalid selection. + continue; + } else { + *tx_port = port; + break; // Move on to rx_port. + } + } } while (1) { std::cout << "Enter audio receive port. Press enter for default (" - << *rxPort << "): "; + << *rx_port << "): "; std::getline(std::cin, str); port = atoi(str.c_str()); if (port == 0) { - // default value + // Default value. return true; } else { - // user selection + // User selection. if (port <= 0 || port > 63556) { - // invalid selection + // Invalid selection. continue; } else { - *rxPort = port; + *rx_port = port; return true; } } @@ -1389,52 +1387,52 @@ bool GetAudioPorts(int* txPort, int* rxPort) { return false; } -bool GetAudioCodec(webrtc::VoECodec* ptrVeCodec, - webrtc::CodecInst& audioCodec) { +bool GetAudioCodec(webrtc::VoECodec* voe_codec, + webrtc::CodecInst& audio_codec) { int error = 0; - int numberOfErrors = 0; - int codecSelection = 0; + int number_of_errors = 0; + int codec_selection = 0; std::string str; - memset(&audioCodec, 0, sizeof(webrtc::CodecInst)); + memset(&audio_codec, 0, sizeof(webrtc::CodecInst)); while (1) { std::cout << std::endl; std::cout << "Available audio codecs:" << std::endl; - int codecIdx = 0; - int defaultCodecIdx = 0; - for (codecIdx = 0; codecIdx < ptrVeCodec->NumOfCodecs(); codecIdx++) { - error = ptrVeCodec->GetCodec(codecIdx, audioCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + int codec_idx = 0; + int default_codec_idx = 0; + for (codec_idx = 0; codec_idx < voe_codec->NumOfCodecs(); codec_idx++) { + error = voe_codec->GetCodec(codec_idx, audio_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); - // test for default codec index - if (strcmp(audioCodec.plname, DEFAULT_AUDIO_CODEC) == 0) { - defaultCodecIdx = codecIdx; + // Test for default codec index. + if (strcmp(audio_codec.plname, DEFAULT_AUDIO_CODEC) == 0) { + default_codec_idx = codec_idx; } - std::cout << " " << codecIdx+1 << ". " << audioCodec.plname + std::cout << " " << codec_idx + 1 << ". " << audio_codec.plname << std::endl; } std::cout << std::endl; std::cout << "Choose audio codec. Press enter for default (" << DEFAULT_AUDIO_CODEC << "): "; std::getline(std::cin, str); - codecSelection = atoi(str.c_str()); + codec_selection = atoi(str.c_str()); - if (codecSelection == 0) { - // use default - error = ptrVeCodec->GetCodec(defaultCodecIdx, audioCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + if (codec_selection == 0) { + // Use default. + error = voe_codec->GetCodec(default_codec_idx, audio_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); return true; } else { - // user selection - codecSelection = atoi(str.c_str())-1; - error = ptrVeCodec->GetCodec(codecSelection, audioCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // User selection. + codec_selection = atoi(str.c_str()) - 1; + error = voe_codec->GetCodec(codec_selection, audio_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); if (error != 0) { std::cout << "ERROR: Code = " << error << " Invalid selection" << std::endl; @@ -1447,110 +1445,111 @@ bool GetAudioCodec(webrtc::VoECodec* ptrVeCodec, return false; } -void PrintCallInformation(char* IP, char* videoCaptureDeviceName, - char* videoCaptureUniqueId, - webrtc::VideoCodec videoCodec, - int videoTxPort, int videoRxPort, - char* audioCaptureDeviceName, - char* audioPlaybackDeviceName, - webrtc::CodecInst audioCodec, - int audioTxPort, int audioRxPort, - int protectionMethod) { +void PrintCallInformation(char* IP, char* video_capture_device_name, + char* video_capture_unique_id, + webrtc::VideoCodec video_codec, + int video_tx_port, int video_rx_port, + char* audio_capture_device_name, + char* audio_playbackDeviceName, + webrtc::CodecInst audio_codec, + int audio_tx_port, int audio_rx_port, + int protection_method) { std::string str; std::cout << "************************************************" << std::endl; std::cout << "The call has the following settings: " << std::endl; std::cout << "\tIP: " << IP << std::endl; - std::cout << "\tVideo Capture Device: " << videoCaptureDeviceName + std::cout << "\tVideo Capture Device: " << video_capture_device_name << std::endl; - std::cout << "\t\tName: " << videoCaptureDeviceName << std::endl; - std::cout << "\t\tUniqueId: " << videoCaptureUniqueId << std::endl; - PrintVideoCodec(videoCodec); - std::cout << "\t Video Tx Port: " << videoTxPort << std::endl; - std::cout << "\t Video Rx Port: " << videoRxPort << std::endl; - std::cout << "\t Video Protection Method: " << protectionMethod + std::cout << "\t\tName: " << video_capture_device_name << std::endl; + std::cout << "\t\tUniqueId: " << video_capture_unique_id << std::endl; + PrintVideoCodec(video_codec); + std::cout << "\t Video Tx Port: " << video_tx_port << std::endl; + std::cout << "\t Video Rx Port: " << video_rx_port << std::endl; + std::cout << "\t Video Protection Method: " << protection_method << std::endl; - std::cout << "\tAudio Capture Device: " << audioCaptureDeviceName + std::cout << "\tAudio Capture Device: " << audio_capture_device_name << std::endl; - std::cout << "\tAudio Playback Device: " << audioPlaybackDeviceName + std::cout << "\tAudio Playback Device: " << audio_playbackDeviceName << std::endl; std::cout << "\tAudio Codec: " << std::endl; - std::cout << "\t\tplname: " << audioCodec.plname << std::endl; - std::cout << "\t\tpltype: " << (int)audioCodec.pltype << std::endl; - std::cout << "\t Audio Tx Port: " << audioTxPort << std::endl; - std::cout << "\t Audio Rx Port: " << audioRxPort << std::endl; + std::cout << "\t\tplname: " << audio_codec.plname << std::endl; + std::cout << "\t\tpltype: " << static_cast(audio_codec.pltype) + << std::endl; + std::cout << "\t Audio Tx Port: " << audio_tx_port << std::endl; + std::cout << "\t Audio Rx Port: " << audio_rx_port << std::endl; std::cout << "************************************************" << std::endl; } -bool SetVideoCodecType(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { +bool SetVideoCodecType(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { int error = 0; - int numberOfErrors = 0; - int codecSelection = 0; + int number_of_errors = 0; + int codec_selection = 0; std::string str; - memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); + memset(video_codec, 0, sizeof(webrtc::VideoCodec)); - bool exitLoop=false; - while (!exitLoop) { + bool exit_loop = false; + while (!exit_loop) { std::cout << std::endl; std::cout << "Available video codecs:" << std::endl; - int codecIdx = 0; - int defaultCodecIdx = 0; + int codec_idx = 0; + int default_codec_idx = 0; // Print out all the codecs available to set Codec to. - for (codecIdx = 0; codecIdx < ptrViECodec->NumberOfCodecs(); codecIdx++) { - error = ptrViECodec->GetCodec(codecIdx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // test for default codec index - if (strcmp(videoCodec.plName, DEFAULT_VIDEO_CODEC) == 0) { - defaultCodecIdx = codecIdx; + for (codec_idx = 0; codec_idx < vie_codec->NumberOfCodecs(); codec_idx++) { + error = vie_codec->GetCodec(codec_idx, *video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + // Test for default codec index. + if (strcmp(video_codec->plName, DEFAULT_VIDEO_CODEC) == 0) { + default_codec_idx = codec_idx; } - std::cout << " " << codecIdx+1 << ". " << videoCodec.plName + std::cout << " " << codec_idx + 1 << ". " << video_codec->plName << std::endl; } std::cout << std::endl; std::cout << "Choose video codec. Press enter for default (" << DEFAULT_VIDEO_CODEC << "): "; std::getline(std::cin, str); - codecSelection = atoi(str.c_str()); - if (codecSelection == 0) { - // use default - error = ptrViECodec->GetCodec(defaultCodecIdx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - exitLoop=true; + codec_selection = atoi(str.c_str()); + if (codec_selection == 0) { + // Use default. + error = vie_codec->GetCodec(default_codec_idx, *video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + exit_loop = true; } else { - // user selection - codecSelection = atoi(str.c_str())-1; - error = ptrViECodec->GetCodec(codecSelection, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // User selection. + codec_selection = atoi(str.c_str()) - 1; + error = vie_codec->GetCodec(codec_selection, *video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); if (error != 0) { std::cout << "ERROR: Code=" << error << " Invalid selection" << std::endl; continue; } - exitLoop=true; + exit_loop = true; } } - if (videoCodec.codecType == webrtc::kVideoCodecI420) { - videoCodec.width = 176; - videoCodec.height = 144; + if (video_codec->codecType == webrtc::kVideoCodecI420) { + video_codec->width = 176; + video_codec->height = 144; } return true; } -bool SetVideoCodecResolution(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { +bool SetVideoCodecResolution(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { std::string str; - int sizeOption = 5; + int size_option = 5; - if (videoCodec.codecType == webrtc::kVideoCodecVP8) { + if (video_codec->codecType == webrtc::kVideoCodecVP8) { std::cout << std::endl; std::cout << "Available Common Resolutions : " << std::endl; std::cout << " 1. SQCIF (128X96) " << std::endl; @@ -1566,48 +1565,48 @@ bool SetVideoCodecResolution(webrtc::ViECodec* ptrViECodec, std::cout << "Enter frame size option: " << std::endl; std::getline(std::cin, str); - sizeOption = atoi(str.c_str()); + size_option = atoi(str.c_str()); - switch (sizeOption) { + switch (size_option) { case 1: - videoCodec.width = 128; - videoCodec.height = 96; + video_codec->width = 128; + video_codec->height = 96; break; case 2: - videoCodec.width = 160; - videoCodec.height = 120; + video_codec->width = 160; + video_codec->height = 120; break; case 3: - videoCodec.width = 176; - videoCodec.height = 144; + video_codec->width = 176; + video_codec->height = 144; break; case 4: - videoCodec.width = 352; - videoCodec.height = 288; + video_codec->width = 352; + video_codec->height = 288; break; case 5: - videoCodec.width = 640; - videoCodec.height = 480; + video_codec->width = 640; + video_codec->height = 480; break; case 6: - videoCodec.width = 800; - videoCodec.height = 480; + video_codec->width = 800; + video_codec->height = 480; break; case 7: - videoCodec.width = 704; - videoCodec.height = 576; + video_codec->width = 704; + video_codec->height = 576; break; case 8: - videoCodec.width = 800; - videoCodec.height = 600; + video_codec->width = 800; + video_codec->height = 600; break; case 9: - videoCodec.width = 1280; - videoCodec.height = 720; + video_codec->width = 1280; + video_codec->height = 720; break; case 10: - videoCodec.width = 1024; - videoCodec.height = 768; + video_codec->width = 1024; + video_codec->height = 768; break; } } else { @@ -1616,25 +1615,25 @@ bool SetVideoCodecResolution(webrtc::ViECodec* ptrViECodec, return true; } -bool SetVideoCodecSize(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { - if (videoCodec.codecType == webrtc::kVideoCodecVP8) { +bool SetVideoCodecSize(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { + if (video_codec->codecType == webrtc::kVideoCodecVP8) { std::string str; - videoCodec.width = DEFAULT_VIDEO_CODEC_WIDTH; - videoCodec.height = DEFAULT_VIDEO_CODEC_HEIGHT; + video_codec->width = DEFAULT_VIDEO_CODEC_WIDTH; + video_codec->height = DEFAULT_VIDEO_CODEC_HEIGHT; std::cout << "Choose video width. Press enter for default (" << DEFAULT_VIDEO_CODEC_WIDTH << "): "; std::getline(std::cin, str); - int sizeSelection = atoi(str.c_str()); - if (sizeSelection!=0) { - videoCodec.width=sizeSelection; + int size_selection = atoi(str.c_str()); + if (size_selection != 0) { + video_codec->width = size_selection; } std::cout << "Choose video height. Press enter for default (" << DEFAULT_VIDEO_CODEC_HEIGHT << "): "; std::getline(std::cin, str); - sizeSelection = atoi(str.c_str()); - if (sizeSelection!=0) { - videoCodec.height=sizeSelection; + size_selection = atoi(str.c_str()); + if (size_selection != 0) { + video_codec->height = size_selection; } } else { std::cout << "Can Only change codec size if it's VP8" << std::endl; @@ -1642,84 +1641,85 @@ bool SetVideoCodecSize(webrtc::ViECodec* ptrViECodec, return true; } -bool SetVideoCodecBitrate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { +bool SetVideoCodecBitrate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { std::string str; std::cout << std::endl; std::cout << "Choose start rate (in kbps). Press enter for default (" << DEFAULT_VIDEO_CODEC_BITRATE << "): "; std::getline(std::cin, str); - int startRate = atoi(str.c_str()); - videoCodec.startBitrate = DEFAULT_VIDEO_CODEC_BITRATE; - if (startRate != 0) { - videoCodec.startBitrate = startRate; + int start_rate = atoi(str.c_str()); + video_codec->startBitrate = DEFAULT_VIDEO_CODEC_BITRATE; + if (start_rate != 0) { + video_codec->startBitrate = start_rate; } return true; } -bool SetVideoCodecMaxBitrate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { +bool SetVideoCodecMaxBitrate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { std::string str; std::cout << std::endl; std::cout << "Choose max bitrate (in kbps). Press enter for default (" << DEFAULT_VIDEO_CODEC_MAX_BITRATE << "): "; std::getline(std::cin, str); - int maxRate = atoi(str.c_str()); - videoCodec.maxBitrate = DEFAULT_VIDEO_CODEC_MAX_BITRATE; - if (maxRate != 0) { - videoCodec.maxBitrate = maxRate; + int max_rate = atoi(str.c_str()); + video_codec->maxBitrate = DEFAULT_VIDEO_CODEC_MAX_BITRATE; + if (max_rate != 0) { + video_codec->maxBitrate = max_rate; } return true; } -bool SetVideoCodecMinBitrate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { +bool SetVideoCodecMinBitrate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { std::string str; std::cout << std::endl; std::cout << "Choose min bitrate (in fps). Press enter for default (" << DEFAULT_VIDEO_CODEC_MIN_BITRATE << "): "; std::getline(std::cin, str); - char minBitRate = atoi(str.c_str()); - videoCodec.minBitrate = DEFAULT_VIDEO_CODEC_MIN_BITRATE; - if (minBitRate != 0) { - videoCodec.minBitrate = minBitRate; + char min_bit_rate = atoi(str.c_str()); + video_codec->minBitrate = DEFAULT_VIDEO_CODEC_MIN_BITRATE; + if (min_bit_rate != 0) { + video_codec->minBitrate = min_bit_rate; } return true; } -bool SetVideoCodecMaxFramerate(webrtc::ViECodec* ptrViECodec, - webrtc::VideoCodec& videoCodec) { +bool SetVideoCodecMaxFramerate(webrtc::ViECodec* vie_codec, + webrtc::VideoCodec* video_codec) { std::string str; std::cout << std::endl; std::cout << "Choose max framerate (in fps). Press enter for default (" << DEFAULT_VIDEO_CODEC_MAX_FRAMERATE << "): "; std::getline(std::cin, str); - char maxFrameRate = atoi(str.c_str()); - videoCodec.maxFramerate = DEFAULT_VIDEO_CODEC_MAX_FRAMERATE; - if (maxFrameRate != 0) { - videoCodec.maxFramerate = maxFrameRate; + char max_frame_rate = atoi(str.c_str()); + video_codec->maxFramerate = DEFAULT_VIDEO_CODEC_MAX_FRAMERATE; + if (max_frame_rate != 0) { + video_codec->maxFramerate = max_frame_rate; } return true; } -bool SetVideoCodecTemporalLayer(webrtc::VideoCodec& videoCodec) { - if (videoCodec.codecType == webrtc::kVideoCodecVP8) { +bool SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) { + if (video_codec->codecType == webrtc::kVideoCodecVP8) { std::string str; std::cout << std::endl; std::cout << "Choose number of temporal layers (1 to 4). " - << "Press enter for default (" + << "Press enter for default (" << DEFAULT_TEMPORAL_LAYER << "): "; std::getline(std::cin, str); - char numTemporalLayers = atoi(str.c_str()); - videoCodec.codecSpecific.VP8.numberOfTemporalLayers - = DEFAULT_TEMPORAL_LAYER; - if(numTemporalLayers != 0) { - videoCodec.codecSpecific.VP8.numberOfTemporalLayers - = numTemporalLayers; + char num_temporal_layers = atoi(str.c_str()); + video_codec->codecSpecific.VP8.numberOfTemporalLayers = + DEFAULT_TEMPORAL_LAYER; + if (num_temporal_layers != 0) { + video_codec->codecSpecific.VP8.numberOfTemporalLayers = + num_temporal_layers; } } return true; } + // GetVideoProtection only prints the prompt to get a number // that SetVideoProtection method uses // 0 = None @@ -1728,7 +1728,7 @@ bool SetVideoCodecTemporalLayer(webrtc::VideoCodec& videoCodec) { // 3 = NACK + FEC (aka Hybrid) // Default = DEFAULT_VIDEO_PROTECTION METHOD int GetVideoProtection() { - int protectionMethod = DEFAULT_VIDEO_PROTECTION_METHOD; + int protection_method = DEFAULT_VIDEO_PROTECTION_METHOD; std::cout << "Available Video Protection Method." << std::endl; std::cout << " 0. None" << std::endl; @@ -1736,110 +1736,108 @@ int GetVideoProtection() { std::cout << " 2. NACK" << std::endl; std::cout << " 3. NACK+FEC" << std::endl; std::cout << "Enter Video Protection Method. " - << "Press enter for default (" << protectionMethod << "):" + << "Press enter for default (" << protection_method << "):" << std::endl; std::string method; std::getline(std::cin, method); - protectionMethod = atoi(method.c_str()); + protection_method = atoi(method.c_str()); - return protectionMethod; + return protection_method; } -bool SetVideoProtection(webrtc::ViECodec* ptrViECodec, - webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel, int protectionMethod) { +bool SetVideoProtection(webrtc::ViECodec* vie_codec, + webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel, int protection_method) { int error = 0; - int numberOfErrors = 0; - webrtc::VideoCodec videoCodec; + int number_of_errors = 0; + webrtc::VideoCodec video_codec; - memset((void*)&videoCodec, 0, sizeof(webrtc::VideoCodec)); + memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); // Set all video protection to false initially - error = ptrViERtpRtcp->SetHybridNACKFECStatus(videoChannel, false, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViERtpRtcp->SetFECStatus(videoChannel, false, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViERtpRtcp->SetNACKStatus(videoChannel, false); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Set video protection for FEC, NACK or Hybrid - switch (protectionMethod) { - case 0: // None - // No protection selected, all protection already at false + error = vie_rtp_rtcp->SetHybridNACKFECStatus(video_channel, false, + VCM_RED_PAYLOAD_TYPE, + VCM_ULPFEC_PAYLOAD_TYPE); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetFECStatus(video_channel, false, + VCM_RED_PAYLOAD_TYPE, + VCM_ULPFEC_PAYLOAD_TYPE); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetNACKStatus(video_channel, false); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + // Set video protection for FEC, NACK or Hybrid. + switch (protection_method) { + case 0: // None. + // No protection selected, all protection already at false. std::cout << "Call using None protection Method" << std::endl; break; - case 1: // FEC only + case 1: // FEC only. std::cout << "Call using FEC protection Method" << std::endl; - error = ptrViERtpRtcp->SetFECStatus(videoChannel, true, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetFECStatus(video_channel, true, + VCM_RED_PAYLOAD_TYPE, + VCM_ULPFEC_PAYLOAD_TYPE); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; - case 2: // NACK only + case 2: // NACK only. std::cout << "Call using NACK protection Method" << std::endl; - error = ptrViERtpRtcp->SetNACKStatus(videoChannel, true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetNACKStatus(video_channel, true); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; - case 3: // Hybrid NACK and FEC + case 3: // Hybrid NACK and FEC. std::cout << "Call using Hybrid NACK and FEC protection Method" << std::endl; - error = ptrViERtpRtcp->SetHybridNACKFECStatus(videoChannel, true, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->SetHybridNACKFECStatus(video_channel, true, + VCM_RED_PAYLOAD_TYPE, + VCM_ULPFEC_PAYLOAD_TYPE); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; } - // Set receive codecs for FEC and hybrid NACK/FEC - if (protectionMethod == 1 || protectionMethod == 3) { - // RED - error = ptrViECodec->GetCodec(ptrViECodec->NumberOfCodecs() - 2, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - videoCodec.plType = VCM_RED_PAYLOAD_TYPE; - error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Set receive codecs for FEC and hybrid NACK/FEC. + if (protection_method == 1 || protection_method == 3) { + // RED. + error = vie_codec->GetCodec(vie_codec->NumberOfCodecs() - 2, + video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + video_codec.plType = VCM_RED_PAYLOAD_TYPE; + error = vie_codec->SetReceiveCodec(video_channel, video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); std::cout << "RED Codec Information:" << std::endl; - PrintVideoCodec(videoCodec); - // ULPFEC - error = ptrViECodec->GetCodec(ptrViECodec->NumberOfCodecs() - 1, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - videoCodec.plType = VCM_ULPFEC_PAYLOAD_TYPE; - error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + PrintVideoCodec(video_codec); + // ULPFEC. + error = vie_codec->GetCodec(vie_codec->NumberOfCodecs() - 1, + video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); + video_codec.plType = VCM_ULPFEC_PAYLOAD_TYPE; + error = vie_codec->SetReceiveCodec(video_channel, video_codec); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); std::cout << "ULPFEC Codec Information:" << std::endl; - PrintVideoCodec(videoCodec); + PrintVideoCodec(video_codec); } - - return true; } @@ -1858,200 +1856,206 @@ bool GetBitrateSignaling() { return true; } -void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel, StatisticsType statType) { +void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel, + StatisticsType stat_type) { int error = 0; - int numberOfErrors =0; - unsigned short fractionLost = 0; - unsigned int cumulativeLost = 0; - unsigned int extendedMax = 0; + int number_of_errors = 0; + uint16_t fraction_lost = 0; + unsigned int cumulative_lost = 0; + unsigned int extended_max = 0; unsigned int jitter = 0; - int rttMS = 0; + int rtt_ms = 0; - switch (statType) { + switch (stat_type) { case kReceivedStatistic: std::cout << "RTCP Received statistics" << std::endl; // Get and print the Received RTCP Statistics - error = ptrViERtpRtcp->GetReceivedRTCPStatistics(videoChannel, - fractionLost, - cumulativeLost, - extendedMax, - jitter, rttMS); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->GetReceivedRTCPStatistics(video_channel, + fraction_lost, + cumulative_lost, + extended_max, + jitter, rtt_ms); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; case kSendStatistic: std::cout << "RTCP Sent statistics" << std::endl; // Get and print the Sent RTCP Statistics - error = ptrViERtpRtcp->GetSentRTCPStatistics(videoChannel, fractionLost, - cumulativeLost, extendedMax, - jitter, rttMS); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->GetSentRTCPStatistics(video_channel, fraction_lost, + cumulative_lost, extended_max, + jitter, rtt_ms); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; } std::cout << "\tRTCP fraction of lost packets: " - << fractionLost << std::endl; + << fraction_lost << std::endl; std::cout << "\tRTCP cumulative number of lost packets: " - << cumulativeLost << std::endl; + << cumulative_lost << std::endl; std::cout << "\tRTCP max received sequence number " - << extendedMax << std::endl; + << extended_max << std::endl; std::cout << "\tRTCP jitter: " << jitter << std::endl; std::cout << "\tRTCP round trip (ms): " - << rttMS<< std::endl; + << rtt_ms << std::endl; } -void PrintRTPStatistics(webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel) { +void PrintRTPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel) { int error = 0; - int numberOfErrors =0; - unsigned int bytesSent = 0; - unsigned int packetsSent= 0; - unsigned int bytesReceived = 0; - unsigned int packetsReceived = 0; + int number_of_errors = 0; + unsigned int bytes_sent = 0; + unsigned int packets_sent = 0; + unsigned int bytes_received = 0; + unsigned int packets_received = 0; std::cout << "RTP statistics" << std::endl; // Get and print the RTP Statistics - error = ptrViERtpRtcp->GetRTPStatistics(videoChannel, bytesSent, packetsSent, - bytesReceived, packetsReceived); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->GetRTPStatistics(video_channel, bytes_sent, + packets_sent, bytes_received, + packets_received); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); std::cout << "\tRTP bytes sent: " - << bytesSent << std::endl; + << bytes_sent << std::endl; std::cout << "\tRTP packets sent: " - << packetsSent << std::endl; + << packets_sent << std::endl; std::cout << "\tRTP bytes received: " - << bytesReceived << std::endl; + << bytes_received << std::endl; std::cout << "\tRTP packets received: " - << packetsReceived << std::endl; + << packets_received << std::endl; } -void PrintBandwidthUsage(webrtc::ViERTP_RTCP* ptrViERtpRtcp, - int videoChannel) { +void PrintBandwidthUsage(webrtc::ViERTP_RTCP* vie_rtp_rtcp, + int video_channel) { int error = 0; - int numberOfErrors = 0; - unsigned int totalBitrateSent = 0; - unsigned int videoBitrateSent = 0; - unsigned int fecBitrateSent = 0; - unsigned int nackBitrateSent = 0; - double percentageFEC = 0; - double percentageNACK = 0; + int number_of_errors = 0; + unsigned int total_bitrate_sent = 0; + unsigned int video_bitrate_sent = 0; + unsigned int fec_bitrate_sent = 0; + unsigned int nack_bitrate_sent = 0; + double percentage_fec = 0; + double percentage_nack = 0; - std::cout << "Bandwidth Usage" - << std::endl; + std::cout << "Bandwidth Usage" << std::endl; // Get and print Bandwidth usage - error = ptrViERtpRtcp->GetBandwidthUsage(videoChannel, totalBitrateSent, - videoBitrateSent, fecBitrateSent, - nackBitrateSent); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_rtp_rtcp->GetBandwidthUsage(video_channel, total_bitrate_sent, + video_bitrate_sent, fec_bitrate_sent, + nack_bitrate_sent); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); std::cout << "\tTotal bitrate sent (Kbit/s): " - << totalBitrateSent << std::endl; + << total_bitrate_sent << std::endl; std::cout << "\tVideo bitrate sent (Kbit/s): " - << videoBitrateSent << std::endl; + << video_bitrate_sent << std::endl; std::cout << "\tFEC bitrate sent (Kbit/s): " - << fecBitrateSent << std::endl; - percentageFEC = ((double)fecBitrateSent/(double)totalBitrateSent) * 100; + << fec_bitrate_sent << std::endl; + percentage_fec = + (static_cast(fec_bitrate_sent) / + static_cast(total_bitrate_sent)) * 100; std::cout << "\tPercentage FEC bitrate sent from total bitrate: " - << percentageFEC << std::endl; + << percentage_fec << std::endl; std::cout << "\tNACK bitrate sent (Kbit/s): " - << nackBitrateSent << std::endl; - percentageNACK = ((double)nackBitrateSent/(double)totalBitrateSent) * 100; + << nack_bitrate_sent << std::endl; + percentage_nack = + (static_cast(nack_bitrate_sent) / + static_cast(total_bitrate_sent)) * 100; std::cout << "\tPercentage NACK bitrate sent from total bitrate: " - << percentageNACK << std::endl; + << percentage_nack << std::endl; } -void PrintCodecStatistics(webrtc::ViECodec* ptrViECodec, int videoChannel, - StatisticsType statType) { +void PrintCodecStatistics(webrtc::ViECodec* vie_codec, + int video_channel, + StatisticsType stat_type) { int error = 0; - int numberOfErrors = 0; - unsigned int keyFrames = 0; - unsigned int deltaFrames = 0; - switch(statType) { + int number_of_errors = 0; + unsigned int key_frames = 0; + unsigned int delta_frames = 0; + switch (stat_type) { case kReceivedStatistic: std::cout << "Codec Receive statistics" << std::endl; // Get and print the Receive Codec Statistics - error = ptrViECodec->GetReceiveCodecStastistics(videoChannel, keyFrames, - deltaFrames); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_codec->GetReceiveCodecStastistics(video_channel, key_frames, + delta_frames); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; case kSendStatistic: std::cout << "Codec Send statistics" << std::endl; // Get and print the Send Codec Statistics - error = ptrViECodec->GetSendCodecStastistics(videoChannel, keyFrames, - deltaFrames); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + error = vie_codec->GetSendCodecStastistics(video_channel, key_frames, + delta_frames); + number_of_errors += ViETest::TestError(error == 0, + "ERROR: %s at line %d", + __FUNCTION__, __LINE__); break; } std::cout << "\tNumber of encoded key frames: " - << keyFrames << std::endl; + << key_frames << std::endl; std::cout << "\tNumber of encoded delta frames: " - << deltaFrames << std::endl; + << delta_frames << std::endl; } -void PrintGetDiscardedPackets(webrtc::ViECodec* ptrViECodec, int videoChannel) { - std::cout << "Discarded Packets" - << std::endl; - int discardedPackets = 0; - discardedPackets = ptrViECodec->GetDiscardedPackets(videoChannel); +void PrintGetDiscardedPackets(webrtc::ViECodec* vie_codec, int video_channel) { + std::cout << "Discarded Packets" << std::endl; + int discarded_packets = 0; + discarded_packets = vie_codec->GetDiscardedPackets(video_channel); std::cout << "\tNumber of discarded packets: " - << discardedPackets << std::endl; + << discarded_packets << std::endl; } -void PrintVideoStreamInformation(webrtc::ViECodec* ptrViECodec, - int videoChannel) { - webrtc::VideoCodec outgoingCodec; - webrtc::VideoCodec incomingCodec; +void PrintVideoStreamInformation(webrtc::ViECodec* vie_codec, + int video_channel) { + webrtc::VideoCodec outgoing_codec; + webrtc::VideoCodec incoming_codec; - memset((void*)&outgoingCodec, 0, sizeof(webrtc::VideoCodec)); - memset((void*)&incomingCodec, 0, sizeof(webrtc::VideoCodec)); + memset(&outgoing_codec, 0, sizeof(webrtc::VideoCodec)); + memset(&incoming_codec, 0, sizeof(webrtc::VideoCodec)); - ptrViECodec->GetSendCodec(videoChannel, outgoingCodec); - ptrViECodec->GetReceiveCodec(videoChannel, incomingCodec); + vie_codec->GetSendCodec(video_channel, outgoing_codec); + vie_codec->GetReceiveCodec(video_channel, incoming_codec); std::cout << "************************************************" << std::endl; - std::cout << "ChannelId: " << videoChannel << std::endl; - std::cout << "Outgoing Stream information:" <(video_codec.plType) << std::endl; - std::cout << "\t\tminBitrate: " << videoCodec.minBitrate + std::cout << "\t\twidth: " << video_codec.width << std::endl; + std::cout << "\t\theight: " << video_codec.height << std::endl; + std::cout << "\t\tstartBitrate: " << video_codec.startBitrate << std::endl; - std::cout << "\t\tmaxBitrate: " << videoCodec.maxBitrate + std::cout << "\t\tminBitrate: " << video_codec.minBitrate << std::endl; - std::cout << "\t\tmaxFramerate: " << (int)videoCodec.maxFramerate + std::cout << "\t\tmaxBitrate: " << video_codec.maxBitrate << std::endl; - if (videoCodec.codecType == webrtc::kVideoCodecVP8) { - std::cout << "\t\tVP8 Temporal Layer: " - << (int)videoCodec.codecSpecific.VP8.numberOfTemporalLayers - << std::endl; + std::cout << "\t\tmaxFramerate: " + << static_cast(video_codec.maxFramerate) << std::endl; + if (video_codec.codecType == webrtc::kVideoCodecVP8) { + int number_of_layers = + static_cast(video_codec.codecSpecific.VP8.numberOfTemporalLayers); + std::cout << "\t\tVP8 Temporal Layer: " << number_of_layers << std::endl; } }