Allow voe_cmd_test to select Opus mono (now the default).

* Opus handles stereo and mono on the same payload type, so we need a different mechanism to choose between them.
* Assorted cleanups.

BUG=webrtc:1710
TBR=turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1379004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3937 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2013-05-02 15:57:36 +00:00
parent 8c845cb623
commit ea83c6ac9d

View File

@ -37,21 +37,14 @@
#include "webrtc/test/channel_transport/include/channel_transport.h" #include "webrtc/test/channel_transport/include/channel_transport.h"
#include "webrtc/test/testsupport/fileutils.h" #include "webrtc/test/testsupport/fileutils.h"
// Enable this this flag to run this test with hard coded
// IP/Port/codec and start test automatically with key input
// it could be useful in repeat tests.
//#define DEBUG
using namespace webrtc; using namespace webrtc;
using namespace test; using namespace test;
#define VALIDATE \ #define VALIDATE \
if (res != 0) \ if (res != 0) { \
{ \ printf("*** Error at line %i \n", __LINE__); \
printf("*** Error at position %i / line %i \n", cnt, __LINE__); \ printf("*** Error code = %i \n", base1->LastError()); \
printf("*** Error code = %i \n", base1->LastError()); \ }
} \
cnt++;
VoiceEngine* m_voe = NULL; VoiceEngine* m_voe = NULL;
VoEBase* base1 = NULL; VoEBase* base1 = NULL;
@ -98,9 +91,28 @@ void MyObserver::CallbackOnError(const int channel, const int err_code) {
} }
} }
void SetStereoIfOpus(bool use_stereo, CodecInst* codec_params) {
if (strncmp(codec_params->plname, "opus", 4) == 0) {
if (use_stereo)
codec_params->channels = 2;
else
codec_params->channels = 1;
}
}
void PrintCodecs(bool opus_stereo) {
CodecInst codec_params;
for (int i = 0; i < codec->NumOfCodecs(); ++i) {
int res = codec->GetCodec(i, codec_params);
VALIDATE;
SetStereoIfOpus(opus_stereo, &codec_params);
printf("%2d. %3d %s/%d/%d \n", i, codec_params.pltype, codec_params.plname,
codec_params.plfreq, codec_params.channels);
}
}
int main() { int main() {
int res = 0; int res = 0;
int cnt = 0;
printf("Test started \n"); printf("Test started \n");
@ -143,12 +155,10 @@ int main() {
res = base1->RegisterVoiceEngineObserver(my_observer); res = base1->RegisterVoiceEngineObserver(my_observer);
VALIDATE; VALIDATE;
cnt++;
printf("Version\n"); printf("Version\n");
char tmp[1024]; char tmp[1024];
res = base1->GetVersion(tmp); res = base1->GetVersion(tmp);
VALIDATE; VALIDATE;
cnt++;
printf("%s\n", tmp); printf("%s\n", tmp);
RunTest(out_path); RunTest(out_path);
@ -205,20 +215,18 @@ int main() {
} }
void RunTest(std::string out_path) { void RunTest(std::string out_path) {
int chan, cnt, res; int chan, res;
CodecInst cinst; CodecInst cinst;
cnt = 0; bool enable_aec = false;
int i; bool enable_agc = false;
int codecinput; bool enable_rx_agc = false;
bool AEC = false; bool enable_cng = false;
bool AGC = true; bool enable_ns = false;
bool rx_agc = false; bool enable_rx_ns = false;
bool VAD = false;
bool NS = false;
bool rx_ns = false;
bool typing_detection = false; bool typing_detection = false;
bool muted = false; bool muted = false;
bool on_hold = false; bool on_hold = false;
bool opus_stereo = false;
#if defined(WEBRTC_ANDROID) #if defined(WEBRTC_ANDROID)
std::string resource_path = "/sdcard/"; std::string resource_path = "/sdcard/";
@ -240,37 +248,29 @@ void RunTest(std::string out_path) {
chan = base1->CreateChannel(); chan = base1->CreateChannel();
if (chan < 0) { if (chan < 0) {
printf("Error at position %i\n", cnt);
printf("************ Error code = %i\n", base1->LastError()); printf("************ Error code = %i\n", base1->LastError());
fflush(NULL); fflush(NULL);
} }
cnt++;
int j = 0;
char ip[64]; char ip[64];
#ifdef DEBUG
strcpy(ip, "127.0.0.1");
#else
printf("1. 127.0.0.1 \n"); printf("1. 127.0.0.1 \n");
printf("2. Specify IP \n"); printf("2. Specify IP \n");
ASSERT_EQ(1, scanf("%i", &i)); int ip_selection;
ASSERT_EQ(1, scanf("%i", &ip_selection));
if (1 == i) { if (ip_selection == 1) {
strcpy(ip, "127.0.0.1"); strcpy(ip, "127.0.0.1");
} else { } else {
printf("Specify remote IP: "); printf("Specify remote IP: ");
ASSERT_EQ(1, scanf("%s", ip)); ASSERT_EQ(1, scanf("%s", ip));
} }
#endif
int rPort = 8500; int rPort;
#ifndef DEBUG
printf("Specify remote port (1=1234): "); printf("Specify remote port (1=1234): ");
ASSERT_EQ(1, scanf("%i", &rPort)); ASSERT_EQ(1, scanf("%i", &rPort));
if (1 == rPort) if (1 == rPort)
rPort = 1234; rPort = 1234;
printf("Set Send port \n"); printf("Set Send port \n");
#endif
scoped_ptr<VoiceChannelTransport> voice_channel_transport( scoped_ptr<VoiceChannelTransport> voice_channel_transport(
new VoiceChannelTransport(netw, chan)); new VoiceChannelTransport(netw, chan));
@ -279,61 +279,39 @@ void RunTest(std::string out_path) {
res = voice_channel_transport->SetSendDestination(ip, rPort); res = voice_channel_transport->SetSendDestination(ip, rPort);
VALIDATE; VALIDATE;
int lPort = 8500; int lPort;
#ifndef DEBUG
printf("Specify local port (1=1234): "); printf("Specify local port (1=1234): ");
ASSERT_EQ(1, scanf("%i", &lPort)); ASSERT_EQ(1, scanf("%i", &lPort));
if (1 == lPort) if (1 == lPort)
lPort = 1234; lPort = 1234;
printf("Set Rec Port \n"); printf("Set Rec Port \n");
#endif
res = voice_channel_transport->SetLocalReceiver(lPort); res = voice_channel_transport->SetLocalReceiver(lPort);
VALIDATE; VALIDATE;
printf("\n"); printf("\n");
for (i = 0; i < codec->NumOfCodecs(); i++) { PrintCodecs(opus_stereo);
res = codec->GetCodec(i, cinst);
VALIDATE;
if (strncmp(cinst.plname, "ISAC", 4) == 0 && cinst.plfreq == 32000) {
printf("%i. ISAC-swb pltype:%i plfreq:%i channels:%i\n", i, cinst.pltype,
cinst.plfreq, cinst.channels);
} else if (strncmp(cinst.plname, "ISAC", 4) == 0 && cinst.plfreq == 48000) {
printf("%i. ISAC-fb pltype:%i plfreq:%i channels:%i\n", i, cinst.pltype,
cinst.plfreq, cinst.channels);
} else {
printf("%i. %s pltype:%i plfreq:%i channels:%i\n", i, cinst.plname,
cinst.pltype, cinst.plfreq, cinst.channels);
}
}
#ifdef DEBUG
codecinput=0;
#else
printf("Select send codec: "); printf("Select send codec: ");
ASSERT_EQ(1, scanf("%i", &codecinput)); int codec_selection;
#endif ASSERT_EQ(1, scanf("%i", &codec_selection));
codec->GetCodec(codecinput, cinst); codec->GetCodec(codec_selection, cinst);
printf("Set primary codec\n"); printf("Set primary codec\n");
SetStereoIfOpus(opus_stereo, &cinst);
res = codec->SetSendCodec(chan, cinst); res = codec->SetSendCodec(chan, cinst);
VALIDATE; VALIDATE;
#ifndef WEBRTC_ANDROID
const int kMaxNumChannels = 8; const int kMaxNumChannels = 8;
#else
const int kMaxNumChannels = 1;
#endif
int channel_index = 0; int channel_index = 0;
std::vector<int> channels(kMaxNumChannels); std::vector<int> channels(kMaxNumChannels);
std::vector<VoiceChannelTransport*> voice_channel_transports(kMaxNumChannels); std::vector<VoiceChannelTransport*> voice_channel_transports(kMaxNumChannels);
for (i = 0; i < kMaxNumChannels; ++i) { for (int i = 0; i < kMaxNumChannels; ++i) {
channels[i] = base1->CreateChannel(); channels[i] = base1->CreateChannel();
int port = rPort + (i + 1) * 2; int port = rPort + (i + 1) * 2;
voice_channel_transports[i] = new VoiceChannelTransport(netw, channels[i]); voice_channel_transports[i] = new VoiceChannelTransport(netw, channels[i]);
printf("Set Send IP \n");
res = voice_channel_transports[i]->SetSendDestination(ip, port); res = voice_channel_transports[i]->SetSendDestination(ip, port);
VALIDATE; VALIDATE;
res = voice_channel_transports[i]->SetLocalReceiver(port); res = voice_channel_transports[i]->SetLocalReceiver(port);
@ -346,7 +324,7 @@ void RunTest(std::string out_path) {
bool newcall = true; bool newcall = true;
while (newcall) { while (newcall) {
#if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) #ifndef WEBRTC_ANDROID
int rd(-1), pd(-1); int rd(-1), pd(-1);
res = hardware->GetNumOfRecordingDevices(rd); res = hardware->GetNumOfRecordingDevices(rd);
VALIDATE; VALIDATE;
@ -356,14 +334,14 @@ void RunTest(std::string out_path) {
char dn[128] = { 0 }; char dn[128] = { 0 };
char guid[128] = { 0 }; char guid[128] = { 0 };
printf("\nPlayout devices (%d): \n", pd); printf("\nPlayout devices (%d): \n", pd);
for (j=0; j<pd; ++j) { for (int j = 0; j < pd; ++j) {
res = hardware->GetPlayoutDeviceName(j, dn, guid); res = hardware->GetPlayoutDeviceName(j, dn, guid);
VALIDATE; VALIDATE;
printf(" %d: %s \n", j, dn); printf(" %d: %s \n", j, dn);
} }
printf("Recording devices (%d): \n", rd); printf("Recording devices (%d): \n", rd);
for (j=0; j<rd; ++j) { for (int j = 0; j < rd; ++j) {
res = hardware->GetRecordingDeviceName(j, dn, guid); res = hardware->GetRecordingDeviceName(j, dn, guid);
VALIDATE; VALIDATE;
printf(" %d: %s \n", j, dn); printf(" %d: %s \n", j, dn);
@ -378,31 +356,28 @@ void RunTest(std::string out_path) {
printf("Setting sound devices \n"); printf("Setting sound devices \n");
res = hardware->SetRecordingDevice(rd); res = hardware->SetRecordingDevice(rd);
VALIDATE; VALIDATE;
#endif // WEBRTC_ANDROID
#endif // WEBRTC_LINUX res = codec->SetVADStatus(0, enable_cng);
res = codec->SetVADStatus(0, VAD);
VALIDATE; VALIDATE;
res = apm->SetAgcStatus(AGC); res = apm->SetAgcStatus(enable_agc);
VALIDATE; VALIDATE;
res = apm->SetEcStatus(AEC); res = apm->SetEcStatus(enable_aec);
VALIDATE; VALIDATE;
res = apm->SetNsStatus(NS); res = apm->SetNsStatus(enable_ns);
VALIDATE; VALIDATE;
#ifdef DEBUG
i = 1;
#else
printf("\n1. Send, listen and playout \n"); printf("\n1. Send, listen and playout \n");
printf("2. Send only \n"); printf("2. Send only \n");
printf("3. Listen and playout only \n"); printf("3. Listen and playout only \n");
printf("Select transfer mode: "); printf("Select transfer mode: ");
ASSERT_EQ(1, scanf("%i", &i)); int call_selection;
#endif ASSERT_EQ(1, scanf("%i", &call_selection));
const bool send = !(3 == i); const bool send = !(call_selection == 3);
const bool receive = !(2 == i); const bool receive = !(call_selection == 2);
if (receive) { if (receive) {
#ifndef EXTERNAL_TRANSPORT #ifndef EXTERNAL_TRANSPORT
@ -434,169 +409,128 @@ void RunTest(std::string out_path) {
int forever = 1; int forever = 1;
while (forever) { while (forever) {
printf("\nActions\n"); printf("\nSelect codec\n");
PrintCodecs(opus_stereo);
printf("\nOther actions\n");
const int num_codecs = codec->NumOfCodecs();
int option_index = num_codecs;
printf("%i. Toggle CNG\n", option_index++);
printf("%i. Toggle AGC\n", option_index++);
printf("%i. Toggle NS\n", option_index++);
printf("%i. Toggle EC\n", option_index++);
printf("%i. Select AEC\n", option_index++);
printf("%i. Select AECM\n", option_index++);
printf("%i. Get speaker volume\n", option_index++);
printf("%i. Set speaker volume\n", option_index++);
printf("%i. Get microphone volume\n", option_index++);
printf("%i. Set microphone volume\n", option_index++);
printf("%i. Play local file (audio_long16.pcm) \n", option_index++);
printf("%i. Change playout device \n", option_index++);
printf("%i. Change recording device \n", option_index++);
printf("%i. Toggle receive-side AGC \n", option_index++);
printf("%i. Toggle receive-side NS \n", option_index++);
printf("%i. AGC status \n", option_index++);
printf("%i. Toggle microphone mute \n", option_index++);
printf("%i. Toggle on hold status \n", option_index++);
printf("%i. Get last error code \n", option_index++);
printf("%i. Toggle typing detection (for Mac/Windows only) \n",
option_index++);
printf("%i. Record a PCM file \n", option_index++);
printf("%i. Play a previously recorded PCM file locally \n",
option_index++);
printf("%i. Play a previously recorded PCM file as microphone \n",
option_index++);
printf("%i. Add an additional file-playing channel \n", option_index++);
printf("%i. Remove a file-playing channel \n", option_index++);
printf("%i. Toggle Opus stereo (Opus must be selected again to apply "
"the setting) \n", option_index++);
printf("Codec Changes\n"); printf("Select action or %i to stop the call: ", option_index);
for (i = 0; i < codec->NumOfCodecs(); i++) { int option_selection;
res = codec->GetCodec(i, cinst); ASSERT_EQ(1, scanf("%i", &option_selection));
option_index = num_codecs;
if (option_selection < option_index) {
res = codec->GetCodec(option_selection, cinst);
VALIDATE; VALIDATE;
if (strncmp(cinst.plname, "ISAC", 4) == 0 && cinst.plfreq SetStereoIfOpus(opus_stereo, &cinst);
== 32000) {
printf("\t%i. ISAC-swb pltype:%i plfreq:%i channels:%i\n", i,
cinst.pltype, cinst.plfreq, cinst.channels);
}
else {
printf("\t%i. %s pltype:%i plfreq:%i channels:%i\n", i, cinst.plname,
cinst.pltype, cinst.plfreq, cinst.channels);
}
}
printf("Other\n");
const int noCodecs = i - 1;
printf("\t%i. Toggle VAD\n", i);
i++;
printf("\t%i. Toggle AGC\n", i);
i++;
printf("\t%i. Toggle NS\n", i);
i++;
printf("\t%i. Toggle EC\n", i);
i++;
printf("\t%i. Select AEC\n", i);
i++;
printf("\t%i. Select AECM\n", i);
i++;
printf("\t%i. Get speaker volume\n", i);
i++;
printf("\t%i. Set speaker volume\n", i);
i++;
printf("\t%i. Get microphone volume\n", i);
i++;
printf("\t%i. Set microphone volume\n", i);
i++;
printf("\t%i. Play local file (audio_long16.pcm) \n", i);
i++;
printf("\t%i. Change playout device \n", i);
i++;
printf("\t%i. Change recording device \n", i);
i++;
printf("\t%i. Toggle receive-side AGC \n", i);
i++;
printf("\t%i. Toggle receive-side NS \n", i);
i++;
printf("\t%i. AGC status \n", i);
i++;
printf("\t%i. Toggle microphone mute \n", i);
i++;
printf("\t%i. Toggle on hold status \n", i);
i++;
printf("\t%i. Get last error code \n", i);
i++;
printf("\t%i. Toggle typing detection (for Mac/Windows only) \n", i);
i++;
printf("\t%i. Record a PCM file \n", i);
i++;
printf("\t%i. Play a previously recorded PCM file locally \n", i);
i++;
printf("\t%i. Play a previously recorded PCM file as microphone \n", i);
i++;
printf("\t%i. Add an additional file-playing channel \n", i);
i++;
printf("\t%i. Remove a file-playing channel \n", i);
i++;
printf("Select action or %i to stop the call: ", i);
ASSERT_EQ(1, scanf("%i", &codecinput));
if (codecinput < codec->NumOfCodecs()) {
res = codec->GetCodec(codecinput, cinst);
VALIDATE;
printf("Set primary codec\n"); printf("Set primary codec\n");
res = codec->SetSendCodec(chan, cinst); res = codec->SetSendCodec(chan, cinst);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 1)) { enable_cng = !enable_cng;
VAD = !VAD; res = codec->SetVADStatus(0, enable_cng);
res = codec->SetVADStatus(0, VAD);
VALIDATE; VALIDATE;
if (VAD) if (enable_cng)
printf("\n VAD is now on! \n"); printf("\n CNG is now on! \n");
else else
printf("\n VAD is now off! \n"); printf("\n CNG is now off! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 2)) { enable_agc = !enable_agc;
AGC = !AGC; res = apm->SetAgcStatus(enable_agc);
res = apm->SetAgcStatus(AGC);
VALIDATE; VALIDATE;
if (AGC) if (enable_agc)
printf("\n AGC is now on! \n"); printf("\n AGC is now on! \n");
else else
printf("\n AGC is now off! \n"); printf("\n AGC is now off! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 3)) { enable_ns = !enable_ns;
NS = !NS; res = apm->SetNsStatus(enable_ns);
res = apm->SetNsStatus(NS);
VALIDATE; VALIDATE;
if (NS) if (enable_ns)
printf("\n NS is now on! \n"); printf("\n NS is now on! \n");
else else
printf("\n NS is now off! \n"); printf("\n NS is now off! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 4)) { enable_aec = !enable_aec;
AEC = !AEC; res = apm->SetEcStatus(enable_aec, kEcUnchanged);
res = apm->SetEcStatus(AEC, kEcUnchanged);
VALIDATE; VALIDATE;
if (AEC) if (enable_aec)
printf("\n Echo control is now on! \n"); printf("\n Echo control is now on! \n");
else else
printf("\n Echo control is now off! \n"); printf("\n Echo control is now off! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 5)) { res = apm->SetEcStatus(enable_aec, kEcAec);
res = apm->SetEcStatus(AEC, kEcAec);
VALIDATE; VALIDATE;
printf("\n AEC selected! \n"); printf("\n AEC selected! \n");
if (AEC) if (enable_aec)
printf(" (Echo control is on)\n"); printf(" (Echo control is on)\n");
else else
printf(" (Echo control is off)\n"); printf(" (Echo control is off)\n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 6)) { res = apm->SetEcStatus(enable_aec, kEcAecm);
res = apm->SetEcStatus(AEC, kEcAecm);
VALIDATE; VALIDATE;
printf("\n AECM selected! \n"); printf("\n AECM selected! \n");
if (AEC) if (enable_aec)
printf(" (Echo control is on)\n"); printf(" (Echo control is on)\n");
else else
printf(" (Echo control is off)\n"); printf(" (Echo control is off)\n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 7)) {
unsigned vol(0); unsigned vol(0);
res = volume->GetSpeakerVolume(vol); res = volume->GetSpeakerVolume(vol);
VALIDATE; VALIDATE;
printf("\n Speaker Volume is %d \n", vol); printf("\n Speaker Volume is %d \n", vol);
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 8)) {
printf("Level: "); printf("Level: ");
ASSERT_EQ(1, scanf("%i", &i)); int level;
res = volume->SetSpeakerVolume(i); ASSERT_EQ(1, scanf("%i", &level));
res = volume->SetSpeakerVolume(level);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 9)) {
unsigned vol(0); unsigned vol(0);
res = volume->GetMicVolume(vol); res = volume->GetMicVolume(vol);
VALIDATE; VALIDATE;
printf("\n Microphone Volume is %d \n", vol); printf("\n Microphone Volume is %d \n", vol);
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 10)) {
printf("Level: "); printf("Level: ");
ASSERT_EQ(1, scanf("%i", &i)); int level;
res = volume->SetMicVolume(i); ASSERT_EQ(1, scanf("%i", &level));
res = volume->SetMicVolume(level);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 11)) {
res = file->StartPlayingFileLocally(0, audio_filename.c_str()); res = file->StartPlayingFileLocally(0, audio_filename.c_str());
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 12)) {
// change the playout device with current call // change the playout device with current call
int num_pd(-1); int num_pd(-1);
res = hardware->GetNumOfPlayoutDevices(num_pd); res = hardware->GetNumOfPlayoutDevices(num_pd);
@ -606,18 +540,17 @@ void RunTest(std::string out_path) {
char guid[128] = { 0 }; char guid[128] = { 0 };
printf("\nPlayout devices (%d): \n", num_pd); printf("\nPlayout devices (%d): \n", num_pd);
for (j = 0; j < num_pd; ++j) { for (int i = 0; i < num_pd; ++i) {
res = hardware->GetPlayoutDeviceName(j, dn, guid); res = hardware->GetPlayoutDeviceName(i, dn, guid);
VALIDATE; VALIDATE;
printf(" %d: %s \n", j, dn); printf(" %d: %s \n", i, dn);
} }
printf("Select playout device: "); printf("Select playout device: ");
ASSERT_EQ(1, scanf("%d", &num_pd)); ASSERT_EQ(1, scanf("%d", &num_pd));
// Will use plughw for hardware devices // Will use plughw for hardware devices
res = hardware->SetPlayoutDevice(num_pd); res = hardware->SetPlayoutDevice(num_pd);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 13)) {
// change the recording device with current call // change the recording device with current call
int num_rd(-1); int num_rd(-1);
@ -628,10 +561,10 @@ void RunTest(std::string out_path) {
char guid[128] = { 0 }; char guid[128] = { 0 };
printf("Recording devices (%d): \n", num_rd); printf("Recording devices (%d): \n", num_rd);
for (j = 0; j < num_rd; ++j) { for (int i = 0; i < num_rd; ++i) {
res = hardware->GetRecordingDeviceName(j, dn, guid); res = hardware->GetRecordingDeviceName(i, dn, guid);
VALIDATE; VALIDATE;
printf(" %d: %s \n", j, dn); printf(" %d: %s \n", i, dn);
} }
printf("Select recording device: "); printf("Select recording device: ");
@ -640,35 +573,31 @@ void RunTest(std::string out_path) {
// Will use plughw for hardware devices // Will use plughw for hardware devices
res = hardware->SetRecordingDevice(num_rd); res = hardware->SetRecordingDevice(num_rd);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 14)) {
// Remote AGC // Remote AGC
rx_agc = !rx_agc; enable_rx_agc = !enable_rx_agc;
res = apm->SetRxAgcStatus(chan, rx_agc); res = apm->SetRxAgcStatus(chan, enable_rx_agc);
VALIDATE; VALIDATE;
if (rx_agc) if (enable_rx_agc)
printf("\n Receive-side AGC is now on! \n"); printf("\n Receive-side AGC is now on! \n");
else else
printf("\n Receive-side AGC is now off! \n"); printf("\n Receive-side AGC is now off! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 15)) {
// Remote NS // Remote NS
rx_ns = !rx_ns; enable_rx_ns = !enable_rx_ns;
res = apm->SetRxNsStatus(chan, rx_ns); res = apm->SetRxNsStatus(chan, enable_rx_ns);
VALIDATE; VALIDATE;
if (rx_ns) if (enable_rx_ns)
printf("\n Receive-side NS is now on! \n"); printf("\n Receive-side NS is now on! \n");
else else
printf("\n Receive-side NS is now off! \n"); printf("\n Receive-side NS is now off! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 16)) {
AgcModes agcmode; AgcModes agcmode;
bool enable; bool enable;
res = apm->GetAgcStatus(enable, agcmode); res = apm->GetAgcStatus(enable, agcmode);
VALIDATE VALIDATE
printf("\n AGC enable is %d, mode is %d \n", enable, agcmode); printf("\n AGC enable is %d, mode is %d \n", enable, agcmode);
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 17)) {
// Toggle Mute on Microphone // Toggle Mute on Microphone
res = volume->GetInputMute(chan, muted); res = volume->GetInputMute(chan, muted);
VALIDATE; VALIDATE;
@ -679,9 +608,7 @@ void RunTest(std::string out_path) {
printf("\n Microphone is now on mute! \n"); printf("\n Microphone is now on mute! \n");
else else
printf("\n Microphone is no longer on mute! \n"); printf("\n Microphone is no longer on mute! \n");
} else if (option_selection == option_index++) {
}
else if (codecinput == (noCodecs + 18)) {
// Toggle the call on hold // Toggle the call on hold
OnHoldModes mode; OnHoldModes mode;
res = base1->GetOnHoldStatus(chan, on_hold, mode); res = base1->GetOnHoldStatus(chan, on_hold, mode);
@ -694,16 +621,13 @@ void RunTest(std::string out_path) {
printf("\n Call now on hold! \n"); printf("\n Call now on hold! \n");
else else
printf("\n Call now not on hold! \n"); printf("\n Call now not on hold! \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 19)) {
// Get the last error code and print to screen // Get the last error code and print to screen
int err_code = 0; int err_code = 0;
err_code = base1->LastError(); err_code = base1->LastError();
if (err_code != -1) if (err_code != -1)
printf("\n The last error code was %i.\n", err_code); printf("\n The last error code was %i.\n", err_code);
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 20)) {
typing_detection= !typing_detection; typing_detection= !typing_detection;
res = apm->SetTypingDetectionStatus(typing_detection); res = apm->SetTypingDetectionStatus(typing_detection);
VALIDATE; VALIDATE;
@ -711,8 +635,7 @@ void RunTest(std::string out_path) {
printf("\n Typing detection is now on!\n"); printf("\n Typing detection is now on!\n");
else else
printf("\n Typing detection is now off!\n"); printf("\n Typing detection is now off!\n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 21)) {
int stop_record = 1; int stop_record = 1;
int file_source = 1; int file_source = 1;
printf("\n Select source of recorded file. "); printf("\n Select source of recorded file. ");
@ -725,8 +648,7 @@ void RunTest(std::string out_path) {
mic_filename.c_str()); mic_filename.c_str());
res = file->StartRecordingMicrophone(mic_filename.c_str()); res = file->StartRecordingMicrophone(mic_filename.c_str());
VALIDATE; VALIDATE;
} } else {
else {
printf("\n Start recording playout as %s \n", play_filename.c_str()); printf("\n Start recording playout as %s \n", play_filename.c_str());
res = file->StartRecordingPlayout(chan, play_filename.c_str()); res = file->StartRecordingPlayout(chan, play_filename.c_str());
VALIDATE; VALIDATE;
@ -738,14 +660,12 @@ void RunTest(std::string out_path) {
if (file_source == 1) { if (file_source == 1) {
res = file->StopRecordingMicrophone(); res = file->StopRecordingMicrophone();
VALIDATE; VALIDATE;
} } else {
else {
res = file->StopRecordingPlayout(chan); res = file->StopRecordingPlayout(chan);
VALIDATE; VALIDATE;
} }
printf("\n File finished recording \n"); printf("\n File finished recording \n");
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 22)) {
int file_type = 1; int file_type = 1;
int stop_play = 1; int stop_play = 1;
printf("\n Select a file to play locally in a loop."); printf("\n Select a file to play locally in a loop.");
@ -758,8 +678,7 @@ void RunTest(std::string out_path) {
mic_filename.c_str()); mic_filename.c_str());
res = file->StartPlayingFileLocally(chan, mic_filename.c_str(), true); res = file->StartPlayingFileLocally(chan, mic_filename.c_str(), true);
VALIDATE; VALIDATE;
} } else {
else {
printf("\n Start playing %s locally in a loop\n", printf("\n Start playing %s locally in a loop\n",
play_filename.c_str()); play_filename.c_str());
res = file->StartPlayingFileLocally(chan, play_filename.c_str(), res = file->StartPlayingFileLocally(chan, play_filename.c_str(),
@ -772,8 +691,7 @@ void RunTest(std::string out_path) {
} }
res = file->StopPlayingFileLocally(chan); res = file->StopPlayingFileLocally(chan);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 23)) {
int file_type = 1; int file_type = 1;
int stop_play = 1; int stop_play = 1;
printf("\n Select a file to play as microphone in a loop."); printf("\n Select a file to play as microphone in a loop.");
@ -787,8 +705,7 @@ void RunTest(std::string out_path) {
res = file->StartPlayingFileAsMicrophone(chan, mic_filename.c_str(), res = file->StartPlayingFileAsMicrophone(chan, mic_filename.c_str(),
true); true);
VALIDATE; VALIDATE;
} } else {
else {
printf("\n Start playing %s as mic in a loop\n", printf("\n Start playing %s as mic in a loop\n",
play_filename.c_str()); play_filename.c_str());
res = file->StartPlayingFileAsMicrophone(chan, play_filename.c_str(), res = file->StartPlayingFileAsMicrophone(chan, play_filename.c_str(),
@ -801,8 +718,7 @@ void RunTest(std::string out_path) {
} }
res = file->StopPlayingFileAsMicrophone(chan); res = file->StopPlayingFileAsMicrophone(chan);
VALIDATE; VALIDATE;
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 24)) {
if (channel_index < kMaxNumChannels) { if (channel_index < kMaxNumChannels) {
res = base1->StartReceive(channels[channel_index]); res = base1->StartReceive(channels[channel_index]);
VALIDATE; VALIDATE;
@ -820,8 +736,7 @@ void RunTest(std::string out_path) {
} else { } else {
printf("Max number of channels reached\n"); printf("Max number of channels reached\n");
} }
} } else if (option_selection == option_index++) {
else if (codecinput == (noCodecs + 25)) {
if (channel_index > 0) { if (channel_index > 0) {
channel_index--; channel_index--;
res = file->StopPlayingFileAsMicrophone(channels[channel_index]); res = file->StopPlayingFileAsMicrophone(channels[channel_index]);
@ -836,9 +751,17 @@ void RunTest(std::string out_path) {
} else { } else {
printf("All additional channels stopped\n"); printf("All additional channels stopped\n");
} }
} } else if (option_selection == option_index++) {
else opus_stereo = !opus_stereo;
if (opus_stereo)
printf("\n Opus stereo enabled (select Opus again to apply the "
"setting). \n");
else
printf("\n Opus mono enabled (select Opus again to apply the "
"setting). \n");
} else {
break; break;
}
} }
if (send) { if (send) {
@ -874,11 +797,12 @@ void RunTest(std::string out_path) {
printf("\n1. New call \n"); printf("\n1. New call \n");
printf("2. Quit \n"); printf("2. Quit \n");
printf("Select action: "); printf("Select action: ");
ASSERT_EQ(1, scanf("%i", &i)); int end_option;
newcall = (1 == i); ASSERT_EQ(1, scanf("%i", &end_option));
newcall = (end_option == 1);
// Call loop // Call loop
} }
for (i = 0; i < kMaxNumChannels; ++i) { for (int i = 0; i < kMaxNumChannels; ++i) {
delete voice_channel_transports[i]; delete voice_channel_transports[i];
voice_channel_transports[i] = NULL; voice_channel_transports[i] = NULL;
} }
@ -887,7 +811,7 @@ void RunTest(std::string out_path) {
res = base1->DeleteChannel(chan); res = base1->DeleteChannel(chan);
VALIDATE; VALIDATE;
for (i = 0; i < kMaxNumChannels; ++i) { for (int i = 0; i < kMaxNumChannels; ++i) {
channels[i] = base1->DeleteChannel(channels[i]); channels[i] = base1->DeleteChannel(channels[i]);
VALIDATE; VALIDATE;
} }