diff --git a/src/voice_engine/main/test/auto_test/standard/codec_test.cc b/src/voice_engine/main/test/auto_test/standard/codec_test.cc new file mode 100644 index 0000000000..4191ef316a --- /dev/null +++ b/src/voice_engine/main/test/auto_test/standard/codec_test.cc @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "after_streaming_fixture.h" +#include "voice_engine_defines.h" + +class CodecTest : public AfterStreamingFixture { + protected: + void SetUp() { + memset(&codec_instance_, 0, sizeof(codec_instance_)); + } + + void SetArbitrarySendCodec() { + // Just grab the first codec. + EXPECT_EQ(0, voe_codec_->GetCodec(0, codec_instance_)); + EXPECT_EQ(0, voe_codec_->SetSendCodec(channel_, codec_instance_)); + } + + webrtc::CodecInst codec_instance_; +}; + +static void SetRateIfILBC(webrtc::CodecInst* codec_instance, int packet_size) { + if (!_stricmp(codec_instance->plname, "ilbc")) { + if (packet_size == 160 || packet_size == 320) { + codec_instance->rate = 15200; + } else { + codec_instance->rate = 13300; + } + } +} + +static bool IsNotViableSendCodec(const char* codec_name) { + return !_stricmp(codec_name, "CN") || + !_stricmp(codec_name, "telephone-event") || + !_stricmp(codec_name, "red"); +} + +TEST_F(CodecTest, PcmuIsDefaultCodecAndHasTheRightValues) { + EXPECT_EQ(0, voe_codec_->GetSendCodec(channel_, codec_instance_)); + EXPECT_EQ(1, codec_instance_.channels); + EXPECT_EQ(160, codec_instance_.pacsize); + EXPECT_EQ(8000, codec_instance_.plfreq); + EXPECT_EQ(0, codec_instance_.pltype); + EXPECT_EQ(64000, codec_instance_.rate); + EXPECT_STRCASEEQ("PCMU", codec_instance_.plname); +} + +TEST_F(CodecTest, VoiceActivityDetectionIsOffByDefault) { + bool vad_enabled = false; + bool dtx_disabled = false; + webrtc::VadModes vad_mode = webrtc::kVadAggressiveMid; + + voe_codec_->GetVADStatus(channel_, vad_enabled, vad_mode, dtx_disabled); + + EXPECT_FALSE(vad_enabled); + EXPECT_TRUE(dtx_disabled); + EXPECT_EQ(webrtc::kVadConventional, vad_mode); +} + +TEST_F(CodecTest, VoiceActivityDetectionCanBeEnabled) { + EXPECT_EQ(0, voe_codec_->SetVADStatus(channel_, true)); + + bool vad_enabled = false; + bool dtx_disabled = false; + webrtc::VadModes vad_mode = webrtc::kVadAggressiveMid; + + voe_codec_->GetVADStatus(channel_, vad_enabled, vad_mode, dtx_disabled); + + EXPECT_TRUE(vad_enabled); + EXPECT_EQ(webrtc::kVadConventional, vad_mode); + EXPECT_FALSE(dtx_disabled); +} + +TEST_F(CodecTest, VoiceActivityDetectionTypeSettingsCanBeChanged) { + bool vad_enabled = false; + bool dtx_disabled = false; + webrtc::VadModes vad_mode = webrtc::kVadAggressiveMid; + + EXPECT_EQ(0, voe_codec_->SetVADStatus( + channel_, true, webrtc::kVadAggressiveLow, false)); + EXPECT_EQ(0, voe_codec_->GetVADStatus( + channel_, vad_enabled, vad_mode, dtx_disabled)); + EXPECT_EQ(vad_mode, webrtc::kVadAggressiveLow); + EXPECT_FALSE(dtx_disabled); + + EXPECT_EQ(0, voe_codec_->SetVADStatus( + channel_, true, webrtc::kVadAggressiveMid, false)); + EXPECT_EQ(0, voe_codec_->GetVADStatus( + channel_, vad_enabled, vad_mode, dtx_disabled)); + EXPECT_EQ(vad_mode, webrtc::kVadAggressiveMid); + EXPECT_FALSE(dtx_disabled); + + // The fourth argument is the DTX disable flag. + EXPECT_EQ(0, voe_codec_->SetVADStatus( + channel_, true, webrtc::kVadAggressiveHigh, true)); + EXPECT_EQ(0, voe_codec_->GetVADStatus( + channel_, vad_enabled, vad_mode, dtx_disabled)); + EXPECT_EQ(vad_mode, webrtc::kVadAggressiveHigh); + EXPECT_TRUE(dtx_disabled); + + EXPECT_EQ(0, voe_codec_->SetVADStatus( + channel_, true, webrtc::kVadConventional, true)); + EXPECT_EQ(0, voe_codec_->GetVADStatus( + channel_, vad_enabled, vad_mode, dtx_disabled)); + EXPECT_EQ(vad_mode, webrtc::kVadConventional); +} + +TEST_F(CodecTest, VoiceActivityDetectionCanBeTurnedOff) { + EXPECT_EQ(0, voe_codec_->SetVADStatus(channel_, true)); + + // VAD is always on when DTX is on, so we need to turn off DTX too. + EXPECT_EQ(0, voe_codec_->SetVADStatus( + channel_, false, webrtc::kVadConventional, true)); + + bool vad_enabled = false; + bool dtx_disabled = false; + webrtc::VadModes vad_mode = webrtc::kVadAggressiveMid; + + voe_codec_->GetVADStatus(channel_, vad_enabled, vad_mode, dtx_disabled); + + EXPECT_FALSE(vad_enabled); + EXPECT_TRUE(dtx_disabled); + EXPECT_EQ(webrtc::kVadConventional, vad_mode); +} + +// Tests requiring manual verification (although they do have some value +// without the manual verification): +TEST_F(CodecTest, ManualExtendedISACApisBehaveAsExpected) { + strcpy(codec_instance_.plname, "isac"); + codec_instance_.pltype = 103; + codec_instance_.plfreq = 16000; + codec_instance_.channels = 1; + // -1 here means "adaptive rate". + codec_instance_.rate = -1; + codec_instance_.pacsize = 480; + + EXPECT_EQ(0, voe_codec_->SetSendCodec(channel_, codec_instance_)); + + EXPECT_NE(0, voe_codec_->SetISACInitTargetRate(channel_, 5000)) << + "iSAC should reject rate 5000."; + EXPECT_NE(0, voe_codec_->SetISACInitTargetRate(channel_, 33000)) << + "iSAC should reject rate 33000."; + EXPECT_EQ(0, voe_codec_->SetISACInitTargetRate(channel_, 32000)); + + TEST_LOG("Ensure that the sound is good (iSAC, target = 32kbps)...\n"); + Sleep(3000); + + EXPECT_EQ(0, voe_codec_->SetISACInitTargetRate(channel_, 10000)); + TEST_LOG("Ensure that the sound is good (iSAC, target = 10kbps)...\n"); + Sleep(3000); + + EXPECT_EQ(0, voe_codec_->SetISACInitTargetRate(channel_, 10000, true)); + EXPECT_EQ(0, voe_codec_->SetISACInitTargetRate(channel_, 10000, false)); + EXPECT_EQ(0, voe_codec_->SetISACInitTargetRate(channel_, 0)); + TEST_LOG("Ensure that the sound is good (iSAC, target = default)...\n"); + Sleep(3000); + + TEST_LOG(" Testing SetISACMaxPayloadSize:\n"); + EXPECT_EQ(0, voe_base_->StopSend(channel_)); + EXPECT_NE(0, voe_codec_->SetISACMaxPayloadSize(channel_, 50)); + EXPECT_NE(0, voe_codec_->SetISACMaxPayloadSize(channel_, 650)); + EXPECT_EQ(0, voe_codec_->SetISACMaxPayloadSize(channel_, 120)); + EXPECT_EQ(0, voe_base_->StartSend(channel_)); + TEST_LOG("Ensure that the sound is good (iSAC, " + "max payload size = 100 bytes)...\n"); + Sleep(3000); + + TEST_LOG(" Testing SetISACMaxRate:\n"); + EXPECT_EQ(0, voe_base_->StopSend(channel_)); + EXPECT_EQ(0, voe_codec_->SetISACMaxPayloadSize(channel_, 400)); + EXPECT_EQ(0, voe_base_->StartSend(channel_)); + + EXPECT_EQ(0, voe_base_->StopSend(channel_)); + EXPECT_NE(0, voe_codec_->SetISACMaxRate(channel_, 31900)); + EXPECT_NE(0, voe_codec_->SetISACMaxRate(channel_, 53500)); + EXPECT_EQ(0, voe_codec_->SetISACMaxRate(channel_, 32000)); + EXPECT_EQ(0, voe_base_->StartSend(channel_)); + TEST_LOG("Ensure that the sound is good (iSAC, max rate = 32 kbps)...\n"); + Sleep(3000); + + EXPECT_EQ(0, voe_base_->StopSend(channel_)); + + // Restore "no limitation". No, no limit, we reach for the sky. + EXPECT_EQ(0, voe_codec_->SetISACMaxRate(channel_, 53400)); + EXPECT_EQ(0, voe_base_->StartSend(channel_)); +} + +TEST_F(CodecTest, ManualVerifySendCodecsForAllPacketSizes) { + for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) { + voe_codec_->GetCodec(i, codec_instance_); + if (IsNotViableSendCodec(codec_instance_.plname)) { + TEST_LOG("Skipping %s.\n", codec_instance_.plname); + continue; + } + EXPECT_NE(-1, codec_instance_.pltype) << + "The codec database should suggest a payload type."; + + // Test with default packet size: + TEST_LOG("%s (pt=%d): default packet size(%d), accepts sizes ", + codec_instance_.plname, codec_instance_.pltype, + codec_instance_.pacsize); + voe_codec_->SetSendCodec(channel_, codec_instance_); + Sleep(CODEC_TEST_TIME); + + // Now test other reasonable packet sizes: + bool at_least_one_succeeded = false; + for (int packet_size = 80; packet_size < 1000; packet_size += 80) { + SetRateIfILBC(&codec_instance_, packet_size); + codec_instance_.pacsize = packet_size; + + if (voe_codec_->SetSendCodec(channel_, codec_instance_) != -1) { + // Note that it's fine for SetSendCodec to fail - what packet sizes + // it accepts depends on the codec. It should accept one at minimum. + TEST_LOG("%d ", packet_size); + TEST_LOG_FLUSH; + at_least_one_succeeded = true; + Sleep(CODEC_TEST_TIME); + } + } + TEST_LOG("\n"); + EXPECT_TRUE(at_least_one_succeeded); + } +} 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 6491b73cd6..591521d1da 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 @@ -971,295 +971,6 @@ int VoETestManager::TestStartPlaying() { return 0; } -int VoETestManager::TestCodecs() { - -#ifdef _TEST_CODEC_ - CodecInst codec_instance; - memset(&codec_instance, 0, sizeof(codec_instance)); - - TEST_LOG("\n\n+++ Codec tests +++\n\n"); - - TEST_LOG("Checking default codec\n"); - TEST_MUSTPASS(voe_codec_->GetSendCodec(0, codec_instance)); - TEST_MUSTPASS(codec_instance.channels != 1); - TEST_MUSTPASS(codec_instance.pacsize != 160); - TEST_MUSTPASS(codec_instance.plfreq != 8000); - TEST_MUSTPASS(codec_instance.pltype != 0); - TEST_MUSTPASS(codec_instance.rate != 64000); - TEST_MUSTPASS(strcmp("PCMU", codec_instance.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 num_codecs = voe_codec_->NumOfCodecs(); - for (int i = 0; i < num_codecs; i++) { - TEST_MUSTPASS(voe_codec_->GetCodec(i, codec_instance)); - - if (!((!_stricmp("CN", codec_instance.plname)) || - (!_stricmp("telephone-event", codec_instance.plname) || - (!_stricmp("red", codec_instance.plname))))) { - // If no default payload type is defined, we use 127 and also set - // receive payload type. - if (-1 == codec_instance.pltype) { - codec_instance.pltype = 127; - TEST_MUSTPASS(voe_base_->StopPlayout(0)); - TEST_MUSTPASS(voe_base_->StopReceive(0)); - TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0, codec_instance)); - TEST_MUSTPASS(voe_base_->StartReceive(0)); - TEST_MUSTPASS(voe_base_->StartPlayout(0)); - } - TEST_LOG("%s (pt=%d): default(%d) ", codec_instance.plname, - codec_instance.pltype, codec_instance.pacsize); - TEST_MUSTPASS(voe_codec_->SetSendCodec(0, codec_instance)); - SLEEP(CODEC_TEST_TIME); - // special case for G.722.1: - if (!_stricmp("g7221", codec_instance.plname)) - { - // Test 16 and 32 kHz. - for (int freq = 16000; freq <= 32000; freq += 16000) { - codec_instance.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 - codec_instance.rate = rate; - // Test packet sizes. - TEST_LOG("\n%s (pt=%d, fs=%d, rate=%d): ", codec_instance.plname, - codec_instance.pltype, codec_instance.plfreq, - codec_instance.rate); - for (int packet_size = 80; packet_size < 1000; packet_size += 80) { - // Set codec, and receive payload type. - codec_instance.pacsize = packet_size; - if (-1 != voe_codec_->SetSendCodec(0, codec_instance)) { - TEST_MUSTPASS(voe_base_->StopPlayout(0)); - TEST_MUSTPASS(voe_base_->StopReceive(0)); - TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0, - codec_instance)); - TEST_MUSTPASS(voe_base_->StartReceive(0)); - TEST_MUSTPASS(voe_base_->StartPlayout(0)); - TEST_LOG("%d ", packet_size); - 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", codec_instance.plname)) { - - if ((pacsize == 160) || (pacsize == 320)) { - codec_instance.rate = 15200; - } else { - codec_instance.rate = 13300; - } - } - codec_instance.pacsize = pacsize; - if (-1 != voe_codec_->SetSendCodec(0, codec_instance)) { - TEST_LOG("%d ", pacsize); - fflush(NULL); - SLEEP(CODEC_TEST_TIME); - } - } - } - TEST_LOG("\n"); - } - } - - TEST_MUSTPASS(voe_codec_->GetCodec(0, codec_instance)); - TEST_LOG("Setting codec to first in list: %s \n", codec_instance.plname); - TEST_MUSTPASS(voe_codec_->SetSendCodec(0, codec_instance)); - - TEST_LOG("Voice Activity Detection calls\n"); - TEST_LOG("Must be OFF by default\n"); - bool vad_test = true; - VadModes vadMode = kVadAggressiveHigh; - bool disabled_dtx = true; - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabled_dtx); - - TEST_LOG("Turn ON VAD\n"); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true)); - TEST_LOG("Should be ON now\n"); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(!vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(!vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(!vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabled_dtx); - - TEST_LOG("Testing Type settings\n"); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveLow)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveLow != vadMode); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveMid != vadMode); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveMid != vadMode); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveMid)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveMid != vadMode); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveHigh, true)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveHigh, true)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadAggressiveHigh, true)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadAggressiveHigh != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, true, kVadConventional)); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(disabled_dtx); - - // VAD is always on when DTX is on, so we need to turn off DTX too. - TEST_LOG("Turn OFF VAD\n"); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, false, kVadConventional, true)); - TEST_LOG("Should be OFF now\n"); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabled_dtx); - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(kVadConventional != vadMode); - TEST_MUSTPASS(!disabled_dtx); - -#if defined(WEBRTC_CODEC_ISAC) - TEST_LOG("Test extended iSAC APIs\n"); - TEST_LOG("Start by selecting iSAC 30ms adaptive mode\n"); - strcpy(codec_instance.plname, "isac"); - codec_instance.pltype = 103; - codec_instance.plfreq = 16000; - codec_instance.channels = 1; - codec_instance.rate = -1; // Adaptive rate. - codec_instance.pacsize = 480; - TEST_LOG(" testing SetISACInitTargetRate:\n"); - TEST_MUSTPASS(voe_codec_->SetSendCodec(0, codec_instance)); - TEST_MUSTPASS(!voe_codec_->SetISACInitTargetRate(0, 5000)); - TEST_MUSTPASS(!voe_codec_->SetISACInitTargetRate(0, 33000)); - TEST_MUSTPASS(voe_codec_->SetISACInitTargetRate(0, 32000)); - TEST_LOG("Speak and ensure that iSAC sounds OK (target = 32kbps)...\n"); - SLEEP(3000); - TEST_MUSTPASS(voe_codec_->SetISACInitTargetRate(0, 10000)); - TEST_LOG("Speak and ensure that iSAC sounds OK (target = 10kbps)...\n"); - SLEEP(3000); - TEST_MUSTPASS(voe_codec_->SetISACInitTargetRate(0, 10000, true)); - TEST_MUSTPASS(voe_codec_->SetISACInitTargetRate(0, 10000, false)); - TEST_MUSTPASS(voe_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(voe_base_->StopSend(0)); - TEST_MUSTPASS(!voe_codec_->SetISACMaxPayloadSize(0, 50)); - TEST_MUSTPASS(!voe_codec_->SetISACMaxPayloadSize(0, 650)); - TEST_MUSTPASS(voe_codec_->SetISACMaxPayloadSize(0, 120)); - TEST_MUSTPASS(voe_base_->StartSend(0)); - TEST_LOG("Speak and ensure that iSAC sounds OK" - "(max payload size = 100 bytes)...\n"); - SLEEP(3000); - TEST_MUSTPASS(voe_base_->StopSend(0)); - TEST_MUSTPASS(voe_codec_->SetISACMaxPayloadSize(0, 400)); - TEST_MUSTPASS(voe_base_->StartSend(0)); - - TEST_LOG(" testing SetISACMaxRate:\n"); - TEST_MUSTPASS(voe_base_->StopSend(0)); - TEST_MUSTPASS(!voe_codec_->SetISACMaxRate(0, 31900)); - TEST_MUSTPASS(!voe_codec_->SetISACMaxRate(0, 53500)); - TEST_MUSTPASS(voe_codec_->SetISACMaxRate(0, 32000)); - TEST_MUSTPASS(voe_base_->StartSend(0)); - TEST_LOG("Speak and ensure that iSAC sounds OK (max rate = 32 kbps)...\n"); - SLEEP(3000); - TEST_MUSTPASS(voe_base_->StopSend(0)); - TEST_MUSTPASS(voe_codec_->SetISACMaxRate(0, 53400)); // restore no limitation - TEST_MUSTPASS(voe_base_->StartSend(0)); - if (voe_file_) { - TEST_LOG("==> Start playing a file as microphone again \n"); - TEST_MUSTPASS(voe_file_->StartPlayingFileAsMicrophone( - 0, AudioFilename(), true, true)); - } -#else - 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: the calls should fail. - TEST_MUSTPASS(!voe_codec_->SetAMREncFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!voe_codec_->SetAMRDecFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!voe_codec_->SetAMREncFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!voe_codec_->SetAMRDecFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!voe_codec_->SetAMREncFormat(0, kRfc3267FileStorage)); - TEST_MUSTPASS(!voe_codec_->SetAMRDecFormat(0, kRfc3267FileStorage)); - - // Tests on AMRWB setencformat and setdecformat: the calls should fail. - TEST_MUSTPASS(!voe_codec_->SetAMRWbEncFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!voe_codec_->SetAMRWbDecFormat(0, kRfc3267BwEfficient)); - TEST_MUSTPASS(!voe_codec_->SetAMRWbEncFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!voe_codec_->SetAMRWbDecFormat(0, kRfc3267OctetAligned)); - TEST_MUSTPASS(!voe_codec_->SetAMRWbEncFormat(0, kRfc3267FileStorage)); - TEST_MUSTPASS(!voe_codec_->SetAMRWbDecFormat(0, kRfc3267FileStorage)); - - TEST_LOG("Turn on VAD,G711 and set packet size to 30 ms:\n"); - strcpy(codec_instance.plname, "pcmu"); - codec_instance.pacsize = 160; - codec_instance.pltype = 0; - codec_instance.plfreq = 8000; - codec_instance.channels = 1; - codec_instance.rate = 64000; - TEST_MUSTPASS(voe_codec_->SetSendCodec(0, codec_instance)); - // The test here is confusing, what are we expecting? VADtest = false? - TEST_MUSTPASS(voe_codec_->GetVADStatus(0, vad_test, vadMode, disabled_dtx)); - TEST_MUSTPASS(vad_test); - TEST_MUSTPASS(voe_codec_->SetVADStatus(0, false, vadMode, true)); - - // Set back to preferred codec. - TEST_MUSTPASS(voe_codec_->GetCodec(0, codec_instance)); - TEST_MUSTPASS(voe_codec_->SetSendCodec(0, codec_instance)); - -#else - TEST_LOG("\n\n+++ Codec tests NOT ENABLED +++\n"); -#endif // #ifdef _TEST_CODEC_ - return 0; -} - int VoETestManager::DoStandardTest() { // Ensure we have all input files: TEST_MUSTPASS(!strcmp("", AudioFilename())); @@ -1276,9 +987,7 @@ int VoETestManager::DoStandardTest() { FakeExternalTransport channel0_transport(voe_network_); if (TestStartStreaming(channel0_transport) != 0) return -1; - if (TestStartPlaying() != 0) return -1; - if (TestCodecs() != 0) return -1; ///////////////////////// // Start another channel 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 cb31a416a9..c9c103a33c 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 @@ -24,6 +24,7 @@ #else #define TEST_LOG printf #define TEST_LOG_ERROR printf +#define TEST_LOG_FLUSH fflush(NULL) #endif // Select the tests to execute, list order below is same as they will be diff --git a/src/voice_engine/main/test/voice_engine_tests.gypi b/src/voice_engine/main/test/voice_engine_tests.gypi index 1ce7e1a48e..ac48545a15 100644 --- a/src/voice_engine/main/test/voice_engine_tests.gypi +++ b/src/voice_engine/main/test/voice_engine_tests.gypi @@ -37,6 +37,7 @@ 'auto_test/fixtures/before_initialization_fixture.cc', 'auto_test/fixtures/before_initialization_fixture.h', 'auto_test/standard/codec_before_streaming_test.cc', + 'auto_test/standard/codec_test.cc', 'auto_test/standard/hardware_before_initializing_test.cc', 'auto_test/standard/hardware_before_streaming_test.cc', 'auto_test/standard/manual_hold_test.cc',