From c4df42be6bb12d73a14128a52e782862fe91baf1 Mon Sep 17 00:00:00 2001 From: "marpan@google.com" Date: Tue, 2 Aug 2011 18:53:33 +0000 Subject: [PATCH] Added option for enabling the video protection settings and testing packet loss/delay in auto_test_loopback. Also allowing for setting frame size and start rate. Review URL: http://webrtc-codereview.appspot.com/91008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@288 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../AutoTest/source/vie_autotest_loopback.cc | 161 ++++++++++++++++-- 1 file changed, 147 insertions(+), 14 deletions(-) diff --git a/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc b/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc index 042c564681..1a0e917684 100644 --- a/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc +++ b/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc @@ -31,6 +31,11 @@ #include "vie_render.h" #include "vie_rtp_rtcp.h" +#include +#include "tb_external_transport.h" +#define VCM_RED_PAYLOAD_TYPE 96 +#define VCM_ULPFEC_PAYLOAD_TYPE 97 + int VideoEngineSampleCode(void* window1, void* window2) { //******************************************************** @@ -317,11 +322,58 @@ int VideoEngineSampleCode(void* window1, void* window2) return -1; } - // try to keep the test frame size small when I420 + // Set spatial resolution option + std::string str; + std::cout << std::endl; + std::cout << "Enter frame size option (default is CIF):" << std::endl; + std::cout << "1. QCIF (176X144) " << std::endl; + std::cout << "2. CIF (352X288) " << std::endl; + std::cout << "3. VGA (640X480) " << std::endl; + std::cout << "4. 4CIF (704X576) " << std::endl; + std::cout << "5. WHD (1280X720) " << std::endl; + std::getline(std::cin, str); + int resolnOption = atoi(str.c_str()); + // Try to keep the test frame size small when I420 if (videoCodec.codecType == webrtc::kVideoCodecI420) { + resolnOption = 1; + } + switch (resolnOption) + { + case 1: videoCodec.width = 176; videoCodec.height = 144; + break; + + case 2: + videoCodec.width = 352; + videoCodec.height = 288; + break; + + case 3: + videoCodec.width = 640; + videoCodec.height = 480; + break; + + case 4: + videoCodec.width = 704; + videoCodec.height = 576; + break; + + case 5: + videoCodec.width = 1280; + videoCodec.height = 720; + break; + } + + // Set start bit rate + std::cout << std::endl; + std::cout << "Choose start rate (in kbps). Press enter for default: "; + std::getline(std::cin, str); + int startRate = atoi(str.c_str()); + if(startRate != 0) + { + videoCodec.startBitrate=startRate; } error = ptrViECodec->SetSendCodec(videoChannel, videoCodec); @@ -331,6 +383,47 @@ int VideoEngineSampleCode(void* window1, void* window2) return -1; } + // + // Choose Protection Mode + // + std::cout << std::endl; + std::cout << "Enter Protection Method:" << std::endl; + std::cout << "0. None" << std::endl; + std::cout << "1. FEC" << std::endl; + std::cout << "2. NACK" << std::endl; + std::cout << "3. NACK+FEC" << std::endl; + std::getline(std::cin, str); + int protectionMethod = atoi(str.c_str()); + error = 0; + switch (protectionMethod) + { + case 0: // None: default is no protection + break; + + case 1: // FEC only + error = ptrViERtpRtcp->SetFECStatus(videoChannel, true, + VCM_RED_PAYLOAD_TYPE, + VCM_ULPFEC_PAYLOAD_TYPE); + break; + + case 2: // Nack only + error = ptrViERtpRtcp->SetNACKStatus(videoChannel, true); + + break; + + case 3: // Hybrid NAck and FEC + error = ptrViERtpRtcp->SetHybridNACKFECStatus(videoChannel, true, + VCM_RED_PAYLOAD_TYPE, + VCM_ULPFEC_PAYLOAD_TYPE); + break; + } + + if (error < 0) + { + printf("ERROR in ViERTP_RTCP::SetProtectionStatus\n"); + } + + // // Address settings // @@ -341,13 +434,60 @@ int VideoEngineSampleCode(void* window1, void* window2) return -1; } - const char* ipAddress = "127.0.0.1"; - const unsigned short rtpPort = 6000; - error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort); - if (error == -1) + // Setting External transport + tbExternalTransport extTransport(*(ptrViENetwork)); + + int testMode = 0; + std::cout << std::endl; + std::cout << "Enter 1 for testing packet loss and delay with " + "external transport: "; + std::string test_str; + std::getline(std::cin, test_str); + testMode = atoi(test_str.c_str()); + if (testMode == 1) { - printf("ERROR in ViENetwork::SetLocalReceiver\n"); - return -1; + error = ptrViENetwork->RegisterSendTransport(videoChannel, + extTransport); + if (error == -1) + { + printf("ERROR in ViECodec::RegisterSendTransport \n"); + return -1; + } + + // Set up packet loss value + std::cout << "Enter Packet Loss Percentage" << std::endl; + std::string rate_str; + std::getline(std::cin, rate_str); + int rate = atoi(rate_str.c_str()); + extTransport.SetPacketLoss(rate); + + // Set network delay value + std::cout << "Enter network delay value [mS]" << std::endl; + std::string delay_str; + std::getline(std::cin, delay_str); + int delayMs = atoi(delay_str.c_str()); + extTransport.SetNetworkDelay(delayMs); + } + else + { + const char* ipAddress = "127.0.0.1"; + const unsigned short rtpPort = 6000; + std::cout << std::endl; + std::cout << "Using rtp port: " << rtpPort << std::endl; + std::cout << std::endl; + error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort); + if (error == -1) + { + printf("ERROR in ViENetwork::SetLocalReceiver\n"); + return -1; + } + error = ptrViENetwork->SetSendDestination(videoChannel, + ipAddress, rtpPort); + if (error == -1) + { + printf("ERROR in ViENetwork::SetSendDestination\n"); + return -1; + } } error = ptrViEBase->StartReceive(videoChannel); @@ -357,13 +497,6 @@ int VideoEngineSampleCode(void* window1, void* window2) return -1; } - error = ptrViENetwork->SetSendDestination(videoChannel, ipAddress, rtpPort); - if (error == -1) - { - printf("ERROR in ViENetwork::SetSendDestination\n"); - return -1; - } - error = ptrViEBase->StartSend(videoChannel); if (error == -1) {