andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include <stdio.h> |
| 12 | #include <stdlib.h> |
| 13 | #include <string.h> |
| 14 | #ifndef _WIN32 |
| 15 | #include <unistd.h> |
| 16 | #endif |
| 17 | |
| 18 | #include <vector> |
| 19 | |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 20 | #include "gflags/gflags.h" |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 21 | #include "testing/gtest/include/gtest/gtest.h" |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 22 | #include "webrtc/common.h" |
| 23 | #include "webrtc/common_types.h" |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 24 | #include "webrtc/engine_configurations.h" |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 25 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 26 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 27 | #include "webrtc/test/channel_transport/include/channel_transport.h" |
| 28 | #include "webrtc/test/testsupport/fileutils.h" |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 29 | #include "webrtc/voice_engine/include/voe_audio_processing.h" |
| 30 | #include "webrtc/voice_engine/include/voe_base.h" |
| 31 | #include "webrtc/voice_engine/include/voe_codec.h" |
| 32 | #include "webrtc/voice_engine/include/voe_dtmf.h" |
| 33 | #include "webrtc/voice_engine/include/voe_encryption.h" |
| 34 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 35 | #include "webrtc/voice_engine/include/voe_external_media.h" |
| 36 | #include "webrtc/voice_engine/include/voe_file.h" |
| 37 | #include "webrtc/voice_engine/include/voe_hardware.h" |
| 38 | #include "webrtc/voice_engine/include/voe_neteq_stats.h" |
| 39 | #include "webrtc/voice_engine/include/voe_network.h" |
| 40 | #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 41 | #include "webrtc/voice_engine/include/voe_video_sync.h" |
| 42 | #include "webrtc/voice_engine/include/voe_volume_control.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 43 | |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 44 | DEFINE_bool(use_acm_version_2, false, |
| 45 | "If true, we'll run the tests with Audio Coding Module version 2."); |
| 46 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 47 | using namespace webrtc; |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 48 | using namespace test; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 49 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 50 | #define VALIDATE \ |
| 51 | if (res != 0) { \ |
| 52 | printf("*** Error at line %i \n", __LINE__); \ |
| 53 | printf("*** Error code = %i \n", base1->LastError()); \ |
| 54 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 55 | |
| 56 | VoiceEngine* m_voe = NULL; |
| 57 | VoEBase* base1 = NULL; |
| 58 | VoECodec* codec = NULL; |
| 59 | VoEVolumeControl* volume = NULL; |
| 60 | VoEDtmf* dtmf = NULL; |
| 61 | VoERTP_RTCP* rtp_rtcp = NULL; |
| 62 | VoEAudioProcessing* apm = NULL; |
| 63 | VoENetwork* netw = NULL; |
| 64 | VoEFile* file = NULL; |
| 65 | VoEVideoSync* vsync = NULL; |
| 66 | VoEEncryption* encr = NULL; |
| 67 | VoEHardware* hardware = NULL; |
| 68 | VoEExternalMedia* xmedia = NULL; |
| 69 | VoENetEqStats* neteqst = NULL; |
| 70 | |
| 71 | void RunTest(std::string out_path); |
| 72 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 73 | class MyObserver : public VoiceEngineObserver { |
| 74 | public: |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 75 | virtual void CallbackOnError(int channel, int err_code); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 78 | void MyObserver::CallbackOnError(int channel, int err_code) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 79 | // Add printf for other error codes here |
| 80 | if (err_code == VE_TYPING_NOISE_WARNING) { |
| 81 | printf(" TYPING NOISE DETECTED \n"); |
| 82 | } else if (err_code == VE_RECEIVE_PACKET_TIMEOUT) { |
| 83 | printf(" RECEIVE PACKET TIMEOUT \n"); |
| 84 | } else if (err_code == VE_PACKET_RECEIPT_RESTARTED) { |
| 85 | printf(" PACKET RECEIPT RESTARTED \n"); |
| 86 | } else if (err_code == VE_RUNTIME_PLAY_WARNING) { |
| 87 | printf(" RUNTIME PLAY WARNING \n"); |
| 88 | } else if (err_code == VE_RUNTIME_REC_WARNING) { |
| 89 | printf(" RUNTIME RECORD WARNING \n"); |
| 90 | } else if (err_code == VE_SATURATION_WARNING) { |
| 91 | printf(" SATURATION WARNING \n"); |
| 92 | } else if (err_code == VE_RUNTIME_PLAY_ERROR) { |
| 93 | printf(" RUNTIME PLAY ERROR \n"); |
| 94 | } else if (err_code == VE_RUNTIME_REC_ERROR) { |
| 95 | printf(" RUNTIME RECORD ERROR \n"); |
| 96 | } else if (err_code == VE_REC_DEVICE_REMOVED) { |
| 97 | printf(" RECORD DEVICE REMOVED \n"); |
| 98 | } |
| 99 | } |
| 100 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 101 | void SetStereoIfOpus(bool use_stereo, CodecInst* codec_params) { |
| 102 | if (strncmp(codec_params->plname, "opus", 4) == 0) { |
| 103 | if (use_stereo) |
| 104 | codec_params->channels = 2; |
| 105 | else |
| 106 | codec_params->channels = 1; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | void PrintCodecs(bool opus_stereo) { |
| 111 | CodecInst codec_params; |
| 112 | for (int i = 0; i < codec->NumOfCodecs(); ++i) { |
| 113 | int res = codec->GetCodec(i, codec_params); |
| 114 | VALIDATE; |
| 115 | SetStereoIfOpus(opus_stereo, &codec_params); |
| 116 | printf("%2d. %3d %s/%d/%d \n", i, codec_params.pltype, codec_params.plname, |
| 117 | codec_params.plfreq, codec_params.channels); |
| 118 | } |
| 119 | } |
| 120 | |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 121 | int main(int argc, char** argv) { |
| 122 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 123 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 124 | int res = 0; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 125 | |
| 126 | printf("Test started \n"); |
| 127 | |
minyue@webrtc.org | 0de0049 | 2013-09-30 08:43:50 +0000 | [diff] [blame^] | 128 | // TODO(minyue): Remove when the old ACM is removed (latest 2014-04-01). |
| 129 | Config config; |
| 130 | config.Set<AudioCodingModuleFactory>(FLAGS_use_acm_version_2 ? |
| 131 | new NewAudioCodingModuleFactory() : |
| 132 | new AudioCodingModuleFactory()); |
| 133 | m_voe = VoiceEngine::Create(config); |
| 134 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 135 | base1 = VoEBase::GetInterface(m_voe); |
| 136 | codec = VoECodec::GetInterface(m_voe); |
| 137 | apm = VoEAudioProcessing::GetInterface(m_voe); |
| 138 | volume = VoEVolumeControl::GetInterface(m_voe); |
| 139 | dtmf = VoEDtmf::GetInterface(m_voe); |
| 140 | rtp_rtcp = VoERTP_RTCP::GetInterface(m_voe); |
| 141 | netw = VoENetwork::GetInterface(m_voe); |
| 142 | file = VoEFile::GetInterface(m_voe); |
| 143 | vsync = VoEVideoSync::GetInterface(m_voe); |
| 144 | encr = VoEEncryption::GetInterface(m_voe); |
| 145 | hardware = VoEHardware::GetInterface(m_voe); |
| 146 | xmedia = VoEExternalMedia::GetInterface(m_voe); |
| 147 | neteqst = VoENetEqStats::GetInterface(m_voe); |
| 148 | |
| 149 | MyObserver my_observer; |
| 150 | |
| 151 | const std::string out_path = webrtc::test::OutputPath(); |
| 152 | const std::string trace_filename = out_path + "webrtc_trace.txt"; |
| 153 | |
| 154 | printf("Set trace filenames (enable trace)\n"); |
| 155 | VoiceEngine::SetTraceFilter(kTraceAll); |
| 156 | res = VoiceEngine::SetTraceFile(trace_filename.c_str()); |
| 157 | VALIDATE; |
| 158 | |
| 159 | res = VoiceEngine::SetTraceCallback(NULL); |
| 160 | VALIDATE; |
| 161 | |
| 162 | printf("Init\n"); |
| 163 | res = base1->Init(); |
| 164 | if (res != 0) { |
| 165 | printf("\nError calling Init: %d\n", base1->LastError()); |
| 166 | fflush(NULL); |
| 167 | exit(1); |
| 168 | } |
| 169 | |
| 170 | res = base1->RegisterVoiceEngineObserver(my_observer); |
| 171 | VALIDATE; |
| 172 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 173 | printf("Version\n"); |
| 174 | char tmp[1024]; |
| 175 | res = base1->GetVersion(tmp); |
| 176 | VALIDATE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 177 | printf("%s\n", tmp); |
| 178 | |
| 179 | RunTest(out_path); |
| 180 | |
| 181 | printf("Terminate \n"); |
| 182 | |
| 183 | base1->DeRegisterVoiceEngineObserver(); |
| 184 | |
| 185 | res = base1->Terminate(); |
| 186 | VALIDATE; |
| 187 | |
| 188 | if (base1) |
| 189 | base1->Release(); |
| 190 | |
| 191 | if (codec) |
| 192 | codec->Release(); |
| 193 | |
| 194 | if (volume) |
| 195 | volume->Release(); |
| 196 | |
| 197 | if (dtmf) |
| 198 | dtmf->Release(); |
| 199 | |
| 200 | if (rtp_rtcp) |
| 201 | rtp_rtcp->Release(); |
| 202 | |
| 203 | if (apm) |
| 204 | apm->Release(); |
| 205 | |
| 206 | if (netw) |
| 207 | netw->Release(); |
| 208 | |
| 209 | if (file) |
| 210 | file->Release(); |
| 211 | |
| 212 | if (vsync) |
| 213 | vsync->Release(); |
| 214 | |
| 215 | if (encr) |
| 216 | encr->Release(); |
| 217 | |
| 218 | if (hardware) |
| 219 | hardware->Release(); |
| 220 | |
| 221 | if (xmedia) |
| 222 | xmedia->Release(); |
| 223 | |
| 224 | if (neteqst) |
| 225 | neteqst->Release(); |
| 226 | |
| 227 | VoiceEngine::Delete(m_voe); |
| 228 | |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | void RunTest(std::string out_path) { |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 233 | int chan, res; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 234 | CodecInst cinst; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 235 | bool enable_aec = false; |
| 236 | bool enable_agc = false; |
| 237 | bool enable_rx_agc = false; |
| 238 | bool enable_cng = false; |
| 239 | bool enable_ns = false; |
| 240 | bool enable_rx_ns = false; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 241 | bool typing_detection = false; |
| 242 | bool muted = false; |
| 243 | bool on_hold = false; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 244 | bool opus_stereo = false; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 245 | |
| 246 | #if defined(WEBRTC_ANDROID) |
| 247 | std::string resource_path = "/sdcard/"; |
| 248 | #else |
| 249 | std::string resource_path = webrtc::test::ProjectRootPath(); |
| 250 | if (resource_path == webrtc::test::kCannotFindProjectRootDir) { |
| 251 | printf("*** Unable to get project root directory. " |
| 252 | "File playing may fail. ***\n"); |
| 253 | // Fall back to the current directory. |
| 254 | resource_path = "./"; |
| 255 | } else { |
| 256 | resource_path += "data/voice_engine/"; |
| 257 | } |
| 258 | #endif |
| 259 | const std::string audio_filename = resource_path + "audio_long16.pcm"; |
| 260 | |
| 261 | const std::string play_filename = out_path + "recorded_playout.pcm"; |
| 262 | const std::string mic_filename = out_path + "recorded_mic.pcm"; |
| 263 | |
| 264 | chan = base1->CreateChannel(); |
| 265 | if (chan < 0) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 266 | printf("************ Error code = %i\n", base1->LastError()); |
| 267 | fflush(NULL); |
| 268 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 269 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 270 | char ip[64]; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 271 | printf("1. 127.0.0.1 \n"); |
| 272 | printf("2. Specify IP \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 273 | int ip_selection; |
| 274 | ASSERT_EQ(1, scanf("%i", &ip_selection)); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 275 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 276 | if (ip_selection == 1) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 277 | strcpy(ip, "127.0.0.1"); |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 278 | } else { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 279 | printf("Specify remote IP: "); |
| 280 | ASSERT_EQ(1, scanf("%s", ip)); |
| 281 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 282 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 283 | int rPort; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 284 | printf("Specify remote port (1=1234): "); |
| 285 | ASSERT_EQ(1, scanf("%i", &rPort)); |
| 286 | if (1 == rPort) |
| 287 | rPort = 1234; |
| 288 | printf("Set Send port \n"); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 289 | |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 290 | scoped_ptr<VoiceChannelTransport> voice_channel_transport( |
| 291 | new VoiceChannelTransport(netw, chan)); |
| 292 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 293 | printf("Set Send IP \n"); |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 294 | res = voice_channel_transport->SetSendDestination(ip, rPort); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 295 | VALIDATE; |
| 296 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 297 | int lPort; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 298 | printf("Specify local port (1=1234): "); |
| 299 | ASSERT_EQ(1, scanf("%i", &lPort)); |
| 300 | if (1 == lPort) |
| 301 | lPort = 1234; |
| 302 | printf("Set Rec Port \n"); |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 303 | |
| 304 | res = voice_channel_transport->SetLocalReceiver(lPort); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 305 | VALIDATE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 306 | |
| 307 | printf("\n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 308 | PrintCodecs(opus_stereo); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 309 | printf("Select send codec: "); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 310 | int codec_selection; |
| 311 | ASSERT_EQ(1, scanf("%i", &codec_selection)); |
| 312 | codec->GetCodec(codec_selection, cinst); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 313 | |
| 314 | printf("Set primary codec\n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 315 | SetStereoIfOpus(opus_stereo, &cinst); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 316 | res = codec->SetSendCodec(chan, cinst); |
| 317 | VALIDATE; |
| 318 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 319 | const int kMaxNumChannels = 8; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 320 | int channel_index = 0; |
| 321 | std::vector<int> channels(kMaxNumChannels); |
pwestin@webrtc.org | c39749a | 2013-04-04 17:24:15 +0000 | [diff] [blame] | 322 | std::vector<VoiceChannelTransport*> voice_channel_transports(kMaxNumChannels); |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 323 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 324 | for (int i = 0; i < kMaxNumChannels; ++i) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 325 | channels[i] = base1->CreateChannel(); |
| 326 | int port = rPort + (i + 1) * 2; |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 327 | |
pwestin@webrtc.org | c39749a | 2013-04-04 17:24:15 +0000 | [diff] [blame] | 328 | voice_channel_transports[i] = new VoiceChannelTransport(netw, channels[i]); |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 329 | |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 330 | res = voice_channel_transports[i]->SetSendDestination(ip, port); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 331 | VALIDATE; |
pwestin@webrtc.org | aa922de | 2013-03-22 16:12:57 +0000 | [diff] [blame] | 332 | res = voice_channel_transports[i]->SetLocalReceiver(port); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 333 | VALIDATE; |
| 334 | res = codec->SetSendCodec(channels[i], cinst); |
| 335 | VALIDATE; |
| 336 | } |
| 337 | |
| 338 | // Call loop |
| 339 | bool newcall = true; |
| 340 | while (newcall) { |
| 341 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 342 | #ifndef WEBRTC_ANDROID |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 343 | int rd(-1), pd(-1); |
| 344 | res = hardware->GetNumOfRecordingDevices(rd); |
| 345 | VALIDATE; |
| 346 | res = hardware->GetNumOfPlayoutDevices(pd); |
| 347 | VALIDATE; |
| 348 | |
| 349 | char dn[128] = { 0 }; |
| 350 | char guid[128] = { 0 }; |
| 351 | printf("\nPlayout devices (%d): \n", pd); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 352 | for (int j = 0; j < pd; ++j) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 353 | res = hardware->GetPlayoutDeviceName(j, dn, guid); |
| 354 | VALIDATE; |
| 355 | printf(" %d: %s \n", j, dn); |
| 356 | } |
| 357 | |
| 358 | printf("Recording devices (%d): \n", rd); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 359 | for (int j = 0; j < rd; ++j) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 360 | res = hardware->GetRecordingDeviceName(j, dn, guid); |
| 361 | VALIDATE; |
| 362 | printf(" %d: %s \n", j, dn); |
| 363 | } |
| 364 | |
| 365 | printf("Select playout device: "); |
| 366 | ASSERT_EQ(1, scanf("%d", &pd)); |
| 367 | res = hardware->SetPlayoutDevice(pd); |
| 368 | VALIDATE; |
| 369 | printf("Select recording device: "); |
| 370 | ASSERT_EQ(1, scanf("%d", &rd)); |
| 371 | printf("Setting sound devices \n"); |
| 372 | res = hardware->SetRecordingDevice(rd); |
| 373 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 374 | #endif // WEBRTC_ANDROID |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 375 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 376 | res = codec->SetVADStatus(0, enable_cng); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 377 | VALIDATE; |
| 378 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 379 | res = apm->SetAgcStatus(enable_agc); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 380 | VALIDATE; |
| 381 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 382 | res = apm->SetEcStatus(enable_aec); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 383 | VALIDATE; |
| 384 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 385 | res = apm->SetNsStatus(enable_ns); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 386 | VALIDATE; |
| 387 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 388 | printf("\n1. Send, listen and playout \n"); |
| 389 | printf("2. Send only \n"); |
| 390 | printf("3. Listen and playout only \n"); |
| 391 | printf("Select transfer mode: "); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 392 | int call_selection; |
| 393 | ASSERT_EQ(1, scanf("%i", &call_selection)); |
| 394 | const bool send = !(call_selection == 3); |
| 395 | const bool receive = !(call_selection == 2); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 396 | |
| 397 | if (receive) { |
| 398 | #ifndef EXTERNAL_TRANSPORT |
| 399 | printf("Start Listen \n"); |
| 400 | res = base1->StartReceive(chan); |
| 401 | VALIDATE; |
| 402 | #endif |
| 403 | |
| 404 | printf("Start Playout \n"); |
| 405 | res = base1->StartPlayout(chan); |
| 406 | VALIDATE; |
| 407 | } |
| 408 | |
| 409 | if (send) { |
| 410 | printf("Start Send \n"); |
| 411 | res = base1->StartSend(chan); |
| 412 | VALIDATE; |
| 413 | } |
| 414 | |
| 415 | #ifndef WEBRTC_ANDROID |
| 416 | printf("Getting mic volume \n"); |
| 417 | unsigned int vol = 999; |
| 418 | res = volume->GetMicVolume(vol); |
| 419 | VALIDATE; |
| 420 | if ((vol > 255) || (vol < 1)) { |
| 421 | printf("\n****ERROR in GetMicVolume"); |
| 422 | } |
| 423 | #endif |
| 424 | |
| 425 | int forever = 1; |
| 426 | while (forever) { |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 427 | printf("\nSelect codec\n"); |
| 428 | PrintCodecs(opus_stereo); |
| 429 | printf("\nOther actions\n"); |
| 430 | const int num_codecs = codec->NumOfCodecs(); |
| 431 | int option_index = num_codecs; |
| 432 | printf("%i. Toggle CNG\n", option_index++); |
| 433 | printf("%i. Toggle AGC\n", option_index++); |
| 434 | printf("%i. Toggle NS\n", option_index++); |
| 435 | printf("%i. Toggle EC\n", option_index++); |
| 436 | printf("%i. Select AEC\n", option_index++); |
| 437 | printf("%i. Select AECM\n", option_index++); |
| 438 | printf("%i. Get speaker volume\n", option_index++); |
| 439 | printf("%i. Set speaker volume\n", option_index++); |
| 440 | printf("%i. Get microphone volume\n", option_index++); |
| 441 | printf("%i. Set microphone volume\n", option_index++); |
| 442 | printf("%i. Play local file (audio_long16.pcm) \n", option_index++); |
| 443 | printf("%i. Change playout device \n", option_index++); |
| 444 | printf("%i. Change recording device \n", option_index++); |
| 445 | printf("%i. Toggle receive-side AGC \n", option_index++); |
| 446 | printf("%i. Toggle receive-side NS \n", option_index++); |
| 447 | printf("%i. AGC status \n", option_index++); |
| 448 | printf("%i. Toggle microphone mute \n", option_index++); |
| 449 | printf("%i. Toggle on hold status \n", option_index++); |
| 450 | printf("%i. Get last error code \n", option_index++); |
| 451 | printf("%i. Toggle typing detection (for Mac/Windows only) \n", |
| 452 | option_index++); |
| 453 | printf("%i. Record a PCM file \n", option_index++); |
| 454 | printf("%i. Play a previously recorded PCM file locally \n", |
| 455 | option_index++); |
| 456 | printf("%i. Play a previously recorded PCM file as microphone \n", |
| 457 | option_index++); |
| 458 | printf("%i. Add an additional file-playing channel \n", option_index++); |
| 459 | printf("%i. Remove a file-playing channel \n", option_index++); |
| 460 | printf("%i. Toggle Opus stereo (Opus must be selected again to apply " |
| 461 | "the setting) \n", option_index++); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 462 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 463 | printf("Select action or %i to stop the call: ", option_index); |
| 464 | int option_selection; |
| 465 | ASSERT_EQ(1, scanf("%i", &option_selection)); |
| 466 | |
| 467 | option_index = num_codecs; |
| 468 | if (option_selection < option_index) { |
| 469 | res = codec->GetCodec(option_selection, cinst); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 470 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 471 | SetStereoIfOpus(opus_stereo, &cinst); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 472 | printf("Set primary codec\n"); |
| 473 | res = codec->SetSendCodec(chan, cinst); |
| 474 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 475 | } else if (option_selection == option_index++) { |
| 476 | enable_cng = !enable_cng; |
| 477 | res = codec->SetVADStatus(0, enable_cng); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 478 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 479 | if (enable_cng) |
| 480 | printf("\n CNG is now on! \n"); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 481 | else |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 482 | printf("\n CNG is now off! \n"); |
| 483 | } else if (option_selection == option_index++) { |
| 484 | enable_agc = !enable_agc; |
| 485 | res = apm->SetAgcStatus(enable_agc); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 486 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 487 | if (enable_agc) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 488 | printf("\n AGC is now on! \n"); |
| 489 | else |
| 490 | printf("\n AGC is now off! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 491 | } else if (option_selection == option_index++) { |
| 492 | enable_ns = !enable_ns; |
| 493 | res = apm->SetNsStatus(enable_ns); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 494 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 495 | if (enable_ns) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 496 | printf("\n NS is now on! \n"); |
| 497 | else |
| 498 | printf("\n NS is now off! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 499 | } else if (option_selection == option_index++) { |
| 500 | enable_aec = !enable_aec; |
| 501 | res = apm->SetEcStatus(enable_aec, kEcUnchanged); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 502 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 503 | if (enable_aec) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 504 | printf("\n Echo control is now on! \n"); |
| 505 | else |
| 506 | printf("\n Echo control is now off! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 507 | } else if (option_selection == option_index++) { |
| 508 | res = apm->SetEcStatus(enable_aec, kEcAec); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 509 | VALIDATE; |
| 510 | printf("\n AEC selected! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 511 | if (enable_aec) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 512 | printf(" (Echo control is on)\n"); |
| 513 | else |
| 514 | printf(" (Echo control is off)\n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 515 | } else if (option_selection == option_index++) { |
| 516 | res = apm->SetEcStatus(enable_aec, kEcAecm); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 517 | VALIDATE; |
| 518 | printf("\n AECM selected! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 519 | if (enable_aec) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 520 | printf(" (Echo control is on)\n"); |
| 521 | else |
| 522 | printf(" (Echo control is off)\n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 523 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 524 | unsigned vol(0); |
| 525 | res = volume->GetSpeakerVolume(vol); |
| 526 | VALIDATE; |
| 527 | printf("\n Speaker Volume is %d \n", vol); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 528 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 529 | printf("Level: "); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 530 | int level; |
| 531 | ASSERT_EQ(1, scanf("%i", &level)); |
| 532 | res = volume->SetSpeakerVolume(level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 533 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 534 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 535 | unsigned vol(0); |
| 536 | res = volume->GetMicVolume(vol); |
| 537 | VALIDATE; |
| 538 | printf("\n Microphone Volume is %d \n", vol); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 539 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 540 | printf("Level: "); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 541 | int level; |
| 542 | ASSERT_EQ(1, scanf("%i", &level)); |
| 543 | res = volume->SetMicVolume(level); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 544 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 545 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 546 | res = file->StartPlayingFileLocally(0, audio_filename.c_str()); |
| 547 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 548 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 549 | // change the playout device with current call |
| 550 | int num_pd(-1); |
| 551 | res = hardware->GetNumOfPlayoutDevices(num_pd); |
| 552 | VALIDATE; |
| 553 | |
| 554 | char dn[128] = { 0 }; |
| 555 | char guid[128] = { 0 }; |
| 556 | |
| 557 | printf("\nPlayout devices (%d): \n", num_pd); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 558 | for (int i = 0; i < num_pd; ++i) { |
| 559 | res = hardware->GetPlayoutDeviceName(i, dn, guid); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 560 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 561 | printf(" %d: %s \n", i, dn); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 562 | } |
| 563 | printf("Select playout device: "); |
| 564 | ASSERT_EQ(1, scanf("%d", &num_pd)); |
| 565 | // Will use plughw for hardware devices |
| 566 | res = hardware->SetPlayoutDevice(num_pd); |
| 567 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 568 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 569 | // change the recording device with current call |
| 570 | int num_rd(-1); |
| 571 | |
| 572 | res = hardware->GetNumOfRecordingDevices(num_rd); |
| 573 | VALIDATE; |
| 574 | |
| 575 | char dn[128] = { 0 }; |
| 576 | char guid[128] = { 0 }; |
| 577 | |
| 578 | printf("Recording devices (%d): \n", num_rd); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 579 | for (int i = 0; i < num_rd; ++i) { |
| 580 | res = hardware->GetRecordingDeviceName(i, dn, guid); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 581 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 582 | printf(" %d: %s \n", i, dn); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | printf("Select recording device: "); |
| 586 | ASSERT_EQ(1, scanf("%d", &num_rd)); |
| 587 | printf("Setting sound devices \n"); |
| 588 | // Will use plughw for hardware devices |
| 589 | res = hardware->SetRecordingDevice(num_rd); |
| 590 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 591 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 592 | // Remote AGC |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 593 | enable_rx_agc = !enable_rx_agc; |
| 594 | res = apm->SetRxAgcStatus(chan, enable_rx_agc); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 595 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 596 | if (enable_rx_agc) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 597 | printf("\n Receive-side AGC is now on! \n"); |
| 598 | else |
| 599 | printf("\n Receive-side AGC is now off! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 600 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 601 | // Remote NS |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 602 | enable_rx_ns = !enable_rx_ns; |
| 603 | res = apm->SetRxNsStatus(chan, enable_rx_ns); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 604 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 605 | if (enable_rx_ns) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 606 | printf("\n Receive-side NS is now on! \n"); |
| 607 | else |
| 608 | printf("\n Receive-side NS is now off! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 609 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 610 | AgcModes agcmode; |
| 611 | bool enable; |
| 612 | res = apm->GetAgcStatus(enable, agcmode); |
| 613 | VALIDATE |
| 614 | printf("\n AGC enable is %d, mode is %d \n", enable, agcmode); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 615 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 616 | // Toggle Mute on Microphone |
| 617 | res = volume->GetInputMute(chan, muted); |
| 618 | VALIDATE; |
| 619 | muted = !muted; |
| 620 | res = volume->SetInputMute(chan, muted); |
| 621 | VALIDATE; |
| 622 | if (muted) |
| 623 | printf("\n Microphone is now on mute! \n"); |
| 624 | else |
| 625 | printf("\n Microphone is no longer on mute! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 626 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 627 | // Toggle the call on hold |
| 628 | OnHoldModes mode; |
| 629 | res = base1->GetOnHoldStatus(chan, on_hold, mode); |
| 630 | VALIDATE; |
| 631 | on_hold = !on_hold; |
| 632 | mode = kHoldSendAndPlay; |
| 633 | res = base1->SetOnHoldStatus(chan, on_hold, mode); |
| 634 | VALIDATE; |
| 635 | if (on_hold) |
| 636 | printf("\n Call now on hold! \n"); |
| 637 | else |
| 638 | printf("\n Call now not on hold! \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 639 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 640 | // Get the last error code and print to screen |
| 641 | int err_code = 0; |
| 642 | err_code = base1->LastError(); |
| 643 | if (err_code != -1) |
| 644 | printf("\n The last error code was %i.\n", err_code); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 645 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 646 | typing_detection= !typing_detection; |
| 647 | res = apm->SetTypingDetectionStatus(typing_detection); |
| 648 | VALIDATE; |
| 649 | if (typing_detection) |
| 650 | printf("\n Typing detection is now on!\n"); |
| 651 | else |
| 652 | printf("\n Typing detection is now off!\n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 653 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 654 | int stop_record = 1; |
| 655 | int file_source = 1; |
| 656 | printf("\n Select source of recorded file. "); |
| 657 | printf("\n 1. Record from microphone to file "); |
| 658 | printf("\n 2. Record from playout to file "); |
| 659 | printf("\n Enter your selection: \n"); |
| 660 | ASSERT_EQ(1, scanf("%i", &file_source)); |
| 661 | if (file_source == 1) { |
| 662 | printf("\n Start recording microphone as %s \n", |
| 663 | mic_filename.c_str()); |
| 664 | res = file->StartRecordingMicrophone(mic_filename.c_str()); |
| 665 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 666 | } else { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 667 | printf("\n Start recording playout as %s \n", play_filename.c_str()); |
| 668 | res = file->StartRecordingPlayout(chan, play_filename.c_str()); |
| 669 | VALIDATE; |
| 670 | } |
| 671 | while (stop_record != 0) { |
| 672 | printf("\n Type 0 to stop recording file \n"); |
| 673 | ASSERT_EQ(1, scanf("%i", &stop_record)); |
| 674 | } |
| 675 | if (file_source == 1) { |
| 676 | res = file->StopRecordingMicrophone(); |
| 677 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 678 | } else { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 679 | res = file->StopRecordingPlayout(chan); |
| 680 | VALIDATE; |
| 681 | } |
| 682 | printf("\n File finished recording \n"); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 683 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 684 | int file_type = 1; |
| 685 | int stop_play = 1; |
| 686 | printf("\n Select a file to play locally in a loop."); |
| 687 | printf("\n 1. Play %s", mic_filename.c_str()); |
| 688 | printf("\n 2. Play %s", play_filename.c_str()); |
| 689 | printf("\n Enter your selection\n"); |
| 690 | ASSERT_EQ(1, scanf("%i", &file_type)); |
| 691 | if (file_type == 1) { |
| 692 | printf("\n Start playing %s locally in a loop\n", |
| 693 | mic_filename.c_str()); |
| 694 | res = file->StartPlayingFileLocally(chan, mic_filename.c_str(), true); |
| 695 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 696 | } else { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 697 | printf("\n Start playing %s locally in a loop\n", |
| 698 | play_filename.c_str()); |
| 699 | res = file->StartPlayingFileLocally(chan, play_filename.c_str(), |
| 700 | true); |
| 701 | VALIDATE; |
| 702 | } |
| 703 | while (stop_play != 0) { |
| 704 | printf("\n Type 0 to stop playing file\n"); |
| 705 | ASSERT_EQ(1, scanf("%i", &stop_play)); |
| 706 | } |
| 707 | res = file->StopPlayingFileLocally(chan); |
| 708 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 709 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 710 | int file_type = 1; |
| 711 | int stop_play = 1; |
| 712 | printf("\n Select a file to play as microphone in a loop."); |
| 713 | printf("\n 1. Play %s", mic_filename.c_str()); |
| 714 | printf("\n 2. Play %s", play_filename.c_str()); |
| 715 | printf("\n Enter your selection\n"); |
| 716 | ASSERT_EQ(1, scanf("%i", &file_type)); |
| 717 | if (file_type == 1) { |
| 718 | printf("\n Start playing %s as mic in a loop\n", |
| 719 | mic_filename.c_str()); |
| 720 | res = file->StartPlayingFileAsMicrophone(chan, mic_filename.c_str(), |
| 721 | true); |
| 722 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 723 | } else { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 724 | printf("\n Start playing %s as mic in a loop\n", |
| 725 | play_filename.c_str()); |
| 726 | res = file->StartPlayingFileAsMicrophone(chan, play_filename.c_str(), |
| 727 | true); |
| 728 | VALIDATE; |
| 729 | } |
| 730 | while (stop_play != 0) { |
| 731 | printf("\n Type 0 to stop playing file\n"); |
| 732 | ASSERT_EQ(1, scanf("%i", &stop_play)); |
| 733 | } |
| 734 | res = file->StopPlayingFileAsMicrophone(chan); |
| 735 | VALIDATE; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 736 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 737 | if (channel_index < kMaxNumChannels) { |
| 738 | res = base1->StartReceive(channels[channel_index]); |
| 739 | VALIDATE; |
| 740 | res = base1->StartPlayout(channels[channel_index]); |
| 741 | VALIDATE; |
| 742 | res = base1->StartSend(channels[channel_index]); |
| 743 | VALIDATE; |
| 744 | res = file->StartPlayingFileAsMicrophone(channels[channel_index], |
| 745 | audio_filename.c_str(), |
| 746 | true, |
| 747 | false); |
| 748 | VALIDATE; |
| 749 | channel_index++; |
| 750 | printf("Using %d additional channels\n", channel_index); |
| 751 | } else { |
| 752 | printf("Max number of channels reached\n"); |
| 753 | } |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 754 | } else if (option_selection == option_index++) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 755 | if (channel_index > 0) { |
| 756 | channel_index--; |
| 757 | res = file->StopPlayingFileAsMicrophone(channels[channel_index]); |
| 758 | VALIDATE; |
| 759 | res = base1->StopSend(channels[channel_index]); |
| 760 | VALIDATE; |
| 761 | res = base1->StopPlayout(channels[channel_index]); |
| 762 | VALIDATE; |
| 763 | res = base1->StopReceive(channels[channel_index]); |
| 764 | VALIDATE; |
| 765 | printf("Using %d additional channels\n", channel_index); |
| 766 | } else { |
| 767 | printf("All additional channels stopped\n"); |
| 768 | } |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 769 | } else if (option_selection == option_index++) { |
| 770 | opus_stereo = !opus_stereo; |
| 771 | if (opus_stereo) |
| 772 | printf("\n Opus stereo enabled (select Opus again to apply the " |
| 773 | "setting). \n"); |
| 774 | else |
| 775 | printf("\n Opus mono enabled (select Opus again to apply the " |
| 776 | "setting). \n"); |
| 777 | } else { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 778 | break; |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 779 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | if (send) { |
| 783 | printf("Stop Send \n"); |
| 784 | res = base1->StopSend(chan); |
| 785 | VALIDATE; |
| 786 | } |
| 787 | |
| 788 | if (receive) { |
| 789 | printf("Stop Playout \n"); |
| 790 | res = base1->StopPlayout(chan); |
| 791 | VALIDATE; |
| 792 | |
| 793 | #ifndef EXTERNAL_TRANSPORT |
| 794 | printf("Stop Listen \n"); |
| 795 | res = base1->StopReceive(chan); |
| 796 | VALIDATE; |
| 797 | #endif |
| 798 | } |
| 799 | |
| 800 | while (channel_index > 0) { |
| 801 | --channel_index; |
| 802 | res = file->StopPlayingFileAsMicrophone(channels[channel_index]); |
| 803 | VALIDATE; |
| 804 | res = base1->StopSend(channels[channel_index]); |
| 805 | VALIDATE; |
| 806 | res = base1->StopPlayout(channels[channel_index]); |
| 807 | VALIDATE; |
| 808 | res = base1->StopReceive(channels[channel_index]); |
| 809 | VALIDATE; |
| 810 | } |
| 811 | |
| 812 | printf("\n1. New call \n"); |
| 813 | printf("2. Quit \n"); |
| 814 | printf("Select action: "); |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 815 | int end_option; |
| 816 | ASSERT_EQ(1, scanf("%i", &end_option)); |
| 817 | newcall = (end_option == 1); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 818 | // Call loop |
| 819 | } |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 820 | for (int i = 0; i < kMaxNumChannels; ++i) { |
pwestin@webrtc.org | c39749a | 2013-04-04 17:24:15 +0000 | [diff] [blame] | 821 | delete voice_channel_transports[i]; |
| 822 | voice_channel_transports[i] = NULL; |
| 823 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 824 | |
| 825 | printf("Delete channels \n"); |
| 826 | res = base1->DeleteChannel(chan); |
| 827 | VALIDATE; |
| 828 | |
andrew@webrtc.org | c0fc487 | 2013-05-02 15:57:36 +0000 | [diff] [blame] | 829 | for (int i = 0; i < kMaxNumChannels; ++i) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 830 | channels[i] = base1->DeleteChannel(channels[i]); |
| 831 | VALIDATE; |
| 832 | } |
| 833 | } |