From 693240f2d923ca8334f2896bf45335fb9969bd33 Mon Sep 17 00:00:00 2001 From: "phoglund@webrtc.org" Date: Wed, 7 Dec 2011 12:32:58 +0000 Subject: [PATCH] Fixed many formatting and indentation problems in voe_auto_test. Fixed indentation. There is nothing but whitespace changes here, except for removing some extraneous semicolons in .h files and fixing a spelling error in a comment. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/305004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1122 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/test/auto_test/voe_cpu_test.cc | 92 +- .../main/test/auto_test/voe_cpu_test.h | 17 +- .../main/test/auto_test/voe_extended_test.cc | 13872 ++++++++-------- .../main/test/auto_test/voe_extended_test.h | 514 +- .../main/test/auto_test/voe_standard_test.cc | 6581 ++++---- .../main/test/auto_test/voe_standard_test.h | 487 +- .../main/test/auto_test/voe_stress_test.cc | 626 +- .../main/test/auto_test/voe_stress_test.h | 36 +- .../main/test/auto_test/voe_test_defines.h | 24 +- .../main/test/auto_test/voe_test_interface.h | 94 +- .../main/test/auto_test/voe_unit_test.cc | 1959 ++- .../main/test/auto_test/voe_unit_test.h | 82 +- 12 files changed, 12003 insertions(+), 12381 deletions(-) diff --git a/src/voice_engine/main/test/auto_test/voe_cpu_test.cc b/src/voice_engine/main/test/auto_test/voe_cpu_test.cc index e93783bc12..051bce96a0 100644 --- a/src/voice_engine/main/test/auto_test/voe_cpu_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_cpu_test.cc @@ -13,7 +13,7 @@ #include #include #if defined(_WIN32) - #include +#include #endif #include "voe_cpu_test.h" @@ -37,65 +37,63 @@ extern int GetResource(char* resource, char* dest, int destLen); extern char* GetResource(char* resource); extern const char* GetResource(const char* resource); -VoECpuTest::VoECpuTest(VoETestManager& mgr) : - _mgr(mgr) -{ - +VoECpuTest::VoECpuTest(VoETestManager& mgr) + : _mgr(mgr) { + } -int VoECpuTest::DoTest() -{ - printf("------------------------------------------------\n"); - printf(" CPU Reference Test\n"); - printf("------------------------------------------------\n"); +int VoECpuTest::DoTest() { + printf("------------------------------------------------\n"); + printf(" CPU Reference Test\n"); + printf("------------------------------------------------\n"); - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); - VoECodec* codec = _mgr.CodecPtr(); - VoEAudioProcessing* apm = _mgr.APMPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); + VoECodec* codec = _mgr.CodecPtr(); + VoEAudioProcessing* apm = _mgr.APMPtr(); - int channel(-1); - CodecInst isac; + int channel(-1); + CodecInst isac; - isac.pltype = 104; - strcpy(isac.plname, "ISAC"); - isac.pacsize = 960; - isac.plfreq = 32000; - isac.channels = 1; - isac.rate = -1; + isac.pltype = 104; + strcpy(isac.plname, "ISAC"); + isac.pacsize = 960; + isac.plfreq = 32000; + isac.channels = 1; + isac.rate = -1; - CHECK(base->Init()); - channel = base->CreateChannel(); + CHECK(base->Init()); + channel = base->CreateChannel(); - CHECK(base->SetLocalReceiver(channel, 5566)); - CHECK(base->SetSendDestination(channel, 5566, "127.0.0.1")); - CHECK(codec->SetRecPayloadType(channel, isac)); - CHECK(codec->SetSendCodec(channel, isac)); + CHECK(base->SetLocalReceiver(channel, 5566)); + CHECK(base->SetSendDestination(channel, 5566, "127.0.0.1")); + CHECK(codec->SetRecPayloadType(channel, isac)); + CHECK(codec->SetSendCodec(channel, isac)); - CHECK(base->StartReceive(channel)); - CHECK(base->StartPlayout(channel)); - CHECK(base->StartSend(channel)); - CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), - true, true)); + CHECK(base->StartReceive(channel)); + CHECK(base->StartPlayout(channel)); + CHECK(base->StartSend(channel)); + CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), + true, true)); - CHECK(codec->SetVADStatus(channel, true)); - CHECK(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); - CHECK(apm->SetNsStatus(true, kNsModerateSuppression)); - CHECK(apm->SetEcStatus(true, kEcAec)); + CHECK(codec->SetVADStatus(channel, true)); + CHECK(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); + CHECK(apm->SetNsStatus(true, kNsModerateSuppression)); + CHECK(apm->SetEcStatus(true, kEcAec)); - TEST_LOG("\nMeasure CPU and memory while running a full-duplex" - " iSAC-swb call.\n\n"); + TEST_LOG("\nMeasure CPU and memory while running a full-duplex" + " iSAC-swb call.\n\n"); - PAUSE + PAUSE - CHECK(base->StopSend(channel)); - CHECK(base->StopPlayout(channel)); - CHECK(base->StopReceive(channel)); + CHECK(base->StopSend(channel)); + CHECK(base->StopPlayout(channel)); + CHECK(base->StopReceive(channel)); - base->DeleteChannel(channel); - CHECK(base->Terminate()); + base->DeleteChannel(channel); + CHECK(base->Terminate()); - return 0; + return 0; } -} // namespace voetest +} // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_cpu_test.h b/src/voice_engine/main/test/auto_test/voe_cpu_test.h index 4c1ef96171..f8830756ed 100644 --- a/src/voice_engine/main/test/auto_test/voe_cpu_test.h +++ b/src/voice_engine/main/test/auto_test/voe_cpu_test.h @@ -17,16 +17,15 @@ namespace voetest { class VoETestManager; -class VoECpuTest -{ -public: - VoECpuTest(VoETestManager& mgr); - ~VoECpuTest() {}; - int DoTest(); -private: - VoETestManager& _mgr; +class VoECpuTest { + public: + VoECpuTest(VoETestManager& mgr); + ~VoECpuTest() {} + int DoTest(); + private: + VoETestManager& _mgr; }; -} // namespace voetest +} // namespace voetest #endif // WEBRTC_VOICE_ENGINE_VOE_CPU_TEST_H diff --git a/src/voice_engine/main/test/auto_test/voe_extended_test.cc b/src/voice_engine/main/test/auto_test/voe_extended_test.cc index 16833f550e..5a3f11b8ae 100644 --- a/src/voice_engine/main/test/auto_test/voe_extended_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_extended_test.cc @@ -29,14 +29,12 @@ using namespace webrtc; -namespace voetest -{ +namespace voetest { -#define _SEND_TO_REMOTE_IP_ // Set this flag to ensure that test packets are - // transmitted to -// RemoteIP::RemotePort during tests of SetSendToS and SetSendGQos. -// Requires receiver at the remote side and Wireshark with a proper ip.src -// filter. +// Set this flag to ensure that test packets are transmitted to +// RemoteIP::RemotePort during tests of SetSendToS and SetSendGQos. Requires +// receiver at the remote side and Wireshark with a proper ip.src filter. +#define _SEND_TO_REMOTE_IP_ #ifdef _SEND_TO_REMOTE_IP_ const int RemotePort = 12345; // transmit to this UDP port @@ -86,10 +84,12 @@ bool AudioDeviceModuleImpl::Destroy(AudioDeviceModuleImpl* adm) { } } -AudioDeviceModuleImpl::AudioDeviceModuleImpl() - : _ref_count(0) {} +AudioDeviceModuleImpl::AudioDeviceModuleImpl() : + _ref_count(0) { +} -AudioDeviceModuleImpl::~AudioDeviceModuleImpl() {} +AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { +} int32_t AudioDeviceModuleImpl::AddRef() { return ++_ref_count; @@ -106,101 +106,81 @@ int32_t AudioDeviceModuleImpl::Release() { // ---------------------------------------------------------------------------- ExtendedTestTransport::ExtendedTestTransport(VoENetwork* ptr) : - myNetw(ptr), - _thread(NULL), - _lock(NULL), - _event(NULL), - _length(0), - _channel(0) -{ - const char* threadName = "voe_extended_test_external_thread"; - _lock = CriticalSectionWrapper::CreateCriticalSection(); - _event = EventWrapper::Create(); - _thread = ThreadWrapper::CreateThread(Run, this, kHighPriority, threadName); - if (_thread) - { - unsigned int id; - _thread->Start(id); + myNetw(ptr), _thread(NULL), _lock(NULL), _event(NULL), _length(0), _channel(0) { + const char* threadName = "voe_extended_test_external_thread"; + _lock = CriticalSectionWrapper::CreateCriticalSection(); + _event = EventWrapper::Create(); + _thread = ThreadWrapper::CreateThread(Run, this, kHighPriority, threadName); + if (_thread) { + unsigned int id; + _thread->Start(id); + } +} + +ExtendedTestTransport::~ExtendedTestTransport() { + if (_thread) { + _thread->SetNotAlive(); + _event->Set(); + if (_thread->Stop()) { + delete _thread; + _thread = NULL; + delete _event; + _event = NULL; + delete _lock; + _lock = NULL; } + } } -ExtendedTestTransport::~ExtendedTestTransport() -{ - if (_thread) - { - _thread->SetNotAlive(); - _event->Set(); - if (_thread->Stop()) - { - delete _thread; - _thread = NULL; - delete _event; - _event = NULL; - delete _lock; - _lock = NULL; - } - } +bool ExtendedTestTransport::Run(void* ptr) { + return static_cast (ptr)->Process(); } -bool ExtendedTestTransport::Run(void* ptr) -{ - return static_cast (ptr)->Process(); +bool ExtendedTestTransport::Process() { + switch (_event->Wait(500)) { + case kEventSignaled: + _lock->Enter(); + myNetw->ReceivedRTPPacket(_channel, _packetBuffer, _length); + _lock->Leave(); + return true; + case kEventTimeout: + return true; + case kEventError: + break; + } + return true; } -bool ExtendedTestTransport::Process() -{ - switch (_event->Wait(500)) - { - case kEventSignaled: - _lock->Enter(); - myNetw->ReceivedRTPPacket(_channel, _packetBuffer, _length); - _lock->Leave(); - return true; - case kEventTimeout: - return true; - case kEventError: - break; - } - return true; +int ExtendedTestTransport::SendPacket(int channel, const void *data, int len) { + _lock->Enter(); + if (len < 1612) { + memcpy(_packetBuffer, (const unsigned char*) data, len); + _length = len; + _channel = channel; + } + _lock->Leave(); + _event->Set(); // triggers ReceivedRTPPacket() from worker thread + return len; } -int ExtendedTestTransport::SendPacket(int channel, const void *data, int len) -{ - _lock->Enter(); - if (len < 1612) - { - memcpy(_packetBuffer, (const unsigned char*) data, len); - _length = len; - _channel = channel; - } - _lock->Leave(); - _event->Set(); // triggers ReceivedRTPPacket() from worker thread - return len; -} - -int ExtendedTestTransport::SendRTCPPacket(int channel, const void *data, - int len) -{ - myNetw->ReceivedRTCPPacket(channel, data, len); - return len; +int ExtendedTestTransport::SendRTCPPacket(int channel, const void *data, int len) { + myNetw->ReceivedRTCPPacket(channel, data, len); + return len; } XTransport::XTransport(VoENetwork* netw, VoEFile* file) : - _netw(netw), _file(file) -{ + _netw(netw), _file(file) { } -int XTransport::SendPacket(int channel, const void *data, int len) -{ - // loopback - // _netw->ReceivedRTPPacket(channel, data, len); +int XTransport::SendPacket(int channel, const void *data, int len) { + // loopback + // _netw->ReceivedRTPPacket(channel, data, len); - return 0; + return 0; } -int XTransport::SendRTCPPacket(int, const void *, int) -{ - return 0; +int XTransport::SendRTCPPacket(int, const void *, int) { + return 0; } // ---------------------------------------------------------------------------- @@ -208,29 +188,23 @@ int XTransport::SendRTCPPacket(int, const void *, int) // ---------------------------------------------------------------------------- XRTPObserver::XRTPObserver() : - _SSRC(0) -{ + _SSRC(0) { } -XRTPObserver::~XRTPObserver() -{ +XRTPObserver::~XRTPObserver() { } -void XRTPObserver::OnIncomingCSRCChanged( - const int /*channel*/, - const unsigned int /*CSRC*/, const bool /*added*/) -{ +void XRTPObserver::OnIncomingCSRCChanged(const int /*channel*/, const unsigned int /*CSRC*/, + const bool /*added*/) { } -void XRTPObserver::OnIncomingSSRCChanged(const int /*channel*/, - const unsigned int SSRC) -{ - // char msg[128]; - // sprintf(msg, "OnIncomingSSRCChanged(channel=%d, SSRC=%lu)\n", - // channel, SSRC); - // TEST_LOG(msg); +void XRTPObserver::OnIncomingSSRCChanged(const int /*channel*/, const unsigned int SSRC) { + // char msg[128]; + // sprintf(msg, "OnIncomingSSRCChanged(channel=%d, SSRC=%lu)\n", + // channel, SSRC); + // TEST_LOG(msg); - _SSRC = SSRC; // skip channel dependency for simplicty + _SSRC = SSRC; // skip channel dependency for simplicty } @@ -238,4709 +212,4546 @@ void XRTPObserver::OnIncomingSSRCChanged(const int /*channel*/, // VoEExtendedTest // ---------------------------------------------------------------------------- -int VoEExtendedTest::PrepareTest(const char* str) const -{ - TEST_LOG("\n\n================================================\n"); - TEST_LOG("\tExtended *%s* Test\n", str); - TEST_LOG("================================================\n\n"); +int VoEExtendedTest::PrepareTest(const char* str) const { + TEST_LOG("\n\n================================================\n"); + TEST_LOG("\tExtended *%s* Test\n", str); + TEST_LOG("================================================\n\n"); - return 0; + return 0; } -int VoEExtendedTest::TestPassed(const char* str) const -{ - TEST_LOG("\n\n------------------------------------------------\n"); - TEST_LOG("\tExtended *%s* test passed!\n", str); - TEST_LOG("------------------------------------------------\n\n"); +int VoEExtendedTest::TestPassed(const char* str) const { + TEST_LOG("\n\n------------------------------------------------\n"); + TEST_LOG("\tExtended *%s* test passed!\n", str); + TEST_LOG("------------------------------------------------\n\n"); - return 0; + return 0; } -void VoEExtendedTest::OnPeriodicDeadOrAlive(const int /*channel*/, - const bool alive) -{ - _alive = alive; - if (alive) - { - TEST_LOG("=> ALIVE "); - } else - { - TEST_LOG("=> DEAD "); - } - fflush(NULL); +void VoEExtendedTest::OnPeriodicDeadOrAlive(const int /*channel*/, const bool alive) { + _alive = alive; + if (alive) { + TEST_LOG("=> ALIVE "); + } else { + TEST_LOG("=> DEAD "); + } + fflush(NULL); } -void VoEExtendedTest::CallbackOnError(const int errCode, int) -{ - _errCode = errCode; - TEST_LOG("\n************************\n"); - TEST_LOG(" RUNTIME ERROR: %d \n", errCode); - TEST_LOG("************************\n"); +void VoEExtendedTest::CallbackOnError(const int errCode, int) { + _errCode = errCode; + TEST_LOG("\n************************\n"); + TEST_LOG(" RUNTIME ERROR: %d \n", errCode); + TEST_LOG("************************\n"); } VoEExtendedTest::VoEExtendedTest(VoETestManager& mgr) : - _mgr(mgr) -{ - for (int i = 0; i < 32; i++) - { - _listening[i] = false; - _playing[i] = false; - _sending[i] = false; - } + _mgr(mgr) { + for (int i = 0; i < 32; i++) { + _listening[i] = false; + _playing[i] = false; + _sending[i] = false; + } } -VoEExtendedTest::~VoEExtendedTest() -{ +VoEExtendedTest::~VoEExtendedTest() { } void VoEExtendedTest::StartMedia(int channel, int rtpPort, bool listen, - bool playout, bool send) -{ - VoEBase* base = _mgr.BasePtr(); + bool playout, bool send) { + VoEBase* base = _mgr.BasePtr(); - _listening[channel] = false; - _playing[channel] = false; - _sending[channel] = false; - - base->SetLocalReceiver(channel, rtpPort); - base->SetSendDestination(channel, rtpPort, "127.0.0.1"); - if (listen) - { - _listening[channel] = true; - base->StartReceive(channel); - } - if (playout) - { - _playing[channel] = true; - base->StartPlayout(channel); - } - if (send) - { - _sending[channel] = true; - base->StartSend(channel); - } -} - -void VoEExtendedTest::StopMedia(int channel) -{ - VoEBase* base = _mgr.BasePtr(); - - if (_listening[channel]) - { - _listening[channel] = false; - base->StopReceive(channel); - } - if (_playing[channel]) - { - _playing[channel] = false; - base->StopPlayout(channel); - } - if (_sending[channel]) - { - _sending[channel] = false; - base->StopSend(channel); - } -} - -void VoEExtendedTest::Play(int channel, - unsigned int timeMillisec, - bool addFileAsMicrophone, - bool addTimeMarker) -{ - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); + _listening[channel] = false; + _playing[channel] = false; + _sending[channel] = false; + base->SetLocalReceiver(channel, rtpPort); + base->SetSendDestination(channel, rtpPort, "127.0.0.1"); + if (listen) { + _listening[channel] = true; + base->StartReceive(channel); + } + if (playout) { + _playing[channel] = true; base->StartPlayout(channel); - TEST_LOG("[playing]"); - fflush(NULL); - if (addFileAsMicrophone) - { - file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), true, - true); - TEST_LOG("[file as mic]"); - fflush(NULL); - } - if (addTimeMarker) - { - float dtSec = (float) ((float) timeMillisec / 1000.0); - TEST_LOG("[dT=%.1f]", dtSec); - fflush(NULL); // print sleep time in seconds - } - SLEEP(timeMillisec); + } + if (send) { + _sending[channel] = true; + base->StartSend(channel); + } +} + +void VoEExtendedTest::StopMedia(int channel) { + VoEBase* base = _mgr.BasePtr(); + + if (_listening[channel]) { + _listening[channel] = false; + base->StopReceive(channel); + } + if (_playing[channel]) { + _playing[channel] = false; base->StopPlayout(channel); - file->StopPlayingFileAsMicrophone(channel); + } + if (_sending[channel]) { + _sending[channel] = false; + base->StopSend(channel); + } } -void VoEExtendedTest::Sleep(unsigned int timeMillisec, bool addMarker) -{ - if (addMarker) - { - float dtSec = (float) ((float) timeMillisec / 1000.0); - TEST_LOG("[dT=%.1f]", dtSec); // print sleep time in seconds - } - ::Sleep(timeMillisec); +void VoEExtendedTest::Play(int channel, unsigned int timeMillisec, bool addFileAsMicrophone, + bool addTimeMarker) { + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); + + base->StartPlayout(channel); + TEST_LOG("[playing]"); + fflush(NULL); + if (addFileAsMicrophone) { + file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), true, true); + TEST_LOG("[file as mic]"); + fflush(NULL); + } + if (addTimeMarker) { + float dtSec = (float) ((float) timeMillisec / 1000.0); + TEST_LOG("[dT=%.1f]", dtSec); + fflush(NULL); // print sleep time in seconds + } + SLEEP(timeMillisec); + base->StopPlayout(channel); + file->StopPlayingFileAsMicrophone(channel); } -int VoEExtendedTest::TestBase() -{ +void VoEExtendedTest::Sleep(unsigned int timeMillisec, bool addMarker) { + if (addMarker) { + float dtSec = (float) ((float) timeMillisec / 1000.0); + TEST_LOG("[dT=%.1f]", dtSec); // print sleep time in seconds + } + ::Sleep(timeMillisec); +} + +int VoEExtendedTest::TestBase() { #ifndef _WIN32 - // Sleep a bit instead when pause not supported + // Sleep a bit instead when pause not supported #undef PAUSE #define PAUSE SLEEP(2000); #endif - PrepareTest("Base"); + PrepareTest("Base"); - VoEBase* base = _mgr.BasePtr(); - VoENetwork* netw = _mgr.NetworkPtr(); + VoEBase* base = _mgr.BasePtr(); + VoENetwork* netw = _mgr.NetworkPtr(); #ifdef _TEST_RTP_RTCP_ - VoERTP_RTCP* rtp = _mgr.RTP_RTCPPtr(); + VoERTP_RTCP* rtp = _mgr.RTP_RTCPPtr(); #endif - ////////////////////////// - // SetTraceFileName + ////////////////////////// + // SetTraceFileName #ifdef _USE_EXTENDED_TRACE_ - TEST(SetTraceFileName - SetDebugTraceFileName); ANL(); + TEST(SetTraceFileName - SetDebugTraceFileName); ANL(); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); MARK(); - // don't use these files - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("" - "VoEBase_trace_dont_use.txt"))); MARK(); - // use these instead - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("" - "VoEBase_trace.txt"))); MARK(); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStream | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); MARK(); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); MARK(); + // don't use these files + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("" + "VoEBase_trace_dont_use.txt"))); MARK(); + // use these instead + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("" + "VoEBase_trace.txt"))); MARK(); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStream | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); MARK(); - ANL(); AOK(); ANL(); ANL(); + ANL(); AOK(); ANL(); ANL(); #endif - /////////////////////////////////////// - // RegisterVoiceEngineObserver - // DeRegisterVoiceEngineObserver + /////////////////////////////////////// + // RegisterVoiceEngineObserver + // DeRegisterVoiceEngineObserver + TEST(SetObserver); + ANL(); - TEST(SetObserver); - ANL(); + TEST_MUSTPASS(base->RegisterVoiceEngineObserver(*this)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->DeRegisterVoiceEngineObserver()); + MARK(); - TEST_MUSTPASS(base->RegisterVoiceEngineObserver(*this)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->DeRegisterVoiceEngineObserver()); - MARK(); + ANL(); + AOK(); + ANL(); + ANL(); - ANL(); - AOK(); - ANL(); - ANL(); + ///////////////////// + // GetVersion + TEST(GetVersion); + ANL(); - ///////////////////// - // GetVersion + char version[1024]; + // audio device module and AudioProcessing fail to getversion when they + // are not initiliazed + TEST_MUSTPASS(base->GetVersion(version)); + MARK(); + TEST_LOG("\n-----\n%s\n-----\n", version); - TEST(GetVersion); - ANL(); + ANL(); + AOK(); + ANL(); + ANL(); - char version[1024]; - // audio device module and AudioProcessing fail to getversion when they - // are not initiliazed - TEST_MUSTPASS(base->GetVersion(version)); - MARK(); - TEST_LOG("\n-----\n%s\n-----\n", version); + /////////////// + // Init + TEST(Init); + ANL(); - ANL(); - AOK(); - ANL(); - ANL(); + TEST_MUSTPASS(base->Init()); + MARK(); + TEST_MUSTPASS(base->Terminate()); - /////////////// - // Init - - TEST(Init); - ANL(); - - TEST_MUSTPASS(base->Init()); - MARK(); - TEST_MUSTPASS(base->Terminate()); - - TEST_MUSTPASS(base->Init()); - MARK(); - // ensure that no new memory is allocated at the second call (check - // trace file) - TEST_MUSTPASS(base->Init()); - MARK(); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->Init()); + MARK(); + // ensure that no new memory is allocated at the second call (check + // trace file) + TEST_MUSTPASS(base->Init()); + MARK(); + TEST_MUSTPASS(base->Terminate()); #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // verify AEC recording - TEST_MUSTPASS(base->Init()); - MARK(); // verify output dat-files - TEST_MUSTPASS(base->Terminate()); + // verify AEC recording + TEST_MUSTPASS(base->Init()); + MARK(); // verify output dat-files + TEST_MUSTPASS(base->Terminate()); #endif - ANL(); - AOK(); - ANL(); - ANL(); + ANL(); + AOK(); + ANL(); + ANL(); - //////////////////// - // Terminate + //////////////////// + // Terminate + TEST(Terminate); + ANL(); + TEST_MUSTPASS(base->Terminate()); + MARK(); // should be ignored + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->Terminate()); + MARK(); // should terminate - TEST(Terminate); - ANL(); - TEST_MUSTPASS(base->Terminate()); - MARK(); // should be ignored - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->Terminate()); - MARK(); // should terminate + ANL(); + AOK(); + ANL(); + ANL(); - ANL(); - AOK(); - ANL(); - ANL(); + // ------------------------------------------------------------------------ + // >> Init(AudioDeviceModule) + // + // Note that our mock implementation of the ADM also mocks the + // reference counting part. This approach enables us to keep track + // of the internal reference counter without checking return values + // from the ADM and we also avoid the built-in self destruction. + // + // TODO(henrika): this test does not verify that external ADM methods + // are called by the VoiceEngine once registered. We could extend + // the mock implementation and add counters for each ADM API to ensure + // that they are called in the correct sequence and the correct number + // of times. + TEST_LOG("\nTesting: Init in combination with an external ADM\n"); - // ------------------------------------------------------------------------ - // >> Init(AudioDeviceModule) - // - // Note that our mock implementation of the ADM also mocks the - // reference counting part. This approach enables us to keep track - // of the internal reference counter without checking return values - // from the ADM and we also avoid the built-in self destruction. - // - // TODO(henrika): this test does not verify that external ADM methods - // are called by the VoiceEngine once registered. We could extend - // the mock implementation and add counters for each ADM API to ensure - // that they are called in the correct sequence and the correct number - // of times. + // Create the ADM and call AddRef within the factory method. + AudioDeviceModuleImpl* xADM = AudioDeviceModuleImpl::Create(); + ASSERT_FALSE(xADM == NULL); + ASSERT_TRUE(xADM->ReferenceCounter() == 1); - TEST_LOG("\nTesting: Init in combination with an external ADM\n"); + // Verify default usage case for external ADM. + TEST_MUSTPASS(base->Init(xADM));MARK(); + ASSERT_TRUE(xADM->ReferenceCounter() == 2); + TEST_MUSTPASS(base->Terminate()); + ASSERT_TRUE(xADM->ReferenceCounter() == 1); - // Create the ADM and call AddRef within the factory method. - AudioDeviceModuleImpl* xADM = AudioDeviceModuleImpl::Create(); - ASSERT_FALSE(xADM == NULL); - ASSERT_TRUE(xADM->ReferenceCounter() == 1); + // Our reference-count implementation does not self destruct. + // We do it manually here instead by calling Release followed by delete. + ASSERT_TRUE(AudioDeviceModuleImpl::Destroy(xADM)); + ANL(); + AOK();ANL(); - // Verify default usage case for external ADM. - TEST_MUSTPASS(base->Init(xADM)); MARK(); - ASSERT_TRUE(xADM->ReferenceCounter() == 2); - TEST_MUSTPASS(base->Terminate()); - ASSERT_TRUE(xADM->ReferenceCounter() == 1); + // >> end of Init(AudioDeviceModule) + // ------------------------------------------------------------------------ - // Our reference-count implementation does not self destruct. - // We do it manually here instead by calling Release followed by delete. - ASSERT_TRUE(AudioDeviceModuleImpl::Destroy(xADM)); - ANL(); AOK(); ANL(); + /////////////////////////// + // MaxNumOfChannels + TEST(MaxNumOfChannels); + ANL(); + TEST_MUSTPASS(base->MaxNumOfChannels() < 0); + MARK(); + ANL(); + AOK(); + ANL(); + ANL(); - // >> end of Init(AudioDeviceModule) - // ------------------------------------------------------------------------ + //////////////////////// + // CreateChannel + // DeleteChannel - /////////////////////////// - // MaxNumOfChannels + int i; + int channel; + int nChannels(base->MaxNumOfChannels()); - TEST(MaxNumOfChannels); - ANL(); - TEST_MUSTPASS(base->MaxNumOfChannels() < 0); - MARK(); - ANL(); - AOK(); - ANL(); - ANL(); + TEST(CreateChannel); + ANL(); + TEST(DeleteChannel); + ANL(); - //////////////////////// - // CreateChannel - // DeleteChannel + TEST_MUSTPASS(base->Init()); - int i; - int channel; - int nChannels(base->MaxNumOfChannels()); + channel = base->CreateChannel(); + MARK(); + TEST_MUSTPASS(channel != 0); + channel = base->CreateChannel(); + MARK(); + TEST_MUSTPASS(channel != 1); - TEST(CreateChannel); - ANL(); - TEST(DeleteChannel); - ANL(); - - TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->DeleteChannel(0)); + MARK(); + TEST_MUSTPASS(base->DeleteChannel(1)); + MARK(); + // create and delete one channel many times + for (i = 0; i < 10; i++) { channel = base->CreateChannel(); MARK(); - TEST_MUSTPASS(channel != 0); + TEST_MUSTPASS(channel != 0); // should be 0 each time + TEST_MUSTPASS(base->DeleteChannel(channel)); + MARK(); + } + // create max number of channels + for (i = 0; i < nChannels; i++) { channel = base->CreateChannel(); MARK(); - TEST_MUSTPASS(channel != 1); + TEST_MUSTPASS(channel != i); + } + channel = base->CreateChannel(); + MARK(); // should fail since no more channels can now be created + TEST_MUSTPASS(channel != -1); - TEST_MUSTPASS(base->DeleteChannel(0)); - MARK(); - TEST_MUSTPASS(base->DeleteChannel(1)); + int aChannel = (((nChannels - 17) > 0) ? (nChannels - 17) : 0); + TEST_MUSTPASS(base->DeleteChannel(aChannel)); + MARK(); + channel = base->CreateChannel(); + MARK(); // should reuse channel + TEST_MUSTPASS(channel != aChannel); + + // delete all created channels + for (i = 0; i < nChannels; i++) { + TEST_MUSTPASS(base->DeleteChannel(i)); MARK(); + } - // create and delete one channel many times - for (i = 0; i < 10; i++) - { - channel = base->CreateChannel(); - MARK(); - TEST_MUSTPASS(channel != 0); // should be 0 each time - TEST_MUSTPASS(base->DeleteChannel(channel)); - MARK(); - } - // create max number of channels - for (i = 0; i < nChannels; i++) - { - channel = base->CreateChannel(); - MARK(); - TEST_MUSTPASS(channel != i); - } - channel = base->CreateChannel(); - MARK(); // should fail since no more channels can now be created - TEST_MUSTPASS(channel != -1); + // try to delete a non-existing channel + TEST_MUSTPASS(-1 != base->DeleteChannel(aChannel)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - int aChannel = (((nChannels - 17) > 0) ? (nChannels - 17) : 0); - TEST_MUSTPASS(base->DeleteChannel(aChannel)); - MARK(); - channel = base->CreateChannel(); - MARK(); // should reuse channel - TEST_MUSTPASS(channel != aChannel); + ANL(); + AOK(); + ANL(); + ANL(); - // delete all created channels - for (i = 0; i < nChannels; i++) - { - TEST_MUSTPASS(base->DeleteChannel(i)); - MARK(); - } + // ------------------------------------------------------------------------ + // >> SetLocalReceiver + // + // State: VE not initialized, no existing channels + TEST_MUSTPASS(base->Init()); - // try to delete a non-existing channel - TEST_MUSTPASS(-1 != base->DeleteChannel(aChannel)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + int ch; - ANL(); - AOK(); - ANL(); - ANL(); + TEST(SetLocalReceiver); + ANL(); - // ------------------------------------------------------------------------ - // >> SetLocalReceiver - // - // State: VE not initialized, no existing channels + // no channel created yet => should fail + TEST_MUSTPASS(!base->SetLocalReceiver(0, 100)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(base->Init()); - - int ch; - - TEST(SetLocalReceiver); - ANL(); - - // no channel created yet => should fail - TEST_MUSTPASS(!base->SetLocalReceiver(0, 100)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - - ch = base->CreateChannel(); + ch = base->CreateChannel(); #ifdef MAC_IPHONE - printf("\nNOTE: Local IP must be set in source code (line %d) \n", - __LINE__ + 1); - char* localIp = "127.0.0.1"; + printf("\nNOTE: Local IP must be set in source code (line %d) \n", + __LINE__ + 1); + char* localIp = "127.0.0.1"; #else - char localIp[64] = { 0 }; - TEST_MUSTPASS(netw->GetLocalIP(localIp)); - MARK(); - // NOTE: This API is supported on Win, Mac and Linux and may fail or not - // return local IP for other platforms. + char localIp[64] = { 0 }; + TEST_MUSTPASS(netw->GetLocalIP(localIp)); + MARK(); + // NOTE: This API is supported on Win, Mac and Linux and may fail or not + // return local IP for other platforms. #endif - // trivial invalid function calls - TEST_MUSTPASS(!base->SetLocalReceiver(ch+1, 12345)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!base->SetLocalReceiver(ch, -1)); - MARK(); - TEST_ERROR(VE_INVALID_PORT_NMBR); + // trivial invalid function calls + TEST_MUSTPASS(!base->SetLocalReceiver(ch+1, 12345)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!base->SetLocalReceiver(ch, -1)); + MARK(); + TEST_ERROR(VE_INVALID_PORT_NMBR); - // check conflict with ongoing receiving - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - MARK(); + // check conflict with ongoing receiving + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + MARK(); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(!base->SetLocalReceiver(ch, 12345)); + MARK(); + TEST_ERROR(VE_ALREADY_LISTENING); + TEST_MUSTPASS(base->StopReceive(ch)); + + // check conflict with ongoing transmission + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(!base->SetLocalReceiver(ch, 12345)); + MARK(); + TEST_ERROR(VE_ALREADY_SENDING); + TEST_MUSTPASS(base->StopSend(ch)); + + // valid function calls + // Need to sleep between, otherwise it may fail for unknown reason + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, localIp)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, NULL, + "230.1.2.3")); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, localIp, + "230.1.2.3")); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, 5555, NULL)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + MARK(); + SLEEP(100); + + // STATE: no media but sockets exists and are binded to 12345 and 12346 + // respectively + + // Add some dynamic tests as well: + + // ensure that last setting is used (cancels old settings) + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 44444)); + MARK(); + SLEEP(100); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 54321)); + MARK(); + TEST_MUSTPASS(base->SetSendDestination(ch, 54321, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + Play(ch, 1000, true, true); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); + + TEST_MUSTPASS(base->DeleteChannel(ch)); + + ANL(); + AOK(); + ANL(); + ANL(); + + // >> end of SetLocalReceiver + // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ + // >> GetLocalReceiver + // + // State: VE initialized, no existing channels + TEST(GetLocalReceiver); + ANL(); + + int port; + char ipaddr[64]; + int RTCPport; + + ch = base->CreateChannel(); + + // verify non-configured (blank) local receiver + TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); + MARK(); + TEST_MUSTPASS(port != 0); + TEST_MUSTPASS(RTCPport != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + + // check some trivial set/get combinations + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)) + TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); + MARK(); + TEST_MUSTPASS(port != 12345); + TEST_MUSTPASS(RTCPport != 12346); + TEST_MUSTPASS(strcmp(ipaddr, "0.0.0.0") != 0); // now binded to "any" IP + + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, 55555)) + TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); + MARK(); + TEST_MUSTPASS(port != 12345); + TEST_MUSTPASS(RTCPport != 55555); + TEST_MUSTPASS(strcmp(ipaddr, "0.0.0.0") != 0); + + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, localIp)) + TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); + MARK(); + TEST_MUSTPASS(port != 12345); + TEST_MUSTPASS(RTCPport != 12346); + TEST_MUSTPASS(strcmp(ipaddr, localIp) != 0); + + TEST_MUSTPASS(base->DeleteChannel(ch)); + + ANL(); + AOK(); + ANL(); + ANL(); + + // >> end of GetLocalReceiver + // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ + // >> SetSendDestination + // + // State: VE initialized, no existing channels + TEST(SetSendDestination); + ANL(); + + // call without existing channel + TEST_MUSTPASS(!base->SetSendDestination(0, 12345, "127.0.0.1")); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); + + ch = base->CreateChannel(); + + // trivial fail tests + TEST_MUSTPASS(!base->SetSendDestination(ch, 65536, "127.0.0.1")); + MARK(); + TEST_ERROR(VE_INVALID_PORT_NMBR); // invalid RTP port + TEST_MUSTPASS(!base->SetSendDestination(ch, 12345, "127.0.0.1", 65536)); + MARK(); + TEST_ERROR(VE_INVALID_PORT_NMBR); // invalid source port + TEST_MUSTPASS(!base->SetSendDestination(ch, 12345, "127.0.0.1", kVoEDefault, + 65536)); + MARK(); + TEST_ERROR(VE_INVALID_PORT_NMBR); // invalid RTCP port + TEST_MUSTPASS(!base->SetSendDestination(ch, 12345, "127.0.0.300")); + MARK(); + TEST_ERROR(VE_INVALID_IP_ADDRESS); // invalid IP address + + // sockets must be created first to support multi-cast (not required + // otherwise) + TEST_MUSTPASS(!base->SetSendDestination(ch, 55555, "230.0.0.1")); + MARK(); + TEST_ERROR(VE_SOCKET_ERROR); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); // create sockets + TEST_MUSTPASS(base->SetSendDestination(ch, 55555, "230.0.0.1")); + MARK(); // should work now + + base->DeleteChannel(0); + ch = base->CreateChannel(); + + // STATE: one channel created, no sockets exist + + // valid function calls + TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1")); + MARK(); + TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", 44444)); + MARK(); + TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", kVoEDefault, + 55555)); + MARK(); + TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", 44444, + 55555)); + MARK(); + + base->DeleteChannel(0); + ch = base->CreateChannel(); + + // create receive sockets first and then an extra pair of send sockets + TEST_MUSTPASS(base->SetLocalReceiver(ch, 44444)); + TEST_MUSTPASS(base->SetSendDestination(ch, 44444, "127.0.0.1", 11111)); + MARK(); // binds to 11111 + + TEST_MUSTPASS(base->DeleteChannel(ch)); + + ANL(); + AOK(); + ANL(); + ANL(); + + // >> end of SetSendDestination + // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ + // >> GetSendDestination + // + // State: VE initialized, no existing channels + TEST(GetSendDestination); + ANL(); + + int sourcePort; + + ch = base->CreateChannel(); + + // verify non-configured (blank) local receiver + TEST_MUSTPASS(base->GetSendDestination(ch, port, ipaddr, sourcePort, + RTCPport)); + MARK(); + TEST_MUSTPASS(port != 0); + TEST_MUSTPASS(sourcePort != 0); + TEST_MUSTPASS(RTCPport != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + + // check some trivial set/get combinations + TEST_MUSTPASS(base->SetSendDestination(ch, 44444, "127.0.0.1")); + TEST_MUSTPASS(base->GetSendDestination(ch, port, ipaddr, sourcePort, + RTCPport)); + MARK(); + TEST_MUSTPASS(port != 44444); + TEST_MUSTPASS(sourcePort != 0); // should be 0 since no local receiver has + // NOT been defined yet + TEST_MUSTPASS(RTCPport != 44445); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + + TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); + TEST_MUSTPASS(base->GetSendDestination(ch, port, ipaddr, sourcePort, + RTCPport)); + MARK(); + TEST_MUSTPASS(port != 44444); + TEST_MUSTPASS(sourcePort != 55555); // should be equal to local port + TEST_MUSTPASS(RTCPport != 44445); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + + base->DeleteChannel(0); + ch = base->CreateChannel(); + + TEST_MUSTPASS(base->SetSendDestination(ch, 44444, "127.0.0.1")); + // NULL as IP-address input should work as well + TEST_MUSTPASS(base->GetSendDestination(ch, port, NULL, sourcePort, + RTCPport)); + MARK(); + TEST_MUSTPASS(port != 44444); + TEST_MUSTPASS(sourcePort != 0); + TEST_MUSTPASS(RTCPport != 44445); + + TEST_MUSTPASS(base->DeleteChannel(ch)); + + ANL(); + AOK(); + ANL(); + ANL(); + + // >> end of GetLocalReceiver + // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ + // >> StartReceive + // >> StopReceive + // + // State: VE initialized, no existing channels + TEST(StartReceive); + ANL(); + TEST(StopReceive); + ANL(); + + // call without existing channel + TEST_MUSTPASS(!base->StartReceive(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!base->StopReceive(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); + + ch = base->CreateChannel(); + + // sockets must be created first + TEST_MUSTPASS(!base->StartReceive(0)); + MARK(); + TEST_ERROR(VE_SOCKETS_NOT_INITED); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); + TEST_MUSTPASS(base->StartReceive(0)); + MARK(); // should work this time + + // enable again (should work) + TEST_MUSTPASS(base->StartReceive(0)); + MARK(); + + // Stop/Start (should work) + TEST_MUSTPASS(base->StopReceive(0)); + MARK(); + TEST_MUSTPASS(base->StartReceive(0)); + MARK(); + + // Verify in loopback + TEST_MUSTPASS(base->SetSendDestination(ch, 55555, "127.0.0.1")); + TEST_MUSTPASS(base->StartSend(ch)); + Play(ch, 1000, true, true); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopReceive(0)); + MARK(); + + base->DeleteChannel(0); + ch = base->CreateChannel(); + + // Ensure that it is OK to add delay between SetLocalReceiver and StarListen + TEST_LOG("\nspeak after 2 seconds and ensure that no delay is added:\n"); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); + + Sleep(2000, true); // adding emulated delay here + + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->SetSendDestination(ch, 55555, "127.0.0.1")); + TEST_MUSTPASS(base->StartSend(ch)); + Play(ch, 2000, true, true); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopReceive(0)); + + TEST_MUSTPASS(base->DeleteChannel(ch)); + ANL(); + + // Multi-channel tests + + for (i = 0; i < base->MaxNumOfChannels(); i++) { + ch = base->CreateChannel(); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 11111+2*i)); TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(!base->SetLocalReceiver(ch, 12345)); MARK(); - TEST_ERROR(VE_ALREADY_LISTENING); - TEST_MUSTPASS(base->StopReceive(ch)); - - // check conflict with ongoing transmission - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(!base->SetLocalReceiver(ch, 12345)); + } + for (i = 0; i < base->MaxNumOfChannels(); i++) { + TEST_MUSTPASS(base->StopReceive(i)); MARK(); - TEST_ERROR(VE_ALREADY_SENDING); - TEST_MUSTPASS(base->StopSend(ch)); - - // valid function calls - // Need to sleep between, otherwise it may fail for unknown reason - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, localIp)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, NULL, - "230.1.2.3")); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, localIp, - "230.1.2.3")); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, 5555, NULL)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - MARK(); - SLEEP(100); - - // STATE: no media but sockets exists and are binded to 12345 and 12346 - // respectively - - // Add some dynamic tests as well: - - // ensure that last setting is used (cancels old settings) - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 44444)); - MARK(); - SLEEP(100); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 54321)); - MARK(); - TEST_MUSTPASS(base->SetSendDestination(ch, 54321, "127.0.0.1")); + base->DeleteChannel(i); + } + for (i = 0; i < base->MaxNumOfChannels(); i++) { + ch = base->CreateChannel(); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 11111+2*i)); TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartSend(ch)); - Play(ch, 1000, true, true); - TEST_MUSTPASS(base->StopSend(ch)); + MARK(); TEST_MUSTPASS(base->StopReceive(ch)); + MARK(); + base->DeleteChannel(ch); + } - TEST_MUSTPASS(base->DeleteChannel(ch)); + ANL(); + AOK(); + ANL(); + ANL(); - ANL(); - AOK(); - ANL(); - ANL(); + // >> end of StartReceive/StopReceive + // ------------------------------------------------------------------------ - // >> end of SetLocalReceiver - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ + // >> StartPlayout + // >> StopPlayout + // + // State: VE initialized, no existing channels + TEST(StartPlayout); + ANL(); + TEST(StopPlayout); + ANL(); - // ------------------------------------------------------------------------ - // >> GetLocalReceiver - // - // State: VE initialized, no existing channels + // call without existing channel + TEST_MUSTPASS(!base->StartPlayout(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!base->StopPlayout(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST(GetLocalReceiver); - ANL(); + ch = base->CreateChannel(); - int port; - char ipaddr[64]; - int RTCPport; + TEST_MUSTPASS(base->StartPlayout(ch)); + MARK(); + TEST_MUSTPASS(base->StartPlayout(ch)); + MARK(); + TEST_MUSTPASS(base->StopPlayout(ch)); + MARK(); + TEST_MUSTPASS(base->StopPlayout(ch)); + MARK(); + base->DeleteChannel(ch); + + // Multi-channel tests + const int MaxNumberOfPlayingChannels(kVoiceEngineMaxNumOfActiveChannels); + + for (i = 0; i < MaxNumberOfPlayingChannels; i++) { ch = base->CreateChannel(); - - // verify non-configured (blank) local receiver - TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); - MARK(); - TEST_MUSTPASS(port != 0); - TEST_MUSTPASS(RTCPport != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - - // check some trivial set/get combinations - - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)) - TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); - MARK(); - TEST_MUSTPASS(port != 12345); - TEST_MUSTPASS(RTCPport != 12346); - TEST_MUSTPASS(strcmp(ipaddr, "0.0.0.0") != 0); // now binded to "any" IP - - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, 55555)) - TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); - MARK(); - TEST_MUSTPASS(port != 12345); - TEST_MUSTPASS(RTCPport != 55555); - TEST_MUSTPASS(strcmp(ipaddr, "0.0.0.0") != 0); - - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, kVoEDefault, localIp)) - TEST_MUSTPASS(base->GetLocalReceiver(ch, port, RTCPport, ipaddr)); - MARK(); - TEST_MUSTPASS(port != 12345); - TEST_MUSTPASS(RTCPport != 12346); - TEST_MUSTPASS(strcmp(ipaddr, localIp) != 0); - - TEST_MUSTPASS(base->DeleteChannel(ch)); - - ANL(); - AOK(); - ANL(); - ANL(); - - // >> end of GetLocalReceiver - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // >> SetSendDestination - // - // State: VE initialized, no existing channels - - TEST(SetSendDestination); - ANL(); - - // call without existing channel - TEST_MUSTPASS(!base->SetSendDestination(0, 12345, "127.0.0.1")); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - - ch = base->CreateChannel(); - - // trivial fail tests - TEST_MUSTPASS(!base->SetSendDestination(ch, 65536, "127.0.0.1")); - MARK(); - TEST_ERROR(VE_INVALID_PORT_NMBR); // invalid RTP port - TEST_MUSTPASS(!base->SetSendDestination(ch, 12345, "127.0.0.1", 65536)); - MARK(); - TEST_ERROR(VE_INVALID_PORT_NMBR); // invalid source port - TEST_MUSTPASS(!base->SetSendDestination(ch, 12345, "127.0.0.1", kVoEDefault, - 65536)); - MARK(); - TEST_ERROR(VE_INVALID_PORT_NMBR); // invalid RTCP port - TEST_MUSTPASS(!base->SetSendDestination(ch, 12345, "127.0.0.300")); - MARK(); - TEST_ERROR(VE_INVALID_IP_ADDRESS); // invalid IP address - - // sockets must be created first to support multi-cast (not required - // otherwise) - TEST_MUSTPASS(!base->SetSendDestination(ch, 55555, "230.0.0.1")); - MARK(); - TEST_ERROR(VE_SOCKET_ERROR); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); // create sockets - TEST_MUSTPASS(base->SetSendDestination(ch, 55555, "230.0.0.1")); - MARK(); // should work now - - base->DeleteChannel(0); - ch = base->CreateChannel(); - - // STATE: one channel created, no sockets exist - - // valid function calls - TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1")); - MARK(); - TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", 44444)); - MARK(); - TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", kVoEDefault, - 55555)); - MARK(); - TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", 44444, - 55555)); - MARK(); - - base->DeleteChannel(0); - ch = base->CreateChannel(); - - // create receive sockets first and then an extra pair of send sockets - TEST_MUSTPASS(base->SetLocalReceiver(ch, 44444)); - TEST_MUSTPASS(base->SetSendDestination(ch, 44444, "127.0.0.1", 11111)); - MARK(); // binds to 11111 - - TEST_MUSTPASS(base->DeleteChannel(ch)); - - ANL(); - AOK(); - ANL(); - ANL(); - - // >> end of SetSendDestination - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // >> GetSendDestination - // - // State: VE initialized, no existing channels - - TEST(GetSendDestination); - ANL(); - - int sourcePort; - - ch = base->CreateChannel(); - - // verify non-configured (blank) local receiver - TEST_MUSTPASS(base->GetSendDestination(ch, port, ipaddr, sourcePort, - RTCPport)); - MARK(); - TEST_MUSTPASS(port != 0); - TEST_MUSTPASS(sourcePort != 0); - TEST_MUSTPASS(RTCPport != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - - // check some trivial set/get combinations - - TEST_MUSTPASS(base->SetSendDestination(ch, 44444, "127.0.0.1")); - TEST_MUSTPASS(base->GetSendDestination(ch, port, ipaddr, sourcePort, - RTCPport)); - MARK(); - TEST_MUSTPASS(port != 44444); - TEST_MUSTPASS(sourcePort != 0); // should be 0 since no local receiver has - // NOT been defined yet - TEST_MUSTPASS(RTCPport != 44445); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - - TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); - TEST_MUSTPASS(base->GetSendDestination(ch, port, ipaddr, sourcePort, - RTCPport)); - MARK(); - TEST_MUSTPASS(port != 44444); - TEST_MUSTPASS(sourcePort != 55555); // should be equal to local port - TEST_MUSTPASS(RTCPport != 44445); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - - base->DeleteChannel(0); - ch = base->CreateChannel(); - - TEST_MUSTPASS(base->SetSendDestination(ch, 44444, "127.0.0.1")); - // NULL as IP-address input should work as well - TEST_MUSTPASS(base->GetSendDestination(ch, port, NULL, sourcePort, - RTCPport)); - MARK(); - TEST_MUSTPASS(port != 44444); - TEST_MUSTPASS(sourcePort != 0); - TEST_MUSTPASS(RTCPport != 44445); - - TEST_MUSTPASS(base->DeleteChannel(ch)); - - ANL(); - AOK(); - ANL(); - ANL(); - - // >> end of GetLocalReceiver - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // >> StartReceive - // >> StopReceive - // - // State: VE initialized, no existing channels - - TEST(StartReceive); - ANL(); - TEST(StopReceive); - ANL(); - - // call without existing channel - TEST_MUSTPASS(!base->StartReceive(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!base->StopReceive(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - - ch = base->CreateChannel(); - - // sockets must be created first - TEST_MUSTPASS(!base->StartReceive(0)); - MARK(); - TEST_ERROR(VE_SOCKETS_NOT_INITED); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); - TEST_MUSTPASS(base->StartReceive(0)); - MARK(); // should work this time - - // enable again (should work) - TEST_MUSTPASS(base->StartReceive(0)); - MARK(); - - // Stop/Start (should work) - TEST_MUSTPASS(base->StopReceive(0)); - MARK(); - TEST_MUSTPASS(base->StartReceive(0)); - MARK(); - - // Verify in loopback - TEST_MUSTPASS(base->SetSendDestination(ch, 55555, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - Play(ch, 1000, true, true); - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopReceive(0)); - MARK(); - - base->DeleteChannel(0); - ch = base->CreateChannel(); - - // Ensure that it is OK to add delay between SetLocalReceiver and StarListen - TEST_LOG("\nspeak after 2 seconds and ensure that no delay is added:\n"); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 55555)); - - Sleep(2000, true); // adding emulated delay here - - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->SetSendDestination(ch, 55555, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - Play(ch, 2000, true, true); - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopReceive(0)); - - TEST_MUSTPASS(base->DeleteChannel(ch)); - ANL(); - - // Multi-channel tests - - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - ch = base->CreateChannel(); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 11111+2*i)); - TEST_MUSTPASS(base->StartReceive(ch)); - MARK(); - } - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - TEST_MUSTPASS(base->StopReceive(i)); - MARK(); - base->DeleteChannel(i); - } - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - ch = base->CreateChannel(); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 11111+2*i)); - TEST_MUSTPASS(base->StartReceive(ch)); - MARK(); - TEST_MUSTPASS(base->StopReceive(ch)); - MARK(); - base->DeleteChannel(ch); - } - - ANL(); - AOK(); - ANL(); - ANL(); - - // >> end of StartReceive/StopReceive - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // >> StartPlayout - // >> StopPlayout - // - // State: VE initialized, no existing channels - - TEST(StartPlayout); - ANL(); - TEST(StopPlayout); - ANL(); - - // call without existing channel - TEST_MUSTPASS(!base->StartPlayout(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!base->StopPlayout(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - - ch = base->CreateChannel(); - TEST_MUSTPASS(base->StartPlayout(ch)); MARK(); + } + for (i = 0; i < MaxNumberOfPlayingChannels; i++) { + TEST_MUSTPASS(base->StopPlayout(i)); + MARK(); + base->DeleteChannel(i); + } + for (i = 0; i < MaxNumberOfPlayingChannels; i++) { + ch = base->CreateChannel(); TEST_MUSTPASS(base->StartPlayout(ch)); MARK(); TEST_MUSTPASS(base->StopPlayout(ch)); MARK(); - TEST_MUSTPASS(base->StopPlayout(ch)); - MARK(); - base->DeleteChannel(ch); + } - // Multi-channel tests - const int MaxNumberOfPlayingChannels(kVoiceEngineMaxNumOfActiveChannels); + ANL(); + AOK(); + ANL(); + ANL(); - for (i = 0; i < MaxNumberOfPlayingChannels; i++) - { - ch = base->CreateChannel(); - TEST_MUSTPASS(base->StartPlayout(ch)); - MARK(); - } - for (i = 0; i < MaxNumberOfPlayingChannels; i++) - { - TEST_MUSTPASS(base->StopPlayout(i)); - MARK(); - base->DeleteChannel(i); - } - for (i = 0; i < MaxNumberOfPlayingChannels; i++) - { - ch = base->CreateChannel(); - TEST_MUSTPASS(base->StartPlayout(ch)); - MARK(); - TEST_MUSTPASS(base->StopPlayout(ch)); - MARK(); - base->DeleteChannel(ch); - } + // >> end of StartPlayout/StopPlayout + // ------------------------------------------------------------------------ - ANL(); - AOK(); - ANL(); - ANL(); + // ------------------------------------------------------------------------ + // >> StartSend + // >> StopSend + // + // State: VE initialized, no existing channels + TEST(StartSend); + ANL(); + TEST(StopSend); + ANL(); - // >> end of StartPlayout/StopPlayout - // ------------------------------------------------------------------------ + // call without existing channel + TEST_MUSTPASS(!base->StartSend(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!base->StopSend(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // ------------------------------------------------------------------------ - // >> StartSend - // >> StopSend - // - // State: VE initialized, no existing channels + ch = base->CreateChannel(); - TEST(StartSend); - ANL(); - TEST(StopSend); - ANL(); + // call without initialized destination + TEST_MUSTPASS(!base->StartSend(ch)); + MARK(); + TEST_ERROR(VE_DESTINATION_NOT_INITED); - // call without existing channel - TEST_MUSTPASS(!base->StartSend(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!base->StopSend(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + // initialize destination and try again (should work even without existing + // sockets) + TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1")); + TEST_MUSTPASS(base->StartSend(ch)); + MARK(); + SLEEP(100); + // STATE: sockets should now have been created automatically at the first + // transmitted packet should be binded to 33333 and "0.0.0.0" + TEST_MUSTPASS(base->StopSend(ch)); + MARK(); + + base->DeleteChannel(ch); + ch = base->CreateChannel(); + + // try loopback with unique send sockets (closed when channel is deleted or + // new source is set) + TEST_MUSTPASS(base->SetLocalReceiver(ch, 33333)); + TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", 44444)); + TEST_MUSTPASS(base->StartSend(ch)); + MARK(); + TEST_MUSTPASS(base->StartReceive(ch)); + Play(ch, 2000, true, true); + TEST_MUSTPASS(base->StopSend(ch)); + MARK(); + TEST_MUSTPASS(base->StopReceive(ch)); + + base->DeleteChannel(ch); + ANL(); + + // Multi-channel tests + for (i = 0; i < base->MaxNumOfChannels(); i++) { ch = base->CreateChannel(); - - // call without initialized destination - TEST_MUSTPASS(!base->StartSend(ch)); - MARK(); - TEST_ERROR(VE_DESTINATION_NOT_INITED); - - // initialize destination and try again (should work even without existing - // sockets) - TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 33333 + 2*i)); + TEST_MUSTPASS(base->SetSendDestination(ch, 33333 + 2*i, "127.0.0.1")); TEST_MUSTPASS(base->StartSend(ch)); MARK(); - SLEEP(100); - - // STATE: sockets should now have been created automatically at the first - // transmitted packet should be binded to 33333 and "0.0.0.0" - - TEST_MUSTPASS(base->StopSend(ch)); + } + for (i = 0; i < base->MaxNumOfChannels(); i++) { + TEST_MUSTPASS(base->StopSend(i)); MARK(); - - base->DeleteChannel(ch); + base->DeleteChannel(i); + } + for (i = 0; i < base->MaxNumOfChannels(); i++) { ch = base->CreateChannel(); - - // try loopback with unique send sockets (closed when channel is deleted or - // new source is set) - TEST_MUSTPASS(base->SetLocalReceiver(ch, 33333)); - TEST_MUSTPASS(base->SetSendDestination(ch, 33333, "127.0.0.1", 44444)); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 45633 + 2*i)); + TEST_MUSTPASS(base->SetSendDestination(ch, 45633 + 2*i, "127.0.0.1")); TEST_MUSTPASS(base->StartSend(ch)); MARK(); - TEST_MUSTPASS(base->StartReceive(ch)); - Play(ch, 2000, true, true); TEST_MUSTPASS(base->StopSend(ch)); MARK(); - TEST_MUSTPASS(base->StopReceive(ch)); - base->DeleteChannel(ch); - ANL(); + } + ANL(); + AOK(); + ANL(); + ANL(); - // Multi-channel tests - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - ch = base->CreateChannel(); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 33333 + 2*i)); - TEST_MUSTPASS(base->SetSendDestination(ch, 33333 + 2*i, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - MARK(); - } - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - TEST_MUSTPASS(base->StopSend(i)); - MARK(); - base->DeleteChannel(i); - } - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - ch = base->CreateChannel(); - TEST_MUSTPASS(base->SetLocalReceiver(ch, 45633 + 2*i)); - TEST_MUSTPASS(base->SetSendDestination(ch, 45633 + 2*i, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - MARK(); - TEST_MUSTPASS(base->StopSend(ch)); - MARK(); - base->DeleteChannel(ch); - } - ANL(); - AOK(); - ANL(); - ANL(); + // >> end of StartSend/StopSend + // ------------------------------------------------------------------------ - // >> end of StartSend/StopSend - // ------------------------------------------------------------------------ + ////////////////////////////// + // SetNetEQPlayoutMode + // GetNetEQPlayoutMode + TEST(SetNetEQPlayoutMode); + ANL(); + TEST(GetNetEQPlayoutMode); + ANL(); - ////////////////////////////// - // SetNetEQPlayoutMode - // GetNetEQPlayoutMode + NetEqModes mode; - TEST(SetNetEQPlayoutMode); - ANL(); - TEST(GetNetEQPlayoutMode); - ANL(); + ch = base->CreateChannel(); - NetEqModes mode; + // invalid function calls (should fail) + TEST_MUSTPASS(!base->GetNetEQPlayoutMode(ch+1, mode)); + MARK(); + TEST_MUSTPASS(!base->SetNetEQPlayoutMode(ch+1, kNetEqDefault)); + MARK(); + // verify default mode (should be kNetEqDefault) + TEST_MUSTPASS(base->GetNetEQPlayoutMode(ch, mode)); + MARK(); + TEST_MUSTPASS(mode != kNetEqDefault); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqStreaming)); + MARK(); + base->DeleteChannel(ch); + + // ensure that default mode is set as soon as new channel is created + ch = base->CreateChannel(); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(ch, mode)); + MARK(); + TEST_MUSTPASS(mode != kNetEqDefault); + base->DeleteChannel(ch); + + // verify Set/Get for all supported modes and max number of channels + for (i = 0; i < base->MaxNumOfChannels(); i++) { ch = base->CreateChannel(); - // invalid function calls (should fail) - TEST_MUSTPASS(!base->GetNetEQPlayoutMode(ch+1, mode)); + // verify Set/Get for all supported modes + TEST_MUSTPASS(base->SetNetEQPlayoutMode(i, kNetEqDefault)); MARK(); - TEST_MUSTPASS(!base->SetNetEQPlayoutMode(ch+1, kNetEqDefault)); - MARK(); - - // verify default mode (should be kNetEqDefault) - TEST_MUSTPASS(base->GetNetEQPlayoutMode(ch, mode)); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(i, mode)); MARK(); TEST_MUSTPASS(mode != kNetEqDefault); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqStreaming)); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(i, kNetEqStreaming)); MARK(); - base->DeleteChannel(ch); - - // ensure that default mode is set as soon as new channel is created - ch = base->CreateChannel(); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(ch, mode)); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(i, mode)); MARK(); - TEST_MUSTPASS(mode != kNetEqDefault); - base->DeleteChannel(ch); + TEST_MUSTPASS(mode != kNetEqStreaming); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(i, kNetEqFax)); + MARK(); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(i, mode)); + MARK(); + TEST_MUSTPASS(mode != kNetEqFax); + SLEEP(50); + } - // verify Set/Get for all supported modes and max number of channels - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - ch = base->CreateChannel(); + for (i = 0; i < base->MaxNumOfChannels(); i++) { + base->DeleteChannel(i); + } - // verify Set/Get for all supported modes - TEST_MUSTPASS(base->SetNetEQPlayoutMode(i, kNetEqDefault)); - MARK(); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(i, mode)); - MARK(); - TEST_MUSTPASS(mode != kNetEqDefault); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(i, kNetEqStreaming)); - MARK(); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(i, mode)); - MARK(); - TEST_MUSTPASS(mode != kNetEqStreaming); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(i, kNetEqFax)); - MARK(); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(i, mode)); - MARK(); - TEST_MUSTPASS(mode != kNetEqFax); - SLEEP(50); - } + ANL(); + AOK(); + ANL(); + ANL(); - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - base->DeleteChannel(i); - } + ////////////////////////////// + // SetNetEQBGNMode + // GetNetEQBGNMode + TEST(SetNetEQBGNMode); + ANL(); + TEST(GetNetEQBGNMode); + ANL(); - ANL(); - AOK(); - ANL(); - ANL(); + NetEqBgnModes bgnMode; - ////////////////////////////// - // SetNetEQBGNMode - // GetNetEQBGNMode + ch = base->CreateChannel(); - TEST(SetNetEQBGNMode); - ANL(); - TEST(GetNetEQBGNMode); - ANL(); + // invalid function calls (should fail) + TEST_MUSTPASS(!base->GetNetEQBGNMode(ch+1, bgnMode)); + MARK(); + TEST_MUSTPASS(!base->SetNetEQBGNMode(ch+1, kBgnOn)); + MARK(); - NetEqBgnModes bgnMode; + // verify default mode (should be kBgnOn) + TEST_MUSTPASS(base->GetNetEQBGNMode(ch, bgnMode)); + MARK(); + TEST_MUSTPASS(bgnMode != kBgnOn); + base->DeleteChannel(ch); + // ensure that default mode is set as soon as new channel is created + ch = base->CreateChannel(); + TEST_MUSTPASS(base->GetNetEQBGNMode(ch, bgnMode)); + MARK(); + TEST_MUSTPASS(bgnMode != kBgnOn); + base->DeleteChannel(ch); + + // verify Set/Get for all supported modes and max number of channels + for (i = 0; i < base->MaxNumOfChannels(); i++) { ch = base->CreateChannel(); - // invalid function calls (should fail) - TEST_MUSTPASS(!base->GetNetEQBGNMode(ch+1, bgnMode)); + // verify Set/Get for all supported modes + TEST_MUSTPASS(base->SetNetEQBGNMode(i, kBgnOn)); MARK(); - TEST_MUSTPASS(!base->SetNetEQBGNMode(ch+1, kBgnOn)); - MARK(); - - // verify default mode (should be kBgnOn) - TEST_MUSTPASS(base->GetNetEQBGNMode(ch, bgnMode)); + TEST_MUSTPASS(base->GetNetEQBGNMode(i, bgnMode)); MARK(); TEST_MUSTPASS(bgnMode != kBgnOn); - base->DeleteChannel(ch); - - // ensure that default mode is set as soon as new channel is created - ch = base->CreateChannel(); - TEST_MUSTPASS(base->GetNetEQBGNMode(ch, bgnMode)); + TEST_MUSTPASS(base->SetNetEQBGNMode(i, kBgnFade)); MARK(); - TEST_MUSTPASS(bgnMode != kBgnOn); - base->DeleteChannel(ch); - - // verify Set/Get for all supported modes and max number of channels - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - ch = base->CreateChannel(); - - // verify Set/Get for all supported modes - TEST_MUSTPASS(base->SetNetEQBGNMode(i, kBgnOn)); - MARK(); - TEST_MUSTPASS(base->GetNetEQBGNMode(i, bgnMode)); - MARK(); - TEST_MUSTPASS(bgnMode != kBgnOn); - TEST_MUSTPASS(base->SetNetEQBGNMode(i, kBgnFade)); - MARK(); - TEST_MUSTPASS(base->GetNetEQBGNMode(i, bgnMode)); - MARK(); - TEST_MUSTPASS(bgnMode != kBgnFade); - TEST_MUSTPASS(base->SetNetEQBGNMode(i, kBgnOff)); - MARK(); - TEST_MUSTPASS(base->GetNetEQBGNMode(i, bgnMode)); - MARK(); - TEST_MUSTPASS(bgnMode != kBgnOff); - SLEEP(50); - } - - for (i = 0; i < base->MaxNumOfChannels(); i++) - { - base->DeleteChannel(i); - } - - // Verify real-time performance for all playout modes in full duplex - - ch = base->CreateChannel(); - - TEST_MUSTPASS(base->SetLocalReceiver(ch , 12345)); - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); - - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); - - TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqDefault)); + TEST_MUSTPASS(base->GetNetEQBGNMode(i, bgnMode)); MARK(); - TEST_LOG("\nenjoy full duplex using kNetEqDefault playout mode...\n"); - PAUSE - - TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqStreaming)); + TEST_MUSTPASS(bgnMode != kBgnFade); + TEST_MUSTPASS(base->SetNetEQBGNMode(i, kBgnOff)); MARK(); - TEST_LOG("\nenjoy full duplex using kNetEqStreaming playout mode...\n"); - PAUSE - - TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqFax)); + TEST_MUSTPASS(base->GetNetEQBGNMode(i, bgnMode)); MARK(); - TEST_LOG("\nenjoy full duplex using kNetEqFax playout mode...\n"); - PAUSE + TEST_MUSTPASS(bgnMode != kBgnOff); + SLEEP(50); + } - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + for (i = 0; i < base->MaxNumOfChannels(); i++) { + base->DeleteChannel(i); + } - base->DeleteChannel(ch); + // Verify real-time performance for all playout modes in full duplex - ANL(); - AOK(); - ANL(); - ANL(); + ch = base->CreateChannel(); - ///////////////////// - // Full duplex tests + TEST_MUSTPASS(base->SetLocalReceiver(ch , 12345)); + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); - ch = base->CreateChannel(); // We must delete this channel first to be able - // to reuse port 12345 + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); - // start with default case, also test non-default RTCP port + TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqDefault)); + MARK(); + TEST_LOG("\nenjoy full duplex using kNetEqDefault playout mode...\n"); + PAUSE + + TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqStreaming)); + MARK(); + TEST_LOG("\nenjoy full duplex using kNetEqStreaming playout mode...\n"); + PAUSE + + TEST_MUSTPASS(base->SetNetEQPlayoutMode(ch, kNetEqFax)); + MARK(); + TEST_LOG("\nenjoy full duplex using kNetEqFax playout mode...\n"); + PAUSE + + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); + + base->DeleteChannel(ch); + + ANL(); + AOK(); + ANL(); + ANL(); + + ///////////////////// + // Full duplex tests + + ch = base->CreateChannel(); // We must delete this channel first to be able + // to reuse port 12345 + + // start with default case, also test non-default RTCP port #ifdef _TEST_RTP_RTCP_ - TEST_MUSTPASS(rtp->SetRTCP_CNAME(ch, "Johnny")); + TEST_MUSTPASS(rtp->SetRTCP_CNAME(ch, "Johnny")); #endif - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, 12349)); - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1", kVoEDefault, - 12349)); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345, 12349)); + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1", kVoEDefault, + 12349)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_LOG("full duplex is now activated (1)\n"); - TEST_LOG("waiting for RTCP packet...\n"); + TEST_LOG("full duplex is now activated (1)\n"); + TEST_LOG("waiting for RTCP packet...\n"); - SLEEP(7000); // Make sure we get RTCP packet - PAUSE; + SLEEP(7000); // Make sure we get RTCP packet + PAUSE; - // Verify that we got RTCP packet from correct source port + // Verify that we got RTCP packet from correct source port #ifdef _TEST_RTP_RTCP_ - char tmpStr[64] = { 0 }; - TEST_MUSTPASS(rtp->GetRemoteRTCP_CNAME(ch, tmpStr)); - TEST_MUSTPASS(_stricmp("Johnny", tmpStr)); + char tmpStr[64] = { 0 }; + TEST_MUSTPASS(rtp->GetRemoteRTCP_CNAME(ch, tmpStr)); + TEST_MUSTPASS(_stricmp("Johnny", tmpStr)); #endif - int rtpPort(0), rtcpPort(0); - char ipAddr[64] = { 0 }; - TEST_MUSTPASS(netw->GetSourceInfo(ch, rtpPort, rtcpPort, ipAddr)); - TEST_MUSTPASS(12349 != rtcpPort); - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + int rtpPort(0), rtcpPort(0); + char ipAddr[64] = { 0 }; + TEST_MUSTPASS(netw->GetSourceInfo(ch, rtpPort, rtcpPort, ipAddr)); + TEST_MUSTPASS(12349 != rtcpPort); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - // Call StartSend before StartReceive - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); + // Call StartSend before StartReceive + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_LOG("\nfull duplex is now activated (2)\n"); + TEST_LOG("\nfull duplex is now activated (2)\n"); - PAUSE + PAUSE - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - // Try again using same ports - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); + // Try again using same ports + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_LOG("\nfull duplex is now activated (3)\n"); - TEST_LOG("waiting for RTCP packet...\n"); + TEST_LOG("\nfull duplex is now activated (3)\n"); + TEST_LOG("waiting for RTCP packet...\n"); - SLEEP(7000); // Make sure we get RTCP packet - PAUSE + SLEEP(7000); // Make sure we get RTCP packet + PAUSE - // Verify correct RTCP source port - TEST_MUSTPASS(netw->GetSourceInfo(ch, rtpPort, rtcpPort, ipAddr)); - TEST_MUSTPASS(12345+1 != rtcpPort); - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + // Verify correct RTCP source port + TEST_MUSTPASS(netw->GetSourceInfo(ch, rtpPort, rtcpPort, ipAddr)); + TEST_MUSTPASS(12345+1 != rtcpPort); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - base->DeleteChannel(ch); - ch = base->CreateChannel(); + base->DeleteChannel(ch); + ch = base->CreateChannel(); - // Try with extra send socket - TEST_MUSTPASS(base->SetLocalReceiver(ch , 22222)); - TEST_MUSTPASS(base->SetSendDestination(ch, 22222, "127.0.0.1", 11111)); + // Try with extra send socket + TEST_MUSTPASS(base->SetLocalReceiver(ch , 22222)); + TEST_MUSTPASS(base->SetSendDestination(ch, 22222, "127.0.0.1", 11111)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_LOG("\nfull duplex is now activated (4)\n"); + TEST_LOG("\nfull duplex is now activated (4)\n"); - PAUSE + PAUSE - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - // repeat default case starting with a fresh channel + // repeat default case starting with a fresh channel - base->DeleteChannel(ch); - ch = base->CreateChannel(); - TEST_MUSTPASS(base->SetLocalReceiver(ch , 12345)); - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); + base->DeleteChannel(ch); + ch = base->CreateChannel(); + TEST_MUSTPASS(base->SetLocalReceiver(ch , 12345)); + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_LOG("\nfull duplex is now activated (5)\n"); + TEST_LOG("\nfull duplex is now activated (5)\n"); - PAUSE + PAUSE - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - // restart call again - TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_MUSTPASS(base->StartSend(ch)); + // restart call again + TEST_MUSTPASS(base->SetLocalReceiver(ch, 12345)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartSend(ch)); - TEST_LOG("\nfull duplex is now activated (6)\n"); + TEST_LOG("\nfull duplex is now activated (6)\n"); - PAUSE + PAUSE - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - // force sending from new socket - TEST_MUSTPASS(base->SetLocalReceiver(ch , 12345)); - TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1", 12350, - 12359)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_MUSTPASS(base->StartSend(ch)); - TEST_LOG("\nfull duplex is now activated (7)\n"); + // force sending from new socket + TEST_MUSTPASS(base->SetLocalReceiver(ch , 12345)); + TEST_MUSTPASS(base->SetSendDestination(ch, 12345, "127.0.0.1", 12350, + 12359)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartSend(ch)); + TEST_LOG("\nfull duplex is now activated (7)\n"); - PAUSE + PAUSE - // Test getting send settings - TEST_MUSTPASS(base->GetSendDestination(ch, rtpPort, ipAddr, sourcePort, - rtcpPort)); - TEST_MUSTPASS(12345 != rtpPort); - TEST_MUSTPASS(_stricmp("127.0.0.1", ipAddr)); - TEST_MUSTPASS(12350 != sourcePort); - TEST_MUSTPASS(12359 != rtcpPort); + // Test getting send settings + TEST_MUSTPASS(base->GetSendDestination(ch, rtpPort, ipAddr, sourcePort, + rtcpPort)); + TEST_MUSTPASS(12345 != rtpPort); + TEST_MUSTPASS(_stricmp("127.0.0.1", ipAddr)); + TEST_MUSTPASS(12350 != sourcePort); + TEST_MUSTPASS(12359 != rtcpPort); - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - // new channel and new port - ch = base->CreateChannel(); + // new channel and new port + ch = base->CreateChannel(); - TEST_MUSTPASS(base->SetLocalReceiver(ch , 33221)); - TEST_MUSTPASS(base->SetSendDestination(ch, 33221, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(ch , 33221)); + TEST_MUSTPASS(base->SetSendDestination(ch, 33221, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartSend(ch)); - TEST_LOG("\nfull duplex is now activated (8)\n"); + TEST_LOG("\nfull duplex is now activated (8)\n"); - PAUSE + PAUSE - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); - base->DeleteChannel(ch); - ch = base->CreateChannel(); + base->DeleteChannel(ch); + ch = base->CreateChannel(); #ifndef MAC_IPHONE - // bind to local IP and try again - strcpy(localIp, "127.0.0.1"); + // bind to local IP and try again + strcpy(localIp, "127.0.0.1"); #else - localIp = "127.0.0.1"; + localIp = "127.0.0.1"; #endif - TEST_MUSTPASS(base->SetLocalReceiver(ch, 33221, 12349, localIp)); - TEST_MUSTPASS(base->SetSendDestination(ch, 33221, localIp)); + TEST_MUSTPASS(base->SetLocalReceiver(ch, 33221, 12349, localIp)); + TEST_MUSTPASS(base->SetSendDestination(ch, 33221, localIp)); - TEST_MUSTPASS(base->StartReceive(ch)); - TEST_MUSTPASS(base->StartPlayout(ch)); - TEST_MUSTPASS(base->StartSend(ch)); + TEST_MUSTPASS(base->StartReceive(ch)); + TEST_MUSTPASS(base->StartPlayout(ch)); + TEST_MUSTPASS(base->StartSend(ch)); - TEST_LOG("\nfull duplex is now activated (9)\n"); + TEST_LOG("\nfull duplex is now activated (9)\n"); - PAUSE + PAUSE - TEST_MUSTPASS(base->GetLocalReceiver(ch, rtpPort, rtcpPort, ipAddr)); - TEST_MUSTPASS(33221 != rtpPort); - TEST_MUSTPASS(_stricmp(localIp, ipAddr)); - TEST_MUSTPASS(12349 != rtcpPort); + TEST_MUSTPASS(base->GetLocalReceiver(ch, rtpPort, rtcpPort, ipAddr)); + TEST_MUSTPASS(33221 != rtpPort); + TEST_MUSTPASS(_stricmp(localIp, ipAddr)); + TEST_MUSTPASS(12349 != rtcpPort); - ANL(); - AOK(); - ANL(); - ANL(); + ANL(); + AOK(); + ANL(); + ANL(); - ////////////////////// - // Trace filter tests + ////////////////////// + // Trace filter tests #ifdef _USE_EXTENDED_TRACE_ - TEST(SetTraceFilter); ANL(); + TEST(SetTraceFilter); ANL(); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("" - "VoEBase_trace_filter.txt"))); MARK(); - SLEEP(100); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("" + "VoEBase_trace_filter.txt"))); MARK(); + SLEEP(100); - // Test a few different filters, verify in trace file - // Each SetTraceFilter calls should be seen once, no more, no less - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceNone)); MARK(); - SLEEP(300); - // API call and info should NOT be seen in log - TEST_MUSTPASS(base->SetOnHoldStatus(0, true)); MARK(); - // API call and error should NOT be seen in log - TEST_MUSTPASS(!base->SetOnHoldStatus(999, true)); MARK(); + // Test a few different filters, verify in trace file + // Each SetTraceFilter calls should be seen once, no more, no less + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceNone)); MARK(); + SLEEP(300); + // API call and info should NOT be seen in log + TEST_MUSTPASS(base->SetOnHoldStatus(0, true)); MARK(); + // API call and error should NOT be seen in log + TEST_MUSTPASS(!base->SetOnHoldStatus(999, true)); MARK(); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceApiCall | - kTraceCritical | - kTraceError | - kTraceWarning)); MARK(); - SLEEP(300); - // API call should and info should NOT be seen in log - TEST_MUSTPASS(base->SetOnHoldStatus(0, false)); MARK(); - // API call and error should be seen in log - TEST_MUSTPASS(!base->SetOnHoldStatus(999, true)); MARK(); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceApiCall | + kTraceCritical | + kTraceError | + kTraceWarning)); MARK(); + SLEEP(300); + // API call should and info should NOT be seen in log + TEST_MUSTPASS(base->SetOnHoldStatus(0, false)); MARK(); + // API call and error should be seen in log + TEST_MUSTPASS(!base->SetOnHoldStatus(999, true)); MARK(); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceApiCall | kTraceInfo)); - MARK(); - SLEEP(300); - // API call and info should be seen in log - TEST_MUSTPASS(base->SetOnHoldStatus(0, true)); MARK(); - // API call should and error should NOT be seen in log - TEST_MUSTPASS(!base->SetOnHoldStatus(999, true)); MARK(); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceApiCall | kTraceInfo)); + MARK(); + SLEEP(300); + // API call and info should be seen in log + TEST_MUSTPASS(base->SetOnHoldStatus(0, true)); MARK(); + // API call should and error should NOT be seen in log + TEST_MUSTPASS(!base->SetOnHoldStatus(999, true)); MARK(); - // Back to default - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceAll)); MARK(); - SLEEP(300); + // Back to default + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceAll)); MARK(); + SLEEP(300); - AOK(); ANL(); + AOK(); ANL(); #endif - // ------------------------------------------------------------------------ - // >> Multiple instance testing - // - // We should support 8 instances simultaneously - // and at least one should be able to have a call running + // ------------------------------------------------------------------------ + // >> Multiple instance testing + // + // We should support 8 instances simultaneously + // and at least one should be able to have a call running - // One instance is already created - VoiceEngine* instVE[7]; - VoEBase* baseVE[7]; - for (int instNum = 0; instNum < 7; instNum++) - { - instVE[instNum] = VoiceEngine::Create(); - baseVE[instNum] = VoEBase::GetInterface(instVE[instNum]); - TEST_MUSTPASS(baseVE[instNum]->Init()); - TEST_MUSTPASS(baseVE[instNum]->CreateChannel()); - } + // One instance is already created + VoiceEngine* instVE[7]; + VoEBase* baseVE[7]; + for (int instNum = 0; instNum < 7; instNum++) { + instVE[instNum] = VoiceEngine::Create(); + baseVE[instNum] = VoEBase::GetInterface(instVE[instNum]); + TEST_MUSTPASS(baseVE[instNum]->Init()); + TEST_MUSTPASS(baseVE[instNum]->CreateChannel()); + } - TEST_LOG("Created 7 more instances of VE, make sure audio is ok...\n\n"); - PAUSE + TEST_LOG("Created 7 more instances of VE, make sure audio is ok...\n\n"); + PAUSE - for (int instNum = 0; instNum < 7; instNum++) - { - TEST_MUSTPASS(baseVE[instNum]->DeleteChannel(0)); - TEST_MUSTPASS(baseVE[instNum]->Terminate()); - TEST_MUSTPASS(baseVE[instNum]->Release()); - VoiceEngine::Delete(instVE[instNum]); - } + for (int instNum = 0; instNum < 7; instNum++) { + TEST_MUSTPASS(baseVE[instNum]->DeleteChannel(0)); + TEST_MUSTPASS(baseVE[instNum]->Terminate()); + TEST_MUSTPASS(baseVE[instNum]->Release()); + VoiceEngine::Delete(instVE[instNum]); + } - AOK(); - ANL(); + AOK(); + ANL(); - ////////////// - // Close down + ////////////// + // Close down + TEST_MUSTPASS(base->StopSend(ch)); + TEST_MUSTPASS(base->StopPlayout(ch)); + TEST_MUSTPASS(base->StopReceive(ch)); + TEST_MUSTPASS(base->DeleteChannel(ch)); - TEST_MUSTPASS(base->StopSend(ch)); - TEST_MUSTPASS(base->StopPlayout(ch)); - TEST_MUSTPASS(base->StopReceive(ch)); - TEST_MUSTPASS(base->DeleteChannel(ch)); + base->DeleteChannel(0); + TEST_MUSTPASS(base->Terminate()); - - base->DeleteChannel(0); - TEST_MUSTPASS(base->Terminate()); - - return 0; + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestCallReport // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestCallReport() -{ - // Get required sub-API pointers - VoEBase* base = _mgr.BasePtr(); - VoECallReport* report = _mgr.CallReportPtr(); - VoEFile* file = _mgr.FilePtr(); - VoEAudioProcessing* apm = _mgr.APMPtr(); - VoENetwork* netw = _mgr.NetworkPtr(); +int VoEExtendedTest::TestCallReport() { + // Get required sub-API pointers + VoEBase* base = _mgr.BasePtr(); + VoECallReport* report = _mgr.CallReportPtr(); + VoEFile* file = _mgr.FilePtr(); + VoEAudioProcessing* apm = _mgr.APMPtr(); + VoENetwork* netw = _mgr.NetworkPtr(); - PrepareTest("CallReport"); + PrepareTest("CallReport"); - // check if this interface is supported - if (!report) - { - TEST_LOG("VoECallReport is not supported!"); - return -1; - } + // check if this interface is supported + if (!report) { + TEST_LOG("VoECallReport is not supported!"); + return -1; + } #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("VoECallReport_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("VoECallReport_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); - /////////////////////////// - // Actual test starts here + /////////////////////////// + // Actual test starts here + TEST(ResetCallReportStatistics); + ANL(); + TEST_MUSTPASS(!report->ResetCallReportStatistics(-2)); + MARK(); // not OK + TEST_MUSTPASS(!report->ResetCallReportStatistics(1)); + MARK(); // not OK + TEST_MUSTPASS(report->ResetCallReportStatistics(0)); + MARK(); // OK + TEST_MUSTPASS(report->ResetCallReportStatistics(-1)); + MARK(); // OK + AOK(); + ANL(); - TEST(ResetCallReportStatistics); - ANL(); - TEST_MUSTPASS(!report->ResetCallReportStatistics(-2)); - MARK(); // not OK - TEST_MUSTPASS(!report->ResetCallReportStatistics(1)); - MARK(); // not OK - TEST_MUSTPASS(report->ResetCallReportStatistics(0)); - MARK(); // OK - TEST_MUSTPASS(report->ResetCallReportStatistics(-1)); - MARK(); // OK - AOK(); - ANL(); + bool enabled = false; + EchoStatistics echo; + TEST(GetEchoMetricSummary); + ANL(); + TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); + TEST_MUSTPASS(report->GetEchoMetricSummary(echo)); // all outputs will be + // -100 in loopback (skip further tests) + AOK(); + ANL(); - bool enabled = false; - EchoStatistics echo; - TEST(GetEchoMetricSummary); - ANL(); - TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); - TEST_MUSTPASS(report->GetEchoMetricSummary(echo)); // all outputs will be - // -100 in loopback (skip further tests) - AOK(); - ANL(); + // TODO(xians): investigate the cause of test failure before enabling. + /* + StatVal delays; + TEST(GetRoundTripTimeSummary); + ANL(); + // All values should be >=0 since RTCP is now on + TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); + MARK(); + TEST_MUSTPASS(delays.min == -1); + TEST_MUSTPASS(delays.max == -1); + TEST_MUSTPASS(delays.average == -1); + rtp_rtcp->SetRTCPStatus(0, false); + // All values should be -1 since RTCP is off + TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); + MARK(); + TEST_MUSTPASS(delays.min != -1); + TEST_MUSTPASS(delays.max != -1); + TEST_MUSTPASS(delays.average != -1); + rtp_rtcp->SetRTCPStatus(0, true); + AOK(); + ANL(); + */ - // TODO(xians): investigate the cause of test failure before enabling. - /* - StatVal delays; - TEST(GetRoundTripTimeSummary); - ANL(); - // All values should be >=0 since RTCP is now on - TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); - MARK(); - TEST_MUSTPASS(delays.min == -1); - TEST_MUSTPASS(delays.max == -1); - TEST_MUSTPASS(delays.average == -1); - rtp_rtcp->SetRTCPStatus(0, false); - // All values should be -1 since RTCP is off - TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); - MARK(); - TEST_MUSTPASS(delays.min != -1); - TEST_MUSTPASS(delays.max != -1); - TEST_MUSTPASS(delays.average != -1); - rtp_rtcp->SetRTCPStatus(0, true); - AOK(); - ANL(); - */ + int nDead = 0; + int nAlive = 0; + TEST(GetDeadOrAliveSummary); + ANL(); + // All results should be -1 since dead-or-alive is not active + TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive) != -1); + MARK(); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); + SLEEP(2000); + // All results should be >= 0 since dead-or-alive is active + TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive)); + MARK(); + TEST_MUSTPASS(nDead == -1); + TEST_MUSTPASS(nAlive == -1) + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); + AOK(); + ANL(); - int nDead = 0; - int nAlive = 0; - TEST(GetDeadOrAliveSummary); - ANL(); - // All results should be -1 since dead-or-alive is not active - TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive) != -1); - MARK(); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); - SLEEP(2000); - // All results should be >= 0 since dead-or-alive is active - TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive)); - MARK(); - TEST_MUSTPASS(nDead == -1); - TEST_MUSTPASS(nAlive == -1) - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); - AOK(); - ANL(); + TEST(WriteReportToFile); + ANL(); - TEST(WriteReportToFile); - ANL(); + // Greek and Coptic (see http://www.utf8-chartable.de/unicode-utf8-table.pl) + char fileNameUTF8[64]; - // Greek and Coptic (see http://www.utf8-chartable.de/unicode-utf8-table.pl) - char fileNameUTF8[64]; + fileNameUTF8[0] = (char) 0xce; + fileNameUTF8[1] = (char) 0xba; + fileNameUTF8[2] = (char) 0xce; + fileNameUTF8[3] = (char) 0xbb; + fileNameUTF8[4] = (char) 0xce; + fileNameUTF8[5] = (char) 0xbd; + fileNameUTF8[6] = (char) 0xce; + fileNameUTF8[7] = (char) 0xbe; + fileNameUTF8[8] = '.'; + fileNameUTF8[9] = 't'; + fileNameUTF8[10] = 'x'; + fileNameUTF8[11] = 't'; + fileNameUTF8[12] = 0; - fileNameUTF8[0] = (char) 0xce; - fileNameUTF8[1] = (char) 0xba; - fileNameUTF8[2] = (char) 0xce; - fileNameUTF8[3] = (char) 0xbb; - fileNameUTF8[4] = (char) 0xce; - fileNameUTF8[5] = (char) 0xbd; - fileNameUTF8[6] = (char) 0xce; - fileNameUTF8[7] = (char) 0xbe; - fileNameUTF8[8] = '.'; - fileNameUTF8[9] = 't'; - fileNameUTF8[10] = 'x'; - fileNameUTF8[11] = 't'; - fileNameUTF8[12] = 0; + TEST_MUSTPASS(!report->WriteReportToFile(NULL)); + MARK(); + TEST_MUSTPASS(report->WriteReportToFile("call_report.txt")); + MARK(); + TEST_MUSTPASS(report->WriteReportToFile(fileNameUTF8)); + MARK(); // should work with UTF-8 as well (κλνξ.txt) + AOK(); + ANL(); - TEST_MUSTPASS(!report->WriteReportToFile(NULL)); - MARK(); - TEST_MUSTPASS(report->WriteReportToFile("call_report.txt")); - MARK(); - TEST_MUSTPASS(report->WriteReportToFile(fileNameUTF8)); - MARK(); // should work with UTF-8 as well (κλνξ.txt) - AOK(); - ANL(); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); - - return 0; + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestCodec // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestCodec() -{ - PrepareTest("Codec"); +int VoEExtendedTest::TestCodec() { + PrepareTest("Codec"); - VoEBase* base = _mgr.BasePtr(); - VoECodec* codec = _mgr.CodecPtr(); - VoEFile* file = _mgr.FilePtr(); + VoEBase* base = _mgr.BasePtr(); + VoECodec* codec = _mgr.CodecPtr(); + VoEFile* file = _mgr.FilePtr(); #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("VoECodec_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("VoECodec_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); #ifdef WEBRTC_EXTERNAL_TRANSPORT - ExtendedTestTransport* ptrTransport(NULL); - ptrTransport = new ExtendedTestTransport(netw); - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + ExtendedTestTransport* ptrTransport(NULL); + ptrTransport = new ExtendedTestTransport(netw); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); #else - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); #endif - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); - /////////////////////////// - // Actual test starts here + /////////////////////////// + // Actual test starts here - int i; - int err; + int i; + int err; - CodecInst cinst; + CodecInst cinst; - ///////////////////////// - // GetNumOfCodecs + ///////////////////////// + // GetNumOfCodecs - int nCodecs; + int nCodecs; - TEST(GetNumOfCodecs); - ANL(); - // validate #codecs - nCodecs = codec->NumOfCodecs(); - MARK(); - TEST_MUSTPASS(nCodecs < 0); - AOK(); - ANL(); + TEST(GetNumOfCodecs); + ANL(); + // validate #codecs + nCodecs = codec->NumOfCodecs(); + MARK(); + TEST_MUSTPASS(nCodecs < 0); + AOK(); + ANL(); - /////////////////// - // GetCodec + /////////////////// + // GetCodec + TEST(GetCodec); + ANL(); + // scan all supported codecs + nCodecs = codec->NumOfCodecs(); + for (int index = 0; index < nCodecs; index++) { + TEST_MUSTPASS(codec->GetCodec(index, cinst)); + TEST_LOG("[%2d] %16s: fs=%6d, pt=%4d, rate=%7d, ch=%2d, size=%5d", index, cinst.plname, + cinst.plfreq, cinst.pltype, cinst.rate, cinst.channels, cinst.pacsize); + if (cinst.pltype == -1) { + TEST_LOG(" <= NOTE pt=-1\n"); + } else { + ANL(); + } + } - TEST(GetCodec); - ANL(); - // scan all supported codecs - nCodecs = codec->NumOfCodecs(); - for (int index = 0; index < nCodecs; index++) - { - TEST_MUSTPASS(codec->GetCodec(index, cinst)); - TEST_LOG("[%2d] %16s: fs=%6d, pt=%4d, rate=%7d, ch=%2d, size=%5d", - index, cinst.plname, cinst.plfreq, cinst.pltype, cinst.rate, - cinst.channels, cinst.pacsize); - if (cinst.pltype == -1) - { - TEST_LOG(" <= NOTE pt=-1\n"); - } else - { - ANL(); - } + // ensure that an invalid index parameter is detected + TEST_MUSTPASS(-1 != codec->GetCodec(-1, cinst)); + nCodecs = codec->NumOfCodecs(); + TEST_MUSTPASS(-1 != codec->GetCodec(nCodecs, cinst)); + MARK(); + // ensure that error code is VE_INVALID_LISTNR + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_LISTNR); + AOK(); + ANL(); + + /////////////////////// + // GetSendCodec + TEST(GetSendCodec); + ANL(); + + CodecInst defaultCodec; + + // check the channel parameter + int nMaxChannels(base->MaxNumOfChannels()); + TEST_MUSTPASS(-1 != codec->GetSendCodec(nMaxChannels-1, cinst)); + MARK(); // not created + TEST_MUSTPASS(-1 != codec->GetSendCodec(nMaxChannels, cinst)); + MARK(); // out of range + TEST_MUSTPASS(-1 != codec->GetSendCodec(-1, cinst)); + MARK(); // out of range + TEST_MUSTPASS(codec->GetSendCodec(0, cinst)); + MARK(); // OK + + nCodecs = codec->NumOfCodecs(); + for (int index = 0; index < nCodecs; index++) { + TEST_MUSTPASS(codec->GetCodec(index, defaultCodec)); + if (codec->SetSendCodec(0, defaultCodec) == 0) { + TEST_MUSTPASS(codec->GetSendCodec(0, cinst)); + MARK(); + //TEST_LOG("[%2d] %s: fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", + // index, cinst.plname, cinst.plfreq, cinst.pltype, cinst.rate, + // cinst.channels, cinst.pacsize); + TEST_MUSTPASS(cinst.pacsize != defaultCodec.pacsize); + TEST_MUSTPASS(cinst.plfreq != defaultCodec.plfreq); + TEST_MUSTPASS(cinst.pltype != defaultCodec.pltype); + TEST_MUSTPASS(cinst.rate != defaultCodec.rate); + TEST_MUSTPASS(cinst.channels != defaultCodec.channels); + } + } + + ANL(); + AOK(); + ANL(); + + /////////////////////// + // SetSendCodec + TEST(SetSendCodec); + ANL(); + + // --- Scan all supported codecs and set default parameters + + nCodecs = codec->NumOfCodecs(); + for (int index = 0; index < nCodecs; index++) { + // Get default (ACM) settings + TEST_MUSTPASS(codec->GetCodec(index, cinst)); + defaultCodec = cinst; + TEST_LOG("[%2d] %s (default): fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", + index, cinst.plname, cinst.plfreq, cinst.pltype, cinst.rate, + cinst.channels, cinst.pacsize); + + // Verify invalid codec names + if (!_stricmp("CN", cinst.plname) || !_stricmp("telephone-event", + cinst.plname) + || !_stricmp("red", cinst.plname)) { + // default settings for invalid payload names (should give + // VE_INVALID_PLNAME) + TEST_MUSTPASS(!codec->SetSendCodec(0, cinst)); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + continue; } - // ensure that an invalid index parameter is detected - TEST_MUSTPASS(-1 != codec->GetCodec(-1, cinst)); - nCodecs = codec->NumOfCodecs(); - TEST_MUSTPASS(-1 != codec->GetCodec(nCodecs, cinst)); - MARK(); - // ensure that error code is VE_INVALID_LISTNR - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_LISTNR); - AOK(); - ANL(); - - /////////////////////// - // GetSendCodec - - TEST(GetSendCodec); - ANL(); - - CodecInst defaultCodec; - - // check the channel parameter - int nMaxChannels(base->MaxNumOfChannels()); - TEST_MUSTPASS(-1 != codec->GetSendCodec(nMaxChannels-1, cinst)); - MARK(); // not created - TEST_MUSTPASS(-1 != codec->GetSendCodec(nMaxChannels, cinst)); - MARK(); // out of range - TEST_MUSTPASS(-1 != codec->GetSendCodec(-1, cinst)); - MARK(); // out of range - TEST_MUSTPASS(codec->GetSendCodec(0, cinst)); - MARK(); // OK - - nCodecs = codec->NumOfCodecs(); - for (int index = 0; index < nCodecs; index++) - { - TEST_MUSTPASS(codec->GetCodec(index, defaultCodec)); - if (codec->SetSendCodec(0, defaultCodec) == 0) - { - TEST_MUSTPASS(codec->GetSendCodec(0, cinst)); - MARK(); - //TEST_LOG("[%2d] %s: fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", - // index, cinst.plname, cinst.plfreq, cinst.pltype, cinst.rate, - // cinst.channels, cinst.pacsize); - TEST_MUSTPASS(cinst.pacsize != defaultCodec.pacsize); - TEST_MUSTPASS(cinst.plfreq != defaultCodec.plfreq); - TEST_MUSTPASS(cinst.pltype != defaultCodec.pltype); - TEST_MUSTPASS(cinst.rate != defaultCodec.rate); - TEST_MUSTPASS(cinst.channels != defaultCodec.channels); - } + // If we build the ACM with more codecs than we have payload types, + // some codecs will be given -1 as default payload type. This is a fix + // to ensure that we can complete these tests also for this case. + if (cinst.pltype == -1) { + cinst.pltype = 97; } - ANL(); - AOK(); - ANL(); + // --- Default settings + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - /////////////////////// - // SetSendCodec + // --- Packet size + TEST_LOG("\npacsize : "); - TEST(SetSendCodec); - ANL(); + for (int pacsize = 80; pacsize < 1440; pacsize += 80) { + cinst.pacsize = pacsize; + if (-1 != codec->SetSendCodec(0, cinst)) { + // log valid packet size + TEST_LOG("%d ", pacsize); + } else { + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } + } + cinst.pacsize = defaultCodec.pacsize; - // --- Scan all supported codecs and set default parameters + // --- Audio channels (1/mono or 2/stereo) + TEST_LOG("\nchannels: "); + for (int channels = 1; channels < 4; channels++) { + cinst.channels = channels; + if (-1 != codec->SetSendCodec(0, cinst)) { + // valid channels (only 1 should be OK) + TEST_LOG("%d ", channels); + } else { + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } + } + cinst.channels = defaultCodec.channels; - nCodecs = codec->NumOfCodecs(); - for (int index = 0; index < nCodecs; index++) + // --- Payload frequency + TEST_LOG("\nplfreq : "); + cinst.plfreq = defaultCodec.plfreq; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.plfreq); + + // --- Payload name + + strcpy(cinst.plname, "INVALID"); + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) { - // Get default (ACM) settings - TEST_MUSTPASS(codec->GetCodec(index, cinst)); - defaultCodec = cinst; - TEST_LOG("[%2d] %s (default): fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", - index, cinst.plname, cinst.plfreq, cinst.pltype, cinst.rate, - cinst.channels, cinst.pacsize); + // ensure that error code is VE_INVALID_PLNAME + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } - // Verify invalid codec names - if (!_stricmp("CN", cinst.plname) || !_stricmp("telephone-event", - cinst.plname) - || !_stricmp("red", cinst.plname)) - { - // default settings for invalid payload names (should give - // VE_INVALID_PLNAME) - TEST_MUSTPASS(!codec->SetSendCodec(0, cinst)); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - continue; + // restore default plname + strcpy(cinst.plname, defaultCodec.plname); + + // --- Payload type (dynamic range is 96-127) + TEST_LOG("\npltype : "); + // All PT should be OK, test a few different + cinst.pltype = defaultCodec.pltype; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.pltype); + cinst.pltype = defaultCodec.pltype + 1; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.pltype); + const int valid_pltypes[4] = { 0, 96, 117, 127 }; + for (i = 0; i < static_cast (sizeof(valid_pltypes) / sizeof(int)); i++) { + cinst.pltype = valid_pltypes[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.pltype); + } + // Restore default + cinst.pltype = defaultCodec.pltype; + + // --- Codec rate + TEST_LOG("\nrate : "); + if (_stricmp("isac", cinst.plname) == 0) { + // ISAC + if (cinst.plfreq == 16000) { + int valid_rates[3] = { -1, 10000, 32000 }; + // failed in RegisterPayload when rate is 32000 + for (i = 0; i < static_cast (sizeof(valid_rates) / sizeof(int)); i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); } - - // If we build the ACM with more codecs than we have payload types, - // some codecs will be given -1 as default payload type. This is a fix - // to ensure that we can complete these tests also for this case. - if (cinst.pltype == -1) - { - cinst.pltype = 97; - } - - // --- Default settings - - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - - // --- Packet size - - TEST_LOG("\npacsize : "); - - for (int pacsize = 80; pacsize < 1440; pacsize += 80) - { - cinst.pacsize = pacsize; - if (-1 != codec->SetSendCodec(0, cinst)) - { - // log valid packet size - TEST_LOG("%d ", pacsize); - } else - { - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - } - cinst.pacsize = defaultCodec.pacsize; - - // --- Audio channels (1/mono or 2/stereo) - - TEST_LOG("\nchannels: "); - for (int channels = 1; channels < 4; channels++) - { - cinst.channels = channels; - if (-1 != codec->SetSendCodec(0, cinst)) - { - // valid channels (only 1 should be OK) - TEST_LOG("%d ", channels); - } else - { - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - } - cinst.channels = defaultCodec.channels; - - // --- Payload frequency - - TEST_LOG("\nplfreq : "); - cinst.plfreq = defaultCodec.plfreq; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.plfreq); - - // --- Payload name - - strcpy(cinst.plname, "INVALID"); + cinst.rate = 0; // invalid TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) { - // ensure that error code is VE_INVALID_PLNAME - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - - // restore default plname - strcpy(cinst.plname, defaultCodec.plname); - - // --- Payload type (dynamic range is 96-127) - - TEST_LOG("\npltype : "); - // All PT should be OK, test a few different - cinst.pltype = defaultCodec.pltype; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.pltype); - cinst.pltype = defaultCodec.pltype + 1; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.pltype); - const int valid_pltypes[4] = { 0, 96, 117, 127 }; - for (i = 0; - i < static_cast (sizeof(valid_pltypes) / sizeof(int)); - i++) - { - cinst.pltype = valid_pltypes[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.pltype); - } - // Restore default - cinst.pltype = defaultCodec.pltype; - - // --- Codec rate - - TEST_LOG("\nrate : "); - if (_stricmp("isac", cinst.plname) == 0) - { - // ISAC - if (cinst.plfreq == 16000) - { - int valid_rates[3] = { -1, 10000, 32000 }; - // failed in RegisterPayload when rate is 32000 - for (i = 0; i < static_cast (sizeof(valid_rates) - / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - cinst.rate = 0; // invalid - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) - { - // ensure that error code is VE_CANNOT_SET_SEND_CODEC - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - ANL(); - } else //ISACSWB - { - // rate changing fails in RegisterPayload - int valid_rates[8] = { -1, 10000, 25000, 32000, 35000, 45000, - 50000, 52000 }; - for (i = 0; i < static_cast (sizeof(valid_rates) - / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - int invalid_rates[3] = { 0, 5000, 57000 }; // invalid - for (i = 0; i < static_cast (sizeof(invalid_rates) - / sizeof(int)); i++) - { - cinst.rate = invalid_rates[i]; - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) - { - // ensure that error code is VE_CANNOT_SET_SEND_CODEC - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - } - ANL(); - } - } - else if (_stricmp("amr", cinst.plname) == 0) - { - int valid_rates[8] = { 4750, 5150, 5900, 6700, 7400, 7950, 10200, - 12200 }; - for (i = 0; i - < static_cast (sizeof(valid_rates) / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - ANL(); - } else if (_stricmp("g7291", cinst.plname) == 0) - { - int valid_rates[12] = { 8000, 12000, 14000, 16000, 18000, 20000, - 22000, 24000, 26000, 28000, 30000, 32000 }; - for (i = 0; i - < static_cast (sizeof(valid_rates) / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - ANL(); - } else if (_stricmp("amr-wb", cinst.plname) == 0) - { - int valid_rates[9] = { 7000, 9000, 12000, 14000, 16000, 18000, - 20000, 23000, 24000 }; - for (i = 0; i - < static_cast (sizeof(valid_rates) / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - TEST_LOG(" <=> "); - ANL(); - } else if (_stricmp("speex", cinst.plname) == 0) - { - // Valid speex rates are > 2000, testing some of them here - int valid_rates[9] = { 2001, 4000, 7000, 11000, 15000, 20000, - 25000, 33000, 46000 }; - for (i = 0; i - < static_cast (sizeof(valid_rates) / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - cinst.rate = 2000; // invalid - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) - { - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - ANL(); - } else if (_stricmp("silk", cinst.plname) == 0) - { - // Valid Silk rates are 6000 - 40000, listing some of them here - int valid_rates[7] = { 6000, 10000, 15000, 20000, 25000, 32000, - 40000 }; - for (i = 0; i - < static_cast (sizeof(valid_rates) / sizeof(int)); i++) - { - cinst.rate = valid_rates[i]; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - } - cinst.rate = 5999; // invalid - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) - { - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - cinst.rate = 40001; // invalid - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) - { - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } - ANL(); - } else - { - // Use default rate for all other codecs. - cinst.rate = defaultCodec.rate; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("%d ", cinst.rate); - cinst.rate = defaultCodec.rate + 17; - TEST_MUSTPASS(!codec->SetSendCodec(0, cinst)); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - ANL(); - } - cinst.rate = defaultCodec.rate; - - // run some extra tests for L16 - if (_stricmp("l16", cinst.plname) == 0) - { - if (8000 == cinst.plfreq) - { - // valid pacsizes: 80, 160, 240, 320 - cinst.pacsize = 480; // only supported in combination with 16kHz - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - cinst.pacsize = 640; // only supported in combination with 16kHz - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } else - { - // valid pacsizes: 160, 320, 480, 640 - cinst.pacsize = 80; // only supported in combination with 8kHz - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - cinst.pacsize = 240; // only supported in combination with 8kHz - TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - } + // ensure that error code is VE_CANNOT_SET_SEND_CODEC + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); } ANL(); - } // for (int index = 0; index < nCodecs; index++) - - // restore PCMU - const CodecInst tmp = { 0, "PCMU", 8000, 160, 1, 64000 }; - TEST_MUSTPASS(codec->SetSendCodec(0, tmp)); - - ANL(); - AOK(); - ANL(); - - /////// - // VAD - - const int VADSleep = 0; - - bool disabledDTX; - VadModes mode; - bool enabled; - - // verify default settings (should be OFF, kVadConventional and DTX enabled) - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(mode != kVadConventional); - TEST_MUSTPASS(disabledDTX != true); - - // enable default VAD settings - TEST_MUSTPASS(codec->SetVADStatus(0, true)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(mode != kVadConventional); - TEST_MUSTPASS(disabledDTX != false); - SLEEP(VADSleep); - - // set kVadConventional mode - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadConventional)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(mode != kVadConventional); - SLEEP(VADSleep); - - // set kVadAggressiveLow mode - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveLow)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(mode != kVadAggressiveLow); - SLEEP(VADSleep); - - // set kVadAggressiveMid mode - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(mode != kVadAggressiveMid); - SLEEP(VADSleep); - - // set kVadAggressiveMid mode - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(mode != kVadAggressiveHigh); - SLEEP(VADSleep); - - // turn DTX OFF (audio should not be affected by VAD decisions) - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadConventional, true)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(disabledDTX != true); - SLEEP(VADSleep); - - // try to enable DTX again (should fail since VAD is disabled) - TEST_MUSTPASS(codec->SetVADStatus(0, false, kVadConventional, false)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(disabledDTX == false); - SLEEP(VADSleep); - - // disable VAD - TEST_MUSTPASS(codec->SetVADStatus(0, false)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(enabled != false); - SLEEP(VADSleep); - - // restore default VAD - TEST_MUSTPASS(codec->SetVADStatus(0, true)); - TEST_MUSTPASS(codec->SetVADStatus(0, false)); - TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); - TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, - disabledDTX); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(mode != kVadConventional); - TEST_MUSTPASS(disabledDTX != true); - SLEEP(VADSleep); - - AOK(); - ANL(); - ANL(); - - ////////////////////// - // GetRecCodec - - TEST(GetRecCodec); - ANL(); - - // stop all streaming first - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - - // start loopback streaming (PCMU is default) -#ifndef WEBRTC_EXTERNAL_TRANSPORT - TEST_MUSTPASS(base->SetSendDestination(0,8000,"127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(0,8000)); -#endif - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(100); // ensure that at least one packets is received - - // scan all supported and valid codecs - CodecInst newCodec; - for (i = 0; i < codec->NumOfCodecs(); i++) - { - TEST_MUSTPASS(codec->GetCodec(i, newCodec)); - // test all valid send codecs - if (!_stricmp("red", newCodec.plname) || !_stricmp("cn", - newCodec.plname) - || !_stricmp("telephone-event", newCodec.plname)) - { - continue; // Ignore these + } else //ISACSWB + { + // rate changing fails in RegisterPayload + int valid_rates[8] = { -1, 10000, 25000, 32000, 35000, 45000, 50000, 52000 }; + for (i = 0; i < static_cast (sizeof(valid_rates) / sizeof(int)); i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); } - if (-1 != codec->SetSendCodec(0, newCodec)) - { - SLEEP(150); - // verify correct detection - TEST_MUSTPASS(codec->GetRecCodec(0, cinst)); - TEST_LOG("%s %s ", newCodec.plname, cinst.plname); - TEST_MUSTPASS(_stricmp(newCodec.plname, cinst.plname) != 0); - TEST_MUSTPASS(cinst.pltype != newCodec.pltype); - TEST_MUSTPASS(cinst.plfreq != newCodec.plfreq); + int invalid_rates[3] = { 0, 5000, 57000 }; // invalid + for (i = 0; i < static_cast (sizeof(invalid_rates) / sizeof(int)); i++) { + cinst.rate = invalid_rates[i]; + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) + { + // ensure that error code is VE_CANNOT_SET_SEND_CODEC + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } } + ANL(); + } + } else if (_stricmp("amr", cinst.plname) == 0) { + int valid_rates[8] = { 4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200 }; + for (i = 0; + i < static_cast (sizeof(valid_rates) / sizeof(int)); + i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); + } + ANL(); + } else if (_stricmp("g7291", cinst.plname) == 0) { + int valid_rates[12] = { 8000, 12000, 14000, 16000, 18000, 20000, 22000, + 24000, 26000, 28000, 30000, 32000 }; + for (i = 0; + i < static_cast (sizeof(valid_rates) / sizeof(int)); + i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); + } + ANL(); + } else if (_stricmp("amr-wb", cinst.plname) == 0) { + int valid_rates[9] = { 7000, 9000, 12000, 14000, 16000, 18000, 20000, + 23000, 24000 }; + for (i = 0; + i < static_cast (sizeof(valid_rates) / sizeof(int)); + i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); + } + TEST_LOG(" <=> "); + ANL(); + } else if (_stricmp("speex", cinst.plname) == 0) { + // Valid speex rates are > 2000, testing some of them here + int valid_rates[9] = { 2001, 4000, 7000, 11000, 15000, 20000, 25000, + 33000, 46000 }; + for (i = 0; + i < static_cast (sizeof(valid_rates) / sizeof(int)); + i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); + } + cinst.rate = 2000; // invalid + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) + { + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } + ANL(); + } else if (_stricmp("silk", cinst.plname) == 0) { + // Valid Silk rates are 6000 - 40000, listing some of them here + int valid_rates[7] = { 6000, 10000, 15000, 20000, 25000, 32000, 40000 }; + for (i = 0; + i < static_cast (sizeof(valid_rates) / sizeof(int)); + i++) { + cinst.rate = valid_rates[i]; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); + } + cinst.rate = 5999; // invalid + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) + { + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } + cinst.rate = 40001; // invalid + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)) + { + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } + ANL(); + } else { + // Use default rate for all other codecs. + cinst.rate = defaultCodec.rate; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_LOG("%d ", cinst.rate); + cinst.rate = defaultCodec.rate + 17; + TEST_MUSTPASS(!codec->SetSendCodec(0, cinst)); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + ANL(); } + cinst.rate = defaultCodec.rate; - // stop streaming - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); + // run some extra tests for L16 + if (_stricmp("l16", cinst.plname) == 0) { + if (8000 == cinst.plfreq) { + // valid pacsizes: 80, 160, 240, 320 + cinst.pacsize = 480; // only supported in combination with 16kHz + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + cinst.pacsize = 640; // only supported in combination with 16kHz + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } else { + // valid pacsizes: 160, 320, 480, 640 + cinst.pacsize = 80; // only supported in combination with 8kHz + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + cinst.pacsize = 240; // only supported in combination with 8kHz + TEST_MUSTPASS(-1 != codec->SetSendCodec(0, cinst)); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + } + } + ANL(); + } // for (int index = 0; index < nCodecs; index++) - ANL(); - AOK(); - ANL(); - ANL(); + // restore PCMU + const CodecInst tmp = { 0, "PCMU", 8000, 160, 1, 64000 }; + TEST_MUSTPASS(codec->SetSendCodec(0, tmp)); + + ANL(); + AOK(); + ANL(); + + /////// + // VAD + + const int VADSleep = 0; + + bool disabledDTX; + VadModes mode; + bool enabled; + + // verify default settings (should be OFF, kVadConventional and DTX enabled) + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(mode != kVadConventional); + TEST_MUSTPASS(disabledDTX != true); + + // enable default VAD settings + TEST_MUSTPASS(codec->SetVADStatus(0, true)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(mode != kVadConventional); + TEST_MUSTPASS(disabledDTX != false); + SLEEP(VADSleep); + + // set kVadConventional mode + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadConventional)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(mode != kVadConventional); + SLEEP(VADSleep); + + // set kVadAggressiveLow mode + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveLow)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(mode != kVadAggressiveLow); + SLEEP(VADSleep); + + // set kVadAggressiveMid mode + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(mode != kVadAggressiveMid); + SLEEP(VADSleep); + + // set kVadAggressiveMid mode + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(mode != kVadAggressiveHigh); + SLEEP(VADSleep); + + // turn DTX OFF (audio should not be affected by VAD decisions) + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadConventional, true)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(disabledDTX != true); + SLEEP(VADSleep); + + // try to enable DTX again (should fail since VAD is disabled) + TEST_MUSTPASS(codec->SetVADStatus(0, false, kVadConventional, false)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(disabledDTX == false); + SLEEP(VADSleep); + + // disable VAD + TEST_MUSTPASS(codec->SetVADStatus(0, false)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(enabled != false); + SLEEP(VADSleep); + + // restore default VAD + TEST_MUSTPASS(codec->SetVADStatus(0, true)); + TEST_MUSTPASS(codec->SetVADStatus(0, false)); + TEST_MUSTPASS(codec->GetVADStatus(0, enabled, mode, disabledDTX)); + TEST_LOG("VAD: enabled=%d, mode=%d, disabledDTX=%d\n", enabled, mode, + disabledDTX); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(mode != kVadConventional); + TEST_MUSTPASS(disabledDTX != true); + SLEEP(VADSleep); + + AOK(); + ANL(); + ANL(); + + ////////////////////// + // GetRecCodec + TEST(GetRecCodec); + ANL(); + + // stop all streaming first + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + + // start loopback streaming (PCMU is default) +#ifndef WEBRTC_EXTERNAL_TRANSPORT + TEST_MUSTPASS(base->SetSendDestination(0,8000,"127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(0,8000)); +#endif + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(100); // ensure that at least one packets is received + + // scan all supported and valid codecs + CodecInst newCodec; + for (i = 0; i < codec->NumOfCodecs(); i++) { + TEST_MUSTPASS(codec->GetCodec(i, newCodec)); + // test all valid send codecs + if (!_stricmp("red", newCodec.plname) || !_stricmp("cn", newCodec.plname) + || !_stricmp("telephone-event", newCodec.plname)) { + continue; // Ignore these + } + if (-1 != codec->SetSendCodec(0, newCodec)) { + SLEEP(150); + // verify correct detection + TEST_MUSTPASS(codec->GetRecCodec(0, cinst)); + TEST_LOG("%s %s ", newCodec.plname, cinst.plname); + TEST_MUSTPASS(_stricmp(newCodec.plname, cinst.plname) != 0); + TEST_MUSTPASS(cinst.pltype != newCodec.pltype); + TEST_MUSTPASS(cinst.plfreq != newCodec.plfreq); + } + } + + // stop streaming + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + + ANL(); + AOK(); + ANL(); + ANL(); #ifdef WEBRTC_CODEC_GSMAMR - ////////////////////////// - // SetAMREncFormat + ////////////////////////// + // SetAMREncFormat - // Fresh channel - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // Fresh channel + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); - TEST(SetAMREncFormat); ANL(); + TEST(SetAMREncFormat); ANL(); - //set another codec which is not AMR - TEST_MUSTPASS(codec->GetCodec(0, cinst)); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - //try to change the encode format, tests should fail - TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0)); MARK(); - TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0, kRfc3267BwEfficient)); - MARK(); - TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0, kRfc3267OctetAligned)); - MARK(); - TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0, kRfc3267FileStorage)); - MARK(); + //set another codec which is not AMR + TEST_MUSTPASS(codec->GetCodec(0, cinst)); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + //try to change the encode format, tests should fail + TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0)); MARK(); + TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0, kRfc3267BwEfficient)); + MARK(); + TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0, kRfc3267OctetAligned)); + MARK(); + TEST_MUSTPASS(-1 != codec->SetAMREncFormat(0, kRfc3267FileStorage)); + MARK(); - //set AMR as encoder - strcpy(cinst.plname,"AMR"); - cinst.channels=1; cinst.plfreq=8000; cinst.rate=12200; cinst.pltype=112; - cinst.pacsize=160; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - //try to change the encode format, tests should pass - TEST_MUSTPASS(codec->SetAMREncFormat(0)); MARK(); - TEST_MUSTPASS(codec->SetAMREncFormat(0, kRfc3267BwEfficient)); MARK(); - TEST_MUSTPASS(codec->SetAMREncFormat(0, kRfc3267OctetAligned)); MARK(); - TEST_MUSTPASS(codec->SetAMREncFormat(0, kRfc3267FileStorage)); MARK(); - TEST_MUSTPASS(-1 != codec->SetAMREncFormat(-1)); MARK(); - TEST_MUSTPASS(codec->SetAMREncFormat(0)); MARK(); // restore default + //set AMR as encoder + strcpy(cinst.plname,"AMR"); + cinst.channels=1; cinst.plfreq=8000; cinst.rate=12200; cinst.pltype=112; + cinst.pacsize=160; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + //try to change the encode format, tests should pass + TEST_MUSTPASS(codec->SetAMREncFormat(0)); MARK(); + TEST_MUSTPASS(codec->SetAMREncFormat(0, kRfc3267BwEfficient)); MARK(); + TEST_MUSTPASS(codec->SetAMREncFormat(0, kRfc3267OctetAligned)); MARK(); + TEST_MUSTPASS(codec->SetAMREncFormat(0, kRfc3267FileStorage)); MARK(); + TEST_MUSTPASS(-1 != codec->SetAMREncFormat(-1)); MARK(); + TEST_MUSTPASS(codec->SetAMREncFormat(0)); MARK(); // restore default - ANL(); - AOK(); - ANL(); + ANL(); + AOK(); + ANL(); - ////////////////////////// - // SetAMRDecFormat + ////////////////////////// + // SetAMRDecFormat - TEST(SetAMRDecFormat); ANL(); + TEST(SetAMRDecFormat); ANL(); - // It should not be possible to set AMR dec format before valid AMR decoder - // is registered - TEST_MUSTPASS(!codec->SetAMRDecFormat(0)); MARK(); - err = base->LastError(); - TEST_MUSTPASS(err != VE_AUDIO_CODING_MODULE_ERROR); + // It should not be possible to set AMR dec format before valid AMR decoder + // is registered + TEST_MUSTPASS(!codec->SetAMRDecFormat(0)); MARK(); + err = base->LastError(); + TEST_MUSTPASS(err != VE_AUDIO_CODING_MODULE_ERROR); - // Ensure that ACM::RegisterReceiveCodec(AMR) is called - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + // Ensure that ACM::RegisterReceiveCodec(AMR) is called + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - // All these tests should now pass - TEST_MUSTPASS(codec->SetAMRDecFormat(0)); MARK(); - TEST_MUSTPASS(codec->SetAMRDecFormat(0, kRfc3267BwEfficient)); MARK(); - TEST_MUSTPASS(codec->SetAMRDecFormat(0, kRfc3267OctetAligned)); MARK(); - TEST_MUSTPASS(codec->SetAMRDecFormat(0, kRfc3267FileStorage)); MARK(); - TEST_MUSTPASS(-1 != codec->SetAMRDecFormat(-1)); MARK(); - TEST_MUSTPASS(codec->SetAMRDecFormat(0)); MARK(); // restore default + // All these tests should now pass + TEST_MUSTPASS(codec->SetAMRDecFormat(0)); MARK(); + TEST_MUSTPASS(codec->SetAMRDecFormat(0, kRfc3267BwEfficient)); MARK(); + TEST_MUSTPASS(codec->SetAMRDecFormat(0, kRfc3267OctetAligned)); MARK(); + TEST_MUSTPASS(codec->SetAMRDecFormat(0, kRfc3267FileStorage)); MARK(); + TEST_MUSTPASS(-1 != codec->SetAMRDecFormat(-1)); MARK(); + TEST_MUSTPASS(codec->SetAMRDecFormat(0)); MARK(); // restore default - ANL(); - AOK(); - ANL(); + ANL(); + AOK(); + ANL(); #endif // #ifdef WEBRTC_CODEC_GSMAMR - #ifdef WEBRTC_CODEC_GSMAMRWB - ////////////////////////// - // SetAMRWbEncFormat + ////////////////////////// + // SetAMRWbEncFormat - // Fresh channel - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // Fresh channel + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); - TEST(SetAMRWbEncFormat); ANL(); + TEST(SetAMRWbEncFormat); ANL(); - //set another codec which is not AMR-wb - TEST_MUSTPASS(codec->GetCodec(0, cinst)); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - //try to change the encode format, tests should fail - TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0)); MARK(); - TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); - MARK(); - TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); - MARK(); - TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0, kRfc3267FileStorage)); - MARK(); + //set another codec which is not AMR-wb + TEST_MUSTPASS(codec->GetCodec(0, cinst)); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + //try to change the encode format, tests should fail + TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0)); MARK(); + TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); + MARK(); + TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); + MARK(); + TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(0, kRfc3267FileStorage)); + MARK(); - //set AMR-wb as encoder - strcpy(cinst.plname,"AMR-WB"); - cinst.channels=1; cinst.plfreq=16000; cinst.rate=20000; - cinst.pltype=112; cinst.pacsize=320; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - //try to change the encode format, tests should pass - TEST_MUSTPASS(codec->SetAMRWbEncFormat(0)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbEncFormat(0, kRfc3267FileStorage)); MARK(); - TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(-1)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbEncFormat(0)); MARK(); // restore default + //set AMR-wb as encoder + strcpy(cinst.plname,"AMR-WB"); + cinst.channels=1; cinst.plfreq=16000; cinst.rate=20000; + cinst.pltype=112; cinst.pacsize=320; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + //try to change the encode format, tests should pass + TEST_MUSTPASS(codec->SetAMRWbEncFormat(0)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbEncFormat(0, kRfc3267FileStorage)); MARK(); + TEST_MUSTPASS(-1 != codec->SetAMRWbEncFormat(-1)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbEncFormat(0)); MARK(); // restore default - ANL(); - AOK(); - ANL(); + ANL(); + AOK(); + ANL(); - ////////////////////////// - // SetAMRDecFormat + ////////////////////////// + // SetAMRDecFormat - TEST(SetAMRWbDecFormat); ANL(); + TEST(SetAMRWbDecFormat); ANL(); - // It should not be possible to set AMR dec format before valid AMR decoder - // is registered - TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0)); MARK(); - err = base->LastError(); - TEST_MUSTPASS(err != VE_AUDIO_CODING_MODULE_ERROR); + // It should not be possible to set AMR dec format before valid AMR decoder + // is registered + TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0)); MARK(); + err = base->LastError(); + TEST_MUSTPASS(err != VE_AUDIO_CODING_MODULE_ERROR); - // Ensure that ACM::RegisterReceiveCodec(AMR) is called - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + // Ensure that ACM::RegisterReceiveCodec(AMR) is called + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - // All these tests should now pass - TEST_MUSTPASS(codec->SetAMRWbDecFormat(0)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbDecFormat(0, kRfc3267BwEfficient)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbDecFormat(0, kRfc3267OctetAligned)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbDecFormat(0, kRfc3267FileStorage)); MARK(); - TEST_MUSTPASS(-1 != codec->SetAMRWbDecFormat(-1)); MARK(); - TEST_MUSTPASS(codec->SetAMRWbDecFormat(0)); MARK(); // restore default + // All these tests should now pass + TEST_MUSTPASS(codec->SetAMRWbDecFormat(0)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbDecFormat(0, kRfc3267BwEfficient)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbDecFormat(0, kRfc3267OctetAligned)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbDecFormat(0, kRfc3267FileStorage)); MARK(); + TEST_MUSTPASS(-1 != codec->SetAMRWbDecFormat(-1)); MARK(); + TEST_MUSTPASS(codec->SetAMRWbDecFormat(0)); MARK(); // restore default - ANL(); - AOK(); - ANL(); + ANL(); + AOK(); + ANL(); #endif // #ifdef WEBRTC_CODEC_GSMAMRWB + /////////////////////////////// + // SetSendCNPayloadType + TEST(SetSendCNPayloadType); + ANL(); - /////////////////////////////// - // SetSendCNPayloadType + TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(-1, 0)); + MARK(); // invalid channel - TEST(SetSendCNPayloadType); - ANL(); + // Invalid payload range (only dynamic range [96,127] + TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, 0)); + MARK(); // invalid PT + TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, 95)); + MARK(); // invalid PT + TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, 128)); + MARK(); // invalid PT + TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, -1)); + MARK(); // invalid PT - TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(-1, 0)); - MARK(); // invalid channel + // Not possible to change PT for 8000 + TEST_MUSTPASS(!codec->SetSendCNPayloadType(0, 96, kFreq8000Hz)); + MARK(); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_PLFREQ); - // Invalid payload range (only dynamic range [96,127] - TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, 0)); - MARK(); // invalid PT - TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, 95)); - MARK(); // invalid PT - TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, 128)); - MARK(); // invalid PT - TEST_MUSTPASS(-1 != codec->SetSendCNPayloadType(0, -1)); - MARK(); // invalid PT + // Try some dynamic for 16000 and 32000 as well + TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 96, kFreq16000Hz)); + MARK(); + TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 96, kFreq32000Hz)); + MARK(); // same should work + TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 127, kFreq16000Hz)); + MARK(); + TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 127, kFreq32000Hz)); + MARK(); + TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 100, kFreq32000Hz)); + MARK(); - // Not possible to change PT for 8000 - TEST_MUSTPASS(!codec->SetSendCNPayloadType(0, 96, kFreq8000Hz)); - MARK(); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_PLFREQ); + ANL(); + AOK(); + ANL(); - // Try some dynamic for 16000 and 32000 as well - TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 96, kFreq16000Hz)); - MARK(); - TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 96, kFreq32000Hz)); - MARK(); // same should work - TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 127, kFreq16000Hz)); - MARK(); - TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 127, kFreq32000Hz)); - MARK(); - TEST_MUSTPASS(codec->SetSendCNPayloadType(0, 100, kFreq32000Hz)); - MARK(); + ///////////////////////////// + // SetRecPayloadType + TEST(SetRecPayloadType); + ANL(); - ANL(); - AOK(); - ANL(); - - ///////////////////////////// - // SetRecPayloadType - - TEST(SetRecPayloadType); - ANL(); - - // scan all supported and valid codecs without changing payloads - nCodecs = codec->NumOfCodecs(); - for (i = 0; i < nCodecs; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, newCodec)); - // If no default payload type is defined, we use 127 - if (-1 == newCodec.pltype) - { - newCodec.pltype = 127; - } - TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); - MARK(); // use default - newCodec.pltype = 99; - TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); - MARK(); // use same PT on all - newCodec.pltype = -1; - TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); - MARK(); // deregister all PTs + // scan all supported and valid codecs without changing payloads + nCodecs = codec->NumOfCodecs(); + for (i = 0; i < nCodecs; i++) { + TEST_MUSTPASS(codec->GetCodec(i, newCodec)); + // If no default payload type is defined, we use 127 + if (-1 == newCodec.pltype) { + newCodec.pltype = 127; } + TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); + MARK(); // use default + newCodec.pltype = 99; + TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); + MARK(); // use same PT on all + newCodec.pltype = -1; + TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); + MARK(); // deregister all PTs + } - ANL(); - AOK(); - ANL(); + ANL(); + AOK(); + ANL(); - ///////////////////////////// - // GetRecPayloadType + ///////////////////////////// + // GetRecPayloadType + TEST(GetRecPayloadType); + ANL(); - TEST(GetRecPayloadType); - ANL(); - - CodecInst extraCodec; - for (i = 0; i < nCodecs; i++) - { - // Set defaults - TEST_MUSTPASS(codec->GetCodec(i, newCodec)); - // If no default payload type is defined, we use 127 - if (-1 == newCodec.pltype) - { - newCodec.pltype = 127; - } - TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); - //TEST_LOG("[%2d] %s (SetRec): fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", - // i, newCodec.plname, newCodec.plfreq, newCodec.pltype, newCodec.rate, - // newCodec.channels, newCodec.pacsize); - extraCodec.pltype = -1; // don't know this yet - extraCodec.plfreq = newCodec.plfreq; - extraCodec.rate = newCodec.rate; - extraCodec.channels = newCodec.channels; - strcpy(extraCodec.plname, newCodec.plname); - // Verfify that setting is OK - TEST_MUSTPASS(codec->GetRecPayloadType(0, extraCodec)); - //TEST_LOG("[%2d] %s (GetRec): fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", - // i, extraCodec.plname, extraCodec.plfreq, extraCodec.pltype, - // extraCodec.rate, extraCodec.channels, extraCodec.pacsize); - TEST_MUSTPASS(newCodec.pltype != extraCodec.pltype); - TEST_MUSTPASS(newCodec.plfreq != extraCodec.plfreq); - TEST_MUSTPASS(newCodec.channels != extraCodec.channels); + CodecInst extraCodec; + for (i = 0; i < nCodecs; i++) { + // Set defaults + TEST_MUSTPASS(codec->GetCodec(i, newCodec)); + // If no default payload type is defined, we use 127 + if (-1 == newCodec.pltype) { + newCodec.pltype = 127; } + TEST_MUSTPASS(codec->SetRecPayloadType(0, newCodec)); + //TEST_LOG("[%2d] %s (SetRec): fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", + // i, newCodec.plname, newCodec.plfreq, newCodec.pltype, newCodec.rate, + // newCodec.channels, newCodec.pacsize); + extraCodec.pltype = -1; // don't know this yet + extraCodec.plfreq = newCodec.plfreq; + extraCodec.rate = newCodec.rate; + extraCodec.channels = newCodec.channels; + strcpy(extraCodec.plname, newCodec.plname); + // Verfify that setting is OK + TEST_MUSTPASS(codec->GetRecPayloadType(0, extraCodec)); + //TEST_LOG("[%2d] %s (GetRec): fs=%d, pt=%d, rate=%d, ch=%d, size=%d\n", + // i, extraCodec.plname, extraCodec.plfreq, extraCodec.pltype, + // extraCodec.rate, extraCodec.channels, extraCodec.pacsize); + TEST_MUSTPASS(newCodec.pltype != extraCodec.pltype); + TEST_MUSTPASS(newCodec.plfreq != extraCodec.plfreq); + TEST_MUSTPASS(newCodec.channels != extraCodec.channels); + } - AOK(); - ANL(); + AOK(); + ANL(); - //////////////////////////////////////////////////// - // SetRecPayloadType - remove receive codecs - - TEST(SetRecPayloadType - removing receive codecs); - ANL(); + //////////////////////////////////////////////////// + // SetRecPayloadType - remove receive codecs + TEST(SetRecPayloadType - removing receive codecs); + ANL(); #ifndef WEBRTC_EXTERNAL_TRANSPORT - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); #endif - TEST_MUSTPASS(base->StartSend(0)); - if (file) - { - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - _mgr.AudioFilename(), - true, - true)); + TEST_MUSTPASS(base->StartSend(0)); + if (file) { + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + _mgr.AudioFilename(), + true, + true)); + } + + // Scan all supported and valid codecs and remove from receiving db, then + // restore + nCodecs = codec->NumOfCodecs(); + for (i = 0; i < nCodecs; i++) { + TEST_MUSTPASS(codec->GetCodec(i, cinst)); + if (!_stricmp("red", cinst.plname) || !_stricmp("cn", cinst.plname) + || !_stricmp("telephone-event", cinst.plname)) { + continue; // Ignore these + } + TEST_LOG("Testing codec: %s", cinst.plname); + fflush(NULL); + + if (-1 == cinst.pltype) { + // If no default payload type is defined, we use 127, + // codec is not registered for receiving + cinst.pltype = 127; + } else { + // Remove codec + memcpy(&extraCodec, &cinst, sizeof(CodecInst)); + extraCodec.pltype = -1; + TEST_MUSTPASS(codec->SetRecPayloadType(0, extraCodec)); } - // Scan all supported and valid codecs and remove from receiving db, then - // restore - nCodecs = codec->NumOfCodecs(); - for (i = 0; i < nCodecs; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, cinst)); - if (!_stricmp("red", cinst.plname) || !_stricmp("cn", cinst.plname) - || !_stricmp("telephone-event", cinst.plname)) - { - continue; // Ignore these - } - TEST_LOG("Testing codec: %s", cinst.plname); - fflush(NULL); - - if (-1 == cinst.pltype) - { - // If no default payload type is defined, we use 127, - // codec is not registered for receiving - cinst.pltype = 127; - } else - { - // Remove codec - memcpy(&extraCodec, &cinst, sizeof(CodecInst)); - extraCodec.pltype = -1; - TEST_MUSTPASS(codec->SetRecPayloadType(0, extraCodec)); - } - - // Set send codec - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - - // Verify no audio - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_LOG(" silence"); - fflush(NULL); - SLEEP(800); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - - // Restore codec - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - - // Verify audio - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_LOG(" audio"); - fflush(NULL); - SLEEP(800); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - - if (127 == cinst.pltype) - { - // If no default payload type is defined, i.e. we have set pt to - //127 above, - // make sure we remove codec from receiving - cinst.pltype = -1; - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - } - - ANL(); - } - - // Remove certain codecs - TEST_LOG("Removing receive codecs:"); - for (i = 0; i < nCodecs; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, cinst)); - if (!_stricmp("ipcmwb", cinst.plname) - || !_stricmp("pcmu", cinst.plname) || !_stricmp("eg711a", - cinst.plname)) - { - TEST_LOG(" %s", cinst.plname); - memcpy(&extraCodec, &cinst, sizeof(CodecInst)); - extraCodec.pltype = -1; - TEST_MUSTPASS(codec->SetRecPayloadType(0, extraCodec)); - } - } - ANL(); + // Set send codec + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + // Verify no audio TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartPlayout(0)); - - // Test sending all codecs - verify audio/no audio depending on codec - TEST_LOG("Looping through send codecs \n"); - TEST_LOG("Verify that removed codecs are not audible and the other are \n"); - for (i = 0; i < nCodecs; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, cinst)); - if (!_stricmp("red", cinst.plname) || !_stricmp("cn", cinst.plname) - || !_stricmp("telephone-event", cinst.plname)) - { - continue; // Ignore these - } - TEST_LOG("Testing codec: %s \n", cinst.plname); - - // If no default payload type is defined, we use 127 and set receive - // payload type - if (-1 == cinst.pltype) - { - cinst.pltype = 127; - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - } - - // Set send codec - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - - // Verify audio/no audio - SLEEP(800); - } - + TEST_LOG(" silence"); + fflush(NULL); + SLEEP(800); TEST_MUSTPASS(base->StopPlayout(0)); TEST_MUSTPASS(base->StopReceive(0)); - // Restore codecs - TEST_LOG("Restoring receive codecs:"); - for (i = 0; i < nCodecs; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, cinst)); - if (!_stricmp("ipcmwb", cinst.plname) || - !_stricmp("pcmu", cinst.plname) || - !_stricmp("eg711a", cinst.plname)) - { - TEST_LOG(" %s", cinst.plname); - memcpy(&extraCodec, &cinst, sizeof(CodecInst)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - } - } - ANL(); + // Restore codec + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + // Verify audio TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartPlayout(0)); - - // Test sending all codecs - verify audio - TEST_LOG("Looping through send codecs \n"); - TEST_LOG("Verify that all codecs are audible \n"); - for (i = 0; i < nCodecs; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, cinst)); - if (!_stricmp("red", cinst.plname) || !_stricmp("cn", cinst.plname) - || !_stricmp("telephone-event", cinst.plname)) - { - continue; // Ignore these - } - TEST_LOG("Testing codec: %s \n", cinst.plname); - - // If no default payload type is defined, we use 127 and set receive - // payload type - if (-1 == cinst.pltype) - { - cinst.pltype = 127; - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - } - - // Set send codec - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - - // Verify audio/no audio - SLEEP(800); - } - + TEST_LOG(" audio"); + fflush(NULL); + SLEEP(800); TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); TEST_MUSTPASS(base->StopReceive(0)); - // Fresh channel - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + if (127 == cinst.pltype) { + // If no default payload type is defined, i.e. we have set pt to + //127 above, + // make sure we remove codec from receiving + cinst.pltype = -1; + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + } + + ANL(); + } + + // Remove certain codecs + TEST_LOG("Removing receive codecs:"); + for (i = 0; i < nCodecs; i++) { + TEST_MUSTPASS(codec->GetCodec(i, cinst)); + if (!_stricmp("ipcmwb", cinst.plname) || !_stricmp("pcmu", cinst.plname) + || !_stricmp("eg711a", cinst.plname)) { + TEST_LOG(" %s", cinst.plname); + memcpy(&extraCodec, &cinst, sizeof(CodecInst)); + extraCodec.pltype = -1; + TEST_MUSTPASS(codec->SetRecPayloadType(0, extraCodec)); + } + } + ANL(); + + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + + // Test sending all codecs - verify audio/no audio depending on codec + TEST_LOG("Looping through send codecs \n"); + TEST_LOG("Verify that removed codecs are not audible and the other are \n"); + for (i = 0; i < nCodecs; i++) { + TEST_MUSTPASS(codec->GetCodec(i, cinst)); + if (!_stricmp("red", cinst.plname) || !_stricmp("cn", cinst.plname) + || !_stricmp("telephone-event", cinst.plname)) { + continue; // Ignore these + } + TEST_LOG("Testing codec: %s \n", cinst.plname); + + // If no default payload type is defined, we use 127 and set receive + // payload type + if (-1 == cinst.pltype) { + cinst.pltype = 127; + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + } + + // Set send codec + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + + // Verify audio/no audio + SLEEP(800); + } + + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + + // Restore codecs + TEST_LOG("Restoring receive codecs:"); + for (i = 0; i < nCodecs; i++) { + TEST_MUSTPASS(codec->GetCodec(i, cinst)); + if (!_stricmp("ipcmwb", cinst.plname) || !_stricmp("pcmu", cinst.plname) + || !_stricmp("eg711a", cinst.plname)) { + TEST_LOG(" %s", cinst.plname); + memcpy(&extraCodec, &cinst, sizeof(CodecInst)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + } + } + ANL(); + + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + + // Test sending all codecs - verify audio + TEST_LOG("Looping through send codecs \n"); + TEST_LOG("Verify that all codecs are audible \n"); + for (i = 0; i < nCodecs; i++) { + TEST_MUSTPASS(codec->GetCodec(i, cinst)); + if (!_stricmp("red", cinst.plname) || !_stricmp("cn", cinst.plname) + || !_stricmp("telephone-event", cinst.plname)) { + continue; // Ignore these + } + TEST_LOG("Testing codec: %s \n", cinst.plname); + + // If no default payload type is defined, we use 127 and set receive + // payload type + if (-1 == cinst.pltype) { + cinst.pltype = 127; + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + } + + // Set send codec + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + + // Verify audio/no audio + SLEEP(800); + } + + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + + // Fresh channel + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); #if defined(WEBRTC_CODEC_ISAC) - ///////////////////////////////////// - // SetISACInitTargetRate - wb + ///////////////////////////////////// + // SetISACInitTargetRate - wb + TEST(SetISACInitTargetRate); + ANL(); - TEST(SetISACInitTargetRate); - ANL(); + // set PCMU as sending codec + cinst.channels = 1; + cinst.pacsize = 160; + cinst.plfreq = 8000; + strcpy(cinst.plname, "PCMU"); + cinst.pltype = 0; + cinst.rate = 64000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - // set PCMU as sending codec - cinst.channels = 1; - cinst.pacsize = 160; - cinst.plfreq = 8000; - strcpy(cinst.plname, "PCMU"); - cinst.pltype = 0; - cinst.rate = 64000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 10000)); + MARK(); // should fail since iSAC is not active + err = base->LastError(); + TEST_MUSTPASS(err != VE_CODEC_ERROR); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 10000)); - MARK(); // should fail since iSAC is not active - err = base->LastError(); - TEST_MUSTPASS(err != VE_CODEC_ERROR); + // set iSAC as sending codec (16kHz) + cinst.channels = 1; + cinst.plfreq = 16000; + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 103; + cinst.rate = -1; // adaptive rate + cinst.pacsize = 480; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - // set iSAC as sending codec (16kHz) - cinst.channels = 1; - cinst.plfreq = 16000; - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 103; - cinst.rate = -1; // adaptive rate - cinst.pacsize = 480; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(1, 10000)); + MARK(); // invalid channel + err = base->LastError(); + TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(1, 10000)); - MARK(); // invalid channel - err = base->LastError(); - TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 500)); + MARK(); // invalid target rates (too small) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 500)); - MARK(); // invalid target rates (too small) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 33000)); + MARK(); // invalid target rates (too large) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 33000)); - MARK(); // invalid target rates (too large) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000)); + MARK(); // life is good now + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 0)); + MARK(); // 0 is a valid rate + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000)); + MARK(); // try max as well + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000, true)); + MARK(); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000, false)); + MARK(); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000)); - MARK(); // life is good now - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 0)); - MARK(); // 0 is a valid rate - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000)); - MARK(); // try max as well - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000, true)); - MARK(); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000, false)); - MARK(); + cinst.pacsize = 960; // 60ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000, false)); + MARK(); - cinst.pacsize = 960; // 60ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000, false)); - MARK(); + cinst.rate = 20000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 32000)); + MARK(); // only works in adaptive mode + err = base->LastError(); + TEST_MUSTPASS(err != VE_AUDIO_CODING_MODULE_ERROR); - cinst.rate = 20000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 32000)); - MARK(); // only works in adaptive mode - err = base->LastError(); - TEST_MUSTPASS(err != VE_AUDIO_CODING_MODULE_ERROR); + cinst.rate = -1; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000)); + MARK(); // back to adaptive mode - cinst.rate = -1; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000)); - MARK(); // back to adaptive mode + ANL(); + AOK(); + ANL(); - ANL(); - AOK(); - ANL(); + ///////////////////////////////////// + // SetISACInitTargetRate - swb + TEST(ISACSWB SetISACInitTargetRate); + ANL(); - ///////////////////////////////////// - // SetISACInitTargetRate - swb + // set iSAC as sending codec + cinst.channels = 1; + cinst.plfreq = 32000; + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 104; + cinst.rate = -1; // default rate + cinst.pacsize = 960; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST(ISACSWB SetISACInitTargetRate); - ANL(); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(1, 10000)); + MARK(); // invalid channel + err = base->LastError(); + TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); - // set iSAC as sending codec - cinst.channels = 1; - cinst.plfreq = 32000; - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 104; - cinst.rate = -1; // default rate - cinst.pacsize = 960; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, -1)); + MARK(); // invalid target rates (too small) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, -1)); + MARK(); // invalid target rates (too small) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(1, 10000)); - MARK(); // invalid channel - err = base->LastError(); - TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 500)); + MARK(); // invalid target rates (too small) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, -1)); - MARK(); // invalid target rates (too small) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, -1)); - MARK(); // invalid target rates (too small) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 57000)); + MARK(); // invalid target rates (valid range is [10000, 56000]) - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 500)); - MARK(); // invalid target rates (too small) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 57000)); - MARK(); // invalid target rates (valid range is [10000, 56000]) + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000)); + MARK(); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 0)); + MARK(); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 56000)); + MARK(); // try max as well + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 56000, true)); + MARK(); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 56000, false)); + MARK(); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + ANL(); + AOK(); + ANL(); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000)); - MARK(); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 0)); - MARK(); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 56000)); - MARK(); // try max as well - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 56000, true)); - MARK(); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 56000, false)); - MARK(); + //////////////////////////////// + // SetISACMaxRate + TEST(SetISACMaxRate); + ANL(); - ANL(); - AOK(); - ANL(); + // set PCMU as sending codec + cinst.channels = 1; + cinst.pacsize = 160; + cinst.plfreq = 8000; + strcpy(cinst.plname, "PCMU"); + cinst.pltype = 0; + cinst.rate = 64000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - //////////////////////////////// - // SetISACMaxRate + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 48000)); + MARK(); // should fail since iSAC is not active + TEST_MUSTPASS(base->LastError() != VE_CODEC_ERROR); - TEST(SetISACMaxRate); - ANL(); + // set iSAC as sending codec + cinst.channels = 1; + cinst.plfreq = 16000; + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 103; + cinst.rate = -1; // adaptive rate + cinst.pacsize = 480; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - // set PCMU as sending codec - cinst.channels = 1; - cinst.pacsize = 160; - cinst.plfreq = 8000; - strcpy(cinst.plname, "PCMU"); - cinst.pltype = 0; - cinst.rate = 64000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACMaxRate(1, 48000)); + MARK(); // invalid channel + TEST_MUSTPASS(base->LastError() != VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 48000)); - MARK(); // should fail since iSAC is not active - TEST_MUSTPASS(base->LastError() != VE_CODEC_ERROR); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); + MARK(); // invalid target rates (too small) + TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - // set iSAC as sending codec - cinst.channels = 1; - cinst.plfreq = 16000; - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 103; - cinst.rate = -1; // adaptive rate - cinst.pacsize = 480; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 53500)); + MARK(); // invalid target rates (too large) + TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxRate(1, 48000)); - MARK(); // invalid channel - TEST_MUSTPASS(base->LastError() != VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); + MARK(); // life is good now + TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 48000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 53400)); + MARK(); // try max as well (default) - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); - MARK(); // invalid target rates (too small) - TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); + cinst.pacsize = 960; // 60ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 48000)); + MARK(); - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 53500)); - MARK(); // invalid target rates (too large) - TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); + cinst.rate = 20000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); + MARK(); // also works in non-adaptive mode - TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); - MARK(); // life is good now - TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 48000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 53400)); - MARK(); // try max as well (default) + ANL(); + AOK(); + ANL(); - cinst.pacsize = 960; // 60ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 48000)); - MARK(); + TEST(ISACSWB SetISACMaxRate); + ANL(); + // set iSAC as sending codec + cinst.channels = 1; + cinst.plfreq = 32000; + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 104; + cinst.rate = 45000; // instantaneous mode + cinst.pacsize = 960; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - cinst.rate = 20000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); - MARK(); // also works in non-adaptive mode + TEST_MUSTPASS(!codec->SetISACMaxRate(1, 48000)); + MARK(); // invalid channel + TEST_MUSTPASS(base->LastError() != VE_CHANNEL_NOT_VALID); - ANL(); - AOK(); - ANL(); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); + MARK(); // invalid target rates (too small) + TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - TEST(ISACSWB SetISACMaxRate); - ANL(); - // set iSAC as sending codec - cinst.channels = 1; - cinst.plfreq = 32000; - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 104; - cinst.rate = 45000; // instantaneous mode - cinst.pacsize = 960; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 107500)); + MARK(); // invalid target rates (too large) + TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxRate(1, 48000)); - MARK(); // invalid channel - TEST_MUSTPASS(base->LastError() != VE_CHANNEL_NOT_VALID); - - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); - MARK(); // invalid target rates (too small) - TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 107500)); - MARK(); // invalid target rates (too large) - TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - - TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); - MARK(); // life is good now - TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 55000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 80000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 107000)); - MARK(); // try max as well (default) + TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); + MARK(); // life is good now + TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 55000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 80000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 107000)); + MARK(); // try max as well (default) - cinst.rate = -1; // adaptive mode - cinst.pacsize = 960; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + cinst.rate = -1; // adaptive mode + cinst.pacsize = 960; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(!codec->SetISACMaxRate(1, 48000)); - MARK(); // invalid channel - TEST_MUSTPASS(base->LastError() != VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!codec->SetISACMaxRate(1, 48000)); + MARK(); // invalid channel + TEST_MUSTPASS(base->LastError() != VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); - MARK(); // invalid target rates (too small) - TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); + MARK(); // invalid target rates (too small) + TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 107500)); - MARK(); // invalid target rates (too large) - TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 107500)); + MARK(); // invalid target rates (too large) + TEST_MUSTPASS(base->LastError() != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); - MARK(); // life is good now - TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 55000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 80000)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 107000)); - MARK(); // try max as well (default) + TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); + MARK(); // life is good now + TEST_MUSTPASS(codec->SetISACMaxRate(0, 40000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 55000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 80000)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 107000)); + MARK(); // try max as well (default) - ANL(); - AOK(); - ANL(); + ANL(); + AOK(); + ANL(); - //////////////////////////////// - // SetISACMaxPayloadSize + //////////////////////////////// + // SetISACMaxPayloadSize + TEST(SetISACMaxPayloadSize); + ANL(); - TEST(SetISACMaxPayloadSize); - ANL(); + // set PCMU as sending codec + cinst.channels = 1; + cinst.pacsize = 160; + cinst.plfreq = 8000; + strcpy(cinst.plname, "PCMU"); + cinst.pltype = 0; + cinst.rate = 64000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - // set PCMU as sending codec - cinst.channels = 1; - cinst.pacsize = 160; - cinst.plfreq = 8000; - strcpy(cinst.plname, "PCMU"); - cinst.pltype = 0; - cinst.rate = 64000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 120)); + MARK(); // should fail since iSAC is not active + err = base->LastError(); + TEST_MUSTPASS(err != VE_CODEC_ERROR); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 120)); - MARK(); // should fail since iSAC is not active - err = base->LastError(); - TEST_MUSTPASS(err != VE_CODEC_ERROR); + // set iSAC as sending codec + cinst.channels = 1; + cinst.plfreq = 16000; + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 103; + cinst.rate = -1; // adaptive rate + cinst.pacsize = 480; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - // set iSAC as sending codec - cinst.channels = 1; - cinst.plfreq = 16000; - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 103; - cinst.rate = -1; // adaptive rate - cinst.pacsize = 480; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(1, 120)); + MARK(); // invalid channel + err = base->LastError(); + TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(1, 120)); - MARK(); // invalid channel - err = base->LastError(); - TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 100)); + MARK(); // invalid size (too small) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 100)); - MARK(); // invalid size (too small) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 410)); + MARK(); // invalid size (too large) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 410)); - MARK(); // invalid size (too large) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 200)); + MARK(); // life is good now + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 120)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 400)); + MARK(); - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 200)); - MARK(); // life is good now - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 120)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 400)); - MARK(); + ANL(); + AOK(); + ANL(); - ANL(); - AOK(); - ANL(); + TEST(ISACSWB SetISACMaxPayloadSize); + ANL(); + // set iSAC as sending codec + cinst.channels = 1; + cinst.plfreq = 32000; + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 104; + cinst.rate = 45000; // default rate + cinst.pacsize = 960; // 30ms + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST(ISACSWB SetISACMaxPayloadSize); - ANL(); - // set iSAC as sending codec - cinst.channels = 1; - cinst.plfreq = 32000; - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 104; - cinst.rate = 45000; // default rate - cinst.pacsize = 960; // 30ms - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(1, 100)); + MARK(); // invalid channel + err = base->LastError(); + TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(1, 100)); - MARK(); // invalid channel - err = base->LastError(); - TEST_MUSTPASS(err != VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 100)); + MARK(); // invalid size (too small) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 100)); - MARK(); // invalid size (too small) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 610)); + MARK(); // invalid size (too large) + err = base->LastError(); + TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 610)); - MARK(); // invalid size (too large) - err = base->LastError(); - TEST_MUSTPASS(err != VE_INVALID_ARGUMENT); + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 200)); + MARK(); // life is good now + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 120)); + MARK(); + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 600)); + MARK(); - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 200)); - MARK(); // life is good now - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 120)); - MARK(); - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 600)); - MARK(); + ANL(); + AOK(); + ANL(); - ANL(); - AOK(); - ANL(); - - // set iSAC as sending codec - // set iSAC-wb as sending codec + // set iSAC as sending codec + // set iSAC-wb as sending codec #ifdef WEBRTC_EXTERNAL_TRANSPORT - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); #else - TEST_MUSTPASS(base->SetSendDestination(0, 8001, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8001)); + TEST_MUSTPASS(base->SetSendDestination(0, 8001, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(0, 8001)); #endif - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - 0, GetFilename("audio_long16.pcm"), true , true)); - cinst.channels = 1; - TEST_LOG("Testing codec: Switch between iSAC-wb and iSAC-swb \n"); - TEST_LOG("Testing codec: iSAC wideband \n"); - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 103; - cinst.rate = -1; // default rate - cinst.pacsize = 480; // 30ms - cinst.plfreq = 16000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - SLEEP(2000); - TEST_LOG(" : iSAC superwideband \n"); - cinst.pltype = 104; - cinst.rate = -1; // default rate - cinst.pacsize = 960; // 30ms - cinst.plfreq = 32000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - SLEEP(2000); - TEST_LOG(" : iSAC wideband \n"); - strcpy(cinst.plname, "ISAC"); - cinst.pltype = 103; - cinst.rate = -1; // default rate - cinst.pacsize = 480; // 30ms - cinst.plfreq = 16000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - SLEEP(2000); - TEST_LOG(" : iSAC superwideband \n"); - cinst.pltype = 104; - cinst.rate = -1; // default rate - cinst.pacsize = 960; // 30ms - cinst.plfreq = 32000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - SLEEP(2000); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, GetFilename("audio_long16.pcm"), true , true)); + cinst.channels = 1; + TEST_LOG("Testing codec: Switch between iSAC-wb and iSAC-swb \n"); + TEST_LOG("Testing codec: iSAC wideband \n"); + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 103; + cinst.rate = -1; // default rate + cinst.pacsize = 480; // 30ms + cinst.plfreq = 16000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + SLEEP(2000); + TEST_LOG(" : iSAC superwideband \n"); + cinst.pltype = 104; + cinst.rate = -1; // default rate + cinst.pacsize = 960; // 30ms + cinst.plfreq = 32000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + SLEEP(2000); + TEST_LOG(" : iSAC wideband \n"); + strcpy(cinst.plname, "ISAC"); + cinst.pltype = 103; + cinst.rate = -1; // default rate + cinst.pacsize = 480; // 30ms + cinst.plfreq = 16000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + SLEEP(2000); + TEST_LOG(" : iSAC superwideband \n"); + cinst.pltype = 104; + cinst.rate = -1; // default rate + cinst.pacsize = 960; // 30ms + cinst.plfreq = 32000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + SLEEP(2000); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StopSend(0)); #else - TEST_LOG("Skipping extended iSAC API tests - " - "WEBRTC_CODEC_ISAC not defined\n"); + TEST_LOG("Skipping extended iSAC API tests - " + "WEBRTC_CODEC_ISAC not defined\n"); #endif // #if defined(WEBRTC_CODEC_ISAC) #ifdef WEBRTC_EXTERNAL_TRANSPORT - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - delete ptrTransport; + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + delete ptrTransport; #endif - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - return 0; + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestDtmf // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestDtmf() -{ - PrepareTest("Dtmf"); +int VoEExtendedTest::TestDtmf() { + PrepareTest("Dtmf"); - VoEBase* base = _mgr.BasePtr(); - VoEDtmf* dtmf = _mgr.DtmfPtr(); - VoECodec* codec = _mgr.CodecPtr(); - VoEVolumeControl* volume = _mgr.VolumeControlPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEDtmf* dtmf = _mgr.DtmfPtr(); + VoECodec* codec = _mgr.CodecPtr(); + VoEVolumeControl* volume = _mgr.VolumeControlPtr(); - //#ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("VoEDtmf_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); - //#endif + //#ifdef _USE_EXTENDED_TRACE_ + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("VoEDtmf_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); + //#endif + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); + /////////////////////////// + // Actual test starts here - /////////////////////////// - // Actual test starts here + // SetDtmfFeedbackStatus + TEST(SetDtmfFeedbackStatus & GetDtmfFeedbackStatus); + ANL(); + bool dtmfFeedback = false, dtmfDirectFeedback = true; + TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, + dtmfDirectFeedback)); + TEST_MUSTPASS(!dtmfFeedback); + TEST_MUSTPASS(dtmfDirectFeedback); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); + MARK(); + SLEEP(500); - // SetDtmfFeedbackStatus - TEST(SetDtmfFeedbackStatus & GetDtmfFeedbackStatus); - ANL(); - bool dtmfFeedback = false, dtmfDirectFeedback = true; - TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, - dtmfDirectFeedback)); - TEST_MUSTPASS(!dtmfFeedback); - TEST_MUSTPASS(dtmfDirectFeedback); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); - MARK(); - SLEEP(500); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false, false)); + TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, + dtmfDirectFeedback)); + TEST_MUSTPASS(dtmfFeedback); + TEST_MUSTPASS(dtmfDirectFeedback); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); + MARK(); + SLEEP(500); - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false, false)); - TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, - dtmfDirectFeedback)); - TEST_MUSTPASS(dtmfFeedback); - TEST_MUSTPASS(dtmfDirectFeedback); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); - MARK(); - SLEEP(500); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false, true)); + TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, + dtmfDirectFeedback)); + TEST_MUSTPASS(dtmfFeedback); + TEST_MUSTPASS(!dtmfDirectFeedback); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); + MARK(); + SLEEP(500); - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false, true)); - TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, - dtmfDirectFeedback)); - TEST_MUSTPASS(dtmfFeedback); - TEST_MUSTPASS(!dtmfDirectFeedback); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); - MARK(); - SLEEP(500); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, false)); + TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, + dtmfDirectFeedback)); + TEST_MUSTPASS(!dtmfFeedback); + TEST_MUSTPASS(dtmfDirectFeedback); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); + MARK(); + SLEEP(500); - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, false)); - TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, - dtmfDirectFeedback)); - TEST_MUSTPASS(!dtmfFeedback); - TEST_MUSTPASS(dtmfDirectFeedback); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); - MARK(); - SLEEP(500); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, true)); + TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, + dtmfDirectFeedback)); + TEST_MUSTPASS(!dtmfFeedback); + TEST_MUSTPASS(!dtmfDirectFeedback); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false, false)); - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, true)); - TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, - dtmfDirectFeedback)); - TEST_MUSTPASS(!dtmfFeedback); - TEST_MUSTPASS(!dtmfDirectFeedback); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false, false)); + AOK(); + ANL(); - AOK(); - ANL(); + // SendDtmf + TEST(SendDtmf); + ANL(); - // SendDtmf - TEST(SendDtmf); - ANL(); + // Fail tests + // Event + // the eventcode is changed to unsigned char, so -1 will be interpreted as + // 255, 256->0 + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, -1, false, 160, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 16, false, 160, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + // Length + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 99, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 60001, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 20, true, -1, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + // Volume + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 160, -1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 160, 37)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + // Without sending + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true)); + MARK(); + TEST_MUSTPASS(VE_NOT_SENDING != base->LastError()); + TEST_MUSTPASS(base->StartSend(0)); - // Fail tests - // Event - // the eventcode is changed to unsigned char, so -1 will be interpreted as - // 255, 256->0 - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, -1, false, 160, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 16, false, 160, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - // Length - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 99, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 60001, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 20, true, -1, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - // Volume - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 160, -1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true, 160, 37)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - // Without sending - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(!dtmf->SendTelephoneEvent(0, 0, true)); - MARK(); - TEST_MUSTPASS(VE_NOT_SENDING != base->LastError()); - TEST_MUSTPASS(base->StartSend(0)); + // Testing Dtmf out-of-band: event, length and volume + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 16, true)); + MARK(); + SLEEP(500); // Flash, not audible + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 100, 10)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400, 10)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 160, 0)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 160, 36)); + MARK(); + SLEEP(500); - // Testing Dtmf out-of-band: event, length and volume - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 16, true)); - MARK(); - SLEEP(500); // Flash, not audible - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 100, 10)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400, 10)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 160, 0)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 160, 36)); - MARK(); - SLEEP(500); + // Testing Dtmf inband: event, length and volume + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 15, false)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 100, 10)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 400, 10)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 160, 0)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 160, 36)); + MARK(); + SLEEP(500); - // Testing Dtmf inband: event, length and volume - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 15, false)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 100, 10)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 400, 10)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 160, 0)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false, 160, 36)); - MARK(); - SLEEP(500); + // Testing other events out-of-band: event and length + // These are not audible + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 17, true, 100, 10)); + MARK(); + SLEEP(200); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 32, true, 100, 10)); + MARK(); + SLEEP(200); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 78, true, 100, 10)); + MARK(); + SLEEP(200); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 255, true, 100, 10)); + MARK(); + SLEEP(200); + // the minimum length is 100 for the telephoneevent + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 32, true, 100, 10)); + MARK(); + SLEEP(200); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 32, true, 1000, 10)); + MARK(); + SLEEP(1200); - // Testing other events out-of-band: event and length - // These are not audible - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 17, true, 100, 10)); - MARK(); - SLEEP(200); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 32, true, 100, 10)); - MARK(); - SLEEP(200); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 78, true, 100, 10)); - MARK(); - SLEEP(200); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 255, true, 100, 10)); - MARK(); - SLEEP(200); - // the minimum length is 100 for the telephoneevent - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 32, true, 100, 10)); - MARK(); - SLEEP(200); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 32, true, 1000, 10)); - MARK(); - SLEEP(1200); + AOK(); + ANL(); - AOK(); - ANL(); + // PlayDtmfTone + TEST(PlayDtmfTone); + ANL(); + TEST_MUSTPASS(!dtmf->PlayDtmfTone(-1, 200, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->PlayDtmfTone(16, 200, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->PlayDtmfTone(0, 9, 10)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->PlayDtmfTone(0, 200, -1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!dtmf->PlayDtmfTone(0, 200, 37)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - // PlayDtmfTone - TEST(PlayDtmfTone); - ANL(); - TEST_MUSTPASS(!dtmf->PlayDtmfTone(-1, 200, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->PlayDtmfTone(16, 200, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->PlayDtmfTone(0, 9, 10)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->PlayDtmfTone(0, 200, -1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!dtmf->PlayDtmfTone(0, 200, 37)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(dtmf->PlayDtmfTone(0)); + MARK(); + SLEEP(500); + // the minimum length fo the DtmfTone is 100 + TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 100, 10)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 2000, 10)); + MARK(); + SLEEP(2300); + TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 200, 0)); + MARK(); + SLEEP(500); + TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 200, 36)); + MARK(); + SLEEP(500); - TEST_MUSTPASS(dtmf->PlayDtmfTone(0)); - MARK(); - SLEEP(500); - // the minimum length fo the DtmfTone is 100 - TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 100, 10)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 2000, 10)); - MARK(); - SLEEP(2300); - TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 200, 0)); - MARK(); - SLEEP(500); - TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 200, 36)); - MARK(); - SLEEP(500); + AOK(); + ANL(); - AOK(); - ANL(); + // SetTelephoneEventDetection + TEST(SetTelephoneEventDetection); + ANL(); + AOK(); + ANL(); - // SetTelephoneEventDetection - TEST(SetTelephoneEventDetection); - ANL(); - AOK(); - ANL(); - - // Testing sending Dtmf under VAD/CN - TEST(SendDtmf - with VAD enabled); - ANL(); - // Mute mic - TEST_MUSTPASS(volume->SetInputMute(0, true)); - MARK(); - // Enable VAD - TEST_MUSTPASS(codec->SetVADStatus(0, true)); - MARK(); - // Send Dtmf - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); - MARK(); - SLEEP(1000); - // Switch codec - CodecInst ci; + // Testing sending Dtmf under VAD/CN + TEST(SendDtmf - with VAD enabled); + ANL(); + // Mute mic + TEST_MUSTPASS(volume->SetInputMute(0, true)); + MARK(); + // Enable VAD + TEST_MUSTPASS(codec->SetVADStatus(0, true)); + MARK(); + // Send Dtmf + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); + MARK(); + SLEEP(1000); + // Switch codec + CodecInst ci; #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - ci.channels = 1; - ci.pacsize = 480; - ci.plfreq = 16000; - strcpy(ci.plname, "ISAC"); - ci.pltype = 103; - ci.rate = -1; + ci.channels = 1; + ci.pacsize = 480; + ci.plfreq = 16000; + strcpy(ci.plname, "ISAC"); + ci.pltype = 103; + ci.rate = -1; #else - ci.pltype = 119; - strcpy(ci.plname, "isaclc"); - ci.plfreq = 16000; - ci.pacsize = 320; - ci.channels = 1; - ci.rate = 40000; + ci.pltype = 119; + strcpy(ci.plname, "isaclc"); + ci.plfreq = 16000; + ci.pacsize = 320; + ci.channels = 1; + ci.rate = 40000; #endif - TEST_MUSTPASS(codec->SetSendCodec(0, ci)); - MARK(); - // Send Dtmf - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); - MARK(); - SLEEP(1000); - SLEEP(4000); - // Disable VAD - TEST_MUSTPASS(codec->SetVADStatus(0, false)); - MARK(); - // Unmute - TEST_MUSTPASS(volume->SetInputMute(0, false)); - MARK(); + TEST_MUSTPASS(codec->SetSendCodec(0, ci)); + MARK(); + // Send Dtmf + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true, 400)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 9, true, 400)); + MARK(); + SLEEP(1000); + SLEEP(4000); + // Disable VAD + TEST_MUSTPASS(codec->SetVADStatus(0, false)); + MARK(); + // Unmute + TEST_MUSTPASS(volume->SetInputMute(0, false)); + MARK(); - AOK(); - ANL(); + AOK(); + ANL(); - // SetSendTelephoneEventPayloadType - TEST(SetSendTelephoneEventPayloadType); - ANL(); - TEST_MUSTPASS(!dtmf->SetSendTelephoneEventPayloadType(0, 128)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + // SetSendTelephoneEventPayloadType + TEST(SetSendTelephoneEventPayloadType); + ANL(); + TEST_MUSTPASS(!dtmf->SetSendTelephoneEventPayloadType(0, 128)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, 96)); - MARK(); - TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, 127)); - MARK(); - TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, 106)); - MARK(); // restore default + TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, 96)); + MARK(); + TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, 127)); + MARK(); + TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, 106)); + MARK(); // restore default - AOK(); - ANL(); + AOK(); + ANL(); #ifdef WEBRTC_DTMF_DETECTION - TEST(RegisterTelephoneEventDetection - several channels); ANL(); + TEST(RegisterTelephoneEventDetection - several channels); ANL(); - ci.channels = 1; - ci.pacsize = 160; - ci.plfreq = 8000; - ci.pltype = 0; - ci.rate = 64000; - strcpy(ci.plname, "PCMU"); - TEST_MUSTPASS(codec->SetSendCodec(0, ci)); + ci.channels = 1; + ci.pacsize = 160; + ci.plfreq = 8000; + ci.pltype = 0; + ci.rate = 64000; + strcpy(ci.plname, "PCMU"); + TEST_MUSTPASS(codec->SetSendCodec(0, ci)); - int ch2 = base->CreateChannel(); - TEST_MUSTPASS(base->SetSendDestination(ch2, 8002, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(ch2, 8002)); - TEST_MUSTPASS(base->StartReceive(ch2)); - TEST_MUSTPASS(codec->SetSendCodec(ch2, ci)); - TEST_MUSTPASS(base->StartPlayout(ch2)); - TEST_MUSTPASS(base->StartSend(ch2)); - MARK(); + int ch2 = base->CreateChannel(); + TEST_MUSTPASS(base->SetSendDestination(ch2, 8002, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(ch2, 8002)); + TEST_MUSTPASS(base->StartReceive(ch2)); + TEST_MUSTPASS(codec->SetSendCodec(ch2, ci)); + TEST_MUSTPASS(base->StartPlayout(ch2)); + TEST_MUSTPASS(base->StartSend(ch2)); + MARK(); - DtmfCallback *d = new DtmfCallback(); - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false)); + DtmfCallback *d = new DtmfCallback(); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); - // In-band - TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(0, kInBand, *d)); - TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(ch2, kInBand, *d)); - TEST_LOG("\nSending in-band telephone events:"); - for(int i = 0; i < 16; i++) - { - TEST_LOG("\n %d ", i); fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, false, 160, 10)); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(ch2, i, false, 160, 10)); - SLEEP(500); - } - TEST_LOG("\nDetected %d events \n", d->counter); - TEST_MUSTPASS(d->counter != 32); - TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); - TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(ch2)); + // In-band + TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(0, kInBand, *d)); + TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(ch2, kInBand, *d)); + TEST_LOG("\nSending in-band telephone events:"); + for(int i = 0; i < 16; i++) + { + TEST_LOG("\n %d ", i); fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, false, 160, 10)); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(ch2, i, false, 160, 10)); + SLEEP(500); + } + TEST_LOG("\nDetected %d events \n", d->counter); + TEST_MUSTPASS(d->counter != 32); + TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); + TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(ch2)); - // Out-of-band - d->counter = 0; - TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(0, kOutOfBand, *d)); - TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(ch2, kOutOfBand, *d)); - TEST_LOG("\nSending out-band telephone events:"); - for(int i = 0; i < 16; i++) - { - TEST_LOG("\n %d ", i); fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, true, 160, 10)); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(ch2, i, true, 160, 10)); - SLEEP(500); - } - TEST_LOG("\nDetected %d events \n", d->counter); - TEST_MUSTPASS(d->counter != 32); - TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); - TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(ch2)); - delete d; + // Out-of-band + d->counter = 0; + TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(0, kOutOfBand, *d)); + TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(ch2, kOutOfBand, *d)); + TEST_LOG("\nSending out-band telephone events:"); + for(int i = 0; i < 16; i++) + { + TEST_LOG("\n %d ", i); fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, true, 160, 10)); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(ch2, i, true, 160, 10)); + SLEEP(500); + } + TEST_LOG("\nDetected %d events \n", d->counter); + TEST_MUSTPASS(d->counter != 32); + TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); + TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(ch2)); + delete d; - AOK(); ANL(); + AOK(); ANL(); #endif - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, false)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, false)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - return 0; + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestEncryption // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestEncryption() -{ - PrepareTest("Encryption"); +int VoEExtendedTest::TestEncryption() { + PrepareTest("Encryption"); - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); - VoEEncryption* encrypt = _mgr.EncryptionPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); + VoEEncryption* encrypt = _mgr.EncryptionPtr(); #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile( - GetFilename("VoEEncryption_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile( + GetFilename("VoEEncryption_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); /////////////////////////// - // Actual test starts here + // Actual test starts here - unsigned char key1[30] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + unsigned char key1[30] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; #ifdef WEBRTC_SRTP - unsigned char key2[30]; // Different than key1 in first position - memcpy(key2, key1, 30); - key2[0] = 99; - unsigned char key3[30]; // Different than key1 in last position - memcpy(key3, key1, 30); - key3[29] = 99; - unsigned char key4[29]; // Same as key1 but shorter - memcpy(key4, key1, 29); + unsigned char key2[30]; // Different than key1 in first position + memcpy(key2, key1, 30); + key2[0] = 99; + unsigned char key3[30]; // Different than key1 in last position + memcpy(key3, key1, 30); + key3[29] = 99; + unsigned char key4[29]; // Same as key1 but shorter + memcpy(key4, key1, 29); - TEST(SRTP - Fail tests); ANL(); + TEST(SRTP - Fail tests); ANL(); - // Send - // Incorrect parameters when not all protection is enabled - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kNoProtection, key1)); - TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kEncryption key1)); - TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kAuthentication, key1)); - TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); - MARK(); - // Incorrect cipher key length - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 15, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 257, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 15, kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 257, kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // Incorrect auth key length - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 21, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthNull, 257, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // Incorrect auth tag length - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 21, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthNull, 20, 13, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); + // Send + // Incorrect parameters when not all protection is enabled + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kNoProtection, key1)); + TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kEncryption key1)); + TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kAuthentication, key1)); + TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); + MARK(); + // Incorrect cipher key length + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 15, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 257, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 15, kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 257, kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // Incorrect auth key length + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 21, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthNull, 257, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // Incorrect auth tag length + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 21, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthNull, 20, 13, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); - // key NULL pointer - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, NULL)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); + // key NULL pointer + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, NULL)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); - // Same for receive - // Incorrect parameters when not all protection is enabled - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kNoProtection, key1)); - TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kEncryption key1)); - TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kAuthentication, key1)); - TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); - MARK(); - // Incorrect cipher key length - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 15, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 257, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 15, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 257, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // Incorrect auth key length - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, - 30, kAuthHmacSha1, 21, 4, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // it crashed the application - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthNull, 257, 4, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // Incorrect auth tag length - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 21, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // it crashed the application - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthNull, 20, 13, - kEncryptionAndAuthentication, - key1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - // key NULL pointer - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - NULL)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - ANL(); + // Same for receive + // Incorrect parameters when not all protection is enabled + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kNoProtection, key1)); + TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kEncryption key1)); + TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kAuthentication, key1)); + TEST_MUSTPASS(VE_SRTP_ERROR != base->LastError()); + MARK(); + // Incorrect cipher key length + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 15, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 257, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 15, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 257, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // Incorrect auth key length + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, + 30, kAuthHmacSha1, 21, 4, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // it crashed the application + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthNull, 257, 4, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // Incorrect auth tag length + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 21, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // it crashed the application + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthNull, 20, 13, + kEncryptionAndAuthentication, + key1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + // key NULL pointer + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + NULL)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + ANL(); - TEST(SRTP - Should hear audio at all time); ANL(); + TEST(SRTP - Should hear audio at all time); ANL(); - // Authentication only - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, - 4, kAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, - 20, 4, kAuthentication, key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); - ANL(); + // Authentication only + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, + 4, kAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, + 20, 4, kAuthentication, key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); + ANL(); - // No protection - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthNull, 0, 0, - kNoProtection, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthNull, 0, 0, - kNoProtection, key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); + // No protection + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthNull, 0, 0, + kNoProtection, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthNull, 0, 0, + kNoProtection, key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); - // Encryption only - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, kEncryption key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, - kEncryption key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); + // Encryption only + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, kEncryption key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, + kEncryption key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); - // Authentication only - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, - 4, kAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, - 20, 4, kAuthentication, key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); - ANL(); + // Authentication only + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, + 4, kAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, + 20, 4, kAuthentication, key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); + ANL(); - // Switching between keys - TEST(SRTP - Different keys - should hear audio at all time); ANL(); + // Switching between keys + TEST(SRTP - Different keys - should hear audio at all time); ANL(); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key2)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key2)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key2)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key2)); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); - ANL(); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key2)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key2)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key2)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key2)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); + ANL(); - // Testing different keys that should be silent - TEST(SRTP - Should be silent or garbage); ANL(); + // Testing different keys that should be silent + TEST(SRTP - Should be silent or garbage); ANL(); - // key1 and key2 - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key2)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key2)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, kEncryption key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, - kEncryption key2)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, - 20, 4, kAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, - 20, 4, kAuthentication, key2)); - MARK(); SLEEP(2000); + // key1 and key2 + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key2)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key2)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, kEncryption key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, + kEncryption key2)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, + 20, 4, kAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, + 20, 4, kAuthentication, key2)); + MARK(); SLEEP(2000); - // key1 and key3 - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key3)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key3)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, kEncryption key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, - kEncryption key3)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, - 4, kAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, - 20, 4, kAuthentication, key3)); - MARK(); SLEEP(2000); + // key1 and key3 + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key3)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key3)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, kEncryption key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, + kEncryption key3)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, + 4, kAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, + 20, 4, kAuthentication, key3)); + MARK(); SLEEP(2000); - // key1 and key4 - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key4)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, key4)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, 20, 4, - kEncryptionAndAuthentication, - key1)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, kEncryption key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthNull, 0, 0, - kEncryption key4)); - MARK(); SLEEP(2000); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, - 4, kAuthentication, key1)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, - 20, 4, kAuthentication, key4)); - MARK(); SLEEP(2000); - ANL(); + // key1 and key4 + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key4)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, key4)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, 20, 4, + kEncryptionAndAuthentication, + key1)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, kEncryption key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthNull, 0, 0, + kEncryption key4)); + MARK(); SLEEP(2000); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherNull, 0, kAuthHmacSha1, 20, + 4, kAuthentication, key1)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherNull, 0, kAuthHmacSha1, + 20, 4, kAuthentication, key4)); + MARK(); SLEEP(2000); + ANL(); - // Back to normal - TEST(SRTP - Back to normal - should hear audio); ANL(); + // Back to normal + TEST(SRTP - Back to normal - should hear audio); ANL(); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - MARK(); SLEEP(2000); - ANL(); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + MARK(); SLEEP(2000); + ANL(); - // SRTCP tests - TEST(SRTCP - Ignore voice or not); ANL(); - VoERTP_RTCP* rtp_rtcp = _mgr.RTP_RTCPPtr(); - char tmpStr[32]; + // SRTCP tests + TEST(SRTCP - Ignore voice or not); ANL(); + VoERTP_RTCP* rtp_rtcp = _mgr.RTP_RTCPPtr(); + char tmpStr[32]; - // First test that RTCP packet is received and OK without encryption + // First test that RTCP packet is received and OK without encryption - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik1")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik1", tmpStr)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik1")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik1", tmpStr)); - // Enable SRTP and SRTCP send and receive - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1, true)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1, true)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik2")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); + // Enable SRTP and SRTCP send and receive + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1, true)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1, true)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik2")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); - // Disable SRTP and SRTCP send - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik3")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed + // Disable SRTP and SRTCP send + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik3")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed - // Enable SRTP send, but disable SRTCP send - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik4")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed + // Enable SRTP send, but disable SRTCP send + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik4")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed - // Enable SRTP and SRTCP send, disable SRTP and SRTCP receive - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1, true)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik5")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed + // Enable SRTP and SRTCP send, disable SRTP and SRTCP receive + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1, true)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik5")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed - // Enable SRTP receive, but disable SRTCP receive - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik6")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed + // Enable SRTP receive, but disable SRTCP receive + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, kCipherAes128CounterMode, 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik6")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik2", tmpStr)); // Should not have changed - // Disable all - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik7")); - MARK(); SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(_stricmp("Henrik7", tmpStr)); - ANL(); + // Disable all + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Henrik7")); + MARK(); SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(_stricmp("Henrik7", tmpStr)); + ANL(); #else - TEST(SRTP disabled - Fail tests); - ANL(); + TEST(SRTP disabled - Fail tests); + ANL(); - TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, key1)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - TEST_MUSTPASS(!encrypt->DisableSRTPSend(0)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - TEST_MUSTPASS(!encrypt->DisableSRTPReceive(0)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - ANL(); + TEST_MUSTPASS(!encrypt->EnableSRTPSend(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!encrypt->EnableSRTPReceive(0, kCipherNull, 30, kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, key1)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!encrypt->DisableSRTPSend(0)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!encrypt->DisableSRTPReceive(0)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + ANL(); #endif - AOK(); + AOK(); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - return 0; + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestExternalMedia // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestExternalMedia() -{ - PrepareTest("VoEExternalMedia"); +int VoEExtendedTest::TestExternalMedia() { + PrepareTest("VoEExternalMedia"); - VoEBase* base = _mgr.BasePtr(); - VoEExternalMedia* xmedia = _mgr.ExternalMediaPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEExternalMedia* xmedia = _mgr.ExternalMediaPtr(); - // check if this interface is supported - if (!xmedia) - { - TEST_LOG("VoEExternalMedia is not supported!"); - return -1; - } + // check if this interface is supported + if (!xmedia) { + TEST_LOG("VoEExternalMedia is not supported!"); + return -1; + } #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile( - GetFilename("VoEExternalMedia_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter( - kTraceStateInfo | kTraceStateInfo | kTraceWarning | - kTraceError | kTraceCritical | kTraceApiCall | - kTraceMemory | kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile( + GetFilename("VoEExternalMedia_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter( + kTraceStateInfo | kTraceStateInfo | kTraceWarning | + kTraceError | kTraceCritical | kTraceApiCall | + kTraceMemory | kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); - int getLen = 0; - WebRtc_Word16 vector[32000]; - memset(vector, 0, 32000 * sizeof(short)); + int getLen = 0; + WebRtc_Word16 vector[32000]; + memset(vector, 0, 32000 * sizeof(short)); #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT - // ExternalPlayoutGetData - TEST(ExternalPlayoutGetData); - ANL(); + // ExternalPlayoutGetData + TEST(ExternalPlayoutGetData); + ANL(); - TEST_MUSTPASS(!xmedia->SetExternalPlayoutStatus(true)); - TEST_MUSTPASS(VE_ALREADY_SENDING != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 16000, 100, getLen)); - TEST_MUSTPASS(VE_INVALID_OPERATION != base->LastError()); + TEST_MUSTPASS(!xmedia->SetExternalPlayoutStatus(true)); + TEST_MUSTPASS(VE_ALREADY_SENDING != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 16000, 100, getLen)); + TEST_MUSTPASS(VE_INVALID_OPERATION != base->LastError()); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(true)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(true)); + TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(xmedia->ExternalPlayoutGetData(vector, 48000, 0, getLen)); - TEST_MUSTPASS(480 != getLen); - SLEEP(10); - TEST_MUSTPASS(xmedia->ExternalPlayoutGetData(vector, 16000, 3000, getLen)); - TEST_MUSTPASS(160 != getLen); - SLEEP(10); + TEST_MUSTPASS(xmedia->ExternalPlayoutGetData(vector, 48000, 0, getLen)); + TEST_MUSTPASS(480 != getLen); + SLEEP(10); + TEST_MUSTPASS(xmedia->ExternalPlayoutGetData(vector, 16000, 3000, getLen)); + TEST_MUSTPASS(160 != getLen); + SLEEP(10); - TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 8000, 100, getLen)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 16000, -1, getLen)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 8000, 100, getLen)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 16000, -1, getLen)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(false)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(false)); + TEST_MUSTPASS(base->StartPlayout(0)); - // SetExternalRecording - TEST(SetExternalRecording); - ANL(); + // SetExternalRecording + TEST(SetExternalRecording); + ANL(); - TEST_MUSTPASS(!xmedia->SetExternalRecordingStatus(true)); - TEST_MUSTPASS(VE_ALREADY_SENDING != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 160, 16000, 20)); - TEST_MUSTPASS(VE_INVALID_OPERATION != base->LastError()); + TEST_MUSTPASS(!xmedia->SetExternalRecordingStatus(true)); + TEST_MUSTPASS(VE_ALREADY_SENDING != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 160, 16000, 20)); + TEST_MUSTPASS(VE_INVALID_OPERATION != base->LastError()); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(true)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(true)); + TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(xmedia->ExternalRecordingInsertData(vector, 480, 48000, 0)); - SLEEP(10); - TEST_MUSTPASS(xmedia->ExternalRecordingInsertData(vector, 640, 16000, 0)); - SLEEP(40); + TEST_MUSTPASS(xmedia->ExternalRecordingInsertData(vector, 480, 48000, 0)); + SLEEP(10); + TEST_MUSTPASS(xmedia->ExternalRecordingInsertData(vector, 640, 16000, 0)); + SLEEP(40); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 160, 16000, -1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 80, 8000, 20)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 0, 16000, 20)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 80, 16000, 20)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 500, 16000, 20)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 160, 16000, -1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 80, 8000, 20)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 0, 16000, 20)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 80, 16000, 20)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 500, 16000, 20)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(false)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(false)); + TEST_MUSTPASS(base->StartSend(0)); #else // #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT - TEST_MUSTPASS(!xmedia->SetExternalPlayoutStatus(true)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 16000, 100, getLen)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - TEST_MUSTPASS(!xmedia->SetExternalRecordingStatus(true)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); - TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 160, 16000, 20)); - TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!xmedia->SetExternalPlayoutStatus(true)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalPlayoutGetData(vector, 16000, 100, getLen)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!xmedia->SetExternalRecordingStatus(true)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); + TEST_MUSTPASS(!xmedia->ExternalRecordingInsertData(vector, 160, 16000, 20)); + TEST_MUSTPASS(VE_FUNC_NOT_SUPPORTED != base->LastError()); #endif // #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - ANL(); - AOK(); - return 0; + ANL(); + AOK(); + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestFile // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestFile() -{ - PrepareTest("File"); +int VoEExtendedTest::TestFile() { + PrepareTest("File"); - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); - VoECodec* codec = _mgr.CodecPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); + VoECodec* codec = _mgr.CodecPtr(); #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile( - GetFilename("VoEFile_trace.txt"))); MARK(); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile( + GetFilename("VoEFile_trace.txt"))); MARK(); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); - /////////////////////////// - // Actual test starts here + /////////////////////////// + // Actual test starts here - const int dT(100); + const int dT(100); - TEST(StartPlayingFileLocally); - ANL(); - TEST(StopPlayingFileLocally); - ANL(); + TEST(StartPlayingFileLocally); + ANL(); + TEST(StopPlayingFileLocally); + ANL(); - base->StopPlayout(0); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"))); MARK(); - base->StartPlayout(0); - MARK(); // file should be mixed in and played out - SLEEP(dT); - TEST_MUSTPASS(!file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"))); - MARK(); // should fail (must stop first) - TEST_MUSTPASS(base->LastError() != VE_ALREADY_PLAYING); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"))); - MARK(); // should work again (restarts file) - SLEEP(dT); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"), false, kFileFormatPcm16kHzFile)); - MARK(); - SLEEP(dT); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long8.pcm"), false, kFileFormatPcm8kHzFile)); - MARK(); - SLEEP(dT); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.wav"), false, kFileFormatPcm8kHzFile)); - MARK(); - SLEEP(dT); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long8mulaw.wav"), false, - kFileFormatPcm8kHzFile)); - MARK(); - SLEEP(dT); + base->StopPlayout(0); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm")));MARK(); + base->StartPlayout(0); + MARK(); // file should be mixed in and played out + SLEEP(dT); + TEST_MUSTPASS(!file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm"))); + MARK(); // should fail (must stop first) + TEST_MUSTPASS(base->LastError() != VE_ALREADY_PLAYING); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm"))); + MARK(); // should work again (restarts file) + SLEEP(dT); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm"), false, kFileFormatPcm16kHzFile)); + MARK(); + SLEEP(dT); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long8.pcm"), false, kFileFormatPcm8kHzFile)); + MARK(); + SLEEP(dT); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.wav"), false, kFileFormatPcm8kHzFile)); + MARK(); + SLEEP(dT); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long8mulaw.wav"), false, + kFileFormatPcm8kHzFile)); + MARK(); + SLEEP(dT); - // add compressed tests here... + // add compressed tests here... - // TEST_MUSTPASS(file->StopPlayingFileLocally(0)); MARK(); - // TEST_MUSTPASS(file->StartPlayingFileLocally( - // 0, GetResource("audio_short16.pcm"), true, - // kFileFormatPcm16kHzFile)); MARK(); // loop - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_short16.pcm"), false, - kFileFormatPcm16kHzFile, 1.0, 0, 2000)); - MARK(); // play segment - SLEEP(2500); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(!file->StartPlayingFileLocally( - 0, GetResource("audio_short16.pcm"), false, - kFileFormatPcm16kHzFile, 1.0, 2000, 1000)); - MARK(); // invalid segment - TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); - TEST_MUSTPASS(!file->StartPlayingFileLocally( - 0, GetResource("audio_short16.pcm"), false, - kFileFormatPcm16kHzFile, 1.0, 21000, 30000)); - MARK(); // start > file size - TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); - TEST_MUSTPASS(!file->StartPlayingFileLocally( - 0, GetResource("audio_short16.pcm"), false, - kFileFormatPcm16kHzFile, 1.0, 100, 100)); - MARK(); // invalid segment - TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"))); - MARK(); // should work again (restarts file) - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - TEST_MUSTPASS(!file->StartPlayingFileLocally(0, (InStream*)NULL)); - MARK(); // just do it - TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); + // TEST_MUSTPASS(file->StopPlayingFileLocally(0)); MARK(); + // TEST_MUSTPASS(file->StartPlayingFileLocally( + // 0, GetResource("audio_short16.pcm"), true, + // kFileFormatPcm16kHzFile)); MARK(); // loop + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_short16.pcm"), false, + kFileFormatPcm16kHzFile, 1.0, 0, 2000)); + MARK(); // play segment + SLEEP(2500); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(!file->StartPlayingFileLocally( + 0, GetResource("audio_short16.pcm"), false, + kFileFormatPcm16kHzFile, 1.0, 2000, 1000)); + MARK(); // invalid segment + TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); + TEST_MUSTPASS(!file->StartPlayingFileLocally( + 0, GetResource("audio_short16.pcm"), false, + kFileFormatPcm16kHzFile, 1.0, 21000, 30000)); + MARK(); // start > file size + TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); + TEST_MUSTPASS(!file->StartPlayingFileLocally( + 0, GetResource("audio_short16.pcm"), false, + kFileFormatPcm16kHzFile, 1.0, 100, 100)); + MARK(); // invalid segment + TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm"))); + MARK(); // should work again (restarts file) + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + TEST_MUSTPASS(!file->StartPlayingFileLocally(0, (InStream*)NULL)); + MARK(); // just do it + TEST_MUSTPASS(base->LastError() != VE_BAD_FILE); - AOK(); - ANL(); + AOK(); + ANL(); - TEST(IsPlayingFileLocally); - ANL(); + TEST(IsPlayingFileLocally); + ANL(); - TEST_MUSTPASS(0 != file->IsPlayingFileLocally(0)); - MARK(); // inactive - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"))); - MARK(); - TEST_MUSTPASS(1 != file->IsPlayingFileLocally(0)); - MARK(); // active - AOK(); - ANL(); + TEST_MUSTPASS(0 != file->IsPlayingFileLocally(0)); + MARK(); // inactive + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm"))); + MARK(); + TEST_MUSTPASS(1 != file->IsPlayingFileLocally(0)); + MARK(); // active + AOK(); + ANL(); - TEST(ScaleLocalFilePlayout); - ANL(); - TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 1.0)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 0.0)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 0.5)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 0.25)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - MARK(); - AOK(); - ANL(); + TEST(ScaleLocalFilePlayout); + ANL(); + TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 1.0)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 0.0)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 0.5)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->ScaleLocalFilePlayout(0, 0.25)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + MARK(); + AOK(); + ANL(); - // Replace microphone with file and play out on remote side - // All channels, per channel - // Different mixing frequencies - TEST(StartPlayingFileAsMicrophone); - ANL(); - TEST(IsPlayingFileAsMicrophone); - ANL(); - TEST(ScaleFileAsMicrophonePlayout); - ANL(); - CodecInst tempCodec; - for (int ch = -1; ch < 1; ++ch) // Channel -1 and 0 + // Replace microphone with file and play out on remote side + // All channels, per channel + // Different mixing frequencies + TEST(StartPlayingFileAsMicrophone); + ANL(); + TEST(IsPlayingFileAsMicrophone); + ANL(); + TEST(ScaleFileAsMicrophonePlayout); + ANL(); + CodecInst tempCodec; + for (int ch = -1; ch < 1; ++ch) // Channel -1 and 0 + { + TEST_LOG("Testing channel = %d \n", ch); + for (int fs = 1; fs < 4; ++fs) // nb, wb and swb codecs { - TEST_LOG("Testing channel = %d \n", ch); - for (int fs = 1; fs < 4; ++fs) // nb, wb and swb codecs - { - switch (fs) - { - case 1: // nb - TEST_LOG("Testing with nb codec \n"); - tempCodec.channels = 1; - tempCodec.pacsize = 160; - tempCodec.plfreq = 8000; - strcpy(tempCodec.plname, "PCMU"); - tempCodec.pltype = 0; - tempCodec.rate = 64000; - break; - case 2: // wb + switch (fs) { + case 1: // nb + TEST_LOG("Testing with nb codec \n"); + tempCodec.channels = 1; + tempCodec.pacsize = 160; + tempCodec.plfreq = 8000; + strcpy(tempCodec.plname, "PCMU"); + tempCodec.pltype = 0; + tempCodec.rate = 64000; + break; + case 2: // wb #ifdef WEBRTC_CODEC_ISAC - TEST_LOG("Testing with wb codec \n"); - tempCodec.channels = 1; - tempCodec.pacsize = 480; - tempCodec.plfreq = 16000; - strcpy(tempCodec.plname, "ISAC"); - tempCodec.pltype = 103; - tempCodec.rate = 32000; - break; + TEST_LOG("Testing with wb codec \n"); + tempCodec.channels = 1; + tempCodec.pacsize = 480; + tempCodec.plfreq = 16000; + strcpy(tempCodec.plname, "ISAC"); + tempCodec.pltype = 103; + tempCodec.rate = 32000; + break; #else - TEST_LOG("NOT testing with wb codec - " - "WEBRTC_CODEC_ISAC not defined \n"); - continue; + TEST_LOG("NOT testing with wb codec - " + "WEBRTC_CODEC_ISAC not defined \n"); + continue; #endif - case 3: // swb + case 3: // swb #ifdef WEBRTC_CODEC_PCM16 - TEST_LOG("Testing with swb codec \n"); - tempCodec.channels = 1; - tempCodec.pacsize = 640; - tempCodec.plfreq = 32000; - strcpy(tempCodec.plname, "L16"); - tempCodec.pltype = 125; - tempCodec.rate = 512000; - break; + TEST_LOG("Testing with swb codec \n"); + tempCodec.channels = 1; + tempCodec.pacsize = 640; + tempCodec.plfreq = 32000; + strcpy(tempCodec.plname, "L16"); + tempCodec.pltype = 125; + tempCodec.rate = 512000; + break; #else - TEST_LOG("NOT testing with swb codec -" - " WEBRTC_CODEC_PCM16 not defined \n"); - continue; + TEST_LOG("NOT testing with swb codec -" + " WEBRTC_CODEC_PCM16 not defined \n"); + continue; #endif - } - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, tempCodec)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(codec->SetSendCodec(0, tempCodec)); + } + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, tempCodec)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(codec->SetSendCodec(0, tempCodec)); - TEST_LOG("File 1 in 16 kHz no mix, 2 in 16 kHz mix," - " 3 in 8 kHz no mix, 4 in 8 kHz mix \n"); + TEST_LOG("File 1 in 16 kHz no mix, 2 in 16 kHz mix," + " 3 in 8 kHz no mix, 4 in 8 kHz mix \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - ch, GetResource("audio_long16.pcm"))); - MARK(); // don't mix - SLEEP(2000); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - ch, GetResource("audio_long16.wav"), false, true, - kFileFormatWavFile)); - MARK(); // mix - SLEEP(2000); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - ch, GetResource("audio_long8.pcm"), false, false, - kFileFormatPcm8kHzFile)); - MARK(); // don't mix - SLEEP(2000); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); - MARK(); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - ch, GetResource("audio_long8.pcm"), false, true, - kFileFormatPcm8kHzFile)); - MARK(); // mix - SLEEP(2000); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); - MARK(); - TEST_MUSTPASS(!file->StartPlayingFileAsMicrophone( - ch, (InStream*)NULL)); - MARK(); // force error - AOK(); - ANL(); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + ch, GetResource("audio_long16.pcm"))); + MARK(); // don't mix + SLEEP(2000); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + ch, GetResource("audio_long16.wav"), false, true, + kFileFormatWavFile)); + MARK(); // mix + SLEEP(2000); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + ch, GetResource("audio_long8.pcm"), false, false, + kFileFormatPcm8kHzFile)); + MARK(); // don't mix + SLEEP(2000); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); + MARK(); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + ch, GetResource("audio_long8.pcm"), false, true, + kFileFormatPcm8kHzFile)); + MARK(); // mix + SLEEP(2000); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); + MARK(); + TEST_MUSTPASS(!file->StartPlayingFileAsMicrophone( + ch, (InStream*)NULL)); + MARK(); // force error + AOK(); + ANL(); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - ch, GetResource("audio_long16.pcm"))); - TEST_MUSTPASS(1 != file->IsPlayingFileAsMicrophone(ch)); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); - TEST_MUSTPASS(0 != file->IsPlayingFileAsMicrophone(ch)); - AOK(); - ANL(); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + ch, GetResource("audio_long16.pcm"))); + TEST_MUSTPASS(1 != file->IsPlayingFileAsMicrophone(ch)); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); + TEST_MUSTPASS(0 != file->IsPlayingFileAsMicrophone(ch)); + AOK(); + ANL(); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - ch, GetResource("audio_long16.pcm"))); - TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 1.0)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 0.5)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 0.25)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 0.0)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); - MARK(); - AOK(); - ANL(); - } + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + ch, GetResource("audio_long16.pcm"))); + TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 1.0)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 0.5)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 0.25)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(ch, 0.0)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(ch)); + MARK(); + AOK(); + ANL(); } + } - // Record speaker signal to file + // Record speaker signal to file - CodecInst fcomp = { 0, "L16", 8000, 80, 1, 128000 }; + CodecInst fcomp = { 0, "L16", 8000, 80, 1, 128000 }; - TEST(StartRecordingPlayout); - ANL(); - TEST(StopRecordingPlayout); - ANL(); + TEST(StartRecordingPlayout); + ANL(); + TEST(StopRecordingPlayout); + ANL(); - TEST_MUSTPASS(file->StartRecordingPlayout(0, - GetFilename("rec_play16.pcm"))); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); - MARK(); + TEST_MUSTPASS(file->StartRecordingPlayout(0, + GetFilename("rec_play16.pcm"))); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); + MARK(); - fcomp.plfreq = 8000; - strcpy(fcomp.plname, "L16"); - TEST_MUSTPASS(file->StartRecordingPlayout(0, GetFilename("rec_play8.wav"), - &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); - MARK(); + fcomp.plfreq = 8000; + strcpy(fcomp.plname, "L16"); + TEST_MUSTPASS(file->StartRecordingPlayout(0, GetFilename("rec_play8.wav"), + &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); + MARK(); fcomp.plfreq = 16000; - strcpy(fcomp.plname, "L16"); - TEST_MUSTPASS(file->StartRecordingPlayout(0, GetFilename("rec_play16.wav"), - &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); - MARK(); + strcpy(fcomp.plname, "L16"); + TEST_MUSTPASS(file->StartRecordingPlayout(0, GetFilename("rec_play16.wav"), + &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); + MARK(); - fcomp.pltype = 0; - fcomp.plfreq = 8000; - strcpy(fcomp.plname, "PCMU"); - fcomp.rate = 64000; - fcomp.pacsize = 160; - fcomp.channels = 1; + fcomp.pltype = 0; + fcomp.plfreq = 8000; + strcpy(fcomp.plname, "PCMU"); + fcomp.rate = 64000; + fcomp.pacsize = 160; + fcomp.channels = 1; - TEST_MUSTPASS(file->StartRecordingPlayout(0, - GetFilename("rec_play_pcmu.wav"), - &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); - MARK(); + TEST_MUSTPASS(file->StartRecordingPlayout(0, + GetFilename("rec_play_pcmu.wav"), + &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); + MARK(); - fcomp.pltype = 8; - fcomp.plfreq = 8000; - strcpy(fcomp.plname, "PCMA"); - TEST_MUSTPASS(file->StartRecordingPlayout(0, - GetFilename("rec_play_pcma.wav"), - &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); - MARK(); + fcomp.pltype = 8; + fcomp.plfreq = 8000; + strcpy(fcomp.plname, "PCMA"); + TEST_MUSTPASS(file->StartRecordingPlayout(0, + GetFilename("rec_play_pcma.wav"), + &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); + MARK(); - fcomp.pltype = 97; - fcomp.pacsize = 240; - fcomp.rate = 13300; - fcomp.plfreq = 8000; - strcpy(fcomp.plname, "ILBC"); - TEST_MUSTPASS(file->StartRecordingPlayout(0, - GetFilename("rec_play.ilbc"), - &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); - MARK(); + fcomp.pltype = 97; + fcomp.pacsize = 240; + fcomp.rate = 13300; + fcomp.plfreq = 8000; + strcpy(fcomp.plname, "ILBC"); + TEST_MUSTPASS(file->StartRecordingPlayout(0, + GetFilename("rec_play.ilbc"), + &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); + MARK(); - TEST_MUSTPASS(file->StartRecordingPlayout( - -1, GetFilename("rec_play16_mixed.pcm"))); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingPlayout(-1)); - MARK(); + TEST_MUSTPASS(file->StartRecordingPlayout( + -1, GetFilename("rec_play16_mixed.pcm"))); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingPlayout(-1)); + MARK(); - // TEST_MUSTPASS(file->StopPlayingFileLocally(0)); // Why should this work? + // TEST_MUSTPASS(file->StopPlayingFileLocally(0)); // Why should this work? + TEST_LOG("\nplaying out...\n"); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetFilename("rec_play.ilbc"), false, kFileFormatCompressedFile)); + MARK(); + SLEEP(2000); - TEST_LOG("\nplaying out...\n"); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetFilename("rec_play.ilbc"), false, kFileFormatCompressedFile)); - MARK(); - SLEEP(2000); + AOK(); + ANL(); - AOK(); - ANL(); + // Record microphone signal to file + TEST(StartRecordingMicrophone); + ANL(); + TEST(StopRecordingMicrophone); + ANL(); - // Record microphone signal to file + TEST_MUSTPASS(file->StartRecordingMicrophone(GetFilename("rec_mic16.pcm"))); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); - TEST(StartRecordingMicrophone); - ANL(); - TEST(StopRecordingMicrophone); - ANL(); + base->StopSend(0); + TEST_MUSTPASS(file->StartRecordingMicrophone(GetFilename("rec_mic16.pcm"))); + MARK(); // record without sending as well + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); + base->StartSend(0); // restore sending - TEST_MUSTPASS(file->StartRecordingMicrophone(GetFilename("rec_mic16.pcm"))); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); + fcomp.plfreq = 8000; + strcpy(fcomp.plname, "L16"); + TEST_MUSTPASS(file->StartRecordingMicrophone( + GetFilename("rec_play8.wav"), &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); - base->StopSend(0); - TEST_MUSTPASS(file->StartRecordingMicrophone(GetFilename("rec_mic16.pcm"))); - MARK(); // record without sending as well - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); - base->StartSend(0); // restore sending + fcomp.plfreq = 16000; + strcpy(fcomp.plname, "L16"); + TEST_MUSTPASS(file->StartRecordingMicrophone( + GetFilename("rec_play16.wav"), &fcomp)); + SLEEP(1000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); - fcomp.plfreq = 8000; - strcpy(fcomp.plname, "L16"); - TEST_MUSTPASS(file->StartRecordingMicrophone( - GetFilename("rec_play8.wav"), &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); + // FT#1810, the following test is to make sure StartRecordingCall will + // record both mic and file + TEST_LOG("StartRecordingCall, record both mic and file in specific" + " channels \n"); + TEST_LOG("Create maxnumofchannels \n"); + for (int i = 1; i < base->MaxNumOfChannels(); i++) { + int ch = base->CreateChannel(); + TEST_MUSTPASS(ch == -1); + TEST_MUSTPASS(base->StopPlayout(ch)); + } - fcomp.plfreq = 16000; - strcpy(fcomp.plname, "L16"); - TEST_MUSTPASS(file->StartRecordingMicrophone( - GetFilename("rec_play16.wav"), &fcomp)); - SLEEP(1000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); + TEST_MUSTPASS(base->SetSendDestination(1, 12356, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(1, 12356)); + TEST_MUSTPASS(base->StartReceive(1)); + TEST_MUSTPASS(base->StopPlayout(1)); + TEST_MUSTPASS(base->StartSend(1)); + TEST_MUSTPASS(base->StartPlayout(1)); - // FT#1810, the following test is to make sure StartRecordingCall will - // record both mic and file - TEST_LOG("StartRecordingCall, record both mic and file in specific" - " channels \n"); - TEST_LOG("Create maxnumofchannels \n"); - for (int i = 1; i < base->MaxNumOfChannels(); i++) - { - int ch = base->CreateChannel(); - TEST_MUSTPASS(ch == -1); - TEST_MUSTPASS(base->StopPlayout(ch)); - } + TEST_LOG("ALways playing audio_long16.pcm for " + "channel 0 in background \n"); + fcomp.plfreq = 16000; + strcpy(fcomp.plname, "L16"); + TEST_LOG("Recording microphone to L16, please speak \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, GetResource("audio_long16.pcm"), true , true)); + TEST_MUSTPASS(file->StartRecordingMicrophone( + GetFilename("rec_play_ch.wav"), &fcomp)); + MARK(); + SLEEP(3000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_LOG("Playing recording file, you should only hear what you said \n"); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetFilename("rec_play_ch.wav"), false, kFileFormatWavFile)); + SLEEP(2500); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + TEST_LOG("Recording microphone 0 to L16, please speak \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + -1, GetResource("audio_long16.pcm"), true , true)); + TEST_MUSTPASS(file->StartRecordingMicrophone( + GetFilename("rec_play_ch_0.wav"), &fcomp)); + MARK(); + SLEEP(3000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(-1)); + TEST_LOG("Playing recording file, you should hear what you said and" + " audio_long16.pcm \n"); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetFilename("rec_play_ch_0.wav"), false, kFileFormatWavFile)); + SLEEP(2500); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + TEST_LOG("Recording microphone to ilbc, please speak \n"); + strcpy(fcomp.plname, "ilbc"); + fcomp.plfreq = 8000; + fcomp.pacsize = 160; + fcomp.rate = 15200; + fcomp.channels = 1; + fcomp.pltype = 97; + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, GetResource("audio_long16.pcm"), true , true)); + TEST_MUSTPASS(file->StartRecordingMicrophone( + GetFilename("rec_play_ch_0.ilbc"), &fcomp)); + MARK(); + SLEEP(3000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + MARK(); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_LOG("Playing recording file, you should only hear what you said \n"); + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetFilename("rec_play_ch_0.ilbc"), false, + kFileFormatCompressedFile)); + SLEEP(2500); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + for (int i = 1; i < base->MaxNumOfChannels(); i++) { + TEST_MUSTPASS(base->DeleteChannel(i)); + } - TEST_MUSTPASS(base->SetSendDestination(1, 12356, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(1, 12356)); - TEST_MUSTPASS(base->StartReceive(1)); - TEST_MUSTPASS(base->StopPlayout(1)); - TEST_MUSTPASS(base->StartSend(1)); - TEST_MUSTPASS(base->StartPlayout(1)); + AOK(); + ANL(); - TEST_LOG("ALways playing audio_long16.pcm for " - "channel 0 in background \n"); - fcomp.plfreq = 16000; - strcpy(fcomp.plname, "L16"); - TEST_LOG("Recording microphone to L16, please speak \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - 0, GetResource("audio_long16.pcm"), true , true)); - TEST_MUSTPASS(file->StartRecordingMicrophone( - GetFilename("rec_play_ch.wav"), &fcomp)); - MARK(); - SLEEP(3000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_LOG("Playing recording file, you should only hear what you said \n"); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetFilename("rec_play_ch.wav"), false, kFileFormatWavFile)); - SLEEP(2500); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - TEST_LOG("Recording microphone 0 to L16, please speak \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - -1, GetResource("audio_long16.pcm"), true , true)); - TEST_MUSTPASS(file->StartRecordingMicrophone( - GetFilename("rec_play_ch_0.wav"), &fcomp)); - MARK(); - SLEEP(3000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(-1)); - TEST_LOG("Playing recording file, you should hear what you said and" - " audio_long16.pcm \n"); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetFilename("rec_play_ch_0.wav"), false, kFileFormatWavFile)); - SLEEP(2500); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - TEST_LOG("Recording microphone to ilbc, please speak \n"); - strcpy(fcomp.plname, "ilbc"); - fcomp.plfreq = 8000; - fcomp.pacsize = 160; - fcomp.rate = 15200; - fcomp.channels = 1; - fcomp.pltype = 97; - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - 0, GetResource("audio_long16.pcm"), true , true)); - TEST_MUSTPASS(file->StartRecordingMicrophone( - GetFilename("rec_play_ch_0.ilbc"), &fcomp)); - MARK(); - SLEEP(3000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - MARK(); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_LOG("Playing recording file, you should only hear what you said \n"); - TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetFilename("rec_play_ch_0.ilbc"), false, - kFileFormatCompressedFile)); - SLEEP(2500); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - for (int i = 1; i < base->MaxNumOfChannels(); i++) - { - TEST_MUSTPASS(base->DeleteChannel(i)); - } - - AOK(); - ANL(); - - // Record mixed (speaker + microphone) signal to file + // Record mixed (speaker + microphone) signal to file #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) - TEST(StartRecordingSpeakerStereo); - ANL(); - TEST(StopRecordingSpeakerStereo); - ANL(); + TEST(StartRecordingSpeakerStereo); + ANL(); + TEST(StopRecordingSpeakerStereo); + ANL(); - VoEHardware* hardware = _mgr.HardwarePtr(); - TEST_MUSTPASS(NULL == hardware); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); + VoEHardware* hardware = _mgr.HardwarePtr(); + TEST_MUSTPASS(NULL == hardware); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); #if defined(_WIN32) - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); #else - TEST_MUSTPASS(hardware->SetRecordingDevice(0)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); + TEST_MUSTPASS(hardware->SetRecordingDevice(0)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); #endif - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - MARK(); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + MARK(); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); #if defined(_WIN32) - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); #else - TEST_MUSTPASS(hardware->SetRecordingDevice(0)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); + TEST_MUSTPASS(hardware->SetRecordingDevice(0)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); #endif - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); - AOK(); - ANL(); + AOK(); + ANL(); #else - TEST_LOG("Skipping stereo record tests -" - " MAC_IPHONE or WEBRTC_ANDROID is defined \n"); + TEST_LOG("Skipping stereo record tests -" + " MAC_IPHONE or WEBRTC_ANDROID is defined \n"); #endif // #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) - // Conversion between different file formats + // Conversion between different file formats #if defined(MAC_IPHONE) || defined(WEBRTC_ANDROID) - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); #endif - TEST(ConvertPCMToWAV); - ANL(); + TEST(ConvertPCMToWAV); + ANL(); - TEST_MUSTPASS(file->ConvertPCMToWAV( - GetResource("audio_long16.pcm"), - GetFilename("singleUserDemoConv.wav"))); - MARK(); - TEST_MUSTPASS(!file->ConvertPCMToWAV((InStream*)NULL, - (OutStream*)NULL)); MARK(); // invalid stream handles - AOK(); - ANL(); + TEST_MUSTPASS(file->ConvertPCMToWAV( + GetResource("audio_long16.pcm"), + GetFilename("singleUserDemoConv.wav"))); + MARK(); + TEST_MUSTPASS(!file->ConvertPCMToWAV((InStream*)NULL, + (OutStream*)NULL));MARK(); // invalid stream handles + AOK(); + ANL(); - TEST(ConvertWAVToPCM); - ANL(); + TEST(ConvertWAVToPCM); + ANL(); - TEST_MUSTPASS(file->ConvertWAVToPCM( - GetResource("audio_long16.wav"), - GetFilename("singleUserDemoConv.pcm"))); - MARK(); - TEST_MUSTPASS(!file->ConvertWAVToPCM((InStream*)NULL, (OutStream*)NULL)); - MARK(); // invalid stream handles - AOK(); - ANL(); + TEST_MUSTPASS(file->ConvertWAVToPCM( + GetResource("audio_long16.wav"), + GetFilename("singleUserDemoConv.pcm"))); + MARK(); + TEST_MUSTPASS(!file->ConvertWAVToPCM((InStream*)NULL, (OutStream*)NULL)); + MARK(); // invalid stream handles + AOK(); + ANL(); - TEST(ConvertPCMToCompressed); - ANL(); + TEST(ConvertPCMToCompressed); + ANL(); - fcomp.plfreq = 16000; - strcpy(fcomp.plname, "L16"); - TEST_MUSTPASS(!file->ConvertPCMToCompressed( - GetResource("audio_long16.pcm"), - GetFilename("singleUserDemoConv16_dummy.wav"), &fcomp)); - MARK(); // should not be supported + fcomp.plfreq = 16000; + strcpy(fcomp.plname, "L16"); + TEST_MUSTPASS(!file->ConvertPCMToCompressed( + GetResource("audio_long16.pcm"), + GetFilename("singleUserDemoConv16_dummy.wav"), &fcomp)); + MARK(); // should not be supported - fcomp.plfreq = 8000; strcpy(fcomp.plname, "ilbc"); fcomp.pacsize = 160; - fcomp.rate=15200; fcomp.pltype=97; fcomp.channels=1; - TEST_MUSTPASS(file->ConvertPCMToCompressed( - GetResource("audio_long16.pcm"), - GetFilename("singleUserDemoConv.ilbc"), &fcomp)); MARK(); - AOK(); ANL(); + fcomp.plfreq = 8000; + strcpy(fcomp.plname, "ilbc"); + fcomp.pacsize = 160; + fcomp.rate = 15200; + fcomp.pltype = 97; + fcomp.channels = 1; + TEST_MUSTPASS(file->ConvertPCMToCompressed( + GetResource("audio_long16.pcm"), + GetFilename("singleUserDemoConv.ilbc"), &fcomp));MARK(); + AOK();ANL(); - TEST(ConvertCompressedToPCM); - ANL(); + TEST(ConvertCompressedToPCM); + ANL(); - TEST_MUSTPASS(file->ConvertCompressedToPCM( - GetFilename("singleUserDemoConv.ilbc"), - GetFilename("singleUserDemoConv_ilbc.pcm"))); MARK(); - TEST_MUSTPASS(!file->ConvertCompressedToPCM( - GetResource("audio_long16.pcm"), - GetFilename("singleUserDemoConv_dummy.pcm"))); MARK(); - AOK(); ANL(); + TEST_MUSTPASS(file->ConvertCompressedToPCM( + GetFilename("singleUserDemoConv.ilbc"), + GetFilename("singleUserDemoConv_ilbc.pcm")));MARK(); + TEST_MUSTPASS(!file->ConvertCompressedToPCM( + GetResource("audio_long16.pcm"), + GetFilename("singleUserDemoConv_dummy.pcm")));MARK(); + AOK();ANL(); #if defined(MAC_IPHONE) || defined(WEBRTC_ANDROID) - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); #endif - // Misc file functions + // Misc file functions + TEST(GetFileDuration); + ANL(); - TEST(GetFileDuration); - ANL(); + int dur; - int dur; + TEST_MUSTPASS(file->GetFileDuration( + GetResource("audio_long16.pcm"), dur)); + TEST_MUSTPASS(file->GetFileDuration( + GetResource("audio_long8.pcm"), dur, kFileFormatPcm8kHzFile)); + TEST_MUSTPASS(file->GetFileDuration( + GetResource("audio_long16.pcm"), dur, kFileFormatPcm16kHzFile)); + TEST_MUSTPASS(file->GetFileDuration( + GetResource("audio_long16.wav"), dur, kFileFormatPcm8kHzFile)); + TEST_MUSTPASS(file->GetFileDuration( + GetFilename("singleUserDemoConv.ilbc"), dur, + kFileFormatCompressedFile)); - TEST_MUSTPASS(file->GetFileDuration( - GetResource("audio_long16.pcm"), dur)); - TEST_MUSTPASS(file->GetFileDuration( - GetResource("audio_long8.pcm"), dur, kFileFormatPcm8kHzFile)); - TEST_MUSTPASS(file->GetFileDuration( - GetResource("audio_long16.pcm"), dur, kFileFormatPcm16kHzFile)); - TEST_MUSTPASS(file->GetFileDuration( - GetResource("audio_long16.wav"), dur, kFileFormatPcm8kHzFile)); - TEST_MUSTPASS(file->GetFileDuration( - GetFilename("singleUserDemoConv.ilbc"), dur, - kFileFormatCompressedFile)); + AOK(); + ANL(); - AOK(); - ANL(); + TEST(GetPlaybackPosition); + ANL(); - TEST(GetPlaybackPosition); - ANL(); + int pos; - int pos; + TEST_MUSTPASS(file->StartPlayingFileLocally( + 0, GetResource("audio_long16.pcm"))); + SLEEP(1000); + TEST_MUSTPASS(file->GetPlaybackPosition(0, pos)); + MARK(); // position should be ~1000 + SLEEP(1000); + TEST_MUSTPASS(file->GetPlaybackPosition(0, pos)); + MARK(); // position should be ~2000 + // SLEEP(70*1000); + // file is no longer playing + // TEST_MUSTPASS(file->GetPlaybackPosition(0, pos)); MARK(); + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + AOK(); + ANL(); + // These tests are related to defect 5136 + // They play .wav files with different sample freq for 5s + char localFiles[7][50] = { "audio_tiny8.wav", "audio_tiny11.wav", + "audio_tiny16.wav", "audio_tiny22.wav", "audio_tiny32.wav", + "audio_tiny44.wav", "audio_tiny48.wav" }; + char freq[7][5] = { "8", "11", "16", "22", "32", "44.1", "48" }; + TEST_MUSTPASS(base->StopReceive(0)); + for (int i = 0; i < 7; i++) { + TEST_LOG("Playing file %s, in %s KHz \n", localFiles[i], freq[i]); TEST_MUSTPASS(file->StartPlayingFileLocally( - 0, GetResource("audio_long16.pcm"))); - SLEEP(1000); - TEST_MUSTPASS(file->GetPlaybackPosition(0, pos)); - MARK(); // position should be ~1000 - SLEEP(1000); - TEST_MUSTPASS(file->GetPlaybackPosition(0, pos)); - MARK(); // position should be ~2000 - // SLEEP(70*1000); - // file is no longer playing - // TEST_MUSTPASS(file->GetPlaybackPosition(0, pos)); MARK(); - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - AOK(); - ANL(); - - // These tests are related to defect 5136 - // They play .wav files with different sample freq for 5s - char localFiles[7][50] = { "audio_tiny8.wav", - "audio_tiny11.wav", "audio_tiny16.wav", - "audio_tiny22.wav", "audio_tiny32.wav", - "audio_tiny44.wav", "audio_tiny48.wav" }; - char freq[7][5] = { "8", "11", "16", "22", "32", "44.1", "48" }; - TEST_MUSTPASS(base->StopReceive(0)); - for (int i = 0; i < 7; i++) - { - TEST_LOG("Playing file %s, in %s KHz \n", localFiles[i], freq[i]); - TEST_MUSTPASS(file->StartPlayingFileLocally( 0, GetResource(localFiles[i]),false, kFileFormatWavFile, 1)); - SLEEP(4500); // The file should not end - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - } + SLEEP(4500); // The file should not end + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + } - // TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); // Should not work - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + // TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); // Should not work + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - AOK(); - ANL(); + AOK(); + ANL(); - return 0; + return 0; } // ---------------------------------------------------------------------------- @@ -4991,10 +4802,10 @@ int VoEExtendedTest::RunMixingTest(int num_channels, ASSERT_TRUE(channel != -1); TEST_MUSTPASS(codec->SetRecPayloadType(channel, codec_inst)); TEST_MUSTPASS(base->SetLocalReceiver(channel, - 1234 + 2 * channel_index)); + 1234 + 2 * channel_index)); TEST_MUSTPASS(base->SetSendDestination(channel, - 1234 + 2 * channel_index, - "127.0.0.1")); + 1234 + 2 * channel_index, + "127.0.0.1")); TEST_MUSTPASS(base->StartReceive(channel)); TEST_MUSTPASS(base->StartPlayout(channel)); TEST_MUSTPASS(codec->SetSendCodec(channel, codec_inst)); @@ -5003,12 +4814,12 @@ int VoEExtendedTest::RunMixingTest(int num_channels, for (int channel_index = 0; channel_index < num_channels; ++channel_index) { const int channel = channels[channel_index]; TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(channel, - input_filename, - true)); + input_filename, + true)); } const char mix_result[] = "mix_result.pcm"; TEST_MUSTPASS(file->StartRecordingPlayout(-1/*record meeting*/, - mix_result)); + mix_result)); TEST_LOG("Playing %d channels\n", num_channels); SLEEP(5000); TEST_MUSTPASS(file->StopRecordingPlayout(-1)); @@ -5085,328 +4896,323 @@ int VoEExtendedTest::TestMixing() { // VoEExtendedTest::TestHardware // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestHardware() -{ - PrepareTest("Hardware"); +int VoEExtendedTest::TestHardware() { + PrepareTest("Hardware"); - VoEBase* base = _mgr.BasePtr(); - VoEHardware* hardware = _mgr.HardwarePtr(); + VoEBase* base = _mgr.BasePtr(); + VoEHardware* hardware = _mgr.HardwarePtr(); #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "VoEHardware_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "VoEHardware_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - // Set/GetAudioDeviceLayer - TEST(Set/GetAudioDeviceLayer); - ANL(); - AudioLayers wantedLayer = kAudioPlatformDefault; - AudioLayers givenLayer; + // Set/GetAudioDeviceLayer + TEST(Set/GetAudioDeviceLayer); + ANL(); + AudioLayers wantedLayer = kAudioPlatformDefault; + AudioLayers givenLayer; #if defined(_WIN32) - wantedLayer = kAudioWindowsCore; - hardware->SetAudioDeviceLayer(wantedLayer); - TEST_LOG("If you run on XP or below, CoreAudio " - "should not be able to set.\n"); - TEST_LOG("If you run on Vista or above, CoreAudio " - "should be able to set.\n"); - TEST_LOG("Verify that this is the case.\n"); + wantedLayer = kAudioWindowsCore; + hardware->SetAudioDeviceLayer(wantedLayer); + TEST_LOG("If you run on XP or below, CoreAudio " + "should not be able to set.\n"); + TEST_LOG("If you run on Vista or above, CoreAudio " + "should be able to set.\n"); + TEST_LOG("Verify that this is the case.\n"); - TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - if(givenLayer == kAudioWindowsCore) - { - TEST_LOG("CoreAudio was set\n"); - } - else - { - TEST_LOG("CoreAudio was *not* set\n"); - } + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + if(givenLayer == kAudioWindowsCore) + { + TEST_LOG("CoreAudio was set\n"); + } + else + { + TEST_LOG("CoreAudio was *not* set\n"); + } - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->Terminate()); - wantedLayer = kAudioWindowsWave; - TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_LOG("Wave audio should always be able to set.\n"); + wantedLayer = kAudioWindowsWave; + TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_LOG("Wave audio should always be able to set.\n"); - TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - if(givenLayer == kAudioWindowsWave) - { - TEST_LOG("Wave audio was set\n"); - } - else - { - TEST_LOG("Wave audio was not set\n"); - } + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + if(givenLayer == kAudioWindowsWave) + { + TEST_LOG("Wave audio was set\n"); + } + else + { + TEST_LOG("Wave audio was not set\n"); + } - TEST_MUSTPASS(base->Terminate()); - // end _WIN32 + TEST_MUSTPASS(base->Terminate()); + // end _WIN32 #elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) - wantedLayer = kAudioLinuxPulse; - TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_LOG("If you run on Linux with no/unsupported PA version, PulseAudio " - "7should not be able to set.\n"); - TEST_LOG("If you run on Linux with supported PA version running, PulseAudio" - " should be able to set.\n"); - TEST_LOG("Verify that this is the case.\n"); + wantedLayer = kAudioLinuxPulse; + TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_LOG("If you run on Linux with no/unsupported PA version, PulseAudio " + "7should not be able to set.\n"); + TEST_LOG("If you run on Linux with supported PA version running, PulseAudio" + " should be able to set.\n"); + TEST_LOG("Verify that this is the case.\n"); - TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - if(givenLayer == kAudioLinuxPulse) - { - TEST_LOG("\nPulseAudio was set\n"); - } - else - { - TEST_LOG("\nPulseAudio was not set\n"); - } + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + if(givenLayer == kAudioLinuxPulse) + { + TEST_LOG("\nPulseAudio was set\n"); + } + else + { + TEST_LOG("\nPulseAudio was not set\n"); + } - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->Terminate()); - wantedLayer = kAudioLinuxAlsa; - TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_LOG("ALSA audio should always be able to set.\n"); + wantedLayer = kAudioLinuxAlsa; + TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_LOG("ALSA audio should always be able to set.\n"); - TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - if(givenLayer == kAudioLinuxAlsa) - { - TEST_LOG("\nALSA audio was set\n"); - } - else - { - TEST_LOG("\nALSA audio was not set\n"); - } + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + if(givenLayer == kAudioLinuxAlsa) + { + TEST_LOG("\nALSA audio was set\n"); + } + else + { + TEST_LOG("\nALSA audio was not set\n"); + } - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->Terminate()); #endif // defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) - // Invalid arguments - wantedLayer = (AudioLayers) 17; - TEST_MUSTPASS(-1 != hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); + // Invalid arguments + wantedLayer = (AudioLayers) 17; + TEST_MUSTPASS(-1 != hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); - // Basic usage - wantedLayer = kAudioPlatformDefault; - TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - TEST_MUSTPASS(givenLayer != wantedLayer); - MARK(); + // Basic usage + wantedLayer = kAudioPlatformDefault; + TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + TEST_MUSTPASS(givenLayer != wantedLayer); + MARK(); - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); - wantedLayer = kAudioPlatformDefault; - TEST_MUSTPASS(-1 != hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_MUSTPASS(VE_ALREADY_INITED != base->LastError()); - MARK(); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - MARK(); - switch (givenLayer) - { - case kAudioPlatformDefault: - // already set above - break; - case kAudioWindowsCore: - TEST_LOG("\nRunning kAudioWindowsCore\n"); - break; - case kAudioWindowsWave: - TEST_LOG("\nRunning kAudioWindowsWave\n"); - break; - case kAudioLinuxAlsa: - TEST_LOG("\nRunning kAudioLinuxAlsa\n"); - break; - case kAudioLinuxPulse: - TEST_LOG("\nRunning kAudioLinuxPulse\n"); - break; - default: - TEST_LOG("\nERROR: Running unknown audio layer!!\n"); - return -1; - } - ANL(); + wantedLayer = kAudioPlatformDefault; + TEST_MUSTPASS(-1 != hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_MUSTPASS(VE_ALREADY_INITED != base->LastError()); + MARK(); + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + MARK(); + switch (givenLayer) { + case kAudioPlatformDefault: + // already set above + break; + case kAudioWindowsCore: + TEST_LOG("\nRunning kAudioWindowsCore\n"); + break; + case kAudioWindowsWave: + TEST_LOG("\nRunning kAudioWindowsWave\n"); + break; + case kAudioLinuxAlsa: + TEST_LOG("\nRunning kAudioLinuxAlsa\n"); + break; + case kAudioLinuxPulse: + TEST_LOG("\nRunning kAudioLinuxPulse\n"); + break; + default: + TEST_LOG("\nERROR: Running unknown audio layer!!\n"); + return -1; + } + ANL(); #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) - // GetRecording/PlayoutDeviceStatus - TEST(Getrecording/PlayoutDeviceStatus); - ANL(); - bool isRecAvailable = false; - bool isPlayAvailable = false; - TEST_MUSTPASS(hardware->GetRecordingDeviceStatus(isRecAvailable)); - TEST_MUSTPASS(!isRecAvailable); - MARK(); - TEST_MUSTPASS(hardware->GetPlayoutDeviceStatus(isPlayAvailable)); - TEST_MUSTPASS(!isPlayAvailable); - MARK(); + // GetRecording/PlayoutDeviceStatus + TEST(Getrecording/PlayoutDeviceStatus); + ANL(); + bool isRecAvailable = false; + bool isPlayAvailable = false; + TEST_MUSTPASS(hardware->GetRecordingDeviceStatus(isRecAvailable)); + TEST_MUSTPASS(!isRecAvailable); + MARK(); + TEST_MUSTPASS(hardware->GetPlayoutDeviceStatus(isPlayAvailable)); + TEST_MUSTPASS(!isPlayAvailable); + MARK(); - ANL(); + ANL(); - int nRec = 0, nPlay = 0; - char devName[128]; - char guidName[128]; - int idx; + int nRec = 0, nPlay = 0; + char devName[128]; + char guidName[128]; + int idx; - TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(nPlay)); + TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(nPlay)); - // GetPlayoutDeviceName - TEST(GetPlayoutDeviceName); - ANL(); - TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(nPlay, devName, - guidName)); - TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); - MARK(); - TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(-2, devName, guidName)); - TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); - MARK(); - TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(nPlay+1, devName, - guidName)); - TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); - MARK(); - TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(0, NULL, guidName)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(0, devName, NULL)); + // GetPlayoutDeviceName + TEST(GetPlayoutDeviceName); + ANL(); + TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(nPlay, devName, + guidName)); + TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + MARK(); + TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(-2, devName, guidName)); + TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + MARK(); + TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(nPlay+1, devName, + guidName)); + TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + MARK(); + TEST_MUSTPASS(-1 != hardware->GetPlayoutDeviceName(0, NULL, guidName)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(0, devName, NULL)); - // default tests - for (idx = 0; idx < nPlay; idx++) - { - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(idx, devName, guidName)); - MARK(); - TEST_MUSTPASS(hardware->SetPlayoutDevice(idx)); - } - - ANL(); - - TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(nRec)); - - // GetRecordingDeviceName - TEST(GetRecordingDeviceName); - ANL(); - TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(nRec, devName, - guidName)); - TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + // default tests + for (idx = 0; idx < nPlay; idx++) { + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(idx, devName, guidName)); MARK(); - TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(-2, devName, guidName)); - TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); - MARK(); - TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(nRec+1, devName, - guidName)); - TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); - MARK(); - TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(0, NULL, guidName)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(hardware->GetRecordingDeviceName(0, devName, NULL)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(idx)); + } - // default tests - for (idx = 0; idx < nRec; idx++) - { - TEST_MUSTPASS(hardware->GetRecordingDeviceName(idx, devName, guidName)); - MARK(); - TEST_MUSTPASS(hardware->SetRecordingDevice(idx)); - } - ANL(); + ANL(); + + TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(nRec)); + + // GetRecordingDeviceName + TEST(GetRecordingDeviceName); + ANL(); + TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(nRec, devName, + guidName)); + TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + MARK(); + TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(-2, devName, guidName)); + TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + MARK(); + TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(nRec+1, devName, + guidName)); + TEST_MUSTPASS(VE_CANNOT_RETRIEVE_DEVICE_NAME != base->LastError()); + MARK(); + TEST_MUSTPASS(-1 != hardware->GetRecordingDeviceName(0, NULL, guidName)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(hardware->GetRecordingDeviceName(0, devName, NULL)); + + // default tests + for (idx = 0; idx < nRec; idx++) { + TEST_MUSTPASS(hardware->GetRecordingDeviceName(idx, devName, guidName)); + MARK(); + TEST_MUSTPASS(hardware->SetRecordingDevice(idx)); + } + ANL(); // // SetRecordingDevice - TEST(SetRecordingDevice); - ANL(); - TEST_MUSTPASS(hardware->SetRecordingDevice(0)); - MARK(); - TEST_MUSTPASS(hardware->SetRecordingDevice(0, kStereoLeft)); - MARK(); - TEST_MUSTPASS(hardware->SetRecordingDevice(0, kStereoRight)); - MARK(); - ANL(); + TEST(SetRecordingDevice); + ANL(); + TEST_MUSTPASS(hardware->SetRecordingDevice(0)); + MARK(); + TEST_MUSTPASS(hardware->SetRecordingDevice(0, kStereoLeft)); + MARK(); + TEST_MUSTPASS(hardware->SetRecordingDevice(0, kStereoRight)); + MARK(); + ANL(); - // SetPlayoutDevice - TEST(SetPlayoutDevice); - ANL(); + // SetPlayoutDevice + TEST(SetPlayoutDevice); + ANL(); #if defined(_WIN32) - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); MARK(); + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); MARK(); #else - TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); - MARK(); + TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); + MARK(); #endif - ANL(); + ANL(); #endif // #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) #if defined(MAC_IPHONE) - TEST(ResetSoundDevice); ANL(); + TEST(ResetSoundDevice); ANL(); - for (int p=0; p<=60; p+=20) + for (int p=0; p<=60; p+=20) + { + TEST_LOG("Resetting sound device several times with pause %d ms\n", p); + for (int l=0; l<50; ++l) { - TEST_LOG("Resetting sound device several times with pause %d ms\n", p); - for (int l=0; l<50; ++l) - { - TEST_MUSTPASS(hardware->ResetAudioDevice()); MARK(); - SLEEP(p); - } - ANL(); + TEST_MUSTPASS(hardware->ResetAudioDevice()); MARK(); + SLEEP(p); } + ANL(); + } - TEST_LOG("Start streaming - verify the audio after each batch of resets \n"); - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(0,8000)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(2000); + TEST_LOG("Start streaming - verify the audio after each batch of resets \n"); + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(0,8000)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(2000); - SLEEP(2000); - for (int p=0; p<=60; p+=20) + SLEEP(2000); + for (int p=0; p<=60; p+=20) + { + TEST_LOG("Resetting sound device several time with pause %d ms\n", p); + for (int l=0; l<20; ++l) { - TEST_LOG("Resetting sound device several time with pause %d ms\n", p); - for (int l=0; l<20; ++l) - { - TEST_MUSTPASS(hardware->ResetAudioDevice()); MARK(); - SLEEP(p); - } - ANL(); - SLEEP(2000); + TEST_MUSTPASS(hardware->ResetAudioDevice()); MARK(); + SLEEP(p); } + ANL(); + SLEEP(2000); + } - TEST_LOG("Stop streaming \n"); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartReceive(0)); + TEST_LOG("Stop streaming \n"); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartReceive(0)); #endif // defined(MAC_IPHONE)) #ifdef MAC_IPHONE - TEST_LOG("\nNOTE: Always run hardware tests also without extended tests " - "enabled,\nsince the extended tests are pre-streaming tests only.\n"); + TEST_LOG("\nNOTE: Always run hardware tests also without extended tests " + "enabled,\nsince the extended tests are pre-streaming tests only.\n"); #endif - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - ANL(); - AOK(); + ANL(); + AOK(); - return 0; + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestNetEqStats // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestNetEqStats() -{ - PrepareTest("NetEqStats (!EMPTY!)"); +int VoEExtendedTest::TestNetEqStats() { + PrepareTest("NetEqStats (!EMPTY!)"); - AOK(); - ANL(); + AOK(); + ANL(); - return 0; + return 0; } // ---------------------------------------------------------------------------- @@ -5414,1491 +5220,1482 @@ int VoEExtendedTest::TestNetEqStats() // // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestNetwork() -{ - PrepareTest("Network"); +int VoEExtendedTest::TestNetwork() { + PrepareTest("Network"); #ifdef WEBRTC_ANDROID - int sleepTime = 200; - int sleepTime2 = 250; + int sleepTime = 200; + int sleepTime2 = 250; #elif defined(MAC_IPHONE) // MAC_IPHONE needs more delay for getSourceInfo() - int sleepTime = 150; - int sleepTime2 = 200; + int sleepTime = 150; + int sleepTime2 = 200; #else - int sleepTime = 100; - int sleepTime2 = 200; + int sleepTime = 100; + int sleepTime2 = 200; #endif - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); - VoENetwork* netw = _mgr.NetworkPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); + VoENetwork* netw = _mgr.NetworkPtr(); #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "VoENetwork_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "VoENetwork_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->Init()); - // ------------------------------------------------------------------------ - // >> GetLocalIP - // - // State: VE initialized, no existing channels - - TEST(GetLocalIP); - ANL(); + // ------------------------------------------------------------------------ + // >> GetLocalIP + // + // State: VE initialized, no existing channels + TEST(GetLocalIP); + ANL(); #ifdef MAC_IPHONE - // Should fail - TEST_MUSTPASS(!netw->GetLocalIP(NULL, 0)); MARK(); - TEST_ERROR(VE_FUNC_NOT_SUPPORTED); + // Should fail + TEST_MUSTPASS(!netw->GetLocalIP(NULL, 0)); MARK(); + TEST_ERROR(VE_FUNC_NOT_SUPPORTED); - ANL(); - printf("NOTE: Local IP must be set in source code (line %d) \n", - __LINE__ + 1); - const char* localIP = "192.168.1.4"; + ANL(); + printf("NOTE: Local IP must be set in source code (line %d) \n", + __LINE__ + 1); + const char* localIP = "192.168.1.4"; #else - char localIP[64]; + char localIP[64]; - // invalid parameter - TEST_MUSTPASS(!netw->GetLocalIP(NULL)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); + // invalid parameter + TEST_MUSTPASS(!netw->GetLocalIP(NULL)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); - // default function calls (IPv4) - TEST_MUSTPASS(netw->GetLocalIP(localIP)); - MARK(); - TEST_LOG("[local IPv4: %s]\n", localIP); - TEST_MUSTPASS(netw->GetLocalIP(localIP)); - MARK(); + // default function calls (IPv4) + TEST_MUSTPASS(netw->GetLocalIP(localIP)); + MARK(); + TEST_LOG("[local IPv4: %s]\n", localIP); + TEST_MUSTPASS(netw->GetLocalIP(localIP)); + MARK(); #if !defined(WEBRTC_MAC) && !defined(WEBRTC_ANDROID) - // default function calls (IPv6) - TEST_MUSTPASS(netw->GetLocalIP(localIP, true)); - MARK(); - TEST_LOG("[local IPv6: %s]\n", localIP); - TEST_MUSTPASS(netw->GetLocalIP(localIP, true)); - MARK(); + // default function calls (IPv6) + TEST_MUSTPASS(netw->GetLocalIP(localIP, true)); + MARK(); + TEST_LOG("[local IPv6: %s]\n", localIP); + TEST_MUSTPASS(netw->GetLocalIP(localIP, true)); + MARK(); #endif - // one last call to ensure that local - TEST_MUSTPASS(netw->GetLocalIP(localIP)); - MARK(); + // one last call to ensure that local + TEST_MUSTPASS(netw->GetLocalIP(localIP)); + MARK(); #endif - ANL(); - AOK(); - ANL(); - ANL(); + ANL(); + AOK(); + ANL(); + ANL(); - // >> end of GetLocalIP - // ------------------------------------------------------------------------ + // >> end of GetLocalIP + // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ - // >> GetSourceInfo - // - // - VE initialized - // - no existing channels + // ------------------------------------------------------------------------ + // >> GetSourceInfo + // + // - VE initialized + // - no existing channels + TEST(GetSourceInfo); + ANL(); - TEST(GetSourceInfo); - ANL(); + int rtpPort(0); + int rtcpPort(0); + char ipaddr[64] = { 0 }; + ExtendedTestTransport* ptrTransport(NULL); - int rtpPort(0); - int rtcpPort(0); - char ipaddr[64] = { 0 }; - ExtendedTestTransport* ptrTransport(NULL); + // call without valid channel + TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // call without valid channel - TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->CreateChannel()); + // NULL as input string + TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, NULL)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); - // NULL as input string - TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, NULL)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); + // call when external transport is enabled + ptrTransport = new ExtendedTestTransport(netw); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + delete ptrTransport; - // call when external transport is enabled - ptrTransport = new ExtendedTestTransport(netw); - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - delete ptrTransport; + // call when external transport is disabled (no packet received yet) + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 0); + TEST_MUSTPASS(rtcpPort != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + // send and receive packets with default settings for a while + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime2); // does not guarantee RTCP - // call when external transport is disabled (no packet received yet) - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 0); - TEST_MUSTPASS(rtcpPort != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - // send and receive packets with default settings for a while - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime2); // does not guarantee RTCP + // verify remote parameters (exclude RTCP) + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 8000); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // verify remote parameters (exclude RTCP) - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 8000); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // ensure that valid results are maintained after StopListen + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 8000); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // ensure that valid results are maintained after StopListen - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 8000); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // verify that results are maintained after new call to SetLocalReceiver + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 8000); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // verify that results are maintained after new call to SetLocalReceiver - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 8000); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // STATE: not listening, not sending + // send and receive packets with other settings for a while + TEST_MUSTPASS(base->SetLocalReceiver(0, 9005)); + TEST_MUSTPASS(base->SetSendDestination(0, 9005, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); - // STATE: not listening, not sending - // send and receive packets with other settings for a while - TEST_MUSTPASS(base->SetLocalReceiver(0, 9005)); - TEST_MUSTPASS(base->SetSendDestination(0, 9005, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + // STATE: listening, sending - // STATE: listening, sending + // verify new remote parameters + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 9005); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // verify new remote parameters - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 9005); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // restart sending to and from local IP + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 9005, kVoEDefault, localIP)); + TEST_MUSTPASS(base->SetSendDestination(0, 9005, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); - // restart sending to and from local IP - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->SetLocalReceiver(0, 9005, kVoEDefault, localIP)); - TEST_MUSTPASS(base->SetSendDestination(0, 9005, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + // verify new remote parameters + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 9005); + TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); // should not be "127.0.0.1" - // verify new remote parameters - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 9005); - TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); // should not be "127.0.0.1" + // use non-default source port in outgoing packets + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 9005)); + TEST_MUSTPASS(base->SetSendDestination(0, 9005, "127.0.0.1", 9010)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); - // use non-default source port in outgoing packets - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->SetLocalReceiver(0, 9005)); - TEST_MUSTPASS(base->SetSendDestination(0, 9005, "127.0.0.1", 9010)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + // verify new remote parameters + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 9010); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // verify new remote parameters - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 9010); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // STATE: listening and sending using an extra local socket - // STATE: listening and sending using an extra local socket + // stop/start sending + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); - // stop/start sending - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + // verify that the unique source port is maintained for the extra socket + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 9010); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // verify that the unique source port is maintained for the extra socket - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 9010); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - - // set new source port for outgoing packets (9010 -> 9020) - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->SetSendDestination(0, 9005, "127.0.0.1", 9020)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + // set new source port for outgoing packets (9010 -> 9020) + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->SetSendDestination(0, 9005, "127.0.0.1", 9020)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); #ifdef MAC_IPHONE - SLEEP(500); // Need extra pause for some reason + SLEEP(500); // Need extra pause for some reason #endif - // verify that the unique source port is set for the new extra socket - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 9020); - // STATE: listening and sending using an extra local socket + // verify that the unique source port is set for the new extra socket + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 9020); + // STATE: listening and sending using an extra local socket - // remove extra send socket and restart call again - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); // delete channel => destroys the - // extra socket - TEST_MUSTPASS(base->CreateChannel()); // new channel uses one socket only - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); // use new port as well - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + // remove extra send socket and restart call again + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); // delete channel => destroys the + // extra socket + TEST_MUSTPASS(base->CreateChannel()); // new channel uses one socket only + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); // use new port as well + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); - // verify that remote info is correct - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 8000); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // verify that remote info is correct + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 8000); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // STATE: listening and sending using shared socket + // STATE: listening and sending using shared socket - // use non-default source port in outgoing packets to create extra send - // socket - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->SetLocalReceiver(0, 7000)); - TEST_MUSTPASS(base->SetSendDestination(0, 7000, "127.0.0.1", 7010)); - // RTP src is 7010 => RTCP src = 7011 - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); - // verify new remote parameters - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 7010); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + // use non-default source port in outgoing packets to create extra send + // socket + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 7000)); + TEST_MUSTPASS(base->SetSendDestination(0, 7000, "127.0.0.1", 7010)); + // RTP src is 7010 => RTCP src = 7011 + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); + // verify new remote parameters + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 7010); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - // check RTCP port as well (should be 7010 + 1 = 7011) - Sleep(8000, true); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 7010); - TEST_MUSTPASS(rtcpPort != 7011); - TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); + // check RTCP port as well (should be 7010 + 1 = 7011) + Sleep(8000, true); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 7010); + TEST_MUSTPASS(rtcpPort != 7011); + TEST_MUSTPASS(strcmp(ipaddr, "127.0.0.1") != 0); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); - AOK(); - ANL(); - ANL(); + ANL(); + AOK(); + ANL(); + ANL(); - // >> end of GetSourceInfo - // ------------------------------------------------------------------------ + // >> end of GetSourceInfo + // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ - // >> SetExternalTransport - // - // - VE initialized - // - no existing channels - // - no media - // + // ------------------------------------------------------------------------ + // >> SetExternalTransport + // + // - VE initialized + // - no existing channels + // - no media + // + TEST(SetExternalTransport); + ANL(); - TEST(SetExternalTransport); - ANL(); + ptrTransport = new ExtendedTestTransport(netw); - ptrTransport = new ExtendedTestTransport(netw); + // call without valid channel + TEST_MUSTPASS(!netw->DeRegisterExternalTransport(0)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // call without valid channel - TEST_MUSTPASS(!netw->DeRegisterExternalTransport(0)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->CreateChannel()); + // different valid call combinations + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + MARK(); + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + MARK(); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); // must deregister first + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + MARK(); - // different valid call combinations - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - MARK(); - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - MARK(); - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); // must deregister first - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - MARK(); + // STATE: external transport is disabled - // STATE: external transport is disabled + // initialize sending and ensure that external transport can't be enabled + TEST_MUSTPASS(base->SetSendDestination(0, 1234, "127.0.0.2")); + TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + TEST_ERROR(VE_SEND_SOCKETS_CONFLICT); - // initialize sending and ensure that external transport can't be enabled - TEST_MUSTPASS(base->SetSendDestination(0, 1234, "127.0.0.2")); - TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - TEST_ERROR(VE_SEND_SOCKETS_CONFLICT); + // restart channel to ensure that "initialized sender" state is cleared + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); - // restart channel to ensure that "initialized sender" state is cleared - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // initialize receiving and ensure that external transport can't be enabled + TEST_MUSTPASS(base->SetLocalReceiver(0, 5678)); + TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + TEST_ERROR(VE_RECEIVE_SOCKETS_CONFLICT); - // initialize receiving and ensure that external transport can't be enabled - TEST_MUSTPASS(base->SetLocalReceiver(0, 5678)); - TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - TEST_ERROR(VE_RECEIVE_SOCKETS_CONFLICT); + // restart channel to ensure that "initialized receiver" state is cleared + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); - // restart channel to ensure that "initialized receiver" state is cleared - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // enable external transport and verify that "emulated loopback" works + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + TEST_MUSTPASS(base->StartSend(0)); // should only start recording + TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); // should fail + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + MARK(); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + Play(0, 2000, true, true); // play file as mic and verify loopback audio + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + MARK(); - // enable external transport and verify that "emulated loopback" works - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - TEST_MUSTPASS(base->StartSend(0)); // should only start recording - TEST_MUSTPASS(!netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); // should fail - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - MARK(); - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - Play(0, 2000, true, true); // play file as mic and verify loopback audio - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - MARK(); - - // STATE: external transport is disabled + // STATE: external transport is disabled #if defined(WEBRTC_ANDROID) || defined(MAC_IPHONE) - int testError = VE_FUNC_NOT_SUPPORTED; + int testError = VE_FUNC_NOT_SUPPORTED; #else - int testError = VE_EXTERNAL_TRANSPORT_ENABLED; + int testError = VE_EXTERNAL_TRANSPORT_ENABLED; #endif - // check all APIs that should fail when external transport is enabled - int DSCP, priority, serviceType, overrideDSCP, nBytes(0); - bool useSetSockopt, enabled; - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - MARK(); - TEST_MUSTPASS(!base->SetLocalReceiver(0, 12345)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!base->GetLocalReceiver(0, rtpPort, rtcpPort, ipaddr)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!base->GetSendDestination(0, rtpPort, ipaddr, rtpPort, - rtcpPort)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!netw->EnableIPv6(0)) - TEST_ERROR(testError); - TEST_MUSTPASS(netw->IPv6IsEnabled(0) != false) - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345, 12346)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(!netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + // check all APIs that should fail when external transport is enabled + int DSCP, priority, serviceType, overrideDSCP, nBytes(0); + bool useSetSockopt, enabled; + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + MARK(); + TEST_MUSTPASS(!base->SetLocalReceiver(0, 12345)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!base->GetLocalReceiver(0, rtpPort, rtcpPort, ipaddr)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!base->GetSendDestination(0, rtpPort, ipaddr, rtpPort, + rtcpPort)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!netw->EnableIPv6(0)) + TEST_ERROR(testError); + TEST_MUSTPASS(netw->IPv6IsEnabled(0) != false) + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345, 12346)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - // modified i VoE 3.4 (can be called also for external transport) - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StopReceive(0)); + // modified i VoE 3.4 (can be called also for external transport) + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StopReceive(0)); -#if (!defined(_WIN32) && !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC)) || defined(WEBRTC_EXTERNAL_TRANSPORT) - testError = VE_FUNC_NOT_SUPPORTED; +#if (!defined(_WIN32) && !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC)) || \ + defined(WEBRTC_EXTERNAL_TRANSPORT) + testError = VE_FUNC_NOT_SUPPORTED; #else - testError = VE_EXTERNAL_TRANSPORT_ENABLED; + testError = VE_EXTERNAL_TRANSPORT_ENABLED; #endif - TEST_MUSTPASS(!netw->SetSendTOS(0, 0)); - TEST_ERROR(testError); - TEST_MUSTPASS(!netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_ERROR(testError); + TEST_MUSTPASS(!netw->SetSendTOS(0, 0)); + TEST_ERROR(testError); + TEST_MUSTPASS(!netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_ERROR(testError); #if !defined(_WIN32) || defined(WEBRTC_EXTERNAL_TRANSPORT) - testError = VE_FUNC_NOT_SUPPORTED; + testError = VE_FUNC_NOT_SUPPORTED; #else - testError = VE_EXTERNAL_TRANSPORT_ENABLED; + testError = VE_EXTERNAL_TRANSPORT_ENABLED; #endif - TEST_MUSTPASS(!netw->SetSendGQoS(0, false, 0)); - TEST_ERROR(testError); - TEST_MUSTPASS(!netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_ERROR(testError); - char dummy[1] = { 'a' }; - TEST_MUSTPASS(!netw->SendUDPPacket(0, dummy, 1, nBytes)); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(!netw->SetSendGQoS(0, false, 0)); + TEST_ERROR(testError); + TEST_MUSTPASS(!netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_ERROR(testError); + char dummy[1] = { 'a' }; + TEST_MUSTPASS(!netw->SendUDPPacket(0, dummy, 1, nBytes)); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - // always disable external transport before deleting the Transport object; - // will lead to crash for RTCP transmission otherwise - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - MARK(); - delete ptrTransport; + // always disable external transport before deleting the Transport object; + // will lead to crash for RTCP transmission otherwise + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + MARK(); + delete ptrTransport; - TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); - AOK(); - ANL(); - ANL(); + ANL(); + AOK(); + ANL(); + ANL(); - // >> end of SetExternalTransport - // ------------------------------------------------------------------------ + // >> end of SetExternalTransport + // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ - // >> EnableIPv6 - // - // - VE initialized - // - no existing channels - // - no media - // - NOTE: set _ENABLE_IPV6_TESTS_ to include these tests - // - http://www.microsoft.com/resources/documentation/windows/xp/all/ - // proddocs/en-us/sag_ip_v6_pro_rt_enable.mspx?mfr=true - // >> ipv6 install - // >> ipv6 [-v] if [IfIndex] - // >> ping6 ::1 - // >> ping6 fe80::1 + // ------------------------------------------------------------------------ + // >> EnableIPv6 + // + // - VE initialized + // - no existing channels + // - no media + // - NOTE: set _ENABLE_IPV6_TESTS_ to include these tests + // - http://www.microsoft.com/resources/documentation/windows/xp/all/ + // proddocs/en-us/sag_ip_v6_pro_rt_enable.mspx?mfr=true + // >> ipv6 install + // >> ipv6 [-v] if [IfIndex] + // >> ping6 ::1 + // >> ping6 fe80::1 #ifdef _ENABLE_IPV6_TESTS_ - TEST(EnableIPv6); ANL(); + TEST(EnableIPv6); ANL(); - // call without valid channel - TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + // call without valid channel + TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->CreateChannel()); - // call with enabled external transport - ptrTransport = new ExtendedTestTransport(netw); - TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); - TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); - TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - delete ptrTransport; + // call with enabled external transport + ptrTransport = new ExtendedTestTransport(netw); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, *ptrTransport)); + TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); + TEST_ERROR(VE_EXTERNAL_TRANSPORT_ENABLED); + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + delete ptrTransport; - // Test "locking" to IPv4 - TEST_MUSTPASS(netw->IPv6IsEnabled(0)); MARK(); // After this call we cannot - // enable IPv6 - TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); // Should fail + // Test "locking" to IPv4 + TEST_MUSTPASS(netw->IPv6IsEnabled(0)); MARK(); // After this call we cannot + // enable IPv6 + TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); // Should fail - // Check that IPv6 address is invalid - TEST_MUSTPASS(!base->SetSendDestination(0, 8000, "::1")); MARK(); // fail + // Check that IPv6 address is invalid + TEST_MUSTPASS(!base->SetSendDestination(0, 8000, "::1")); MARK(); // fail - // New channel - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // New channel + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); - // valid default call - TEST_MUSTPASS(netw->EnableIPv6(0)); MARK(); - TEST_MUSTPASS(netw->GetLocalIP(localIP)); MARK(); // should still read IPv4 - TEST_LOG("[local IPv4: %s]", localIP); + // valid default call + TEST_MUSTPASS(netw->EnableIPv6(0)); MARK(); + TEST_MUSTPASS(netw->GetLocalIP(localIP)); MARK(); // should still read IPv4 + TEST_LOG("[local IPv4: %s]", localIP); - // ensure that Ipv6 is enabled - TEST_MUSTPASS(netw->IPv6IsEnabled(0) != true); + // ensure that Ipv6 is enabled + TEST_MUSTPASS(netw->IPv6IsEnabled(0) != true); - // check that IPv4 address is invalid - TEST_MUSTPASS(!base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_ERROR(VE_INVALID_IP_ADDRESS); + // check that IPv4 address is invalid + TEST_MUSTPASS(!base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_ERROR(VE_INVALID_IP_ADDRESS); - // verify usage of IPv6 loopback address - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - // IPv6 loopback address is 0:0:0:0:0:0:0:1 - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "::1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); // Should fail - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); - ANL(); + // verify usage of IPv6 loopback address + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + // IPv6 loopback address is 0:0:0:0:0:0:0:1 + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "::1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(!netw->EnableIPv6(0)); MARK(); // Should fail + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); + ANL(); - // Restart channel - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // Restart channel + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(netw->EnableIPv6(0)); MARK(); - // ensure that Ipv6 is enabled - TEST_MUSTPASS(netw->IPv6IsEnabled(0) != true); + TEST_MUSTPASS(netw->EnableIPv6(0)); MARK(); + // ensure that Ipv6 is enabled + TEST_MUSTPASS(netw->IPv6IsEnabled(0) != true); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - TEST_MUSTPASS(base->StartReceive(0)); - // IPv6 loopback address is 0:0:0:0:0:0:0:1 - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "::1")); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), true, - true); - SLEEP(500); // ensure that we receieve some packets + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + TEST_MUSTPASS(base->StartReceive(0)); + // IPv6 loopback address is 0:0:0:0:0:0:0:1 + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "::1")); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), true, + true); + SLEEP(500); // ensure that we receieve some packets - // SetSourceFilter and GetSourceFilter - TEST(SetSourceFilter and GetSourceFilter for IPv6); ANL(); - char sourceIp[64] = - { 0}; - char filterIp[64] = - { 0}; - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, sourceIp)); - TEST_LOG("Source port: %d \n", rtpPort); - TEST_LOG("Source RTCP port: %d \n", rtcpPort); - TEST_LOG("Source IP: %s \n", sourceIp); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); - TEST_LOG("Filter port RTP: %d \n", rtpPort); - TEST_LOG("Filter port RTCP: %d \n", rtcpPort); - TEST_LOG("Filter IP: %s \n", filterIp); - TEST_MUSTPASS(0 != rtpPort); - TEST_MUSTPASS(0 != rtcpPort); - TEST_MUSTPASS(filterIp[0] != '\0'); - TEST_LOG("Set filter IP to %s => should hear audio\n", sourceIp); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, sourceIp)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); - TEST_MUSTPASS(0 != rtpPort); - TEST_MUSTPASS(0 != rtcpPort); - TEST_MUSTPASS(_stricmp(filterIp, sourceIp)); - SLEEP(1500); - TEST_LOG("Set filter IP to ::10:10:10 => should *not* hear audio\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::10:10:10")); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); - TEST_MUSTPASS(_stricmp(filterIp, "::10:10:10")); - SLEEP(1500); - TEST_LOG("Disable IP filter => should hear audio again\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::0")); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); - TEST_MUSTPASS(_stricmp(filterIp, "::")); - SLEEP(1500); - TEST_LOG("Set filter IP to ::10:10:10 => should *not* hear audio\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::10:10:10")); - SLEEP(1500); - TEST_LOG("Disable IP filter => should hear audio again\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); - TEST_MUSTPASS(filterIp[0] != '\0'); - SLEEP(1500); - TEST_LOG("Set filter IP to ::10:10:10 => should *not* hear audio\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::10:10:10")); - SLEEP(1500); - TEST_LOG("Disable IP filter => should hear audio again\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::")); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); - TEST_MUSTPASS(_stricmp(filterIp, "::")); - SLEEP(1500); + // SetSourceFilter and GetSourceFilter + TEST(SetSourceFilter and GetSourceFilter for IPv6); ANL(); + char sourceIp[64] = + { 0}; + char filterIp[64] = + { 0}; + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, sourceIp)); + TEST_LOG("Source port: %d \n", rtpPort); + TEST_LOG("Source RTCP port: %d \n", rtcpPort); + TEST_LOG("Source IP: %s \n", sourceIp); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); + TEST_LOG("Filter port RTP: %d \n", rtpPort); + TEST_LOG("Filter port RTCP: %d \n", rtcpPort); + TEST_LOG("Filter IP: %s \n", filterIp); + TEST_MUSTPASS(0 != rtpPort); + TEST_MUSTPASS(0 != rtcpPort); + TEST_MUSTPASS(filterIp[0] != '\0'); + TEST_LOG("Set filter IP to %s => should hear audio\n", sourceIp); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, sourceIp)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); + TEST_MUSTPASS(0 != rtpPort); + TEST_MUSTPASS(0 != rtcpPort); + TEST_MUSTPASS(_stricmp(filterIp, sourceIp)); + SLEEP(1500); + TEST_LOG("Set filter IP to ::10:10:10 => should *not* hear audio\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::10:10:10")); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); + TEST_MUSTPASS(_stricmp(filterIp, "::10:10:10")); + SLEEP(1500); + TEST_LOG("Disable IP filter => should hear audio again\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::0")); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); + TEST_MUSTPASS(_stricmp(filterIp, "::")); + SLEEP(1500); + TEST_LOG("Set filter IP to ::10:10:10 => should *not* hear audio\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::10:10:10")); + SLEEP(1500); + TEST_LOG("Disable IP filter => should hear audio again\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); + TEST_MUSTPASS(filterIp[0] != '\0'); + SLEEP(1500); + TEST_LOG("Set filter IP to ::10:10:10 => should *not* hear audio\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::10:10:10")); + SLEEP(1500); + TEST_LOG("Disable IP filter => should hear audio again\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "::")); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, filterIp)); + TEST_MUSTPASS(_stricmp(filterIp, "::")); + SLEEP(1500); - file->StopPlayingFileAsMicrophone(0); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); + file->StopPlayingFileAsMicrophone(0); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); #endif // #ifdef _ENABLE_IPV6_TESTS_ - // >> end of EnableIPv6 - // ------------------------------------------------------------------------ + // >> end of EnableIPv6 + // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ - // >> SetSourceFilter - // - // - VE initialized - // - no existing channels - // - no media + // ------------------------------------------------------------------------ + // >> SetSourceFilter + // + // - VE initialized + // - no existing channels + // - no media + TEST(SetSourceFilter); + ANL(); - TEST(SetSourceFilter); - ANL(); + // call without valid channel + TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // call without valid channel - TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->CreateChannel()); + // invalid parameters + TEST_MUSTPASS(!netw->SetSourceFilter(0, 65536)); + MARK(); + TEST_ERROR(VE_INVALID_PORT_NMBR); + TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345, 65536)); + MARK(); + TEST_ERROR(VE_INVALID_PORT_NMBR); + TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345, 12346, "300.300.300.300")); + MARK(); + TEST_ERROR(VE_INVALID_IP_ADDRESS); - // invalid parameters - TEST_MUSTPASS(!netw->SetSourceFilter(0, 65536)); - MARK(); - TEST_ERROR(VE_INVALID_PORT_NMBR); - TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345, 65536)); - MARK(); - TEST_ERROR(VE_INVALID_PORT_NMBR); - TEST_MUSTPASS(!netw->SetSourceFilter(0, 12345, 12346, "300.300.300.300")); - MARK(); - TEST_ERROR(VE_INVALID_IP_ADDRESS); + // STATE: RTP filter port is 12345, RTCP filter port is 12346 - // STATE: RTP filter port is 12345, RTCP filter port is 12346 + // disable all filters and ensure that media is received + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + MARK(); + TEST_MUSTPASS(base->SetLocalReceiver(0, 2000, kVoEDefault, localIP)); + TEST_MUSTPASS(base->SetSendDestination(0, 2000, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); - // disable all filters and ensure that media is received - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - MARK(); - TEST_MUSTPASS(base->SetLocalReceiver(0, 2000, kVoEDefault, localIP)); - TEST_MUSTPASS(base->SetSendDestination(0, 2000, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + TEST_MUSTPASS(rtpPort != 2000); + TEST_MUSTPASS(rtcpPort != 2001); + TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - TEST_MUSTPASS(rtpPort != 2000); - TEST_MUSTPASS(rtcpPort != 2001); - TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); + // clear states and restart loopback session + TEST_MUSTPASS(base->DeleteChannel(0)); // clear source info state + TEST_MUSTPASS(base->CreateChannel()); - // clear states and restart loopback session - TEST_MUSTPASS(base->DeleteChannel(0)); // clear source info state - TEST_MUSTPASS(base->CreateChannel()); + // set RTP filter to port 2002 and verify that source 2000 is blocked + TEST_MUSTPASS(netw->SetSourceFilter(0, 2002, 0, NULL));; + MARK(); + TEST_MUSTPASS(base->SetLocalReceiver(0, 2000, kVoEDefault, localIP)); + TEST_MUSTPASS(base->SetSendDestination(0, 2000, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + TEST_MUSTPASS(rtpPort != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - // set RTP filter to port 2002 and verify that source 2000 is blocked - TEST_MUSTPASS(netw->SetSourceFilter(0, 2002, 0, NULL));; - MARK(); - TEST_MUSTPASS(base->SetLocalReceiver(0, 2000, kVoEDefault, localIP)); - TEST_MUSTPASS(base->SetSendDestination(0, 2000, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - TEST_MUSTPASS(rtpPort != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + // ensure that received packets originates from 2002 and that they now pass + // the filter + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StopSend(0)); + // RTP source is 2002 + TEST_MUSTPASS(base->SetLocalReceiver(0, 2002, kVoEDefault, localIP)); + TEST_MUSTPASS(base->SetSendDestination(0, 2002, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + TEST_MUSTPASS(rtpPort != 2002); + TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); - // ensure that received packets originates from 2002 and that they now pass - // the filter - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StopSend(0)); - // RTP source is 2002 - TEST_MUSTPASS(base->SetLocalReceiver(0, 2002, kVoEDefault, localIP)); - TEST_MUSTPASS(base->SetSendDestination(0, 2002, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - TEST_MUSTPASS(rtpPort != 2002); - TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); + // clear states and restart loopback session + TEST_MUSTPASS(base->DeleteChannel(0)); // clear source info state + TEST_MUSTPASS(base->CreateChannel()); - // clear states and restart loopback session - TEST_MUSTPASS(base->DeleteChannel(0)); // clear source info state - TEST_MUSTPASS(base->CreateChannel()); + // set IP filter to local IP and verify that default loopback stream is + // blocked + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, localIP));; + MARK(); + TEST_MUSTPASS(base->SetLocalReceiver(0, 2000)); + TEST_MUSTPASS(base->SetSendDestination(0, 2000, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + TEST_MUSTPASS(rtpPort != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - // set IP filter to local IP and verify that default loopback stream is - // blocked - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, localIP));; - MARK(); - TEST_MUSTPASS(base->SetLocalReceiver(0, 2000)); - TEST_MUSTPASS(base->SetSendDestination(0, 2000, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - TEST_MUSTPASS(rtpPort != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + // ensure that received packets originates from the local IP and that they + // now pass the filter + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StopSend(0)); + // should pass the filter + TEST_MUSTPASS(base->SetLocalReceiver(0, 2000, kVoEDefault, localIP)); + TEST_MUSTPASS(base->SetSendDestination(0, 2000, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); + TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); + TEST_MUSTPASS(rtpPort != 2000); + TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); - // ensure that received packets originates from the local IP and that they - // now pass the filter - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StopSend(0)); - // should pass the filter - TEST_MUSTPASS(base->SetLocalReceiver(0, 2000, kVoEDefault, localIP)); - TEST_MUSTPASS(base->SetSendDestination(0, 2000, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); - TEST_MUSTPASS(netw->GetSourceInfo(0, rtpPort, rtcpPort, ipaddr)); - TEST_MUSTPASS(rtpPort != 2000); - TEST_MUSTPASS(strcmp(ipaddr, localIP) != 0); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StopSend(0)); + // STATE: no active media, IP filter is active - // STATE: no active media, IP filter is active + // disable all filters + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL));; + MARK(); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + TEST_MUSTPASS(rtpPort != 0); + TEST_MUSTPASS(rtcpPort != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - // disable all filters - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL));; - MARK(); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - TEST_MUSTPASS(rtpPort != 0); - TEST_MUSTPASS(rtcpPort != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + TEST_MUSTPASS(base->DeleteChannel(0)); + ANL(); + AOK(); + ANL(); + ANL(); - TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); - AOK(); - ANL(); - ANL(); + // >> end of SetSourceFilter + // ------------------------------------------------------------------------ - // >> end of SetSourceFilter - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ + // >> GetSourceFilter + // + // - VE initialized + // - no existing channels + // - no media + TEST(GetSourceFilter); + ANL(); - // ------------------------------------------------------------------------ - // >> GetSourceFilter - // - // - VE initialized - // - no existing channels - // - no media + // call without valid channel + TEST_MUSTPASS(!netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST(GetSourceFilter); - ANL(); + TEST_MUSTPASS(base->CreateChannel()); - // call without valid channel - TEST_MUSTPASS(!netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + // invalid input parameters + TEST_MUSTPASS(!netw->GetSourceFilter(0, rtpPort, rtcpPort, NULL)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(base->CreateChannel()); + // valid call without any filter set + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 0); + TEST_MUSTPASS(rtcpPort != 0); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - // invalid input parameters - TEST_MUSTPASS(!netw->GetSourceFilter(0, rtpPort, rtcpPort, NULL)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); + // STATE: no active media and no enabled filters - // valid call without any filter set - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 0); - TEST_MUSTPASS(rtcpPort != 0); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + // set different filters and verify that they "bite" + TEST_MUSTPASS(netw->SetSourceFilter(0, 54321, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 54321); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtpPort != 0); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 15425, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtcpPort != 15425); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(rtcpPort != 0); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "192.168.199.19")); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(strcmp(ipaddr, "192.168.199.19") != 0); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "0.0.0.0")); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(strcmp(ipaddr, "0.0.0.0") != 0); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); + MARK(); + TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - // STATE: no active media and no enabled filters + TEST_MUSTPASS(base->DeleteChannel(0)); + ANL(); + AOK(); + ANL(); + ANL(); - // set different filters and verify that they "bite" - TEST_MUSTPASS(netw->SetSourceFilter(0, 54321, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 54321); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtpPort != 0); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 15425, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtcpPort != 15425); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(rtcpPort != 0); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "192.168.199.19")); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(strcmp(ipaddr, "192.168.199.19") != 0); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, "0.0.0.0")); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(strcmp(ipaddr, "0.0.0.0") != 0); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, rtpPort, rtcpPort, ipaddr)); - MARK(); - TEST_MUSTPASS(strcmp(ipaddr, "") != 0); + // >> end of GetSourceFilter + // ------------------------------------------------------------------------ - TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); - AOK(); - ANL(); - ANL(); + // ------------------------------------------------------------------------ + // >> RegisterDeadOrAliveObserver + // >> DeRegisterDeadOrAliveObserver + // + // - VE initialized + // - no existing channels + // - no media + TEST(RegisterDeadOrAliveObserver); + ANL(); + TEST(DeRegisterDeadOrAliveObserver); + ANL(); - // >> end of GetSourceFilter - // ------------------------------------------------------------------------ + // call without valid channel + TEST_MUSTPASS(!netw->RegisterDeadOrAliveObserver(0, *this)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // ------------------------------------------------------------------------ - // >> RegisterDeadOrAliveObserver - // >> DeRegisterDeadOrAliveObserver - // - // - VE initialized - // - no existing channels - // - no media + TEST_MUSTPASS(base->CreateChannel()); - TEST(RegisterDeadOrAliveObserver); - ANL(); - TEST(DeRegisterDeadOrAliveObserver); - ANL(); + TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, *this)); + MARK(); + TEST_MUSTPASS(!netw->RegisterDeadOrAliveObserver(0, *this)); + MARK(); // already registered + TEST_ERROR(VE_INVALID_OPERATION); + TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); + MARK(); + TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); + MARK(); // OK to do it again + TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, *this)); + MARK(); + TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); + MARK(); - // call without valid channel - TEST_MUSTPASS(!netw->RegisterDeadOrAliveObserver(0, *this)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + // STATE: dead-or-alive observer is disabled - TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, *this)); - MARK(); - TEST_MUSTPASS(!netw->RegisterDeadOrAliveObserver(0, *this)); - MARK(); // already registered - TEST_ERROR(VE_INVALID_OPERATION); - TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); - MARK(); - TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); - MARK(); // OK to do it again - TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, *this)); - MARK(); - TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); - MARK(); + // >> end of RegisterDeadOrAliveObserver + // ------------------------------------------------------------------------ - TEST_MUSTPASS(base->DeleteChannel(0)); + // ------------------------------------------------------------------------ + // >> SetPeriodicDeadOrAliveStatus + // >> GetPeriodicDeadOrAliveStatus + // + // - VE initialized + // - no existing channels + // - no media - // STATE: dead-or-alive observer is disabled + // call without valid channel + TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(0, false)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // >> end of RegisterDeadOrAliveObserver - // ------------------------------------------------------------------------ + TEST_MUSTPASS(base->CreateChannel()); - // ------------------------------------------------------------------------ - // >> SetPeriodicDeadOrAliveStatus - // >> GetPeriodicDeadOrAliveStatus - // - // - VE initialized - // - no existing channels - // - no media + // Invalid paramters + TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(0, true, 0)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(0, true, 151)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(1, true, 10)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // call without valid channel - TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(0, false)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + int sampleTime(0); - TEST_MUSTPASS(base->CreateChannel()); + // Valid parameters + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); + MARK(); + TEST_MUSTPASS(netw->GetPeriodicDeadOrAliveStatus(0, enabled, sampleTime)); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(sampleTime != 1); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 150)); + MARK(); + TEST_MUSTPASS(netw->GetPeriodicDeadOrAliveStatus(0, enabled, sampleTime)); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(sampleTime != 150); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); + MARK(); + TEST_MUSTPASS(netw->GetPeriodicDeadOrAliveStatus(0, enabled, sampleTime)); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(sampleTime != 150); // ensure last set time isnt modified - // Invalid paramters - TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(0, true, 0)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(0, true, 151)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetPeriodicDeadOrAliveStatus(1, true, 10)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + StartMedia(0, 2000, true, true, true); - int sampleTime(0); + // STATE: full duplex media is active - // Valid parameters - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); - MARK(); - TEST_MUSTPASS(netw->GetPeriodicDeadOrAliveStatus(0, enabled, sampleTime)); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(sampleTime != 1); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 150)); - MARK(); - TEST_MUSTPASS(netw->GetPeriodicDeadOrAliveStatus(0, enabled, sampleTime)); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(sampleTime != 150); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); - MARK(); - TEST_MUSTPASS(netw->GetPeriodicDeadOrAliveStatus(0, enabled, sampleTime)); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(sampleTime != 150); // ensure last set time isnt modified + // test the dead-or-alive mechanism + TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, *this)); + MARK(); + TEST_LOG("\nVerify that Alive callbacks are received (dT=2sec): "); + fflush(NULL); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 2)); + SLEEP(6000); + TEST_LOG("\nChange dT to 1 second: "); + fflush(NULL); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); + SLEEP(6000); + TEST_LOG("\nDisable dead-or-alive callbacks: "); + fflush(NULL); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); + SLEEP(6000); + TEST_LOG("\nStop sending and enable callbacks again.\n"); + TEST_LOG("Verify that Dead callbacks are received (dT=2sec): "); + fflush(NULL); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 2)); + SLEEP(6000); + TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("\nRestart sending.\n"); + TEST_LOG("Verify that Alive callbacks are received again (dT=2sec): "); + fflush(NULL); + SLEEP(6000); + TEST_LOG("\nDisable dead-or-alive callbacks."); + fflush(NULL); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); + TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); + MARK(); - StartMedia(0, 2000, true, true, true); + StopMedia(0); - // STATE: full duplex media is active + TEST_MUSTPASS(base->DeleteChannel(0)); + ANL(); + AOK(); + ANL(); + ANL(); - // test the dead-or-alive mechanism - TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, *this)); - MARK(); - TEST_LOG("\nVerify that Alive callbacks are received (dT=2sec): "); - fflush(NULL); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 2)); - SLEEP(6000); - TEST_LOG("\nChange dT to 1 second: "); - fflush(NULL); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); - SLEEP(6000); - TEST_LOG("\nDisable dead-or-alive callbacks: "); - fflush(NULL); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); - SLEEP(6000); - TEST_LOG("\nStop sending and enable callbacks again.\n"); - TEST_LOG("Verify that Dead callbacks are received (dT=2sec): "); - fflush(NULL); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 2)); - SLEEP(6000); - TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("\nRestart sending.\n"); - TEST_LOG("Verify that Alive callbacks are received again (dT=2sec): "); - fflush(NULL); - SLEEP(6000); - TEST_LOG("\nDisable dead-or-alive callbacks."); - fflush(NULL); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); - TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); - MARK(); + // >> end of SetPeriodicDeadOrAliveStatus + // ------------------------------------------------------------------------ - StopMedia(0); + // ------------------------------------------------------------------------ + // >> SetPacketTimeoutNotification + // >> GetPacketTimeoutNotification + // + // - VE initialized + // - no existing channels + // - no media + // - NOTE: dynamic tests are performed in standard test - TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); - AOK(); - ANL(); - ANL(); + int timeOut(0); - // >> end of SetPeriodicDeadOrAliveStatus - // ------------------------------------------------------------------------ + TEST(SetPacketTimeoutNotification); + ANL(); + TEST(GetPacketTimeoutNotification); + ANL(); - // ------------------------------------------------------------------------ - // >> SetPacketTimeoutNotification - // >> GetPacketTimeoutNotification - // - // - VE initialized - // - no existing channels - // - no media - // - NOTE: dynamic tests are performed in standard test + // call without existing valid channel + TEST_MUSTPASS(!netw->SetPacketTimeoutNotification(0, false)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - int timeOut(0); + TEST_MUSTPASS(base->CreateChannel()); - TEST(SetPacketTimeoutNotification); - ANL(); - TEST(GetPacketTimeoutNotification); - ANL(); + // invalid function calls + TEST_MUSTPASS(!netw->SetPacketTimeoutNotification(0, true, 0)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetPacketTimeoutNotification(0, true, 151)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); - // call without existing valid channel - TEST_MUSTPASS(!netw->SetPacketTimeoutNotification(0, false)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + // valid function calls (no active media) + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); + MARK(); + TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(timeOut != 2); + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, false)); + MARK(); + TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); + MARK(); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 10)); + MARK(); + TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(timeOut != 10); + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); + MARK(); + TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(timeOut != 2); + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, false)); + MARK(); + TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); + MARK(); + TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->DeleteChannel(0)); + ANL(); + AOK(); + ANL(); + ANL(); - // invalid function calls - TEST_MUSTPASS(!netw->SetPacketTimeoutNotification(0, true, 0)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetPacketTimeoutNotification(0, true, 151)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); + // >> end of SetPacketTimeoutNotification + // ------------------------------------------------------------------------ - // valid function calls (no active media) - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); - MARK(); - TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(timeOut != 2); - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, false)); - MARK(); - TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); - MARK(); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 10)); - MARK(); - TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(timeOut != 10); - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); - MARK(); - TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(timeOut != 2); - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, false)); - MARK(); - TEST_MUSTPASS(netw->GetPacketTimeoutNotification(0, enabled, timeOut)); - MARK(); - TEST_MUSTPASS(enabled != false); - - TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); - AOK(); - ANL(); - ANL(); - - // >> end of SetPacketTimeoutNotification - // ------------------------------------------------------------------------ - - // ------------------------------------------------------------------------ - // >> SendUDPPacket - // - // - VE initialized - // - no existing channels - // - no media + // ------------------------------------------------------------------------ + // >> SendUDPPacket + // + // - VE initialized + // - no existing channels + // - no media - // >> end of SendUDPPacket - // ------------------------------------------------------------------------ + // >> end of SendUDPPacket + // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ - // >> SetSendTOS - // - // - VE initialized - // - no existing channels - // - no media - - TEST(SetSendTOS); - ANL(); + // ------------------------------------------------------------------------ + // >> SetSendTOS + // + // - VE initialized + // - no existing channels + // - no media + TEST(SetSendTOS); + ANL(); #if defined(_WIN32) || defined(WEBRTC_MAC) || defined(WEBRTC_LINUX) - // call without existing valid channel + // call without existing valid channel - TEST_MUSTPASS(!netw->SetSendTOS(0, 0)); MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(!netw->SetSendTOS(0, 0)); MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->CreateChannel()); - // trivial invalid function calls - TEST_MUSTPASS(!netw->SetSendTOS(0, -1)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendTOS(0, 64)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendTOS(0, 1, -2)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendTOS(0, 1, 8)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendTOS(0, 1)); MARK(); - TEST_ERROR(VE_SOCKET_ERROR); // must create sockets first + // trivial invalid function calls + TEST_MUSTPASS(!netw->SetSendTOS(0, -1)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendTOS(0, 64)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendTOS(0, 1, -2)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendTOS(0, 1, 8)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendTOS(0, 1)); MARK(); + TEST_ERROR(VE_SOCKET_ERROR); // must create sockets first #ifdef _WIN32 - TEST_MUSTPASS(base->SetLocalReceiver(0, 3000)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 3000)); - // enable ToS using SetSockopt (should work without local binding) - TEST_MUSTPASS(netw->SetSendTOS(0, 1, -1, true)); MARK(); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); - TEST_MUSTPASS(DSCP != 1); - TEST_MUSTPASS(priority != 0); - TEST_MUSTPASS(useSetSockopt != true); + // enable ToS using SetSockopt (should work without local binding) + TEST_MUSTPASS(netw->SetSendTOS(0, 1, -1, true)); MARK(); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); + TEST_MUSTPASS(DSCP != 1); + TEST_MUSTPASS(priority != 0); + TEST_MUSTPASS(useSetSockopt != true); - // try to disable SetSockopt while ToS is enabled (should fail) - TEST_MUSTPASS(!netw->SetSendTOS(0, 1, -1, false)); MARK(); - TEST_ERROR(VE_TOS_INVALID); // must disable ToS before enabling SetSockopt + // try to disable SetSockopt while ToS is enabled (should fail) + TEST_MUSTPASS(!netw->SetSendTOS(0, 1, -1, false)); MARK(); + TEST_ERROR(VE_TOS_INVALID); // must disable ToS before enabling SetSockopt - // disable ToS to be able to stop using SetSockopt - TEST_MUSTPASS(netw->SetSendTOS(0, 0, -1, true)); MARK(); // disable ToS - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); - TEST_MUSTPASS(DSCP != 0); - TEST_MUSTPASS(priority != 0); - TEST_MUSTPASS(useSetSockopt != true); + // disable ToS to be able to stop using SetSockopt + TEST_MUSTPASS(netw->SetSendTOS(0, 0, -1, true)); MARK(); // disable ToS + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); + TEST_MUSTPASS(DSCP != 0); + TEST_MUSTPASS(priority != 0); + TEST_MUSTPASS(useSetSockopt != true); - // to use the "non-SetSockopt" method, local binding is required, - // trying without it should fail - TEST_MUSTPASS(!netw->SetSendTOS(0, 1, -1, false)); MARK(); - TEST_ERROR(VE_TOS_ERROR); // must bind to local IP first + // to use the "non-SetSockopt" method, local binding is required, + // trying without it should fail + TEST_MUSTPASS(!netw->SetSendTOS(0, 1, -1, false)); MARK(); + TEST_ERROR(VE_TOS_ERROR); // must bind to local IP first - // bind to local IP and try again (should work this time) - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345, kVoEDefault, localIP)); - TEST_LOG("\nThis test needs to be run as administrator\n"); - TEST_MUSTPASS(netw->SetSendTOS(0, 1, -1, false)); MARK(); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); - TEST_MUSTPASS(DSCP != 1); - TEST_MUSTPASS(priority != 0); - TEST_MUSTPASS(useSetSockopt != false); + // bind to local IP and try again (should work this time) + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345, kVoEDefault, localIP)); + TEST_LOG("\nThis test needs to be run as administrator\n"); + TEST_MUSTPASS(netw->SetSendTOS(0, 1, -1, false)); MARK(); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); + TEST_MUSTPASS(DSCP != 1); + TEST_MUSTPASS(priority != 0); + TEST_MUSTPASS(useSetSockopt != false); - // STATE: binded to local IP, local port is 12345 and DSCP is 1 (not using - // SetSockopt) + // STATE: binded to local IP, local port is 12345 and DSCP is 1 (not using + // SetSockopt) - // verify loopback audio with the current settings - TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); // file should be played out here... + // verify loopback audio with the current settings + TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); // file should be played out here... #ifdef _SEND_TO_REMOTE_IP_ - // Send to remote destination and verify the DSCP using Wireshark. - // Use filter ip.src == "RemoteIP". - TEST_LOG("\nUse Wireshark and verify a correctly received DSCP at the " - "remote side!\n"); - TEST_LOG("Sending approx. 5 packets to %s:%d for each DSCP below:\n", - RemoteIP, RemotePort); - TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); - TEST_LOG(" DSCP is set to 0x%02x\n", 1); - SLEEP(100); + // Send to remote destination and verify the DSCP using Wireshark. + // Use filter ip.src == "RemoteIP". + TEST_LOG("\nUse Wireshark and verify a correctly received DSCP at the " + "remote side!\n"); + TEST_LOG("Sending approx. 5 packets to %s:%d for each DSCP below:\n", + RemoteIP, RemotePort); + TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); + TEST_LOG(" DSCP is set to 0x%02x\n", 1); + SLEEP(100); - // Change the DSCP while sending is active and verify on remote side. - TEST_MUSTPASS(netw->SetSendTOS(0, 2)); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x\n", DSCP); - SLEEP(100); + // Change the DSCP while sending is active and verify on remote side. + TEST_MUSTPASS(netw->SetSendTOS(0, 2)); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x\n", DSCP); + SLEEP(100); - // Change the DSCP while sending is active and verify on remote side. - TEST_MUSTPASS(netw->SetSendTOS(0, 63)); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x\n", DSCP); - SLEEP(100); + // Change the DSCP while sending is active and verify on remote side. + TEST_MUSTPASS(netw->SetSendTOS(0, 63)); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x\n", DSCP); + SLEEP(100); - // stop and resume sending - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x\n", DSCP); - SLEEP(100); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(netw->SetSendTOS(0, 0)); + // stop and resume sending + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x\n", DSCP); + SLEEP(100); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(netw->SetSendTOS(0, 0)); #endif // _SEND_TO_REMOTE_IP_ - // Windows priority tests (priority cannot be set using setsockopt on Win) - TEST_LOG("Testing priority\n"); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(!netw->SetSendTOS(0, 0, 3, true)); // Should fail - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(netw->SetSendTOS(0, 0, 3, false)); - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(netw->SetSendTOS(0, 1, 3, false)); - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); // file should be played out here... + // Windows priority tests (priority cannot be set using setsockopt on Win) + TEST_LOG("Testing priority\n"); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(!netw->SetSendTOS(0, 0, 3, true)); // Should fail + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(netw->SetSendTOS(0, 0, 3, false)); + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(netw->SetSendTOS(0, 1, 3, false)); + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); #endif // _WIN32 - // STATE: no media, disabled ToS, no defined receiver + // STATE: no media, disabled ToS, no defined receiver - // Repeat tests above but using setsockopt() this time. - // Binding to local IP should not be required. + // Repeat tests above but using setsockopt() this time. + // Binding to local IP should not be required. - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345, kVoEDefault)); - TEST_MUSTPASS(netw->SetSendTOS(0, 10, -1, true)); MARK(); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); - TEST_MUSTPASS(DSCP != 10); - TEST_MUSTPASS(priority != 0); - TEST_MUSTPASS(useSetSockopt != true); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345, kVoEDefault)); + TEST_MUSTPASS(netw->SetSendTOS(0, 10, -1, true)); MARK(); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); MARK(); + TEST_MUSTPASS(DSCP != 10); + TEST_MUSTPASS(priority != 0); + TEST_MUSTPASS(useSetSockopt != true); - // STATE: *not* binded to local IP, local port is 12345 and DSCP is 10 - // (using SetSockopt) + // STATE: *not* binded to local IP, local port is 12345 and DSCP is 10 + // (using SetSockopt) - // verify loopback audio with the current settings - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); // file should be played out here... + // verify loopback audio with the current settings + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); // file should be played out here... #ifdef _SEND_TO_REMOTE_IP_ - // Send to remote destination and verify the DSCP using Wireshark. - // Use filter ip.src == "RemoteIP". - TEST_LOG("\nUse Wireshark and verify a correctly received DSCP at the" - " remote side!\n"); - TEST_LOG("Sending approx. 5 packets to %s:%d for each DSCP below:\n", - RemoteIP, RemotePort); - TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); - SLEEP(100); + // Send to remote destination and verify the DSCP using Wireshark. + // Use filter ip.src == "RemoteIP". + TEST_LOG("\nUse Wireshark and verify a correctly received DSCP at the" + " remote side!\n"); + TEST_LOG("Sending approx. 5 packets to %s:%d for each DSCP below:\n", + RemoteIP, RemotePort); + TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); + SLEEP(100); - // Change the DSCP while sending is active and verify on remote side. - TEST_MUSTPASS(netw->SetSendTOS(0, 20, -1, true)); // use setsockopt() - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); - SLEEP(100); + // Change the DSCP while sending is active and verify on remote side. + TEST_MUSTPASS(netw->SetSendTOS(0, 20, -1, true)); // use setsockopt() + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); + SLEEP(100); - // Change the DSCP while sending is active and verify on remote side. - TEST_MUSTPASS(netw->SetSendTOS(0, 61, -1, true)); // use setsockopt() - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); - SLEEP(100); + // Change the DSCP while sending is active and verify on remote side. + TEST_MUSTPASS(netw->SetSendTOS(0, 61, -1, true)); // use setsockopt() + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); + SLEEP(100); - // stop and resume sending - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); - TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); - SLEEP(100); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(netw->SetSendTOS(0, 0, -1, true)); + // stop and resume sending + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(netw->GetSendTOS(0, DSCP, priority, useSetSockopt)); + TEST_LOG(" DSCP is set to 0x%02x (setsockopt)\n", DSCP); + SLEEP(100); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(netw->SetSendTOS(0, 0, -1, true)); #endif // _SEND_TO_REMOTE_IP_ #if defined(WEBRTC_LINUX) - // Linux priority tests (using setsockopt) - TEST_LOG("Testing priority\n"); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(netw->SetSendTOS(0, 0, 3, true)); - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(netw->SetSendTOS(0, 1, 3, true)); - TEST_MUSTPASS(base->StartSend(0)); - Play(0, 2000, true, true); // file should be played out here... + // Linux priority tests (using setsockopt) + TEST_LOG("Testing priority\n"); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(netw->SetSendTOS(0, 0, 3, true)); + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(netw->SetSendTOS(0, 1, 3, true)); + TEST_MUSTPASS(base->StartSend(0)); + Play(0, 2000, true, true); // file should be played out here... #endif // #if defined(WEBRTC_LINUX) #if !defined(_WIN32) && !defined(WEBRTC_LINUX) - // Fail tests for other than Wind and Linux - TEST_MUSTPASS(!netw->SetSendTOS(0, 0, 3, false)); // Should fail - TEST_ERROR(VE_INVALID_ARGUMENT); + // Fail tests for other than Wind and Linux + TEST_MUSTPASS(!netw->SetSendTOS(0, 0, 3, false)); // Should fail + TEST_ERROR(VE_INVALID_ARGUMENT); #endif // #if !defined(_WIN32) && !defined(WEBRTC_LINUX) - TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); AOK(); ANL(); ANL(); + TEST_MUSTPASS(base->DeleteChannel(0)); + ANL(); AOK(); ANL(); ANL(); - // END #if defined(_WIN32) || defined(WEBRTC_MAC) || defined(WEBRTC_LINUX) + // END #if defined(_WIN32) || defined(WEBRTC_MAC) || defined(WEBRTC_LINUX) #else - TEST_LOG( "Skipping ToS tests - _WIN32, LINUX, MAC is not defined or " - "WEBRTC_ANDROID is defined"); + TEST_LOG("Skipping ToS tests - _WIN32, LINUX, MAC is not defined or " + "WEBRTC_ANDROID is defined"); #endif - // >> end of SetSendTOS - // ------------------------------------------------------------------------ + // >> end of SetSendTOS + // ------------------------------------------------------------------------ - // ------------------------------------------------------------------------ - // >> SetSendGQoS (Windows only) - // - // - VE initialized - // - no existing channels - // - no media - // - // From qos.h: - // - // #define SERVICETYPE_NOTRAFFIC 0x00000000 - // #define SERVICETYPE_BESTEFFORT 0x00000001 (*) - // #define SERVICETYPE_CONTROLLEDLOAD 0x00000002 (*) - // #define SERVICETYPE_GUARANTEED 0x00000003 (*) - // #define SERVICETYPE_NETWORK_UNAVAILABLE 0x00000004 - // #define SERVICETYPE_GENERAL_INFORMATION 0x00000005 - // #define SERVICETYPE_NOCHANGE 0x00000006 - // #define SERVICETYPE_NONCONFORMING 0x00000009 - // #define SERVICETYPE_NETWORK_CONTROL 0x0000000A - // #define SERVICETYPE_QUALITATIVE 0x0000000D (*) - // - // #define SERVICE_BESTEFFORT 0x80010000 - // #define SERVICE_CONTROLLEDLOAD 0x80020000 - // #define SERVICE_GUARANTEED 0x80040000 - // #define SERVICE_QUALITATIVE 0x80200000 - // - // (*) supported in WEBRTC VoE - - TEST(SetSendGQoS); - ANL(); + // ------------------------------------------------------------------------ + // >> SetSendGQoS (Windows only) + // + // - VE initialized + // - no existing channels + // - no media + // + // From qos.h: + // + // #define SERVICETYPE_NOTRAFFIC 0x00000000 + // #define SERVICETYPE_BESTEFFORT 0x00000001 (*) + // #define SERVICETYPE_CONTROLLEDLOAD 0x00000002 (*) + // #define SERVICETYPE_GUARANTEED 0x00000003 (*) + // #define SERVICETYPE_NETWORK_UNAVAILABLE 0x00000004 + // #define SERVICETYPE_GENERAL_INFORMATION 0x00000005 + // #define SERVICETYPE_NOCHANGE 0x00000006 + // #define SERVICETYPE_NONCONFORMING 0x00000009 + // #define SERVICETYPE_NETWORK_CONTROL 0x0000000A + // #define SERVICETYPE_QUALITATIVE 0x0000000D (*) + // + // #define SERVICE_BESTEFFORT 0x80010000 + // #define SERVICE_CONTROLLEDLOAD 0x80020000 + // #define SERVICE_GUARANTEED 0x80040000 + // #define SERVICE_QUALITATIVE 0x80200000 + // + // (*) supported in WEBRTC VoE + TEST(SetSendGQoS); + ANL(); #ifdef _WIN32 - // call without existing valid channel - TEST_MUSTPASS(!netw->SetSendGQoS(0, false, 0)); MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); + // call without existing valid channel + TEST_MUSTPASS(!netw->SetSendGQoS(0, false, 0)); MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->CreateChannel()); - // supported service type but no sockets - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); - TEST_ERROR(VE_SOCKETS_NOT_INITED); + // supported service type but no sockets + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); + TEST_ERROR(VE_SOCKETS_NOT_INITED); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - // supported service type but sender is not initialized - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); - TEST_ERROR(VE_DESTINATION_NOT_INITED); + // supported service type but sender is not initialized + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); + TEST_ERROR(VE_DESTINATION_NOT_INITED); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - // invalid service types - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NOTRAFFIC)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NETWORK_UNAVAILABLE)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_GENERAL_INFORMATION)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NOCHANGE)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NONCONFORMING)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NETWORK_CONTROL)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_BESTEFFORT)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_CONTROLLEDLOAD)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_GUARANTEED)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_QUALITATIVE)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); + // invalid service types + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NOTRAFFIC)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NETWORK_UNAVAILABLE)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_GENERAL_INFORMATION)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NOCHANGE)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NONCONFORMING)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_NETWORK_CONTROL)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_BESTEFFORT)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_CONTROLLEDLOAD)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_GUARANTEED)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICE_QUALITATIVE)); MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); - // Is ToS enabled here? + // Is ToS enabled here? - // Settings which don't require binding to local IP + // Settings which don't require binding to local IP - // set SERVICETYPE_BESTEFFORT - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(serviceType != SERVICETYPE_BESTEFFORT); - TEST_MUSTPASS(overrideDSCP != false); + // set SERVICETYPE_BESTEFFORT + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(serviceType != SERVICETYPE_BESTEFFORT); + TEST_MUSTPASS(overrideDSCP != false); - // set SERVICETYPE_CONTROLLEDLOAD - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_CONTROLLEDLOAD)); - MARK(); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(serviceType != SERVICETYPE_CONTROLLEDLOAD); - TEST_MUSTPASS(overrideDSCP != false); + // set SERVICETYPE_CONTROLLEDLOAD + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_CONTROLLEDLOAD)); + MARK(); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(serviceType != SERVICETYPE_CONTROLLEDLOAD); + TEST_MUSTPASS(overrideDSCP != false); - // set SERVICETYPE_GUARANTEED - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_GUARANTEED)); MARK(); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(serviceType != SERVICETYPE_GUARANTEED); - TEST_MUSTPASS(overrideDSCP != false); + // set SERVICETYPE_GUARANTEED + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_GUARANTEED)); MARK(); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(serviceType != SERVICETYPE_GUARANTEED); + TEST_MUSTPASS(overrideDSCP != false); - // set SERVICETYPE_QUALITATIVE - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_QUALITATIVE)); MARK(); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(serviceType != SERVICETYPE_QUALITATIVE); - TEST_MUSTPASS(overrideDSCP != false); + // set SERVICETYPE_QUALITATIVE + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_QUALITATIVE)); MARK(); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(serviceType != SERVICETYPE_QUALITATIVE); + TEST_MUSTPASS(overrideDSCP != false); - // disable GQoS - TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); MARK(); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - MARK(); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(serviceType != SERVICETYPE_QUALITATIVE); - TEST_MUSTPASS(overrideDSCP != false); + // disable GQoS + TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); MARK(); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + MARK(); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(serviceType != SERVICETYPE_QUALITATIVE); + TEST_MUSTPASS(overrideDSCP != false); - // STATE: diabled QGoS, sockets exists, sending side is initialized, no media + // STATE: diabled QGoS, sockets exists, sending side is initialized, no media - // Loopback tests using the four different GQoS settings + // Loopback tests using the four different GQoS settings - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - ANL(); - TEST_LOG("[SERVICETYPE_BESTEFFORT]"); - Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); MARK(); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + ANL(); + TEST_LOG("[SERVICETYPE_BESTEFFORT]"); + Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_CONTROLLEDLOAD)); MARK(); - ANL(); - TEST_LOG("[SERVICETYPE_CONTROLLEDLOAD]"); - Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_CONTROLLEDLOAD)); MARK(); + ANL(); + TEST_LOG("[SERVICETYPE_CONTROLLEDLOAD]"); + Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_GUARANTEED)); MARK(); - ANL(); - TEST_LOG("[SERVICETYPE_GUARANTEED]"); - Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_GUARANTEED)); MARK(); + ANL(); + TEST_LOG("[SERVICETYPE_GUARANTEED]"); + Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_QUALITATIVE)); MARK(); - ANL(); - TEST_LOG("[SERVICETYPE_QUALITATIVE]"); - Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_QUALITATIVE)); MARK(); + ANL(); + TEST_LOG("[SERVICETYPE_QUALITATIVE]"); + Play(0, 2000, true, true); // file should be played out here... #ifdef _SEND_TO_REMOTE_IP_ - // Send to remote destination and verify the DSCP mapping using Wireshark. - // Use filter ip.src == "RemoteIP". + // Send to remote destination and verify the DSCP mapping using Wireshark. + // Use filter ip.src == "RemoteIP". - // Modify the send destination on the fly - TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); + // Modify the send destination on the fly + TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); - TEST_LOG("\nUse Wireshark and verify a correctly received DSCP mapping at" - " the remote side!\n"); - TEST_LOG("Sending approx. 5 packets to %s:%d for each GQoS setting below:\n", - RemoteIP, RemotePort); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT (0x%02x), should " - "be mapped to DSCP = 0x00\n", serviceType); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_CONTROLLEDLOAD)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_CONTROLLEDLOAD (0x%02x), " - "should be mapped to DSCP = 0x18\n", serviceType); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); - TEST_LOG(" QoS is disabled, should give DSCP = 0x%02x\n", 0); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_GUARANTEED)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_GUARANTEED (0x%02x), should " - "be mapped to DSCP = 0x28\n", serviceType); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_QUALITATIVE)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_QUALITATIVE (0x%02x), should" - " be mapped to DSCP = 0x00\n", serviceType); - SLEEP(100); + TEST_LOG("\nUse Wireshark and verify a correctly received DSCP mapping at" + " the remote side!\n"); + TEST_LOG("Sending approx. 5 packets to %s:%d for each GQoS setting below:\n", + RemoteIP, RemotePort); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT (0x%02x), should " + "be mapped to DSCP = 0x00\n", serviceType); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_CONTROLLEDLOAD)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_CONTROLLEDLOAD (0x%02x), " + "should be mapped to DSCP = 0x18\n", serviceType); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); + TEST_LOG(" QoS is disabled, should give DSCP = 0x%02x\n", 0); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_GUARANTEED)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_GUARANTEED (0x%02x), should " + "be mapped to DSCP = 0x28\n", serviceType); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_QUALITATIVE)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_QUALITATIVE (0x%02x), should" + " be mapped to DSCP = 0x00\n", serviceType); + SLEEP(100); #endif // _SEND_TO_REMOTE_IP_ - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StopSend(0)); - // STATE: sockets exists, sending side is initialized, no media + // STATE: sockets exists, sending side is initialized, no media - // Repeat test above but this time using overrideDSCP. + // Repeat test above but this time using overrideDSCP. - // Some initial loopack tests. - // NOTE - override DSCP requres binding to local IP. + // Some initial loopack tests. + // NOTE - override DSCP requres binding to local IP. - // should not work since QoS is enabled - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 3)); - MARK(); - TEST_ERROR(VE_TOS_GQOS_CONFLICT); + // should not work since QoS is enabled + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 3)); + MARK(); + TEST_ERROR(VE_TOS_GQOS_CONFLICT); - // disble QoS and try to override again (should fail again since local - // binding is not done yet) - TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); - TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 3)); - MARK(); - TEST_ERROR(VE_GQOS_ERROR); + // disble QoS and try to override again (should fail again since local + // binding is not done yet) + TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); + TEST_MUSTPASS(!netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 3)); + MARK(); + TEST_ERROR(VE_GQOS_ERROR); - // make proper settings and try again (should work this time) - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345, kVoEDefault, localIP)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 3)); - MARK(); + // make proper settings and try again (should work this time) + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345, kVoEDefault, localIP)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, localIP)); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 3)); + MARK(); - // Now, let's try some loopback tests using override DSCP + // Now, let's try some loopback tests using override DSCP - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - ANL(); - TEST_LOG("[overrideDSCP=3]"); - Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + ANL(); + TEST_LOG("[overrideDSCP=3]"); + Play(0, 2000, true, true); // file should be played out here... - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 17)); - MARK(); - ANL(); - TEST_LOG("[overrideDSCP=17]"); - Play(0, 2000, true, true); // file should be played out here... + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 17)); + MARK(); + ANL(); + TEST_LOG("[overrideDSCP=17]"); + Play(0, 2000, true, true); // file should be played out here... - // And finally, send to remote side as well to verify that the new mapping - // works as it should. + // And finally, send to remote side as well to verify that the new mapping + // works as it should. #ifdef _SEND_TO_REMOTE_IP_ - // Modify the send destination on the fly - TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); + // Modify the send destination on the fly + TEST_MUSTPASS(base->SetSendDestination(0, RemotePort, RemoteIP)); - TEST_LOG("\nUse Wireshark and verify a correctly received DSCP mapping at" - " the remote side!\n"); - TEST_LOG("Sending approx. 5 packets to %s:%d for each GQoS setting below:\n", - RemoteIP, RemotePort); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 18)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " - "overrided to DSCP = 0x%02x\n", overrideDSCP); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 62)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " - "overrided to DSCP = 0x%02x\n", overrideDSCP); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 32)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " - "overrided to DSCP = 0x%02x\n", overrideDSCP); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 1)); - TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); - TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " - "overrided to DSCP = 0x%02x\n", overrideDSCP); - SLEEP(100); - TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); - TEST_LOG(" QoS is disabled, should give DSCP = 0x%02x\n", 0); - SLEEP(100); + TEST_LOG("\nUse Wireshark and verify a correctly received DSCP mapping at" + " the remote side!\n"); + TEST_LOG("Sending approx. 5 packets to %s:%d for each GQoS setting below:\n", + RemoteIP, RemotePort); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 18)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " + "overrided to DSCP = 0x%02x\n", overrideDSCP); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 62)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " + "overrided to DSCP = 0x%02x\n", overrideDSCP); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 32)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " + "overrided to DSCP = 0x%02x\n", overrideDSCP); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, true, SERVICETYPE_BESTEFFORT, 1)); + TEST_MUSTPASS(netw->GetSendGQoS(0, enabled, serviceType, overrideDSCP)); + TEST_LOG(" serviceType is set to SERVICETYPE_BESTEFFORT, should be " + "overrided to DSCP = 0x%02x\n", overrideDSCP); + SLEEP(100); + TEST_MUSTPASS(netw->SetSendGQoS(0, false, 0)); + TEST_LOG(" QoS is disabled, should give DSCP = 0x%02x\n", 0); + SLEEP(100); #endif // _SEND_TO_REMOTE_IP_ - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - ANL(); AOK(); ANL(); ANL(); + TEST_MUSTPASS(base->DeleteChannel(0)); + ANL(); AOK(); ANL(); ANL(); #else - TEST_LOG("Skipping GQoS tests - _WIN32 is not defined"); + TEST_LOG("Skipping GQoS tests - _WIN32 is not defined"); #endif // #ifdef _WIN32 - // >> end of SetSendGQoS - // ------------------------------------------------------------------------ + // >> end of SetSendGQoS + // ------------------------------------------------------------------------ - if (file) - { - file->StopPlayingFileAsMicrophone(0); - } - base->StopSend(0); - base->StopPlayout(0); - base->StopReceive(0); - base->DeleteChannel(0); - base->Terminate(); + if (file) { + file->StopPlayingFileAsMicrophone(0); + } + base->StopSend(0); + base->StopPlayout(0); + base->StopReceive(0); + base->DeleteChannel(0); + base->Terminate(); - ANL(); - AOK(); - return 0; + ANL(); + AOK(); + return 0; } // ---------------------------------------------------------------------------- @@ -6906,24 +6703,30 @@ int VoEExtendedTest::TestNetwork() // ---------------------------------------------------------------------------- // Used to validate packets during the RTP audio level indication test. -class RTPAudioTransport : public Transport { - public: +class RTPAudioTransport: public Transport { +public: - RTPAudioTransport() - : mute_(false) {} + RTPAudioTransport() : + mute_(false) { + } - virtual ~RTPAudioTransport() {} + virtual ~RTPAudioTransport() { + } - void set_mute(bool mute) { mute_ = mute; } - bool mute() const { return mute_; } + void set_mute(bool mute) { + mute_ = mute; + } + bool mute() const { + return mute_; + } // TODO(andrew): use proper error checks here rather than asserts. virtual int SendPacket(int channel, const void* data, int length) { - const uint8_t* packet = static_cast(data); + const uint8_t* packet = static_cast (data); // Extension bit. assert(packet[0] & 0x10); - int index = 12; // Assume standard RTP header. + int index = 12; // Assume standard RTP header. // Header extension ID assert(packet[index++] == 0xBE); assert(packet[index++] == 0xDE); @@ -6962,692 +6765,678 @@ class RTPAudioTransport : public Transport { return 0; } - private: +private: bool mute_; }; -int VoEExtendedTest::TestRTP_RTCP() -{ - PrepareTest("RTP_RTCP"); +int VoEExtendedTest::TestRTP_RTCP() { + PrepareTest("RTP_RTCP"); - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); - VoERTP_RTCP* rtp_rtcp = _mgr.RTP_RTCPPtr(); - VoENetwork* network = _mgr.NetworkPtr(); - VoEVolumeControl* volume = _mgr.VolumeControlPtr(); - VoECodec* codec = _mgr.CodecPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); + VoERTP_RTCP* rtp_rtcp = _mgr.RTP_RTCPPtr(); + VoENetwork* network = _mgr.NetworkPtr(); + VoEVolumeControl* volume = _mgr.VolumeControlPtr(); + VoECodec* codec = _mgr.CodecPtr(); - XRTPObserver rtpObserver; + XRTPObserver rtpObserver; #ifdef WEBRTC_ANDROID - int sleepTime = 200; + int sleepTime = 200; #else - int sleepTime = 100; + int sleepTime = 100; #endif #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "VoERTP_RTCP_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "VoERTP_RTCP_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); - /////////////////////////// - // Actual test starts here + /////////////////////////// + // Actual test starts here - // ------------------------------------------------------------------------ - // >> Set/GetRTPAudioLevelIndicationStatus + // ------------------------------------------------------------------------ + // >> Set/GetRTPAudioLevelIndicationStatus + TEST(SetRTPAudioLevelIndicationStatus); + ANL(); + TEST(GetRTPAudioLevelIndicationStatus); - TEST(SetRTPAudioLevelIndicationStatus); - ANL(); - TEST(GetRTPAudioLevelIndicationStatus); + // test invalid input parameters + TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, 0)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, 15)); + MARK(); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, false, 15)); + MARK(); + TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(1, true, 5)); + MARK(); + TEST_ERROR(VE_CHANNEL_NOT_VALID); - // test invalid input parameters - TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, 0)); + // test complete valid input range [1,14] + bool audioLevelEnabled(false); + unsigned char ID(0); + for (int id = 1; id < 15; id++) { + TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, id)); MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, 15)); - MARK(); - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, false, 15)); - MARK(); - TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(1, true, 5)); - MARK(); - TEST_ERROR(VE_CHANNEL_NOT_VALID); - - // test complete valid input range [1,14] - bool audioLevelEnabled(false); - unsigned char ID(0); - for (int id = 1; id < 15; id++) - { - TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, id)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTPAudioLevelIndicationStatus( + TEST_MUSTPASS(rtp_rtcp->GetRTPAudioLevelIndicationStatus( 0, audioLevelEnabled, ID)); - MARK(); - TEST_MUSTPASS(audioLevelEnabled != true); - TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, false, id)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTPAudioLevelIndicationStatus( + MARK(); + TEST_MUSTPASS(audioLevelEnabled != true); + TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, false, id)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTPAudioLevelIndicationStatus( 0, audioLevelEnabled, ID)); - MARK(); - TEST_MUSTPASS(audioLevelEnabled != false); - TEST_MUSTPASS(ID != id); - } - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - - RTPAudioTransport rtpAudioTransport; - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(network->RegisterExternalTransport(0, rtpAudioTransport)); - TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true)); - TEST_MUSTPASS(codec->SetVADStatus(0, true)); - - printf("\n\nReceving muted packets (expect VAD = 0, Level = -127)...\n"); - printf("VAD Level [dbFS]\n"); - SLEEP(2000); - rtpAudioTransport.set_mute(true); - TEST_MUSTPASS(volume->SetInputMute(0, true)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(5000); - TEST_MUSTPASS(base->StopSend(0)); - rtpAudioTransport.set_mute(false); - TEST_MUSTPASS(volume->SetInputMute(0, false)); - - printf("\nReceiving packets from mic (should respond to mic level)...\n"); - printf("VAD Level [dbFS]\n"); - SLEEP(2000); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(5000); - TEST_MUSTPASS(base->StopSend(0)); - - printf("\nReceiving packets from file (expect mostly VAD = 1)...\n"); - printf("VAD Level [dbFS]\n"); - SLEEP(2000); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(5000); - TEST_MUSTPASS(base->StopSend(0)); - - printf("\nMuted and mic on independent channels...\n"); - printf("Muted Mic\n"); - SLEEP(2000); - ASSERT_TRUE(1 == base->CreateChannel()); - TEST_MUSTPASS(network->RegisterExternalTransport(1, rtpAudioTransport)); - TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(1, true)); - TEST_MUSTPASS(codec->SetVADStatus(1, true)); - TEST_MUSTPASS(volume->SetInputMute(0, true)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartSend(1)); - SLEEP(5000); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopSend(1)); - - TEST_MUSTPASS(network->DeRegisterExternalTransport(0)); - TEST_MUSTPASS(network->DeRegisterExternalTransport(1)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->DeleteChannel(1)); - - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - MARK(); - ANL(); + TEST_MUSTPASS(audioLevelEnabled != false); + TEST_MUSTPASS(ID != id); + } + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); - // ------------------------------------------------------------------------ - // >> InsertExtraRTPPacket + RTPAudioTransport rtpAudioTransport; + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(network->RegisterExternalTransport(0, rtpAudioTransport)); + TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true)); + TEST_MUSTPASS(codec->SetVADStatus(0, true)); - int i(0); + printf("\n\nReceving muted packets (expect VAD = 0, Level = -127)...\n"); + printf("VAD Level [dbFS]\n"); + SLEEP(2000); + rtpAudioTransport.set_mute(true); + TEST_MUSTPASS(volume->SetInputMute(0, true)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(5000); + TEST_MUSTPASS(base->StopSend(0)); + rtpAudioTransport.set_mute(false); + TEST_MUSTPASS(volume->SetInputMute(0, false)); - TEST(SetLocalSSRC); - TEST_MUSTPASS(!rtp_rtcp->SetLocalSSRC(0, 5678)); - MARK(); - TEST_MUSTPASS(VE_ALREADY_SENDING != base->LastError()); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 5678)); // force send SSRC to 5678 - TEST_MUSTPASS(base->StartSend(0)); - MARK(); - ANL(); + printf("\nReceiving packets from mic (should respond to mic level)...\n"); + printf("VAD Level [dbFS]\n"); + SLEEP(2000); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(5000); + TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); + printf("\nReceiving packets from file (expect mostly VAD = 1)...\n"); + printf("VAD Level [dbFS]\n"); + SLEEP(2000); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(5000); + TEST_MUSTPASS(base->StopSend(0)); - // ------------------------------------------------------------------------ - // >> InsertExtraRTPPacket + printf("\nMuted and mic on independent channels...\n"); + printf("Muted Mic\n"); + SLEEP(2000); + ASSERT_TRUE(1 == base->CreateChannel()); + TEST_MUSTPASS(network->RegisterExternalTransport(1, rtpAudioTransport)); + TEST_MUSTPASS(rtp_rtcp->SetRTPAudioLevelIndicationStatus(1, true)); + TEST_MUSTPASS(codec->SetVADStatus(1, true)); + TEST_MUSTPASS(volume->SetInputMute(0, true)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartSend(1)); + SLEEP(5000); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopSend(1)); - TEST(InsertExtraRTPPacket); - ANL(); + TEST_MUSTPASS(network->DeRegisterExternalTransport(0)); + TEST_MUSTPASS(network->DeRegisterExternalTransport(1)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->DeleteChannel(1)); - const char payloadData[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }; + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(-1, 0, false, - payloadData, 8)); - MARK(); // invalid channel - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, -1, false, - payloadData, 8)); - MARK(); // invalid payload type - TEST_ERROR(VE_INVALID_PLTYPE); - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 128, false, - payloadData, 8)); - MARK(); // invalid payload type - TEST_ERROR(VE_INVALID_PLTYPE); - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 99, false, - NULL, 8)); + MARK(); + ANL(); + + // ------------------------------------------------------------------------ + // >> InsertExtraRTPPacket + + int i(0); + + TEST(SetLocalSSRC); + TEST_MUSTPASS(!rtp_rtcp->SetLocalSSRC(0, 5678)); + MARK(); + TEST_MUSTPASS(VE_ALREADY_SENDING != base->LastError()); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 5678)); // force send SSRC to 5678 + TEST_MUSTPASS(base->StartSend(0)); + MARK(); + ANL(); + + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); + + // ------------------------------------------------------------------------ + // >> InsertExtraRTPPacket + TEST(InsertExtraRTPPacket); + ANL(); + + const char payloadData[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }; + + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(-1, 0, false, + payloadData, 8)); + MARK(); // invalid channel + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, -1, false, + payloadData, 8)); + MARK(); // invalid payload type + TEST_ERROR(VE_INVALID_PLTYPE); + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 128, false, + payloadData, 8)); + MARK(); // invalid payload type + TEST_ERROR(VE_INVALID_PLTYPE); + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 99, false, + NULL, 8)); MARK(); // invalid pointer - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 99, false, - payloadData, 1500-28+1)); - MARK(); // invalid size - TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 99, false, - payloadData, 8)); - MARK(); // not sending - TEST_ERROR(VE_NOT_SENDING); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 99, false, + payloadData, 1500-28+1)); + MARK(); // invalid size + TEST_ERROR(VE_INVALID_ARGUMENT); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, 99, false, + payloadData, 8)); + MARK(); // not sending + TEST_ERROR(VE_NOT_SENDING); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); - SLEEP(1000); - for (int p = 0; p < 128; p++) - { - TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, p, false, - payloadData, 8)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, p, true, - payloadData, 8)); - MARK(); - } + SLEEP(1000); + for (int p = 0; p < 128; p++) { + TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, p, false, + payloadData, 8)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, p, true, + payloadData, 8)); + MARK(); + } - // Ensure we have sent all extra packets before we move forward to avoid - //incorrect error code - SLEEP(1000); + // Ensure we have sent all extra packets before we move forward to avoid + //incorrect error code + SLEEP(1000); - ANL(); + ANL(); - // ------------------------------------------------------------------------ - // >> RTP dump APIs + // ------------------------------------------------------------------------ + // >> RTP dump APIs + TEST(Start/StopRtpDump); + ANL(); + TEST(Start/RTPDumpIsActive); - TEST(Start/StopRtpDump); - ANL(); - TEST(Start/RTPDumpIsActive); + TEST_MUSTPASS(-1 != rtp_rtcp->RTPDumpIsActive(-1, kRtpIncoming)); + MARK(); // invalid channel + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(false != rtp_rtcp->RTPDumpIsActive(0, kRtpIncoming)); + MARK(); // should be off by default + TEST_MUSTPASS(false != rtp_rtcp->RTPDumpIsActive(0, kRtpOutgoing)); + MARK(); // should be off by default - TEST_MUSTPASS(-1 != rtp_rtcp->RTPDumpIsActive(-1, kRtpIncoming)); - MARK(); // invalid channel - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(false != rtp_rtcp->RTPDumpIsActive(0, kRtpIncoming)); - MARK(); // should be off by default - TEST_MUSTPASS(false != rtp_rtcp->RTPDumpIsActive(0, kRtpOutgoing)); - MARK(); // should be off by default + TEST_MUSTPASS(-1 != rtp_rtcp->StartRTPDump(-1, NULL)); + MARK(); // invalid channel + TEST_ERROR(VE_CHANNEL_NOT_VALID); + TEST_MUSTPASS(-1 != rtp_rtcp->StartRTPDump(0, NULL)); + MARK(); // invalid file name + TEST_ERROR(VE_BAD_FILE); - TEST_MUSTPASS(-1 != rtp_rtcp->StartRTPDump(-1, NULL)); - MARK(); // invalid channel - TEST_ERROR(VE_CHANNEL_NOT_VALID); - TEST_MUSTPASS(-1 != rtp_rtcp->StartRTPDump(0, NULL)); - MARK(); // invalid file name - TEST_ERROR(VE_BAD_FILE); + // Create two RTP dump files: - // Create two RTP dump files: + // - dump_in_1sec.rtp <=> ~1 sec recording of input side + // - dump_in_2sec.rtp <=> ~2 sec recording of output side + // + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpIncoming)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpOutgoing)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, GetFilename("dump_in_1sec.rtp"), + kRtpIncoming)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, GetFilename("dump_out_2sec.rtp"), + kRtpOutgoing)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpIncoming)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpOutgoing)); + MARK(); - // - dump_in_1sec.rtp <=> ~1 sec recording of input side - // - dump_in_2sec.rtp <=> ~2 sec recording of output side - // + // Start/Stop tests: + // + // - only one file (called dump_in_200ms.rtp) should exist after this test + // + for (i = 0; i < 10; i++) { + TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, + GetFilename("dump_in_200ms.rtp"))); + MARK(); + SLEEP(200); TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0)); MARK(); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpIncoming)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpOutgoing)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, GetFilename("dump_in_1sec.rtp"), - kRtpIncoming)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, GetFilename("dump_out_2sec.rtp"), - kRtpOutgoing)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpIncoming)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpOutgoing)); - MARK(); + } - // Start/Stop tests: - // - // - only one file (called dump_in_200ms.rtp) should exist after this test - // - for (i = 0; i < 10; i++) - { - TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, - GetFilename("dump_in_200ms.rtp"))); - MARK(); - SLEEP(200); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0)); - MARK(); - } + // >> end of RTP dump APIs + // ------------------------------------------------------------------------ + ANL(); - // >> end of RTP dump APIs - // ------------------------------------------------------------------------ + TEST(GetRTCPStatus); + bool enabled; + TEST_MUSTPASS(!rtp_rtcp->GetRTCPStatus(-1, enabled)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, enabled)); + MARK(); // should be on by default + TEST_MUSTPASS(enabled != true); + ANL(); - ANL(); + TEST(SetRTCPStatus); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, enabled)); + TEST_MUSTPASS(enabled != false); + MARK(); + SLEEP(2000); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, enabled)); + TEST_MUSTPASS(enabled != true); + MARK(); + SLEEP(6000); // Make sure we get an RTCP packet + ANL(); - TEST(GetRTCPStatus); - bool enabled; - TEST_MUSTPASS(!rtp_rtcp->GetRTCPStatus(-1, enabled)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, enabled)); - MARK(); // should be on by default - TEST_MUSTPASS(enabled != true); - ANL(); + TEST(CNAME); + TEST_MUSTPASS(!rtp_rtcp->SetRTCP_CNAME(0, NULL)); + MARK(); + TEST_MUSTPASS(VE_RTP_RTCP_MODULE_ERROR != base->LastError()); + MARK(); + TEST_MUSTPASS(!rtp_rtcp->GetRemoteRTCP_CNAME(0, NULL)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + ANL(); - TEST(SetRTCPStatus); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, enabled)); - TEST_MUSTPASS(enabled != false); - MARK(); - SLEEP(2000); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, enabled)); - TEST_MUSTPASS(enabled != true); - MARK(); - SLEEP(6000); // Make sure we get an RTCP packet - ANL(); + TEST(GetRemoteSSRC); + unsigned int ssrc(0); + TEST_MUSTPASS(rtp_rtcp->GetRemoteSSRC(0, ssrc)); + MARK(); + TEST_MUSTPASS(ssrc != 5678); + ANL(); - TEST(CNAME); - TEST_MUSTPASS(!rtp_rtcp->SetRTCP_CNAME(0, NULL)); - MARK(); - TEST_MUSTPASS(VE_RTP_RTCP_MODULE_ERROR != base->LastError()); - MARK(); - TEST_MUSTPASS(!rtp_rtcp->GetRemoteRTCP_CNAME(0, NULL)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - ANL(); + TEST(GetRemoteCSRC); // only trivial tests added + unsigned int csrcs[2]; + int n(0); + TEST_MUSTPASS(!rtp_rtcp->GetRemoteCSRCs(1, csrcs)); + MARK(); + n = rtp_rtcp->GetRemoteCSRCs(0, csrcs); + MARK(); + TEST_MUSTPASS(n != 0); // should be empty + ANL(); - TEST(GetRemoteSSRC); - unsigned int ssrc(0); - TEST_MUSTPASS(rtp_rtcp->GetRemoteSSRC(0, ssrc)); - MARK(); - TEST_MUSTPASS(ssrc != 5678); - ANL(); + TEST(SetRTPObserver); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(0, rtpObserver)); + TEST_MUSTPASS(rtp_rtcp->DeRegisterRTPObserver(0)); + TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(0, rtpObserver)); + TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 7777)); // force send SSRC to 7777 + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(sleepTime); + // verify that the new SSRC has been detected by the observer + TEST_MUSTPASS(rtpObserver._SSRC != 7777); + TEST_MUSTPASS(rtp_rtcp->DeRegisterRTPObserver(0)); + ANL(); - TEST(GetRemoteCSRC); // only trivial tests added - unsigned int csrcs[2]; - int n(0); - TEST_MUSTPASS(!rtp_rtcp->GetRemoteCSRCs(1, csrcs)); - MARK(); - n = rtp_rtcp->GetRemoteCSRCs(0, csrcs); - MARK(); - TEST_MUSTPASS(n != 0); // should be empty - ANL(); + TEST(GetRTPKeepaliveStatus); + unsigned char pt; + int dT; + TEST_MUSTPASS(!rtp_rtcp->GetRTPKeepaliveStatus(-1, enabled, pt, dT)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); + MARK(); // should be off by default + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(pt != 255); + TEST_MUSTPASS(dT != 0); + ANL(); - TEST(SetRTPObserver); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(0, rtpObserver)); - TEST_MUSTPASS(rtp_rtcp->DeRegisterRTPObserver(0)); - TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(0, rtpObserver)); - TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 7777)); // force send SSRC to 7777 - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(sleepTime); - // verify that the new SSRC has been detected by the observer - TEST_MUSTPASS(rtpObserver._SSRC != 7777); - TEST_MUSTPASS(rtp_rtcp->DeRegisterRTPObserver(0)); - ANL(); + TEST(SetRTPKeepaliveStatus); + // stop send before changing the settings + TEST_MUSTPASS(base->StopSend(0)); + // verify invalid input parameters + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(-1, true, 0, 15)); + MARK(); + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, -1, 15)); + MARK(); + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, 0, 61)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); + MARK(); // should still be off + TEST_MUSTPASS(enabled != false); + // try valid settings + TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 117)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); + MARK(); // should be on now + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(pt != 117); + TEST_MUSTPASS(dT != 15); + // change from PT 99 to 121, as 99 is occupied + TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 121, 3)); + MARK(); // on, PT=99, dT=3 + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); + MARK(); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(pt != 121); + TEST_MUSTPASS(dT != 3); + ANL(); - TEST(GetRTPKeepaliveStatus); - unsigned char pt; - int dT; - TEST_MUSTPASS(!rtp_rtcp->GetRTPKeepaliveStatus(-1, enabled, pt, dT)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); - MARK(); // should be off by default - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(pt != 255); - TEST_MUSTPASS(dT != 0); - ANL(); + // Make fresh restart (ensures that SSRC is randomized) + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); - TEST(SetRTPKeepaliveStatus); - // stop send before changing the settings - TEST_MUSTPASS(base->StopSend(0)); - // verify invalid input parameters - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(-1, true, 0, 15)); - MARK(); - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, -1, 15)); - MARK(); - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, 0, 61)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); - MARK(); // should still be off - TEST_MUSTPASS(enabled != false); - // try valid settings - TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 117)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); - MARK(); // should be on now - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(pt != 117); - TEST_MUSTPASS(dT != 15); - // change from PT 99 to 121, as 99 is occupied - TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 121, 3)); - MARK(); // on, PT=99, dT=3 - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, enabled, pt, dT)); - MARK(); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(pt != 121); - TEST_MUSTPASS(dT != 3); - ANL(); + SLEEP(100); - // Make fresh restart (ensures that SSRC is randomized) + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); + SLEEP(8000); - SLEEP(100); + TEST(GetRemoteRTCPData); + // Statistics based on received RTCP reports (i.e. statistics on the remote + // side sent to us). + unsigned int NTPHigh(0), NTPLow(0), timestamp(0), playoutTimestamp(0), + jitter(0); + unsigned short fractionLost(0); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh, NTPLow, + timestamp, playoutTimestamp)); + TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " + " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", + NTPHigh, NTPLow, timestamp, playoutTimestamp, jitter, fractionLost); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); + unsigned int NTPHigh2(0), NTPLow2(0), timestamp2(0); + unsigned int playoutTimestamp2(0), jitter2(0); + unsigned short fractionLost2(0); - SLEEP(8000); + TEST_LOG("take a new sample and ensure that the playout timestamp is " + "maintained"); + SLEEP(100); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh2, NTPLow2, timestamp2, + playoutTimestamp2, &jitter2, + &fractionLost2)); + TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " + " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", + NTPHigh2, NTPLow2, timestamp2, playoutTimestamp2, jitter2, fractionLost2); + TEST_MUSTPASS(playoutTimestamp != playoutTimestamp2); - TEST(GetRemoteRTCPData); - // Statistics based on received RTCP reports (i.e. statistics on the remote - // side sent to us). - unsigned int NTPHigh(0), NTPLow(0), timestamp(0), playoutTimestamp(0), - jitter(0); - unsigned short fractionLost(0); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh, NTPLow, - timestamp, playoutTimestamp)); - TEST_LOG( "\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " - " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", - NTPHigh, NTPLow, timestamp, playoutTimestamp, jitter, fractionLost); - - unsigned int NTPHigh2(0), NTPLow2(0), timestamp2(0); - unsigned int playoutTimestamp2(0), jitter2(0); - unsigned short fractionLost2(0); - - TEST_LOG( - "take a new sample and ensure that the playout timestamp is " - "maintained"); - SLEEP(100); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh2, NTPLow2, timestamp2, - playoutTimestamp2, &jitter2, - &fractionLost2)); - TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " - " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", - NTPHigh2, NTPLow2, timestamp2, playoutTimestamp2, jitter2, - fractionLost2); - TEST_MUSTPASS(playoutTimestamp != playoutTimestamp2); - - TEST_LOG("wait for 8 seconds and ensure that the RTCP statistics is" - " updated..."); - SLEEP(8000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh2, NTPLow2, - timestamp2, playoutTimestamp2, - &jitter2, &fractionLost2)); - TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " - " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", - NTPHigh2, NTPLow2, timestamp2, playoutTimestamp2, jitter2, - fractionLost2); - TEST_MUSTPASS((NTPHigh == NTPHigh2) && (NTPLow == NTPLow2)); - TEST_MUSTPASS(timestamp == timestamp2); - TEST_MUSTPASS(playoutTimestamp == playoutTimestamp2); + TEST_LOG("wait for 8 seconds and ensure that the RTCP statistics is" + " updated..."); + SLEEP(8000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh2, NTPLow2, + timestamp2, playoutTimestamp2, + &jitter2, &fractionLost2)); + TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " + " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", + NTPHigh2, NTPLow2, timestamp2, playoutTimestamp2, jitter2, fractionLost2); + TEST_MUSTPASS((NTPHigh == NTPHigh2) && (NTPLow == NTPLow2)); + TEST_MUSTPASS(timestamp == timestamp2); + TEST_MUSTPASS(playoutTimestamp == playoutTimestamp2); #ifdef WEBRTC_CODEC_RED - //The following test is related to defect 4985 and 4986 - TEST_LOG("Turn FEC and VAD on and wait for 4 seconds and ensure that " - "the jitter is still small..."); - CodecInst cinst; + //The following test is related to defect 4985 and 4986 + TEST_LOG("Turn FEC and VAD on and wait for 4 seconds and ensure that " + "the jitter is still small..."); + CodecInst cinst; #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - cinst.pltype = 104; - strcpy(cinst.plname, "isac"); - cinst.plfreq = 32000; - cinst.pacsize = 960; - cinst.channels = 1; - cinst.rate = 45000; + cinst.pltype = 104; + strcpy(cinst.plname, "isac"); + cinst.plfreq = 32000; + cinst.pacsize = 960; + cinst.channels = 1; + cinst.rate = 45000; #else - cinst.pltype = 119; - strcpy(cinst.plname, "isaclc"); - cinst.plfreq = 16000; - cinst.pacsize = 320; - cinst.channels = 1; - cinst.rate = 40000; + cinst.pltype = 119; + strcpy(cinst.plname, "isaclc"); + cinst.plfreq = 16000; + cinst.pacsize = 320; + cinst.channels = 1; + cinst.rate = 40000; #endif - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true, -1)); - MARK(); - TEST_MUSTPASS(codec->SetVADStatus(0,true)); - SLEEP(4000); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh2, NTPLow2, timestamp2, - playoutTimestamp2, &jitter2, - &fractionLost2)); - TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " - " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", - NTPHigh2, NTPLow2, timestamp2, playoutTimestamp2, jitter2, - fractionLost2); - TEST_MUSTPASS(jitter2 > 1000) - TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, false)); - MARK(); - //4985 and 4986 end + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true, -1)); + MARK(); + TEST_MUSTPASS(codec->SetVADStatus(0,true)); + SLEEP(4000); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCPData(0, NTPHigh2, NTPLow2, timestamp2, + playoutTimestamp2, &jitter2, + &fractionLost2)); + TEST_LOG("\n NTPHigh = %u \n NTPLow = %u \n timestamp = %u \n " + " playoutTimestamp = %u \n jitter = %u \n fractionLost = %hu \n", + NTPHigh2, NTPLow2, timestamp2, playoutTimestamp2, jitter2, fractionLost2); + TEST_MUSTPASS(jitter2 > 1000) + TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, false)); + MARK(); + //4985 and 4986 end #endif // #ifdef WEBRTC_CODEC_RED - TEST(GetRTPStatistics); - ANL(); - // Statistics summarized on local side based on received RTP packets. - CallStatistics stats; - // Call GetRTPStatistics over a longer period than 7.5 seconds - // (=dT RTCP transmissions). - unsigned int averageJitterMs, maxJitterMs, discardedPackets; + TEST(GetRTPStatistics); + ANL(); + // Statistics summarized on local side based on received RTP packets. + CallStatistics stats; + // Call GetRTPStatistics over a longer period than 7.5 seconds + // (=dT RTCP transmissions). + unsigned int averageJitterMs, maxJitterMs, discardedPackets; + SLEEP(1000); + for (i = 0; i < 8; i++) { + TEST_MUSTPASS(rtp_rtcp->GetRTPStatistics(0, averageJitterMs, + maxJitterMs, + discardedPackets)); + TEST_LOG(" %i) averageJitterMs = %u \n maxJitterMs = %u \n " + " discardedPackets = %u \n", i, averageJitterMs, maxJitterMs, + discardedPackets); SLEEP(1000); - for (i = 0; i < 8; i++) - { - TEST_MUSTPASS(rtp_rtcp->GetRTPStatistics(0, averageJitterMs, - maxJitterMs, - discardedPackets)); - TEST_LOG( " %i) averageJitterMs = %u \n maxJitterMs = %u \n " - " discardedPackets = %u \n", - i, averageJitterMs, maxJitterMs, discardedPackets); - SLEEP(1000); - } + } - TEST(RTCPStatistics #1); - ANL(); - unsigned int packetsSent(0); - unsigned int packetsReceived(0); - for (i = 0; i < 8; i++) - { - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); - TEST_LOG(" %i) fractionLost = %hu \n cumulativeLost = %u \n " - " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", - i, stats.fractionLost, stats.cumulativeLost, - stats.extendedMax, stats.jitterSamples, stats.rttMs); - TEST_LOG( " bytesSent = %d \n packetsSent = %d \n " - " bytesReceived = %d \n packetsReceived = %d \n", - stats.bytesSent, stats.packetsSent, stats.bytesReceived, - stats.packetsReceived); - if (i > 0) - { - TEST_LOG(" diff sent packets : %u (~50)\n", - stats.packetsSent - packetsSent); - TEST_LOG(" diff received packets: %u (~50)\n", - stats.packetsReceived - packetsReceived); - } - packetsSent = stats.packetsSent; - packetsReceived = stats.packetsReceived; - SLEEP(1000); - } - -TEST(RTCPStatistics #2); - ANL(); - TEST_LOG("restart sending and ensure that the statistics is reset"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(50); // ensures approx. two received packets + TEST(RTCPStatistics #1); + ANL(); + unsigned int packetsSent(0); + unsigned int packetsReceived(0); + for (i = 0; i < 8; i++) + { TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); - TEST_LOG("\n fractionLost = %hu \n cumulativeLost = %u \n " + TEST_LOG(" %i) fractionLost = %hu \n cumulativeLost = %u \n " " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", - stats.fractionLost, stats.cumulativeLost, + i, stats.fractionLost, stats.cumulativeLost, stats.extendedMax, stats.jitterSamples, stats.rttMs); TEST_LOG( " bytesSent = %d \n packetsSent = %d \n " " bytesReceived = %d \n packetsReceived = %d \n", stats.bytesSent, stats.packetsSent, stats.bytesReceived, stats.packetsReceived); + if (i > 0) + { + TEST_LOG(" diff sent packets : %u (~50)\n", + stats.packetsSent - packetsSent); + TEST_LOG(" diff received packets: %u (~50)\n", + stats.packetsReceived - packetsReceived); + } + packetsSent = stats.packetsSent; + packetsReceived = stats.packetsReceived; + SLEEP(1000); + } - TEST(RTCPStatistics #3); - ANL(); - TEST_LOG("disable RTCP and verify that statistics is not corrupt"); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); - SLEEP(250); - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); - TEST_LOG("\n fractionLost = %hu \n cumulativeLost = %u \n " - " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", - stats.fractionLost, stats.cumulativeLost, - stats.extendedMax, stats.jitterSamples, stats.rttMs); - TEST_LOG(" bytesSent = %d \n packetsSent = %d \n " - "bytesReceived = %d \n packetsReceived = %d \n", - stats.bytesSent, stats.packetsSent, - stats.bytesReceived, stats.packetsReceived); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); + TEST(RTCPStatistics #2); + ANL(); + TEST_LOG("restart sending and ensure that the statistics is reset"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(50); // ensures approx. two received packets + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); + TEST_LOG("\n fractionLost = %hu \n cumulativeLost = %u \n " + " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", + stats.fractionLost, stats.cumulativeLost, + stats.extendedMax, stats.jitterSamples, stats.rttMs); + TEST_LOG( " bytesSent = %d \n packetsSent = %d \n " + " bytesReceived = %d \n packetsReceived = %d \n", + stats.bytesSent, stats.packetsSent, stats.bytesReceived, + stats.packetsReceived); - TEST(RTCPStatistics #4); - ANL(); - TEST_LOG("restart receiving and check RX statistics"); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->StartReceive(0)); - SLEEP(50); // ensures approx. two received packets - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); - TEST_LOG("\n fractionLost = %hu \n cumulativeLost = %u \n " - " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", - stats.fractionLost, stats.cumulativeLost, - stats.extendedMax, stats.jitterSamples, - stats.rttMs); - TEST_LOG(" bytesSent = %d \n packetsSent = %d \n " - " bytesReceived = %d \n packetsReceived = %d \n", - stats.bytesSent, stats.packetsSent, - stats.bytesReceived, stats.packetsReceived); + TEST(RTCPStatistics #3); + ANL(); + TEST_LOG("disable RTCP and verify that statistics is not corrupt"); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); + SLEEP(250); + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); + TEST_LOG("\n fractionLost = %hu \n cumulativeLost = %u \n " + " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", + stats.fractionLost, stats.cumulativeLost, + stats.extendedMax, stats.jitterSamples, stats.rttMs); + TEST_LOG(" bytesSent = %d \n packetsSent = %d \n " + "bytesReceived = %d \n packetsReceived = %d \n", + stats.bytesSent, stats.packetsSent, + stats.bytesReceived, stats.packetsReceived); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); - TEST(SendApplicationDefinedRTCPPacket); - // just do some fail tests here - TEST_MUSTPASS(base->StopSend(0)); - // should fail since sending is off - TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket( - 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); - MARK(); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket( - 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); - // should fail since RTCP is off - TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket( - 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); - TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket( - 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); - MARK(); - // invalid data length - TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket( - 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabc", 31)); - MARK(); - // invalid data vector - TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket(0, 0, 0, NULL, 0)); - MARK(); - ANL(); + TEST(RTCPStatistics #4); + ANL(); + TEST_LOG("restart receiving and check RX statistics"); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->StartReceive(0)); + SLEEP(50); // ensures approx. two received packets + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatistics(0, stats)); + TEST_LOG("\n fractionLost = %hu \n cumulativeLost = %u \n " + " extendedMax = %u \n jitterSamples = %u \n rttMs = %d \n", + stats.fractionLost, stats.cumulativeLost, + stats.extendedMax, stats.jitterSamples, + stats.rttMs); + TEST_LOG(" bytesSent = %d \n packetsSent = %d \n " + " bytesReceived = %d \n packetsReceived = %d \n", + stats.bytesSent, stats.packetsSent, + stats.bytesReceived, stats.packetsReceived); + + TEST(SendApplicationDefinedRTCPPacket); + // just do some fail tests here + TEST_MUSTPASS(base->StopSend(0)); + // should fail since sending is off + TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket( + 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); + MARK(); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket( + 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); + // should fail since RTCP is off + TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket( + 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); + TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket( + 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabcd", 32)); + MARK(); + // invalid data length + TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket( + 0, 0, 0, "abcdabcdabcdabcdabcdabcdabcdabc", 31)); + MARK(); + // invalid data vector + TEST_MUSTPASS(!rtp_rtcp->SendApplicationDefinedRTCPPacket(0, 0, 0, NULL, 0)); + MARK(); + ANL(); #ifdef WEBRTC_CODEC_RED - TEST(SetFECStatus); - ANL(); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - cinst.pltype = 126; - strcpy(cinst.plname, "red"); - cinst.plfreq = 8000; - cinst.pacsize = 0; - cinst.channels = 1; - cinst.rate = 0; - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST(SetFECStatus); + ANL(); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); + cinst.pltype = 126; + strcpy(cinst.plname, "red"); + cinst.plfreq = 8000; + cinst.pacsize = 0; + cinst.channels = 1; + cinst.rate = 0; + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - cinst.pltype = 104; - strcpy(cinst.plname, "isac"); - cinst.plfreq = 32000; - cinst.pacsize = 960; - cinst.channels = 1; - cinst.rate = 45000; + cinst.pltype = 104; + strcpy(cinst.plname, "isac"); + cinst.plfreq = 32000; + cinst.pacsize = 960; + cinst.channels = 1; + cinst.rate = 45000; #else - cinst.pltype = 119; - strcpy(cinst.plname, "isaclc"); - cinst.plfreq = 16000; - cinst.pacsize = 320; - cinst.channels = 1; - cinst.rate = 40000; + cinst.pltype = 119; + strcpy(cinst.plname, "isaclc"); + cinst.plfreq = 16000; + cinst.pacsize = 320; + cinst.channels = 1; + cinst.rate = 40000; #endif - // We have to re-register the audio codec payload type as stopReceive will - // clean the database - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); - TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true, 126)); - MARK(); - TEST_LOG("Should sound OK with FEC enabled\n"); - SLEEP(4000); - TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, false)); - MARK(); + // We have to re-register the audio codec payload type as stopReceive will + // clean the database + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); + TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true, 126)); + MARK(); + TEST_LOG("Should sound OK with FEC enabled\n"); + SLEEP(4000); + TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, false)); + MARK(); #endif // #ifdef WEBRTC_CODEC_RED - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - ANL(); - AOK(); - return 0; + ANL(); + AOK(); + return 0; } // ---------------------------------------------------------------------------- @@ -7656,100 +7445,100 @@ TEST(RTCPStatistics #2); int VoEExtendedTest::TestVideoSync() { - PrepareTest("VideoSync"); + PrepareTest("VideoSync"); - VoEBase* base = _mgr.BasePtr(); - VoEVideoSync* vsync = _mgr.VideoSyncPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEVideoSync* vsync = _mgr.VideoSyncPtr(); - // check if this interface is supported - if (!vsync) - { - TEST_LOG("VoEVideoSync is not supported!"); - return -1; - } + // check if this interface is supported + if (!vsync) + { + TEST_LOG("VoEVideoSync is not supported!"); + return -1; + } #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "VoEVideoSync_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "VoEVideoSync_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); - /////////////////////////// - // Actual test starts here + /////////////////////////// + // Actual test starts here - TEST(SetInitTimestamp); - ANL(); - TEST_MUSTPASS(!vsync->SetInitTimestamp(0, 12345)); - TEST_MUSTPASS(base->StopSend(0)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(vsync->SetInitTimestamp(0, 12345)); - TEST_MUSTPASS(base->StartSend(0)); - MARK(); - SLEEP(1000); - AOK(); - ANL(); + TEST(SetInitTimestamp); + ANL(); + TEST_MUSTPASS(!vsync->SetInitTimestamp(0, 12345)); + TEST_MUSTPASS(base->StopSend(0)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(vsync->SetInitTimestamp(0, 12345)); + TEST_MUSTPASS(base->StartSend(0)); + MARK(); + SLEEP(1000); + AOK(); + ANL(); - TEST(SetInitSequenceNumber); - ANL(); - TEST_MUSTPASS(!vsync->SetInitSequenceNumber(0, 123)); - TEST_MUSTPASS(base->StopSend(0)); - MARK(); - SLEEP(1000); - TEST_MUSTPASS(vsync->SetInitSequenceNumber(0, 123)); - TEST_MUSTPASS(base->StartSend(0)); - MARK(); - SLEEP(1000); - AOK(); - ANL(); + TEST(SetInitSequenceNumber); + ANL(); + TEST_MUSTPASS(!vsync->SetInitSequenceNumber(0, 123)); + TEST_MUSTPASS(base->StopSend(0)); + MARK(); + SLEEP(1000); + TEST_MUSTPASS(vsync->SetInitSequenceNumber(0, 123)); + TEST_MUSTPASS(base->StartSend(0)); + MARK(); + SLEEP(1000); + AOK(); + ANL(); - unsigned int timeStamp; - TEST(GetPlayoutTimestamp); - ANL(); - TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, timeStamp)); - TEST_LOG("GetPlayoutTimestamp: %u", timeStamp); - SLEEP(1000); - TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, timeStamp)); - TEST_LOG(" %u", timeStamp); - SLEEP(1000); - TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, timeStamp)); - TEST_LOG(" %u\n", timeStamp); - AOK(); - ANL(); + unsigned int timeStamp; + TEST(GetPlayoutTimestamp); + ANL(); + TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, timeStamp)); + TEST_LOG("GetPlayoutTimestamp: %u", timeStamp); + SLEEP(1000); + TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, timeStamp)); + TEST_LOG(" %u", timeStamp); + SLEEP(1000); + TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, timeStamp)); + TEST_LOG(" %u\n", timeStamp); + AOK(); + ANL(); - TEST(SetMinimumPlayoutDelay); - ANL(); - TEST_MUSTPASS(!vsync->SetMinimumPlayoutDelay(0, -1)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); - TEST_MUSTPASS(!vsync->SetMinimumPlayoutDelay(0, 5000)); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - MARK(); + TEST(SetMinimumPlayoutDelay); + ANL(); + TEST_MUSTPASS(!vsync->SetMinimumPlayoutDelay(0, -1)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); + TEST_MUSTPASS(!vsync->SetMinimumPlayoutDelay(0, 5000)); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + MARK(); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - AOK(); - ANL(); - return 0; + AOK(); + ANL(); + return 0; } // ---------------------------------------------------------------------------- @@ -7758,842 +7547,839 @@ int VoEExtendedTest::TestVideoSync() int VoEExtendedTest::TestVolumeControl() { - PrepareTest("TestVolumeControl"); + PrepareTest("TestVolumeControl"); - VoEBase* base = _mgr.BasePtr(); - VoEVolumeControl* volume = _mgr.VolumeControlPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEVolumeControl* volume = _mgr.VolumeControlPtr(); #ifdef _TEST_FILE_ - VoEFile* file = _mgr.FilePtr(); + VoEFile* file = _mgr.FilePtr(); #endif #ifdef _TEST_HARDWARE_ - VoEHardware* hardware = _mgr.HardwarePtr(); + VoEHardware* hardware = _mgr.HardwarePtr(); #endif #ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile( - GetFilename("VoEVolumeControl_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile( + GetFilename("VoEVolumeControl_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); #endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); -#if (defined _TEST_HARDWARE_ && (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID))) + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); +#if (defined _TEST_HARDWARE_ && (!defined(MAC_IPHONE) && \ + !defined(WEBRTC_ANDROID))) #if defined(_WIN32) - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); #else - TEST_MUSTPASS(hardware->SetRecordingDevice(0)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); + TEST_MUSTPASS(hardware->SetRecordingDevice(0)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); #endif #endif - TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); - TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->SetLocalReceiver(0, 12345)); + TEST_MUSTPASS(base->SetSendDestination(0, 12345, "127.0.0.1")); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); #ifdef _TEST_FILE_ - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), - true, true)); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, _mgr.AudioFilename(), + true, true)); #endif - //////////////////////////// - // Actual test starts here + //////////////////////////// + // Actual test starts here #if !defined(MAC_IPHONE) - TEST(SetSpeakerVolume); - ANL(); - TEST_MUSTPASS(-1 != volume->SetSpeakerVolume(256)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - ANL(); + TEST(SetSpeakerVolume); + ANL(); + TEST_MUSTPASS(-1 != volume->SetSpeakerVolume(256)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + ANL(); #endif // #if !defined(MAC_IPHONE) #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - TEST(SetMicVolume); ANL(); - TEST_MUSTPASS(-1 != volume->SetMicVolume(256)); MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - ANL(); + TEST(SetMicVolume); ANL(); + TEST_MUSTPASS(-1 != volume->SetMicVolume(256)); MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + ANL(); #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) #if !defined(MAC_IPHONE) - TEST(SetChannelOutputVolumeScaling); - ANL(); - TEST_MUSTPASS(-1 != volume->SetChannelOutputVolumeScaling(0, (float)-0.1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetChannelOutputVolumeScaling(0, (float)10.1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - ANL(); + TEST(SetChannelOutputVolumeScaling); + ANL(); + TEST_MUSTPASS(-1 != volume->SetChannelOutputVolumeScaling(0, (float)-0.1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetChannelOutputVolumeScaling(0, (float)10.1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + ANL(); #endif // #if !defined(MAC_IPHONE) #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - TEST(SetOutputVolumePan); - ANL(); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)-0.1, - (float)1.0)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)1.1, - (float)1.0)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)1.0, - (float)-0.1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)1.0, - (float)1.1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - ANL(); + TEST(SetOutputVolumePan); + ANL(); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)-0.1, + (float)1.0)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)1.1, + (float)1.0)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)1.0, + (float)-0.1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(-1, (float)1.0, + (float)1.1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + ANL(); - TEST(SetChannelOutputVolumePan); - ANL(); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)-0.1, - (float)1.0)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)1.1, - (float)1.0)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)1.0, - (float)-0.1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)1.0, - (float)1.1)); - MARK(); - TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); - ANL(); + TEST(SetChannelOutputVolumePan); + ANL(); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)-0.1, + (float)1.0)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)1.1, + (float)1.0)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)1.0, + (float)-0.1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + TEST_MUSTPASS(-1 != volume->SetOutputVolumePan(0, (float)1.0, + (float)1.1)); + MARK(); + TEST_MUSTPASS(VE_INVALID_ARGUMENT != base->LastError()); + ANL(); #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) #ifdef _TEST_FILE_ - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); #endif - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - AOK(); - ANL(); - return 0; + AOK(); + ANL(); + return 0; } // ---------------------------------------------------------------------------- // VoEExtendedTest::TestAPM // ---------------------------------------------------------------------------- -int VoEExtendedTest::TestAPM() -{ - PrepareTest("AudioProcessing"); +int VoEExtendedTest::TestAPM() { + PrepareTest("AudioProcessing"); - VoEBase* base = _mgr.BasePtr(); - VoEAudioProcessing* apm = _mgr.APMPtr(); + VoEBase* base = _mgr.BasePtr(); + VoEAudioProcessing* apm = _mgr.APMPtr(); - //#ifdef _USE_EXTENDED_TRACE_ - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("apm_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo)); - //#endif + //#ifdef _USE_EXTENDED_TRACE_ + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("apm_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFilter(kTraceStateInfo | + kTraceStateInfo | + kTraceWarning | + kTraceError | + kTraceCritical | + kTraceApiCall | + kTraceMemory | + kTraceInfo)); + //#endif - TEST_MUSTPASS(base->Init()); - TEST_MUSTPASS(base->CreateChannel()); + TEST_MUSTPASS(base->Init()); + TEST_MUSTPASS(base->CreateChannel()); - /////////////////////////// - // Actual test starts here + /////////////////////////// + // Actual test starts here - int i; - bool enabled; + int i; + bool enabled; - ////// - // EC + ////// + // EC - const int ECSleep = 0; - const int ECIterations = 10; + const int ECSleep = 0; + const int ECIterations = 10; - EcModes ECmode(kEcAec); - AecmModes AECMmode(kAecmSpeakerphone); - bool enabledCNG(false); + EcModes ECmode(kEcAec); + AecmModes AECMmode(kAecmSpeakerphone); + bool enabledCNG(false); #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - const EcModes ECmodeDefault(kEcAecm); + const EcModes ECmodeDefault(kEcAecm); #else - const EcModes ECmodeDefault(kEcAec); + const EcModes ECmodeDefault(kEcAec); #endif - // verify default settings (should be OFF and mode as above) - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(ECmode != ECmodeDefault); + // verify default settings (should be OFF and mode as above) + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(ECmode != ECmodeDefault); - // set EC defaults - TEST_MUSTPASS(apm->SetEcStatus(false, kEcDefault)); - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(ECmode != ECmodeDefault); - SLEEP(ECSleep); + // set EC defaults + TEST_MUSTPASS(apm->SetEcStatus(false, kEcDefault)); + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(ECmode != ECmodeDefault); + SLEEP(ECSleep); #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // set kEcAec mode - TEST_MUSTPASS(apm->SetEcStatus(true, kEcAec)); - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(ECmode != kEcAec); - SLEEP(ECSleep); + // set kEcAec mode + TEST_MUSTPASS(apm->SetEcStatus(true, kEcAec)); + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(ECmode != kEcAec); + SLEEP(ECSleep); - // set kEcConference mode - TEST_MUSTPASS(apm->SetEcStatus(true, kEcConference)); - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(ECmode != kEcAec); - SLEEP(ECSleep); + // set kEcConference mode + TEST_MUSTPASS(apm->SetEcStatus(true, kEcConference)); + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(ECmode != kEcAec); + SLEEP(ECSleep); #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // get default AECM mode, should the kAecmSpeakerphone as default - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_MUSTPASS(AECMmode != kAecmSpeakerphone); - TEST_MUSTPASS(enabledCNG != true); - TEST_MUSTPASS(apm->SetAecmMode(kAecmQuietEarpieceOrHeadset, false)); - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, - enabledCNG); - TEST_MUSTPASS(AECMmode != kAecmQuietEarpieceOrHeadset); - TEST_MUSTPASS(enabledCNG != false); + // get default AECM mode, should the kAecmSpeakerphone as default + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_MUSTPASS(AECMmode != kAecmSpeakerphone); + TEST_MUSTPASS(enabledCNG != true); + TEST_MUSTPASS(apm->SetAecmMode(kAecmQuietEarpieceOrHeadset, false)); + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, + enabledCNG); + TEST_MUSTPASS(AECMmode != kAecmQuietEarpieceOrHeadset); + TEST_MUSTPASS(enabledCNG != false); - // set kEcAecm mode - TEST_MUSTPASS(apm->SetEcStatus(true, kEcAecm)); - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != true); - TEST_MUSTPASS(ECmode != kEcAecm); - SLEEP(ECSleep); + // set kEcAecm mode + TEST_MUSTPASS(apm->SetEcStatus(true, kEcAecm)); + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != true); + TEST_MUSTPASS(ECmode != kEcAecm); + SLEEP(ECSleep); - // AECM mode, get and set - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_MUSTPASS(AECMmode != kAecmQuietEarpieceOrHeadset); - TEST_MUSTPASS(enabledCNG != false); - TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, true)); - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, - enabledCNG); - TEST_MUSTPASS(AECMmode != kAecmEarpiece); - TEST_MUSTPASS(enabledCNG != true); - TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, false)); - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, - enabledCNG); - TEST_MUSTPASS(AECMmode != kAecmEarpiece); - TEST_MUSTPASS(enabledCNG != false); - TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudEarpiece, true)); - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, - enabledCNG); - TEST_MUSTPASS(AECMmode != kAecmLoudEarpiece); - TEST_MUSTPASS(enabledCNG != true); - TEST_MUSTPASS(apm->SetAecmMode(kAecmSpeakerphone, false)); - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, - enabledCNG); - TEST_MUSTPASS(AECMmode != kAecmSpeakerphone); - TEST_MUSTPASS(enabledCNG != false); - TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudSpeakerphone, true)); - TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); - TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, - enabledCNG); - TEST_MUSTPASS(AECMmode != kAecmLoudSpeakerphone); - TEST_MUSTPASS(enabledCNG != true); + // AECM mode, get and set + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_MUSTPASS(AECMmode != kAecmQuietEarpieceOrHeadset); + TEST_MUSTPASS(enabledCNG != false); + TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, true)); + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, + enabledCNG); + TEST_MUSTPASS(AECMmode != kAecmEarpiece); + TEST_MUSTPASS(enabledCNG != true); + TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, false)); + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, + enabledCNG); + TEST_MUSTPASS(AECMmode != kAecmEarpiece); + TEST_MUSTPASS(enabledCNG != false); + TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudEarpiece, true)); + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, + enabledCNG); + TEST_MUSTPASS(AECMmode != kAecmLoudEarpiece); + TEST_MUSTPASS(enabledCNG != true); + TEST_MUSTPASS(apm->SetAecmMode(kAecmSpeakerphone, false)); + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, + enabledCNG); + TEST_MUSTPASS(AECMmode != kAecmSpeakerphone); + TEST_MUSTPASS(enabledCNG != false); + TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudSpeakerphone, true)); + TEST_MUSTPASS(apm->GetAecmMode(AECMmode, enabledCNG)); + TEST_LOG("AECM: mode=%d, CNG: mode=%d\n", AECMmode, + enabledCNG); + TEST_MUSTPASS(AECMmode != kAecmLoudSpeakerphone); + TEST_MUSTPASS(enabledCNG != true); - // verify that all modes are maintained when EC is disabled + // verify that all modes are maintained when EC is disabled + TEST_MUSTPASS(apm->SetEcStatus(false)); + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(ECmode != kEcAecm); + SLEEP(ECSleep); + + // restore defaults + TEST_MUSTPASS(apm->SetEcStatus(true, kEcDefault)); + TEST_MUSTPASS(apm->SetEcStatus(false, kEcUnchanged)); + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(ECmode != ECmodeDefault); + SLEEP(ECSleep); + + // enable/disable many times in a row + for (i = 0; i < ECIterations; i++) { + TEST_MUSTPASS(apm->SetEcStatus(true)); TEST_MUSTPASS(apm->SetEcStatus(false)); - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(ECmode != kEcAecm); - SLEEP(ECSleep); + } + TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(ECmode != ECmodeDefault); + SLEEP(ECSleep); - // restore defaults - TEST_MUSTPASS(apm->SetEcStatus(true, kEcDefault)); - TEST_MUSTPASS(apm->SetEcStatus(false, kEcUnchanged)); - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(ECmode != ECmodeDefault); - SLEEP(ECSleep); + /////// + // AGC - // enable/disable many times in a row - for (i = 0; i < ECIterations; i++) - { - TEST_MUSTPASS(apm->SetEcStatus(true)); - TEST_MUSTPASS(apm->SetEcStatus(false)); - } - TEST_MUSTPASS(apm->GetEcStatus(enabled, ECmode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", enabled, ECmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(ECmode != ECmodeDefault); - SLEEP(ECSleep); + const int AGCSleep = 0; + const int AGCIterations = 10; - /////// - // AGC - - const int AGCSleep = 0; - const int AGCIterations = 10; - - AgcModes AGCmode(kAgcAdaptiveAnalog); + AgcModes AGCmode(kAgcAdaptiveAnalog); #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - bool enabledDefault = false; - AgcModes AGCmodeDefault(kAgcAdaptiveDigital); + bool enabledDefault = false; + AgcModes AGCmodeDefault(kAgcAdaptiveDigital); #else - bool enabledDefault = true; - AgcModes AGCmodeDefault(kAgcAdaptiveAnalog); + bool enabledDefault = true; + AgcModes AGCmodeDefault(kAgcAdaptiveAnalog); #endif - // verify default settings (should be as above) - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(enabled != enabledDefault); - TEST_MUSTPASS(AGCmode != AGCmodeDefault); + // verify default settings (should be as above) + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(enabled != enabledDefault); + TEST_MUSTPASS(AGCmode != AGCmodeDefault); - // set default AGC mode - TEST_MUSTPASS(apm->SetAgcStatus(false, kAgcDefault)); - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(AGCmode != AGCmodeDefault); - SLEEP(AGCSleep); + // set default AGC mode + TEST_MUSTPASS(apm->SetAgcStatus(false, kAgcDefault)); + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(AGCmode != AGCmodeDefault); + SLEEP(AGCSleep); - // set kAgcFixedDigital mode - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcFixedDigital)); - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(AGCmode != kAgcFixedDigital); - SLEEP(AGCSleep); + // set kAgcFixedDigital mode + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcFixedDigital)); + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(AGCmode != kAgcFixedDigital); + SLEEP(AGCSleep); #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // set kAgcAdaptiveAnalog mode - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(AGCmode != kAgcAdaptiveAnalog); - SLEEP(AGCSleep); + // set kAgcAdaptiveAnalog mode + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(AGCmode != kAgcAdaptiveAnalog); + SLEEP(AGCSleep); #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // set kAgcAdaptiveDigital mode - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(AGCmode != kAgcAdaptiveDigital); - SLEEP(AGCSleep); + // set kAgcAdaptiveDigital mode + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(AGCmode != kAgcAdaptiveDigital); + SLEEP(AGCSleep); - // verify that mode is maintained when AGC is disabled + // verify that mode is maintained when AGC is disabled + TEST_MUSTPASS(apm->SetAgcStatus(false)); + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(AGCmode != kAgcAdaptiveDigital); + SLEEP(AGCSleep); + + // restore default AGC + TEST_MUSTPASS(apm->SetAgcStatus(enabledDefault, kAgcDefault)); + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(enabled != enabledDefault); + TEST_MUSTPASS(AGCmode != AGCmodeDefault); + SLEEP(AGCSleep); + + // enable/disable many times in a row + for (i = 0; i < AGCIterations; i++) + { + TEST_MUSTPASS(apm->SetAgcStatus(true)); TEST_MUSTPASS(apm->SetAgcStatus(false)); - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(AGCmode != kAgcAdaptiveDigital); - SLEEP(AGCSleep); + } + TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); + TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(AGCmode != AGCmodeDefault); - // restore default AGC - TEST_MUSTPASS(apm->SetAgcStatus(enabledDefault, kAgcDefault)); - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(enabled != enabledDefault); - TEST_MUSTPASS(AGCmode != AGCmodeDefault); - SLEEP(AGCSleep); + // --- Set/AGCConfig -- - // enable/disable many times in a row - for (i = 0; i < AGCIterations; i++) - { - TEST_MUSTPASS(apm->SetAgcStatus(true)); - TEST_MUSTPASS(apm->SetAgcStatus(false)); - } - TEST_MUSTPASS(apm->GetAgcStatus(enabled, AGCmode)); - TEST_LOG("AGC: enabled=%d, AGCmode=%d\n", enabled, AGCmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(AGCmode != AGCmodeDefault); + // + // targetLeveldBOv : [0, 31] (default 3) + // digitalCompressionGaindB: [0, 90] (default 9) + // limiterEnable : 0: Off, 1: On (default) - // --- Set/AGCConfig -- + AgcConfig agcConfig; + AgcConfig agcConfigDefault; - // - // targetLeveldBOv : [0, 31] (default 3) - // digitalCompressionGaindB: [0, 90] (default 9) - // limiterEnable : 0: Off, 1: On (default) + const unsigned short targetLeveldBOvDefault = 3; + const unsigned short digitalCompressionGaindBDefault = 9; + const bool limiterEnableDefault = true; - AgcConfig agcConfig; - AgcConfig agcConfigDefault; + const unsigned short targetLeveldBOvMax = 31; + const unsigned short digitalCompressionGaindBMax = 90; - const unsigned short targetLeveldBOvDefault = 3; - const unsigned short digitalCompressionGaindBDefault = 9; - const bool limiterEnableDefault = true; + // verify default configuration + TEST_MUSTPASS(apm->GetAgcConfig(agcConfigDefault)); + TEST_LOG("AGC: targetLeveldBOv=%d, digitalCompressionGaindB=%d, " + "limiterEnable=%d\n", + agcConfigDefault.targetLeveldBOv, + agcConfigDefault.digitalCompressionGaindB, + agcConfigDefault.limiterEnable); + TEST_MUSTPASS(agcConfigDefault.targetLeveldBOv != targetLeveldBOvDefault); + TEST_MUSTPASS(agcConfigDefault.digitalCompressionGaindB != + digitalCompressionGaindBDefault); + TEST_MUSTPASS(agcConfigDefault.limiterEnable != limiterEnableDefault); - const unsigned short targetLeveldBOvMax = 31; - const unsigned short digitalCompressionGaindBMax = 90; + // verify that invalid (out-of-range) parameters are detected + agcConfig = agcConfigDefault; + agcConfig.targetLeveldBOv = targetLeveldBOvMax + 1; + TEST_MUSTPASS(!apm->SetAgcConfig(agcConfig)); + int err = base->LastError(); + TEST_MUSTPASS(err != VE_APM_ERROR); + agcConfig = agcConfigDefault; + agcConfig.digitalCompressionGaindB + = digitalCompressionGaindBMax + 1; + TEST_MUSTPASS(!apm->SetAgcConfig(agcConfig)); - // verify default configuration - TEST_MUSTPASS(apm->GetAgcConfig(agcConfigDefault)); - TEST_LOG("AGC: targetLeveldBOv=%d, digitalCompressionGaindB=%d, " - "limiterEnable=%d\n", - agcConfigDefault.targetLeveldBOv, - agcConfigDefault.digitalCompressionGaindB, - agcConfigDefault.limiterEnable); - TEST_MUSTPASS(agcConfigDefault.targetLeveldBOv != targetLeveldBOvDefault); - TEST_MUSTPASS(agcConfigDefault.digitalCompressionGaindB != - digitalCompressionGaindBDefault); - TEST_MUSTPASS(agcConfigDefault.limiterEnable != limiterEnableDefault); + AgcConfig agcConfigSet; + agcConfigSet.digitalCompressionGaindB = 17; + agcConfigSet.targetLeveldBOv = 11; + agcConfigSet.limiterEnable = false; - // verify that invalid (out-of-range) parameters are detected - agcConfig = agcConfigDefault; - agcConfig.targetLeveldBOv = targetLeveldBOvMax + 1; - TEST_MUSTPASS(!apm->SetAgcConfig(agcConfig)); - int err = base->LastError(); - TEST_MUSTPASS(err != VE_APM_ERROR); - agcConfig = agcConfigDefault; - agcConfig.digitalCompressionGaindB - = digitalCompressionGaindBMax + 1; - TEST_MUSTPASS(!apm->SetAgcConfig(agcConfig)); + // try some set/get operations using valid settings + TEST_MUSTPASS(apm->SetAgcConfig(agcConfigDefault)); + TEST_MUSTPASS(apm->GetAgcConfig(agcConfig)); + TEST_MUSTPASS(agcConfig.targetLeveldBOv != targetLeveldBOvDefault); + TEST_MUSTPASS(agcConfig.digitalCompressionGaindB != + digitalCompressionGaindBDefault); + TEST_MUSTPASS(agcConfig.limiterEnable != limiterEnableDefault); - AgcConfig agcConfigSet; - agcConfigSet.digitalCompressionGaindB = 17; - agcConfigSet.targetLeveldBOv = 11; - agcConfigSet.limiterEnable = false; + TEST_MUSTPASS(apm->SetAgcConfig(agcConfigSet)); + TEST_MUSTPASS(apm->GetAgcConfig(agcConfig)); + TEST_MUSTPASS(agcConfig.targetLeveldBOv != agcConfigSet.targetLeveldBOv); + TEST_MUSTPASS(agcConfig.digitalCompressionGaindB != + agcConfigSet.digitalCompressionGaindB); + TEST_MUSTPASS(agcConfig.limiterEnable != agcConfigSet.limiterEnable); - // try some set/get operations using valid settings - TEST_MUSTPASS(apm->SetAgcConfig(agcConfigDefault)); - TEST_MUSTPASS(apm->GetAgcConfig(agcConfig)); - TEST_MUSTPASS(agcConfig.targetLeveldBOv != targetLeveldBOvDefault); - TEST_MUSTPASS(agcConfig.digitalCompressionGaindB != -digitalCompressionGaindBDefault); - TEST_MUSTPASS(agcConfig.limiterEnable != limiterEnableDefault); + // restore default AGC config + TEST_MUSTPASS(apm->SetAgcConfig(agcConfigDefault)); + SLEEP(AGCSleep); - TEST_MUSTPASS(apm->SetAgcConfig(agcConfigSet)); - TEST_MUSTPASS(apm->GetAgcConfig(agcConfig)); - TEST_MUSTPASS(agcConfig.targetLeveldBOv != agcConfigSet.targetLeveldBOv); - TEST_MUSTPASS(agcConfig.digitalCompressionGaindB != - agcConfigSet.digitalCompressionGaindB); - TEST_MUSTPASS(agcConfig.limiterEnable != agcConfigSet.limiterEnable); + ////// + // NS - // restore default AGC config - TEST_MUSTPASS(apm->SetAgcConfig(agcConfigDefault)); - SLEEP(AGCSleep); + const int NSSleep = 0; + const int NSIterations = 10; - ////// - // NS + NsModes NSmode(kNsHighSuppression); + NsModes NSmodeDefault(kNsModerateSuppression); - const int NSSleep = 0; - const int NSIterations = 10; + // verify default settings (should be OFF and mode as above) + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(NSmode != NSmodeDefault); - NsModes NSmode(kNsHighSuppression); - NsModes NSmodeDefault(kNsModerateSuppression); + // enable default NS settings + // must set a value first time! + TEST_MUSTPASS(apm->SetNsStatus(false, kNsDefault)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(NSmode != NSmodeDefault); + SLEEP(NSSleep); - // verify default settings (should be OFF and mode as above) - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(NSmode != NSmodeDefault); + // set kNsLowSuppression mode + TEST_MUSTPASS(apm->SetNsStatus(true, kNsLowSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(NSmode != kNsLowSuppression); + SLEEP(NSSleep); - // enable default NS settings - // must set a value first time! - TEST_MUSTPASS(apm->SetNsStatus(false, kNsDefault)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(NSmode != NSmodeDefault); - SLEEP(NSSleep); + // set kNsModerateSuppression mode + TEST_MUSTPASS(apm->SetNsStatus(true, kNsModerateSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(NSmode != kNsModerateSuppression); + SLEEP(NSSleep); - // set kNsLowSuppression mode - TEST_MUSTPASS(apm->SetNsStatus(true, kNsLowSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(NSmode != kNsLowSuppression); - SLEEP(NSSleep); + // set kNsHighSuppression mode + TEST_MUSTPASS(apm->SetNsStatus(true, kNsHighSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(NSmode != kNsHighSuppression); + SLEEP(NSSleep); - // set kNsModerateSuppression mode - TEST_MUSTPASS(apm->SetNsStatus(true, kNsModerateSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(NSmode != kNsModerateSuppression); - SLEEP(NSSleep); + // set kNsVeryHighSuppression mode + TEST_MUSTPASS(apm->SetNsStatus(true, kNsVeryHighSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(NSmode != kNsVeryHighSuppression); + SLEEP(NSSleep); - // set kNsHighSuppression mode - TEST_MUSTPASS(apm->SetNsStatus(true, kNsHighSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(NSmode != kNsHighSuppression); - SLEEP(NSSleep); + // set kNsVeryHighSuppression mode + TEST_MUSTPASS(apm->SetNsStatus(true, kNsConference)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(NSmode != kNsHighSuppression); + SLEEP(NSSleep); - // set kNsVeryHighSuppression mode - TEST_MUSTPASS(apm->SetNsStatus(true, kNsVeryHighSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(NSmode != kNsVeryHighSuppression); - SLEEP(NSSleep); + // verify that mode is maintained when NS is disabled + TEST_MUSTPASS(apm->SetNsStatus(false)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(NSmode != kNsHighSuppression); + SLEEP(NSSleep); - // set kNsVeryHighSuppression mode - TEST_MUSTPASS(apm->SetNsStatus(true, kNsConference)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(NSmode != kNsHighSuppression); - SLEEP(NSSleep); + // restore default NS + TEST_MUSTPASS(apm->SetNsStatus(true, kNsDefault)); + TEST_MUSTPASS(apm->SetNsStatus(false)); + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(NSmode != NSmodeDefault); + SLEEP(NSSleep); - // verify that mode is maintained when NS is disabled + // enable/disable many times in a row + for (i = 0; i < NSIterations; i++) { + TEST_MUSTPASS(apm->SetNsStatus(true)); TEST_MUSTPASS(apm->SetNsStatus(false)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(NSmode != kNsHighSuppression); - SLEEP(NSSleep); + } + TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); + TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(NSmode != NSmodeDefault); + SLEEP(NSSleep); - // restore default NS - TEST_MUSTPASS(apm->SetNsStatus(true, kNsDefault)); - TEST_MUSTPASS(apm->SetNsStatus(false)); - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(NSmode != NSmodeDefault); - SLEEP(NSSleep); - - // enable/disable many times in a row - for (i = 0; i < NSIterations; i++) - { - TEST_MUSTPASS(apm->SetNsStatus(true)); - TEST_MUSTPASS(apm->SetNsStatus(false)); - } - TEST_MUSTPASS(apm->GetNsStatus(enabled, NSmode)); - TEST_LOG("NS: enabled=%d, NSmode=%d\n", enabled, NSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(NSmode != NSmodeDefault); - SLEEP(NSSleep); - - ////////////////////////////////// - // Ec Metrics + ////////////////////////////////// + // Ec Metrics #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - TEST(GetEcMetricsStatus); - ANL(); - TEST(SetEcMetricsStatus); - ANL(); - TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); - MARK(); - TEST_MUSTPASS(enabled != false); - MARK(); // should be OFF by default - TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); - MARK(); - TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); - MARK(); - TEST_MUSTPASS(enabled != true); - MARK(); - TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); - MARK(); - TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); - MARK(); - TEST_MUSTPASS(enabled != false); - MARK(); - AOK(); - ANL(); + TEST(GetEcMetricsStatus); + ANL(); + TEST(SetEcMetricsStatus); + ANL(); + TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); + MARK(); + TEST_MUSTPASS(enabled != false); + MARK(); // should be OFF by default + TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); + MARK(); + TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); + MARK(); + TEST_MUSTPASS(enabled != true); + MARK(); + TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); + MARK(); + TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); + MARK(); + TEST_MUSTPASS(enabled != false); + MARK(); + AOK(); + ANL(); - TEST(GetEchoMetrics); - ANL(); + TEST(GetEchoMetrics); + ANL(); - int ERL, ERLE, RERL, A_NLP; - TEST_MUSTPASS(-1 != apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); - MARK(); // Should fail since not activated. - err = base->LastError(); - TEST_MUSTPASS(err != VE_APM_ERROR); - TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); - TEST_MUSTPASS(-1 != apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); - MARK(); // Should fail since AEC is off. - err = base->LastError(); - TEST_MUSTPASS(err != VE_APM_ERROR); - TEST_MUSTPASS(apm->SetEcStatus(true)); - TEST_MUSTPASS(apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); - MARK(); // Should work now. - TEST_LOG("\nEcho: ERL=%d, ERLE=%d, RERL=%d, A_NLP=%d [dB]\n", - ERL, ERLE, RERL, A_NLP); - TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); - TEST_MUSTPASS(apm->SetEcStatus(false)); - AOK(); - ANL(); + int ERL, ERLE, RERL, A_NLP; + TEST_MUSTPASS(-1 != apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); + MARK(); // Should fail since not activated. + err = base->LastError(); + TEST_MUSTPASS(err != VE_APM_ERROR); + TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); + TEST_MUSTPASS(-1 != apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); + MARK(); // Should fail since AEC is off. + err = base->LastError(); + TEST_MUSTPASS(err != VE_APM_ERROR); + TEST_MUSTPASS(apm->SetEcStatus(true)); + TEST_MUSTPASS(apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); + MARK(); // Should work now. + TEST_LOG("\nEcho: ERL=%d, ERLE=%d, RERL=%d, A_NLP=%d [dB]\n", + ERL, ERLE, RERL, A_NLP); + TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); + TEST_MUSTPASS(apm->SetEcStatus(false)); + AOK(); + ANL(); - TEST(GetEcDelayMetrics); - ANL(); + TEST(GetEcDelayMetrics); + ANL(); - int delay_median = 0; - int delay_std = 0; - TEST_MUSTPASS(-1 != apm->GetEcDelayMetrics(delay_median, delay_std)); - MARK(); // Should fail since not activated. - err = base->LastError(); - TEST_MUSTPASS(err != VE_APM_ERROR); - TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); - TEST_MUSTPASS(-1 != apm->GetEcDelayMetrics(delay_median, delay_std)); - MARK(); // Should fail since AEC is off. - err = base->LastError(); - TEST_MUSTPASS(err != VE_APM_ERROR); - TEST_MUSTPASS(apm->SetEcStatus(true)); - TEST_MUSTPASS(apm->GetEcDelayMetrics(delay_median, delay_std)); - MARK(); // Should work now. - TEST_LOG("\nEC Delay: median=%d, std=%d [ms]\n", delay_median, delay_std); - TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); - TEST_MUSTPASS(apm->SetEcStatus(false)); - AOK(); - ANL(); + int delay_median = 0; + int delay_std = 0; + TEST_MUSTPASS(-1 != apm->GetEcDelayMetrics(delay_median, delay_std)); + MARK(); // Should fail since not activated. + err = base->LastError(); + TEST_MUSTPASS(err != VE_APM_ERROR); + TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); + TEST_MUSTPASS(-1 != apm->GetEcDelayMetrics(delay_median, delay_std)); + MARK(); // Should fail since AEC is off. + err = base->LastError(); + TEST_MUSTPASS(err != VE_APM_ERROR); + TEST_MUSTPASS(apm->SetEcStatus(true)); + TEST_MUSTPASS(apm->GetEcDelayMetrics(delay_median, delay_std)); + MARK(); // Should work now. + TEST_LOG("\nEC Delay: median=%d, std=%d [ms]\n", delay_median, delay_std); + TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); + TEST_MUSTPASS(apm->SetEcStatus(false)); + AOK(); + ANL(); #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // far-end AudioProcessing - /////// - // AGC + // far-end AudioProcessing + /////// + // AGC - AgcModes rxAGCmode(kAgcAdaptiveDigital); - AgcModes rxAGCmodeDefault(kAgcAdaptiveDigital); - bool rxEnabledDefault = false; + AgcModes rxAGCmode(kAgcAdaptiveDigital); + AgcModes rxAGCmodeDefault(kAgcAdaptiveDigital); + bool rxEnabledDefault = false; - // verify default settings (should be as above) - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(enabled != rxEnabledDefault); - TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); + // verify default settings (should be as above) + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(enabled != rxEnabledDefault); + TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); - // set default AGC mode - TEST_MUSTPASS(apm->SetRxAgcStatus(0, false, kAgcDefault)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); - SLEEP(AGCSleep); + // set default AGC mode + TEST_MUSTPASS(apm->SetRxAgcStatus(0, false, kAgcDefault)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); + SLEEP(AGCSleep); - // set kAgcAdaptiveAnalog mode, should fail - TEST_MUSTPASS(!apm->SetRxAgcStatus(0, true, kAgcAdaptiveAnalog)); + // set kAgcAdaptiveAnalog mode, should fail + TEST_MUSTPASS(!apm->SetRxAgcStatus(0, true, kAgcAdaptiveAnalog)); - // set kAgcFixedDigital mode - TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcFixedDigital)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(rxAGCmode != kAgcFixedDigital); - SLEEP(AGCSleep); + // set kAgcFixedDigital mode + TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcFixedDigital)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(rxAGCmode != kAgcFixedDigital); + SLEEP(AGCSleep); - // set kAgcAdaptiveDigital mode - TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcAdaptiveDigital)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(rxAGCmode != kAgcAdaptiveDigital); - SLEEP(AGCSleep); + // set kAgcAdaptiveDigital mode + TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcAdaptiveDigital)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(rxAGCmode != kAgcAdaptiveDigital); + SLEEP(AGCSleep); - // verify that mode is maintained when AGC is disabled + // verify that mode is maintained when AGC is disabled + TEST_MUSTPASS(apm->SetRxAgcStatus(0, false)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxAGCmode != kAgcAdaptiveDigital); + SLEEP(AGCSleep); + + // restore default AGC + TEST_MUSTPASS(apm->SetRxAgcStatus(0, enabledDefault, kAgcDefault)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(enabled != enabledDefault); + TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); + SLEEP(AGCSleep); + + // enable/disable many times in a row + for (i = 0; i < AGCIterations; i++) { + TEST_MUSTPASS(apm->SetRxAgcStatus(0, true)); TEST_MUSTPASS(apm->SetRxAgcStatus(0, false)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxAGCmode != kAgcAdaptiveDigital); - SLEEP(AGCSleep); + } + TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); + TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, + rxAGCmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); - // restore default AGC - TEST_MUSTPASS(apm->SetRxAgcStatus(0, enabledDefault, kAgcDefault)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(enabled != enabledDefault); - TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); - SLEEP(AGCSleep); - - // enable/disable many times in a row - for (i = 0; i < AGCIterations; i++) - { - TEST_MUSTPASS(apm->SetRxAgcStatus(0, true)); - TEST_MUSTPASS(apm->SetRxAgcStatus(0, false)); - } - TEST_MUSTPASS(apm->GetRxAgcStatus(0, enabled, rxAGCmode)); - TEST_LOG("rxAGC: enabled=%d, AGCmode=%d\n", enabled, - rxAGCmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxAGCmode != rxAGCmodeDefault); - - // --- Set/GetAgcConfig -- + // --- Set/GetAgcConfig -- - // targetLeveldBOv : [0, 31] (default 3) - // digitalCompressionGaindB: [0, 90] (default 9) - // limiterEnable : 0: Off, 1: On (default) + // targetLeveldBOv : [0, 31] (default 3) + // digitalCompressionGaindB: [0, 90] (default 9) + // limiterEnable : 0: Off, 1: On (default) - AgcConfig rxAGCConfig; - AgcConfig rxAGCConfigDefault; + AgcConfig rxAGCConfig; + AgcConfig rxAGCConfigDefault; - const unsigned short rxTargetLeveldBOvDefault = 3; - const unsigned short rxDigitalCompressionGaindBDefault = 9; - const bool rxLimiterEnableDefault = true; + const unsigned short rxTargetLeveldBOvDefault = 3; + const unsigned short rxDigitalCompressionGaindBDefault = 9; + const bool rxLimiterEnableDefault = true; - const unsigned short rxTargetLeveldBOvMax = 31; - const unsigned short rxDigitalCompressionGaindBMax = 90; + const unsigned short rxTargetLeveldBOvMax = 31; + const unsigned short rxDigitalCompressionGaindBMax = 90; - // verify default configuration - TEST_MUSTPASS(apm->GetRxAgcConfig(0, rxAGCConfigDefault)); - TEST_LOG( - "rxAGC: targetLeveldBOv=%u, digitalCompressionGaindB=%u, " - "limiterEnable=%d\n", - rxAGCConfigDefault.targetLeveldBOv, - rxAGCConfigDefault.digitalCompressionGaindB, - rxAGCConfigDefault.limiterEnable); - TEST_MUSTPASS(rxAGCConfigDefault.targetLeveldBOv != - rxTargetLeveldBOvDefault); - TEST_MUSTPASS(rxAGCConfigDefault.digitalCompressionGaindB != - rxDigitalCompressionGaindBDefault); - TEST_MUSTPASS(rxAGCConfigDefault.limiterEnable != rxLimiterEnableDefault); + // verify default configuration + TEST_MUSTPASS(apm->GetRxAgcConfig(0, rxAGCConfigDefault)); + TEST_LOG( + "rxAGC: targetLeveldBOv=%u, digitalCompressionGaindB=%u, " + "limiterEnable=%d\n", + rxAGCConfigDefault.targetLeveldBOv, + rxAGCConfigDefault.digitalCompressionGaindB, + rxAGCConfigDefault.limiterEnable); + TEST_MUSTPASS(rxAGCConfigDefault.targetLeveldBOv != + rxTargetLeveldBOvDefault); + TEST_MUSTPASS(rxAGCConfigDefault.digitalCompressionGaindB != + rxDigitalCompressionGaindBDefault); + TEST_MUSTPASS(rxAGCConfigDefault.limiterEnable != rxLimiterEnableDefault); - // verify that invalid (out-of-range) parameters are detected - rxAGCConfig = rxAGCConfigDefault; - rxAGCConfig.targetLeveldBOv = rxTargetLeveldBOvMax + 1; - TEST_MUSTPASS(!apm->SetRxAgcConfig(0, rxAGCConfig)); - int rxErr = base->LastError(); - TEST_MUSTPASS(rxErr != VE_APM_ERROR); - rxAGCConfig = rxAGCConfigDefault; - rxAGCConfig.digitalCompressionGaindB - = rxDigitalCompressionGaindBMax + 1; - TEST_MUSTPASS(!apm->SetRxAgcConfig(0, rxAGCConfig)); + // verify that invalid (out-of-range) parameters are detected + rxAGCConfig = rxAGCConfigDefault; + rxAGCConfig.targetLeveldBOv = rxTargetLeveldBOvMax + 1; + TEST_MUSTPASS(!apm->SetRxAgcConfig(0, rxAGCConfig)); + int rxErr = base->LastError(); + TEST_MUSTPASS(rxErr != VE_APM_ERROR); + rxAGCConfig = rxAGCConfigDefault; + rxAGCConfig.digitalCompressionGaindB + = rxDigitalCompressionGaindBMax + 1; + TEST_MUSTPASS(!apm->SetRxAgcConfig(0, rxAGCConfig)); - AgcConfig rxAGCConfigSet; - rxAGCConfigSet.digitalCompressionGaindB = 17; - rxAGCConfigSet.targetLeveldBOv = 11; - rxAGCConfigSet.limiterEnable = false; + AgcConfig rxAGCConfigSet; + rxAGCConfigSet.digitalCompressionGaindB = 17; + rxAGCConfigSet.targetLeveldBOv = 11; + rxAGCConfigSet.limiterEnable = false; - // try some set/get operations using valid settings - TEST_MUSTPASS(apm->SetRxAgcConfig(0, rxAGCConfigDefault)); - TEST_MUSTPASS(apm->GetRxAgcConfig(0, rxAGCConfig)); - TEST_MUSTPASS(rxAGCConfig.targetLeveldBOv != rxTargetLeveldBOvDefault); - TEST_MUSTPASS(rxAGCConfig.digitalCompressionGaindB != - rxDigitalCompressionGaindBDefault); - TEST_MUSTPASS(rxAGCConfig.limiterEnable != rxLimiterEnableDefault); + // try some set/get operations using valid settings + TEST_MUSTPASS(apm->SetRxAgcConfig(0, rxAGCConfigDefault)); + TEST_MUSTPASS(apm->GetRxAgcConfig(0, rxAGCConfig)); + TEST_MUSTPASS(rxAGCConfig.targetLeveldBOv != rxTargetLeveldBOvDefault); + TEST_MUSTPASS(rxAGCConfig.digitalCompressionGaindB != + rxDigitalCompressionGaindBDefault); + TEST_MUSTPASS(rxAGCConfig.limiterEnable != rxLimiterEnableDefault); - TEST_MUSTPASS(apm->SetRxAgcConfig(0, rxAGCConfigSet)); - TEST_MUSTPASS(apm->GetRxAgcConfig(0, rxAGCConfig)); - TEST_MUSTPASS(rxAGCConfig.targetLeveldBOv != - rxAGCConfigSet.targetLeveldBOv); - TEST_MUSTPASS(rxAGCConfig.digitalCompressionGaindB != - rxAGCConfigSet.digitalCompressionGaindB); - TEST_MUSTPASS(rxAGCConfig.limiterEnable != rxAGCConfigSet.limiterEnable); + TEST_MUSTPASS(apm->SetRxAgcConfig(0, rxAGCConfigSet)); + TEST_MUSTPASS(apm->GetRxAgcConfig(0, rxAGCConfig)); + TEST_MUSTPASS(rxAGCConfig.targetLeveldBOv != + rxAGCConfigSet.targetLeveldBOv); + TEST_MUSTPASS(rxAGCConfig.digitalCompressionGaindB != + rxAGCConfigSet.digitalCompressionGaindB); + TEST_MUSTPASS(rxAGCConfig.limiterEnable != rxAGCConfigSet.limiterEnable); - // restore default AGC config - TEST_MUSTPASS(apm->SetRxAgcConfig(0, rxAGCConfigDefault)); - SLEEP(AGCSleep); + // restore default AGC config + TEST_MUSTPASS(apm->SetRxAgcConfig(0, rxAGCConfigDefault)); + SLEEP(AGCSleep); - ////// - // NS + ////// + // NS - NsModes rxNSmode(kNsHighSuppression); - NsModes rxNSmodeDefault(kNsModerateSuppression); + NsModes rxNSmode(kNsHighSuppression); + NsModes rxNSmodeDefault(kNsModerateSuppression); - // verify default settings (should be OFF and mode as above) - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxNSmode != rxNSmodeDefault); + // verify default settings (should be OFF and mode as above) + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxNSmode != rxNSmodeDefault); - // enable default NS settings - // must set a value first time! - TEST_MUSTPASS(apm->SetRxNsStatus(0, false, kNsDefault)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxNSmode != rxNSmodeDefault); - SLEEP(NSSleep); + // enable default NS settings + // must set a value first time! + TEST_MUSTPASS(apm->SetRxNsStatus(0, false, kNsDefault)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxNSmode != rxNSmodeDefault); + SLEEP(NSSleep); - // set kNsLowSuppression mode - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsLowSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(rxNSmode != kNsLowSuppression); - SLEEP(NSSleep); + // set kNsLowSuppression mode + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsLowSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(rxNSmode != kNsLowSuppression); + SLEEP(NSSleep); - // set kNsModerateSuppression mode - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsModerateSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(rxNSmode != kNsModerateSuppression); - SLEEP(NSSleep); + // set kNsModerateSuppression mode + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsModerateSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(rxNSmode != kNsModerateSuppression); + SLEEP(NSSleep); - // set kNsHighSuppression mode - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsHighSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(rxNSmode != kNsHighSuppression); - SLEEP(NSSleep); + // set kNsHighSuppression mode + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsHighSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(rxNSmode != kNsHighSuppression); + SLEEP(NSSleep); - // set kNsVeryHighSuppression mode - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsVeryHighSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(rxNSmode != kNsVeryHighSuppression); - SLEEP(NSSleep); + // set kNsVeryHighSuppression mode + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsVeryHighSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(rxNSmode != kNsVeryHighSuppression); + SLEEP(NSSleep); - // set kNsVeryHighSuppression mode - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsConference)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(rxNSmode != kNsHighSuppression); - SLEEP(NSSleep); + // set kNsVeryHighSuppression mode + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsConference)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(rxNSmode != kNsHighSuppression); + SLEEP(NSSleep); - // verify that mode is maintained when NS is disabled + // verify that mode is maintained when NS is disabled + TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxNSmode != kNsHighSuppression); + SLEEP(NSSleep); + + // restore default NS + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsDefault)); + TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxNSmode != NSmodeDefault); + SLEEP(NSSleep); + + // enable/disable many times in a row + for (i = 0; i < NSIterations; i++) + { + TEST_MUSTPASS(apm->SetRxNsStatus(0, true)); TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxNSmode != kNsHighSuppression); - SLEEP(NSSleep); + } + TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); + TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(rxNSmode != NSmodeDefault); + SLEEP(NSSleep); - // restore default NS - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsDefault)); - TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxNSmode != NSmodeDefault); - SLEEP(NSSleep); + ///////////////////////////// + // StartDebugRecording + //////////////////////////// + // StopDebugRecording + TEST_LOG("StartDebugRecording"); + TEST_MUSTPASS(apm->StartDebugRecording(GetFilename("apm_debug.txt"))); + SLEEP(1000); + TEST_LOG("StopDebugRecording"); + TEST_MUSTPASS(apm->StopDebugRecording()); - // enable/disable many times in a row - for (i = 0; i < NSIterations; i++) - { - TEST_MUSTPASS(apm->SetRxNsStatus(0, true)); - TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); - } - TEST_MUSTPASS(apm->GetRxNsStatus(0, enabled, rxNSmode)); - TEST_LOG("rxNS: enabled=%d, NSmode=%d\n", enabled, rxNSmode); - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(rxNSmode != NSmodeDefault); - SLEEP(NSSleep); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - ///////////////////////////// - // StartDebugRecording - //////////////////////////// - // StopDebugRecording - TEST_LOG("StartDebugRecording"); - TEST_MUSTPASS(apm->StartDebugRecording(GetFilename("apm_debug.txt"))); - SLEEP(1000); - TEST_LOG("StopDebugRecording"); - TEST_MUSTPASS(apm->StopDebugRecording()); - - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); - - return 0; + return 0; } } // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_extended_test.h b/src/voice_engine/main/test/auto_test/voe_extended_test.h index 3463c81135..0b53d09bd6 100644 --- a/src/voice_engine/main/test/auto_test/voe_extended_test.h +++ b/src/voice_engine/main/test/auto_test/voe_extended_test.h @@ -34,7 +34,9 @@ class AudioDeviceModuleImpl : public AudioDeviceModule { // Helper methods which allows us to get some handy information about // this mock implementation. - int32_t ReferenceCounter() const { return _ref_count; } + int32_t ReferenceCounter() const { + return _ref_count; + } // RefCountedModule implementation (mocks default implementation) virtual int32_t AddRef(); @@ -42,15 +44,28 @@ class AudioDeviceModuleImpl : public AudioDeviceModule { // Module implementation virtual int32_t Version(char* version, - uint32_t& remaining_buffer_in_bytes, uint32_t& position) const { return 0;} - virtual int32_t ChangeUniqueId(const int32_t id) { return 0; } - virtual int32_t TimeUntilNextProcess() { return -1;} - virtual int32_t Process() { return 0; } + uint32_t& remaining_buffer_in_bytes, + uint32_t& position) const { + return 0; + } + virtual int32_t ChangeUniqueId(const int32_t id) { + return 0; + } + virtual int32_t TimeUntilNextProcess() { + return -1; + } + virtual int32_t Process() { + return 0; + } // AudioDeviceModule implementation - virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const { return 0; } + virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const { + return 0; + } - virtual ErrorCode LastError() const { return static_cast (0); } + virtual ErrorCode LastError() const { + return static_cast (0); + } virtual int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) { return 0; } @@ -59,148 +74,276 @@ class AudioDeviceModuleImpl : public AudioDeviceModule { return 0; } - virtual int32_t Init() { return 0; } - virtual int32_t Terminate() { return 0; } - virtual bool Initialized() const { return true; } + virtual int32_t Init() { + return 0; + } + virtual int32_t Terminate() { + return 0; + } + virtual bool Initialized() const { + return true; + } - virtual int16_t PlayoutDevices() { return -1; } - virtual int16_t RecordingDevices() { return -1; } + virtual int16_t PlayoutDevices() { + return -1; + } + virtual int16_t RecordingDevices() { + return -1; + } virtual int32_t PlayoutDeviceName(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]) { return -1; } + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]) { + return -1; + } virtual int32_t RecordingDeviceName(uint16_t index, - char name[kAdmMaxDeviceNameSize], - char guid[kAdmMaxGuidSize]) { return -1; } + char name[kAdmMaxDeviceNameSize], + char guid[kAdmMaxGuidSize]) { + return -1; + } - virtual int32_t SetPlayoutDevice(uint16_t index) { return 0; } - virtual int32_t SetPlayoutDevice(WindowsDeviceType device) { return 0; } - virtual int32_t SetRecordingDevice(uint16_t index) { return 0; } - virtual int32_t SetRecordingDevice(WindowsDeviceType device) { return 0; } + virtual int32_t SetPlayoutDevice(uint16_t index) { + return 0; + } + virtual int32_t SetPlayoutDevice(WindowsDeviceType device) { + return 0; + } + virtual int32_t SetRecordingDevice(uint16_t index) { + return 0; + } + virtual int32_t SetRecordingDevice(WindowsDeviceType device) { + return 0; + } virtual int32_t PlayoutIsAvailable(bool* available) { *available = true; return 0; } - virtual int32_t InitPlayout() { return 0; } - virtual bool PlayoutIsInitialized() const { return true; } + virtual int32_t InitPlayout() { + return 0; + } + virtual bool PlayoutIsInitialized() const { + return true; + } virtual int32_t RecordingIsAvailable(bool* available) { *available = true; return 0; } - virtual int32_t InitRecording() { return 0; } - virtual bool RecordingIsInitialized() const { return true; } + virtual int32_t InitRecording() { + return 0; + } + virtual bool RecordingIsInitialized() const { + return true; + } - virtual int32_t StartPlayout() { return 0; } - virtual int32_t StopPlayout() { return 0; } - virtual bool Playing() const { return true; } - virtual int32_t StartRecording() { return 0; } - virtual int32_t StopRecording() { return 0; } - virtual bool Recording() const { return true; } + virtual int32_t StartPlayout() { + return 0; + } + virtual int32_t StopPlayout() { + return 0; + } + virtual bool Playing() const { + return true; + } + virtual int32_t StartRecording() { + return 0; + } + virtual int32_t StopRecording() { + return 0; + } + virtual bool Recording() const { + return true; + } - virtual int32_t SetAGC(bool enable) { return -1; } - virtual bool AGC() const { return false; } + virtual int32_t SetAGC(bool enable) { + return -1; + } + virtual bool AGC() const { + return false; + } virtual int32_t SetWaveOutVolume(uint16_t volumeLeft, - uint16_t volumeRight) { return -1; } + uint16_t volumeRight) { + return -1; + } virtual int32_t WaveOutVolume(uint16_t* volumeLeft, - uint16_t* volumeRight) const { return -1; } + uint16_t* volumeRight) const { + return -1; + } virtual int32_t SpeakerIsAvailable(bool* available) { *available = true; return 0; } - virtual int32_t InitSpeaker() { return 0; } - virtual bool SpeakerIsInitialized() const { return true; } + virtual int32_t InitSpeaker() { + return 0; + } + virtual bool SpeakerIsInitialized() const { + return true; + } virtual int32_t MicrophoneIsAvailable(bool* available) { *available = true; return 0; } - virtual int32_t InitMicrophone() { return 0; } - virtual bool MicrophoneIsInitialized() const { return true; } + virtual int32_t InitMicrophone() { + return 0; + } + virtual bool MicrophoneIsInitialized() const { + return true; + } - virtual int32_t SpeakerVolumeIsAvailable(bool* available) { return -1; } - virtual int32_t SetSpeakerVolume(uint32_t volume) { return -1; } - virtual int32_t SpeakerVolume(uint32_t* volume) const { return -1; } - virtual int32_t MaxSpeakerVolume(uint32_t* maxVolume) const { return -1; } - virtual int32_t MinSpeakerVolume(uint32_t* minVolume) const { return -1; } - virtual int32_t SpeakerVolumeStepSize(uint16_t* stepSize) const { + virtual int32_t SpeakerVolumeIsAvailable(bool* available) { + return -1; + } + virtual int32_t SetSpeakerVolume(uint32_t volume) { + return -1; + } + virtual int32_t SpeakerVolume(uint32_t* volume) const { + return -1; + } + virtual int32_t MaxSpeakerVolume(uint32_t* maxVolume) const { + return -1; + } + virtual int32_t MinSpeakerVolume(uint32_t* minVolume) const { + return -1; + } + virtual int32_t SpeakerVolumeStepSize(uint16_t* stepSize) const { return -1; } - virtual int32_t MicrophoneVolumeIsAvailable(bool* available) { return -1; } - virtual int32_t SetMicrophoneVolume(uint32_t volume) { return -1; } - virtual int32_t MicrophoneVolume(uint32_t* volume) const { return -1; } - virtual int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const { return -1; } - virtual int32_t MinMicrophoneVolume(uint32_t* minVolume) const { return -1; } - virtual int32_t MicrophoneVolumeStepSize(uint16_t* stepSize) const { + virtual int32_t MicrophoneVolumeIsAvailable(bool* available) { + return -1; + } + virtual int32_t SetMicrophoneVolume(uint32_t volume) { + return -1; + } + virtual int32_t MicrophoneVolume(uint32_t* volume) const { + return -1; + } + virtual int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const { + return -1; + } + virtual int32_t MinMicrophoneVolume(uint32_t* minVolume) const { + return -1; + } + virtual int32_t MicrophoneVolumeStepSize(uint16_t* stepSize) const { return -1; } - virtual int32_t SpeakerMuteIsAvailable(bool* available) { return -1; } - virtual int32_t SetSpeakerMute(bool enable) { return -1; } - virtual int32_t SpeakerMute(bool* enabled) const { return -1; } + virtual int32_t SpeakerMuteIsAvailable(bool* available) { + return -1; + } + virtual int32_t SetSpeakerMute(bool enable) { + return -1; + } + virtual int32_t SpeakerMute(bool* enabled) const { + return -1; + } - virtual int32_t MicrophoneMuteIsAvailable(bool* available) { return -1; } - virtual int32_t SetMicrophoneMute(bool enable) { return -1; } - virtual int32_t MicrophoneMute(bool* enabled) const { return -1; } + virtual int32_t MicrophoneMuteIsAvailable(bool* available) { + return -1; + } + virtual int32_t SetMicrophoneMute(bool enable) { + return -1; + } + virtual int32_t MicrophoneMute(bool* enabled) const { + return -1; + } - virtual int32_t MicrophoneBoostIsAvailable(bool* available) { return -1; } - virtual int32_t SetMicrophoneBoost(bool enable) { return -1; } - virtual int32_t MicrophoneBoost(bool* enabled) const { return -1; } + virtual int32_t MicrophoneBoostIsAvailable(bool* available) { + return -1; + } + virtual int32_t SetMicrophoneBoost(bool enable) { + return -1; + } + virtual int32_t MicrophoneBoost(bool* enabled) const { + return -1; + } virtual int32_t StereoPlayoutIsAvailable(bool* available) const { - return -1; } - virtual int32_t SetStereoPlayout(bool enable) { return -1; } - virtual int32_t StereoPlayout(bool* enabled) const { return -1; } + return -1; + } + virtual int32_t SetStereoPlayout(bool enable) { + return -1; + } + virtual int32_t StereoPlayout(bool* enabled) const { + return -1; + } virtual int32_t StereoRecordingIsAvailable(bool* available) const { return -1; } - virtual int32_t SetStereoRecording(bool enable) { return -1; } - virtual int32_t StereoRecording(bool* enabled) const { return -1; } + virtual int32_t SetStereoRecording(bool enable) { + return -1; + } + virtual int32_t StereoRecording(bool* enabled) const { + return -1; + } virtual int32_t SetRecordingChannel(const ChannelType channel) { - return -1; + return -1; + } + virtual int32_t RecordingChannel(ChannelType* channel) const { + return -1; } - virtual int32_t RecordingChannel(ChannelType* channel) const { return -1; } - virtual int32_t SetPlayoutBuffer(const BufferType type, - uint16_t sizeMS = 0) { return -1; } + virtual int32_t SetPlayoutBuffer(const BufferType type, uint16_t sizeMS = 0) { + return -1; + } virtual int32_t PlayoutBuffer(BufferType* type, uint16_t* sizeMS) const { - return -1; + return -1; + } + virtual int32_t PlayoutDelay(uint16_t* delayMS) const { + return -1; + } + virtual int32_t RecordingDelay(uint16_t* delayMS) const { + return -1; } - virtual int32_t PlayoutDelay(uint16_t* delayMS) const { return -1; } - virtual int32_t RecordingDelay(uint16_t* delayMS) const { return -1; } - virtual int32_t CPULoad(uint16_t* load) const { return -1; } + virtual int32_t CPULoad(uint16_t* load) const { + return -1; + } virtual int32_t StartRawOutputFileRecording( - const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { return -1; } - virtual int32_t StopRawOutputFileRecording() { return -1; } + const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { + return -1; + } + virtual int32_t StopRawOutputFileRecording() { + return -1; + } virtual int32_t StartRawInputFileRecording( - const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { return -1; } - virtual int32_t StopRawInputFileRecording() { return -1; } + const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { + return -1; + } + virtual int32_t StopRawInputFileRecording() { + return -1; + } virtual int32_t SetRecordingSampleRate(const uint32_t samplesPerSec) { - return -1; + return -1; } virtual int32_t RecordingSampleRate(uint32_t* samplesPerSec) const { - return -1; + return -1; } virtual int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec) { - return -1; + return -1; } virtual int32_t PlayoutSampleRate(uint32_t* samplesPerSec) const { - return -1; + return -1; } - virtual int32_t ResetAudioDevice() { return -1; } - virtual int32_t SetLoudspeakerStatus(bool enable) { return -1; } - virtual int32_t GetLoudspeakerStatus(bool* enabled) const { return -1; } + virtual int32_t ResetAudioDevice() { + return -1; + } + virtual int32_t SetLoudspeakerStatus(bool enable) { + return -1; + } + virtual int32_t GetLoudspeakerStatus(bool* enabled) const { + return -1; + } -protected: + protected: AudioDeviceModuleImpl(); ~AudioDeviceModuleImpl(); -private: + private: volatile int32_t _ref_count; }; @@ -208,51 +351,53 @@ private: // Transport // ---------------------------------------------------------------------------- -class ExtendedTestTransport : public Transport -{ -public: - ExtendedTestTransport(VoENetwork* ptr); - ~ExtendedTestTransport(); - VoENetwork* myNetw; -protected: - virtual int SendPacket(int channel,const void *data,int len); - virtual int SendRTCPPacket(int channel, const void *data, int len); -private: - static bool Run(void* ptr); - bool Process(); -private: - ThreadWrapper* _thread; - CriticalSectionWrapper* _lock; - EventWrapper* _event; -private: - unsigned char _packetBuffer[1612]; - int _length; - int _channel; +class ExtendedTestTransport : public Transport { + public: + ExtendedTestTransport(VoENetwork* ptr); + ~ExtendedTestTransport(); + VoENetwork* myNetw; + + protected: + virtual int SendPacket(int channel, const void *data, int len); + virtual int SendRTCPPacket(int channel, const void *data, int len); + + private: + static bool Run(void* ptr); + bool Process(); + + private: + ThreadWrapper* _thread; + CriticalSectionWrapper* _lock; + EventWrapper* _event; + + private: + unsigned char _packetBuffer[1612]; + int _length; + int _channel; }; -class XTransport : public Transport -{ -public: - XTransport(VoENetwork* netw, VoEFile* file); - VoENetwork* _netw; - VoEFile* _file; -public: - virtual int SendPacket(int channel, const void *data, int len); - virtual int SendRTCPPacket(int channel, const void *data, int len); +class XTransport : public Transport { + public: + XTransport(VoENetwork* netw, VoEFile* file); + VoENetwork* _netw; + VoEFile* _file; + + public: + virtual int SendPacket(int channel, const void *data, int len); + virtual int SendRTCPPacket(int channel, const void *data, int len); }; -class XRTPObserver : public VoERTPObserver -{ -public: - XRTPObserver(); - ~XRTPObserver(); - virtual void OnIncomingCSRCChanged(const int channel, - const unsigned int CSRC, - const bool added); - virtual void OnIncomingSSRCChanged(const int channel, - const unsigned int SSRC); -public: - unsigned int _SSRC; +class XRTPObserver : public VoERTPObserver { + public: + XRTPObserver(); + ~XRTPObserver(); + virtual void OnIncomingCSRCChanged(const int channel, + const unsigned int CSRC, + const bool added); + virtual void OnIncomingSSRCChanged(const int channel, + const unsigned int SSRC); + public: + unsigned int _SSRC; }; // ---------------------------------------------------------------------------- @@ -260,72 +405,57 @@ public: // ---------------------------------------------------------------------------- class VoEExtendedTest : public VoiceEngineObserver, - public VoEConnectionObserver -{ -public: - VoEExtendedTest(VoETestManager& mgr); - ~VoEExtendedTest(); - int PrepareTest(const char* str) const; - int TestPassed(const char* str) const; - int TestBase(); - int TestCallReport(); - int TestCodec(); - int TestDtmf(); - int TestEncryption(); - int TestExternalMedia(); - int TestFile(); - int TestMixing(); - int TestHardware(); - int TestNetEqStats(); - int TestNetwork(); - int TestRTP_RTCP(); - int TestVideoSync(); - int TestVolumeControl(); - int TestAPM(); -public: - int ErrorCode() const - { - return _errCode; - } - ; - void ClearErrorCode() - { - _errCode = 0; - } - ; -protected: - // from VoiceEngineObserver - void CallbackOnError(const int errCode, const int channel); - void CallbackOnTrace(const TraceLevel level, - const char* message, - const int length); -protected: - // from VoEConnectionObserver - void OnPeriodicDeadOrAlive(const int channel, const bool alive); -private: - void Play(int channel, - unsigned int timeMillisec, - bool addFileAsMicrophone = false, - bool addTimeMarker = false); - void Sleep(unsigned int timeMillisec, bool addMarker = false); - void StartMedia(int channel, - int rtpPort, - bool listen, - bool playout, - bool send); - void StopMedia(int channel); - int RunMixingTest(int num_channels, - int16_t input_value, - int16_t max_output_value, - int16_t min_output_value); -private: - VoETestManager& _mgr; -private: - int _errCode; - bool _alive; - bool _listening[32]; - bool _playing[32]; - bool _sending[32]; + public VoEConnectionObserver { + public: + VoEExtendedTest(VoETestManager& mgr); + ~VoEExtendedTest(); + int PrepareTest(const char* str) const; + int TestPassed(const char* str) const; + int TestBase(); + int TestCallReport(); + int TestCodec(); + int TestDtmf(); + int TestEncryption(); + int TestExternalMedia(); + int TestFile(); + int TestMixing(); + int TestHardware(); + int TestNetEqStats(); + int TestNetwork(); + int TestRTP_RTCP(); + int TestVideoSync(); + int TestVolumeControl(); + int TestAPM(); + public: + int ErrorCode() const { + return _errCode; + } + void ClearErrorCode() { + _errCode = 0; + } + protected: + // from VoiceEngineObserver + void CallbackOnError(const int errCode, const int channel); + void CallbackOnTrace(const TraceLevel level, const char* message, const int length); + protected: + // from VoEConnectionObserver + void OnPeriodicDeadOrAlive(const int channel, const bool alive); + private: + void Play(int channel, unsigned int timeMillisec, bool addFileAsMicrophone = false, + bool addTimeMarker = false); + void Sleep(unsigned int timeMillisec, bool addMarker = false); + void StartMedia(int channel, int rtpPort, bool listen, bool playout, bool send); + void StopMedia(int channel); + int RunMixingTest(int num_channels, int16_t input_value, int16_t max_output_value, + int16_t min_output_value); + private: + VoETestManager& _mgr; + private: + int _errCode; + bool _alive; + bool _listening[32]; + bool _playing[32]; + bool _sending[32]; }; } // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_standard_test.cc b/src/voice_engine/main/test/auto_test/voe_standard_test.cc index f68bcaa510..6c01f12adc 100644 --- a/src/voice_engine/main/test/auto_test/voe_standard_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_standard_test.cc @@ -61,158 +61,130 @@ const char* GetResource(const char* resource); char filenameStr[2][256]; int currentStr = 0; -char* GetFilename(char* filename) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], "/sdcard/%s", filename); - return filenameStr[currentStr]; +char* GetFilename(char* filename) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/sdcard/%s", filename); + return filenameStr[currentStr]; } -const char* GetFilename(const char* filename) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], "/sdcard/%s", filename); - return filenameStr[currentStr]; + +const char* GetFilename(const char* filename) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/sdcard/%s", filename); + return filenameStr[currentStr]; } -int GetResource(char* resource, char* dest, int destLen) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], "/sdcard/%s", resource); - strncpy(dest, filenameStr[currentStr], destLen-1); - return 0; + +int GetResource(char* resource, char* dest, int destLen) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/sdcard/%s", resource); + strncpy(dest, filenameStr[currentStr], destLen-1); + return 0; } -char* GetResource(char* resource) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], "/sdcard/%s", resource); - return filenameStr[currentStr]; + +char* GetResource(char* resource) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/sdcard/%s", resource); + return filenameStr[currentStr]; } -const char* GetResource(const char* resource) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], "/sdcard/%s", resource); - return filenameStr[currentStr]; + +const char* GetResource(const char* resource) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/sdcard/%s", resource); + return filenameStr[currentStr]; } + #else char filenameStr[2][256]; int currentStr = 0; -char* GetFilename(char* filename) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], - "/tmp/%s", - filename); - return filenameStr[currentStr]; +char* GetFilename(char* filename) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/tmp/%s", filename); + return filenameStr[currentStr]; } -const char* GetFilename(const char* filename) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], - "/tmp/%s", - filename); - return filenameStr[currentStr]; +const char* GetFilename(const char* filename) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/tmp/%s", filename); + return filenameStr[currentStr]; } -int GetResource(char* resource, char* dest, int destLen) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], - "/tmp/%s", - resource); - strncpy(dest, filenameStr[currentStr], destLen-1); - return 0; +int GetResource(char* resource, char* dest, int destLen) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/tmp/%s", resource); + strncpy(dest, filenameStr[currentStr], destLen - 1); + return 0; } -char* GetResource(char* resource) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], - "/tmp/%s", - resource); - return filenameStr[currentStr]; +char* GetResource(char* resource) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/tmp/%s", resource); + return filenameStr[currentStr]; } -const char* GetResource(const char* resource) -{ - currentStr = !currentStr; - sprintf(filenameStr[currentStr], - "/tmp/%s", - resource); - return filenameStr[currentStr]; +const char* GetResource(const char* resource) { + currentStr = !currentStr; + sprintf(filenameStr[currentStr], "/tmp/%s", resource); + return filenameStr[currentStr]; } #endif #if !defined(MAC_IPHONE) -const char* summaryFilename = - "/tmp/VoiceEngineSummary.txt"; +const char* summaryFilename = "/tmp/VoiceEngineSummary.txt"; #endif // For iPhone the summary filename is created in createSummary -int dummy = 0; // Dummy used in different functions to avoid warnings +int dummy = 0; // Dummy used in different functions to avoid warnings -MyRTPObserver::MyRTPObserver() -{ - Reset(); +MyRTPObserver::MyRTPObserver() { + Reset(); } -MyRTPObserver::~MyRTPObserver() -{ +MyRTPObserver::~MyRTPObserver() { } -void MyRTPObserver::Reset() -{ - for (int i = 0; i < 2; i++) - { - _SSRC[i] = 0; - _CSRC[i][0] = 0; - _CSRC[i][1] = 0; - _added[i][0] = false; - _added[i][1] = false; - _size[i] = 0; - } +void MyRTPObserver::Reset() { + for (int i = 0; i < 2; i++) { + _SSRC[i] = 0; + _CSRC[i][0] = 0; + _CSRC[i][1] = 0; + _added[i][0] = false; + _added[i][1] = false; + _size[i] = 0; + } } void MyRTPObserver::OnIncomingCSRCChanged(const int channel, const unsigned int CSRC, - const bool added) -{ - char msg[128]; - sprintf(msg, "=> OnIncomingCSRCChanged(channel=%d, CSRC=%u, added=%d)\n", - channel, CSRC, added); - TEST_LOG("%s", msg); + const bool added) { + char msg[128]; + sprintf(msg, "=> OnIncomingCSRCChanged(channel=%d, CSRC=%u, added=%d)\n", + channel, CSRC, added); + TEST_LOG("%s", msg); - if (channel > 1) - return; // not enough memory + if (channel > 1) + return; // Not enough memory. - _CSRC[channel][_size[channel]] = CSRC; - _added[channel][_size[channel]] = added; + _CSRC[channel][_size[channel]] = CSRC; + _added[channel][_size[channel]] = added; - _size[channel]++; - if (_size[channel] == 2) - _size[channel] = 0; + _size[channel]++; + if (_size[channel] == 2) + _size[channel] = 0; } void MyRTPObserver::OnIncomingSSRCChanged(const int channel, - const unsigned int SSRC) -{ - char msg[128]; - sprintf(msg, - "\n=> OnIncomingSSRCChanged(channel=%d, SSRC=%u)\n", - channel, SSRC); - TEST_LOG("%s", msg); + const unsigned int SSRC) { + char msg[128]; + sprintf(msg, "\n=> OnIncomingSSRCChanged(channel=%d, SSRC=%u)\n", channel, SSRC); + TEST_LOG("%s", msg); - _SSRC[channel] = SSRC; + _SSRC[channel] = SSRC; } void MyDeadOrAlive::OnPeriodicDeadOrAlive(const int /*channel*/, - const bool alive) -{ - if (alive) - { - TEST_LOG("ALIVE\n"); - } - else - { - TEST_LOG("DEAD\n"); - } - fflush(NULL); + const bool alive) { + if (alive) { + TEST_LOG("ALIVE\n"); + } else { + TEST_LOG("DEAD\n"); + } + fflush(NULL); } #ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API @@ -221,3816 +193,3689 @@ void MyMedia::Process(const int channel, WebRtc_Word16 audio_10ms[], const int length, const int samplingFreqHz, - const bool stereo) -{ - for(int i = 0; i < length; i++) - { - if (!stereo) - { - audio_10ms[i] = (WebRtc_Word16)(audio_10ms[i] * - sin(2.0 * 3.14 * f * 400.0 / samplingFreqHz)); - } - else - { - // interleaved stereo - audio_10ms[2 * i] = (WebRtc_Word16)(audio_10ms[2 * i] * - sin(2.0 * 3.14 * f * 400.0 / samplingFreqHz)); - audio_10ms[2 * i + 1] = (WebRtc_Word16)(audio_10ms[2 * i + 1] * - sin(2.0 * 3.14 * f * 400.0 / samplingFreqHz)); - } - f++; + const bool stereo) { + for (int i = 0; i < length; i++) { + if (!stereo) { + audio_10ms[i] = (WebRtc_Word16) (audio_10ms[i] * + sin(2.0 * 3.14 * f * 400.0 / samplingFreqHz)); + } else { + // interleaved stereo + audio_10ms[2 * i] = (WebRtc_Word16) (audio_10ms[2 * i] * + sin(2.0 * 3.14 * f * 400.0 / samplingFreqHz)); + audio_10ms[2 * i + 1] = (WebRtc_Word16) (audio_10ms[2 * i + 1] * + sin(2.0 * 3.14 * f * 400.0 / samplingFreqHz)); } + f++; + } } #endif MyMedia mobj; -my_transportation::my_transportation(VoENetwork* ptr) : - myNetw(ptr), - _thread(NULL), - _lock(NULL), - _event(NULL), - _length(0), - _channel(0), - _delayIsEnabled(0), - _delayTimeInMs(0) -{ - const char* threadName = "external_thread"; - _lock = CriticalSectionWrapper::CreateCriticalSection(); - _event = EventWrapper::Create(); - _thread = ThreadWrapper::CreateThread(Run, - this, - kHighPriority, - threadName); - if (_thread) - { - unsigned int id; - _thread->Start(id); +my_transportation::my_transportation(VoENetwork* ptr) + : myNetw(ptr), + _thread(NULL), + _lock(NULL), + _event(NULL), + _length(0), + _channel(0), + _delayIsEnabled(0), + _delayTimeInMs(0) { + const char* threadName = "external_thread"; + _lock = CriticalSectionWrapper::CreateCriticalSection(); + _event = EventWrapper::Create(); + _thread = ThreadWrapper::CreateThread(Run, this, kHighPriority, threadName); + if (_thread) { + unsigned int id; + _thread->Start(id); + } +} + +my_transportation::~my_transportation() { + if (_thread) { + _thread->SetNotAlive(); + _event->Set(); + if (_thread->Stop()) { + delete _thread; + _thread = NULL; + delete _event; + _event = NULL; + delete _lock; + _lock = NULL; } + } } -my_transportation::~my_transportation() -{ - if (_thread) - { - _thread->SetNotAlive(); - _event->Set(); - if (_thread->Stop()) - { - delete _thread; - _thread = NULL; - delete _event; - _event = NULL; - delete _lock; - _lock = NULL; - } - } +bool my_transportation::Run(void* ptr) { + return static_cast (ptr)->Process(); } -bool my_transportation::Run(void* ptr) -{ - return static_cast(ptr)->Process(); -} - -bool my_transportation::Process() -{ - switch(_event->Wait(500)) - { +bool my_transportation::Process() { + switch (_event->Wait(500)) { case kEventSignaled: - _lock->Enter(); - myNetw->ReceivedRTPPacket( _channel, _packetBuffer, _length ); - _lock->Leave(); - return true; + _lock->Enter(); + myNetw->ReceivedRTPPacket(_channel, _packetBuffer, _length); + _lock->Leave(); + return true; case kEventTimeout: - return true; + return true; case kEventError: - break; - } - return true; + break; + } + return true; } -int my_transportation::SendPacket(int channel, const void *data, int len) -{ - _lock->Enter(); - if (len < 1612) - { - memcpy(_packetBuffer, (const unsigned char*)data, len); - _length = len; - _channel = channel; - } - _lock->Leave(); - _event->Set(); // triggers ReceivedRTPPacket() from worker thread - return len; +int my_transportation::SendPacket(int channel, const void *data, int len) { + _lock->Enter(); + if (len < 1612) { + memcpy(_packetBuffer, (const unsigned char*) data, len); + _length = len; + _channel = channel; + } + _lock->Leave(); + _event->Set(); // triggers ReceivedRTPPacket() from worker thread + return len; } -int my_transportation::SendRTCPPacket(int channel,const void *data,int len) -{ - if (_delayIsEnabled) - { - Sleep(_delayTimeInMs); - } - myNetw->ReceivedRTCPPacket(channel, data, len); - return len; +int my_transportation::SendRTCPPacket(int channel, const void *data, int len) { + if (_delayIsEnabled) { + Sleep(_delayTimeInMs); + } + myNetw->ReceivedRTCPPacket(channel, data, len); + return len; } -void my_transportation::SetDelayStatus(bool enable, unsigned int delayInMs) -{ - _delayIsEnabled = enable; - _delayTimeInMs = delayInMs; +void my_transportation::SetDelayStatus(bool enable, unsigned int delayInMs) { + _delayIsEnabled = enable; + _delayTimeInMs = delayInMs; } -ErrorObserver::ErrorObserver() -{ - code = -1; +ErrorObserver::ErrorObserver() { + code = -1; } -void ErrorObserver::CallbackOnError(const int channel, const int errCode) -{ - code=errCode; +void ErrorObserver::CallbackOnError(const int channel, const int errCode) { + code = errCode; #ifndef _INSTRUMENTATION_TESTING_ - TEST_LOG("\n************************\n"); - TEST_LOG(" RUNTIME ERROR: %d \n", errCode); - TEST_LOG("************************\n"); + TEST_LOG("\n************************\n"); + TEST_LOG(" RUNTIME ERROR: %d \n", errCode); + TEST_LOG("************************\n"); #endif } -void MyTraceCallback::Print(const TraceLevel level, const char *traceString, - const int length) -{ - if (traceString) - { - char* tmp = new char[length]; - memcpy(tmp, traceString, length); - TEST_LOG("%s", tmp); - TEST_LOG("\n"); - delete [] tmp; - } +void MyTraceCallback::Print(const TraceLevel level, + const char *traceString, + const int length) { + if (traceString) { + char* tmp = new char[length]; + memcpy(tmp, traceString, length); + TEST_LOG("%s", tmp); + TEST_LOG("\n"); + delete[] tmp; + } } void RtcpAppHandler::OnApplicationDataReceived( - const int /*channel*/, - const unsigned char subType, - const unsigned int name, - const unsigned char* data, - const unsigned short dataLengthInBytes) -{ - _lengthBytes = dataLengthInBytes; - memcpy(_data, &data[0], dataLengthInBytes); - _subType = subType; - _name = name; + const int /*channel*/, const unsigned char subType, const unsigned int name, + const unsigned char* data, const unsigned short dataLengthInBytes) { + _lengthBytes = dataLengthInBytes; + memcpy(_data, &data[0], dataLengthInBytes); + _subType = subType; + _name = name; } -void RtcpAppHandler::Reset() -{ - _lengthBytes = 0; - memset(_data, 0, sizeof(_data)); - _subType = 0; - _name = 0; +void RtcpAppHandler::Reset() { + _lengthBytes = 0; + memset(_data, 0, sizeof(_data)); + _subType = 0; + _name = 0; } ErrorObserver obs; RtcpAppHandler myRtcpAppHandler; MyRTPObserver rtpObserver; -void my_encryption::encrypt(int , - unsigned char * in_data, +void my_encryption::encrypt(int, unsigned char * in_data, unsigned char * out_data, int bytes_in, - int * bytes_out){ - int i; - for(i=0;iSetAudioDeviceLayer(TESTED_AUDIO_LAYER); - if (res < 0) - { - printf("\nERROR: failed to set audio layer to use in " - "testing\n"); - } - else - { - printf("\nAudio layer %d will be used in testing\n", - TESTED_AUDIO_LAYER); - } - } -#ifdef _TEST_XMEDIA_ - xmedia = VoEExternalMedia::GetInterface(ve); -#endif -#ifdef _TEST_CALL_REPORT_ - report = VoECallReport::GetInterface(ve); -#endif -#ifdef _TEST_NETEQ_STATS_ - neteqst = VoENetEqStats::GetInterface(ve); -#endif - } -} + if (VoiceEngine::SetTraceFile(NULL) != -1) { + // should not be possible to call a Trace method before the VoE is + // created + TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" + "should fail)!\n", __LINE__); + return false; + } -int VoETestManager::ReleaseInterfaces() -{ - int err(0), remInt(1), j(0); - bool releaseOK(true); - - if (base) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = base->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d base interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - // try to release one addition time (should fail) - TEST_MUSTPASS(-1 != base->Release()); - err = base->LastError(); - // it is considered safe to delete even if Release has been called - // too many times - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (codec) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = codec->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d codec interfaces" - " (should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != codec->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (volume) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = volume->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d volume interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != volume->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (dtmf) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = dtmf->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d dtmf interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != dtmf->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (rtp_rtcp) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = rtp_rtcp->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d rtp/rtcp interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != rtp_rtcp->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (apm) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = apm->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d apm interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != apm->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (netw) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = netw->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d network interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != netw->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (file) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = file->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d file interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != file->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } -#ifdef _TEST_VIDEO_SYNC_ - if (vsync) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = vsync->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d video sync interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != vsync->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } -#endif - if (encrypt) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = encrypt->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d encryption interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != encrypt->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } - if (hardware) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = hardware->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d hardware interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != hardware->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } -#ifdef _TEST_XMEDIA_ - if (xmedia) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = xmedia->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d external media interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != xmedia->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } -#endif -#ifdef _TEST_CALL_REPORT_ - if (report) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = report->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d call report interfaces" - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != report->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } -#endif -#ifdef _TEST_NETEQ_STATS_ - if (neteqst) - { - for (remInt=1,j=0; remInt>0; j++) - TEST_MUSTPASS(-1 == (remInt = neteqst->Release())); - if (j>1) - { - TEST_LOG("\n\n*** Error: released %d neteq stat interfaces " - "(should only be 1) \n", j); - releaseOK = false; - } - TEST_MUSTPASS(-1 != neteqst->Release()); - err = base->LastError(); - TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); - } -#endif - if (false == VoiceEngine::Delete(ve)) - { - TEST_LOG("\n\nVoiceEngine::Delete() failed. \n"); - releaseOK = false; - } - - if (VoiceEngine::SetTraceFile(NULL) != -1) - { - TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" - "should fail)!\n", __LINE__); - } - - return (releaseOK == true) ? 0 : -1; -} - -int VoETestManager::DoStandardTest() -{ -#if (defined(_TEST_CODEC_) || defined(_TEST_FILE_)) - CodecInst cinst; - memset(&cinst, 0, sizeof(cinst)); -#endif - char tmpStr[1024]; - - TEST_LOG("\n\n+++ Base tests +++\n\n"); - - // Test trace callbacks - TEST_LOG("Enabling the trace callback => default trace messages " - "shall be printed... \n\n"); - MyTraceCallback* callback = new MyTraceCallback(); - VoiceEngine::SetTraceCallback(callback); - - // Test the remaining trace APIs - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("webrtc_voe_trace.txt"), - true)); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "webrtc_voe_trace.txt"))); - - VoiceEngine* extra = VoiceEngine::Create(); - instanceCount++; - TEST_LOG("\nVerify that the VoE ID is now changed from 1 to 2\n\n"); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "webrtc_voe_trace.txt"))); - TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); - VoiceEngine::Delete(extra); - SLEEP(10); - TEST_LOG("\nVerify that the VoE ID is now changed back to 1\n"); - TEST_LOG("NOTE: Currently it will still be 2, this is OK\n\n"); - - // The API below shall be the first line in the stored trace file - // (verify after test)! - TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( - "webrtc_voe_trace.txt"))); - VoiceEngine::SetTraceCallback(NULL); - delete callback; - TEST_LOG("\n...the trace callback is now disabled.\n\n"); - - ///////////////////////////////////////////////// - // Hardware (test before VoE is intialized) -#ifdef _TEST_HARDWARE_ - // Set/GetAudioDeviceLayer - TEST_LOG("Set/Get audio device layer\n"); - AudioLayers wantedLayer = TESTED_AUDIO_LAYER; - AudioLayers givenLayer; - TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - TEST_MUSTPASS(wantedLayer != givenLayer); // Should be same before init -#endif //_TEST_HARDWARE_ - - TEST_LOG("Init \n"); -#if defined BLACKFIN - TEST_MUSTPASS(base->Init(0,LINUX_AUDIO_OSS)); +#if defined(WEBRTC_ANDROID) + resourcePath_ = "/sdcard/"; #else - TEST_MUSTPASS( base->Init()); + resourcePath_ = webrtc::test::ProjectRootPath(); + if (resourcePath_ == webrtc::test::kCannotFindProjectRootDir) { + TEST_LOG("Failed to get project root directory\n"); + return false; + } + resourcePath_ += "test/data/voice_engine/"; +#endif + audioFilename_ = resourcePath_ + "audio_long16.pcm"; + + ve = VoiceEngine::Create(); + if (!ve) { + TEST_LOG("Failed to create VoiceEngine\n"); + return false; + } + instanceCount++; + + return true; +} + +void VoETestManager::GetInterfaces() { + if (ve) { + base = VoEBase::GetInterface(ve); + codec = VoECodec::GetInterface(ve); + volume = VoEVolumeControl::GetInterface(ve); + dtmf = VoEDtmf::GetInterface(ve); + rtp_rtcp = VoERTP_RTCP::GetInterface(ve); + apm = VoEAudioProcessing::GetInterface(ve); + netw = VoENetwork::GetInterface(ve); + file = VoEFile::GetInterface(ve); +#ifdef _TEST_VIDEO_SYNC_ + vsync = VoEVideoSync::GetInterface(ve); +#endif + encrypt = VoEEncryption::GetInterface(ve); + hardware = VoEHardware::GetInterface(ve); + // Set the audio layer to use in all tests + if (hardware) { + int res = hardware->SetAudioDeviceLayer(TESTED_AUDIO_LAYER); + if (res < 0) { + printf("\nERROR: failed to set audio layer to use in " + "testing\n"); + } else { + printf("\nAudio layer %d will be used in testing\n", TESTED_AUDIO_LAYER); + } + } +#ifdef _TEST_XMEDIA_ + xmedia = VoEExternalMedia::GetInterface(ve); +#endif +#ifdef _TEST_CALL_REPORT_ + report = VoECallReport::GetInterface(ve); +#endif +#ifdef _TEST_NETEQ_STATS_ + neteqst = VoENetEqStats::GetInterface(ve); +#endif + } +} + +int VoETestManager::ReleaseInterfaces() { + int err(0), remInt(1), j(0); + bool releaseOK(true); + + if (base) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = base->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d base interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + // try to release one addition time (should fail) + TEST_MUSTPASS(-1 != base->Release()); + err = base->LastError(); + // it is considered safe to delete even if Release has been called + // too many times + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (codec) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = codec->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d codec interfaces" + " (should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != codec->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (volume) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = volume->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d volume interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != volume->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (dtmf) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = dtmf->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d dtmf interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != dtmf->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (rtp_rtcp) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = rtp_rtcp->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d rtp/rtcp interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != rtp_rtcp->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (apm) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = apm->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d apm interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != apm->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (netw) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = netw->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d network interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != netw->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (file) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = file->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d file interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != file->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } +#ifdef _TEST_VIDEO_SYNC_ + if (vsync) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = vsync->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d video sync interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != vsync->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } +#endif + if (encrypt) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = encrypt->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d encryption interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != encrypt->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } + if (hardware) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = hardware->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d hardware interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != hardware->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } +#ifdef _TEST_XMEDIA_ + if (xmedia) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = xmedia->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d external media interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != xmedia->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } +#endif +#ifdef _TEST_CALL_REPORT_ + if (report) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = report->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d call report interfaces" + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != report->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } +#endif +#ifdef _TEST_NETEQ_STATS_ + if (neteqst) { + for (remInt = 1, j = 0; remInt > 0; j++) + TEST_MUSTPASS(-1 == (remInt = neteqst->Release())); + if (j > 1) { + TEST_LOG("\n\n*** Error: released %d neteq stat interfaces " + "(should only be 1) \n", j); + releaseOK = false; + } + TEST_MUSTPASS(-1 != neteqst->Release()); + err = base->LastError(); + TEST_MUSTPASS(err != VE_INTERFACE_NOT_FOUND); + } +#endif + if (false == VoiceEngine::Delete(ve)) { + TEST_LOG("\n\nVoiceEngine::Delete() failed. \n"); + releaseOK = false; + } + + if (VoiceEngine::SetTraceFile(NULL) != -1) { + TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" + "should fail)!\n", __LINE__); + } + + return (releaseOK == true) ? 0 : -1; +} + +int VoETestManager::DoStandardTest() { +#if (defined(_TEST_CODEC_) || defined(_TEST_FILE_)) + CodecInst cinst; + memset(&cinst, 0, sizeof(cinst)); +#endif + char tmpStr[1024]; + + TEST_LOG("\n\n+++ Base tests +++\n\n"); + + // Test trace callbacks + TEST_LOG("Enabling the trace callback => default trace messages " + "shall be printed... \n\n"); + MyTraceCallback* callback = new MyTraceCallback(); + VoiceEngine::SetTraceCallback(callback); + + // Test the remaining trace APIs + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename("webrtc_voe_trace.txt"), + true)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "webrtc_voe_trace.txt"))); + + VoiceEngine* extra = VoiceEngine::Create(); + instanceCount++; + TEST_LOG("\nVerify that the VoE ID is now changed from 1 to 2\n\n"); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "webrtc_voe_trace.txt"))); + TEST_MUSTPASS(VoiceEngine::SetTraceFile(NULL)); + VoiceEngine::Delete(extra); + SLEEP(10); + TEST_LOG("\nVerify that the VoE ID is now changed back to 1\n"); + TEST_LOG("NOTE: Currently it will still be 2, this is OK\n\n"); + + // The API below shall be the first line in the stored trace file + // (verify after test)! + TEST_MUSTPASS(VoiceEngine::SetTraceFile(GetFilename( + "webrtc_voe_trace.txt"))); + VoiceEngine::SetTraceCallback(NULL); + delete callback; + TEST_LOG("\n...the trace callback is now disabled.\n\n"); + + ///////////////////////////////////////////////// + // Hardware (test before VoE is intialized) +#ifdef _TEST_HARDWARE_ + // Set/GetAudioDeviceLayer + TEST_LOG("Set/Get audio device layer\n"); + AudioLayers wantedLayer = TESTED_AUDIO_LAYER; + AudioLayers givenLayer; + TEST_MUSTPASS(hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + TEST_MUSTPASS(wantedLayer != givenLayer); // Should be same before init +#endif //_TEST_HARDWARE_ + TEST_LOG("Init \n"); +#if defined BLACKFIN + TEST_MUSTPASS(base->Init(0,LINUX_AUDIO_OSS)); +#else + TEST_MUSTPASS( base->Init()); #endif #if defined(WEBRTC_ANDROID) - TEST_LOG("Setting loudspeaker status to false \n"); - TEST_MUSTPASS(hardware->SetLoudspeakerStatus(false)); + TEST_LOG("Setting loudspeaker status to false \n"); + TEST_MUSTPASS(hardware->SetLoudspeakerStatus(false)); #endif #ifndef __INSURE__ - TEST_LOG("Enabling the observer \n"); - TEST_MUSTPASS(base->RegisterVoiceEngineObserver(obs)); + TEST_LOG("Enabling the observer \n"); + TEST_MUSTPASS(base->RegisterVoiceEngineObserver(obs)); #endif - TEST_LOG("Get version \n"); - TEST_MUSTPASS(base->GetVersion(tmpStr)); - TEST_LOG("--------------------\n%s\n--------------------\n", tmpStr); + TEST_LOG("Get version \n"); + TEST_MUSTPASS(base->GetVersion(tmpStr)); + TEST_LOG("--------------------\n%s\n--------------------\n", tmpStr); - TEST_LOG("Create channel \n"); - int nChannels = base->MaxNumOfChannels(); - TEST_MUSTPASS(!(nChannels > 0)); - TEST_LOG("Max number of channels = %d \n", nChannels); - TEST_MUSTPASS(base->CreateChannel()); + TEST_LOG("Create channel \n"); + int nChannels = base->MaxNumOfChannels(); + TEST_MUSTPASS(!(nChannels > 0)); + TEST_LOG("Max number of channels = %d \n", nChannels); + TEST_MUSTPASS(base->CreateChannel()); - ///////////////////////////////////////////////// - // RTP/RTCP (test before streaming is activated) + ///////////////////////////////////////////////// + // RTP/RTCP (test before streaming is activated) #ifdef _TEST_RTP_RTCP_ - TEST_LOG("\n\n+++ RTP/RTCP tests +++\n\n"); + TEST_LOG("\n\n+++ RTP/RTCP tests +++\n\n"); - TEST_LOG("Set/Get RTCP and CName \n"); - bool on; - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, on)); // should be on by default - TEST_MUSTPASS(on != true); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, on)); - TEST_MUSTPASS(on != false); - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); - TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, on)); - TEST_MUSTPASS(on != true); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Niklas")); + TEST_LOG("Set/Get RTCP and CName \n"); + bool on; + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, on)); // should be on by default + TEST_MUSTPASS(on != true); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, on)); + TEST_MUSTPASS(on != false); + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, true)); + TEST_MUSTPASS(rtp_rtcp->GetRTCPStatus(0, on)); + TEST_MUSTPASS(on != true); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Niklas")); - TEST_LOG("Set/Get RTP Keepalive\n"); - unsigned char pt; int dT; - TEST_MUSTPASS(!rtp_rtcp->GetRTPKeepaliveStatus(-1, on, pt, dT)); - // should be off by default - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); - TEST_MUSTPASS(on != false); - TEST_MUSTPASS(pt != 255); - TEST_MUSTPASS(dT != 0); + TEST_LOG("Set/Get RTP Keepalive\n"); + unsigned char pt; + int dT; + TEST_MUSTPASS(!rtp_rtcp->GetRTPKeepaliveStatus(-1, on, pt, dT)); + // should be off by default + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); + TEST_MUSTPASS(on != false); + TEST_MUSTPASS(pt != 255); + TEST_MUSTPASS(dT != 0); - // verify invalid input parameters - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(-1, true, 0, 15)); - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, -1, 15)); - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, 0, 61)); - // should still be off - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); - TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, 0)); - // should fail since default 0 is used bu PCMU - TEST_MUSTPASS(on != false); - // try valid settings - TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 1)); - TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 1)); - // should be on now - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); - TEST_MUSTPASS(on != true); TEST_MUSTPASS(pt != 1); TEST_MUSTPASS(dT != 15); - // Set the Keep alive payload to 60, and this payloadtype could not used - // by the codecs - TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 60, 3)); - TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); - TEST_MUSTPASS(on != true); TEST_MUSTPASS(pt != 60); TEST_MUSTPASS(dT != 3); - TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, false, 60)); + // verify invalid input parameters + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(-1, true, 0, 15)); + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, -1, 15)); + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, 0, 61)); + // should still be off + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); + TEST_MUSTPASS(!rtp_rtcp->SetRTPKeepaliveStatus(0, true, 0)); + // should fail since default 0 is used bu PCMU + TEST_MUSTPASS(on != false); + // try valid settings + TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 1)); + TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 1)); + // should be on now + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); + TEST_MUSTPASS(on != true);TEST_MUSTPASS(pt != 1);TEST_MUSTPASS(dT != 15); + // Set the Keep alive payload to 60, and this payloadtype could not used + // by the codecs + TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, true, 60, 3)); + TEST_MUSTPASS(rtp_rtcp->GetRTPKeepaliveStatus(0, on, pt, dT)); + TEST_MUSTPASS(on != true);TEST_MUSTPASS(pt != 60);TEST_MUSTPASS(dT != 3); + TEST_MUSTPASS(rtp_rtcp->SetRTPKeepaliveStatus(0, false, 60)); - TEST_LOG("Set and get SSRC \n"); - TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 1234)); - unsigned int sendSSRC = 0; - TEST_MUSTPASS(rtp_rtcp->GetLocalSSRC(0, sendSSRC)); - TEST_MUSTPASS(1234 != sendSSRC); + TEST_LOG("Set and get SSRC \n"); + TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 1234)); + unsigned int sendSSRC = 0; + TEST_MUSTPASS(rtp_rtcp->GetLocalSSRC(0, sendSSRC)); + TEST_MUSTPASS(1234 != sendSSRC); #else - TEST_LOG("\n\n+++ RTP/RTCP tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ RTP/RTCP tests NOT ENABLED +++\n"); #endif - ///////////////////////////////////////////////// - // Hardware (test before streaming is activated) - // the test will select the device using 44100, which fails the call + ///////////////////////////////////////////////// + // Hardware (test before streaming is activated) + // the test will select the device using 44100, which fails the call #ifdef _TEST_HARDWARE_ - TEST_LOG("\n\n+++ Hardware tests +++\n\n"); + TEST_LOG("\n\n+++ Hardware tests +++\n\n"); - // Set/GetAudioDeviceLayer - TEST_LOG("Set/Get audio device layer\n"); - TEST_MUSTPASS(-1 != hardware->SetAudioDeviceLayer(wantedLayer)); - TEST_MUSTPASS(VE_ALREADY_INITED != base->LastError()); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - switch (givenLayer) - { + // Set/GetAudioDeviceLayer + TEST_LOG("Set/Get audio device layer\n"); + TEST_MUSTPASS(-1 != hardware->SetAudioDeviceLayer(wantedLayer)); + TEST_MUSTPASS(VE_ALREADY_INITED != base->LastError()); + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + switch (givenLayer) { case kAudioPlatformDefault: - // already set above - break; + // already set above + break; case kAudioWindowsCore: - TEST_LOG("Running kAudioWindowsCore\n"); - break; + TEST_LOG("Running kAudioWindowsCore\n"); + break; case kAudioWindowsWave: - TEST_LOG("Running kAudioWindowsWave\n"); - break; + TEST_LOG("Running kAudioWindowsWave\n"); + break; case kAudioLinuxAlsa: - TEST_LOG("Running kAudioLinuxAlsa\n"); - break; + TEST_LOG("Running kAudioLinuxAlsa\n"); + break; case kAudioLinuxPulse: - TEST_LOG("Running kAudioLinuxPulse\n"); - break; + TEST_LOG("Running kAudioLinuxPulse\n"); + break; default: - TEST_LOG("ERROR: Running unknown audio layer!!\n"); - return -1; - } + TEST_LOG("ERROR: Running unknown audio layer!!\n"); + return -1; + } - int loadPercent; + int loadPercent; #if defined(_WIN32) - TEST_LOG("CPU load \n"); - TEST_MUSTPASS(hardware->GetCPULoad(loadPercent)); - TEST_LOG("GetCPULoad => %d%%\n", loadPercent); + TEST_LOG("CPU load \n"); + TEST_MUSTPASS(hardware->GetCPULoad(loadPercent)); + TEST_LOG("GetCPULoad => %d%%\n", loadPercent); #else - TEST_MUSTPASS(!hardware->GetCPULoad(loadPercent)); + TEST_MUSTPASS(!hardware->GetCPULoad(loadPercent)); #endif #if !defined(MAC_IPHONE) & !defined(WEBRTC_ANDROID) - TEST_MUSTPASS(hardware->GetSystemCPULoad(loadPercent)); - TEST_LOG("GetSystemCPULoad => %d%%\n", loadPercent); + TEST_MUSTPASS(hardware->GetSystemCPULoad(loadPercent)); + TEST_LOG("GetSystemCPULoad => %d%%\n", loadPercent); #endif #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) - bool playAvail = false, recAvail = false; - TEST_LOG("Get device status \n"); - TEST_MUSTPASS(hardware->GetPlayoutDeviceStatus(playAvail)); - TEST_MUSTPASS(hardware->GetRecordingDeviceStatus(recAvail)); - TEST_MUSTPASS(!(recAvail && playAvail)); + bool playAvail = false, recAvail = false; + TEST_LOG("Get device status \n"); + TEST_MUSTPASS(hardware->GetPlayoutDeviceStatus(playAvail)); + TEST_MUSTPASS(hardware->GetRecordingDeviceStatus(recAvail)); + TEST_MUSTPASS(!(recAvail && playAvail)); #endif - // Win, Mac and Linux sound device tests -#if (defined(WEBRTC_MAC) && !defined(MAC_IPHONE)) || defined(_WIN32) || (defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)) - int idx, nRec = 0, nPlay = 0; - char devName[128] = {0}; - char guidName[128] = {0}; + // Win, Mac and Linux sound device tests +#if (defined(WEBRTC_MAC) && !defined(MAC_IPHONE)) || defined(_WIN32) || \ + (defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)) + int idx, nRec = 0, nPlay = 0; + char devName[128] = {0}; + char guidName[128] = {0}; - TEST_LOG("Printing names of default sound devices \n"); + TEST_LOG("Printing names of default sound devices \n"); #if defined(_WIN32) - TEST_MUSTPASS(hardware->GetRecordingDeviceName(-1, devName, guidName)); - TEST_LOG("Recording device= %s, guid=%s\n",devName,guidName); - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(-1, devName, guidName)); - TEST_LOG("Playout device= %s, guid=%s\n",devName,guidName); + TEST_MUSTPASS(hardware->GetRecordingDeviceName(-1, devName, guidName)); + TEST_LOG("Recording device= %s, guid=%s\n",devName,guidName); + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(-1, devName, guidName)); + TEST_LOG("Playout device= %s, guid=%s\n",devName,guidName); #else - TEST_MUSTPASS(hardware->GetRecordingDeviceName(0, devName, guidName)); - TEST_LOG("Recording device= %s\n",devName); - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(0, devName, guidName)); - TEST_LOG("Playout device= %s\n",devName); + TEST_MUSTPASS(hardware->GetRecordingDeviceName(0, devName, guidName)); + TEST_LOG("Recording device= %s\n",devName); + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(0, devName, guidName)); + TEST_LOG("Playout device= %s\n",devName); #endif - // Recording side - TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(nRec)); - TEST_LOG("GetNumOfRecordingDevices = %d\n", nRec); - for (idx = 0; idx < nRec; idx++) - { - // extended Win32 enumeration tests => unique GUID outputs on Vista - // and up - // Win XP and below : devName is copied to guidName - // Win Vista and up : devName is the friendly name and GUID is a uniqe - // indentifier - // Other : guidName is left unchanged - TEST_MUSTPASS(hardware->GetRecordingDeviceName(idx, devName, guidName)); + // Recording side + TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(nRec)); + TEST_LOG("GetNumOfRecordingDevices = %d\n", nRec); + for (idx = 0; idx < nRec; idx++) + { + // extended Win32 enumeration tests => unique GUID outputs on Vista + // and up + // Win XP and below : devName is copied to guidName + // Win Vista and up : devName is the friendly name and GUID is a uniqe + // indentifier + // Other : guidName is left unchanged + TEST_MUSTPASS(hardware->GetRecordingDeviceName(idx, devName, guidName)); #if defined(_WIN32) - TEST_LOG("GetRecordingDeviceName(%d) => name=%s, guid=%s\n", - idx, devName, guidName); + TEST_LOG("GetRecordingDeviceName(%d) => name=%s, guid=%s\n", + idx, devName, guidName); #else - TEST_LOG("GetRecordingDeviceName(%d) => name=%s\n", idx, devName); + TEST_LOG("GetRecordingDeviceName(%d) => name=%s\n", idx, devName); #endif - TEST_MUSTPASS(hardware->SetRecordingDevice(idx)); - } + TEST_MUSTPASS(hardware->SetRecordingDevice(idx)); + } - // Playout side - TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(nPlay)); - TEST_LOG("GetNumDevsPlayout = %d\n", nPlay); - for (idx = 0; idx < nPlay; idx++) - { - // extended Win32 enumeration tests => unique GUID outputs on Vista - // and up - // Win XP and below : devName is copied to guidName - // Win Vista and up : devName is the friendly name and GUID is a - // uniqe indentifier - // Other : guidName is left unchanged - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(idx, devName, guidName)); + // Playout side + TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(nPlay)); + TEST_LOG("GetNumDevsPlayout = %d\n", nPlay); + for (idx = 0; idx < nPlay; idx++) + { + // extended Win32 enumeration tests => unique GUID outputs on Vista + // and up + // Win XP and below : devName is copied to guidName + // Win Vista and up : devName is the friendly name and GUID is a + // uniqe indentifier + // Other : guidName is left unchanged + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(idx, devName, guidName)); #if defined(_WIN32) - TEST_LOG("GetPlayoutDeviceName(%d) => name=%s, guid=%s\n", - idx, devName, guidName); + TEST_LOG("GetPlayoutDeviceName(%d) => name=%s, guid=%s\n", + idx, devName, guidName); #else - TEST_LOG("GetPlayoutDeviceName(%d) => name=%s\n", idx, devName); + TEST_LOG("GetPlayoutDeviceName(%d) => name=%s\n", idx, devName); #endif - TEST_MUSTPASS(hardware->SetPlayoutDevice(idx)); - } + TEST_MUSTPASS(hardware->SetPlayoutDevice(idx)); + } #endif // #if (defined(WEBRTC_MAC) && !defined(MAC_IPHONE)) || (defined(_WI...& - TEST_LOG("Setting default sound devices \n"); + TEST_LOG("Setting default sound devices \n"); #ifdef _WIN32 - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); #else #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) - TEST_MUSTPASS(hardware->SetRecordingDevice(0)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); + TEST_MUSTPASS(hardware->SetRecordingDevice(0)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); #endif #endif #ifdef MAC_IPHONE - // Reset sound device - TEST_LOG("Reset sound device \n"); - TEST_MUSTPASS(hardware->ResetAudioDevice()); + // Reset sound device + TEST_LOG("Reset sound device \n"); + TEST_MUSTPASS(hardware->ResetAudioDevice()); #endif #else - TEST_LOG("\n\n+++ Hardware tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Hardware tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_HARDWARE_ - - // This testing must be done before we start playing + // This testing must be done before we start playing #ifdef _TEST_CODEC_ - // Test that set and get payload type work + // Test that set and get payload type work #if defined(WEBRTC_CODEC_ISAC) - TEST_LOG("Getting payload type for iSAC\n"); - strcpy(cinst.plname,"niklas"); - cinst.channels=1; - cinst.plfreq=16000; - cinst.pacsize=480; - // should fail since niklas is not a valid codec name - TEST_MUSTPASS(!codec->GetRecPayloadType(0,cinst)); - strcpy(cinst.plname,"iSAC"); - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); // both iSAC - strcpy(cinst.plname,"ISAC"); // and ISAC should work - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); - int orgPT=cinst.pltype; // default payload type is 103 - TEST_LOG("Setting payload type for iSAC to 127\n"); - cinst.pltype=123; - TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); - TEST_MUSTPASS(!(cinst.pltype==123)); - TEST_LOG("Setting it back\n"); - cinst.pltype=orgPT; - TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); - TEST_MUSTPASS(!(cinst.pltype==orgPT)); - cinst.pltype=123; - cinst.plfreq=8000; - cinst.pacsize=240; - cinst.rate=13300; + TEST_LOG("Getting payload type for iSAC\n"); + strcpy(cinst.plname, "niklas"); + cinst.channels = 1; + cinst.plfreq = 16000; + cinst.pacsize = 480; + // should fail since niklas is not a valid codec name + TEST_MUSTPASS(!codec->GetRecPayloadType(0,cinst)); + strcpy(cinst.plname, "iSAC"); + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); // both iSAC + strcpy(cinst.plname, "ISAC"); // and ISAC should work + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); + int orgPT = cinst.pltype; // default payload type is 103 + TEST_LOG("Setting payload type for iSAC to 127\n"); + cinst.pltype = 123; + TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); + TEST_MUSTPASS(!(cinst.pltype==123)); + TEST_LOG("Setting it back\n"); + cinst.pltype = orgPT; + TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); + TEST_MUSTPASS(!(cinst.pltype==orgPT)); + cinst.pltype = 123; + cinst.plfreq = 8000; + cinst.pacsize = 240; + cinst.rate = 13300; #ifdef WEBRTC_CODEC_ILBC - strcpy(cinst.plname,"iLBC"); - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); - orgPT=cinst.pltype; - cinst.pltype=123; - TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); - TEST_LOG("Setting it back\n"); - cinst.pltype=orgPT; - TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); - TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); - TEST_MUSTPASS(!(cinst.pltype==orgPT)); + strcpy(cinst.plname, "iLBC"); + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); + orgPT = cinst.pltype; + cinst.pltype = 123; + TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); + TEST_LOG("Setting it back\n"); + cinst.pltype = orgPT; + TEST_MUSTPASS(codec->SetRecPayloadType(0,cinst)); + TEST_MUSTPASS(codec->GetRecPayloadType(0,cinst)); + TEST_MUSTPASS(!(cinst.pltype==orgPT)); #endif // #ifdef WEBRTC_CODEC_ILBC #endif // #if defined(WEBRTC_CODEC_ISAC) #endif // #ifdef _TEST_CODEC_ - - /////////////////////////////////////////////// - // Network (test before streaming is activated) + /////////////////////////////////////////////// + // Network (test before streaming is activated) #ifdef _TEST_NETWORK_ - TEST_LOG("\n\n+++ Network tests +++\n\n"); + TEST_LOG("\n\n+++ Network tests +++\n\n"); #ifndef WEBRTC_EXTERNAL_TRANSPORT - int srcRtpPort = 0; - int srcRtcpPort = 0; + int srcRtpPort = 0; + int srcRtcpPort = 0; - int filtPort = -1; - int filtPortRTCP = -1; - char srcIp[32] = "0.0.0.0"; - char filtIp[32] = "0.0.0.0"; + int filtPort = -1; + int filtPortRTCP = -1; + char srcIp[32] = "0.0.0.0"; + char filtIp[32] = "0.0.0.0"; - TEST_LOG("GetSourceInfo \n"); - srcRtpPort = 1234; - srcRtcpPort = 1235; - TEST_MUSTPASS(netw->GetSourceInfo(0, srcRtpPort, srcRtcpPort, srcIp)); - TEST_MUSTPASS(0 != srcRtpPort); - TEST_MUSTPASS(0 != srcRtcpPort); - TEST_MUSTPASS(_stricmp(srcIp, "")); + TEST_LOG("GetSourceInfo \n"); + srcRtpPort = 1234; + srcRtcpPort = 1235; + TEST_MUSTPASS(netw->GetSourceInfo(0, srcRtpPort, srcRtcpPort, srcIp)); + TEST_MUSTPASS(0 != srcRtpPort); + TEST_MUSTPASS(0 != srcRtcpPort); + TEST_MUSTPASS(_stricmp(srcIp, "")); - TEST_LOG("GetSourceFilter \n"); - TEST_MUSTPASS(netw->GetSourceFilter(0, filtPort, filtPortRTCP, filtIp)); - TEST_MUSTPASS(0 != filtPort); - TEST_MUSTPASS(0 != filtPortRTCP); - TEST_MUSTPASS(_stricmp(filtIp, "")); + TEST_LOG("GetSourceFilter \n"); + TEST_MUSTPASS(netw->GetSourceFilter(0, filtPort, filtPortRTCP, filtIp)); + TEST_MUSTPASS(0 != filtPort); + TEST_MUSTPASS(0 != filtPortRTCP); + TEST_MUSTPASS(_stricmp(filtIp, "")); - TEST_LOG("SetSourceFilter \n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, srcRtpPort)); + TEST_LOG("SetSourceFilter \n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, srcRtpPort)); #else - TEST_LOG("Skipping network tests - WEBRTC_EXTERNAL_TRANSPORT is defined \n"); + TEST_LOG("Skipping network tests - WEBRTC_EXTERNAL_TRANSPORT is defined \n"); #endif // #ifndef WEBRTC_EXTERNAL_TRANSPORT #else - TEST_LOG("\n\n+++ Network tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Network tests NOT ENABLED +++\n"); #endif - /////////////////// - // Start streaming + /////////////////// + // Start streaming + TEST_LOG("\n\n+++ Starting streaming +++\n\n"); - TEST_LOG("\n\n+++ Starting streaming +++\n\n"); + my_transportation ch0transport(netw); - my_transportation ch0transport(netw); - - // goto Exit; + // goto Exit; #ifdef WEBRTC_EXTERNAL_TRANSPORT - TEST_LOG("Enabling external transport \n"); - TEST_MUSTPASS(netw->RegisterExternalTransport(0, ch0transport)); + TEST_LOG("Enabling external transport \n"); + TEST_MUSTPASS(netw->RegisterExternalTransport(0, ch0transport)); #else - TEST_LOG("Setting send and receive parameters \n"); - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - // no IP specified => "0.0.0.0" will be stored - TEST_MUSTPASS(base->SetLocalReceiver(0,8000)); + TEST_LOG("Setting send and receive parameters \n"); + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + // no IP specified => "0.0.0.0" will be stored + TEST_MUSTPASS(base->SetLocalReceiver(0,8000)); - CodecInst Jing_inst; - Jing_inst.channels=1; - Jing_inst.pacsize=160; - Jing_inst.plfreq=8000; - Jing_inst.pltype=0; - Jing_inst.rate=64000; - strcpy(Jing_inst.plname, "PCMU"); - TEST_MUSTPASS(codec->SetSendCodec(0, Jing_inst)); + CodecInst Jing_inst; + Jing_inst.channels = 1; + Jing_inst.pacsize = 160; + Jing_inst.plfreq = 8000; + Jing_inst.pltype = 0; + Jing_inst.rate = 64000; + strcpy(Jing_inst.plname, "PCMU"); + TEST_MUSTPASS(codec->SetSendCodec(0, Jing_inst)); - int port = -1, srcPort = -1, rtcpPort = -1; - char ipaddr[64] = {0}; - strcpy(ipaddr, "10.10.10.10"); - TEST_MUSTPASS(base->GetSendDestination(0, port, ipaddr, srcPort, rtcpPort)); - TEST_MUSTPASS(8000 != port); - TEST_MUSTPASS(8000 != srcPort); - TEST_MUSTPASS(8001 != rtcpPort); - TEST_MUSTPASS(_stricmp(ipaddr, "127.0.0.1")); + int port = -1, srcPort = -1, rtcpPort = -1; + char ipaddr[64] = { 0 }; + strcpy(ipaddr, "10.10.10.10"); + TEST_MUSTPASS(base->GetSendDestination(0, port, ipaddr, srcPort, rtcpPort)); + TEST_MUSTPASS(8000 != port); + TEST_MUSTPASS(8000 != srcPort); + TEST_MUSTPASS(8001 != rtcpPort); + TEST_MUSTPASS(_stricmp(ipaddr, "127.0.0.1")); - port = -1; rtcpPort = -1; - TEST_MUSTPASS(base->GetLocalReceiver(0, port, rtcpPort, ipaddr)); - TEST_MUSTPASS(8000 != port); - TEST_MUSTPASS(8001 != rtcpPort); - TEST_MUSTPASS(_stricmp(ipaddr, "0.0.0.0")); + port = -1; + rtcpPort = -1; + TEST_MUSTPASS(base->GetLocalReceiver(0, port, rtcpPort, ipaddr)); + TEST_MUSTPASS(8000 != port); + TEST_MUSTPASS(8001 != rtcpPort); + TEST_MUSTPASS(_stricmp(ipaddr, "0.0.0.0")); #endif - TEST_LOG("Start listening, playout and sending \n"); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Start listening, playout and sending \n"); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); - // <=== full duplex ===> + // <=== full duplex ===> + TEST_LOG("You should now hear yourself, running default codec (PCMU)\n"); + SLEEP(2000); - TEST_LOG("You should now hear yourself, running default codec (PCMU)\n"); - SLEEP(2000); - - if (file) - { - TEST_LOG("Start playing a file as microphone, so you don't need to" - " speak all the time\n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - SLEEP(1000); - } + if (file) { + TEST_LOG("Start playing a file as microphone, so you don't need to" + " speak all the time\n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + SLEEP(1000); + } #ifdef _TEST_BASE_ - TEST_LOG("Put channel on hold => should *not* hear audio \n"); - // HOLD_SEND_AND_PLAY is the default mode - TEST_MUSTPASS(base->SetOnHoldStatus(0, true)); - SLEEP(2000); - TEST_LOG("Remove on hold => should hear audio again \n"); - TEST_MUSTPASS(base->SetOnHoldStatus(0, false)); - SLEEP(2000); - TEST_LOG("Put sending on hold => should *not* hear audio \n"); - TEST_MUSTPASS(base->SetOnHoldStatus(0, true, kHoldSendOnly)); - SLEEP(2000); - if (file) - { - TEST_LOG("Start playing a file locally => " - "you should now hear this file being played out \n"); - TEST_MUSTPASS(file->StartPlayingFileLocally(0, AudioFilename(), - true)); - SLEEP(2000); - } - TEST_LOG("Put playing on hold => should *not* hear audio \n"); - TEST_MUSTPASS(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); - SLEEP(2000); - TEST_LOG("Remove on hold => should hear audio again \n"); - if (file) - { - TEST_MUSTPASS(file->StopPlayingFileLocally(0)); - } - TEST_MUSTPASS(base->SetOnHoldStatus(0, false)); + TEST_LOG("Put channel on hold => should *not* hear audio \n"); + // HOLD_SEND_AND_PLAY is the default mode + TEST_MUSTPASS(base->SetOnHoldStatus(0, true)); + SLEEP(2000); + TEST_LOG("Remove on hold => should hear audio again \n"); + TEST_MUSTPASS(base->SetOnHoldStatus(0, false)); + SLEEP(2000); + TEST_LOG("Put sending on hold => should *not* hear audio \n"); + TEST_MUSTPASS(base->SetOnHoldStatus(0, true, kHoldSendOnly)); + SLEEP(2000); + if (file) { + TEST_LOG("Start playing a file locally => " + "you should now hear this file being played out \n"); + TEST_MUSTPASS(file->StartPlayingFileLocally(0, AudioFilename(), + true)); SLEEP(2000); + } + TEST_LOG("Put playing on hold => should *not* hear audio \n"); + TEST_MUSTPASS(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); + SLEEP(2000); + TEST_LOG("Remove on hold => should hear audio again \n"); + if (file) { + TEST_MUSTPASS(file->StopPlayingFileLocally(0)); + } + TEST_MUSTPASS(base->SetOnHoldStatus(0, false)); + SLEEP(2000); - NetEqModes mode; - TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); - TEST_MUSTPASS(mode != kNetEqDefault); - TEST_LOG("NetEQ DEFAULT playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); - SLEEP(3000); - TEST_LOG("NetEQ STREAMING playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqStreaming)); - SLEEP(3000); - TEST_LOG("NetEQ FAX playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqFax)); - SLEEP(3000); - TEST_LOG("NetEQ default mode is restored \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); - TEST_MUSTPASS(mode != kNetEqDefault); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); - TEST_MUSTPASS(mode != kNetEqDefault); - TEST_LOG("NetEQ DEFAULT playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); - SLEEP(3000); - TEST_LOG("NetEQ STREAMING playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqStreaming)); - SLEEP(3000); - TEST_LOG("NetEQ FAX playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqFax)); - SLEEP(3000); - TEST_LOG("NetEQ default mode is restored \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); - TEST_MUSTPASS(mode != kNetEqDefault); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); - TEST_MUSTPASS(mode != kNetEqDefault); - TEST_LOG("NetEQ DEFAULT playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); - SLEEP(3000); - TEST_LOG("NetEQ STREAMING playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqStreaming)); - SLEEP(3000); - TEST_LOG("NetEQ FAX playout mode enabled => should hear OK audio \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqFax)); - SLEEP(3000); - TEST_LOG("NetEQ default mode is restored \n"); - TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); - TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); - TEST_MUSTPASS(mode != kNetEqDefault); + NetEqModes mode; + TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); + TEST_MUSTPASS(mode != kNetEqDefault); + TEST_LOG("NetEQ DEFAULT playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); + SLEEP(3000); + TEST_LOG("NetEQ STREAMING playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqStreaming)); + SLEEP(3000); + TEST_LOG("NetEQ FAX playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqFax)); + SLEEP(3000); + TEST_LOG("NetEQ default mode is restored \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); + TEST_MUSTPASS(mode != kNetEqDefault); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); + TEST_MUSTPASS(mode != kNetEqDefault); + TEST_LOG("NetEQ DEFAULT playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); + SLEEP(3000); + TEST_LOG("NetEQ STREAMING playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqStreaming)); + SLEEP(3000); + TEST_LOG("NetEQ FAX playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqFax)); + SLEEP(3000); + TEST_LOG("NetEQ default mode is restored \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); + TEST_MUSTPASS(mode != kNetEqDefault); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); + TEST_MUSTPASS(mode != kNetEqDefault); + TEST_LOG("NetEQ DEFAULT playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); + SLEEP(3000); + TEST_LOG("NetEQ STREAMING playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqStreaming)); + SLEEP(3000); + TEST_LOG("NetEQ FAX playout mode enabled => should hear OK audio \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqFax)); + SLEEP(3000); + TEST_LOG("NetEQ default mode is restored \n"); + TEST_MUSTPASS(base->SetNetEQPlayoutMode(0, kNetEqDefault)); + TEST_MUSTPASS(base->GetNetEQPlayoutMode(0, mode)); + TEST_MUSTPASS(mode != kNetEqDefault); - TEST_LOG("Scan all possible NetEQ BGN modes\n"); // skip listening test - enum NetEqBgnModes bgnMode; - TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); - TEST_MUSTPASS(bgnMode != kBgnOn); - TEST_MUSTPASS(base->SetNetEQBGNMode(0, kBgnOn)); - TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); - TEST_MUSTPASS(bgnMode != kBgnOn); - TEST_MUSTPASS(base->SetNetEQBGNMode(0, kBgnFade)); - TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); - TEST_MUSTPASS(bgnMode != kBgnFade); - TEST_MUSTPASS(base->SetNetEQBGNMode(0, kBgnOff)); - TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); - TEST_MUSTPASS(bgnMode != kBgnOff); + TEST_LOG("Scan all possible NetEQ BGN modes\n"); // skip listening test + enum NetEqBgnModes bgnMode; + TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); + TEST_MUSTPASS(bgnMode != kBgnOn); + TEST_MUSTPASS(base->SetNetEQBGNMode(0, kBgnOn)); + TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); + TEST_MUSTPASS(bgnMode != kBgnOn); + TEST_MUSTPASS(base->SetNetEQBGNMode(0, kBgnFade)); + TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); + TEST_MUSTPASS(bgnMode != kBgnFade); + TEST_MUSTPASS(base->SetNetEQBGNMode(0, kBgnOff)); + TEST_MUSTPASS(base->GetNetEQBGNMode(0, bgnMode)); + TEST_MUSTPASS(bgnMode != kBgnOff); #else - TEST_LOG("Skipping on hold and NetEQ playout tests -" - "Base tests are not enabled \n"); + TEST_LOG("Skipping on hold and NetEQ playout tests -" + "Base tests are not enabled \n"); #endif // #ifdef _TEST_BASE_ - - ///////// - // Codec + ///////// + // Codec #ifdef _TEST_CODEC_ - TEST_LOG("\n\n+++ Codec tests +++\n\n"); + TEST_LOG("\n\n+++ Codec tests +++\n\n"); - TEST_LOG("Checking default codec\n"); - TEST_MUSTPASS(codec->GetSendCodec(0, cinst)); - TEST_MUSTPASS(cinst.channels != 1); - TEST_MUSTPASS(cinst.pacsize != 160); - TEST_MUSTPASS(cinst.plfreq != 8000); - TEST_MUSTPASS(cinst.pltype != 0); - TEST_MUSTPASS(cinst.rate != 64000); - TEST_MUSTPASS(strcmp("PCMU", cinst.plname) != 0); + TEST_LOG("Checking default codec\n"); + TEST_MUSTPASS(codec->GetSendCodec(0, cinst)); + TEST_MUSTPASS(cinst.channels != 1); + TEST_MUSTPASS(cinst.pacsize != 160); + TEST_MUSTPASS(cinst.plfreq != 8000); + TEST_MUSTPASS(cinst.pltype != 0); + TEST_MUSTPASS(cinst.rate != 64000); + TEST_MUSTPASS(strcmp("PCMU", cinst.plname) != 0); - TEST_LOG("Looping through all codecs and packet sizes\n"); - TEST_LOG("NOTE: For swb codecs, ensure that you speak in the mic\n"); - int nCodecs = codec->NumOfCodecs(); - for (int index = 0; index < nCodecs; index++) - { - TEST_MUSTPASS(codec->GetCodec(index, cinst)); + TEST_LOG("Looping through all codecs and packet sizes\n"); + TEST_LOG("NOTE: For swb codecs, ensure that you speak in the mic\n"); + int nCodecs = codec->NumOfCodecs(); + for (int index = 0; index < nCodecs; index++) { + TEST_MUSTPASS(codec->GetCodec(index, cinst)); - if (!((!_stricmp("CN", cinst.plname)) || - (!_stricmp("telephone-event", cinst.plname) || - (!_stricmp("red",cinst.plname))))) - { - // If no default payload type is defined, we use 127 and also set - // receive payload type - if (-1 == cinst.pltype) - { - cinst.pltype = 127; + if (!((!_stricmp("CN", cinst.plname)) || + (!_stricmp("telephone-event", cinst.plname) || + (!_stricmp("red", cinst.plname))))) { + // If no default payload type is defined, we use 127 and also set + // receive payload type + if (-1 == cinst.pltype) { + cinst.pltype = 127; + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + } + TEST_LOG("%s (pt=%d): default(%d) ", cinst.plname, cinst.pltype, + cinst.pacsize); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + SLEEP(CODEC_TEST_TIME); + // Packet sizes + if (!_stricmp("g7221", cinst.plname)) // special case for G.722.1 + { + // Test 16 and 32 kHz + for (int freq = 16000; freq <= 32000; freq += 16000) { + cinst.plfreq = freq; + // Test 16/24/32 and 24/32/48 kbit respectively + int rate = (16000 == freq ? 16000 : 24000); + int maxRate = (16000 == freq ? 32000 : 40000); + // In fact 48, see below + for (; rate <= maxRate; rate += 8000) { + rate = (40000 == rate ? 48000 : rate); // 40 -> 48 + cinst.rate = rate; + // Test packet sizes + TEST_LOG("\n%s (pt=%d, fs=%d, rate=%d): ", cinst.plname, + cinst.pltype, cinst.plfreq, cinst.rate); + for (int pacsize = 80; pacsize < 1000; pacsize += 80) { + // Set codec, and receive payload type + cinst.pacsize = pacsize; + if (-1 != codec->SetSendCodec(0, cinst)) { TEST_MUSTPASS(base->StopPlayout(0)); TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, cinst)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, + cinst)); TEST_MUSTPASS(base->StartReceive(0)); TEST_MUSTPASS(base->StartPlayout(0)); + TEST_LOG("%d ", pacsize); + fflush(NULL); + SLEEP(2 * CODEC_TEST_TIME); + } } - TEST_LOG("%s (pt=%d): default(%d) ", cinst.plname, cinst.pltype, - cinst.pacsize); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - SLEEP(CODEC_TEST_TIME); - // Packet sizes - if (!_stricmp("g7221", cinst.plname)) // special case for G.722.1 - { - // Test 16 and 32 kHz - for (int freq = 16000; freq <= 32000; freq += 16000) - { - cinst.plfreq = freq; - // Test 16/24/32 and 24/32/48 kbit respectively - int rate = (16000 == freq ? 16000 : 24000); - int maxRate = (16000 == freq ? 32000 : 40000); - // In fact 48, see below - for (; rate <= maxRate; rate += 8000) - { - rate = (40000 == rate ? 48000 : rate); // 40 -> 48 - cinst.rate = rate; - // Test packet sizes - TEST_LOG("\n%s (pt=%d, fs=%d, rate=%d): ", - cinst.plname, cinst.pltype, - cinst.plfreq, cinst.rate); - for (int pacsize = 80; pacsize < 1000; pacsize += 80) - { - // Set codec, and receive payload type - cinst.pacsize = pacsize; - if (-1 != codec->SetSendCodec(0, cinst)) - { - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, - cinst)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_LOG("%d ", pacsize); - fflush(NULL); - SLEEP(2*CODEC_TEST_TIME); - } - } - } - } - } - else - { - for (int pacsize = 80; pacsize < 1000; pacsize += 80) - { - // Set codec - // from VoE 4.0, we need the specify the right rate - if (!_stricmp("ilbc", cinst.plname)) - { - - if((pacsize == 160) || (pacsize == 320)) - { - cinst.rate = 15200; - } - else - { - cinst.rate = 13300; - } - } - cinst.pacsize = pacsize; - if (-1 != codec->SetSendCodec(0, cinst)) - { - TEST_LOG("%d ", pacsize); - fflush(NULL); - SLEEP(CODEC_TEST_TIME); - } - } - } - TEST_LOG("\n"); + } } + } else { + for (int pacsize = 80; pacsize < 1000; pacsize += 80) { + // Set codec + // from VoE 4.0, we need the specify the right rate + if (!_stricmp("ilbc", cinst.plname)) { + + if ((pacsize == 160) || (pacsize == 320)) { + cinst.rate = 15200; + } else { + cinst.rate = 13300; + } + } + cinst.pacsize = pacsize; + if (-1 != codec->SetSendCodec(0, cinst)) { + TEST_LOG("%d ", pacsize); + fflush(NULL); + SLEEP(CODEC_TEST_TIME); + } + } + } + TEST_LOG("\n"); } + } - TEST_MUSTPASS(codec->GetCodec(0, cinst)); - TEST_LOG("Setting codec to first in list: %s \n", cinst.plname); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(codec->GetCodec(0, cinst)); + TEST_LOG("Setting codec to first in list: %s \n", cinst.plname); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_LOG("Voice Activity Detection calls\n"); - TEST_LOG("Must be OFF by default\n"); - bool VADtest = true; - VadModes vadMode = kVadAggressiveHigh; - bool disabledDTX = true; - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabledDTX); + TEST_LOG("Voice Activity Detection calls\n"); + TEST_LOG("Must be OFF by default\n"); + bool VADtest = true; + VadModes vadMode = kVadAggressiveHigh; + bool disabledDTX = true; + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(!disabledDTX); - TEST_LOG("Turn ON VAD\n"); - TEST_MUSTPASS(codec->SetVADStatus(0, true)); - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(!VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(!VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(!VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabledDTX); + TEST_LOG("Turn ON VAD\n"); + TEST_MUSTPASS(codec->SetVADStatus(0, true)); + TEST_LOG("Should be ON now\n"); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(!VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(!VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(!VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(disabledDTX); - TEST_LOG("Testing Type settings\n"); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveLow)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveLow != vadMode); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveMid != vadMode); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveMid != vadMode); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveMid != vadMode); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh, true)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh, true)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh, true)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadConventional)); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabledDTX); + TEST_LOG("Testing Type settings\n"); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveLow)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveLow != vadMode); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveMid != vadMode); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveMid != vadMode); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveMid)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveMid != vadMode); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh, true)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveHigh != vadMode); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh, true)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveHigh != vadMode); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadAggressiveHigh, true)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveHigh != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveHigh != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadAggressiveHigh != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->SetVADStatus(0, true, kVadConventional)); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(disabledDTX); - // VAD is always on when DTX is on, so we need to turn off DTX too - TEST_LOG("Turn OFF VAD\n"); - TEST_MUSTPASS(codec->SetVADStatus(0, false, kVadConventional, true)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabledDTX); - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabledDTX); + // VAD is always on when DTX is on, so we need to turn off DTX too + TEST_LOG("Turn OFF VAD\n"); + TEST_MUSTPASS(codec->SetVADStatus(0, false, kVadConventional, true)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(!disabledDTX); + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(kVadConventional != vadMode); + TEST_MUSTPASS(!disabledDTX); #if defined(WEBRTC_CODEC_ISAC) - TEST_LOG("Test extended iSAC APIs\n"); - TEST_LOG("Start by selecting iSAC 30ms adaptive mode\n"); - strcpy(cinst.plname,"isac"); - cinst.pltype=103; - cinst.plfreq=16000; - cinst.channels=1; - cinst.rate=-1; // adaptive rate - cinst.pacsize=480; - TEST_LOG(" testing SetISACInitTargetRate:\n"); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 5000)); - TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 33000)); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000)); - TEST_LOG("Speak and ensure that iSAC sounds OK (target = 32kbps)...\n"); - SLEEP(3000); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000)); - TEST_LOG("Speak and ensure that iSAC sounds OK (target = 10kbps)...\n"); - SLEEP(3000); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000, true)); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000, false)); - TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 0)); - TEST_LOG("Speak and ensure that iSAC sounds OK (target = default)...\n"); - SLEEP(3000); + TEST_LOG("Test extended iSAC APIs\n"); + TEST_LOG("Start by selecting iSAC 30ms adaptive mode\n"); + strcpy(cinst.plname, "isac"); + cinst.pltype = 103; + cinst.plfreq = 16000; + cinst.channels = 1; + cinst.rate = -1; // adaptive rate + cinst.pacsize = 480; + TEST_LOG(" testing SetISACInitTargetRate:\n"); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 5000)); + TEST_MUSTPASS(!codec->SetISACInitTargetRate(0, 33000)); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 32000)); + TEST_LOG("Speak and ensure that iSAC sounds OK (target = 32kbps)...\n"); + SLEEP(3000); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000)); + TEST_LOG("Speak and ensure that iSAC sounds OK (target = 10kbps)...\n"); + SLEEP(3000); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000, true)); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 10000, false)); + TEST_MUSTPASS(codec->SetISACInitTargetRate(0, 0)); + TEST_LOG("Speak and ensure that iSAC sounds OK (target = default)...\n"); + SLEEP(3000); - TEST_LOG(" testing SetISACMaxPayloadSize:\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 50)); - TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 650)); - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 120)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Speak and ensure that iSAC sounds OK" - "(max payload size = 100 bytes)...\n"); - SLEEP(3000); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 400)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG(" testing SetISACMaxPayloadSize:\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 50)); + TEST_MUSTPASS(!codec->SetISACMaxPayloadSize(0, 650)); + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 120)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Speak and ensure that iSAC sounds OK" + "(max payload size = 100 bytes)...\n"); + SLEEP(3000); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(codec->SetISACMaxPayloadSize(0, 400)); + TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG(" testing SetISACMaxRate:\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); - TEST_MUSTPASS(!codec->SetISACMaxRate(0, 53500)); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Speak and ensure that iSAC sounds OK (max rate = 32 kbps)...\n"); - SLEEP(3000); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(codec->SetISACMaxRate(0, 53400)); // restore no limitation - TEST_MUSTPASS(base->StartSend(0)); - if (file) - { - TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - 0, AudioFilename(), true, true)); - } + TEST_LOG(" testing SetISACMaxRate:\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 31900)); + TEST_MUSTPASS(!codec->SetISACMaxRate(0, 53500)); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 32000)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Speak and ensure that iSAC sounds OK (max rate = 32 kbps)...\n"); + SLEEP(3000); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(codec->SetISACMaxRate(0, 53400)); // restore no limitation + TEST_MUSTPASS(base->StartSend(0)); + if (file) { + TEST_LOG("==> Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, AudioFilename(), true, true)); + } #else - TEST_LOG("Skipping extended iSAC API tests - " - "WEBRTC_CODEC_ISAC not defined\n"); + TEST_LOG("Skipping extended iSAC API tests - " + "WEBRTC_CODEC_ISAC not defined\n"); #endif // #if defined(WEBRTC_CODEC_ISAC) + // Tests on AMR setencformat and setdecformat + // These should fail + TEST_MUSTPASS(!codec->SetAMREncFormat(0, kRfc3267BwEfficient)); + TEST_MUSTPASS(!codec->SetAMRDecFormat(0, kRfc3267BwEfficient)); + TEST_MUSTPASS(!codec->SetAMREncFormat(0, kRfc3267OctetAligned)); + TEST_MUSTPASS(!codec->SetAMRDecFormat(0, kRfc3267OctetAligned)); + TEST_MUSTPASS(!codec->SetAMREncFormat(0, kRfc3267FileStorage)); + TEST_MUSTPASS(!codec->SetAMRDecFormat(0, kRfc3267FileStorage)); - // Tests on AMR setencformat and setdecformat - // These should fail - TEST_MUSTPASS(!codec->SetAMREncFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!codec->SetAMRDecFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!codec->SetAMREncFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!codec->SetAMRDecFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!codec->SetAMREncFormat(0, kRfc3267FileStorage)); - TEST_MUSTPASS(!codec->SetAMRDecFormat(0, kRfc3267FileStorage)); + // Tests on AMRWB setencformat and setdecformat + // These should fail + TEST_MUSTPASS(!codec->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); + TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0, kRfc3267BwEfficient)); + TEST_MUSTPASS(!codec->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); + TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0, kRfc3267OctetAligned)); + TEST_MUSTPASS(!codec->SetAMRWbEncFormat(0, kRfc3267FileStorage)); + TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0, kRfc3267FileStorage)); - // Tests on AMRWB setencformat and setdecformat - // These should fail - TEST_MUSTPASS(!codec->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!codec->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!codec->SetAMRWbEncFormat(0, kRfc3267FileStorage)); - TEST_MUSTPASS(!codec->SetAMRWbDecFormat(0, kRfc3267FileStorage)); + TEST_LOG("Turn on VAD,G711 and set packet size to 30 ms:\n"); + strcpy(cinst.plname, "pcmu"); + cinst.pacsize = 160; + cinst.pltype = 0; + cinst.plfreq = 8000; + cinst.channels = 1; + cinst.rate = 64000; + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + // The test here is confusing, what are we expecting? VADtest = false? + TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); + TEST_MUSTPASS(VADtest); + TEST_MUSTPASS(codec->SetVADStatus(0, false, vadMode, true)); - TEST_LOG("Turn on VAD,G711 and set packet size to 30 ms:\n"); - strcpy(cinst.plname,"pcmu"); - cinst.pacsize=160; - cinst.pltype=0; - cinst.plfreq=8000; - cinst.channels=1; - cinst.rate=64000; - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); - // The test here is confusing, what are we expecting? VADtest = false? - TEST_MUSTPASS(codec->GetVADStatus(0, VADtest, vadMode, disabledDTX)); - TEST_MUSTPASS(VADtest); - TEST_MUSTPASS(codec->SetVADStatus(0, false, vadMode, true)); - - // Set back to preferred codec - TEST_MUSTPASS(codec->GetCodec(0, cinst)); - TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); + // Set back to preferred codec + TEST_MUSTPASS(codec->GetCodec(0, cinst)); + TEST_MUSTPASS(codec->SetSendCodec(0, cinst)); #else - TEST_LOG("\n\n+++ Codec tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Codec tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_CODEC_ - - ///////////////////////// - // Start another channel + ///////////////////////// + // Start another channel #if defined(_TEST_RTP_RTCP_) - TEST_LOG("\n\n+++ Preparing another channel for" - " RTP/RTCP tests +++ \n\n"); + TEST_LOG("\n\n+++ Preparing another channel for" + " RTP/RTCP tests +++ \n\n"); - TEST_LOG("Create one more channel and start it up\n"); - TEST_MUSTPASS(!(1==base->CreateChannel())); + TEST_LOG("Create one more channel and start it up\n"); + TEST_MUSTPASS(!(1==base->CreateChannel())); #ifdef WEBRTC_EXTERNAL_TRANSPORT - my_transportation ch1transport(netw); - TEST_MUSTPASS(netw->RegisterExternalTransport(1, ch1transport)); + my_transportation ch1transport(netw); + TEST_MUSTPASS(netw->RegisterExternalTransport(1, ch1transport)); #else - TEST_MUSTPASS(base->SetSendDestination(1, 8002, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(1, 8002)); + TEST_MUSTPASS(base->SetSendDestination(1, 8002, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(1, 8002)); #endif - TEST_MUSTPASS(base->StartReceive(1)); - TEST_MUSTPASS(base->StartPlayout(1)); - TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(1, 5678)); // ensures SSSR_ch1 = 5678 - TEST_MUSTPASS(base->StartSend(1)); - SLEEP(2000); + TEST_MUSTPASS(base->StartReceive(1)); + TEST_MUSTPASS(base->StartPlayout(1)); + TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(1, 5678)); // ensures SSSR_ch1 = 5678 + TEST_MUSTPASS(base->StartSend(1)); + SLEEP(2000); #else - TEST_LOG("\n\n+++ Preparing another channel NOT NEEDED +++ \n"); + TEST_LOG("\n\n+++ Preparing another channel NOT NEEDED +++ \n"); #endif // defined(_TEST_RTP_RTCP_) - - ///////////////// - // Conferencing + ///////////////// + // Conferencing #ifndef _TEST_BASE_ - TEST_LOG("\n\n+++ (Base) tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ (Base) tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_BASE_ - - //////////////////////////////////////////////// - // RTP/RTCP (test after streaming is activated) + //////////////////////////////////////////////// + // RTP/RTCP (test after streaming is activated) #if (defined(_TEST_RTP_RTCP_) && defined(_TEST_BASE_)) - TEST_LOG("\n\n+++ More RTP/RTCP tests +++\n\n"); + TEST_LOG("\n\n+++ More RTP/RTCP tests +++\n\n"); - SLEEP(8000); - - TEST_LOG("Check that we have gotten RTCP packet, and collected CName\n"); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_LOG("default cname is %s", tmpStr); - TEST_MUSTPASS(_stricmp("Niklas", tmpStr)); - - TEST_LOG("Check that we have received the right SSRC\n"); - unsigned int ssrc1; - TEST_MUSTPASS(rtp_rtcp->GetLocalSSRC(0, ssrc1)); - TEST_LOG("SSRC chan 0 = %lu \n", (long unsigned int) ssrc1); - TEST_MUSTPASS(rtp_rtcp->GetRemoteSSRC(0, ssrc1)); - // the originally set 1234 should be maintained - TEST_MUSTPASS(1234 != ssrc1); - - - - // RTCP APP tests - TEST_LOG("Check RTCP APP send/receive \n"); - TEST_MUSTPASS(rtp_rtcp->RegisterRTCPObserver(0, myRtcpAppHandler)); - SLEEP(100); - // send RTCP APP packet (fill up data message to multiple of 32 bits) - const char* data = "application-dependent data------"; // multiple of 32byte - unsigned short lenBytes(static_cast(strlen(data))); - unsigned int name = static_cast(0x41424344); // 'ABCD'; - unsigned char subType = 1; - TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket(0, - subType, - name, - data, - lenBytes)); - TEST_LOG("Waiting for RTCP APP callback...\n"); - SLEEP(8000); // ensures that RTCP is scheduled - TEST_MUSTPASS(strlen(data) != myRtcpAppHandler._lengthBytes); - TEST_MUSTPASS(memcmp(data, myRtcpAppHandler._data, lenBytes)); - TEST_MUSTPASS(myRtcpAppHandler._name != name); - TEST_MUSTPASS(myRtcpAppHandler._subType != subType); - TEST_LOG("=> application-dependent data of size %d bytes was received\n", - lenBytes); - // disable the callback and verify that no callback is received this time - myRtcpAppHandler.Reset(); - TEST_MUSTPASS(rtp_rtcp->DeRegisterRTCPObserver(0)); - - TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket(0, - subType, - name, - data, - lenBytes)); - TEST_LOG("RTCP APP callback should not be received since the observer " - "is disabled...\n"); - SLEEP(5000); // ensures that RTCP is scheduled - TEST_MUSTPASS(myRtcpAppHandler._name != 0); - TEST_MUSTPASS(myRtcpAppHandler._subType != 0); + SLEEP(8000); + TEST_LOG("Check that we have gotten RTCP packet, and collected CName\n"); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_LOG("default cname is %s", tmpStr); + TEST_MUSTPASS(_stricmp("Niklas", tmpStr)); + TEST_LOG("Check that we have received the right SSRC\n"); + unsigned int ssrc1; + TEST_MUSTPASS(rtp_rtcp->GetLocalSSRC(0, ssrc1)); + TEST_LOG("SSRC chan 0 = %lu \n", (long unsigned int) ssrc1); + TEST_MUSTPASS(rtp_rtcp->GetRemoteSSRC(0, ssrc1)); + // the originally set 1234 should be maintained + TEST_MUSTPASS(1234 != ssrc1); + // RTCP APP tests + TEST_LOG("Check RTCP APP send/receive \n"); + TEST_MUSTPASS(rtp_rtcp->RegisterRTCPObserver(0, myRtcpAppHandler)); + SLEEP(100); + // send RTCP APP packet (fill up data message to multiple of 32 bits) + const char* data = "application-dependent data------"; // multiple of 32byte + unsigned short lenBytes(static_cast (strlen(data))); + unsigned int name = static_cast (0x41424344); // 'ABCD'; + unsigned char subType = 1; + TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket(0, + subType, + name, + data, + lenBytes)); + TEST_LOG("Waiting for RTCP APP callback...\n"); + SLEEP(8000); // ensures that RTCP is scheduled + TEST_MUSTPASS(strlen(data) != myRtcpAppHandler._lengthBytes); + TEST_MUSTPASS(memcmp(data, myRtcpAppHandler._data, lenBytes)); + TEST_MUSTPASS(myRtcpAppHandler._name != name); + TEST_MUSTPASS(myRtcpAppHandler._subType != subType); + TEST_LOG("=> application-dependent data of size %d bytes was received\n", + lenBytes); + // disable the callback and verify that no callback is received this time + myRtcpAppHandler.Reset(); + TEST_MUSTPASS(rtp_rtcp->DeRegisterRTCPObserver(0)); + TEST_MUSTPASS(rtp_rtcp->SendApplicationDefinedRTCPPacket(0, + subType, + name, + data, + lenBytes)); + TEST_LOG("RTCP APP callback should not be received since the observer " + "is disabled...\n"); + SLEEP(5000); // ensures that RTCP is scheduled + TEST_MUSTPASS(myRtcpAppHandler._name != 0); + TEST_MUSTPASS(myRtcpAppHandler._subType != 0); #if !defined(WEBRTC_EXTERNAL_TRANSPORT) - printf("Tesing InsertExtraRTPPacket\n"); + printf("Tesing InsertExtraRTPPacket\n"); - const char payloadData[8] = {'A','B','C','D','E','F','G','H'}; + const char payloadData[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }; - // fail tests - // invalid channel - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(-1, - 0, - false, - payloadData, - 8)); - // invalid payload type - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, - -1, - false, - payloadData, - 8)); - // invalid payload type - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, - 128, - false, - payloadData, - 8)); - // invalid pointer - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, - 99, - false, - NULL, - 8)); - // invalid size - TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, - 99, - false, - payloadData, - 1500 - 28 + 1)); + // fail tests + // invalid channel + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(-1, + 0, + false, + payloadData, + 8)); + // invalid payload type + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, + -1, + false, + payloadData, + 8)); + // invalid payload type + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, + 128, + false, + payloadData, + 8)); + // invalid pointer + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, + 99, + false, + NULL, + 8)); + // invalid size + TEST_MUSTPASS(-1 != rtp_rtcp->InsertExtraRTPPacket(0, + 99, + false, + payloadData, + 1500 - 28 + 1)); - // transmit some extra RTP packets - for (int pt = 0; pt < 128; pt++) - { - TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, - pt, - false, - payloadData, - 8)); - TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, - pt, - true, - payloadData, - 8)); - } + // transmit some extra RTP packets + for (int pt = 0; pt < 128; pt++) { + TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, + pt, + false, + payloadData, + 8)); + TEST_MUSTPASS(rtp_rtcp->InsertExtraRTPPacket(0, + pt, + true, + payloadData, + 8)); + } #else - printf("Skipping InsertExtraRTPPacket tests -" - " WEBRTC_EXTERNAL_TRANSPORT is defined \n"); + printf("Skipping InsertExtraRTPPacket tests -" + " WEBRTC_EXTERNAL_TRANSPORT is defined \n"); #endif - TEST_LOG("Enable the RTP observer\n"); - TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(0, rtpObserver)); - TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(1, rtpObserver)); - rtpObserver.Reset(); + TEST_LOG("Enable the RTP observer\n"); + TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(0, rtpObserver)); + TEST_MUSTPASS(rtp_rtcp->RegisterRTPObserver(1, rtpObserver)); + rtpObserver.Reset(); - // Create two RTP-dump files (3 seconds long). - // Verify using rtpplay or NetEqRTPplay when test is done. - TEST_LOG("Creating two RTP-dump files...\n"); - TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, - GetFilename("dump_in_3sec.rtp"), - kRtpIncoming)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, - GetFilename("dump_out_3sec.rtp"), - kRtpOutgoing)); - MARK(); - SLEEP(3000); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpIncoming)); - MARK(); - TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpOutgoing)); - MARK(); + // Create two RTP-dump files (3 seconds long). + // Verify using rtpplay or NetEqRTPplay when test is done. + TEST_LOG("Creating two RTP-dump files...\n"); + TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, + GetFilename("dump_in_3sec.rtp"), + kRtpIncoming)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->StartRTPDump(0, + GetFilename("dump_out_3sec.rtp"), + kRtpOutgoing)); + MARK(); + SLEEP(3000); + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpIncoming)); + MARK(); + TEST_MUSTPASS(rtp_rtcp->StopRTPDump(0, kRtpOutgoing)); + MARK(); - rtpObserver.Reset(); + rtpObserver.Reset(); - TEST_LOG("Verify the OnIncomingSSRCChanged callback\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 7777)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(500); - TEST_MUSTPASS(rtpObserver._SSRC[0] != 7777); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 1234)); - TEST_MUSTPASS(base->StartSend(0)); - SLEEP(500); - TEST_MUSTPASS(rtpObserver._SSRC[0] != 1234); - rtpObserver.Reset(); - if (file) - { - TEST_LOG("Start playing a file as microphone again...\n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - } + TEST_LOG("Verify the OnIncomingSSRCChanged callback\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 7777)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(500); + TEST_MUSTPASS(rtpObserver._SSRC[0] != 7777); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(rtp_rtcp->SetLocalSSRC(0, 1234)); + TEST_MUSTPASS(base->StartSend(0)); + SLEEP(500); + TEST_MUSTPASS(rtpObserver._SSRC[0] != 1234); + rtpObserver.Reset(); + if (file) { + TEST_LOG("Start playing a file as microphone again...\n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + } #ifdef WEBRTC_CODEC_RED - TEST_LOG("Enabling FEC \n"); - TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true)); - SLEEP(2000); + TEST_LOG("Enabling FEC \n"); + TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, true)); + SLEEP(2000); - TEST_LOG("Disabling FEC\n"); - TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, false)); - SLEEP(2000); + TEST_LOG("Disabling FEC\n"); + TEST_MUSTPASS(rtp_rtcp->SetFECStatus(0, false)); + SLEEP(2000); #else - TEST_LOG("Skipping FEC tests - WEBRTC_CODEC_RED not defined \n"); + TEST_LOG("Skipping FEC tests - WEBRTC_CODEC_RED not defined \n"); #endif // #ifdef WEBRTC_CODEC_RED #else - TEST_LOG("\n\n+++ More RTP/RTCP tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ More RTP/RTCP tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_RTP_RTCP_ - - ///////////////////////// - // Delete extra channel + ///////////////////////// + // Delete extra channel #if defined(_TEST_RTP_RTCP_) - TEST_LOG("\n\n+++ Delete extra channel +++ \n\n"); + TEST_LOG("\n\n+++ Delete extra channel +++ \n\n"); - TEST_LOG("Delete channel 1, stopping everything\n"); - TEST_MUSTPASS(base->DeleteChannel(1)); + TEST_LOG("Delete channel 1, stopping everything\n"); + TEST_MUSTPASS(base->DeleteChannel(1)); #else - TEST_LOG("\n\n+++ Delete extra channel NOT NEEDED +++ \n"); + TEST_LOG("\n\n+++ Delete extra channel NOT NEEDED +++ \n"); #endif // #if defined(WEBRTC_VOICE_ENGINE_CONFERENCING) && (define...... - - ///////////////////////////////////////////////// - // Hardware (test after streaming is activated) + ///////////////////////////////////////////////// + // Hardware (test after streaming is activated) #ifdef _TEST_HARDWARE_ - TEST_LOG("\n\n+++ More hardware tests +++\n\n"); - + TEST_LOG("\n\n+++ More hardware tests +++\n\n"); #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) #ifdef _WIN32 - // should works also while already recording - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - // should works also while already playing - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + // should works also while already recording + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + // should works also while already playing + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); #else - TEST_MUSTPASS(hardware->SetRecordingDevice(0)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); + TEST_MUSTPASS(hardware->SetRecordingDevice(0)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(0)); #endif - TEST_MUSTPASS(hardware->GetRecordingDeviceName(0, devName, guidName)); - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(0, devName, guidName)); + TEST_MUSTPASS(hardware->GetRecordingDeviceName(0, devName, guidName)); + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(0, devName, guidName)); - TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(nRec)); - TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(nPlay)); + TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(nRec)); + TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(nPlay)); #endif - int load = -1; + int load = -1; #if defined(_WIN32) - TEST_MUSTPASS(hardware->GetCPULoad(load)); - TEST_MUSTPASS(load == -1); - TEST_LOG("VE CPU load = %d\n", load); + TEST_MUSTPASS(hardware->GetCPULoad(load)); + TEST_MUSTPASS(load == -1); + TEST_LOG("VE CPU load = %d\n", load); #else - TEST_MUSTPASS(!hardware->GetCPULoad(load)); + TEST_MUSTPASS(!hardware->GetCPULoad(load)); #endif #if !defined(WEBRTC_MAC) && !defined(WEBRTC_ANDROID) - // Not supported on Mac yet - load = -1; - TEST_MUSTPASS(hardware->GetSystemCPULoad(load)); - TEST_MUSTPASS(load == -1); - TEST_LOG("System CPU load = %d\n", load); + // Not supported on Mac yet + load = -1; + TEST_MUSTPASS(hardware->GetSystemCPULoad(load)); + TEST_MUSTPASS(load == -1); + TEST_LOG("System CPU load = %d\n", load); #endif #ifdef MAC_IPHONE - // Reset sound device - TEST_LOG("Reset sound device \n"); - TEST_MUSTPASS(hardware->ResetAudioDevice()); - SLEEP(2000); + // Reset sound device + TEST_LOG("Reset sound device \n"); + TEST_MUSTPASS(hardware->ResetAudioDevice()); + SLEEP(2000); #endif // #ifdef MAC_IPHONE + TEST_LOG("\nBuilt-in WASAPI AEC tests\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + + TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); + if (givenLayer != kAudioWindowsCore) { + TEST_MUSTFAIL(hardware->EnableBuiltInAEC(true)); + TEST_MUSTFAIL(hardware->EnableBuiltInAEC(false)); + } else { + TEST_MUSTPASS(base->StartSend(0)); + // Can't be set after StartSend(). + TEST_MUSTFAIL(hardware->EnableBuiltInAEC(true)); + TEST_MUSTFAIL(hardware->EnableBuiltInAEC(false)); - TEST_LOG("\nBuilt-in WASAPI AEC tests\n"); TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(hardware->EnableBuiltInAEC(true)); + + // Can't be called before StartPlayout(). + TEST_MUSTFAIL(base->StartSend(0)); + + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Processing capture data with built-in AEC...\n"); + SLEEP(2000); + + TEST_LOG("Looping through capture devices...\n"); + int num_devs = 0; + char dev_name[128] = { 0 }; + char guid_name[128] = { 0 }; + TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(num_devs)); + for (int dev_index = 0; dev_index < num_devs; ++dev_index) { + TEST_MUSTPASS(hardware->GetRecordingDeviceName(dev_index, + dev_name, + guid_name)); + TEST_LOG("%d: %s\n", dev_index, dev_name); + TEST_MUSTPASS(hardware->SetRecordingDevice(dev_index)); + SLEEP(2000); + } + + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + + TEST_LOG("Looping through render devices, restarting for each " + "device...\n"); + TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(num_devs)); + for (int dev_index = 0; dev_index < num_devs; ++dev_index) { + TEST_MUSTPASS(hardware->GetPlayoutDeviceName(dev_index, + dev_name, + guid_name)); + TEST_LOG("%d: %s\n", dev_index, dev_name); + TEST_MUSTPASS(hardware->SetPlayoutDevice(dev_index)); + SLEEP(2000); + } + + TEST_LOG("Using default devices...\n"); + TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); + TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); + SLEEP(2000); + + // Possible, but not recommended before StopSend(). TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(hardware->GetAudioDeviceLayer(givenLayer)); - if (givenLayer != kAudioWindowsCore) - { - TEST_MUSTFAIL(hardware->EnableBuiltInAEC(true)); - TEST_MUSTFAIL(hardware->EnableBuiltInAEC(false)); - } - else - { - TEST_MUSTPASS(base->StartSend(0)); - // Can't be set after StartSend(). - TEST_MUSTFAIL(hardware->EnableBuiltInAEC(true)); - TEST_MUSTFAIL(hardware->EnableBuiltInAEC(false)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + SLEEP(2000); // To verify that there is no garbage audio. - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(hardware->EnableBuiltInAEC(true)); - - // Can't be called before StartPlayout(). - TEST_MUSTFAIL(base->StartSend(0)); - - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Processing capture data with built-in AEC...\n"); - SLEEP(2000); - - TEST_LOG("Looping through capture devices...\n"); - int num_devs = 0; - char dev_name[128] = {0}; - char guid_name[128] = {0}; - TEST_MUSTPASS(hardware->GetNumOfRecordingDevices(num_devs)); - for (int dev_index = 0; dev_index < num_devs; ++dev_index) - { - TEST_MUSTPASS(hardware->GetRecordingDeviceName(dev_index, - dev_name, - guid_name)); - TEST_LOG("%d: %s\n", dev_index, dev_name); - TEST_MUSTPASS(hardware->SetRecordingDevice(dev_index)); - SLEEP(2000); - } - - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - - TEST_LOG("Looping through render devices, restarting for each " - "device...\n"); - TEST_MUSTPASS(hardware->GetNumOfPlayoutDevices(num_devs)); - for (int dev_index = 0; dev_index < num_devs; ++dev_index) - { - TEST_MUSTPASS(hardware->GetPlayoutDeviceName(dev_index, - dev_name, - guid_name)); - TEST_LOG("%d: %s\n", dev_index, dev_name); - TEST_MUSTPASS(hardware->SetPlayoutDevice(dev_index)); - SLEEP(2000); - } - - TEST_LOG("Using default devices...\n"); - TEST_MUSTPASS(hardware->SetRecordingDevice(-1)); - TEST_MUSTPASS(hardware->SetPlayoutDevice(-1)); - SLEEP(2000); - - // Possible, but not recommended before StopSend(). - TEST_MUSTPASS(base->StopPlayout(0)); - - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - SLEEP(2000); // To verify that there is no garbage audio. - - TEST_LOG("Disabling built-in AEC.\n"); - TEST_MUSTPASS(hardware->EnableBuiltInAEC(false)); - } - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_LOG("Disabling built-in AEC.\n"); + TEST_MUSTPASS(hardware->EnableBuiltInAEC(false)); + } + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); #else - TEST_LOG("\n\n+++ More hardware tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ More hardware tests NOT ENABLED +++\n"); #endif - //////// - // Dtmf + //////// + // Dtmf #ifdef _TEST_DTMF_ - TEST_LOG("\n\n+++ Dtmf tests +++\n\n"); + TEST_LOG("\n\n+++ Dtmf tests +++\n\n"); - TEST_LOG("Making sure Dtmf Feedback is enabled by default \n"); - bool dtmfFeedback = false, dtmfDirectFeedback = true; - TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, - dtmfDirectFeedback)); - TEST_MUSTPASS(!dtmfFeedback); - TEST_MUSTPASS(dtmfDirectFeedback); + TEST_LOG("Making sure Dtmf Feedback is enabled by default \n"); + bool dtmfFeedback = false, dtmfDirectFeedback = true; + TEST_MUSTPASS(dtmf->GetDtmfFeedbackStatus(dtmfFeedback, + dtmfDirectFeedback)); + TEST_MUSTPASS(!dtmfFeedback); + TEST_MUSTPASS(dtmfDirectFeedback); - // Add support when new 4.0 API is complete + // Add support when new 4.0 API is complete #if (defined(WEBRTC_DTMF_DETECTION) && !defined(_INSTRUMENTATION_TESTING_)) - DtmfCallback *d = new DtmfCallback(); + DtmfCallback *d = new DtmfCallback(); - // Set codec to PCMU to make sure tones are not distorted - TEST_LOG("Setting codec to PCMU\n"); - CodecInst ci; - ci.channels = 1; - ci.pacsize = 160; - ci.plfreq = 8000; - ci.pltype = 0; - ci.rate = 64000; - strcpy(ci.plname, "PCMU"); - TEST_MUSTPASS(codec->SetSendCodec(0, ci)); + // Set codec to PCMU to make sure tones are not distorted + TEST_LOG("Setting codec to PCMU\n"); + CodecInst ci; + ci.channels = 1; + ci.pacsize = 160; + ci.plfreq = 8000; + ci.pltype = 0; + ci.rate = 64000; + strcpy(ci.plname, "PCMU"); + TEST_MUSTPASS(codec->SetSendCodec(0, ci)); - // Loop the different detections methods - TelephoneEventDetectionMethods detMethod = kInBand; - for (int h=0; h<3; ++h) + // Loop the different detections methods + TelephoneEventDetectionMethods detMethod = kInBand; + for (int h=0; h<3; ++h) + { + if (0 == h) { - if (0 == h) - { - TEST_LOG("Testing telephone-event (Dtmf) detection" - " using in-band method \n"); - TEST_LOG(" In-band events should be detected \n"); - TEST_LOG(" Out-of-band Dtmf events (0-15) should be" - " detected \n"); - TEST_LOG(" Out-of-band non-Dtmf events (>15) should NOT be" - " detected \n"); - detMethod = kInBand; - } - if (1 == h) - { - TEST_LOG("Testing telephone-event (Dtmf) detection using" - " out-of-band method\n"); - TEST_LOG(" In-band events should NOT be detected \n"); - TEST_LOG(" Out-of-band events should be detected \n"); - detMethod = kOutOfBand; - } - if (2 == h) - { - TEST_LOG("Testing telephone-event (Dtmf) detection using both" - " in-band and out-of-band methods\n"); - TEST_LOG(" In-band events should be detected \n"); - TEST_LOG(" Out-of-band Dtmf events (0-15) should be detected" - " TWICE \n"); - TEST_LOG(" Out-of-band non-Dtmf events (>15) should be detected" - " ONCE \n"); - detMethod = kInAndOutOfBand; - } - TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(0, detMethod, *d)); + TEST_LOG("Testing telephone-event (Dtmf) detection" + " using in-band method \n"); + TEST_LOG(" In-band events should be detected \n"); + TEST_LOG(" Out-of-band Dtmf events (0-15) should be" + " detected \n"); + TEST_LOG(" Out-of-band non-Dtmf events (>15) should NOT be" + " detected \n"); + detMethod = kInBand; + } + if (1 == h) + { + TEST_LOG("Testing telephone-event (Dtmf) detection using" + " out-of-band method\n"); + TEST_LOG(" In-band events should NOT be detected \n"); + TEST_LOG(" Out-of-band events should be detected \n"); + detMethod = kOutOfBand; + } + if (2 == h) + { + TEST_LOG("Testing telephone-event (Dtmf) detection using both" + " in-band and out-of-band methods\n"); + TEST_LOG(" In-band events should be detected \n"); + TEST_LOG(" Out-of-band Dtmf events (0-15) should be detected" + " TWICE \n"); + TEST_LOG(" Out-of-band non-Dtmf events (>15) should be detected" + " ONCE \n"); + detMethod = kInAndOutOfBand; + } + TEST_MUSTPASS(dtmf->RegisterTelephoneEventDetection(0, detMethod, *d)); #else - TEST_LOG("Skipping Dtmf detection tests - WEBRTC_DTMF_DETECTION not" - " defined or _INSTRUMENTATION_TESTING_ defined \n"); + TEST_LOG("Skipping Dtmf detection tests - WEBRTC_DTMF_DETECTION not" + " defined or _INSTRUMENTATION_TESTING_ defined \n"); #endif - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false)); - TEST_LOG("Sending in-band telephone events:"); - for(int i = 0; i < 16; i++) - { - TEST_LOG("\n %d ", i); fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, false, 160, 10)); - SLEEP(500); - } + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(false)); + TEST_LOG("Sending in-band telephone events:"); + for (int i = 0; i < 16; i++) { + TEST_LOG("\n %d ", i); + fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, false, 160, 10)); + SLEEP(500); + } #ifdef WEBRTC_CODEC_AVT - TEST_LOG("\nSending out-of-band telephone events:"); - for(int i = 0; i < 16; i++) - { - TEST_LOG("\n %d ", i); fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, true)); - SLEEP(500); - } - // Testing 2 non-Dtmf events - int num = 32; - TEST_LOG("\n %d ", num); fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, num, true)); - SLEEP(500); - num = 110; - TEST_LOG("\n %d ", num); fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, num, true)); - SLEEP(500); - ANL(); + TEST_LOG("\nSending out-of-band telephone events:"); + for (int i = 0; i < 16; i++) { + TEST_LOG("\n %d ", i); + fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, true)); + SLEEP(500); + } + // Testing 2 non-Dtmf events + int num = 32; + TEST_LOG("\n %d ", num); + fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, num, true)); + SLEEP(500); + num = 110; + TEST_LOG("\n %d ", num); + fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, num, true)); + SLEEP(500); + ANL(); #endif #if (defined(WEBRTC_DTMF_DETECTION) && !defined(_INSTRUMENTATION_TESTING_)) - TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); - TEST_LOG("Detected %d events \n", d->counter); - int expectedCount = 32; // For 0 == h - if (1 == h) expectedCount = 18; - if (2 == h) expectedCount = 50; - TEST_MUSTPASS(d->counter != expectedCount); - d->counter = 0; - } // for loop + TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); + TEST_LOG("Detected %d events \n", d->counter); + int expectedCount = 32; // For 0 == h + if (1 == h) expectedCount = 18; + if (2 == h) expectedCount = 50; + TEST_MUSTPASS(d->counter != expectedCount); + d->counter = 0; +} // for loop - TEST_LOG("Testing no detection after disabling:"); - TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); - TEST_LOG(" 0"); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false)); - SLEEP(500); - TEST_LOG(" 1"); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 1, true)); - SLEEP(500); - TEST_LOG("\nDtmf tones sent: 2, detected: %d \n", d->counter); - TEST_MUSTPASS(0 != d->counter); - delete d; +TEST_LOG("Testing no detection after disabling:"); +TEST_MUSTPASS(dtmf->DeRegisterTelephoneEventDetection(0)); +TEST_LOG(" 0"); +TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, false)); +SLEEP(500); +TEST_LOG(" 1"); +TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 1, true)); +SLEEP(500); +TEST_LOG("\nDtmf tones sent: 2, detected: %d \n", d->counter); +TEST_MUSTPASS(0 != d->counter); +delete d; - TEST_MUSTPASS(codec->GetCodec(0, ci)); - TEST_LOG("Back to first codec in list: %s\n", ci.plname); - TEST_MUSTPASS(codec->SetSendCodec(0, ci)); +TEST_MUSTPASS(codec->GetCodec(0, ci)); +TEST_LOG("Back to first codec in list: %s\n", ci.plname); +TEST_MUSTPASS(codec->SetSendCodec(0, ci)); #endif - #ifndef MAC_IPHONE #ifdef WEBRTC_CODEC_AVT - TEST_LOG("Disabling Dtmf playout (no tone should be heard) \n"); - TEST_MUSTPASS(dtmf->SetDtmfPlayoutStatus(0, false)); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true)); - SLEEP(500); + TEST_LOG("Disabling Dtmf playout (no tone should be heard) \n"); + TEST_MUSTPASS(dtmf->SetDtmfPlayoutStatus(0, false)); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true)); + SLEEP(500); - TEST_LOG("Enabling Dtmf playout (tone should be heard) \n"); - TEST_MUSTPASS(dtmf->SetDtmfPlayoutStatus(0, true)); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true)); - SLEEP(500); + TEST_LOG("Enabling Dtmf playout (tone should be heard) \n"); + TEST_MUSTPASS(dtmf->SetDtmfPlayoutStatus(0, true)); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, 0, true)); + SLEEP(500); #endif #endif - TEST_LOG("Playing Dtmf tone locally \n"); -/// TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 300, 15)); - SLEEP(500); + TEST_LOG("Playing Dtmf tone locally \n"); + /// TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 300, 15)); + SLEEP(500); #ifdef WEBRTC_CODEC_AVT - CodecInst c2; + CodecInst c2; - TEST_LOG("Changing Dtmf payload type \n"); + TEST_LOG("Changing Dtmf payload type \n"); - // Start by modifying the receiving side - if (codec) - { - int nc = codec->NumOfCodecs(); - for(int i = 0; i < nc; i++) - { - TEST_MUSTPASS(codec->GetCodec(i, c2)); - if(!_stricmp("telephone-event", c2.plname)) - { - c2.pltype = 88; // use 88 instead of default 106 - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - TEST_MUSTPASS(codec->SetRecPayloadType(0, c2)); - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - 0, AudioFilename(), true, true)); - break; - } - } + // Start by modifying the receiving side + if (codec) { + int nc = codec->NumOfCodecs(); + for (int i = 0; i < nc; i++) { + TEST_MUSTPASS(codec->GetCodec(i, c2)); + if (!_stricmp("telephone-event", c2.plname)) { + c2.pltype = 88; // use 88 instead of default 106 + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + TEST_MUSTPASS(codec->SetRecPayloadType(0, c2)); + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, AudioFilename(), true, true)); + break; + } } + } + SLEEP(500); + + // Next, we must modify the sending side as well + TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, c2.pltype)); + + TEST_LOG("Outband Dtmf test with modified Dtmf payload:"); + for (int i = 0; i < 16; i++) { + TEST_LOG(" %d", i); + fflush(NULL); + TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, true)); SLEEP(500); - - // Next, we must modify the sending side as well - TEST_MUSTPASS(dtmf->SetSendTelephoneEventPayloadType(0, c2.pltype)); - - TEST_LOG("Outband Dtmf test with modified Dtmf payload:"); - for(int i = 0; i < 16; i++) - { - TEST_LOG(" %d", i); - fflush(NULL); - TEST_MUSTPASS(dtmf->SendTelephoneEvent(0, i, true)); - SLEEP(500); - } - ANL(); + } + ANL(); #endif - TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, false)); + TEST_MUSTPASS(dtmf->SetDtmfFeedbackStatus(true, false)); #else - TEST_LOG("\n\n+++ Dtmf tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Dtmf tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_DTMF_ - - ////////// - // Volume + ////////// + // Volume #ifdef _TEST_VOLUME_ - TEST_LOG("\n\n+++ Volume tests +++\n\n"); + TEST_LOG("\n\n+++ Volume tests +++\n\n"); #if !defined(MAC_IPHONE) - // Speaker volume test - unsigned int vol = 1000; - TEST_LOG("Saving Speaker volume\n"); - TEST_MUSTPASS(volume->GetSpeakerVolume(vol)); - TEST_MUSTPASS(!(vol <= 255)); - TEST_LOG("Setting speaker volume to 0\n"); - TEST_MUSTPASS(volume->SetSpeakerVolume(0)); - SLEEP(1000); - TEST_LOG("Setting speaker volume to 255\n"); - TEST_MUSTPASS(volume->SetSpeakerVolume(255)); - SLEEP(1000); - TEST_LOG("Setting speaker volume back to saved value\n"); - TEST_MUSTPASS(volume->SetSpeakerVolume(vol)); - SLEEP(1000); + // Speaker volume test + unsigned int vol = 1000; + TEST_LOG("Saving Speaker volume\n"); + TEST_MUSTPASS(volume->GetSpeakerVolume(vol)); + TEST_MUSTPASS(!(vol <= 255)); + TEST_LOG("Setting speaker volume to 0\n"); + TEST_MUSTPASS(volume->SetSpeakerVolume(0)); + SLEEP(1000); + TEST_LOG("Setting speaker volume to 255\n"); + TEST_MUSTPASS(volume->SetSpeakerVolume(255)); + SLEEP(1000); + TEST_LOG("Setting speaker volume back to saved value\n"); + TEST_MUSTPASS(volume->SetSpeakerVolume(vol)); + SLEEP(1000); #endif // #if !defined(MAC_IPHONE) - - if (file) - { - TEST_LOG("==> Talk into the microphone \n"); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - SLEEP(1000); - } + if (file) { + TEST_LOG("==> Talk into the microphone \n"); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + SLEEP(1000); + } #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // Mic volume test + // Mic volume test #if defined(_TEST_AUDIO_PROCESSING_) && defined(WEBRTC_VOICE_ENGINE_AGC) - bool agcTemp(true); - AgcModes agcModeTemp(kAgcAdaptiveAnalog); - TEST_MUSTPASS(apm->GetAgcStatus(agcTemp, agcModeTemp)); // current state - TEST_LOG("Turn off AGC\n"); - TEST_MUSTPASS(apm->SetAgcStatus(false)); + bool agcTemp(true); + AgcModes agcModeTemp(kAgcAdaptiveAnalog); + TEST_MUSTPASS(apm->GetAgcStatus(agcTemp, agcModeTemp)); // current state + TEST_LOG("Turn off AGC\n"); + TEST_MUSTPASS(apm->SetAgcStatus(false)); #endif - TEST_LOG("Saving Mic volume\n"); - TEST_MUSTPASS(volume->GetMicVolume(vol)); - TEST_MUSTPASS(!(vol <= 255)); - TEST_LOG("Setting Mic volume to 0\n"); - TEST_MUSTPASS(volume->SetMicVolume(0)); - SLEEP(1000); - TEST_LOG("Setting Mic volume to 255\n"); - TEST_MUSTPASS(volume->SetMicVolume(255)); - SLEEP(1000); - TEST_LOG("Setting Mic volume back to saved value\n"); - TEST_MUSTPASS(volume->SetMicVolume(vol)); - SLEEP(1000); + TEST_LOG("Saving Mic volume\n"); + TEST_MUSTPASS(volume->GetMicVolume(vol)); + TEST_MUSTPASS(!(vol <= 255)); + TEST_LOG("Setting Mic volume to 0\n"); + TEST_MUSTPASS(volume->SetMicVolume(0)); + SLEEP(1000); + TEST_LOG("Setting Mic volume to 255\n"); + TEST_MUSTPASS(volume->SetMicVolume(255)); + SLEEP(1000); + TEST_LOG("Setting Mic volume back to saved value\n"); + TEST_MUSTPASS(volume->SetMicVolume(vol)); + SLEEP(1000); #if defined(_TEST_AUDIO_PROCESSING_) && defined(WEBRTC_VOICE_ENGINE_AGC) - TEST_LOG("Reset AGC to previous state\n"); - TEST_MUSTPASS(apm->SetAgcStatus(agcTemp, agcModeTemp)); + TEST_LOG("Reset AGC to previous state\n"); + TEST_MUSTPASS(apm->SetAgcStatus(agcTemp, agcModeTemp)); #endif #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - - // Input mute test - TEST_LOG("Enabling input muting\n"); - bool mute = true; - TEST_MUSTPASS(volume->GetInputMute(0, mute)); - TEST_MUSTPASS(mute); - TEST_MUSTPASS(volume->SetInputMute(0, true)); - TEST_MUSTPASS(volume->GetInputMute(0, mute)); - TEST_MUSTPASS(!mute); - SLEEP(1000); - TEST_LOG("Disabling input muting\n"); - TEST_MUSTPASS(volume->SetInputMute(0, false)); - TEST_MUSTPASS(volume->GetInputMute(0, mute)); - TEST_MUSTPASS(mute); - SLEEP(1000); + // Input mute test + TEST_LOG("Enabling input muting\n"); + bool mute = true; + TEST_MUSTPASS(volume->GetInputMute(0, mute)); + TEST_MUSTPASS(mute); + TEST_MUSTPASS(volume->SetInputMute(0, true)); + TEST_MUSTPASS(volume->GetInputMute(0, mute)); + TEST_MUSTPASS(!mute); + SLEEP(1000); + TEST_LOG("Disabling input muting\n"); + TEST_MUSTPASS(volume->SetInputMute(0, false)); + TEST_MUSTPASS(volume->GetInputMute(0, mute)); + TEST_MUSTPASS(mute); + SLEEP(1000); #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // System output mute test - TEST_LOG("Enabling system output muting\n"); - bool outputMute = true; - TEST_MUSTPASS(volume->GetSystemOutputMute(outputMute)); - TEST_MUSTPASS(outputMute); - TEST_MUSTPASS(volume->SetSystemOutputMute(true)); - TEST_MUSTPASS(volume->GetSystemOutputMute(outputMute)); - TEST_MUSTPASS(!outputMute); - SLEEP(1000); - TEST_LOG("Disabling system output muting\n"); - TEST_MUSTPASS(volume->SetSystemOutputMute(false)); - TEST_MUSTPASS(volume->GetSystemOutputMute(outputMute)); - TEST_MUSTPASS(outputMute); - SLEEP(1000); + // System output mute test + TEST_LOG("Enabling system output muting\n"); + bool outputMute = true; + TEST_MUSTPASS(volume->GetSystemOutputMute(outputMute)); + TEST_MUSTPASS(outputMute); + TEST_MUSTPASS(volume->SetSystemOutputMute(true)); + TEST_MUSTPASS(volume->GetSystemOutputMute(outputMute)); + TEST_MUSTPASS(!outputMute); + SLEEP(1000); + TEST_LOG("Disabling system output muting\n"); + TEST_MUSTPASS(volume->SetSystemOutputMute(false)); + TEST_MUSTPASS(volume->GetSystemOutputMute(outputMute)); + TEST_MUSTPASS(outputMute); + SLEEP(1000); - // System Input mute test - TEST_LOG("Enabling system input muting\n"); - bool inputMute = true; - TEST_MUSTPASS(volume->GetSystemInputMute(inputMute)); - TEST_MUSTPASS(inputMute); - TEST_MUSTPASS(volume->SetSystemInputMute(true)); - // This is needed to avoid error using pulse - SLEEP(100); - TEST_MUSTPASS(volume->GetSystemInputMute(inputMute)); - TEST_MUSTPASS(!inputMute); - SLEEP(1000); - TEST_LOG("Disabling system input muting\n"); - TEST_MUSTPASS(volume->SetSystemInputMute(false)); - // This is needed to avoid error using pulse - SLEEP(100); - TEST_MUSTPASS(volume->GetSystemInputMute(inputMute)); - TEST_MUSTPASS(inputMute); - SLEEP(1000); + // System Input mute test + TEST_LOG("Enabling system input muting\n"); + bool inputMute = true; + TEST_MUSTPASS(volume->GetSystemInputMute(inputMute)); + TEST_MUSTPASS(inputMute); + TEST_MUSTPASS(volume->SetSystemInputMute(true)); + // This is needed to avoid error using pulse + SLEEP(100); + TEST_MUSTPASS(volume->GetSystemInputMute(inputMute)); + TEST_MUSTPASS(!inputMute); + SLEEP(1000); + TEST_LOG("Disabling system input muting\n"); + TEST_MUSTPASS(volume->SetSystemInputMute(false)); + // This is needed to avoid error using pulse + SLEEP(100); + TEST_MUSTPASS(volume->GetSystemInputMute(inputMute)); + TEST_MUSTPASS(inputMute); + SLEEP(1000); #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - #if(!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - // Test Input & Output levels - TEST_LOG("Testing input & output levels for 10 seconds (dT=1 second)\n"); - TEST_LOG("Speak in microphone to vary the levels...\n"); - unsigned int inputLevel(0); - unsigned int outputLevel(0); - unsigned int inputLevelFullRange(0); - unsigned int outputLevelFullRange(0); + // Test Input & Output levels + TEST_LOG("Testing input & output levels for 10 seconds (dT=1 second)\n"); + TEST_LOG("Speak in microphone to vary the levels...\n"); + unsigned int inputLevel(0); + unsigned int outputLevel(0); + unsigned int inputLevelFullRange(0); + unsigned int outputLevelFullRange(0); - for (int t = 0; t < 5; t++) - { - SLEEP(1000); - TEST_MUSTPASS(volume->GetSpeechInputLevel(inputLevel)); - TEST_MUSTPASS(volume->GetSpeechOutputLevel(0, outputLevel)); - TEST_MUSTPASS(volume->GetSpeechInputLevelFullRange( + for (int t = 0; t < 5; t++) { + SLEEP(1000); + TEST_MUSTPASS(volume->GetSpeechInputLevel(inputLevel)); + TEST_MUSTPASS(volume->GetSpeechOutputLevel(0, outputLevel)); + TEST_MUSTPASS(volume->GetSpeechInputLevelFullRange( inputLevelFullRange)); - TEST_MUSTPASS(volume->GetSpeechOutputLevelFullRange( + TEST_MUSTPASS(volume->GetSpeechOutputLevelFullRange( 0, outputLevelFullRange)); - TEST_LOG(" warped levels (0-9) : in=%5d, out=%5d\n", - inputLevel, outputLevel); - TEST_LOG(" linear levels (0-32768): in=%5d, out=%5d\n", - inputLevelFullRange, outputLevelFullRange); - } + TEST_LOG(" warped levels (0-9) : in=%5d, out=%5d\n", + inputLevel, outputLevel); + TEST_LOG(" linear levels (0-32768): in=%5d, out=%5d\n", + inputLevelFullRange, outputLevelFullRange); + } #endif // #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - - if (file) - { - TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - SLEEP(1000); - } + if (file) { + TEST_LOG("==> Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + SLEEP(1000); + } #if !defined(MAC_IPHONE) - // Channel scaling test - TEST_LOG("Channel scaling\n"); - float scaling = -1.0; - TEST_MUSTPASS(volume->GetChannelOutputVolumeScaling(0, scaling)); - TEST_MUSTPASS(1.0 != scaling); - TEST_MUSTPASS(volume->SetChannelOutputVolumeScaling(0, (float)0.1)); - TEST_MUSTPASS(volume->GetChannelOutputVolumeScaling(0, scaling)); - TEST_MUSTPASS(!((scaling > 0.099) && (scaling < 0.101))); - SLEEP(1000); - TEST_MUSTPASS(volume->SetChannelOutputVolumeScaling(0, (float)1.0)); - TEST_MUSTPASS(volume->GetChannelOutputVolumeScaling(0, scaling)); - TEST_MUSTPASS(1.0 != scaling); + // Channel scaling test + TEST_LOG("Channel scaling\n"); + float scaling = -1.0; + TEST_MUSTPASS(volume->GetChannelOutputVolumeScaling(0, scaling)); + TEST_MUSTPASS(1.0 != scaling); + TEST_MUSTPASS(volume->SetChannelOutputVolumeScaling(0, (float)0.1)); + TEST_MUSTPASS(volume->GetChannelOutputVolumeScaling(0, scaling)); + TEST_MUSTPASS(!((scaling > 0.099) && (scaling < 0.101))); + SLEEP(1000); + TEST_MUSTPASS(volume->SetChannelOutputVolumeScaling(0, (float)1.0)); + TEST_MUSTPASS(volume->GetChannelOutputVolumeScaling(0, scaling)); + TEST_MUSTPASS(1.0 != scaling); #endif // #if !defined(MAC_IPHONE) - #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) - // Channel panning test - TEST_LOG("Channel panning\n"); - float left = -1.0, right = -1.0; - TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); - TEST_MUSTPASS(!((left == 1.0) && (right == 1.0))); - TEST_LOG("Panning to left\n"); - TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)0.8, (float)0.1)); - TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); - TEST_MUSTPASS(!((left > 0.799) && (left < 0.801))); - TEST_MUSTPASS(!((right > 0.099) && (right < 0.101))); - SLEEP(1000); - TEST_LOG("Back to center\n"); - TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)1.0, (float)1.0)); - SLEEP(1000); - left = -1.0; right = -1.0; - TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); - TEST_MUSTPASS(!((left == 1.0) && (right == 1.0))); - TEST_LOG("Panning channel to right\n"); - TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)0.1, (float)0.8)); - SLEEP(100); - TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); - TEST_MUSTPASS(!((left > 0.099) && (left < 0.101))); - TEST_MUSTPASS(!((right > 0.799) && (right < 0.801))); - SLEEP(1000); - TEST_LOG("Channel back to center\n"); - TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)1.0, (float)1.0)); - SLEEP(1000); + // Channel panning test + TEST_LOG("Channel panning\n"); + float left = -1.0, right = -1.0; + TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); + TEST_MUSTPASS(!((left == 1.0) && (right == 1.0))); + TEST_LOG("Panning to left\n"); + TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)0.8, (float)0.1)); + TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); + TEST_MUSTPASS(!((left > 0.799) && (left < 0.801))); + TEST_MUSTPASS(!((right > 0.099) && (right < 0.101))); + SLEEP(1000); + TEST_LOG("Back to center\n"); + TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)1.0, (float)1.0)); + SLEEP(1000); + left = -1.0; + right = -1.0; + TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); + TEST_MUSTPASS(!((left == 1.0) && (right == 1.0))); + TEST_LOG("Panning channel to right\n"); + TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)0.1, (float)0.8)); + SLEEP(100); + TEST_MUSTPASS(volume->GetOutputVolumePan(0, left, right)); + TEST_MUSTPASS(!((left > 0.099) && (left < 0.101))); + TEST_MUSTPASS(!((right > 0.799) && (right < 0.801))); + SLEEP(1000); + TEST_LOG("Channel back to center\n"); + TEST_MUSTPASS(volume->SetOutputVolumePan(0, (float)1.0, (float)1.0)); + SLEEP(1000); #else - TEST_LOG("Skipping stereo tests\n"); + TEST_LOG("Skipping stereo tests\n"); #endif // #if !defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - #else - TEST_LOG("\n\n+++ Volume tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Volume tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_VOLUME_ - - /////// - // AudioProcessing + /////// + // AudioProcessing #ifdef _TEST_AUDIO_PROCESSING_ - TEST_LOG("\n\n+++ AudioProcessing tests +++\n\n"); + TEST_LOG("\n\n+++ AudioProcessing tests +++\n\n"); #ifdef WEBRTC_VOICE_ENGINE_AGC - bool test; - TEST_LOG("AGC calls\n"); + bool test; + TEST_LOG("AGC calls\n"); #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - TEST_LOG("Must be OFF by default\n"); - test = true; - AgcModes agcMode = kAgcAdaptiveAnalog; - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); + TEST_LOG("Must be OFF by default\n"); + test = true; + AgcModes agcMode = kAgcAdaptiveAnalog; + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); #else - TEST_LOG("Must be ON by default\n"); - test = false; - AgcModes agcMode = kAgcAdaptiveAnalog; - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(!test); - TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); + TEST_LOG("Must be ON by default\n"); + test = false; + AgcModes agcMode = kAgcAdaptiveAnalog; + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(!test); + TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); - TEST_LOG("Turn off AGC\n"); - // must set value in first call! - TEST_MUSTPASS(apm->SetAgcStatus(false, kAgcDefault)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); + TEST_LOG("Turn off AGC\n"); + // must set value in first call! + TEST_MUSTPASS(apm->SetAgcStatus(false, kAgcDefault)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); #endif // #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - - TEST_LOG("Turn ON AGC\n"); + TEST_LOG("Turn ON AGC\n"); #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); #else - TEST_MUSTPASS(apm->SetAgcStatus(true)); + TEST_MUSTPASS(apm->SetAgcStatus(true)); #endif - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(!test); + TEST_LOG("Should be ON now\n"); + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(!test); #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); #else - TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); + TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); #endif #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - TEST_LOG("Testing Type settings\n"); - // Should fail - TEST_MUSTPASS(!apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); - // Should fail - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcFixedDigital)); - // Should fail - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); + TEST_LOG("Testing Type settings\n"); + // Should fail + TEST_MUSTPASS(!apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); + // Should fail + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcFixedDigital)); + // Should fail + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); - TEST_LOG("Turn off AGC\n"); - TEST_MUSTPASS(apm->SetAgcStatus(false)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); + TEST_LOG("Turn off AGC\n"); + TEST_MUSTPASS(apm->SetAgcStatus(false)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); #else - TEST_LOG("Testing Mode settings\n"); - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcFixedDigital)); - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(kAgcFixedDigital != agcMode); - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); - TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); - TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); - TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); + TEST_LOG("Testing Mode settings\n"); + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcFixedDigital)); + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(kAgcFixedDigital != agcMode); + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveDigital)); + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); + TEST_MUSTPASS(apm->SetAgcStatus(true, kAgcAdaptiveAnalog)); + TEST_MUSTPASS(apm->GetAgcStatus(test, agcMode)); + TEST_MUSTPASS(kAgcAdaptiveAnalog != agcMode); #endif // #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) + TEST_LOG("rxAGC calls\n"); + // Note the following test is not tested in iphone, android and wince, + // you may run into issue - TEST_LOG("rxAGC calls\n"); - // Note the following test is not tested in iphone, android and wince, - // you may run into issue + bool rxAGCTemp(false); + AgcModes rxAGCModeTemp(kAgcAdaptiveAnalog); + // Store current state + TEST_MUSTPASS(apm->GetAgcStatus(rxAGCTemp, rxAGCModeTemp)); + TEST_LOG("Turn off near-end AGC\n"); + TEST_MUSTPASS(apm->SetAgcStatus(false)); - bool rxAGCTemp(false); - AgcModes rxAGCModeTemp(kAgcAdaptiveAnalog); - // Store current state - TEST_MUSTPASS(apm->GetAgcStatus(rxAGCTemp, rxAGCModeTemp)); - TEST_LOG("Turn off near-end AGC\n"); - TEST_MUSTPASS(apm->SetAgcStatus(false)); + TEST_LOG("rxAGC Must be OFF by default\n"); + test = true; + AgcModes rxAGCMode = kAgcAdaptiveDigital; + TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(kAgcAdaptiveDigital != rxAGCMode); - TEST_LOG("rxAGC Must be OFF by default\n"); - test = true; - AgcModes rxAGCMode = kAgcAdaptiveDigital; - TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(kAgcAdaptiveDigital != rxAGCMode); + TEST_LOG("Turn off rxAGC\n"); + // must set value in first call! + TEST_MUSTPASS(apm->SetRxAgcStatus(0, false, kAgcDefault)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(kAgcAdaptiveDigital != rxAGCMode); - TEST_LOG("Turn off rxAGC\n"); - // must set value in first call! - TEST_MUSTPASS(apm->SetRxAgcStatus(0, false, kAgcDefault)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(kAgcAdaptiveDigital != rxAGCMode); + TEST_LOG("Turn ON AGC\n"); + TEST_MUSTPASS(apm->SetRxAgcStatus(0, true)); + TEST_LOG("Should be ON now\n"); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); + TEST_MUSTPASS(!test); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); - TEST_LOG("Turn ON AGC\n"); - TEST_MUSTPASS(apm->SetRxAgcStatus(0, true)); - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); - TEST_MUSTPASS(!test); - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); + TEST_LOG("Testing Type settings\n"); + // Should fail + TEST_MUSTPASS(!apm->SetRxAgcStatus(0, true, kAgcAdaptiveAnalog)); + TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcFixedDigital)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); + TEST_MUSTPASS(kAgcFixedDigital != agcMode); + TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcAdaptiveDigital)); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); - TEST_LOG("Testing Type settings\n"); - // Should fail - TEST_MUSTPASS(!apm->SetRxAgcStatus(0, true, kAgcAdaptiveAnalog)); - TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcFixedDigital)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); - TEST_MUSTPASS(kAgcFixedDigital != agcMode); - TEST_MUSTPASS(apm->SetRxAgcStatus(0, true, kAgcAdaptiveDigital)); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); + TEST_LOG("Turn off AGC\n"); + TEST_MUSTPASS(apm->SetRxAgcStatus(0, false)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); - TEST_LOG("Turn off AGC\n"); - TEST_MUSTPASS(apm->SetRxAgcStatus(0, false)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetRxAgcStatus(0, test, agcMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(kAgcAdaptiveDigital != agcMode); - - // recover the old AGC mode - TEST_MUSTPASS(apm->SetAgcStatus(rxAGCTemp, rxAGCModeTemp)); + // recover the old AGC mode + TEST_MUSTPASS(apm->SetAgcStatus(rxAGCTemp, rxAGCModeTemp)); #else - TEST_LOG("Skipping AGC tests - WEBRTC_VOICE_ENGINE_AGC not defined \n"); + TEST_LOG("Skipping AGC tests - WEBRTC_VOICE_ENGINE_AGC not defined \n"); #endif // #ifdef WEBRTC_VOICE_ENGINE_AGC - #ifdef WEBRTC_VOICE_ENGINE_ECHO - TEST_LOG("EC calls\n"); - TEST_LOG("Must be OFF by default\n"); + TEST_LOG("EC calls\n"); + TEST_LOG("Must be OFF by default\n"); #if (defined(MAC_IPHONE) || defined(WEBRTC_ANDROID)) - const EcModes ecModeDefault = kEcAecm; + const EcModes ecModeDefault = kEcAecm; #else - const EcModes ecModeDefault = kEcAec; + const EcModes ecModeDefault = kEcAec; #endif - test = true; - EcModes ecMode = kEcAec; - AecmModes aecmMode = kAecmSpeakerphone; - bool enabledCNG(false); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(ecModeDefault != ecMode); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("default AECM: mode=%d CNG: mode=%d\n",aecmMode, enabledCNG); - TEST_MUSTPASS(kAecmSpeakerphone != aecmMode); - TEST_MUSTPASS(enabledCNG != true); - TEST_MUSTPASS(apm->SetAecmMode(kAecmQuietEarpieceOrHeadset, false)); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("change AECM to mode=%d CNG to false\n",aecmMode); - TEST_MUSTPASS(aecmMode != kAecmQuietEarpieceOrHeadset); - TEST_MUSTPASS(enabledCNG != false); + test = true; + EcModes ecMode = kEcAec; + AecmModes aecmMode = kAecmSpeakerphone; + bool enabledCNG(false); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(ecModeDefault != ecMode); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("default AECM: mode=%d CNG: mode=%d\n", aecmMode, enabledCNG); + TEST_MUSTPASS(kAecmSpeakerphone != aecmMode); + TEST_MUSTPASS(enabledCNG != true); + TEST_MUSTPASS(apm->SetAecmMode(kAecmQuietEarpieceOrHeadset, false)); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("change AECM to mode=%d CNG to false\n", aecmMode); + TEST_MUSTPASS(aecmMode != kAecmQuietEarpieceOrHeadset); + TEST_MUSTPASS(enabledCNG != false); - TEST_LOG("Turn ON EC\n"); - TEST_MUSTPASS(apm->SetEcStatus(true, ecModeDefault)); - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_MUSTPASS(!test); - TEST_MUSTPASS(ecModeDefault != ecMode); + TEST_LOG("Turn ON EC\n"); + TEST_MUSTPASS(apm->SetEcStatus(true, ecModeDefault)); + TEST_LOG("Should be ON now\n"); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_MUSTPASS(!test); + TEST_MUSTPASS(ecModeDefault != ecMode); #if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID)) - TEST_MUSTPASS(apm->SetEcStatus(true, kEcAec)); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_MUSTPASS(kEcAec != ecMode); + TEST_MUSTPASS(apm->SetEcStatus(true, kEcAec)); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_MUSTPASS(kEcAec != ecMode); - TEST_MUSTPASS(apm->SetEcStatus(true, kEcConference)); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_MUSTPASS(kEcAec != ecMode); + TEST_MUSTPASS(apm->SetEcStatus(true, kEcConference)); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_MUSTPASS(kEcAec != ecMode); - - // the samplefreq for AudioProcessing is 32k, so it wont work to - // activate AECM - TEST_MUSTPASS(apm->SetEcStatus(true, kEcAecm)); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_MUSTPASS(kEcAecm != ecMode); + // the samplefreq for AudioProcessing is 32k, so it wont work to + // activate AECM + TEST_MUSTPASS(apm->SetEcStatus(true, kEcAecm)); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_MUSTPASS(kEcAecm != ecMode); #endif - // set kEcAecm mode - TEST_LOG("Testing AECM Mode settings\n"); - TEST_MUSTPASS(apm->SetEcStatus(true, kEcAecm)); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_LOG("EC: enabled=%d, ECmode=%d\n", test, ecMode); - TEST_MUSTPASS(test != true); - TEST_MUSTPASS(ecMode != kEcAecm); + // set kEcAecm mode + TEST_LOG("Testing AECM Mode settings\n"); + TEST_MUSTPASS(apm->SetEcStatus(true, kEcAecm)); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_LOG("EC: enabled=%d, ECmode=%d\n", test, ecMode); + TEST_MUSTPASS(test != true); + TEST_MUSTPASS(ecMode != kEcAecm); - // AECM mode, get and set - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_MUSTPASS(aecmMode != kAecmQuietEarpieceOrHeadset); - TEST_MUSTPASS(enabledCNG != false); - TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, true)); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("AECM: mode=%d CNG: mode=%d\n",aecmMode, enabledCNG); - TEST_MUSTPASS(aecmMode != kAecmEarpiece); - TEST_MUSTPASS(enabledCNG != true); - TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, false)); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("AECM: mode=%d CNG: mode=%d\n",aecmMode, enabledCNG); - TEST_MUSTPASS(aecmMode != kAecmEarpiece); - TEST_MUSTPASS(enabledCNG != false); - TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudEarpiece, true)); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("AECM: mode=%d CNG: mode=%d\n",aecmMode, enabledCNG); - TEST_MUSTPASS(aecmMode != kAecmLoudEarpiece); - TEST_MUSTPASS(enabledCNG != true); - TEST_MUSTPASS(apm->SetAecmMode(kAecmSpeakerphone, false)); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("AECM: mode=%d CNG: mode=%d\n",aecmMode, enabledCNG); - TEST_MUSTPASS(aecmMode != kAecmSpeakerphone); - TEST_MUSTPASS(enabledCNG != false); - TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudSpeakerphone, true)); - TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); - TEST_LOG("AECM: mode=%d CNG: mode=%d\n",aecmMode, enabledCNG); - TEST_MUSTPASS(aecmMode != kAecmLoudSpeakerphone); - TEST_MUSTPASS(enabledCNG != true); + // AECM mode, get and set + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_MUSTPASS(aecmMode != kAecmQuietEarpieceOrHeadset); + TEST_MUSTPASS(enabledCNG != false); + TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, true)); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("AECM: mode=%d CNG: mode=%d\n", aecmMode, enabledCNG); + TEST_MUSTPASS(aecmMode != kAecmEarpiece); + TEST_MUSTPASS(enabledCNG != true); + TEST_MUSTPASS(apm->SetAecmMode(kAecmEarpiece, false)); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("AECM: mode=%d CNG: mode=%d\n", aecmMode, enabledCNG); + TEST_MUSTPASS(aecmMode != kAecmEarpiece); + TEST_MUSTPASS(enabledCNG != false); + TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudEarpiece, true)); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("AECM: mode=%d CNG: mode=%d\n", aecmMode, enabledCNG); + TEST_MUSTPASS(aecmMode != kAecmLoudEarpiece); + TEST_MUSTPASS(enabledCNG != true); + TEST_MUSTPASS(apm->SetAecmMode(kAecmSpeakerphone, false)); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("AECM: mode=%d CNG: mode=%d\n", aecmMode, enabledCNG); + TEST_MUSTPASS(aecmMode != kAecmSpeakerphone); + TEST_MUSTPASS(enabledCNG != false); + TEST_MUSTPASS(apm->SetAecmMode(kAecmLoudSpeakerphone, true)); + TEST_MUSTPASS(apm->GetAecmMode(aecmMode, enabledCNG)); + TEST_LOG("AECM: mode=%d CNG: mode=%d\n", aecmMode, enabledCNG); + TEST_MUSTPASS(aecmMode != kAecmLoudSpeakerphone); + TEST_MUSTPASS(enabledCNG != true); - TEST_LOG("Turn OFF AEC\n"); - TEST_MUSTPASS(apm->SetEcStatus(false)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); - TEST_MUSTPASS(test); + TEST_LOG("Turn OFF AEC\n"); + TEST_MUSTPASS(apm->SetEcStatus(false)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetEcStatus(test, ecMode)); + TEST_MUSTPASS(test); #else - TEST_LOG("Skipping echo cancellation tests -" - " WEBRTC_VOICE_ENGINE_ECHO not defined \n"); + TEST_LOG("Skipping echo cancellation tests -" + " WEBRTC_VOICE_ENGINE_ECHO not defined \n"); #endif // #ifdef WEBRTC_VOICE_ENGINE_ECHO - #ifdef WEBRTC_VOICE_ENGINE_NR - TEST_LOG("NS calls\n"); - TEST_LOG("Must be OFF by default\n"); + TEST_LOG("NS calls\n"); + TEST_LOG("Must be OFF by default\n"); - NsModes nsModeDefault = kNsModerateSuppression; + NsModes nsModeDefault = kNsModerateSuppression; - test = true; - NsModes nsMode = kNsVeryHighSuppression; - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(nsModeDefault != nsMode); + test = true; + NsModes nsMode = kNsVeryHighSuppression; + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(nsModeDefault != nsMode); - TEST_LOG("Turn ON NS\n"); - TEST_MUSTPASS(apm->SetNsStatus(true)); - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(!test); - TEST_MUSTPASS(nsModeDefault != nsMode); + TEST_LOG("Turn ON NS\n"); + TEST_MUSTPASS(apm->SetNsStatus(true)); + TEST_LOG("Should be ON now\n"); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(!test); + TEST_MUSTPASS(nsModeDefault != nsMode); - TEST_LOG("Testing Mode settings\n"); - TEST_MUSTPASS(apm->SetNsStatus(true, kNsLowSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(kNsLowSuppression != nsMode); - TEST_MUSTPASS(apm->SetNsStatus(true, kNsModerateSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(kNsModerateSuppression != nsMode); - TEST_MUSTPASS(apm->SetNsStatus(true, kNsHighSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(kNsHighSuppression != nsMode); - TEST_MUSTPASS(apm->SetNsStatus(true, kNsVeryHighSuppression)); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(kNsVeryHighSuppression != nsMode); - TEST_MUSTPASS(apm->SetNsStatus(true, kNsConference)); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(kNsHighSuppression != nsMode); - TEST_MUSTPASS(apm->SetNsStatus(true, kNsDefault)); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(nsModeDefault != nsMode); + TEST_LOG("Testing Mode settings\n"); + TEST_MUSTPASS(apm->SetNsStatus(true, kNsLowSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(kNsLowSuppression != nsMode); + TEST_MUSTPASS(apm->SetNsStatus(true, kNsModerateSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(kNsModerateSuppression != nsMode); + TEST_MUSTPASS(apm->SetNsStatus(true, kNsHighSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(kNsHighSuppression != nsMode); + TEST_MUSTPASS(apm->SetNsStatus(true, kNsVeryHighSuppression)); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(kNsVeryHighSuppression != nsMode); + TEST_MUSTPASS(apm->SetNsStatus(true, kNsConference)); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(kNsHighSuppression != nsMode); + TEST_MUSTPASS(apm->SetNsStatus(true, kNsDefault)); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(nsModeDefault != nsMode); - TEST_LOG("Turn OFF NS\n"); - TEST_MUSTPASS(apm->SetNsStatus(false)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); - TEST_MUSTPASS(test); + TEST_LOG("Turn OFF NS\n"); + TEST_MUSTPASS(apm->SetNsStatus(false)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetNsStatus(test, nsMode)); + TEST_MUSTPASS(test); + TEST_LOG("rxNS calls\n"); + TEST_LOG("rxNS Must be OFF by default\n"); - TEST_LOG("rxNS calls\n"); - TEST_LOG("rxNS Must be OFF by default\n"); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(test); + TEST_MUSTPASS(nsModeDefault != nsMode); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(test); - TEST_MUSTPASS(nsModeDefault != nsMode); + TEST_LOG("Turn ON rxNS\n"); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true)); + TEST_LOG("Should be ON now\n"); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(!test); + TEST_MUSTPASS(nsModeDefault != nsMode); - TEST_LOG("Turn ON rxNS\n"); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true)); - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(!test); - TEST_MUSTPASS(nsModeDefault != nsMode); + TEST_LOG("Testing Mode settings\n"); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsLowSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(kNsLowSuppression != nsMode); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsModerateSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(kNsModerateSuppression != nsMode); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsHighSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(kNsHighSuppression != nsMode); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsVeryHighSuppression)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(kNsVeryHighSuppression != nsMode); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsConference)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(kNsHighSuppression != nsMode); + TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsDefault)); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(nsModeDefault != nsMode); - TEST_LOG("Testing Mode settings\n"); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsLowSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(kNsLowSuppression != nsMode); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsModerateSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(kNsModerateSuppression != nsMode); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsHighSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(kNsHighSuppression != nsMode); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsVeryHighSuppression)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(kNsVeryHighSuppression != nsMode); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsConference)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(kNsHighSuppression != nsMode); - TEST_MUSTPASS(apm->SetRxNsStatus(0, true, kNsDefault)); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(nsModeDefault != nsMode); - - TEST_LOG("Turn OFF NS\n"); - TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); - TEST_MUSTPASS(test); + TEST_LOG("Turn OFF NS\n"); + TEST_MUSTPASS(apm->SetRxNsStatus(0, false)); + TEST_LOG("Should be OFF now\n"); + TEST_MUSTPASS(apm->GetRxNsStatus(0, test, nsMode)); + TEST_MUSTPASS(test); #else - TEST_LOG("Skipping NS tests - WEBRTC_VOICE_ENGINE_NR not defined \n"); + TEST_LOG("Skipping NS tests - WEBRTC_VOICE_ENGINE_NR not defined \n"); #endif // #ifdef WEBRTC_VOICE_ENGINE_NR - -#if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) && defined(WEBRTC_VOICE_ENGINE_NR)) +#if (!defined(MAC_IPHONE) && !defined(WEBRTC_ANDROID) && \ + defined(WEBRTC_VOICE_ENGINE_NR)) #ifdef WEBRTC_VOICE_ENGINE_ECHO - bool enabled = false; - TEST_LOG("EC Metrics calls\n"); - TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); // check default - TEST_MUSTPASS(enabled != false); - TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); // enable EC metrics - // must enable AEC to get valid echo metrics - TEST_MUSTPASS(apm->SetEcStatus(true, kEcAec)); - TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); - TEST_MUSTPASS(enabled != true); + bool enabled = false; + TEST_LOG("EC Metrics calls\n"); + TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); // check default + TEST_MUSTPASS(enabled != false); + TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); // enable EC metrics + // must enable AEC to get valid echo metrics + TEST_MUSTPASS(apm->SetEcStatus(true, kEcAec)); + TEST_MUSTPASS(apm->GetEcMetricsStatus(enabled)); + TEST_MUSTPASS(enabled != true); - TEST_LOG("Speak into microphone and check metrics for 10 seconds...\n"); - int ERL, ERLE, RERL, A_NLP; - int delay_median = 0; - int delay_std = 0; - for (int t = 0; t < 5; t++) { - SLEEP(2000); - TEST_MUSTPASS(apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); - TEST_MUSTPASS(apm->GetEcDelayMetrics(delay_median, delay_std)); - TEST_LOG(" Echo : ERL=%5d, ERLE=%5d, RERL=%5d, A_NLP=%5d [dB], " - " delay median=%3d, delay std=%3d [ms]\n", - ERL, ERLE, RERL, A_NLP, delay_median, delay_std); - } - TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); // disable echo metrics + TEST_LOG("Speak into microphone and check metrics for 10 seconds...\n"); + int ERL, ERLE, RERL, A_NLP; + int delay_median = 0; + int delay_std = 0; + for (int t = 0; t < 5; t++) { + SLEEP(2000); + TEST_MUSTPASS(apm->GetEchoMetrics(ERL, ERLE, RERL, A_NLP)); + TEST_MUSTPASS(apm->GetEcDelayMetrics(delay_median, delay_std)); + TEST_LOG(" Echo : ERL=%5d, ERLE=%5d, RERL=%5d, A_NLP=%5d [dB], " + " delay median=%3d, delay std=%3d [ms]\n", ERL, ERLE, RERL, A_NLP, + delay_median, delay_std); + } + TEST_MUSTPASS(apm->SetEcMetricsStatus(false)); // disable echo metrics #else - TEST_LOG("Skipping Echo Control metrics tests -" - " WEBRTC_VOICE_ENGINE_ECHO not defined \n"); + TEST_LOG("Skipping Echo Control metrics tests -" + " WEBRTC_VOICE_ENGINE_ECHO not defined \n"); #endif // #ifdef WEBRTC_VOICE_ENGINE_ECHO #else - TEST_LOG("Skipping apm metrics tests - MAC_IPHONE/WEBRTC_ANDROID defined \n"); + TEST_LOG("Skipping apm metrics tests - MAC_IPHONE/WEBRTC_ANDROID defined \n"); #endif // #if (!defined(MAC_IPHONE) && !d... - - // VAD/DTX indication - TEST_LOG("Get voice activity indication \n"); - if (codec) - { - bool v = true, dummy2; - VadModes dummy1; - TEST_MUSTPASS(codec->GetVADStatus(0, v, dummy1, dummy2)); - TEST_MUSTPASS(v); // Make sure VAD is disabled + // VAD/DTX indication + TEST_LOG("Get voice activity indication \n"); + if (codec) { + bool v = true, dummy2; + VadModes dummy1; + TEST_MUSTPASS(codec->GetVADStatus(0, v, dummy1, dummy2)); + TEST_MUSTPASS(v); // Make sure VAD is disabled + } + TEST_MUSTPASS(1 != apm->VoiceActivityIndicator(0)); + if (codec && volume) { + TEST_LOG("RX VAD detections may vary depending on current signal" + " and mic input \n"); +#if !defined(WEBRTC_ANDROID) && !defined(MAC_IPHONE) + RxCallback rxc; + TEST_MUSTPASS(apm->RegisterRxVadObserver(0, rxc)); +#endif + TEST_MUSTPASS(codec->SetVADStatus(0, true)); + TEST_MUSTPASS(volume->SetInputMute(0, true)); + if (file) { + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); } + SLEEP(500); // After sleeping we should have detected silence + TEST_MUSTPASS(0 != apm->VoiceActivityIndicator(0)); +#if !defined(WEBRTC_ANDROID) && !defined(MAC_IPHONE) + TEST_MUSTPASS(0 != rxc._vadDecision); +#endif + if (file) { + TEST_LOG("Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( + 0, AudioFilename(), true, true)); + } else { + TEST_LOG("==> Make sure you talk into the microphone \n"); + } + TEST_MUSTPASS(codec->SetVADStatus(0, false)); + TEST_MUSTPASS(volume->SetInputMute(0, false)); + SLEEP(500); // Sleep time selected by looking in mic play file, after + // sleep we should have detected voice TEST_MUSTPASS(1 != apm->VoiceActivityIndicator(0)); - if (codec && volume) - { - TEST_LOG ("RX VAD detections may vary depending on current signal" - " and mic input \n"); #if !defined(WEBRTC_ANDROID) && !defined(MAC_IPHONE) - RxCallback rxc; - TEST_MUSTPASS(apm->RegisterRxVadObserver(0, rxc)); + TEST_MUSTPASS(1 != rxc._vadDecision); + TEST_LOG("Disabling RX VAD detection, make sure you see no " + "detections\n"); + TEST_MUSTPASS(apm->DeRegisterRxVadObserver(0)); + SLEEP(2000); #endif - TEST_MUSTPASS(codec->SetVADStatus(0, true)); - TEST_MUSTPASS(volume->SetInputMute(0, true)); - if (file) - { - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - } - SLEEP(500); // After sleeping we should have detected silence - TEST_MUSTPASS(0 != apm->VoiceActivityIndicator(0)); -#if !defined(WEBRTC_ANDROID) && !defined(MAC_IPHONE) - TEST_MUSTPASS(0 != rxc._vadDecision); -#endif - if (file) - { - TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone( - 0, AudioFilename(), true, true)); - } - else - { - TEST_LOG("==> Make sure you talk into the microphone \n"); - } - TEST_MUSTPASS(codec->SetVADStatus(0, false)); - TEST_MUSTPASS(volume->SetInputMute(0, false)); - SLEEP(500); // Sleep time selected by looking in mic play file, after - // sleep we should have detected voice - TEST_MUSTPASS(1 != apm->VoiceActivityIndicator(0)); -#if !defined(WEBRTC_ANDROID) && !defined(MAC_IPHONE) - TEST_MUSTPASS(1 != rxc._vadDecision); - TEST_LOG("Disabling RX VAD detection, make sure you see no " - "detections\n"); - TEST_MUSTPASS(apm->DeRegisterRxVadObserver(0)); - SLEEP(2000); -#endif - } - else - { - TEST_LOG("Skipping voice activity indicator tests - codec and" - " volume APIs not available \n"); - } + } else { + TEST_LOG("Skipping voice activity indicator tests - codec and" + " volume APIs not available \n"); + } #else - TEST_LOG("\n\n+++ AudioProcessing tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ AudioProcessing tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_AUDIO_PROCESSING_ - - //////// - // File + //////// + // File #ifdef _TEST_FILE_ - TEST_LOG("\n\n+++ File tests +++\n\n"); + TEST_LOG("\n\n+++ File tests +++\n\n"); - // test of UTF8 using swedish letters åäö + // test of UTF8 using swedish letters åäö - char fileName[64]; - fileName[0] = (char)0xc3; - fileName[1] = (char)0xa5; - fileName[2] = (char)0xc3; - fileName[3] = (char)0xa4; - fileName[4] = (char)0xc3; - fileName[5] = (char)0xb6; - fileName[6] = '.'; - fileName[7] = 'p'; - fileName[8] = 'c'; - fileName[9] = 'm'; - fileName[10] = 0; + char fileName[64]; + fileName[0] = (char) 0xc3; + fileName[1] = (char) 0xa5; + fileName[2] = (char) 0xc3; + fileName[3] = (char) 0xa4; + fileName[4] = (char) 0xc3; + fileName[5] = (char) 0xb6; + fileName[6] = '.'; + fileName[7] = 'p'; + fileName[8] = 'c'; + fileName[9] = 'm'; + fileName[10] = 0; - // test of UTF8 using japanese Hirigana "ぁあ"letter small A and letter A -/* fileName[0] = (char)0xe3; - fileName[1] = (char)0x81; - fileName[2] = (char)0x81; - fileName[3] = (char)0xe3; - fileName[4] = (char)0x81; - fileName[5] = (char)0x82; - fileName[6] = '.'; - fileName[7] = 'p'; - fileName[8] = 'c'; - fileName[9] = 'm'; - fileName[10] = 0; -*/ + // test of UTF8 using japanese Hirigana "ぁあ"letter small A and letter A + /* fileName[0] = (char)0xe3; + fileName[1] = (char)0x81; + fileName[2] = (char)0x81; + fileName[3] = (char)0xe3; + fileName[4] = (char)0x81; + fileName[5] = (char)0x82; + fileName[6] = '.'; + fileName[7] = 'p'; + fileName[8] = 'c'; + fileName[9] = 'm'; + fileName[10] = 0; + */ - // Part of the cyrillic alpabet - // Ф Х Ѡ Ц Ч Ш Щ Ъ ЪІ Ь Ѣ + // Part of the cyrillic alpabet + // Ф Х Ѡ Ц Ч Ш Щ Ъ ЪІ Ь Ѣ - const char* recName = GetFilename(fileName); - // Generated with + const char* recName = GetFilename(fileName); + // Generated with #if _WIN32 -/* char tempFileNameUTF8[200]; - int err = WideCharToMultiByte(CP_UTF8,0,L"åäö", -1, tempFileNameUTF8, - sizeof(tempFileNameUTF8), NULL, NULL); -*/ + /* char tempFileNameUTF8[200]; + int err = WideCharToMultiByte(CP_UTF8,0,L"åäö", -1, tempFileNameUTF8, + sizeof(tempFileNameUTF8), NULL, NULL); + */ #endif - //Stop the current file - TEST_LOG("Stop playing file as microphone \n"); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_LOG("==> Talk into the microphone \n"); - SLEEP(1000); - TEST_LOG("Record mic for 3 seconds in PCM format\n"); - TEST_MUSTPASS(file->StartRecordingMicrophone(recName)); - SLEEP(3000); - TEST_MUSTPASS(file->StopRecordingMicrophone()); - TEST_LOG("Play out the recorded file...\n"); - TEST_MUSTPASS(file->StartPlayingFileLocally(0, recName)); - SLEEP(2000); + //Stop the current file + TEST_LOG("Stop playing file as microphone \n"); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_LOG("==> Talk into the microphone \n"); + SLEEP(1000); + TEST_LOG("Record mic for 3 seconds in PCM format\n"); + TEST_MUSTPASS(file->StartRecordingMicrophone(recName)); + SLEEP(3000); + TEST_MUSTPASS(file->StopRecordingMicrophone()); + TEST_LOG("Play out the recorded file...\n"); + TEST_MUSTPASS(file->StartPlayingFileLocally(0, recName)); + SLEEP(2000); #ifndef _INSTRUMENTATION_TESTING_ - TEST_LOG("After 2 seconds we should still be playing\n"); - TEST_MUSTPASS(!file->IsPlayingFileLocally(0)); + TEST_LOG("After 2 seconds we should still be playing\n"); + TEST_MUSTPASS(!file->IsPlayingFileLocally(0)); #endif - TEST_LOG("Set scaling\n"); - TEST_MUSTPASS(file->ScaleLocalFilePlayout(0,(float)0.11)); - SLEEP(1100); - TEST_LOG("After 3.1 seconds we should NOT be playing\n"); - TEST_MUSTPASS(file->IsPlayingFileLocally(0)); + TEST_LOG("Set scaling\n"); + TEST_MUSTPASS(file->ScaleLocalFilePlayout(0,(float)0.11)); + SLEEP(1100); + TEST_LOG("After 3.1 seconds we should NOT be playing\n"); + TEST_MUSTPASS(file->IsPlayingFileLocally(0)); - CodecInst codec; - TEST_LOG("Record speaker for 3 seconds to wav file\n"); - memset(&codec, 0, sizeof(CodecInst)); - strcpy(codec.plname,"pcmu"); - codec.plfreq=8000; - codec.channels=1; - codec.pacsize=160; - codec.pltype=0; - codec.rate=64000; - TEST_MUSTPASS(file->StartRecordingPlayout(0,recName,&codec)); - SLEEP(3000); - TEST_MUSTPASS(file->StopRecordingPlayout(0)); + CodecInst codec; + TEST_LOG("Record speaker for 3 seconds to wav file\n"); + memset(&codec, 0, sizeof(CodecInst)); + strcpy(codec.plname, "pcmu"); + codec.plfreq = 8000; + codec.channels = 1; + codec.pacsize = 160; + codec.pltype = 0; + codec.rate = 64000; + TEST_MUSTPASS(file->StartRecordingPlayout(0,recName,&codec)); + SLEEP(3000); + TEST_MUSTPASS(file->StopRecordingPlayout(0)); - TEST_LOG("Play file as mic, looping for 3 seconds\n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - recName, - 1, - 0, - kFileFormatWavFile)); - SLEEP(3000); - TEST_LOG("After 3 seconds we should still be playing\n"); - TEST_MUSTPASS(!file->IsPlayingFileAsMicrophone(0)); - SLEEP(600); - TEST_LOG("After 3.6 seconds we should still be playing\n"); - TEST_MUSTPASS(!file->IsPlayingFileAsMicrophone(0)); + TEST_LOG("Play file as mic, looping for 3 seconds\n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + recName, + 1, + 0, + kFileFormatWavFile)); + SLEEP(3000); + TEST_LOG("After 3 seconds we should still be playing\n"); + TEST_MUSTPASS(!file->IsPlayingFileAsMicrophone(0)); + SLEEP(600); + TEST_LOG("After 3.6 seconds we should still be playing\n"); + TEST_MUSTPASS(!file->IsPlayingFileAsMicrophone(0)); - TEST_LOG("Set scaling\n"); - TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(0,(float)0.11)); - SLEEP(200); + TEST_LOG("Set scaling\n"); + TEST_MUSTPASS(file->ScaleFileAsMicrophonePlayout(0,(float)0.11)); + SLEEP(200); - TEST_LOG("Stop playing file as microphone\n"); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_LOG("Stop playing file as microphone\n"); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, AudioFilename(), - true, true)); + TEST_LOG("==> Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, AudioFilename(), + true, true)); #else - TEST_LOG("\n\n+++ File tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ File tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_FILE_ - #ifdef _XTENDED_TEST_FILE_ - // Create unique trace files for this test - TEST_MUSTPASS(base->SetTraceFileName(GetFilename("VoEFile_trace.txt"))); - TEST_MUSTPASS(base->SetDebugTraceFileName(GetFilename( - "VoEFile_trace_debug.txt"))); - // turn off default AGC during these tests - TEST_MUSTPASS(apm->SetAgcStatus(false)); - int res = xtend.TestFile(file); + // Create unique trace files for this test + TEST_MUSTPASS(base->SetTraceFileName(GetFilename("VoEFile_trace.txt"))); + TEST_MUSTPASS(base->SetDebugTraceFileName(GetFilename( + "VoEFile_trace_debug.txt"))); + // turn off default AGC during these tests + TEST_MUSTPASS(apm->SetAgcStatus(false)); + int res = xtend.TestFile(file); #ifndef MAC_IPHONE - TEST_MUSTPASS(apm->SetAgcStatus(true)); // restore AGC state + TEST_MUSTPASS(apm->SetAgcStatus(true)); // restore AGC state #endif - TEST_MUSTPASS(base->Terminate()); - return res; + TEST_MUSTPASS(base->Terminate()); + return res; #endif - //////////// - // Network + //////////// + // Network #ifdef _TEST_NETWORK_ - TEST_LOG("\n\n+++ Network tests +++\n\n"); + TEST_LOG("\n\n+++ Network tests +++\n\n"); #ifndef WEBRTC_EXTERNAL_TRANSPORT - int sourceRtpPort = 1234; - int sourceRtcpPort = 1235; + int sourceRtpPort = 1234; + int sourceRtcpPort = 1235; - int filterPort = -1; - int filterPortRTCP = -1; - char sourceIp[32] = "127.0.0.1"; - char filterIp[64] = {0}; + int filterPort = -1; + int filterPortRTCP = -1; + char sourceIp[32] = "127.0.0.1"; + char filterIp[64] = { 0 }; - SLEEP(200); // Make sure we have received packets + SLEEP(200); // Make sure we have received packets - TEST_MUSTPASS(netw->GetSourceInfo(0, - sourceRtpPort, - sourceRtcpPort, - sourceIp)); + TEST_MUSTPASS(netw->GetSourceInfo(0, + sourceRtpPort, + sourceRtcpPort, + sourceIp)); - TEST_LOG("sourceIp = %s, sourceRtpPort = %d, sourceRtcpPort = %d\n", - sourceIp, sourceRtpPort, sourceRtcpPort); - TEST_MUSTPASS(8000 != sourceRtpPort); - TEST_MUSTPASS(8001 != sourceRtcpPort); + TEST_LOG("sourceIp = %s, sourceRtpPort = %d, sourceRtcpPort = %d\n", + sourceIp, sourceRtpPort, sourceRtcpPort); + TEST_MUSTPASS(8000 != sourceRtpPort); + TEST_MUSTPASS(8001 != sourceRtcpPort); - TEST_MUSTPASS(netw->GetSourceFilter(0, - filterPort, - filterPortRTCP, - filterIp)); - TEST_MUSTPASS(0 != filterPort); - TEST_MUSTPASS(0 != filterPortRTCP); - TEST_MUSTPASS(_stricmp(filterIp, "")); + TEST_MUSTPASS(netw->GetSourceFilter(0, + filterPort, + filterPortRTCP, + filterIp)); + TEST_MUSTPASS(0 != filterPort); + TEST_MUSTPASS(0 != filterPortRTCP); + TEST_MUSTPASS(_stricmp(filterIp, "")); - TEST_LOG("Set filter port to %d => should hear audio\n", sourceRtpPort); - TEST_MUSTPASS(netw->SetSourceFilter(0, - sourceRtpPort, - sourceRtcpPort, - "0.0.0.0")); - TEST_MUSTPASS(netw->GetSourceFilter(0, - filterPort, - filterPortRTCP, - filterIp)); - TEST_MUSTPASS(sourceRtpPort != filterPort); - TEST_MUSTPASS(sourceRtcpPort != filterPortRTCP); - TEST_MUSTPASS(_stricmp(filterIp, "0.0.0.0")); - SLEEP(1000); - TEST_LOG("Set filter port to %d => should *not* hear audio\n", - sourceRtpPort+10); - TEST_MUSTPASS(netw->SetSourceFilter(0, sourceRtpPort+10)); - TEST_MUSTPASS(netw->GetSourceFilter(0, - filterPort, - filterPortRTCP, - filterIp)); - TEST_MUSTPASS(sourceRtpPort+10 != filterPort); - SLEEP(1000); - TEST_LOG("Disable port filter => should hear audio again\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0)); - SLEEP(1000); + TEST_LOG("Set filter port to %d => should hear audio\n", sourceRtpPort); + TEST_MUSTPASS(netw->SetSourceFilter(0, + sourceRtpPort, + sourceRtcpPort, + "0.0.0.0")); + TEST_MUSTPASS(netw->GetSourceFilter(0, + filterPort, + filterPortRTCP, + filterIp)); + TEST_MUSTPASS(sourceRtpPort != filterPort); + TEST_MUSTPASS(sourceRtcpPort != filterPortRTCP); + TEST_MUSTPASS(_stricmp(filterIp, "0.0.0.0")); + SLEEP(1000); + TEST_LOG("Set filter port to %d => should *not* hear audio\n", + sourceRtpPort + 10); + TEST_MUSTPASS(netw->SetSourceFilter(0, sourceRtpPort+10)); + TEST_MUSTPASS(netw->GetSourceFilter(0, + filterPort, + filterPortRTCP, + filterIp)); + TEST_MUSTPASS(sourceRtpPort+10 != filterPort); + SLEEP(1000); + TEST_LOG("Disable port filter => should hear audio again\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0)); + SLEEP(1000); - if(rtp_rtcp) - { - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Tomas")); - } + if (rtp_rtcp) { + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Tomas")); + } - TEST_LOG("Set filter IP to %s => should hear audio\n", sourceIp); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, sourceIp)); - TEST_MUSTPASS(netw->GetSourceFilter(0, - filterPort, - filterPortRTCP, - filterIp)); - TEST_MUSTPASS(_stricmp(filterIp, sourceIp)); - SLEEP(1000); - TEST_LOG("Set filter IP to 10.10.10.10 => should *not* hear audio\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, - "10.10.10.10")); - TEST_MUSTPASS(netw->GetSourceFilter(0, filterPort, filterPort, filterIp)); - TEST_MUSTPASS(_stricmp(filterIp, "10.10.10.10")); - SLEEP(1000); - TEST_LOG("Disable IP filter => should hear audio again\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, "0.0.0.0")); - SLEEP(1000); - TEST_LOG("Set filter IP to 10.10.10.10 => should *not* hear audio\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, - "10.10.10.10")); - SLEEP(1000); + TEST_LOG("Set filter IP to %s => should hear audio\n", sourceIp); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, sourceIp)); + TEST_MUSTPASS(netw->GetSourceFilter(0, + filterPort, + filterPortRTCP, + filterIp)); + TEST_MUSTPASS(_stricmp(filterIp, sourceIp)); + SLEEP(1000); + TEST_LOG("Set filter IP to 10.10.10.10 => should *not* hear audio\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, + "10.10.10.10")); + TEST_MUSTPASS(netw->GetSourceFilter(0, filterPort, filterPort, filterIp)); + TEST_MUSTPASS(_stricmp(filterIp, "10.10.10.10")); + SLEEP(1000); + TEST_LOG("Disable IP filter => should hear audio again\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, "0.0.0.0")); + SLEEP(1000); + TEST_LOG("Set filter IP to 10.10.10.10 => should *not* hear audio\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, sourceRtcpPort+10, + "10.10.10.10")); + SLEEP(1000); - if(rtp_rtcp) - { - char tmpStr[64]; - SLEEP(2000); - TEST_LOG("Checking RTCP port filter with CNAME...\n"); - TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); - TEST_MUSTPASS(!_stricmp("Tomas", tmpStr)); - TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Niklas")); - } - else - { - TEST_LOG("Skipping RTCP port filter test since there is no RTP/RTCP " - "interface!\n"); - } - - TEST_LOG("Disable IP filter => should hear audio again\n"); - TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); - TEST_MUSTPASS(netw->GetSourceFilter(0, filterPort, filterPortRTCP, - filterIp)); - TEST_MUSTPASS(_stricmp(filterIp, "")); - SLEEP(1000); - - TEST_LOG("Wait 2 seconds for packet timeout...\n"); - TEST_LOG("You should see runtime error %d\n", VE_RECEIVE_PACKET_TIMEOUT); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); - SLEEP(3000); - - #if !defined(_INSTRUMENTATION_TESTING_) - TEST_LOG("obs.code is %d\n", obs.code); - TEST_MUSTPASS(obs.code != VE_RECEIVE_PACKET_TIMEOUT); - #endif - obs.code=-1; - TEST_MUSTPASS(base->StartSend(0)); - if (file) - { - TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - } - TEST_LOG("You should see runtime error %d\n", VE_PACKET_RECEIPT_RESTARTED); - SLEEP(1000); - #if !defined(_INSTRUMENTATION_TESTING_) - TEST_MUSTPASS(obs.code != VE_PACKET_RECEIPT_RESTARTED); - #endif - - #if !defined(_INSTRUMENTATION_TESTING_) - TEST_LOG("Disabling observer, no runtime error should be seen...\n"); - TEST_MUSTPASS(base->DeRegisterVoiceEngineObserver()); - obs.code = -1; - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); - SLEEP(2500); - TEST_MUSTPASS(obs.code != -1); - // disable notifications to avoid additional 8082 callbacks - TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, false, 2)); - TEST_MUSTPASS(base->StartSend(0)); - if (file) - { - TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - } - SLEEP(1000); -/// TEST_MUSTPASS(obs.code != -1); - TEST_LOG("Enabling observer again\n"); - TEST_MUSTPASS(base->RegisterVoiceEngineObserver(obs)); - #endif - - TEST_LOG("Enable dead-or-alive callbacks for 4 seconds (dT=1sec)...\n"); - TEST_LOG("You should see ALIVE messages\n"); - - MyDeadOrAlive obs; - TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, obs)); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); - SLEEP(4000); - - // stop sending and flush dead-or-alive states - if (rtp_rtcp) - { - TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); - } - TEST_MUSTPASS(base->StopSend(0)); - SLEEP(500); - - TEST_LOG("Disable sending for 4 seconds (dT=1sec)...\n"); - TEST_LOG("You should see DEAD messages (one ALIVE message might" - " sneak in if you are unlucky)\n"); - SLEEP(4000); - TEST_LOG("Disable dead-or-alive callbacks.\n"); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); - - TEST_LOG("Enabling external transport\n"); - TEST_MUSTPASS(base->StopReceive(0)); - - // recreate the channel to ensure that we can switch from transport - // to external transport - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->CreateChannel()); - - TEST_MUSTPASS(netw->RegisterExternalTransport(0, ch0transport)); - - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - if (file) - { - TEST_LOG("Start playing a file as microphone again using" - " external transport\n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - } - SLEEP(4000); - - TEST_LOG("Disabling external transport\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopReceive(0)); - - TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); - - TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); - TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); - - TEST_MUSTPASS(base->StartReceive(0)); - TEST_MUSTPASS(base->StartSend(0)); - TEST_MUSTPASS(base->StartPlayout(0)); - if (file) - { - TEST_LOG("Start playing a file as microphone again using transport\n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - } + if (rtp_rtcp) { + char tmpStr[64]; SLEEP(2000); + TEST_LOG("Checking RTCP port filter with CNAME...\n"); + TEST_MUSTPASS(rtp_rtcp->GetRemoteRTCP_CNAME(0, tmpStr)); + TEST_MUSTPASS(!_stricmp("Tomas", tmpStr)); + TEST_MUSTPASS(rtp_rtcp->SetRTCP_CNAME(0, "Niklas")); + } else { + TEST_LOG("Skipping RTCP port filter test since there is no RTP/RTCP " + "interface!\n"); + } + + TEST_LOG("Disable IP filter => should hear audio again\n"); + TEST_MUSTPASS(netw->SetSourceFilter(0, 0, 0, NULL)); + TEST_MUSTPASS(netw->GetSourceFilter(0, filterPort, filterPortRTCP, + filterIp)); + TEST_MUSTPASS(_stricmp(filterIp, "")); + SLEEP(1000); + + TEST_LOG("Wait 2 seconds for packet timeout...\n"); + TEST_LOG("You should see runtime error %d\n", VE_RECEIVE_PACKET_TIMEOUT); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); + SLEEP(3000); + +#if !defined(_INSTRUMENTATION_TESTING_) + TEST_LOG("obs.code is %d\n", obs.code); + TEST_MUSTPASS(obs.code != VE_RECEIVE_PACKET_TIMEOUT); +#endif + obs.code = -1; + TEST_MUSTPASS(base->StartSend(0)); + if (file) { + TEST_LOG("Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + } + TEST_LOG("You should see runtime error %d\n", VE_PACKET_RECEIPT_RESTARTED); + SLEEP(1000); +#if !defined(_INSTRUMENTATION_TESTING_) + TEST_MUSTPASS(obs.code != VE_PACKET_RECEIPT_RESTARTED); +#endif + +#if !defined(_INSTRUMENTATION_TESTING_) + TEST_LOG("Disabling observer, no runtime error should be seen...\n"); + TEST_MUSTPASS(base->DeRegisterVoiceEngineObserver()); + obs.code = -1; + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, true, 2)); + SLEEP(2500); + TEST_MUSTPASS(obs.code != -1); + // disable notifications to avoid additional 8082 callbacks + TEST_MUSTPASS(netw->SetPacketTimeoutNotification(0, false, 2)); + TEST_MUSTPASS(base->StartSend(0)); + if (file) { + TEST_LOG("Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + } + SLEEP(1000); + /// TEST_MUSTPASS(obs.code != -1); + TEST_LOG("Enabling observer again\n"); + TEST_MUSTPASS(base->RegisterVoiceEngineObserver(obs)); +#endif + + TEST_LOG("Enable dead-or-alive callbacks for 4 seconds (dT=1sec)...\n"); + TEST_LOG("You should see ALIVE messages\n"); + + MyDeadOrAlive obs; + TEST_MUSTPASS(netw->RegisterDeadOrAliveObserver(0, obs)); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); + SLEEP(4000); + + // stop sending and flush dead-or-alive states + if (rtp_rtcp) { + TEST_MUSTPASS(rtp_rtcp->SetRTCPStatus(0, false)); + } + TEST_MUSTPASS(base->StopSend(0)); + SLEEP(500); + + TEST_LOG("Disable sending for 4 seconds (dT=1sec)...\n"); + TEST_LOG("You should see DEAD messages (one ALIVE message might" + " sneak in if you are unlucky)\n"); + SLEEP(4000); + TEST_LOG("Disable dead-or-alive callbacks.\n"); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); + + TEST_LOG("Enabling external transport\n"); + TEST_MUSTPASS(base->StopReceive(0)); + + // recreate the channel to ensure that we can switch from transport + // to external transport + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->CreateChannel()); + + TEST_MUSTPASS(netw->RegisterExternalTransport(0, ch0transport)); + + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + if (file) { + TEST_LOG("Start playing a file as microphone again using" + " external transport\n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + } + SLEEP(4000); + + TEST_LOG("Disabling external transport\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopReceive(0)); + + TEST_MUSTPASS(netw->DeRegisterExternalTransport(0)); + + TEST_MUSTPASS(base->SetSendDestination(0, 8000, "127.0.0.1")); + TEST_MUSTPASS(base->SetLocalReceiver(0, 8000)); + + TEST_MUSTPASS(base->StartReceive(0)); + TEST_MUSTPASS(base->StartSend(0)); + TEST_MUSTPASS(base->StartPlayout(0)); + if (file) { + TEST_LOG("Start playing a file as microphone again using transport\n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + } + SLEEP(2000); #else - TEST_LOG("Skipping network tests - " - "WEBRTC_EXTERNAL_TRANSPORT is defined \n"); + TEST_LOG("Skipping network tests - " + "WEBRTC_EXTERNAL_TRANSPORT is defined \n"); #endif // #ifndef WEBRTC_EXTERNAL_TRANSPORT #else - TEST_LOG("\n\n+++ Network tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Network tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_NETWORK_ - - /////////////// - // CallReport + /////////////// + // CallReport #ifdef _TEST_CALL_REPORT_ - TEST_LOG("\n\n+++ CallReport tests +++\n\n"); + TEST_LOG("\n\n+++ CallReport tests +++\n\n"); #if (defined(WEBRTC_VOICE_ENGINE_ECHO) && defined(WEBRTC_VOICE_ENGINE_NR)) - TEST(ResetCallReportStatistics);ANL(); - TEST_MUSTPASS(!report->ResetCallReportStatistics(-2)); - TEST_MUSTPASS(!report->ResetCallReportStatistics(1)); - TEST_MUSTPASS(report->ResetCallReportStatistics(0)); - TEST_MUSTPASS(report->ResetCallReportStatistics(-1)); + TEST(ResetCallReportStatistics);ANL(); + TEST_MUSTPASS(!report->ResetCallReportStatistics(-2)); + TEST_MUSTPASS(!report->ResetCallReportStatistics(1)); + TEST_MUSTPASS(report->ResetCallReportStatistics(0)); + TEST_MUSTPASS(report->ResetCallReportStatistics(-1)); - bool onOff; - TEST_MUSTPASS(apm->GetEcMetricsStatus(onOff)); - TEST_MUSTPASS(onOff != false); - TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); - SLEEP(3000); - EchoStatistics echo; - TEST(GetEchoMetricSummary);ANL(); - // all outputs will be -100 in loopback (skip further tests) - TEST_MUSTPASS(report->GetEchoMetricSummary(echo)); + bool onOff; + TEST_MUSTPASS(apm->GetEcMetricsStatus(onOff)); + TEST_MUSTPASS(onOff != false); + TEST_MUSTPASS(apm->SetEcMetricsStatus(true)); + SLEEP(3000); + EchoStatistics echo; + TEST(GetEchoMetricSummary);ANL(); + // all outputs will be -100 in loopback (skip further tests) + TEST_MUSTPASS(report->GetEchoMetricSummary(echo)); - StatVal delays; - TEST(GetRoundTripTimeSummary);ANL(); - rtp_rtcp->SetRTCPStatus(0, false); - // All values should be -1 since RTCP is off - TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); - TEST_MUSTPASS(delays.min != -1); - TEST_MUSTPASS(delays.max != -1); - TEST_MUSTPASS(delays.average != -1); - rtp_rtcp->SetRTCPStatus(0, true); - SLEEP(5000); // gives time for RTCP - TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); - TEST_MUSTPASS(delays.min == -1); - TEST_MUSTPASS(delays.max == -1); - TEST_MUSTPASS(delays.average == -1); - rtp_rtcp->SetRTCPStatus(0, false); + StatVal delays; + TEST(GetRoundTripTimeSummary);ANL(); + rtp_rtcp->SetRTCPStatus(0, false); + // All values should be -1 since RTCP is off + TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); + TEST_MUSTPASS(delays.min != -1); + TEST_MUSTPASS(delays.max != -1); + TEST_MUSTPASS(delays.average != -1); + rtp_rtcp->SetRTCPStatus(0, true); + SLEEP(5000); // gives time for RTCP + TEST_MUSTPASS(report->GetRoundTripTimeSummary(0, delays)); + TEST_MUSTPASS(delays.min == -1); + TEST_MUSTPASS(delays.max == -1); + TEST_MUSTPASS(delays.average == -1); + rtp_rtcp->SetRTCPStatus(0, false); - int nDead = 0; - int nAlive = 0; - // -1 will be returned since dead-or-alive is not active - TEST(GetDeadOrAliveSummary);ANL(); - TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive) != -1); - // we don't need these callbacks any longer - TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); - SLEEP(2000); - // All results should be >= 0 since dead-or-alive is active - TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive)); - TEST_MUSTPASS(nDead == -1);TEST_MUSTPASS(nAlive == -1) - TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); + int nDead = 0; + int nAlive = 0; + // -1 will be returned since dead-or-alive is not active + TEST(GetDeadOrAliveSummary);ANL(); + TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive) != -1); + // we don't need these callbacks any longer + TEST_MUSTPASS(netw->DeRegisterDeadOrAliveObserver(0)); + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, true, 1)); + SLEEP(2000); + // All results should be >= 0 since dead-or-alive is active + TEST_MUSTPASS(report->GetDeadOrAliveSummary(0, nDead, nAlive)); + TEST_MUSTPASS(nDead == -1);TEST_MUSTPASS(nAlive == -1) + TEST_MUSTPASS(netw->SetPeriodicDeadOrAliveStatus(0, false)); - TEST(WriteReportToFile);ANL(); - TEST_MUSTPASS(!report->WriteReportToFile(NULL)); - TEST_MUSTPASS(report->WriteReportToFile("call_report.txt")); + TEST(WriteReportToFile);ANL(); + TEST_MUSTPASS(!report->WriteReportToFile(NULL)); + TEST_MUSTPASS(report->WriteReportToFile("call_report.txt")); #else - TEST_LOG("Skipping CallReport tests since both EC and NS are required\n"); + TEST_LOG("Skipping CallReport tests since both EC and NS are required\n"); #endif #else - TEST_LOG("\n\n+++ CallReport tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ CallReport tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_CALL_REPORT_ - - ////////////// - // Video Sync + ////////////// + // Video Sync #ifdef _TEST_VIDEO_SYNC_ - TEST_LOG("\n\n+++ Video sync tests +++\n\n"); + TEST_LOG("\n\n+++ Video sync tests +++\n\n"); - unsigned int val; - TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, val)); - TEST_LOG("Playout timestamp = %lu\n", (long unsigned int)val); + unsigned int val; + TEST_MUSTPASS(vsync->GetPlayoutTimestamp(0, val)); + TEST_LOG("Playout timestamp = %lu\n", (long unsigned int) val); - TEST_LOG("Init timestamp and sequence number manually\n"); - TEST_MUSTPASS(!vsync->SetInitTimestamp(0, 12345)); - TEST_MUSTPASS(!vsync->SetInitSequenceNumber(0, 123)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(vsync->SetInitTimestamp(0, 12345)); - TEST_MUSTPASS(vsync->SetInitSequenceNumber(0, 123)); - TEST_MUSTPASS(base->StartSend(0)); - if (file) - { - TEST_LOG("Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, - AudioFilename(), - true, - true)); - } - SLEEP(3000); + TEST_LOG("Init timestamp and sequence number manually\n"); + TEST_MUSTPASS(!vsync->SetInitTimestamp(0, 12345)); + TEST_MUSTPASS(!vsync->SetInitSequenceNumber(0, 123)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(vsync->SetInitTimestamp(0, 12345)); + TEST_MUSTPASS(vsync->SetInitSequenceNumber(0, 123)); + TEST_MUSTPASS(base->StartSend(0)); + if (file) { + TEST_LOG("Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, + AudioFilename(), + true, + true)); + } + SLEEP(3000); - TEST_LOG("Check delay estimates during 15 seconds, verify that " - "they stabilize during this time\n"); - int valInt = -1; - for (int i = 0; i < 15; i++) - { - TEST_MUSTPASS(vsync->GetDelayEstimate(0, valInt)); - TEST_LOG("Delay estimate = %d ms\n", valInt); + TEST_LOG("Check delay estimates during 15 seconds, verify that " + "they stabilize during this time\n"); + int valInt = -1; + for (int i = 0; i < 15; i++) { + TEST_MUSTPASS(vsync->GetDelayEstimate(0, valInt)); + TEST_LOG("Delay estimate = %d ms\n", valInt); #if defined(MAC_IPHONE) - TEST_MUSTPASS(valInt <= 30); + TEST_MUSTPASS(valInt <= 30); #else - TEST_MUSTPASS(valInt <= 45); // 45=20+25 => can't be this low + TEST_MUSTPASS(valInt <= 45); // 45=20+25 => can't be this low #endif - SLEEP(1000); - } + SLEEP(1000); + } - TEST_LOG("Setting NetEQ min delay to 500 milliseconds and repeat " - "the test above\n"); - TEST_MUSTPASS(vsync->SetMinimumPlayoutDelay(0, 500)); - for (int i = 0; i < 15; i++) - { - TEST_MUSTPASS(vsync->GetDelayEstimate(0, valInt)); - TEST_LOG("Delay estimate = %d ms\n", valInt); - TEST_MUSTPASS(valInt <= 45); - SLEEP(1000); - } + TEST_LOG("Setting NetEQ min delay to 500 milliseconds and repeat " + "the test above\n"); + TEST_MUSTPASS(vsync->SetMinimumPlayoutDelay(0, 500)); + for (int i = 0; i < 15; i++) { + TEST_MUSTPASS(vsync->GetDelayEstimate(0, valInt)); + TEST_LOG("Delay estimate = %d ms\n", valInt); + TEST_MUSTPASS(valInt <= 45); + SLEEP(1000); + } - TEST_LOG("Setting NetEQ min delay to 0 milliseconds and repeat" - " the test above\n"); - TEST_MUSTPASS(vsync->SetMinimumPlayoutDelay(0, 0)); - for (int i = 0; i < 15; i++) - { - TEST_MUSTPASS(vsync->GetDelayEstimate(0, valInt)); - TEST_LOG("Delay estimate = %d ms\n", valInt); - TEST_MUSTPASS(valInt <= 45); - SLEEP(1000); - } + TEST_LOG("Setting NetEQ min delay to 0 milliseconds and repeat" + " the test above\n"); + TEST_MUSTPASS(vsync->SetMinimumPlayoutDelay(0, 0)); + for (int i = 0; i < 15; i++) { + TEST_MUSTPASS(vsync->GetDelayEstimate(0, valInt)); + TEST_LOG("Delay estimate = %d ms\n", valInt); + TEST_MUSTPASS(valInt <= 45); + SLEEP(1000); + } #if (defined (_WIN32) || (defined(WEBRTC_LINUX)) && !defined(WEBRTC_ANDROID)) - valInt = -1; - TEST_MUSTPASS(vsync->GetPlayoutBufferSize(valInt)); - TEST_LOG("Soundcard buffer size = %d ms\n", valInt); + valInt = -1; + TEST_MUSTPASS(vsync->GetPlayoutBufferSize(valInt)); + TEST_LOG("Soundcard buffer size = %d ms\n", valInt); #endif #else - TEST_LOG("\n\n+++ Video sync tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Video sync tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_VIDEO_SYNC_ - - ////////////// - // Encryption + ////////////// + // Encryption #ifdef _TEST_ENCRYPT_ - TEST_LOG("\n\n+++ Encryption tests +++\n\n"); + TEST_LOG("\n\n+++ Encryption tests +++\n\n"); #ifdef WEBRTC_SRTP - TEST_LOG("SRTP tests:\n"); + TEST_LOG("SRTP tests:\n"); - unsigned char encrKey[30] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; + unsigned char encrKey[30] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; - TEST_LOG("Enable SRTP encryption and decryption, you should still hear" - " the voice\n"); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, - kCipherAes128CounterMode, - 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, encrKey)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, - kCipherAes128CounterMode, - 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, encrKey)); - SLEEP(2000); + TEST_LOG("Enable SRTP encryption and decryption, you should still hear" + " the voice\n"); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, + kCipherAes128CounterMode, + 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, encrKey)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, + kCipherAes128CounterMode, + 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, encrKey)); + SLEEP(2000); - TEST_LOG("Disabling decryption, you should hear nothing or garbage\n"); - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - SLEEP(2000); + TEST_LOG("Disabling decryption, you should hear nothing or garbage\n"); + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + SLEEP(2000); - TEST_LOG("Enable decryption again, you should hear the voice again\n"); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, - kCipherAes128CounterMode, - 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, encrKey)); - SLEEP(2000); + TEST_LOG("Enable decryption again, you should hear the voice again\n"); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, + kCipherAes128CounterMode, + 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, encrKey)); + SLEEP(2000); - TEST_LOG("Disabling encryption and enabling decryption, you should" - " hear nothing\n"); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - SLEEP(2000); + TEST_LOG("Disabling encryption and enabling decryption, you should" + " hear nothing\n"); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + SLEEP(2000); - TEST_LOG("Back to normal\n"); - // both SRTP sides are now inactive - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - SLEEP(2000); + TEST_LOG("Back to normal\n"); + // both SRTP sides are now inactive + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + SLEEP(2000); - TEST_LOG("Enable SRTP and SRTCP encryption and decryption," - " you should still hear the voice\n"); - TEST_MUSTPASS(encrypt->EnableSRTPSend(0, - kCipherAes128CounterMode, - 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, encrKey, true)); - TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, - kCipherAes128CounterMode, - 30, - kAuthHmacSha1, - 20, 4, kEncryptionAndAuthentication, encrKey, true)); - SLEEP(2000); + TEST_LOG("Enable SRTP and SRTCP encryption and decryption," + " you should still hear the voice\n"); + TEST_MUSTPASS(encrypt->EnableSRTPSend(0, + kCipherAes128CounterMode, + 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, encrKey, true)); + TEST_MUSTPASS(encrypt->EnableSRTPReceive(0, + kCipherAes128CounterMode, + 30, + kAuthHmacSha1, + 20, 4, kEncryptionAndAuthentication, encrKey, true)); + SLEEP(2000); - TEST_LOG("Back to normal\n"); - TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); - // both SRTP sides are now inactive - TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); - SLEEP(2000); + TEST_LOG("Back to normal\n"); + TEST_MUSTPASS(encrypt->DisableSRTPSend(0)); + // both SRTP sides are now inactive + TEST_MUSTPASS(encrypt->DisableSRTPReceive(0)); + SLEEP(2000); #else - TEST_LOG("Skipping SRTP tests - WEBRTC_SRTP not defined \n"); + TEST_LOG("Skipping SRTP tests - WEBRTC_SRTP not defined \n"); #endif // #ifdef WEBRTC_SRTP - - TEST_LOG("\nExternal encryption tests:\n"); - my_encryption * encObj = new my_encryption; - TEST_MUSTPASS(encrypt->RegisterExternalEncryption(0, *encObj)); - TEST_LOG("Encryption enabled but you should still hear the voice\n"); - SLEEP(2000); - TEST_LOG("Removing encryption object and deleting it\n"); - TEST_MUSTPASS(encrypt->DeRegisterExternalEncryption(0)); - delete encObj; - SLEEP(2000); + TEST_LOG("\nExternal encryption tests:\n"); + my_encryption * encObj = new my_encryption; + TEST_MUSTPASS(encrypt->RegisterExternalEncryption(0, *encObj)); + TEST_LOG("Encryption enabled but you should still hear the voice\n"); + SLEEP(2000); + TEST_LOG("Removing encryption object and deleting it\n"); + TEST_MUSTPASS(encrypt->DeRegisterExternalEncryption(0)); + delete encObj; + SLEEP(2000); #else - TEST_LOG("\n\n+++ Encryption tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ Encryption tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_ENCRYPT_ - - ////////////////// - // External media + ////////////////// + // External media #ifdef _TEST_XMEDIA_ - TEST_LOG("\n\n+++ External media tests +++\n\n"); + TEST_LOG("\n\n+++ External media tests +++\n\n"); #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT - TEST_LOG("Stop playing file as microphone \n"); - TEST_LOG("==> Talk into the microphone \n"); - TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); + TEST_LOG("Stop playing file as microphone \n"); + TEST_LOG("==> Talk into the microphone \n"); + TEST_MUSTPASS(file->StopPlayingFileAsMicrophone(0)); - TEST_LOG("Enabling external playout\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(true)); - TEST_MUSTPASS(base->StartPlayout(0)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Enabling external playout\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(true)); + TEST_MUSTPASS(base->StartPlayout(0)); + TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Writing 2 secs of play data to vector\n"); - int getLen; - WebRtc_Word16 speechData[32000]; - for (int i = 0; i < 200; i++) - { - TEST_MUSTPASS(xmedia->ExternalPlayoutGetData(speechData+i*160, - 16000, - 100, - getLen)); - TEST_MUSTPASS(160 != getLen); - SLEEP(10); - } + TEST_LOG("Writing 2 secs of play data to vector\n"); + int getLen; + WebRtc_Word16 speechData[32000]; + for (int i = 0; i < 200; i++) { + TEST_MUSTPASS(xmedia->ExternalPlayoutGetData(speechData+i*160, + 16000, + 100, + getLen)); + TEST_MUSTPASS(160 != getLen); + SLEEP(10); + } - TEST_LOG("Disabling external playout\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(false)); - TEST_MUSTPASS(base->StartPlayout(0)); + TEST_LOG("Disabling external playout\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(xmedia->SetExternalPlayoutStatus(false)); + TEST_MUSTPASS(base->StartPlayout(0)); - TEST_LOG("Enabling external recording\n"); - TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(true)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Enabling external recording\n"); + TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(true)); + TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("Inserting record data from vector\n"); - for (int i = 0; i < 200; i++) - { - TEST_MUSTPASS(xmedia->ExternalRecordingInsertData(speechData+i*160, - 160, - 16000, - 20)); - SLEEP(10); - } + TEST_LOG("Inserting record data from vector\n"); + for (int i = 0; i < 200; i++) { + TEST_MUSTPASS(xmedia->ExternalRecordingInsertData(speechData+i*160, + 160, + 16000, + 20)); + SLEEP(10); + } - TEST_LOG("Disabling external recording\n"); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(false)); - TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("Disabling external recording\n"); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(xmedia->SetExternalRecordingStatus(false)); + TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, AudioFilename(), - true, true)); + TEST_LOG("==> Start playing a file as microphone again \n"); + TEST_MUSTPASS(file->StartPlayingFileAsMicrophone(0, AudioFilename(), + true, true)); #else - TEST_LOG("Skipping external rec and playout tests - \ + TEST_LOG("Skipping external rec and playout tests - \ WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT not defined \n"); #endif // WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT - - TEST_LOG("Enabling playout external media processing => " - "played audio should now be affected \n"); - TEST_MUSTPASS(xmedia->RegisterExternalMediaProcessing( - -1, kPlaybackAllChannelsMixed, mobj)); - SLEEP(2000); - TEST_LOG("Back to normal again \n"); - TEST_MUSTPASS(xmedia->DeRegisterExternalMediaProcessing( - -1, kPlaybackAllChannelsMixed)); - SLEEP(2000); - // Note that we must do per channel here because PlayFileAsMicrophone - // is only done on ch 0. - TEST_LOG("Enabling recording external media processing => " - "played audio should now be affected \n"); - TEST_MUSTPASS(xmedia->RegisterExternalMediaProcessing( - 0, kRecordingPerChannel, mobj)); - SLEEP(2000); - TEST_LOG("Back to normal again \n"); - TEST_MUSTPASS(xmedia->DeRegisterExternalMediaProcessing( - 0, kRecordingPerChannel)); - SLEEP(2000); - TEST_LOG("Enabling recording external media processing => " - "speak and make sure that voice is affected \n"); - TEST_MUSTPASS(xmedia->RegisterExternalMediaProcessing( - -1, kRecordingAllChannelsMixed, mobj)); - SLEEP(2000); - TEST_LOG("Back to normal again \n"); - TEST_MUSTPASS(xmedia->DeRegisterExternalMediaProcessing( - -1, kRecordingAllChannelsMixed)); - SLEEP(2000); + TEST_LOG("Enabling playout external media processing => " + "played audio should now be affected \n"); + TEST_MUSTPASS(xmedia->RegisterExternalMediaProcessing( + -1, kPlaybackAllChannelsMixed, mobj)); + SLEEP(2000); + TEST_LOG("Back to normal again \n"); + TEST_MUSTPASS(xmedia->DeRegisterExternalMediaProcessing( + -1, kPlaybackAllChannelsMixed)); + SLEEP(2000); + // Note that we must do per channel here because PlayFileAsMicrophone + // is only done on ch 0. + TEST_LOG("Enabling recording external media processing => " + "played audio should now be affected \n"); + TEST_MUSTPASS(xmedia->RegisterExternalMediaProcessing( + 0, kRecordingPerChannel, mobj)); + SLEEP(2000); + TEST_LOG("Back to normal again \n"); + TEST_MUSTPASS(xmedia->DeRegisterExternalMediaProcessing( + 0, kRecordingPerChannel)); + SLEEP(2000); + TEST_LOG("Enabling recording external media processing => " + "speak and make sure that voice is affected \n"); + TEST_MUSTPASS(xmedia->RegisterExternalMediaProcessing( + -1, kRecordingAllChannelsMixed, mobj)); + SLEEP(2000); + TEST_LOG("Back to normal again \n"); + TEST_MUSTPASS(xmedia->DeRegisterExternalMediaProcessing( + -1, kRecordingAllChannelsMixed)); + SLEEP(2000); #else - TEST_LOG("\n\n+++ External media tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ External media tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_XMEDIA_ - - ///////////////////// - // NetEQ statistics + ///////////////////// + // NetEQ statistics #ifdef _TEST_NETEQ_STATS_ - TEST_LOG("\n\n+++ NetEQ statistics tests +++\n\n"); + TEST_LOG("\n\n+++ NetEQ statistics tests +++\n\n"); #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API - NetworkStatistics nStats; - TEST_MUSTPASS(neteqst->GetNetworkStatistics(0, nStats)); - TEST_LOG("\nNetwork statistics: \n"); - TEST_LOG(" currentAccelerateRate = %hu \n", - nStats.currentAccelerateRate); - TEST_LOG(" currentBufferSize = %hu \n", - nStats.currentBufferSize); - TEST_LOG(" currentDiscardRate = %hu \n", - nStats.currentDiscardRate); - TEST_LOG(" currentExpandRate = %hu \n", - nStats.currentExpandRate); - TEST_LOG(" currentPacketLossRate = %hu \n", - nStats.currentPacketLossRate); - TEST_LOG(" currentPreemptiveRate = %hu \n", - nStats.currentPreemptiveRate); - TEST_LOG(" preferredBufferSize = %hu \n", - nStats.preferredBufferSize); + NetworkStatistics nStats; + TEST_MUSTPASS(neteqst->GetNetworkStatistics(0, nStats)); + TEST_LOG("\nNetwork statistics: \n"); + TEST_LOG(" currentAccelerateRate = %hu \n", + nStats.currentAccelerateRate); + TEST_LOG(" currentBufferSize = %hu \n", + nStats.currentBufferSize); + TEST_LOG(" currentDiscardRate = %hu \n", + nStats.currentDiscardRate); + TEST_LOG(" currentExpandRate = %hu \n", + nStats.currentExpandRate); + TEST_LOG(" currentPacketLossRate = %hu \n", + nStats.currentPacketLossRate); + TEST_LOG(" currentPreemptiveRate = %hu \n", + nStats.currentPreemptiveRate); + TEST_LOG(" preferredBufferSize = %hu \n", + nStats.preferredBufferSize); #else - TEST_LOG("Skipping NetEQ statistics tests - " - "WEBRTC_VOICE_ENGINE_NETEQ_STATS_API not defined \n"); + TEST_LOG("Skipping NetEQ statistics tests - " + "WEBRTC_VOICE_ENGINE_NETEQ_STATS_API not defined \n"); #endif // #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API #else - TEST_LOG("\n\n+++ NetEQ statistics tests NOT ENABLED +++\n"); + TEST_LOG("\n\n+++ NetEQ statistics tests NOT ENABLED +++\n"); #endif // #ifdef _TEST_NETEQ_STATS_ + ////////////////// + // Stop streaming + TEST_LOG("\n\n+++ Stop streaming +++\n\n"); - ////////////////// - // Stop streaming + TEST_LOG("Stop playout, sending and listening \n"); + TEST_MUSTPASS(base->StopPlayout(0)); + TEST_MUSTPASS(base->StopSend(0)); + TEST_MUSTPASS(base->StopReceive(0)); - TEST_LOG("\n\n+++ Stop streaming +++\n\n"); + // Exit: + TEST_LOG("Delete channel and terminate VE \n"); + TEST_MUSTPASS(base->DeleteChannel(0)); + TEST_MUSTPASS(base->Terminate()); - TEST_LOG("Stop playout, sending and listening \n"); - TEST_MUSTPASS(base->StopPlayout(0)); - TEST_MUSTPASS(base->StopSend(0)); - TEST_MUSTPASS(base->StopReceive(0)); - -// Exit: - - TEST_LOG("Delete channel and terminate VE \n"); - TEST_MUSTPASS(base->DeleteChannel(0)); - TEST_MUSTPASS(base->Terminate()); - - return 0; + return 0; } -int runAutoTest(TestType testType, ExtendedSelection extendedSel) -{ - SubAPIManager apiMgr; - apiMgr.DisplayStatus(); +int runAutoTest(TestType testType, ExtendedSelection extendedSel) { + SubAPIManager apiMgr; + apiMgr.DisplayStatus(); - //////////////////////////////////// - // Create VoiceEngine and sub API:s + //////////////////////////////////// + // Create VoiceEngine and sub API:s - voetest::VoETestManager tm; - if (!tm.Init()) - { - return -1; - } - tm.GetInterfaces(); + voetest::VoETestManager tm; + if (!tm.Init()) { + return -1; + } + tm.GetInterfaces(); - ////////////////////// - // Run standard tests + ////////////////////// + // Run standard tests - int mainRet(-1); - if (testType == Standard) - { - mainRet = tm.DoStandardTest(); + int mainRet(-1); + if (testType == Standard) { + mainRet = tm.DoStandardTest(); - //////////////////////////////// - // Create configuration summary + //////////////////////////////// + // Create configuration summary + TEST_LOG("\n\n+++ Creating configuration summary file +++\n"); + createSummary(tm.VoiceEnginePtr()); + } else if (testType == Extended) { + VoEExtendedTest xtend(tm); - TEST_LOG("\n\n+++ Creating configuration summary file +++\n"); - createSummary(tm.VoiceEnginePtr()); - } - else if (testType == Extended) - { - VoEExtendedTest xtend(tm); + mainRet = 0; + while (extendedSel != XSEL_None) { + if (extendedSel == XSEL_Base || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestBase()) == -1) + break; + xtend.TestPassed("Base"); + } + if (extendedSel == XSEL_CallReport || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestCallReport()) == -1) + break; + xtend.TestPassed("CallReport"); + } + if (extendedSel == XSEL_Codec || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestCodec()) == -1) + break; + xtend.TestPassed("Codec"); + } + if (extendedSel == XSEL_DTMF || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestDtmf()) == -1) + break; + xtend.TestPassed("Dtmf"); + } + if (extendedSel == XSEL_Encryption || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestEncryption()) == -1) + break; + xtend.TestPassed("Encryption"); + } + if (extendedSel == XSEL_ExternalMedia || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestExternalMedia()) == -1) + break; + xtend.TestPassed("ExternalMedia"); + } + if (extendedSel == XSEL_File || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestFile()) == -1) + break; + xtend.TestPassed("File"); + } + if (extendedSel == XSEL_Mixing || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestMixing()) == -1) + break; + xtend.TestPassed("Mixing"); + } + if (extendedSel == XSEL_Hardware || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestHardware()) == -1) + break; + xtend.TestPassed("Hardware"); + } + if (extendedSel == XSEL_NetEqStats || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestNetEqStats()) == -1) + break; + xtend.TestPassed("NetEqStats"); + } + if (extendedSel == XSEL_Network || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestNetwork()) == -1) + break; + xtend.TestPassed("Network"); + } + if (extendedSel == XSEL_RTP_RTCP || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestRTP_RTCP()) == -1) + break; + xtend.TestPassed("RTP_RTCP"); + } + if (extendedSel == XSEL_VideoSync || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestVideoSync()) == -1) + break; + xtend.TestPassed("VideoSync"); + } + if (extendedSel == XSEL_VolumeControl || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestVolumeControl()) == -1) + break; + xtend.TestPassed("VolumeControl"); + } + if (extendedSel == XSEL_AudioProcessing || extendedSel == XSEL_All) { + if ((mainRet = xtend.TestAPM()) == -1) + break; + xtend.TestPassed("AudioProcessing"); + } + apiMgr.GetExtendedMenuSelection(extendedSel); + } // while (extendedSel != XSEL_None) + } else if (testType == Stress) { + VoEStressTest stressTest(tm); + mainRet = stressTest.DoTest(); + } else if (testType == Unit) { + VoEUnitTest unitTest(tm); + mainRet = unitTest.DoTest(); + } else if (testType == CPU) { + VoECpuTest cpuTest(tm); + mainRet = cpuTest.DoTest(); + } else { + // Should never end up here + TEST_LOG("INVALID SELECTION \n"); + } - mainRet = 0; - while (extendedSel != XSEL_None) - { - if (extendedSel == XSEL_Base || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestBase()) == -1) - break; - xtend.TestPassed("Base"); - } - if (extendedSel == XSEL_CallReport || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestCallReport()) == -1) - break; - xtend.TestPassed("CallReport"); - } - if (extendedSel == XSEL_Codec || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestCodec()) == -1) - break; - xtend.TestPassed("Codec"); - } - if (extendedSel == XSEL_DTMF || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestDtmf()) == -1) - break; - xtend.TestPassed("Dtmf"); - } - if (extendedSel == XSEL_Encryption || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestEncryption()) == -1) - break; - xtend.TestPassed("Encryption"); - } - if (extendedSel == XSEL_ExternalMedia || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestExternalMedia()) == -1) - break; - xtend.TestPassed("ExternalMedia"); - } - if (extendedSel == XSEL_File || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestFile()) == -1) - break; - xtend.TestPassed("File"); - } - if (extendedSel == XSEL_Mixing || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestMixing()) == -1) - break; - xtend.TestPassed("Mixing"); - } - if (extendedSel == XSEL_Hardware || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestHardware()) == -1) - break; - xtend.TestPassed("Hardware"); - } - if (extendedSel == XSEL_NetEqStats || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestNetEqStats()) == -1) - break; - xtend.TestPassed("NetEqStats"); - } - if (extendedSel == XSEL_Network || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestNetwork()) == -1) - break; - xtend.TestPassed("Network"); - } - if (extendedSel == XSEL_RTP_RTCP || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestRTP_RTCP()) == -1) - break; - xtend.TestPassed("RTP_RTCP"); - } - if (extendedSel == XSEL_VideoSync || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestVideoSync()) == -1) - break; - xtend.TestPassed("VideoSync"); - } - if (extendedSel == XSEL_VolumeControl || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestVolumeControl()) == -1) - break; - xtend.TestPassed("VolumeControl"); - } - if (extendedSel == XSEL_AudioProcessing || extendedSel == XSEL_All) - { - if ((mainRet = xtend.TestAPM()) == -1) - break; - xtend.TestPassed("AudioProcessing"); - } - apiMgr.GetExtendedMenuSelection(extendedSel); - } // while (extendedSel != XSEL_None) - } - else if (testType == Stress) - { - VoEStressTest stressTest(tm); - mainRet = stressTest.DoTest(); - } - else if (testType == Unit) - { - VoEUnitTest unitTest(tm); - mainRet = unitTest.DoTest(); - } - else if (testType == CPU) - { - VoECpuTest cpuTest(tm); - mainRet = cpuTest.DoTest(); - } - else - { - // Should never end up here - TEST_LOG("INVALID SELECTION \n"); - } + ////////////////// + // Release/Delete + int releaseOK = tm.ReleaseInterfaces(); - ////////////////// - // Release/Delete + if ((0 == mainRet) && (releaseOK != -1)) { + TEST_LOG("\n\n*** All tests passed *** \n\n"); + } else { + TEST_LOG("\n\n*** Test failed! *** \n"); + } - int releaseOK = tm.ReleaseInterfaces(); - - if ((0 == mainRet) && (releaseOK != -1)) - { - TEST_LOG("\n\n*** All tests passed *** \n\n"); - } - else - { - TEST_LOG("\n\n*** Test failed! *** \n"); - } - - return 0; + return 0; } -void createSummary(VoiceEngine* ve) -{ - int len; - char str[256]; +void createSummary(VoiceEngine* ve) { + int len; + char str[256]; #ifdef MAC_IPHONE - char summaryFilename[256]; - GetDocumentsDir(summaryFilename, 256); - strcat(summaryFilename, "/summary.txt"); + char summaryFilename[256]; + GetDocumentsDir(summaryFilename, 256); + strcat(summaryFilename, "/summary.txt"); #endif - VoEBase* base = VoEBase::GetInterface(ve); - FILE* stream = fopen(summaryFilename, "wt"); + VoEBase* base = VoEBase::GetInterface(ve); + FILE* stream = fopen(summaryFilename, "wt"); - sprintf(str, "WebRTc VoiceEngine "); + sprintf(str, "WebRTc VoiceEngine "); #if defined(_WIN32) - strcat(str, "Win"); -#elif defined(WEBRTC_LINUX) && defined(WEBRTC_TARGET_PC) && !defined(WEBRTC_ANDROID) - strcat(str, "Linux"); + strcat(str, "Win"); +#elif defined(WEBRTC_LINUX) && defined(WEBRTC_TARGET_PC) && \ + !defined(WEBRTC_ANDROID) + strcat(str, "Linux"); #elif defined(WEBRTC_MAC) && !defined(MAC_IPHONE) - strcat(str, "Mac"); + strcat(str, "Mac"); #elif defined(WEBRTC_ANDROID) - strcat(str, "Android"); + strcat(str, "Android"); #elif defined(MAC_IPHONE) - strcat(str, "iPhone"); + strcat(str, "iPhone"); #endif - // Add for other platforms as needed + // Add for other platforms as needed - fprintf(stream, "%s\n", str); - len = (int)strlen(str); - for (int i=0; iGetVersion(version); - // find first NL <=> end of VoiceEngine version string - int pos = (int)strcspn(version, "\n"); - strncpy(veVersion, version, pos); - veVersion[pos] = '\0'; - sprintf(str, "Version: %s\n", veVersion); - fprintf(stream, "%s\n", str); + char version[1024]; + char veVersion[24]; + base->GetVersion(version); + // find first NL <=> end of VoiceEngine version string + int pos = (int) strcspn(version, "\n"); + strncpy(veVersion, version, pos); + veVersion[pos] = '\0'; + sprintf(str, "Version: %s\n", veVersion); + fprintf(stream, "%s\n", str); - sprintf(str, "Build date & time: %s\n", BUILDDATE " " BUILDTIME); - fprintf(stream, "%s\n", str); + sprintf(str, "Build date & time: %s\n", BUILDDATE " " BUILDTIME); + fprintf(stream, "%s\n", str); - strcpy(str, "G.711 A-law"); - fprintf(stream, "\nSupported codecs: %s\n", str); - strcpy(str, " G.711 mu-law"); - fprintf(stream, "%s\n", str); + strcpy(str, "G.711 A-law"); + fprintf(stream, "\nSupported codecs: %s\n", str); + strcpy(str, " G.711 mu-law"); + fprintf(stream, "%s\n", str); #ifdef WEBRTC_CODEC_EG711 - strcpy(str, " Enhanced G.711 A-law"); - fprintf(stream, "%s\n", str); - strcpy(str, " Enhanced G.711 mu-law"); - fprintf(stream, "%s\n", str); + strcpy(str, " Enhanced G.711 A-law"); + fprintf(stream, "%s\n", str); + strcpy(str, " Enhanced G.711 mu-law"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_IPCMWB - strcpy(str, " iPCM-wb"); - fprintf(stream, "%s\n", str); + strcpy(str, " iPCM-wb"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_ILBC - strcpy(str, " iLBC"); - fprintf(stream, "%s\n", str); + strcpy(str, " iLBC"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_ISAC - strcpy(str, " iSAC"); - fprintf(stream, "%s\n", str); + strcpy(str, " iSAC"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_ISACLC - strcpy(str, " iSAC-LC"); - fprintf(stream, "%s\n", str); + strcpy(str, " iSAC-LC"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G722 - strcpy(str, " G.722"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.722"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G722_1 - strcpy(str, " G.722.1"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.722.1"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G722_1C - strcpy(str, " G.722.1C"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.722.1C"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G723 - strcpy(str, " G.723"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.723"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G726 - strcpy(str, " G.726"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.726"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G729 - strcpy(str, " G.729"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.729"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_G729_1 - strcpy(str, " G.729.1"); - fprintf(stream, "%s\n", str); + strcpy(str, " G.729.1"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_GSMFR - strcpy(str, " GSM-FR"); - fprintf(stream, "%s\n", str); + strcpy(str, " GSM-FR"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_GSMAMR - strcpy(str, " AMR"); - fprintf(stream, "%s\n", str); + strcpy(str, " AMR"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_GSMAMRWB - strcpy(str, " AMR-WB"); - fprintf(stream, "%s\n", str); + strcpy(str, " AMR-WB"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_GSMEFR - strcpy(str, " GSM-EFR"); - fprintf(stream, "%s\n", str); + strcpy(str, " GSM-EFR"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_SPEEX - strcpy(str, " Speex"); - fprintf(stream, "%s\n", str); + strcpy(str, " Speex"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_SILK - strcpy(str, " Silk"); - fprintf(stream, "%s\n", str); + strcpy(str, " Silk"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_CODEC_PCM16 - strcpy(str, " L16"); - fprintf(stream, "%s\n", str); + strcpy(str, " L16"); + fprintf(stream, "%s\n", str); #endif #ifdef NETEQFIX_VOXWARE_SC3 - strcpy(str, " Voxware SC3"); - fprintf(stream, "%s\n", str); + strcpy(str, " Voxware SC3"); + fprintf(stream, "%s\n", str); #endif - // Always included - strcpy(str, " AVT (RFC2833)"); - fprintf(stream, "%s\n", str); + // Always included + strcpy(str, " AVT (RFC2833)"); + fprintf(stream, "%s\n", str); #ifdef WEBRTC_CODEC_RED - strcpy(str, " RED (forward error correction)"); - fprintf(stream, "%s\n", str); + strcpy(str, " RED (forward error correction)"); + fprintf(stream, "%s\n", str); #endif - fprintf(stream, "\nEcho Control: "); + fprintf(stream, "\nEcho Control: "); #ifdef WEBRTC_VOICE_ENGINE_ECHO - fprintf(stream, "Yes\n"); + fprintf(stream, "Yes\n"); #else - fprintf(stream, "No\n"); + fprintf(stream, "No\n"); #endif - fprintf(stream, "\nAutomatic Gain Control: "); + fprintf(stream, "\nAutomatic Gain Control: "); #ifdef WEBRTC_VOICE_ENGINE_AGC - fprintf(stream, "Yes\n"); + fprintf(stream, "Yes\n"); #else - fprintf(stream, "No\n"); + fprintf(stream, "No\n"); #endif - fprintf(stream, "\nNoise Reduction: "); + fprintf(stream, "\nNoise Reduction: "); #ifdef WEBRTC_VOICE_ENGINE_NR - fprintf(stream, "Yes\n"); + fprintf(stream, "Yes\n"); #else - fprintf(stream, "No\n"); + fprintf(stream, "No\n"); #endif - fprintf(stream, "\nSRTP: "); + fprintf(stream, "\nSRTP: "); #ifdef WEBRTC_SRTP - fprintf(stream, "Yes\n"); + fprintf(stream, "Yes\n"); #else - fprintf(stream, "No\n"); + fprintf(stream, "No\n"); #endif - fprintf(stream, "\nExternal transport only: "); + fprintf(stream, "\nExternal transport only: "); #ifdef WEBRTC_EXTERNAL_TRANSPORT - fprintf(stream, "Yes\n"); + fprintf(stream, "Yes\n"); #else - fprintf(stream, "No\n"); + fprintf(stream, "No\n"); #endif - fprintf(stream, "\nTelephone event detection: "); + fprintf(stream, "\nTelephone event detection: "); #ifdef WEBRTC_DTMF_DETECTION - fprintf(stream, "Yes\n"); + fprintf(stream, "Yes\n"); #else - fprintf(stream, "No\n"); + fprintf(stream, "No\n"); #endif - strcpy(str, "VoEBase"); - fprintf(stream, "\nSupported sub-APIs: %s\n", str); + strcpy(str, "VoEBase"); + fprintf(stream, "\nSupported sub-APIs: %s\n", str); #ifdef WEBRTC_VOICE_ENGINE_CODEC_API - strcpy(str, " VoECodec"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoECodec"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_DTMF_API - strcpy(str, " VoEDtmf"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEDtmf"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_FILE_API - strcpy(str, " VoEFile"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEFile"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API - strcpy(str, " VoEHardware"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEHardware"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_NETWORK_API - strcpy(str, " VoENetwork"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoENetwork"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API - strcpy(str, " VoERTP_RTCP"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoERTP_RTCP"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API - strcpy(str, " VoEVolumeControl"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEVolumeControl"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API - strcpy(str, " VoEAudioProcessing"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEAudioProcessing"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API - strcpy(str, " VoeExternalMedia"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoeExternalMedia"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API - strcpy(str, " VoENetEqStats"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoENetEqStats"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_ENCRYPTION_API - strcpy(str, " VoEEncryption"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEEncryption"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_CALL_REPORT_API - strcpy(str, " VoECallReport"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoECallReport"); + fprintf(stream, "%s\n", str); #endif #ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API - strcpy(str, " VoEVideoSync"); - fprintf(stream, "%s\n", str); + strcpy(str, " VoEVideoSync"); + fprintf(stream, "%s\n", str); #endif - fclose(stream); - base->Release(); + fclose(stream); + base->Release(); } /*********Knowledge Base******************/ @@ -4042,36 +3887,36 @@ void createSummary(VoiceEngine* ve) class ThreadTest { public: - ThreadTest( - VoEBase* base); - ~ThreadTest() - { - delete _myThread; - } - void Stop(); + ThreadTest( + VoEBase* base); + ~ThreadTest() + { + delete _myThread; + } + void Stop(); private: - static bool StartSend( - void* obj); - bool StartSend(); + static bool StartSend( + void* obj); + bool StartSend(); - ThreadWrapper* _myThread; - VoEBase* _base; + ThreadWrapper* _myThread; + VoEBase* _base; - bool _stopped; + bool _stopped; }; //Main function from where StartSend is invoked as a seperate thread. ThreadTest::ThreadTest( VoEBase* base) - : - _stopped(false), - _base(base) +: +_stopped(false), +_base(base) { - //Thread Creation - _myThread = ThreadWrapper::CreateThread(StartSend, this, kLowPriority); - unsigned int id = 0; - //Starting the thread - _myThread->Start(id); + //Thread Creation + _myThread = ThreadWrapper::CreateThread(StartSend, this, kLowPriority); + unsigned int id = 0; + //Starting the thread + _myThread->Start(id); } //Calls the StartSend. This is to avoid the static declaration issue. @@ -4079,21 +3924,20 @@ bool ThreadTest::StartSend( void* obj) { - return ((ThreadTest*)obj)->StartSend(); + return ((ThreadTest*)obj)->StartSend(); } - bool ThreadTest::StartSend() { - _myThread->SetNotAlive(); //Ensures this function is called only once. - _base->StartSend(0); - return true; + _myThread->SetNotAlive(); //Ensures this function is called only once. + _base->StartSend(0); + return true; } void ThreadTest::Stop() { - _stopped = true; + _stopped = true; } // Use the following to invoke ThreatTest from the main function. @@ -4106,95 +3950,93 @@ void ThreadTest::Stop() //Thread Declaration. Need to be added in the class controlling/dictating // the main code. /** -private: - static unsigned int WINAPI StartSend(void* obj); - unsigned int WINAPI StartSend(); -**/ + private: + static unsigned int WINAPI StartSend(void* obj); + unsigned int WINAPI StartSend(); + **/ //Thread Definition unsigned int WINAPI mainTest::StartSend(void *obj) { - return ((mainTest*)obj)->StartSend(); + return ((mainTest*)obj)->StartSend(); } unsigned int WINAPI mainTest::StartSend() { - //base - base->StartSend(0); + //base + base->StartSend(0); - // TEST_MUSTPASS(base->StartSend(0)); - TEST_LOG("hi hi hi"); - return 0; + // TEST_MUSTPASS(base->StartSend(0)); + TEST_LOG("hi hi hi"); + return 0; } //Thread invoking. From the main code /***** - unsigned int threadID=0; - if ((HANDLE)_beginthreadex(NULL, - 0, - StartSend, - (void*)this, - 0, - &threadID) == NULL) - return false; -****/ + unsigned int threadID=0; + if ((HANDLE)_beginthreadex(NULL, + 0, + StartSend, + (void*)this, + 0, + &threadID) == NULL) + return false; + ****/ #endif -} // namespace voetest +} // namespace voetest -int RunInManualMode() -{ - using namespace voetest; +int RunInManualMode() { + using namespace voetest; - SubAPIManager apiMgr; - apiMgr.DisplayStatus(); + SubAPIManager apiMgr; + apiMgr.DisplayStatus(); - printf("----------------------------\n"); - printf("Select type of test\n\n"); - printf(" (0) Quit\n"); - printf(" (1) Standard test\n"); - printf(" (2) Extended test(s)...\n"); - printf(" (3) Stress test(s)...\n"); - printf(" (4) Unit test(s)...\n"); - printf(" (5) CPU & memory reference test [Windows]...\n"); - printf("\n: "); + printf("----------------------------\n"); + printf("Select type of test\n\n"); + printf(" (0) Quit\n"); + printf(" (1) Standard test\n"); + printf(" (2) Extended test(s)...\n"); + printf(" (3) Stress test(s)...\n"); + printf(" (4) Unit test(s)...\n"); + printf(" (5) CPU & memory reference test [Windows]...\n"); + printf("\n: "); - int selection(0); + int selection(0); - dummy = scanf("%d", &selection); + dummy = scanf("%d", &selection); - ExtendedSelection extendedSel(XSEL_Invalid); + ExtendedSelection extendedSel(XSEL_Invalid); - enum TestType testType(Invalid); + enum TestType testType(Invalid); - switch (selection) - { - case 0: - return 0; - case 1: - testType = Standard; - break; - case 2: - testType = Extended; - while (!apiMgr.GetExtendedMenuSelection(extendedSel)) - continue; - break; - case 3: - testType = Stress; - break; - case 4: - testType = Unit; - break; - case 5: - testType = CPU; - break; - default: - TEST_LOG("Invalid selection!\n"); - return 0; - } + switch (selection) { + case 0: + return 0; + case 1: + testType = Standard; + break; + case 2: + testType = Extended; + while (!apiMgr.GetExtendedMenuSelection(extendedSel)) + continue; + break; + case 3: + testType = Stress; + break; + case 4: + testType = Unit; + break; + case 5: + testType = CPU; + break; + default: + TEST_LOG("Invalid selection!\n"); + return 0; + } - // Function that can be called from other entry functions. - return runAutoTest(testType, extendedSel); + // Function that can be called from other entry functions. + return runAutoTest(testType, extendedSel); } // ---------------------------------------------------------------------------- @@ -4202,14 +4044,13 @@ int RunInManualMode() // ---------------------------------------------------------------------------- #if !defined(MAC_IPHONE) -int main(int argc, char** argv) -{ - if (argc > 1 && std::string(argv[1]) == "--automated") { - // This function is defined in automated_mode.cc to avoid macro clashes - // with googletest (for instance the ASSERT_TRUE macro). - return RunInAutomatedMode(argc, argv); - } +int main(int argc, char** argv) { + if (argc > 1 && std::string(argv[1]) == "--automated") { + // This function is defined in automated_mode.cc to avoid macro clashes + // with googletest (for instance the ASSERT_TRUE macro). + return RunInAutomatedMode(argc, argv); + } - return RunInManualMode(); + return RunInManualMode(); } #endif //#if !defined(MAC_IPHONE) diff --git a/src/voice_engine/main/test/auto_test/voe_standard_test.h b/src/voice_engine/main/test/auto_test/voe_standard_test.h index b432996b0d..becf6afd12 100644 --- a/src/voice_engine/main/test/auto_test/voe_standard_test.h +++ b/src/voice_engine/main/test/auto_test/voe_standard_test.h @@ -49,8 +49,7 @@ #endif #ifdef _TEST_NETEQ_STATS_ -namespace webrtc -{ +namespace webrtc { class CriticalSectionWrapper; class ThreadWrapper; class VoENetEqStats; @@ -61,327 +60,301 @@ class VoENetEqStats; extern char mobileLogMsg[640]; #endif -namespace voetest -{ +namespace voetest { void createSummary(VoiceEngine* ve); void prepareDelivery(); -class MyRTPObserver: public VoERTPObserver -{ -public: - MyRTPObserver(); - ~MyRTPObserver(); - virtual void OnIncomingCSRCChanged(const int channel, - const unsigned int CSRC, - const bool added); - virtual void OnIncomingSSRCChanged(const int channel, - const unsigned int SSRC); - void Reset(); -public: - unsigned int _SSRC[2]; - unsigned int _CSRC[2][2]; // stores 2 SSRCs for each channel - bool _added[2][2]; - int _size[2]; +class MyRTPObserver : public VoERTPObserver { + public: + MyRTPObserver(); + ~MyRTPObserver(); + virtual void OnIncomingCSRCChanged(const int channel, + const unsigned int CSRC, + const bool added); + virtual void OnIncomingSSRCChanged(const int channel, + const unsigned int SSRC); + void Reset(); + public: + unsigned int _SSRC[2]; + unsigned int _CSRC[2][2]; // stores 2 SSRCs for each channel + bool _added[2][2]; + int _size[2]; }; -class MyTraceCallback: public TraceCallback -{ -public: - void Print(const TraceLevel level, const char *traceString, - const int length); +class MyTraceCallback : public TraceCallback { + public: + void Print(const TraceLevel level, const char *traceString, const int length); }; -class MyDeadOrAlive: public VoEConnectionObserver -{ -public: - void OnPeriodicDeadOrAlive(const int channel, const bool alive); +class MyDeadOrAlive : public VoEConnectionObserver { + public: + void OnPeriodicDeadOrAlive(const int channel, const bool alive); }; -class ErrorObserver: public VoiceEngineObserver -{ -public: - ErrorObserver(); - void CallbackOnError(const int channel, const int errCode); -public: - int code; +class ErrorObserver : public VoiceEngineObserver { + public: + ErrorObserver(); + void CallbackOnError(const int channel, const int errCode); + public: + int code; }; -class RtcpAppHandler: public VoERTCPObserver -{ -public: - void OnApplicationDataReceived(const int channel, - const unsigned char subType, - const unsigned int name, - const unsigned char* data, - const unsigned short dataLengthInBytes); - void Reset(); - ~RtcpAppHandler() - { - }; - unsigned short _lengthBytes; - unsigned char _data[256]; - unsigned char _subType; - unsigned int _name; +class RtcpAppHandler : public VoERTCPObserver { + public: + void OnApplicationDataReceived(const int channel, + const unsigned char subType, + const unsigned int name, + const unsigned char* data, + const unsigned short dataLengthInBytes); + void Reset(); + ~RtcpAppHandler() {} + unsigned short _lengthBytes; + unsigned char _data[256]; + unsigned char _subType; + unsigned int _name; }; -class DtmfCallback: public VoETelephoneEventObserver -{ -public: - int counter; - DtmfCallback() - { - counter = 0; - } - virtual void OnReceivedTelephoneEventInband(int channel, - int eventCode, - bool endOfEvent) - { - char msg[128]; - if (endOfEvent) - sprintf(msg, "(event=%d, [END])", eventCode); - else - sprintf(msg, "(event=%d, [START])", eventCode); - TEST_LOG("%s", msg); - if (!endOfEvent) - counter++; // cound start of event only - fflush(NULL); - } +class DtmfCallback : public VoETelephoneEventObserver { + public: + int counter; + DtmfCallback() { + counter = 0; + } + virtual void OnReceivedTelephoneEventInband(int channel, + int eventCode, + bool endOfEvent) { + char msg[128]; + if (endOfEvent) + sprintf(msg, "(event=%d, [END])", eventCode); + else + sprintf(msg, "(event=%d, [START])", eventCode); + TEST_LOG("%s", msg); + if (!endOfEvent) + counter++; // cound start of event only + fflush(NULL); + } - virtual void OnReceivedTelephoneEventOutOfBand( - int channel, - int eventCode, - bool endOfEvent) - { - char msg[128]; - if (endOfEvent) - sprintf(msg, "(event=%d, [END])", eventCode); - else - sprintf(msg, "(event=%d, [START])", eventCode); - TEST_LOG("%s", msg); - if (!endOfEvent) - counter++; // cound start of event only - fflush(NULL); - } + virtual void OnReceivedTelephoneEventOutOfBand(int channel, + int eventCode, + bool endOfEvent) { + char msg[128]; + if (endOfEvent) + sprintf(msg, "(event=%d, [END])", eventCode); + else + sprintf(msg, "(event=%d, [START])", eventCode); + TEST_LOG("%s", msg); + if (!endOfEvent) + counter++; // cound start of event only + fflush(NULL); + } }; -class my_encryption: public Encryption -{ - void encrypt(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); - void decrypt(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); - void encrypt_rtcp(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); - void decrypt_rtcp(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); +class my_encryption : public Encryption { + void encrypt(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); + void decrypt(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); + void encrypt_rtcp(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); + void decrypt_rtcp(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); }; -class RxCallback: public VoERxVadCallback -{ -public: - RxCallback() : - _vadDecision(-1) - { - }; +class RxCallback : public VoERxVadCallback { + public: + RxCallback() : + _vadDecision(-1) { + } - virtual void OnRxVad(int, int vadDecision) - { - char msg[128]; - sprintf(msg, "RX VAD detected decision %d \n", vadDecision); - TEST_LOG("%s", msg); - _vadDecision = vadDecision; - } + virtual void OnRxVad(int, int vadDecision) { + char msg[128]; + sprintf(msg, "RX VAD detected decision %d \n", vadDecision); + TEST_LOG("%s", msg); + _vadDecision = vadDecision; + } - int _vadDecision; + int _vadDecision; }; #ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API -class MyMedia: public VoEMediaProcess -{ -public: - virtual void Process(const int channel, const ProcessingTypes type, - WebRtc_Word16 audio_10ms[], const int length, - const int samplingFreqHz, const bool stereo); -private: - int f; +class MyMedia : public VoEMediaProcess { + public: + virtual void Process(const int channel, + const ProcessingTypes type, + WebRtc_Word16 audio_10ms[], + const int length, + const int samplingFreqHz, + const bool stereo); + private: + int f; }; #endif -class SubAPIManager -{ -public: - SubAPIManager() : - _base(true), - _callReport(false), - _codec(false), - _dtmf(false), - _encryption(false), - _externalMedia(false), - _file(false), - _hardware(false), - _netEqStats(false), - _network(false), - _rtp_rtcp(false), - _videoSync(false), - _volumeControl(false), - _apm(false), - _xsel(XSEL_Invalid) - { +class SubAPIManager { + public: + SubAPIManager() + : _base(true), + _callReport(false), + _codec(false), + _dtmf(false), + _encryption(false), + _externalMedia(false), + _file(false), + _hardware(false), + _netEqStats(false), + _network(false), + _rtp_rtcp(false), + _videoSync(false), + _volumeControl(false), + _apm(false), + _xsel(XSEL_Invalid) { #ifdef WEBRTC_VOICE_ENGINE_CALL_REPORT_API - _callReport = true; + _callReport = true; #endif #ifdef WEBRTC_VOICE_ENGINE_CODEC_API - _codec = true; + _codec = true; #endif #ifdef WEBRTC_VOICE_ENGINE_DTMF_API - _dtmf = true; + _dtmf = true; #endif #ifdef WEBRTC_VOICE_ENGINE_ENCRYPTION_API - _encryption = true; + _encryption = true; #endif #ifdef WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API - _externalMedia = true; + _externalMedia = true; #endif #ifdef WEBRTC_VOICE_ENGINE_FILE_API - _file = true; + _file = true; #endif #ifdef WEBRTC_VOICE_ENGINE_HARDWARE_API - _hardware = true; + _hardware = true; #endif #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API - _netEqStats = true; + _netEqStats = true; #endif #ifdef WEBRTC_VOICE_ENGINE_NETWORK_API - _network = true; + _network = true; #endif #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API - _rtp_rtcp = true; + _rtp_rtcp = true; #endif #ifdef WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API - _videoSync = true; + _videoSync = true; #endif #ifdef WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API - _volumeControl = true; + _volumeControl = true; #endif #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API - _apm = true; + _apm = true; #endif - }; + } - void DisplayStatus() const; - bool GetExtendedMenuSelection(ExtendedSelection& sel); + void DisplayStatus() const; + bool GetExtendedMenuSelection(ExtendedSelection& sel); -private: - bool _base, _callReport, _codec, _dtmf, _encryption; - bool _externalMedia, _file, _hardware; - bool _netEqStats, _network, _rtp_rtcp, _videoSync, _volumeControl, _apm; - ExtendedSelection _xsel; + private: + bool _base, _callReport, _codec, _dtmf, _encryption; + bool _externalMedia, _file, _hardware; + bool _netEqStats, _network, _rtp_rtcp, _videoSync, _volumeControl, _apm; + ExtendedSelection _xsel; }; -class VoETestManager -{ -public: - VoETestManager(); - ~VoETestManager(); +class VoETestManager { + public: + VoETestManager(); + ~VoETestManager(); - // Must be called after construction. - bool Init(); + // Must be called after construction. + bool Init(); - void GetInterfaces(); - int ReleaseInterfaces(); - int DoStandardTest(); + void GetInterfaces(); + int ReleaseInterfaces(); + int DoStandardTest(); - const char* AudioFilename() const - { - return audioFilename_.c_str(); - } + const char* AudioFilename() const { + return audioFilename_.c_str(); + } + + VoiceEngine* VoiceEnginePtr() const { + return ve; + } + VoEBase* BasePtr() const { + return base; + } + VoECodec* CodecPtr() const { + return codec; + } + VoEVolumeControl* VolumeControlPtr() const { + return volume; + } + VoEDtmf* DtmfPtr() const { + return dtmf; + } + VoERTP_RTCP* RTP_RTCPPtr() const { + return rtp_rtcp; + } + VoEAudioProcessing* APMPtr() const { + return apm; + } + + VoENetwork* NetworkPtr() const { + return netw; + } + + VoEFile* FilePtr() const { + return file; + } + + VoEHardware* HardwarePtr() const { + return hardware; + } + + VoEVideoSync* VideoSyncPtr() const { + return vsync; + } + + VoEEncryption* EncryptionPtr() const { + return encrypt; + } + + VoEExternalMedia* ExternalMediaPtr() const { + return xmedia; + } + + VoECallReport* CallReportPtr() const { + return report; + } - VoiceEngine* VoiceEnginePtr() const - { - return ve; - }; - VoEBase* BasePtr() const - { - return base; - }; - VoECodec* CodecPtr() const - { - return codec; - }; - VoEVolumeControl* VolumeControlPtr() const - { - return volume; - }; - VoEDtmf* DtmfPtr() const - { - return dtmf; - }; - VoERTP_RTCP* RTP_RTCPPtr() const - { - return rtp_rtcp; - }; - VoEAudioProcessing* APMPtr() const - { - return apm; - }; - VoENetwork* NetworkPtr() const - { - return netw; - }; - VoEFile* FilePtr() const - { - return file; - }; - VoEHardware* HardwarePtr() const - { - return hardware; - }; - VoEVideoSync* VideoSyncPtr() const - { - return vsync; - }; - VoEEncryption* EncryptionPtr() const - { - return encrypt; - }; - VoEExternalMedia* ExternalMediaPtr() const - { - return xmedia; - }; - VoECallReport* CallReportPtr() const - { - return report; - }; #ifdef _TEST_NETEQ_STATS_ - VoENetEqStats* NetEqStatsPtr() const - { - return neteqst; - }; + VoENetEqStats* NetEqStatsPtr() const { + return neteqst; + } + #endif -private: - bool initialized_; - VoiceEngine* ve; - VoEBase* base; - VoECallReport* report; - VoECodec* codec; - VoEDtmf* dtmf; - VoEEncryption* encrypt; - VoEExternalMedia* xmedia; - VoEFile* file; - VoEHardware* hardware; + private: + bool initialized_; + VoiceEngine* ve; + VoEBase* base; + VoECallReport* report; + VoECodec* codec; + VoEDtmf* dtmf; + VoEEncryption* encrypt; + VoEExternalMedia* xmedia; + VoEFile* file; + VoEHardware* hardware; #ifdef _TEST_NETEQ_STATS_ - VoENetEqStats* neteqst; + VoENetEqStats* neteqst; #endif - VoENetwork* netw; - VoERTP_RTCP* rtp_rtcp; - VoEVideoSync* vsync; - VoEVolumeControl* volume; - VoEAudioProcessing* apm; - int instanceCount; - std::string resourcePath_; - std::string audioFilename_; + VoENetwork* netw; + VoERTP_RTCP* rtp_rtcp; + VoEVideoSync* vsync; + VoEVolumeControl* volume; + VoEAudioProcessing* apm; + int instanceCount; + std::string resourcePath_; + std::string audioFilename_; }; } // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_stress_test.cc b/src/voice_engine/main/test/auto_test/voe_stress_test.cc index 6c3a4c9c70..b7098ecdfb 100644 --- a/src/voice_engine/main/test/auto_test/voe_stress_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_stress_test.cc @@ -19,14 +19,13 @@ #include #include #if defined(_WIN32) - #include +#include #endif #include "voe_stress_test.h" #include "voe_standard_test.h" #include "../../source/voice_engine_defines.h" // defines build macros - #include "thread_wrapper.h" using namespace webrtc; @@ -41,11 +40,11 @@ namespace voetest { } #ifdef _WIN32 - // Pause if supported - #define PAUSE_OR_SLEEP(x) PAUSE; +// Pause if supported +#define PAUSE_OR_SLEEP(x) PAUSE; #else - // Sleep a bit instead if pause not supported - #define PAUSE_OR_SLEEP(x) SLEEP(x); +// Sleep a bit instead if pause not supported +#define PAUSE_OR_SLEEP(x) SLEEP(x); #endif extern char* GetFilename(char* filename); @@ -54,400 +53,363 @@ extern int GetResource(char* resource, char* dest, int destLen); extern char* GetResource(char* resource); extern const char* GetResource(const char* resource); - const char* VoEStressTest::_key = "====YUtFWRAAAAADBtIHgAAAAAEAAAAcAAAAAQBHU0ds" - "b2JhbCBJUCBTb3VuZAAC\nAAAAIwAAAExpY2Vuc2VkIHRvIE5vcnRlbCBOZXR3cm9rcwAAAAA" - "xAAAAZxZ7/u0M\niFYyTwSwko5Uutf7mh8S0O4rYZYTFidbzQeuGonuL17F/2oD/2pfDp3jL4" - "Rf3z/A\nnlJsEJgEtASkDNFuwLILjGY0pzjjAYQp3pCl6z6k2MtE06AirdjGLYCjENpq/opX" - "\nOrs3sIuwdYK5va/aFcsjBDmlsGCUM48RDYG9s23bIHYafXUC4ofOaubbZPWiPTmL\nEVJ8WH" - "4F9pgNjALc14oJXfON7r/3\n=EsLx"; + "b2JhbCBJUCBTb3VuZAAC\nAAAAIwAAAExpY2Vuc2VkIHRvIE5vcnRlbCBOZXR3cm9rcwAAAAA" + "xAAAAZxZ7/u0M\niFYyTwSwko5Uutf7mh8S0O4rYZYTFidbzQeuGonuL17F/2oD/2pfDp3jL4" + "Rf3z/A\nnlJsEJgEtASkDNFuwLILjGY0pzjjAYQp3pCl6z6k2MtE06AirdjGLYCjENpq/opX" + "\nOrs3sIuwdYK5va/aFcsjBDmlsGCUM48RDYG9s23bIHYafXUC4ofOaubbZPWiPTmL\nEVJ8WH" + "4F9pgNjALc14oJXfON7r/3\n=EsLx"; +int VoEStressTest::DoTest() { + int test(-1); + while (test != 0) { + test = MenuSelection(); + switch (test) { + case 0: + // Quit stress test + break; + case 1: + // All tests + StartStopTest(); + CreateDeleteChannelsTest(); + MultipleThreadsTest(); + break; + case 2: + StartStopTest(); + break; + case 3: + CreateDeleteChannelsTest(); + break; + case 4: + MultipleThreadsTest(); + break; + default: + // Should not be possible + printf("Invalid selection! (Test code error)\n"); + assert(false); + } // switch + } // while -int VoEStressTest::DoTest() -{ - int test(-1); - while (test != 0) - { - test = MenuSelection(); - switch (test) - { - case 0: - // Quit stress test - break; - case 1: - // All tests - StartStopTest(); - CreateDeleteChannelsTest(); - MultipleThreadsTest(); - break; - case 2: - StartStopTest(); - break; - case 3: - CreateDeleteChannelsTest(); - break; - case 4: - MultipleThreadsTest(); - break; - default: - // Should not be possible - printf("Invalid selection! (Test code error)\n"); - assert(false); - } // switch - } // while - - return 0; + return 0; } +int VoEStressTest::MenuSelection() { + printf("------------------------------------------------\n"); + printf("Select stress test\n\n"); + printf(" (0) Quit\n"); + printf(" (1) All\n"); + printf("- - - - - - - - - - - - - - - - - - - - - - - - \n"); + printf(" (2) Start/stop\n"); + printf(" (3) Create/delete channels\n"); + printf(" (4) Multiple threads\n"); -int VoEStressTest::MenuSelection() -{ - printf("------------------------------------------------\n"); - printf("Select stress test\n\n"); - printf(" (0) Quit\n"); - printf(" (1) All\n"); - printf("- - - - - - - - - - - - - - - - - - - - - - - - \n"); - printf(" (2) Start/stop\n"); - printf(" (3) Create/delete channels\n"); - printf(" (4) Multiple threads\n"); + const int maxMenuSelection = 4; + int selection(-1); - const int maxMenuSelection = 4; - int selection(-1); - - while ((selection < 0) || (selection > maxMenuSelection)) - { - printf("\n: "); - int retval = scanf("%d", &selection); - if ((retval != 1) || (selection < 0) || (selection > maxMenuSelection)) - { - printf("Invalid selection!\n"); - } + while ((selection < 0) || (selection > maxMenuSelection)) { + printf("\n: "); + int retval = scanf("%d", &selection); + if ((retval != 1) || (selection < 0) || (selection > maxMenuSelection)) { + printf("Invalid selection!\n"); } + } - return selection; + return selection; } +int VoEStressTest::StartStopTest() { + printf("------------------------------------------------\n"); + printf("Running start/stop test\n"); + printf("------------------------------------------------\n"); -int VoEStressTest::StartStopTest() -{ - printf("------------------------------------------------\n"); - printf("Running start/stop test\n"); - printf("------------------------------------------------\n"); + printf("\nNOTE: this thest will fail after a while if Core audio is used\n"); + printf("because MS returns AUDCLNT_E_CPUUSAGE_EXCEEDED (VoE Error 10013).\n"); - printf("\nNOTE: this thest will fail after a while if Core audio is used\n"); - printf("because MS returns AUDCLNT_E_CPUUSAGE_EXCEEDED (VoE Error 10013).\n"); + // Get sub-API pointers + VoEBase* base = _mgr.BasePtr(); - // Get sub-API pointers - VoEBase* base = _mgr.BasePtr(); + // Set trace + // VALIDATE_STRESS(base->SetTraceFileName( + // GetFilename("VoEStressTest_StartStop_trace.txt"))); + // VALIDATE_STRESS(base->SetDebugTraceFileName( + // GetFilename("VoEStressTest_StartStop_trace_debug.txt"))); + // VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo | + // kTraceWarning | kTraceError | + // kTraceCritical | kTraceApiCall | + // kTraceMemory | kTraceInfo)); + VALIDATE_STRESS(base->Init()); + VALIDATE_STRESS(base->CreateChannel()); - // Set trace -// VALIDATE_STRESS(base->SetTraceFileName( -// GetFilename("VoEStressTest_StartStop_trace.txt"))); -// VALIDATE_STRESS(base->SetDebugTraceFileName( -// GetFilename("VoEStressTest_StartStop_trace_debug.txt"))); -// VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo | -// kTraceWarning | kTraceError | -// kTraceCritical | kTraceApiCall | -// kTraceMemory | kTraceInfo)); + ///////////// Start test ///////////// - VALIDATE_STRESS(base->Init()); - VALIDATE_STRESS(base->CreateChannel()); + int numberOfLoops(2000); + int loopSleep(200); + int i(0); + int markInterval(20); + printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", + numberOfLoops, loopSleep, markInterval); + printf("Test will take approximately %d minutes. \n", + numberOfLoops * loopSleep / 1000 / 60 + 1); - ///////////// Start test ///////////// - - int numberOfLoops(2000); - int loopSleep(200); - int i(0); - int markInterval(20); - - printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", - numberOfLoops, loopSleep, markInterval); - printf("Test will take approximately %d minutes. \n", - numberOfLoops*loopSleep/1000/60+1); - - for (i=0; iSetLocalReceiver(0, 4800)); - VALIDATE_STRESS(base->SetSendDestination(0, 4800, "127.0.0.1")); - VALIDATE_STRESS(base->StartReceive(0)); - VALIDATE_STRESS(base->StartPlayout(0)); - VALIDATE_STRESS(base->StartSend(0)); - if (!(i % markInterval)) MARK(); - SLEEP(loopSleep); - VALIDATE_STRESS(base->StopSend(0)); - VALIDATE_STRESS(base->StopPlayout(0)); - VALIDATE_STRESS(base->StopReceive(0)); - } - ANL(); - + for (i = 0; i < numberOfLoops; ++i) { VALIDATE_STRESS(base->SetLocalReceiver(0, 4800)); VALIDATE_STRESS(base->SetSendDestination(0, 4800, "127.0.0.1")); VALIDATE_STRESS(base->StartReceive(0)); VALIDATE_STRESS(base->StartPlayout(0)); VALIDATE_STRESS(base->StartSend(0)); - printf("Verify that audio is good. \n"); - PAUSE_OR_SLEEP(20000); + if (!(i % markInterval)) + MARK(); + SLEEP(loopSleep); VALIDATE_STRESS(base->StopSend(0)); VALIDATE_STRESS(base->StopPlayout(0)); VALIDATE_STRESS(base->StopReceive(0)); + } + ANL(); - ///////////// End test ///////////// + VALIDATE_STRESS(base->SetLocalReceiver(0, 4800)); + VALIDATE_STRESS(base->SetSendDestination(0, 4800, "127.0.0.1")); + VALIDATE_STRESS(base->StartReceive(0)); + VALIDATE_STRESS(base->StartPlayout(0)); + VALIDATE_STRESS(base->StartSend(0)); + printf("Verify that audio is good. \n"); + PAUSE_OR_SLEEP(20000); + VALIDATE_STRESS(base->StopSend(0)); + VALIDATE_STRESS(base->StopPlayout(0)); + VALIDATE_STRESS(base->StopReceive(0)); + + ///////////// End test ///////////// - // Terminate - VALIDATE_STRESS(base->DeleteChannel(0)); - VALIDATE_STRESS(base->Terminate()); + // Terminate + VALIDATE_STRESS(base->DeleteChannel(0)); + VALIDATE_STRESS(base->Terminate()); - printf("Test finished \n"); + printf("Test finished \n"); - return 0; + return 0; } +int VoEStressTest::CreateDeleteChannelsTest() { + printf("------------------------------------------------\n"); + printf("Running create/delete channels test\n"); + printf("------------------------------------------------\n"); -int VoEStressTest::CreateDeleteChannelsTest() -{ - printf("------------------------------------------------\n"); - printf("Running create/delete channels test\n"); - printf("------------------------------------------------\n"); + // Get sub-API pointers + VoEBase* base = _mgr.BasePtr(); - // Get sub-API pointers - VoEBase* base = _mgr.BasePtr(); + // Set trace + // VALIDATE_STRESS(base->SetTraceFileName( + // GetFilename("VoEStressTest_CreateChannels_trace.txt"))); + // VALIDATE_STRESS(base->SetDebugTraceFileName( + // GetFilename("VoEStressTest_CreateChannels_trace_debug.txt"))); + // VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo | + // kTraceWarning | kTraceError | + // kTraceCritical | kTraceApiCall | + // kTraceMemory | kTraceInfo)); + VALIDATE_STRESS(base->Init()); - // Set trace -// VALIDATE_STRESS(base->SetTraceFileName( -// GetFilename("VoEStressTest_CreateChannels_trace.txt"))); -// VALIDATE_STRESS(base->SetDebugTraceFileName( -// GetFilename("VoEStressTest_CreateChannels_trace_debug.txt"))); -// VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo | -// kTraceWarning | kTraceError | -// kTraceCritical | kTraceApiCall | -// kTraceMemory | kTraceInfo)); + ///////////// Start test ///////////// - VALIDATE_STRESS(base->Init()); + int numberOfLoops(10000); + int loopSleep(10); + int i(0); + int markInterval(200); - ///////////// Start test ///////////// + printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", + numberOfLoops, loopSleep, markInterval); + printf("Test will take approximately %d minutes. \n", + numberOfLoops * loopSleep / 1000 / 60 + 1); - int numberOfLoops(10000); - int loopSleep(10); - int i(0); - int markInterval(200); + // Some possible extensions include: + // Different sleep times (fixed or random) or zero. + // Start call on all or some channels. + // Two parts: first have a slight overweight to creating channels, + // then to deleting. (To ensure we hit max channels and go to zero.) + // Make sure audio is OK after test has finished. - printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", - numberOfLoops, loopSleep, markInterval); - printf("Test will take approximately %d minutes. \n", - numberOfLoops * loopSleep / 1000 / 60 + 1); + // Set up, start with maxChannels/2 channels + const int maxChannels = base->MaxNumOfChannels(); + VALIDATE_STRESS(maxChannels < 1); // Should always have at least one channel + bool* channelState = new bool[maxChannels]; + memset(channelState, 0, maxChannels * sizeof(bool)); + int channel(0); + int noOfActiveChannels(0); + for (i = 0; i < (maxChannels / 2); ++i) { + channel = base->CreateChannel(); + VALIDATE_STRESS(channel < 0); + if (channel >= 0) { + channelState[channel] = true; + ++noOfActiveChannels; + } + } + srand((unsigned int) time(NULL)); + bool action(false); + double rnd(0.0); + int res(0); - // Some possible extensions include: - // Different sleep times (fixed or random) or zero. - // Start call on all or some channels. - // Two parts: first have a slight overweight to creating channels, - // then to deleting. (To ensure we hit max channels and go to zero.) - // Make sure audio is OK after test has finished. - - // Set up, start with maxChannels/2 channels - const int maxChannels = base->MaxNumOfChannels(); - VALIDATE_STRESS(maxChannels < 1); // Should always have at least one channel - bool* channelState = new bool[maxChannels]; - memset(channelState, 0, maxChannels*sizeof(bool)); - int channel(0); - int noOfActiveChannels(0); - for (i=0; i<(maxChannels/2); ++i) - { + // Create/delete channels with slight + for (i = 0; i < numberOfLoops; ++i) { + // Randomize action (create or delete channel) + action = rand() <= (RAND_MAX / 2); + if (action) { + if (noOfActiveChannels < maxChannels) { + // Create new channel channel = base->CreateChannel(); VALIDATE_STRESS(channel < 0); - if (channel >= 0) - { - channelState[channel] = true; - ++noOfActiveChannels; + if (channel >= 0) { + channelState[channel] = true; + ++noOfActiveChannels; } + } + } else { + if (noOfActiveChannels > 0) { + // Delete random channel that's created [0, maxChannels - 1] + do { + rnd = static_cast (rand()); + channel = static_cast (rnd / + (static_cast (RAND_MAX) + 1.0f) * + maxChannels); + } while (!channelState[channel]); // Must find a created channel + + res = base->DeleteChannel(channel); + VALIDATE_STRESS(0 != res); + if (0 == res) { + channelState[channel] = false; + --noOfActiveChannels; + } + } } - srand((unsigned int)time(NULL)); - bool action(false); - double rnd(0.0); - int res(0); - // Create/delete channels with slight - for (i=0; iCreateChannel(); - VALIDATE_STRESS(channel < 0); - if (channel >= 0) - { - channelState[channel] = true; - ++noOfActiveChannels; - } - } - } - else - { - if (noOfActiveChannels > 0) - { - // Delete random channel that's created [0, maxChannels - 1] - do - { - rnd = static_cast(rand()); - channel = static_cast(rnd / - (static_cast(RAND_MAX) + 1.0f) * maxChannels); - } while (!channelState[channel]); // Must find a created channel + if (!(i % markInterval)) + MARK(); + SLEEP(loopSleep); + } + ANL(); - res = base->DeleteChannel(channel); - VALIDATE_STRESS(0 != res); - if (0 == res) - { - channelState[channel] = false; - --noOfActiveChannels; - } - } - } + delete[] channelState; - if (!(i % markInterval)) MARK(); - SLEEP(loopSleep); - } - ANL(); - - delete [] channelState; - - ///////////// End test ///////////// + ///////////// End test ///////////// - // Terminate - VALIDATE_STRESS(base->Terminate()); // Deletes all channels + // Terminate + VALIDATE_STRESS(base->Terminate()); // Deletes all channels - printf("Test finished \n"); + printf("Test finished \n"); - return 0; + return 0; } +int VoEStressTest::MultipleThreadsTest() { + printf("------------------------------------------------\n"); + printf("Running multiple threads test\n"); + printf("------------------------------------------------\n"); -int VoEStressTest::MultipleThreadsTest() -{ - printf("------------------------------------------------\n"); - printf("Running multiple threads test\n"); - printf("------------------------------------------------\n"); + // Get sub-API pointers + VoEBase* base = _mgr.BasePtr(); - // Get sub-API pointers - VoEBase* base = _mgr.BasePtr(); + // Set trace + // VALIDATE_STRESS(base->SetTraceFileName( + // GetFilename("VoEStressTest_MultipleThreads_trace.txt"))); + // VALIDATE_STRESS(base->SetDebugTraceFileName( + // GetFilename("VoEStressTest_MultipleThreads_trace_debug.txt"))); + // VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo | + // kTraceWarning | kTraceError | + // kTraceCritical | kTraceApiCall | + // kTraceMemory | kTraceInfo)); - // Set trace -// VALIDATE_STRESS(base->SetTraceFileName( -// GetFilename("VoEStressTest_MultipleThreads_trace.txt"))); -// VALIDATE_STRESS(base->SetDebugTraceFileName( -// GetFilename("VoEStressTest_MultipleThreads_trace_debug.txt"))); -// VALIDATE_STRESS(base->SetTraceFilter(kTraceStateInfo | -// kTraceWarning | kTraceError | -// kTraceCritical | kTraceApiCall | -// kTraceMemory | kTraceInfo)); + // Init + VALIDATE_STRESS(base->Init()); + VALIDATE_STRESS(base->CreateChannel()); - // Init - VALIDATE_STRESS(base->Init()); - VALIDATE_STRESS(base->CreateChannel()); + ///////////// Start test ///////////// + int numberOfLoops(10000); + int loopSleep(0); + int i(0); + int markInterval(1000); - ///////////// Start test ///////////// + printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", + numberOfLoops, loopSleep, markInterval); + printf("Test will take approximately %d minutes. \n", + numberOfLoops * loopSleep / 1000 / 60 + 1); - int numberOfLoops(10000); - int loopSleep(0); - int i(0); - int markInterval(1000); + srand((unsigned int) time(NULL)); + int rnd(0); - printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", - numberOfLoops, loopSleep, markInterval); - printf("Test will take approximately %d minutes. \n", - numberOfLoops * loopSleep / 1000 / 60 + 1); + // Start extra thread + const char* threadName = "StressTest Extra API Thread"; + _ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this, + kNormalPriority, threadName); + unsigned int id(0); + VALIDATE_STRESS(!_ptrExtraApiThread->Start(id)); - srand((unsigned int)time(NULL)); - int rnd(0); + // Some possible extensions include: + // Add more API calls to randomize + // More threads + // Different sleep times (fixed or random). + // Make sure audio is OK after test has finished. - // Start extra thread - const char* threadName = "StressTest Extra API Thread"; - _ptrExtraApiThread = ThreadWrapper::CreateThread( - RunExtraApi, this, kNormalPriority, threadName); - unsigned int id(0); - VALIDATE_STRESS(!_ptrExtraApiThread->Start(id)); - - // Some possible extensions include: - // Add more API calls to randomize - // More threads - // Different sleep times (fixed or random). - // Make sure audio is OK after test has finished. - - // Call random API functions here and in extra thread, ignore any error - for (i=0; iStartPlayout(0); - } - else - { - // Stop playout - base->StopPlayout(0); - } - // --- END --- - - if (!(i % markInterval)) MARK(); - SLEEP(loopSleep); - } - ANL(); - - // Stop extra thread - VALIDATE_STRESS(!_ptrExtraApiThread->Stop()); - delete _ptrExtraApiThread; - - ///////////// End test ///////////// - - // Terminate - VALIDATE_STRESS(base->Terminate()); // Deletes all channels - - printf("Test finished \n"); - - return 0; -} - - -// Thread functions - -bool VoEStressTest::RunExtraApi(void* ptr) -{ - return static_cast(ptr)->ProcessExtraApi(); -} - -bool VoEStressTest::ProcessExtraApi() -{ - // Prepare - VoEBase* base = _mgr.BasePtr(); - int rnd(0); - - // Call random API function, ignore any error - - // This part should be equal to the marked part in the main thread + // Call random API functions here and in extra thread, ignore any error + for (i = 0; i < numberOfLoops; ++i) { + // This part should be equal to the marked part in the extra thread // --- BEGIN --- rnd = rand(); - if (rnd < (RAND_MAX / 2)) - { - // Start playout - base->StartPlayout(0); - } - else - { - // Stop playout - base->StopPlayout(0); + if (rnd < (RAND_MAX / 2)) { + // Start playout + base->StartPlayout(0); + } else { + // Stop playout + base->StopPlayout(0); } // --- END --- - return true; + if (!(i % markInterval)) + MARK(); + SLEEP(loopSleep); + } + ANL(); + + // Stop extra thread + VALIDATE_STRESS(!_ptrExtraApiThread->Stop()); + delete _ptrExtraApiThread; + + ///////////// End test ///////////// + + // Terminate + VALIDATE_STRESS(base->Terminate()); // Deletes all channels + + printf("Test finished \n"); + + return 0; } -} // namespace voetest +// Thread functions + +bool VoEStressTest::RunExtraApi(void* ptr) { + return static_cast (ptr)->ProcessExtraApi(); +} + +bool VoEStressTest::ProcessExtraApi() { + // Prepare + VoEBase* base = _mgr.BasePtr(); + int rnd(0); + + // Call random API function, ignore any error + + // This part should be equal to the marked part in the main thread + // --- BEGIN --- + rnd = rand(); + if (rnd < (RAND_MAX / 2)) { + // Start playout + base->StartPlayout(0); + } else { + // Stop playout + base->StopPlayout(0); + } + // --- END --- + + return true; +} + +} // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_stress_test.h b/src/voice_engine/main/test/auto_test/voe_stress_test.h index aab4535726..b3a418c7b4 100644 --- a/src/voice_engine/main/test/auto_test/voe_stress_test.h +++ b/src/voice_engine/main/test/auto_test/voe_stress_test.h @@ -21,28 +21,30 @@ using namespace webrtc; class VoETestManager; -class VoEStressTest -{ -public: - VoEStressTest(VoETestManager& mgr) : _mgr(mgr), _ptrExtraApiThread(NULL) {}; - ~VoEStressTest() {}; - int DoTest(); +class VoEStressTest { + public: + VoEStressTest(VoETestManager& mgr) : + _mgr(mgr), _ptrExtraApiThread(NULL) { + } + ~VoEStressTest() { + } + int DoTest(); -private: - int MenuSelection(); - int StartStopTest(); - int CreateDeleteChannelsTest(); - int MultipleThreadsTest(); + private: + int MenuSelection(); + int StartStopTest(); + int CreateDeleteChannelsTest(); + int MultipleThreadsTest(); - static bool RunExtraApi(void* ptr); - bool ProcessExtraApi(); + static bool RunExtraApi(void* ptr); + bool ProcessExtraApi(); - VoETestManager& _mgr; - static const char* _key; + VoETestManager& _mgr; + static const char* _key; - ThreadWrapper* _ptrExtraApiThread; + ThreadWrapper* _ptrExtraApiThread; }; -} // namespace voetest +} // namespace voetest #endif // WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H diff --git a/src/voice_engine/main/test/auto_test/voe_test_defines.h b/src/voice_engine/main/test/auto_test/voe_test_defines.h index cd21a5b7c8..bc438de49d 100644 --- a/src/voice_engine/main/test/auto_test/voe_test_defines.h +++ b/src/voice_engine/main/test/auto_test/voe_test_defines.h @@ -15,15 +15,15 @@ #include "engine_configurations.h" #ifdef WEBRTC_ANDROID - #include - #define ANDROID_LOG_TAG "VoiceEngine Auto Test" - #define TEST_LOG(...) \ +#include +#define ANDROID_LOG_TAG "VoiceEngine Auto Test" +#define TEST_LOG(...) \ __android_log_print(ANDROID_LOG_DEBUG, ANDROID_LOG_TAG, __VA_ARGS__) - #define TEST_LOG_ERROR(...) \ +#define TEST_LOG_ERROR(...) \ __android_log_print(ANDROID_LOG_ERROR, ANDROID_LOG_TAG, __VA_ARGS__) #else - #define TEST_LOG printf - #define TEST_LOG_ERROR printf +#define TEST_LOG printf +#define TEST_LOG_ERROR printf #endif // Select the tests to execute, list order below is same as they will be @@ -110,16 +110,15 @@ #define MARK() TEST_LOG("."); fflush(NULL); // Add test marker #define ANL() TEST_LOG("\n") // Add New Line #define AOK() TEST_LOG("[Test is OK]"); fflush(NULL); // Add OK - #if defined(_WIN32) - #define PAUSE \ +#define PAUSE \ { \ TEST_LOG("Press any key to continue..."); \ _getch(); \ TEST_LOG("\n"); \ } #else - #define PAUSE \ +#define PAUSE \ { \ TEST_LOG("Continuing (pause not supported)\n"); \ } @@ -146,9 +145,9 @@ if (err != code) \ { \ TEST_LOG_ERROR("Invalid error code (%d, should be %d) at line %d\n", - code, err, __LINE__); \ - } \ - } +code, err, __LINE__); +} +} #else #define ASSERT_TRUE(expr) TEST_MUSTPASS(!(expr)) #define ASSERT_FALSE(expr) TEST_MUSTPASS(expr) @@ -174,7 +173,6 @@ } \ } #endif // #ifdef _INSTRUMENTATION_TESTING_ - #define EXCLUDE() \ { \ TEST_LOG("\n>>> Excluding test at line: %i <<<\n\n",__LINE__); \ diff --git a/src/voice_engine/main/test/auto_test/voe_test_interface.h b/src/voice_engine/main/test/auto_test/voe_test_interface.h index 3ce7298d2d..8767339398 100644 --- a/src/voice_engine/main/test/auto_test/voe_test_interface.h +++ b/src/voice_engine/main/test/auto_test/voe_test_interface.h @@ -29,69 +29,61 @@ namespace voetest { using namespace webrtc; // TestType enumerator -enum TestType -{ - Invalid = -1, - Standard = 0, - Extended = 1, - Stress = 2, - Unit = 3, - CPU = 4 +enum TestType { + Invalid = -1, Standard = 0, Extended = 1, Stress = 2, Unit = 3, CPU = 4 }; // ExtendedSelection enumerator -enum ExtendedSelection -{ - XSEL_Invalid = -1, - XSEL_None = 0, - XSEL_All, - XSEL_Base, - XSEL_CallReport, - XSEL_Codec, - XSEL_DTMF, - XSEL_Encryption, - XSEL_ExternalMedia, - XSEL_File, - XSEL_Mixing, - XSEL_Hardware, - XSEL_NetEqStats, - XSEL_Network, - XSEL_RTP_RTCP, - XSEL_VideoSync, - XSEL_VolumeControl, - XSEL_AudioProcessing, +enum ExtendedSelection { + XSEL_Invalid = -1, + XSEL_None = 0, + XSEL_All, + XSEL_Base, + XSEL_CallReport, + XSEL_Codec, + XSEL_DTMF, + XSEL_Encryption, + XSEL_ExternalMedia, + XSEL_File, + XSEL_Mixing, + XSEL_Hardware, + XSEL_NetEqStats, + XSEL_Network, + XSEL_RTP_RTCP, + XSEL_VideoSync, + XSEL_VolumeControl, + XSEL_AudioProcessing, }; // ---------------------------------------------------------------------------- // External transport (Transport) // ---------------------------------------------------------------------------- -class my_transportation : public Transport -{ -public: - my_transportation(VoENetwork* ptr); - virtual ~my_transportation(); - VoENetwork* myNetw; - int SendPacket(int channel,const void *data,int len); - int SendRTCPPacket(int channel, const void *data, int len); - void SetDelayStatus(bool enabled, unsigned int delayInMs = 100); -private: - static bool Run(void* ptr); - bool Process(); -private: - ThreadWrapper* _thread; - CriticalSectionWrapper* _lock; - EventWrapper* _event; -private: - unsigned char _packetBuffer[1612]; - int _length; - int _channel; - bool _delayIsEnabled; - int _delayTimeInMs; +class my_transportation : public Transport { + public: + my_transportation(VoENetwork* ptr); + virtual ~my_transportation(); + VoENetwork* myNetw; + int SendPacket(int channel, const void *data, int len); + int SendRTCPPacket(int channel, const void *data, int len); + void SetDelayStatus(bool enabled, unsigned int delayInMs = 100); + private: + static bool Run(void* ptr); + bool Process(); + private: + ThreadWrapper* _thread; + CriticalSectionWrapper* _lock; + EventWrapper* _event; + private: + unsigned char _packetBuffer[1612]; + int _length; + int _channel; + bool _delayIsEnabled; + int _delayTimeInMs; }; // Main test function int runAutoTest(TestType testType, ExtendedSelection extendedSel); -} // namespace voetest +} // namespace voetest #endif // WEBRTC_VOICE_ENGINE_VOE_TEST_INTERFACE_H diff --git a/src/voice_engine/main/test/auto_test/voe_unit_test.cc b/src/voice_engine/main/test/auto_test/voe_unit_test.cc index 0775b5589b..1aa9e10dab 100644 --- a/src/voice_engine/main/test/auto_test/voe_unit_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_unit_test.cc @@ -13,7 +13,7 @@ #include #include #if defined(_WIN32) - #include +#include #endif #include "voe_unit_test.h" @@ -41,11 +41,11 @@ extern char* GetResource(char* resource); extern const char* GetResource(const char* resource); const char* VoEUnitTest::_key = "====YUtFWRAAAAADBtIHgAAAAAEAAAAcAAAAAQBHU0dsb2" - "JhbCBJUCBTb3VuZAAC\nAAAAIwAAAExpY2Vuc2VkIHRvIE5vcnRlbCBOZXR3cm9rcwAAAAAxA" - "AAAZxZ7/u0M\niFYyTwSwko5Uutf7mh8S0O4rYZYTFidbzQeuGonuL17F/2oD/2pfDp3jL4Rf" - "3z/A\nnlJsEJgEtASkDNFuwLILjGY0pzjjAYQp3pCl6z6k2MtE06AirdjGLYCjENpq/opX\nO" - "rs3sIuwdYK5va/aFcsjBDmlsGCUM48RDYG9s23bIHYafXUC4ofOaubbZPWiPTmL\nEVJ8WH4F" - "9pgNjALc14oJXfON7r/3\n=EsLx"; + "JhbCBJUCBTb3VuZAAC\nAAAAIwAAAExpY2Vuc2VkIHRvIE5vcnRlbCBOZXR3cm9rcwAAAAAxA" + "AAAZxZ7/u0M\niFYyTwSwko5Uutf7mh8S0O4rYZYTFidbzQeuGonuL17F/2oD/2pfDp3jL4Rf" + "3z/A\nnlJsEJgEtASkDNFuwLILjGY0pzjjAYQp3pCl6z6k2MtE06AirdjGLYCjENpq/opX\nO" + "rs3sIuwdYK5va/aFcsjBDmlsGCUM48RDYG9s23bIHYafXUC4ofOaubbZPWiPTmL\nEVJ8WH4F" + "9pgNjALc14oJXfON7r/3\n=EsLx"; // ---------------------------------------------------------------------------- // >>> R E A D M E F I R S T <<< @@ -57,7 +57,7 @@ const char* VoEUnitTest::_key = "====YUtFWRAAAAADBtIHgAAAAAEAAAAcAAAAAQBHU0dsb2" // - G.729 // - G.722.1C -// 2) It is also possible to modify the simulation time for each indivifual test +// 2) It is also possible to modify the simulation time for each individual test // const int dTBetweenEachTest = 4000; @@ -65,143 +65,118 @@ const int dTBetweenEachTest = 4000; // Encrypt // ---------------------------------------------------------------------------- -void VoEUnitTest::encrypt(int channel_no, - unsigned char * in_data, - unsigned char * out_data, - int bytes_in, - int * bytes_out) -{ - int i; +void VoEUnitTest::encrypt(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, + int * bytes_out) { + int i; - if (!_extOnOff) - { - // no stereo emulation <=> pure bypass - for (i = 0; i < bytes_in; i++) - out_data[i] = in_data[i]; - *bytes_out = bytes_in; - } - else if (_extOnOff && (_extBitsPerSample == 16)) - { - // stereo emulation (sample based, 2 bytes per sample) - - const int nBytesPayload = bytes_in-12; - - // RTP header (first 12 bytes) - memcpy(out_data, in_data, 12); - - // skip RTP header - short* ptrIn = (short*) &in_data[12]; - short* ptrOut = (short*) &out_data[12]; - - // network byte order - for (i = 0; i < nBytesPayload/2; i++) - { - // produce two output samples for each input sample - *ptrOut++ = *ptrIn; // left sample - *ptrOut++ = *ptrIn; // right sample - ptrIn++; - } - - *bytes_out = 12 + 2*nBytesPayload; - } - else if (_extOnOff && (_extBitsPerSample == 8)) - { - // stereo emulation (sample based, 1 bytes per sample) - - const int nBytesPayload = bytes_in-12; - - // RTP header (first 12 bytes) - memcpy(out_data, in_data, 12); - - // skip RTP header - unsigned char* ptrIn = (unsigned char*) &in_data[12]; - unsigned char* ptrOut = (unsigned char*) &out_data[12]; - - // network byte order - for (i = 0; i < nBytesPayload; i++) - { - // produce two output samples for each input sample - *ptrOut++ = *ptrIn; // left sample - *ptrOut++ = *ptrIn; // right sample - ptrIn++; - } - - *bytes_out = 12 + 2*nBytesPayload; - } - else if (_extOnOff && (_extBitsPerSample == -1)) - { - // stereo emulation (frame based) - - const int nBytesPayload = bytes_in-12; - - // RTP header (first 12 bytes) - memcpy(out_data, in_data, 12); - - // skip RTP header - unsigned char* ptrIn = (unsigned char*) &in_data[12]; - unsigned char* ptrOut = (unsigned char*) &out_data[12]; - - // left channel - for (i = 0; i < nBytesPayload; i++) - { - *ptrOut++ = *ptrIn++; - } - - ptrIn = (unsigned char*) &in_data[12]; - - // right channel - for (i = 0; i < nBytesPayload; i++) - { - *ptrOut++ = *ptrIn++; - } - - *bytes_out = 12 + 2*nBytesPayload; - } -} - -void VoEUnitTest::decrypt(int channel_no, - unsigned char * in_data, - unsigned char * out_data, - int bytes_in, - int * bytes_out) -{ - int i; + if (!_extOnOff) { + // no stereo emulation <=> pure bypass for (i = 0; i < bytes_in; i++) - out_data[i] = in_data[i]; - *bytes_out = bytes_in; -} - -void VoEUnitTest::encrypt_rtcp(int channel_no, - unsigned char * in_data, - unsigned char * out_data, - int bytes_in, - int * bytes_out) -{ - int i; - for (i = 0; i < bytes_in; i++) - out_data[i] = in_data[i]; + out_data[i] = in_data[i]; *bytes_out = bytes_in; + } else if (_extOnOff && (_extBitsPerSample == 16)) { + // stereo emulation (sample based, 2 bytes per sample) + + const int nBytesPayload = bytes_in - 12; + + // RTP header (first 12 bytes) + memcpy(out_data, in_data, 12); + + // skip RTP header + short* ptrIn = (short*) &in_data[12]; + short* ptrOut = (short*) &out_data[12]; + + // network byte order + for (i = 0; i < nBytesPayload / 2; i++) { + // produce two output samples for each input sample + *ptrOut++ = *ptrIn; // left sample + *ptrOut++ = *ptrIn; // right sample + ptrIn++; + } + + *bytes_out = 12 + 2 * nBytesPayload; + } else if (_extOnOff && (_extBitsPerSample == 8)) { + // stereo emulation (sample based, 1 bytes per sample) + + const int nBytesPayload = bytes_in - 12; + + // RTP header (first 12 bytes) + memcpy(out_data, in_data, 12); + + // skip RTP header + unsigned char* ptrIn = (unsigned char*) &in_data[12]; + unsigned char* ptrOut = (unsigned char*) &out_data[12]; + + // network byte order + for (i = 0; i < nBytesPayload; i++) { + // produce two output samples for each input sample + *ptrOut++ = *ptrIn; // left sample + *ptrOut++ = *ptrIn; // right sample + ptrIn++; + } + + *bytes_out = 12 + 2 * nBytesPayload; + } else if (_extOnOff && (_extBitsPerSample == -1)) { + // stereo emulation (frame based) + + const int nBytesPayload = bytes_in - 12; + + // RTP header (first 12 bytes) + memcpy(out_data, in_data, 12); + + // skip RTP header + unsigned char* ptrIn = (unsigned char*) &in_data[12]; + unsigned char* ptrOut = (unsigned char*) &out_data[12]; + + // left channel + for (i = 0; i < nBytesPayload; i++) { + *ptrOut++ = *ptrIn++; + } + + ptrIn = (unsigned char*) &in_data[12]; + + // right channel + for (i = 0; i < nBytesPayload; i++) { + *ptrOut++ = *ptrIn++; + } + + *bytes_out = 12 + 2 * nBytesPayload; + } } -void VoEUnitTest::decrypt_rtcp(int channel_no, - unsigned char * in_data, - unsigned char * out_data, - int bytes_in, - int * bytes_out) -{ - int i; - for (i = 0; i < bytes_in; i++) - out_data[i] = in_data[i]; - *bytes_out = bytes_in; +void VoEUnitTest::decrypt(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, + int * bytes_out) { + int i; + for (i = 0; i < bytes_in; i++) + out_data[i] = in_data[i]; + *bytes_out = bytes_in; } -void VoEUnitTest::SetStereoExternalEncryption(int channel, - bool onOff, - int bitsPerSample) -{ - _extOnOff = onOff; - _extChannel = channel; - _extBitsPerSample = bitsPerSample; +void VoEUnitTest::encrypt_rtcp(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, + int * bytes_out) { + int i; + for (i = 0; i < bytes_in; i++) + out_data[i] = in_data[i]; + *bytes_out = bytes_in; +} + +void VoEUnitTest::decrypt_rtcp(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, + int * bytes_out) { + int i; + for (i = 0; i < bytes_in; i++) + out_data[i] = in_data[i]; + *bytes_out = bytes_in; +} + +void VoEUnitTest::SetStereoExternalEncryption(int channel, bool onOff, + int bitsPerSample) { + _extOnOff = onOff; + _extChannel = channel; + _extBitsPerSample = bitsPerSample; } // VoEVEMediaProcess @@ -212,933 +187,897 @@ MyMedia mpobj; // ---------------------------------------------------------------------------- VoEUnitTest::VoEUnitTest(VoETestManager& mgr) : - _mgr(mgr), - _extOnOff(false), - _extBitsPerSample(-1) -{ - for (int i = 0; i < 32; i++) - { - _listening[i] = false; - _playing[i] = false; - _sending[i] = false; - } + _mgr(mgr), _extOnOff(false), _extBitsPerSample(-1) { + for (int i = 0; i < 32; i++) { + _listening[i] = false; + _playing[i] = false; + _sending[i] = false; + } } // ---------------------------------------------------------------------------- // DoTest // ---------------------------------------------------------------------------- -int VoEUnitTest::DoTest() -{ - int test(-1); - int ret(0); - while ((test != 0) && (ret != -1)) - { - test = MenuSelection(); - switch (test) - { - case 0: - // Quit stress test - break; - case 1: - ret = MixerTest(); - break; - case 2: - ret = MixerTest(); - break; - default: - // Should not be possible - printf("Invalid selection! (Test code error)\n"); - assert(false); - } // switch - } // while +int VoEUnitTest::DoTest() { + int test(-1); + int ret(0); + while ((test != 0) && (ret != -1)) { + test = MenuSelection(); + switch (test) { + case 0: + // Quit stress test + break; + case 1: + ret = MixerTest(); + break; + case 2: + ret = MixerTest(); + break; + default: + // Should not be possible + printf("Invalid selection! (Test code error)\n"); + assert(false); + } // switch + } // while - return ret; + return ret; } // ---------------------------------------------------------------------------- // MenuSelection // ---------------------------------------------------------------------------- -int VoEUnitTest::MenuSelection() -{ - printf("------------------------------------------------\n"); - printf("Select unit test\n\n"); - printf(" (0) Quit\n"); - printf(" (1) All\n"); - printf("- - - - - - - - - - - - - - - - - - - - - - - - \n"); - printf(" (2) Mixer\n"); +int VoEUnitTest::MenuSelection() { + printf("------------------------------------------------\n"); + printf("Select unit test\n\n"); + printf(" (0) Quit\n"); + printf(" (1) All\n"); + printf("- - - - - - - - - - - - - - - - - - - - - - - - \n"); + printf(" (2) Mixer\n"); - const int maxMenuSelection = 2; - int selection(-1); + const int maxMenuSelection = 2; + int selection(-1); - while ((selection < 0) || (selection > maxMenuSelection)) - { - printf("\n: "); - int retval = scanf("%d", &selection); - if ((retval != 1) || (selection < 0) || (selection > maxMenuSelection)) - { - printf("Invalid selection!\n"); - } + while ((selection < 0) || (selection > maxMenuSelection)) { + printf("\n: "); + int retval = scanf("%d", &selection); + if ((retval != 1) || (selection < 0) || (selection > maxMenuSelection)) { + printf("Invalid selection!\n"); } + } - return selection; + return selection; } // ---------------------------------------------------------------------------- // StartMedia // ---------------------------------------------------------------------------- -int VoEUnitTest::StartMedia(int channel, - int rtpPort, - bool listen, - bool playout, - bool send, - bool fileAsMic, - bool localFile) -{ - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); +int VoEUnitTest::StartMedia(int channel, int rtpPort, bool listen, bool playout, + bool send, bool fileAsMic, bool localFile) { + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); - _listening[channel] = false; - _playing[channel] = false; - _sending[channel] = false; + _listening[channel] = false; + _playing[channel] = false; + _sending[channel] = false; - CHECK(base->SetLocalReceiver(channel, rtpPort)); - CHECK(base->SetSendDestination(channel, rtpPort, "127.0.0.1")); - if (listen) - { - _listening[channel] = true; - CHECK(base->StartReceive(channel)); - } - if (playout) - { - _playing[channel] = true; - CHECK(base->StartPlayout(channel)); - } - if (send) - { - _sending[channel] = true; - CHECK(base->StartSend(channel)); - } - if (fileAsMic) - { - // play mic as file, mix with microphone to ensure that SWB can be - //tested as well - const bool mixWithMic(true); - CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), - true, mixWithMic)); - } - if (localFile) - { - CHECK(file->StartPlayingFileLocally(channel, - GetResource("audio_short16.pcm"), - false, - kFileFormatPcm16kHzFile)); - } + CHECK(base->SetLocalReceiver(channel, rtpPort)); + CHECK(base->SetSendDestination(channel, rtpPort, "127.0.0.1")); + if (listen) { + _listening[channel] = true; + CHECK(base->StartReceive(channel)); + } + if (playout) { + _playing[channel] = true; + CHECK(base->StartPlayout(channel)); + } + if (send) { + _sending[channel] = true; + CHECK(base->StartSend(channel)); + } + if (fileAsMic) { + // play mic as file, mix with microphone to ensure that SWB can be + //tested as well + const bool mixWithMic(true); + CHECK(file->StartPlayingFileAsMicrophone(channel, _mgr.AudioFilename(), + true, mixWithMic)); + } + if (localFile) { + CHECK(file->StartPlayingFileLocally(channel, + GetResource("audio_short16.pcm"), + false, + kFileFormatPcm16kHzFile)); + } - return 0; + return 0; } // ---------------------------------------------------------------------------- // StopMedia // ---------------------------------------------------------------------------- -int VoEUnitTest::StopMedia(int channel) -{ - VoEBase* base = _mgr.BasePtr(); - VoEFile* file = _mgr.FilePtr(); +int VoEUnitTest::StopMedia(int channel) { + VoEBase* base = _mgr.BasePtr(); + VoEFile* file = _mgr.FilePtr(); - if (file->IsPlayingFileAsMicrophone(channel)) - { - CHECK(file->StopPlayingFileAsMicrophone(channel)); - } - if (file->IsPlayingFileLocally(channel)) - { - CHECK(file->StopPlayingFileLocally(channel)); - } - if (_listening[channel]) - { - _listening[channel] = false; - CHECK(base->StopReceive(channel)); - } - if (_playing[channel]) - { - _playing[channel] = false; - CHECK(base->StopPlayout(channel)); - } - if (_sending[channel]) - { - _sending[channel] = false; - CHECK(base->StopSend(channel)); - } + if (file->IsPlayingFileAsMicrophone(channel)) { + CHECK(file->StopPlayingFileAsMicrophone(channel)); + } + if (file->IsPlayingFileLocally(channel)) { + CHECK(file->StopPlayingFileLocally(channel)); + } + if (_listening[channel]) { + _listening[channel] = false; + CHECK(base->StopReceive(channel)); + } + if (_playing[channel]) { + _playing[channel] = false; + CHECK(base->StopPlayout(channel)); + } + if (_sending[channel]) { + _sending[channel] = false; + CHECK(base->StopSend(channel)); + } - return 0; + return 0; } -void VoEUnitTest::Sleep(unsigned int timeMillisec, bool addMarker) -{ - if (addMarker) - { - float dtSec = (float) ((float) timeMillisec / 1000.0); - printf("[dT=%.1f]", dtSec); - fflush(NULL); - } - ::Sleep(timeMillisec); +void VoEUnitTest::Sleep(unsigned int timeMillisec, bool addMarker) { + if (addMarker) { + float dtSec = (float) ((float) timeMillisec / 1000.0); + printf("[dT=%.1f]", dtSec); + fflush(NULL); + } + ::Sleep(timeMillisec); } -void VoEUnitTest::Wait() -{ +void VoEUnitTest::Wait() { #if defined(_WIN32) - printf("\npress any key..."); fflush(NULL); - _getch(); + printf("\npress any key..."); fflush(NULL); + _getch(); #endif } -void VoEUnitTest::Test(const char* msg) -{ - printf("%s", msg); fflush(NULL); - printf("\n"); fflush(NULL); +void VoEUnitTest::Test(const char* msg) { + printf("%s", msg); + fflush(NULL); + printf("\n"); + fflush(NULL); } -int VoEUnitTest::MixerTest() -{ - // Set up test parameters first - // - const int testTime(dTBetweenEachTest); - - printf("\n\n================================================\n"); - printf(" Mixer Unit Test\n"); - printf("================================================\n\n"); - - // Get sub-API pointers - // - VoEBase* base = _mgr.BasePtr(); - VoECodec* codec = _mgr.CodecPtr(); - VoEFile* file = _mgr.FilePtr(); - VoEVolumeControl* volume = _mgr.VolumeControlPtr(); - VoEEncryption* encrypt = _mgr.EncryptionPtr(); - VoEDtmf* dtmf = _mgr.DtmfPtr(); - VoEExternalMedia* xmedia = _mgr.ExternalMediaPtr(); - - // Set trace - // - VoiceEngine::SetTraceFile(GetFilename("UnitTest_Mixer_trace.txt")); - VoiceEngine::SetTraceFilter(kTraceStateInfo | - kTraceWarning | - kTraceError | - kTraceCritical | - kTraceApiCall | - kTraceMemory | - kTraceInfo); - - // Init - // - CHECK(base->Init()); - - // 8 kHz -// CodecInst l16_8 = { 123, "L16", 8000, 160, 1, 128000 }; - CodecInst pcmu_8 = { 0, "pcmu", 8000, 160, 1, 64000 }; -// CodecInst g729_8 = { 18, "g729", 8000, 160, 1, 8000 }; - - // 16 kHz - CodecInst ipcmwb_16 = { 97, "ipcmwb", 16000, 320, 1, 80000 }; - CodecInst l16_16 = { 124, "L16", 16000, 320, 1, 256000 }; - - // 32 kHz - CodecInst l16_32 = { 125, "L16", 32000, 320, 1, 512000 }; - CodecInst g722_1c_32 = { 126, "G7221", 32000, 640, 1, 32000 };// 20ms@32kHz - - // ------------------------ - // Verify mixing frequency - // ------------------------ - - base->CreateChannel(); - - Test(">> Verify correct mixing frequency:\n"); - - Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - - Test("(ch 0) Sending file at 16kHz <=> mixing at 16kHz..."); - CHECK(codec->SetSendCodec(0, ipcmwb_16)); - Sleep(testTime); - - Test("(ch 0) Sending speech at 32kHz <=> mixing at 32Hz..."); - CHECK(codec->SetSendCodec(0, l16_32)); - Sleep(testTime); - - Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); - CHECK(codec->SetSendCodec(0, pcmu_8)); - Sleep(testTime); - - Test("(ch 0) Playing 16kHz file locally <=> mixing at 16kHz..."); - CHECK(file->StartPlayingFileLocally(0, GetResource("audio_long16.pcm"), - false, kFileFormatPcm16kHzFile)); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - - base->CreateChannel(); - - Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); - CHECK(codec->SetSendCodec(0, pcmu_8)); - Sleep(testTime); - - Test("(ch 0) Sending speech at 32kHz <=> mixing at 32Hz..."); - CHECK(codec->SetSendCodec(0, l16_32)); - Sleep(testTime); - - Test("(ch 1) Playing 16kHz file locally <=> mixing at 32kHz..."); - CHECK(StartMedia(1, 54321, false, true, false, false, true)); - Sleep(testTime); - - CHECK(StopMedia(1)); - CHECK(StopMedia(0)); - - base->DeleteChannel(1); - base->DeleteChannel(0); - ANL(); - - // ------------------------- - // Verify stereo mode mixing - // ------------------------- - - base->CreateChannel(); - base->CreateChannel(); - - // SetOutputVolumePan - // - // Ensure that all cases sound OK and that the mixer changes state between - // mono and stereo as it should. A debugger is required to trace the state - // transitions. - - Test(">> Verify correct mixing in stereo using SetOutputVolumePan():\n"); - - Test("(ch 0) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); - CHECK(StartMedia(0, 12345, false, true, false, false, true)); - Sleep(testTime); - Test("Panning volume to the left <=> mixing in stereo @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 1.0, 0.0)); - Sleep(testTime); - Test("Panning volume to the right <=> mixing in stereo @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 0.0, 1.0)); - Sleep(testTime); - Test("Back to center volume again <=> mixing in mono @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); - Sleep(testTime); - Test("(ch 1) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); - CHECK(StartMedia(1, 54321, false, true, false, false, true)); - Sleep(testTime); - Test("Panning volume to the left <=> mixing in stereo @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 1.0, 0.0)); - Sleep(testTime); - Test("Back to center volume again <=> mixing in mono @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); - Sleep(testTime); - Test("(ch 1) Stopped playing file <=> mixing in mono @ 16kHz..."); - CHECK(StopMedia(1)); - Sleep(testTime); - CHECK(StopMedia(0)); - Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - Test("(ch 0) Sending speech at 32kHz <=> mixing at 32kHz..."); - CHECK(codec->SetSendCodec(0, l16_32)); - Sleep(testTime); - Test("Panning volume to the right <=> mixing in stereo @ 32kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 0.0, 1.0)); - Sleep(testTime); - Test("Back to center volume again <=> mixing in mono @ 32kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); - Sleep(testTime); - CHECK(StopMedia(0)); - ANL(); - - base->DeleteChannel(0); - base->DeleteChannel(1); - - // SetChannelOutputVolumePan - // - // Ensure that all cases sound OK and that the mixer changes state between - // mono and stereo as it should. A debugger is required to trace the state - // transitions. - - base->CreateChannel(); - base->CreateChannel(); - - Test(">> Verify correct mixing in stereo using" - " SetChannelOutputVolumePan():\n"); - - Test("(ch 0) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); - CHECK(StartMedia(0, 12345, false, true, false, false, true)); - Sleep(testTime); - Test("(ch 0) Panning channel volume to the left <=> mixing in stereo @ " - "16kHz..."); - CHECK(volume->SetOutputVolumePan(0, 1.0, 0.0)); - Sleep(testTime); - Test("(ch 0) Panning channel volume to the right <=> mixing in stereo" - " @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(0, 0.0, 1.0)); - Sleep(testTime); - Test("(ch 0) Back to center volume again <=> mixing in mono @" - " 16kHz..."); - CHECK(volume->SetOutputVolumePan(0, 1.0, 1.0)); - Sleep(testTime); - Test("(ch 1) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); - CHECK(StartMedia(1, 54321, false, true, false, false, true)); - Sleep(testTime); - Test("(ch 1) Panning channel volume to the left <=> mixing in stereo " - "@ 16kHz..."); - CHECK(volume->SetOutputVolumePan(1, 1.0, 0.0)); - Sleep(testTime); - Test("(ch 1) Back to center volume again <=> mixing in mono @ 16kHz..."); - CHECK(volume->SetOutputVolumePan(1, 1.0, 1.0)); - Sleep(testTime); - Test("(ch 1) Stopped playing file <=> mixing in mono @ 16kHz..."); - CHECK(StopMedia(1)); - Sleep(testTime); - CHECK(StopMedia(0)); - ANL(); - - base->DeleteChannel(0); - base->DeleteChannel(1); - - // Emulate stereo-encoding using Encryption - // - // Modify the transmitted RTP stream by using external encryption. - // Supports frame based and sample based "stereo-encoding schemes". - - base->CreateChannel(); - - Test(">> Verify correct mixing in stereo using emulated stereo input:\n"); - - // enable external encryption - CHECK(encrypt->RegisterExternalEncryption(0, *this)); - Test("(ch 0) External Encryption is now enabled:"); - - Test("(ch 0) Sending file at 8kHz <=> mixing in mono @ 8kHz..."); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - - // switch to 16kHz (L16) sending codec - CHECK(codec->SetSendCodec(0, l16_16)); - Test("(ch 0) Sending file at 16kHz (L16) <=> mixing in mono @ 16kHz..."); - Sleep(testTime); - - // register L16 as 2-channel codec on receiving side => - // should sound bad since RTP module splits all received packets in half - // (sample based) - CHECK(base->StopPlayout(0)); - CHECK(base->StopReceive(0)); - l16_16.channels = 2; - CHECK(codec->SetRecPayloadType(0, l16_16)); - CHECK(base->StartReceive(0)); - CHECK(base->StartPlayout(0)); - Test("(ch 0) 16kHz L16 is now registered as 2-channel codec on RX side => " - "should sound bad..."); - Sleep(testTime); - - // emulate sample-based stereo encoding - Test("(ch 0) Emulate sample-based stereo encoding on sending side => " - "should sound OK..."); - SetStereoExternalEncryption(0, true, 16); - Sleep(testTime); - Test("(ch 0) Stop emulating sample-based stereo encoding on sending side =>" - " should sound bad..."); - SetStereoExternalEncryption(0, false, 16); - Sleep(testTime); - Test("(ch 0) Emulate sample-based stereo encoding on sending side => " - "should sound OK..."); - SetStereoExternalEncryption(0, true, 16); - Sleep(testTime); - - // switch to 32kHz (L16) sending codec and disable stereo encoding - CHECK(codec->SetSendCodec(0, l16_32)); - SetStereoExternalEncryption(0, false, 16); - Test("(ch 0) Sending file and spech at 32kHz (L16) <=> mixing in mono @ " - "32kHz..."); - Sleep(testTime); - - // register L16 32kHz as 2-channel codec on receiving side - CHECK(base->StopPlayout(0)); - CHECK(base->StopReceive(0)); - l16_32.channels = 2; - CHECK(codec->SetRecPayloadType(0, l16_32)); - CHECK(base->StartReceive(0)); - CHECK(base->StartPlayout(0)); - Test("(ch 0) 32kHz L16 is now registered as 2-channel codec on RX side =>" - " should sound bad..."); - Sleep(testTime); - - // emulate sample-based stereo encoding - Test("(ch 0) Emulate sample-based stereo encoding on sending side =>" - " should sound OK..."); - SetStereoExternalEncryption(0, true, 16); - Sleep(testTime); - - StopMedia(0); - l16_32.channels = 1; - - // disable external encryption - CHECK(encrypt->DeRegisterExternalEncryption(0)); - ANL(); - - base->DeleteChannel(0); - - // ------------------ - // Verify put-on-hold - // ------------------ - - base->CreateChannel(); - base->CreateChannel(); - - Test(">> Verify put-on-hold functionality:\n"); - - Test("(ch 0) Sending at 8kHz..."); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - - CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); - Test("(ch 0) Playout is now on hold..."); - Sleep(testTime); - CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); - Test("(ch 0) Playout is now enabled again..."); - Sleep(testTime); - - Test("(ch 0) Sending at 16kHz..."); - l16_16.channels = 1; - CHECK(codec->SetSendCodec(0, l16_16)); - Sleep(testTime); - - CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); - Test("(ch 0) Playout is now on hold..."); - Sleep(testTime); - CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); - Test("(ch 0) Playout is now enabled again..."); - Sleep(testTime); - - Test("(ch 0) Perform minor panning to the left to force mixing in" - " stereo..."); - CHECK(volume->SetOutputVolumePan(0, (float)1.0, (float)0.7)); - Sleep(testTime); - - CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); - Test("(ch 0) Playout is now on hold..."); - Sleep(testTime); - CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); - Test("(ch 0) Playout is now enabled again..."); - Sleep(testTime); - - Test("(ch 0) Back to center volume again..."); - CHECK(volume->SetOutputVolumePan(0, 1.0, 1.0)); - Sleep(testTime); - - Test("(ch 1) Add 16kHz local file to the mixer..."); - CHECK(StartMedia(1, 54321, false, true, false, false, true)); - Sleep(testTime); - - CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); - Test("(ch 0) Playout is now on hold..."); - Sleep(testTime); - CHECK(base->SetOnHoldStatus(1, true, kHoldPlayOnly)); - Test("(ch 1) Playout is now on hold => should be silent..."); - Sleep(testTime); - CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); - Test("(ch 0) Playout is now enabled again..."); - CHECK(base->SetOnHoldStatus(1, false, kHoldPlayOnly)); - Test("(ch 1) Playout is now enabled again..."); - Sleep(testTime); - StopMedia(1); - Test("(ch 1) Stopped playing file..."); - Sleep(testTime); - StopMedia(0); - ANL(); - - base->DeleteChannel(0); - base->DeleteChannel(1); - - // ----------------------------------- - // Verify recording of playout to file - // ----------------------------------- - - // StartRecordingPlayout - // - // Verify that the correct set of signals is recorded in the mixer. - // Record each channel and all channels (-1) to ensure that post and pre - // mixing recording works. - - base->CreateChannel(); - base->CreateChannel(); - - Test(">> Verify file-recording functionality:\n"); - - Test("(ch 0) Sending at 8kHz..."); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - - Test("(ch 0) Recording of playout to 16kHz PCM file..."); - CHECK(file->StartRecordingPlayout( - 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); - Sleep(testTime); - CHECK(file->StopRecordingPlayout(0)); - - Test("(ch 0) Playing out the recorded file..."); - CHECK(volume->SetInputMute(0, true)); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - CHECK(volume->SetInputMute(0, false)); - - CHECK(codec->SetSendCodec(0, l16_16)); - Test("(ch 0) Sending at 16kHz (L16)..."); - Sleep(testTime); - - Test("(ch 0) Recording of playout to 16kHz PCM file..."); - CHECK(file->StartRecordingPlayout( - 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); - Sleep(testTime); - CHECK(file->StopRecordingPlayout(0)); - - Test("(ch 0) Playing out the recorded file..."); - CHECK(volume->SetInputMute(0, true)); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - CHECK(volume->SetInputMute(0, false)); - - CHECK(codec->SetSendCodec(0, l16_32)); - Test("(ch 0) Sending at 32kHz (L16)..."); - Sleep(testTime); - - Test("(ch 0) Recording of playout to 16kHz PCM file..."); - CHECK(file->StartRecordingPlayout( - 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); - Sleep(testTime); - CHECK(file->StopRecordingPlayout(0)); - - Test("(ch 0) Playing out the recorded file..."); - CHECK(volume->SetInputMute(0, true)); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - CHECK(volume->SetInputMute(0, false)); - - Test("(ch 0) Sending at 16kHz without file as mic but file added on the" - " playout side instead..."); - CHECK(StopMedia(0)); - CHECK(StartMedia(0, 12345, false, true, false, false, true)); - CHECK(codec->SetSendCodec(0, l16_16)); - Sleep(testTime); - - Test("(ch 0) Recording of playout to 16kHz PCM file..."); - CHECK(file->StartRecordingPlayout( - 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); - Sleep(testTime); - CHECK(file->StopRecordingPlayout(0)); - CHECK(file->StopPlayingFileLocally(0)); - - Test("(ch 0) Playing out the recorded file..."); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - - CHECK(StopMedia(0)); - CHECK(StopMedia(1)); - - Test("(ch 0) Sending at 16kHz..."); +int VoEUnitTest::MixerTest() { + // Set up test parameters first + // + const int testTime(dTBetweenEachTest); + + printf("\n\n================================================\n"); + printf(" Mixer Unit Test\n"); + printf("================================================\n\n"); + + // Get sub-API pointers + // + VoEBase* base = _mgr.BasePtr(); + VoECodec* codec = _mgr.CodecPtr(); + VoEFile* file = _mgr.FilePtr(); + VoEVolumeControl* volume = _mgr.VolumeControlPtr(); + VoEEncryption* encrypt = _mgr.EncryptionPtr(); + VoEDtmf* dtmf = _mgr.DtmfPtr(); + VoEExternalMedia* xmedia = _mgr.ExternalMediaPtr(); + + // Set trace + // + VoiceEngine::SetTraceFile(GetFilename("UnitTest_Mixer_trace.txt")); + VoiceEngine::SetTraceFilter(kTraceStateInfo | kTraceWarning | kTraceError | + kTraceCritical | kTraceApiCall | kTraceMemory | + kTraceInfo); + + // Init + // + CHECK(base->Init()); + + // 8 kHz + // CodecInst l16_8 = { 123, "L16", 8000, 160, 1, 128000 }; + CodecInst pcmu_8 = { 0, "pcmu", 8000, 160, 1, 64000 }; + // CodecInst g729_8 = { 18, "g729", 8000, 160, 1, 8000 }; + + // 16 kHz + CodecInst ipcmwb_16 = { 97, "ipcmwb", 16000, 320, 1, 80000 }; + CodecInst l16_16 = { 124, "L16", 16000, 320, 1, 256000 }; + + // 32 kHz + CodecInst l16_32 = { 125, "L16", 32000, 320, 1, 512000 }; + CodecInst g722_1c_32 = { 126, "G7221", 32000, 640, 1, 32000 };// 20ms@32kHz + + // ------------------------ + // Verify mixing frequency + // ------------------------ + + base->CreateChannel(); + + Test(">> Verify correct mixing frequency:\n"); + + Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + + Test("(ch 0) Sending file at 16kHz <=> mixing at 16kHz..."); + CHECK(codec->SetSendCodec(0, ipcmwb_16)); + Sleep(testTime); + + Test("(ch 0) Sending speech at 32kHz <=> mixing at 32Hz..."); + CHECK(codec->SetSendCodec(0, l16_32)); + Sleep(testTime); + + Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); + CHECK(codec->SetSendCodec(0, pcmu_8)); + Sleep(testTime); + + Test("(ch 0) Playing 16kHz file locally <=> mixing at 16kHz..."); + CHECK(file->StartPlayingFileLocally(0, GetResource("audio_long16.pcm"), + false, kFileFormatPcm16kHzFile)); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + + base->CreateChannel(); + + Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); + CHECK(codec->SetSendCodec(0, pcmu_8)); + Sleep(testTime); + + Test("(ch 0) Sending speech at 32kHz <=> mixing at 32Hz..."); + CHECK(codec->SetSendCodec(0, l16_32)); + Sleep(testTime); + + Test("(ch 1) Playing 16kHz file locally <=> mixing at 32kHz..."); + CHECK(StartMedia(1, 54321, false, true, false, false, true)); + Sleep(testTime); + + CHECK(StopMedia(1)); + CHECK(StopMedia(0)); + + base->DeleteChannel(1); + base->DeleteChannel(0); + ANL(); + + // ------------------------- + // Verify stereo mode mixing + // ------------------------- + + base->CreateChannel(); + base->CreateChannel(); + + // SetOutputVolumePan + // + // Ensure that all cases sound OK and that the mixer changes state between + // mono and stereo as it should. A debugger is required to trace the state + // transitions. + + Test(">> Verify correct mixing in stereo using SetOutputVolumePan():\n"); + + Test("(ch 0) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); + CHECK(StartMedia(0, 12345, false, true, false, false, true)); + Sleep(testTime); + Test("Panning volume to the left <=> mixing in stereo @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 1.0, 0.0)); + Sleep(testTime); + Test("Panning volume to the right <=> mixing in stereo @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 0.0, 1.0)); + Sleep(testTime); + Test("Back to center volume again <=> mixing in mono @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); + Sleep(testTime); + Test("(ch 1) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); + CHECK(StartMedia(1, 54321, false, true, false, false, true)); + Sleep(testTime); + Test("Panning volume to the left <=> mixing in stereo @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 1.0, 0.0)); + Sleep(testTime); + Test("Back to center volume again <=> mixing in mono @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); + Sleep(testTime); + Test("(ch 1) Stopped playing file <=> mixing in mono @ 16kHz..."); + CHECK(StopMedia(1)); + Sleep(testTime); + CHECK(StopMedia(0)); + Test("(ch 0) Sending file at 8kHz <=> mixing at 8kHz..."); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + Test("(ch 0) Sending speech at 32kHz <=> mixing at 32kHz..."); + CHECK(codec->SetSendCodec(0, l16_32)); + Sleep(testTime); + Test("Panning volume to the right <=> mixing in stereo @ 32kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 0.0, 1.0)); + Sleep(testTime); + Test("Back to center volume again <=> mixing in mono @ 32kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); + Sleep(testTime); + CHECK(StopMedia(0)); + ANL(); + + base->DeleteChannel(0); + base->DeleteChannel(1); + + // SetChannelOutputVolumePan + // + // Ensure that all cases sound OK and that the mixer changes state between + // mono and stereo as it should. A debugger is required to trace the state + // transitions. + + base->CreateChannel(); + base->CreateChannel(); + + Test(">> Verify correct mixing in stereo using" + " SetChannelOutputVolumePan():\n"); + + Test("(ch 0) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); + CHECK(StartMedia(0, 12345, false, true, false, false, true)); + Sleep(testTime); + Test("(ch 0) Panning channel volume to the left <=> mixing in stereo @ " + "16kHz..."); + CHECK(volume->SetOutputVolumePan(0, 1.0, 0.0)); + Sleep(testTime); + Test("(ch 0) Panning channel volume to the right <=> mixing in stereo" + " @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(0, 0.0, 1.0)); + Sleep(testTime); + Test("(ch 0) Back to center volume again <=> mixing in mono @" + " 16kHz..."); + CHECK(volume->SetOutputVolumePan(0, 1.0, 1.0)); + Sleep(testTime); + Test("(ch 1) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); + CHECK(StartMedia(1, 54321, false, true, false, false, true)); + Sleep(testTime); + Test("(ch 1) Panning channel volume to the left <=> mixing in stereo " + "@ 16kHz..."); + CHECK(volume->SetOutputVolumePan(1, 1.0, 0.0)); + Sleep(testTime); + Test("(ch 1) Back to center volume again <=> mixing in mono @ 16kHz..."); + CHECK(volume->SetOutputVolumePan(1, 1.0, 1.0)); + Sleep(testTime); + Test("(ch 1) Stopped playing file <=> mixing in mono @ 16kHz..."); + CHECK(StopMedia(1)); + Sleep(testTime); + CHECK(StopMedia(0)); + ANL(); + + base->DeleteChannel(0); + base->DeleteChannel(1); + + // Emulate stereo-encoding using Encryption + // + // Modify the transmitted RTP stream by using external encryption. + // Supports frame based and sample based "stereo-encoding schemes". + + base->CreateChannel(); + + Test(">> Verify correct mixing in stereo using emulated stereo input:\n"); + + // enable external encryption + CHECK(encrypt->RegisterExternalEncryption(0, *this)); + Test("(ch 0) External Encryption is now enabled:"); + + Test("(ch 0) Sending file at 8kHz <=> mixing in mono @ 8kHz..."); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + + // switch to 16kHz (L16) sending codec + CHECK(codec->SetSendCodec(0, l16_16)); + Test("(ch 0) Sending file at 16kHz (L16) <=> mixing in mono @ 16kHz..."); + Sleep(testTime); + + // register L16 as 2-channel codec on receiving side => + // should sound bad since RTP module splits all received packets in half + // (sample based) + CHECK(base->StopPlayout(0)); + CHECK(base->StopReceive(0)); + l16_16.channels = 2; + CHECK(codec->SetRecPayloadType(0, l16_16)); + CHECK(base->StartReceive(0)); + CHECK(base->StartPlayout(0)); + Test("(ch 0) 16kHz L16 is now registered as 2-channel codec on RX side => " + "should sound bad..."); + Sleep(testTime); + + // emulate sample-based stereo encoding + Test("(ch 0) Emulate sample-based stereo encoding on sending side => " + "should sound OK..."); + SetStereoExternalEncryption(0, true, 16); + Sleep(testTime); + Test("(ch 0) Stop emulating sample-based stereo encoding on sending side =>" + " should sound bad..."); + SetStereoExternalEncryption(0, false, 16); + Sleep(testTime); + Test("(ch 0) Emulate sample-based stereo encoding on sending side => " + "should sound OK..."); + SetStereoExternalEncryption(0, true, 16); + Sleep(testTime); + + // switch to 32kHz (L16) sending codec and disable stereo encoding + CHECK(codec->SetSendCodec(0, l16_32)); + SetStereoExternalEncryption(0, false, 16); + Test("(ch 0) Sending file and spech at 32kHz (L16) <=> mixing in mono @ " + "32kHz..."); + Sleep(testTime); + + // register L16 32kHz as 2-channel codec on receiving side + CHECK(base->StopPlayout(0)); + CHECK(base->StopReceive(0)); + l16_32.channels = 2; + CHECK(codec->SetRecPayloadType(0, l16_32)); + CHECK(base->StartReceive(0)); + CHECK(base->StartPlayout(0)); + Test("(ch 0) 32kHz L16 is now registered as 2-channel codec on RX side =>" + " should sound bad..."); + Sleep(testTime); + + // emulate sample-based stereo encoding + Test("(ch 0) Emulate sample-based stereo encoding on sending side =>" + " should sound OK..."); + SetStereoExternalEncryption(0, true, 16); + Sleep(testTime); + + StopMedia(0); + l16_32.channels = 1; + + // disable external encryption + CHECK(encrypt->DeRegisterExternalEncryption(0)); + ANL(); + + base->DeleteChannel(0); + + // ------------------ + // Verify put-on-hold + // ------------------ + + base->CreateChannel(); + base->CreateChannel(); + + Test(">> Verify put-on-hold functionality:\n"); + + Test("(ch 0) Sending at 8kHz..."); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + + CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); + Test("(ch 0) Playout is now on hold..."); + Sleep(testTime); + CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); + Test("(ch 0) Playout is now enabled again..."); + Sleep(testTime); + + Test("(ch 0) Sending at 16kHz..."); + l16_16.channels = 1; + CHECK(codec->SetSendCodec(0, l16_16)); + Sleep(testTime); + + CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); + Test("(ch 0) Playout is now on hold..."); + Sleep(testTime); + CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); + Test("(ch 0) Playout is now enabled again..."); + Sleep(testTime); + + Test("(ch 0) Perform minor panning to the left to force mixing in" + " stereo..."); + CHECK(volume->SetOutputVolumePan(0, (float)1.0, (float)0.7)); + Sleep(testTime); + + CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); + Test("(ch 0) Playout is now on hold..."); + Sleep(testTime); + CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); + Test("(ch 0) Playout is now enabled again..."); + Sleep(testTime); + + Test("(ch 0) Back to center volume again..."); + CHECK(volume->SetOutputVolumePan(0, 1.0, 1.0)); + Sleep(testTime); + + Test("(ch 1) Add 16kHz local file to the mixer..."); + CHECK(StartMedia(1, 54321, false, true, false, false, true)); + Sleep(testTime); + + CHECK(base->SetOnHoldStatus(0, true, kHoldPlayOnly)); + Test("(ch 0) Playout is now on hold..."); + Sleep(testTime); + CHECK(base->SetOnHoldStatus(1, true, kHoldPlayOnly)); + Test("(ch 1) Playout is now on hold => should be silent..."); + Sleep(testTime); + CHECK(base->SetOnHoldStatus(0, false, kHoldPlayOnly)); + Test("(ch 0) Playout is now enabled again..."); + CHECK(base->SetOnHoldStatus(1, false, kHoldPlayOnly)); + Test("(ch 1) Playout is now enabled again..."); + Sleep(testTime); + StopMedia(1); + Test("(ch 1) Stopped playing file..."); + Sleep(testTime); + StopMedia(0); + ANL(); + + base->DeleteChannel(0); + base->DeleteChannel(1); + + // ----------------------------------- + // Verify recording of playout to file + // ----------------------------------- + + // StartRecordingPlayout + // + // Verify that the correct set of signals is recorded in the mixer. + // Record each channel and all channels (-1) to ensure that post and pre + // mixing recording works. + + base->CreateChannel(); + base->CreateChannel(); + + Test(">> Verify file-recording functionality:\n"); + + Test("(ch 0) Sending at 8kHz..."); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + + Test("(ch 0) Recording of playout to 16kHz PCM file..."); + CHECK(file->StartRecordingPlayout( + 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); + Sleep(testTime); + CHECK(file->StopRecordingPlayout(0)); + + Test("(ch 0) Playing out the recorded file..."); + CHECK(volume->SetInputMute(0, true)); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + CHECK(volume->SetInputMute(0, false)); + + CHECK(codec->SetSendCodec(0, l16_16)); + Test("(ch 0) Sending at 16kHz (L16)..."); + Sleep(testTime); + + Test("(ch 0) Recording of playout to 16kHz PCM file..."); + CHECK(file->StartRecordingPlayout( + 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); + Sleep(testTime); + CHECK(file->StopRecordingPlayout(0)); + + Test("(ch 0) Playing out the recorded file..."); + CHECK(volume->SetInputMute(0, true)); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + CHECK(volume->SetInputMute(0, false)); + + CHECK(codec->SetSendCodec(0, l16_32)); + Test("(ch 0) Sending at 32kHz (L16)..."); + Sleep(testTime); + + Test("(ch 0) Recording of playout to 16kHz PCM file..."); + CHECK(file->StartRecordingPlayout( + 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); + Sleep(testTime); + CHECK(file->StopRecordingPlayout(0)); + + Test("(ch 0) Playing out the recorded file..."); + CHECK(volume->SetInputMute(0, true)); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + CHECK(volume->SetInputMute(0, false)); + + Test("(ch 0) Sending at 16kHz without file as mic but file added on the" + " playout side instead..."); + CHECK(StopMedia(0)); + CHECK(StartMedia(0, 12345, false, true, false, false, true)); + CHECK(codec->SetSendCodec(0, l16_16)); + Sleep(testTime); + + Test("(ch 0) Recording of playout to 16kHz PCM file..."); + CHECK(file->StartRecordingPlayout( + 0, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); + Sleep(testTime); + CHECK(file->StopRecordingPlayout(0)); + CHECK(file->StopPlayingFileLocally(0)); + + Test("(ch 0) Playing out the recorded file..."); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + + CHECK(StopMedia(0)); + CHECK(StopMedia(1)); + + Test("(ch 0) Sending at 16kHz..."); + CHECK(StartMedia(0, 12345, true, true, true, false, false)); + CHECK(codec->SetSendCodec(0, l16_16)); + Test("(ch 1) Adding playout file..."); + CHECK(StartMedia(1, 33333, false, true, false, false, true)); + Sleep(testTime); + + Test("(ch -1) Speak while recording all channels to add mixer input on " + "channel 0..."); + CHECK(file->StartRecordingPlayout( + -1, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); + Sleep(testTime); + CHECK(file->StopRecordingPlayout(-1)); + CHECK(file->StopPlayingFileLocally(1)); + + Test("(ch 0) Playing out the recorded file..."); + CHECK(volume->SetInputMute(0, true)); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + CHECK(volume->SetInputMute(0, false)); + + CHECK(StopMedia(0)); + CHECK(StopMedia(1)); + ANL(); + + // StartRecordingPlayoutStereo + + Test(">> Verify recording of playout in stereo:\n"); + + Test("(ch 0) Sending at 32kHz..."); + CHECK(codec->SetSendCodec(0, l16_16)); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + + Test("Modified master balance (L=10%%, R=100%%) to force stereo mixing..."); + CHECK(volume->SetOutputVolumePan(-1, (float)0.1, (float)1.0)); + Sleep(testTime); + + /* + Test("Recording of left and right channel playout to two 16kHz PCM " + "files..."); + file->StartRecordingPlayoutStereo( + GetFilename("RecordedPlayout_Left_16kHz.pcm"), + GetFilename("RecordedPlayout_Right_16kHz.pcm"), StereoBoth); + Sleep(testTime); + Test("Back to center volume again..."); + CHECK(volume->SetOutputVolumePan(-1, (float)1.0, (float)1.0)); + */ + + Test("(ch 0) Playing out the recorded file for the left channel (10%%)..."); + CHECK(volume->SetInputMute(0, true)); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout_Left_16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + + Test("(ch 0) Playing out the recorded file for the right channel (100%%) =>" + " should sound louder than the left channel..."); + CHECK(file->StartPlayingFileLocally( + 0, GetFilename("RecordedPlayout_Right_16kHz.pcm"))); + Sleep(testTime); + CHECK(file->StopPlayingFileLocally(0)); + CHECK(volume->SetInputMute(0, false)); + + base->DeleteChannel(0); + base->DeleteChannel(1); + ANL(); + + // --------------------------- + // Verify inserted Dtmf tones + // --------------------------- + + Test(">> Verify Dtmf feedback functionality:\n"); + + base->CreateChannel(); + + for (int i = 0; i < 2; i++) { + if (i == 0) + Test("Dtmf direct feedback is now enabled..."); + else + Test("Dtmf direct feedback is now disabled..."); + + CHECK(dtmf->SetDtmfFeedbackStatus(true, (i==0))); + + Test("(ch 0) Sending at 32kHz using G.722.1C..."); + CHECK(codec->SetRecPayloadType(0, g722_1c_32)); + CHECK(codec->SetSendCodec(0, g722_1c_32)); CHECK(StartMedia(0, 12345, true, true, true, false, false)); + Sleep(500); + + Test("(ch 0) Sending outband Dtmf events => ensure that they are added" + " to the mixer..."); + // ensure that receiver will not play out outband Dtmf + CHECK(dtmf->SetSendTelephoneEventPayloadType(0, 118)); + CHECK(dtmf->SendTelephoneEvent(0, 9, true, 390)); + Sleep(500); + CHECK(dtmf->SendTelephoneEvent(0, 1, true, 390)); + Sleep(500); + CHECK(dtmf->SendTelephoneEvent(0, 5, true, 390)); + Sleep(500); + Sleep(testTime - 1500); + + Test("(ch 0) Changing codec to 8kHz PCMU..."); + CHECK(codec->SetSendCodec(0, pcmu_8)); + Sleep(500); + + Test("(ch 0) Sending outband Dtmf events => ensure that they are added" + " to the mixer..."); + CHECK(dtmf->SendTelephoneEvent(0, 9, true, 390)); + Sleep(500); + CHECK(dtmf->SendTelephoneEvent(0, 1, true, 390)); + Sleep(500); + CHECK(dtmf->SendTelephoneEvent(0, 5, true, 390)); + Sleep(500); + Sleep(testTime - 1500); + + Test("(ch 0) Changing codec to 16kHz L16..."); CHECK(codec->SetSendCodec(0, l16_16)); - Test("(ch 1) Adding playout file..."); - CHECK(StartMedia(1, 33333, false, true, false, false, true)); - Sleep(testTime); + Sleep(500); - Test("(ch -1) Speak while recording all channels to add mixer input on " - "channel 0..."); - CHECK(file->StartRecordingPlayout( - -1, GetFilename("RecordedPlayout16kHz.pcm"), NULL)); - Sleep(testTime); - CHECK(file->StopRecordingPlayout(-1)); - CHECK(file->StopPlayingFileLocally(1)); - - Test("(ch 0) Playing out the recorded file..."); - CHECK(volume->SetInputMute(0, true)); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - CHECK(volume->SetInputMute(0, false)); - - CHECK(StopMedia(0)); - CHECK(StopMedia(1)); - ANL(); - - // StartRecordingPlayoutStereo - - Test(">> Verify recording of playout in stereo:\n"); - - Test("(ch 0) Sending at 32kHz..."); - CHECK(codec->SetSendCodec(0, l16_16)); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - - Test("Modified master balance (L=10%%, R=100%%) to force stereo mixing..."); - CHECK(volume->SetOutputVolumePan(-1, (float)0.1, (float)1.0)); - Sleep(testTime); - - /* - Test("Recording of left and right channel playout to two 16kHz PCM " - "files..."); - file->StartRecordingPlayoutStereo( - GetFilename("RecordedPlayout_Left_16kHz.pcm"), - GetFilename("RecordedPlayout_Right_16kHz.pcm"), StereoBoth); - Sleep(testTime); - Test("Back to center volume again..."); - CHECK(volume->SetOutputVolumePan(-1, (float)1.0, (float)1.0)); - */ - - Test("(ch 0) Playing out the recorded file for the left channel (10%%)..."); - CHECK(volume->SetInputMute(0, true)); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout_Left_16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - - Test("(ch 0) Playing out the recorded file for the right channel (100%%) =>" - " should sound louder than the left channel..."); - CHECK(file->StartPlayingFileLocally( - 0, GetFilename("RecordedPlayout_Right_16kHz.pcm"))); - Sleep(testTime); - CHECK(file->StopPlayingFileLocally(0)); - CHECK(volume->SetInputMute(0, false)); - - base->DeleteChannel(0); - base->DeleteChannel(1); - ANL(); - - // --------------------------- - // Verify inserted Dtmf tones - // --------------------------- - - Test(">> Verify Dtmf feedback functionality:\n"); - - base->CreateChannel(); - - for (int i = 0; i < 2; i++) - { - if (i == 0) - Test("Dtmf direct feedback is now enabled..."); - else - Test("Dtmf direct feedback is now disabled..."); - - CHECK(dtmf->SetDtmfFeedbackStatus(true, (i==0))); - - Test("(ch 0) Sending at 32kHz using G.722.1C..."); - CHECK(codec->SetRecPayloadType(0, g722_1c_32)); - CHECK(codec->SetSendCodec(0, g722_1c_32)); - CHECK(StartMedia(0, 12345, true, true, true, false, false)); - Sleep(500); - - Test("(ch 0) Sending outband Dtmf events => ensure that they are added" - " to the mixer..."); - // ensure that receiver will not play out outband Dtmf - CHECK(dtmf->SetSendTelephoneEventPayloadType(0, 118)); - CHECK(dtmf->SendTelephoneEvent(0, 9, true, 390)); - Sleep(500); - CHECK(dtmf->SendTelephoneEvent(0, 1, true, 390)); - Sleep(500); - CHECK(dtmf->SendTelephoneEvent(0, 5, true, 390)); - Sleep(500); - Sleep(testTime - 1500); - - Test("(ch 0) Changing codec to 8kHz PCMU..."); - CHECK(codec->SetSendCodec(0, pcmu_8)); - Sleep(500); - - Test("(ch 0) Sending outband Dtmf events => ensure that they are added" - " to the mixer..."); - CHECK(dtmf->SendTelephoneEvent(0, 9, true, 390)); - Sleep(500); - CHECK(dtmf->SendTelephoneEvent(0, 1, true, 390)); - Sleep(500); - CHECK(dtmf->SendTelephoneEvent(0, 5, true, 390)); - Sleep(500); - Sleep(testTime - 1500); - - Test("(ch 0) Changing codec to 16kHz L16..."); - CHECK(codec->SetSendCodec(0, l16_16)); - Sleep(500); - - Test("(ch 0) Sending outband Dtmf events => ensure that they are added" - " to the mixer..."); - CHECK(dtmf->SendTelephoneEvent(0, 9, true, 390)); - Sleep(500); - CHECK(dtmf->SendTelephoneEvent(0, 1, true, 390)); - Sleep(500); - CHECK(dtmf->SendTelephoneEvent(0, 5, true, 390)); - Sleep(500); - Sleep(testTime - 1500); - - StopMedia(0); - ANL(); - } - - base->DeleteChannel(0); - - // --------------------------- - // Verify external processing - // -------------------------- - - base->CreateChannel(); - - Test(">> Verify external media processing:\n"); - - Test("(ch 0) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); - CHECK(StartMedia(0, 12345, false, true, false, false, true)); - Sleep(testTime); - Test("Enabling playout external media processing => played audio should " - "now be affected"); - CHECK(xmedia->RegisterExternalMediaProcessing( - 0, kPlaybackAllChannelsMixed, mpobj)); - Sleep(testTime); - Test("(ch 0) Sending speech at 32kHz <=> mixing at 32kHz..."); - CHECK(codec->SetSendCodec(0, l16_32)); - Sleep(testTime); - printf("Back to normal again\n"); - CHECK(xmedia->DeRegisterExternalMediaProcessing(0, - kPlaybackAllChannelsMixed)); - Sleep(testTime); - printf("Enabling playout external media processing on ch 0 => " - "played audio should now be affected\n"); - CHECK(xmedia->RegisterExternalMediaProcessing(0, kPlaybackPerChannel, - mpobj)); - Sleep(testTime); - Test("Panning volume to the right <=> mixing in stereo @ 32kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 0.0, 1.0)); - Sleep(testTime); - Test("Back to center volume again <=> mixing in mono @ 32kHz..."); - CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); - Sleep(testTime); - printf("Back to normal again\n"); - CHECK(xmedia->DeRegisterExternalMediaProcessing(0, kPlaybackPerChannel)); - Sleep(testTime); - CHECK(StopMedia(0)); - ANL(); - - base->DeleteChannel(0); - - // -------------------------------------------------- - // Extended tests of emulated stereo encoding schemes - // -------------------------------------------------- - - CodecInst PCMU; - CodecInst G729; - CodecInst L16_8; - CodecInst L16_16; - CodecInst L16_32; - - base->CreateChannel(); - - Test(">> Verify emulated stereo encoding for differenct codecs:\n"); - - // enable external encryption - CHECK(encrypt->RegisterExternalEncryption(0, *this)); - Test("(ch 0) External Encryption is now enabled:"); - - // register all codecs on the receiving side - strcpy(PCMU.plname, "PCMU"); - PCMU.channels = 2; - PCMU.pacsize = 160; - PCMU.plfreq = 8000; - PCMU.pltype = 125; - PCMU.rate = 64000; - CHECK(codec->SetRecPayloadType(0, PCMU)); - - strcpy(G729.plname, "G729"); - G729.channels = 2; - G729.pacsize = 160; - G729.plfreq = 8000; - G729.pltype = 18; - G729.rate = 8000; - CHECK(codec->SetRecPayloadType(0, G729)); - - strcpy(L16_8.plname, "L16"); - L16_8.channels = 2; - L16_8.pacsize = 160; - L16_8.plfreq = 8000; - L16_8.pltype = 120; - L16_8.rate = 128000; - CHECK(codec->SetRecPayloadType(0, L16_8)); - - strcpy(L16_16.plname, "L16"); - L16_16.channels = 2; - L16_16.pacsize = 320; - L16_16.plfreq = 16000; - L16_16.pltype = 121; - L16_16.rate = 256000; - CHECK(codec->SetRecPayloadType(0, L16_16)); - - // NOTE - we cannot send larger than 1500 bytes per RTP packet - strcpy(L16_32.plname, "L16"); - L16_32.channels = 2; - L16_32.pacsize = 320; - L16_32.plfreq = 32000; - L16_32.pltype = 122; - L16_32.rate = 512000; - CHECK(codec->SetRecPayloadType(0, L16_32)); - - // sample-based, 8-bits per sample - - Test("(ch 0) Sending using G.711 (sample based, 8 bits/sample)..."); - PCMU.channels = 1; - CHECK(codec->SetSendCodec(0, PCMU)); - SetStereoExternalEncryption(0, true, 8); - CHECK(StartMedia(0, 12345, true, true, true, true, false)); - Sleep(testTime); - - // sample-based, 16-bits per sample - - Test("(ch 0) Sending using L16 8kHz (sample based, 16 bits/sample)..."); - L16_8.channels = 1; - CHECK(codec->SetSendCodec(0, L16_8)); - SetStereoExternalEncryption(0, true, 16); - Sleep(testTime); - - Test("(ch 0) Sending using L16 16kHz (sample based, 16 bits/sample)..."); - L16_16.channels = 1; - CHECK(codec->SetSendCodec(0, L16_16)); - Sleep(testTime); - - Test("(ch 0) Sending using L16 32kHz (sample based, 16 bits/sample)..."); - L16_32.channels = 1; - CHECK(codec->SetSendCodec(0, L16_32)); - Sleep(testTime); - - Test("(ch 0) Sending using G.729 (frame based)..."); - G729.channels = 1; - CHECK(codec->SetSendCodec(0, G729)); - Sleep(testTime); + Test("(ch 0) Sending outband Dtmf events => ensure that they are added" + " to the mixer..."); + CHECK(dtmf->SendTelephoneEvent(0, 9, true, 390)); + Sleep(500); + CHECK(dtmf->SendTelephoneEvent(0, 1, true, 390)); + Sleep(500); + CHECK(dtmf->SendTelephoneEvent(0, 5, true, 390)); + Sleep(500); + Sleep(testTime - 1500); StopMedia(0); + ANL(); + } - // disable external encryption - CHECK(encrypt->DeRegisterExternalEncryption(0)); + base->DeleteChannel(0); - base->DeleteChannel(0); + // --------------------------- + // Verify external processing + // -------------------------- - // ------------------------------------------------------------------------ + base->CreateChannel(); - CHECK(base->Terminate()); + Test(">> Verify external media processing:\n"); - printf("\n\n------------------------------------------------\n"); - printf(" Test passed!\n"); - printf("------------------------------------------------\n\n"); + Test("(ch 0) Playing 16kHz file locally <=> mixing in mono @ 16kHz..."); + CHECK(StartMedia(0, 12345, false, true, false, false, true)); + Sleep(testTime); + Test("Enabling playout external media processing => played audio should " + "now be affected"); + CHECK(xmedia->RegisterExternalMediaProcessing( + 0, kPlaybackAllChannelsMixed, mpobj)); + Sleep(testTime); + Test("(ch 0) Sending speech at 32kHz <=> mixing at 32kHz..."); + CHECK(codec->SetSendCodec(0, l16_32)); + Sleep(testTime); + printf("Back to normal again\n"); + CHECK(xmedia->DeRegisterExternalMediaProcessing(0, + kPlaybackAllChannelsMixed)); + Sleep(testTime); + printf("Enabling playout external media processing on ch 0 => " + "played audio should now be affected\n"); + CHECK(xmedia->RegisterExternalMediaProcessing(0, kPlaybackPerChannel, + mpobj)); + Sleep(testTime); + Test("Panning volume to the right <=> mixing in stereo @ 32kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 0.0, 1.0)); + Sleep(testTime); + Test("Back to center volume again <=> mixing in mono @ 32kHz..."); + CHECK(volume->SetOutputVolumePan(-1, 1.0, 1.0)); + Sleep(testTime); + printf("Back to normal again\n"); + CHECK(xmedia->DeRegisterExternalMediaProcessing(0, kPlaybackPerChannel)); + Sleep(testTime); + CHECK(StopMedia(0)); + ANL(); - return 0; + base->DeleteChannel(0); + + // -------------------------------------------------- + // Extended tests of emulated stereo encoding schemes + // -------------------------------------------------- + + CodecInst PCMU; + CodecInst G729; + CodecInst L16_8; + CodecInst L16_16; + CodecInst L16_32; + + base->CreateChannel(); + + Test(">> Verify emulated stereo encoding for differenct codecs:\n"); + + // enable external encryption + CHECK(encrypt->RegisterExternalEncryption(0, *this)); + Test("(ch 0) External Encryption is now enabled:"); + + // register all codecs on the receiving side + strcpy(PCMU.plname, "PCMU"); + PCMU.channels = 2; + PCMU.pacsize = 160; + PCMU.plfreq = 8000; + PCMU.pltype = 125; + PCMU.rate = 64000; + CHECK(codec->SetRecPayloadType(0, PCMU)); + + strcpy(G729.plname, "G729"); + G729.channels = 2; + G729.pacsize = 160; + G729.plfreq = 8000; + G729.pltype = 18; + G729.rate = 8000; + CHECK(codec->SetRecPayloadType(0, G729)); + + strcpy(L16_8.plname, "L16"); + L16_8.channels = 2; + L16_8.pacsize = 160; + L16_8.plfreq = 8000; + L16_8.pltype = 120; + L16_8.rate = 128000; + CHECK(codec->SetRecPayloadType(0, L16_8)); + + strcpy(L16_16.plname, "L16"); + L16_16.channels = 2; + L16_16.pacsize = 320; + L16_16.plfreq = 16000; + L16_16.pltype = 121; + L16_16.rate = 256000; + CHECK(codec->SetRecPayloadType(0, L16_16)); + + // NOTE - we cannot send larger than 1500 bytes per RTP packet + strcpy(L16_32.plname, "L16"); + L16_32.channels = 2; + L16_32.pacsize = 320; + L16_32.plfreq = 32000; + L16_32.pltype = 122; + L16_32.rate = 512000; + CHECK(codec->SetRecPayloadType(0, L16_32)); + + // sample-based, 8-bits per sample + + Test("(ch 0) Sending using G.711 (sample based, 8 bits/sample)..."); + PCMU.channels = 1; + CHECK(codec->SetSendCodec(0, PCMU)); + SetStereoExternalEncryption(0, true, 8); + CHECK(StartMedia(0, 12345, true, true, true, true, false)); + Sleep(testTime); + + // sample-based, 16-bits per sample + + Test("(ch 0) Sending using L16 8kHz (sample based, 16 bits/sample)..."); + L16_8.channels = 1; + CHECK(codec->SetSendCodec(0, L16_8)); + SetStereoExternalEncryption(0, true, 16); + Sleep(testTime); + + Test("(ch 0) Sending using L16 16kHz (sample based, 16 bits/sample)..."); + L16_16.channels = 1; + CHECK(codec->SetSendCodec(0, L16_16)); + Sleep(testTime); + + Test("(ch 0) Sending using L16 32kHz (sample based, 16 bits/sample)..."); + L16_32.channels = 1; + CHECK(codec->SetSendCodec(0, L16_32)); + Sleep(testTime); + + Test("(ch 0) Sending using G.729 (frame based)..."); + G729.channels = 1; + CHECK(codec->SetSendCodec(0, G729)); + Sleep(testTime); + + StopMedia(0); + + // disable external encryption + CHECK(encrypt->DeRegisterExternalEncryption(0)); + + base->DeleteChannel(0); + + // ------------------------------------------------------------------------ + CHECK(base->Terminate()); + + printf("\n\n------------------------------------------------\n"); + printf(" Test passed!\n"); + printf("------------------------------------------------\n\n"); + + return 0; } -} // namespace voetest +} // namespace voetest diff --git a/src/voice_engine/main/test/auto_test/voe_unit_test.h b/src/voice_engine/main/test/auto_test/voe_unit_test.h index 979a3f693b..ce532415d6 100644 --- a/src/voice_engine/main/test/auto_test/voe_unit_test.h +++ b/src/voice_engine/main/test/auto_test/voe_unit_test.h @@ -17,51 +17,53 @@ namespace voetest { class VoETestManager; -class VoEUnitTest : public Encryption -{ -public: - VoEUnitTest(VoETestManager& mgr); - ~VoEUnitTest() {}; - int DoTest(); +class VoEUnitTest : public Encryption { + public: + VoEUnitTest(VoETestManager& mgr); + ~VoEUnitTest() {} + int DoTest(); -protected: - // Encryption - void encrypt(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); - void decrypt(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); - void encrypt_rtcp(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); - void decrypt_rtcp(int channel_no, unsigned char * in_data, - unsigned char * out_data, int bytes_in, int * bytes_out); + protected: + // Encryption + void encrypt(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); + void decrypt(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); + void encrypt_rtcp(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); + void decrypt_rtcp(int channel_no, unsigned char * in_data, + unsigned char * out_data, int bytes_in, int * bytes_out); -private: - int MenuSelection(); - int MixerTest(); - void Sleep(unsigned int timeMillisec, bool addMarker = false); - void Wait(); - int StartMedia(int channel, int rtpPort, bool listen, bool playout, - bool send, bool fileAsMic, bool localFile); - int StopMedia(int channel); - void Test(const char* msg); - void SetStereoExternalEncryption(int channel, - bool onOff, - int bitsPerSample); + private: + int MenuSelection(); + int MixerTest(); + void Sleep(unsigned int timeMillisec, bool addMarker = false); + void Wait(); + int StartMedia(int channel, + int rtpPort, + bool listen, + bool playout, + bool send, + bool fileAsMic, + bool localFile); + int StopMedia(int channel); + void Test(const char* msg); + void SetStereoExternalEncryption(int channel, bool onOff, int bitsPerSample); -private: - VoETestManager& _mgr; - static const char* _key; + private: + VoETestManager& _mgr; + static const char* _key; -private: - bool _listening[32]; - bool _playing[32]; - bool _sending[32]; + private: + bool _listening[32]; + bool _playing[32]; + bool _sending[32]; -private: - bool _extOnOff; - int _extBitsPerSample; - int _extChannel; + private: + bool _extOnOff; + int _extBitsPerSample; + int _extChannel; }; -} // namespace voetest +} // namespace voetest #endif // WEBRTC_VOICE_ENGINE_VOE_UNIT_TEST_H