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 <math.h> 12 #include "webrtc/test/testsupport/fileutils.h" 13 #include "webrtc/voice_engine/test/win_test/WinTest.h" 14 #include "webrtc/voice_engine/test/win_test/WinTestDlg.h" 15 #include "webrtc/voice_engine/test/win_test/stdafx.h" 16 17 #ifdef _DEBUG 18 #define new DEBUG_NEW 19 #endif 20 21 using namespace webrtc; 22 23 unsigned char key[30] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 24 25 // Hack to convert char to TCHAR, using two buffers to be able to 26 // call twice in the same statement 27 TCHAR convertTemp1[256] = {0}; 28 TCHAR convertTemp2[256] = {0}; 29 bool convertBufferSwitch(false); 30 TCHAR* CharToTchar(const char* str, int len) 31 { 32 #ifdef _UNICODE 33 TCHAR* temp = convertBufferSwitch ? convertTemp1 : convertTemp2; 34 convertBufferSwitch = !convertBufferSwitch; 35 memset(temp, 0, sizeof(convertTemp1)); 36 MultiByteToWideChar(CP_UTF8, 0, str, len, temp, 256); 37 return temp; 38 #else 39 return str; 40 #endif 41 } 42 43 // Hack to convert TCHAR to char 44 char convertTemp3[256] = {0}; 45 char* TcharToChar(TCHAR* str, int len) 46 { 47 #ifdef _UNICODE 48 memset(convertTemp3, 0, sizeof(convertTemp3)); 49 WideCharToMultiByte(CP_UTF8, 0, str, len, convertTemp3, 256, 0, 0); 50 return convertTemp3; 51 #else 52 return str; 53 #endif 54 } 55 56 // ---------------------------------------------------------------------------- 57 // VoEConnectionObserver 58 // ---------------------------------------------------------------------------- 59 60 class ConnectionObserver : public VoEConnectionObserver 61 { 62 public: 63 ConnectionObserver(); 64 virtual void OnPeriodicDeadOrAlive(int channel, bool alive); 65 }; 66 67 ConnectionObserver::ConnectionObserver() 68 { 69 } 70 71 void ConnectionObserver::OnPeriodicDeadOrAlive(int channel, bool alive) 72 { 73 CString str; 74 str.Format(_T("OnPeriodicDeadOrAlive(channel=%d) => alive=%d"), channel, alive); 75 OutputDebugString(str); 76 } 77 78 // ---------------------------------------------------------------------------- 79 // VoiceEngineObserver 80 // ---------------------------------------------------------------------------- 81 82 void CWinTestDlg::CallbackOnError(int channel, int errCode) 83 { 84 _nErrorCallbacks++; 85 86 CString str; 87 str.Format(_T("[#%d] CallbackOnError(channel=%d) => errCode = %d"), _nErrorCallbacks, channel, errCode); 88 if (errCode == VE_RECEIVE_PACKET_TIMEOUT) 89 { 90 str += _T(" <=> VE_RECEIVE_PACKET_TIMEOUT"); 91 } 92 else if (errCode == VE_PACKET_RECEIPT_RESTARTED) 93 { 94 str += _T(" <=> VE_PACKET_RECEIPT_RESTARTED"); 95 } 96 else if (errCode == VE_RUNTIME_PLAY_WARNING) 97 { 98 str += _T(" <=> VE_RUNTIME_PLAY_WARNING"); 99 } 100 else if (errCode == VE_RUNTIME_REC_WARNING) 101 { 102 str += _T(" <=> VE_RUNTIME_REC_WARNING"); 103 } 104 else if (errCode == VE_RUNTIME_PLAY_ERROR) 105 { 106 str += _T(" <=> VE_RUNTIME_PLAY_ERROR"); 107 } 108 else if (errCode == VE_RUNTIME_REC_ERROR) 109 { 110 str += _T(" <=> VE_RUNTIME_REC_ERROR"); 111 } 112 else if (errCode == VE_SATURATION_WARNING) 113 { 114 str += _T(" <=> VE_SATURATION_WARNING"); 115 } 116 else if (errCode == VE_TYPING_NOISE_WARNING) 117 { 118 str += _T(" <=> VE_TYPING_NOISE_WARNING"); 119 } 120 else if (errCode == VE_REC_DEVICE_REMOVED) 121 { 122 str += _T(" <=> VE_REC_DEVICE_REMOVED"); 123 } 124 // AfxMessageBox((LPCTSTR)str, MB_OK); 125 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, (LPCTSTR)str); 126 } 127 128 // ---------------------------------------------------------------------------- 129 // VoERTPObserver 130 // ---------------------------------------------------------------------------- 131 132 void CWinTestDlg::OnIncomingCSRCChanged(int channel, unsigned int CSRC, bool added) 133 { 134 CString str; 135 str.Format(_T("OnIncomingCSRCChanged(channel=%d) => CSRC=%u, added=%d"), channel, CSRC, added); 136 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, (LPCTSTR)str); 137 } 138 139 void CWinTestDlg::OnIncomingSSRCChanged(int channel, unsigned int SSRC) 140 { 141 CString str; 142 str.Format(_T("OnIncomingSSRCChanged(channel=%d) => SSRC=%u"), channel, SSRC); 143 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, (LPCTSTR)str); 144 } 145 146 // ---------------------------------------------------------------------------- 147 // Transport 148 // ---------------------------------------------------------------------------- 149 150 class MyTransport : public Transport 151 { 152 public: 153 MyTransport(VoENetwork* veNetwork); 154 virtual int SendPacket(int channel, const void *data, int len); 155 virtual int SendRTCPPacket(int channel, const void *data, int len); 156 private: 157 VoENetwork* _veNetworkPtr; 158 }; 159 160 MyTransport::MyTransport(VoENetwork* veNetwork) : 161 _veNetworkPtr(veNetwork) 162 { 163 } 164 165 int 166 MyTransport::SendPacket(int channel, const void *data, int len) 167 { 168 _veNetworkPtr->ReceivedRTPPacket(channel, data, len); 169 return len; 170 } 171 172 int 173 MyTransport::SendRTCPPacket(int channel, const void *data, int len) 174 { 175 _veNetworkPtr->ReceivedRTCPPacket(channel, data, len); 176 return len; 177 } 178 179 // ---------------------------------------------------------------------------- 180 // VoEMediaProcess 181 // ---------------------------------------------------------------------------- 182 183 class MediaProcessImpl : public VoEMediaProcess 184 { 185 public: 186 MediaProcessImpl(); 187 virtual void Process(int channel, 188 ProcessingTypes type, 189 int16_t audio_10ms[], 190 int length, 191 int samplingFreqHz, 192 bool stereo); 193 }; 194 195 MediaProcessImpl::MediaProcessImpl() 196 { 197 } 198 199 void MediaProcessImpl::Process(int channel, 200 ProcessingTypes type, 201 int16_t audio_10ms[], 202 int length, 203 int samplingFreqHz, 204 bool stereo) 205 { 206 int x = rand() % 100; 207 208 for (int i = 0; i < length; i++) 209 { 210 if (channel == -1) 211 { 212 if (type == kPlaybackAllChannelsMixed) 213 { 214 // playout: scale up 215 if (!stereo) 216 { 217 audio_10ms[i] = (audio_10ms[i] << 2); 218 } 219 else 220 { 221 audio_10ms[2*i] = (audio_10ms[2*i] << 2); 222 audio_10ms[2*i+1] = (audio_10ms[2*i+1] << 2); 223 } 224 } 225 else 226 { 227 // recording: emulate packet loss by "dropping" 10% of the packets 228 if (x >= 0 && x < 10) 229 { 230 if (!stereo) 231 { 232 audio_10ms[i] = 0; 233 } 234 else 235 { 236 audio_10ms[2*i] = 0; 237 audio_10ms[2*i+1] = 0; 238 } 239 } 240 } 241 } 242 else 243 { 244 if (type == kPlaybackPerChannel) 245 { 246 // playout: mute 247 if (!stereo) 248 { 249 audio_10ms[i] = 0; 250 } 251 else 252 { 253 audio_10ms[2*i] = 0; 254 audio_10ms[2*i+1] = 0; 255 } 256 } 257 else 258 { 259 // recording: emulate packet loss by "dropping" 50% of the packets 260 if (x >= 0 && x < 50) 261 { 262 if (!stereo) 263 { 264 audio_10ms[i] = 0; 265 } 266 else 267 { 268 audio_10ms[2*i] = 0; 269 audio_10ms[2*i+1] = 0; 270 } 271 } 272 } 273 } 274 } 275 } 276 277 // ---------------------------------------------------------------------------- 278 // TelephoneEventObserver 279 // ---------------------------------------------------------------------------- 280 281 class TelephoneEventObserver: public VoETelephoneEventObserver 282 { 283 public: 284 TelephoneEventObserver(CWnd* editControlOut, CWnd* editControlIn); 285 virtual void OnReceivedTelephoneEventInband(int channel, int eventCode, 286 bool endOfEvent); 287 virtual void OnReceivedTelephoneEventOutOfBand(int channel, int eventCode, 288 bool endOfEvent); 289 private: 290 CWnd* _editControlOutPtr; 291 CWnd* _editControlInPtr; 292 }; 293 294 TelephoneEventObserver::TelephoneEventObserver(CWnd* editControlOut, CWnd* editControlIn) : 295 _editControlOutPtr(editControlOut), 296 _editControlInPtr(editControlIn) 297 { 298 } 299 300 void TelephoneEventObserver::OnReceivedTelephoneEventInband(int channel, 301 int eventCode, 302 bool endOfEvent) 303 { 304 CString msg; 305 if (endOfEvent) 306 { 307 msg.AppendFormat(_T("%d [END]"), eventCode); 308 _editControlInPtr->SetWindowText((LPCTSTR)msg); 309 } 310 else 311 { 312 msg.AppendFormat(_T("%d [START]"), eventCode); 313 _editControlInPtr->SetWindowText((LPCTSTR)msg); 314 } 315 } 316 317 void TelephoneEventObserver::OnReceivedTelephoneEventOutOfBand(int channel, 318 int eventCode, 319 bool endOfEvent) 320 { 321 CString msg; 322 if (endOfEvent) 323 { 324 msg.AppendFormat(_T("%d [END]"), eventCode); 325 _editControlOutPtr->SetWindowText((LPCTSTR)msg); 326 } 327 else 328 { 329 msg.AppendFormat(_T("%d [START]"), eventCode); 330 _editControlOutPtr->SetWindowText((LPCTSTR)msg); 331 } 332 } 333 334 // ---------------------------------------------------------------------------- 335 // RxVadCallback 336 // ---------------------------------------------------------------------------- 337 338 class RxCallback : public VoERxVadCallback 339 { 340 public: 341 RxCallback() : vad_decision(-1) {}; 342 343 virtual void OnRxVad(int , int vadDecision) 344 { 345 vad_decision = vadDecision; 346 } 347 348 int vad_decision; 349 }; 350 351 // ---------------------------------------------------------------------------- 352 // CAboutDlg dialog 353 // ---------------------------------------------------------------------------- 354 355 class CAboutDlg : public CDialog 356 { 357 public: 358 CAboutDlg(); 359 360 // Dialog Data 361 enum { IDD = IDD_ABOUTBOX }; 362 363 protected: 364 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 365 366 // Implementation 367 protected: 368 DECLARE_MESSAGE_MAP() 369 }; 370 371 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 372 { 373 } 374 375 void CAboutDlg::DoDataExchange(CDataExchange* pDX) 376 { 377 CDialog::DoDataExchange(pDX); 378 } 379 380 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 381 END_MESSAGE_MAP() 382 383 // ---------------------------------------------------------------------------- 384 // CTelephonyEvent dialog 385 // ---------------------------------------------------------------------------- 386 387 class CTelephonyEvent : public CDialog 388 { 389 DECLARE_DYNAMIC(CTelephonyEvent) 390 391 public: 392 CTelephonyEvent(VoiceEngine* voiceEngine, int channel, CDialog* pParentDialog, CWnd* pParent = NULL); // standard constructor 393 virtual ~CTelephonyEvent(); 394 395 // Dialog Data 396 enum { IDD = IDD_DTMF_DIALOG }; 397 398 protected: 399 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 400 virtual BOOL OnInitDialog(); 401 402 DECLARE_MESSAGE_MAP() 403 public: 404 afx_msg void OnBnClickedButton1(); 405 afx_msg void OnBnClickedButton2(); 406 afx_msg void OnBnClickedButton3(); 407 afx_msg void OnBnClickedButton4(); 408 afx_msg void OnBnClickedButton5(); 409 afx_msg void OnBnClickedButton6(); 410 afx_msg void OnBnClickedButton7(); 411 afx_msg void OnBnClickedButton8(); 412 afx_msg void OnBnClickedButton9(); 413 afx_msg void OnBnClickedButton10(); 414 afx_msg void OnBnClickedButton11(); 415 afx_msg void OnBnClickedButton12(); 416 afx_msg void OnBnClickedButtonA(); 417 afx_msg void OnBnClickedButtonB(); 418 afx_msg void OnBnClickedButtonC(); 419 afx_msg void OnBnClickedButtonD(); 420 afx_msg void OnBnClickedCheckDtmfPlayoutRx(); 421 afx_msg void OnBnClickedCheckDtmfPlayTone(); 422 afx_msg void OnBnClickedCheckStartStopMode(); 423 afx_msg void OnBnClickedCheckEventInband(); 424 afx_msg void OnBnClickedCheckDtmfFeedback(); 425 afx_msg void OnBnClickedCheckDirectFeedback(); 426 afx_msg void OnBnClickedRadioSingle(); 427 afx_msg void OnBnClickedRadioMulti(); 428 afx_msg void OnBnClickedRadioStartStop(); 429 afx_msg void OnBnClickedButtonSetRxTelephonePt(); 430 afx_msg void OnBnClickedButtonSetTxTelephonePt(); 431 afx_msg void OnBnClickedButtonSendTelephoneEvent(); 432 afx_msg void OnBnClickedCheckDetectInband(); 433 afx_msg void OnBnClickedCheckDetectOutOfBand(); 434 afx_msg void OnBnClickedCheckEventDetection(); 435 436 private: 437 void SendTelephoneEvent(unsigned char eventCode); 438 439 private: 440 VoiceEngine* _vePtr; 441 VoEBase* _veBasePtr; 442 VoEDtmf* _veDTMFPtr; 443 VoECodec* _veCodecPtr; 444 int _channel; 445 CString _strMsg; 446 CDialog* _parentDialogPtr; 447 TelephoneEventObserver* _telephoneEventObserverPtr; 448 bool _PlayDtmfToneLocally; 449 bool _modeStartStop; 450 bool _modeSingle; 451 bool _modeSequence; 452 bool _playingDTMFTone; 453 bool _outOfBandEventDetection; 454 bool _inbandEventDetection; 455 }; 456 457 IMPLEMENT_DYNAMIC(CTelephonyEvent, CDialog) 458 459 CTelephonyEvent::CTelephonyEvent(VoiceEngine* voiceEngine, 460 int channel, 461 CDialog* pParentDialog, 462 CWnd* pParent /*=NULL*/) 463 : _vePtr(voiceEngine), 464 _channel(channel), 465 _PlayDtmfToneLocally(false), 466 _modeStartStop(false), 467 _modeSingle(true), 468 _modeSequence(false), 469 _playingDTMFTone(false), 470 _outOfBandEventDetection(true), 471 _inbandEventDetection(false), 472 _parentDialogPtr(pParentDialog), 473 _telephoneEventObserverPtr(NULL), 474 CDialog(CTelephonyEvent::IDD, pParent) 475 { 476 _veBasePtr = VoEBase::GetInterface(_vePtr); 477 _veDTMFPtr = VoEDtmf::GetInterface(_vePtr); 478 _veCodecPtr = VoECodec::GetInterface(_vePtr); 479 } 480 481 CTelephonyEvent::~CTelephonyEvent() 482 { 483 _veDTMFPtr->Release(); 484 _veCodecPtr->Release(); 485 _veBasePtr->Release(); 486 487 if (_telephoneEventObserverPtr) 488 { 489 _veDTMFPtr->DeRegisterTelephoneEventDetection(_channel); 490 delete _telephoneEventObserverPtr; 491 _telephoneEventObserverPtr = NULL; 492 } 493 } 494 495 void CTelephonyEvent::DoDataExchange(CDataExchange* pDX) 496 { 497 CDialog::DoDataExchange(pDX); 498 } 499 500 501 BEGIN_MESSAGE_MAP(CTelephonyEvent, CDialog) 502 ON_BN_CLICKED(IDC_BUTTON_1, &CTelephonyEvent::OnBnClickedButton1) 503 ON_BN_CLICKED(IDC_BUTTON_2, &CTelephonyEvent::OnBnClickedButton2) 504 ON_BN_CLICKED(IDC_BUTTON_3, &CTelephonyEvent::OnBnClickedButton3) 505 ON_BN_CLICKED(IDC_BUTTON_4, &CTelephonyEvent::OnBnClickedButton4) 506 ON_BN_CLICKED(IDC_BUTTON_5, &CTelephonyEvent::OnBnClickedButton5) 507 ON_BN_CLICKED(IDC_BUTTON_6, &CTelephonyEvent::OnBnClickedButton6) 508 ON_BN_CLICKED(IDC_BUTTON_7, &CTelephonyEvent::OnBnClickedButton7) 509 ON_BN_CLICKED(IDC_BUTTON_8, &CTelephonyEvent::OnBnClickedButton8) 510 ON_BN_CLICKED(IDC_BUTTON_9, &CTelephonyEvent::OnBnClickedButton9) 511 ON_BN_CLICKED(IDC_BUTTON_10, &CTelephonyEvent::OnBnClickedButton10) 512 ON_BN_CLICKED(IDC_BUTTON_11, &CTelephonyEvent::OnBnClickedButton11) 513 ON_BN_CLICKED(IDC_BUTTON_12, &CTelephonyEvent::OnBnClickedButton12) 514 ON_BN_CLICKED(IDC_BUTTON_13, &CTelephonyEvent::OnBnClickedButtonA) 515 ON_BN_CLICKED(IDC_BUTTON_14, &CTelephonyEvent::OnBnClickedButtonB) 516 ON_BN_CLICKED(IDC_BUTTON_15, &CTelephonyEvent::OnBnClickedButtonC) 517 ON_BN_CLICKED(IDC_BUTTON_16, &CTelephonyEvent::OnBnClickedButtonD) 518 ON_BN_CLICKED(IDC_CHECK_DTMF_PLAYOUT_RX, &CTelephonyEvent::OnBnClickedCheckDtmfPlayoutRx) 519 ON_BN_CLICKED(IDC_CHECK_DTMF_PLAY_TONE, &CTelephonyEvent::OnBnClickedCheckDtmfPlayTone) 520 ON_BN_CLICKED(IDC_CHECK_EVENT_INBAND, &CTelephonyEvent::OnBnClickedCheckEventInband) 521 ON_BN_CLICKED(IDC_CHECK_DTMF_FEEDBACK, &CTelephonyEvent::OnBnClickedCheckDtmfFeedback) 522 ON_BN_CLICKED(IDC_CHECK_DIRECT_FEEDBACK, &CTelephonyEvent::OnBnClickedCheckDirectFeedback) 523 ON_BN_CLICKED(IDC_RADIO_SINGLE, &CTelephonyEvent::OnBnClickedRadioSingle) 524 ON_BN_CLICKED(IDC_RADIO_MULTI, &CTelephonyEvent::OnBnClickedRadioMulti) 525 ON_BN_CLICKED(IDC_RADIO_START_STOP, &CTelephonyEvent::OnBnClickedRadioStartStop) 526 ON_BN_CLICKED(IDC_BUTTON_SET_RX_TELEPHONE_PT, &CTelephonyEvent::OnBnClickedButtonSetRxTelephonePt) 527 ON_BN_CLICKED(IDC_BUTTON_SET_TX_TELEPHONE_PT, &CTelephonyEvent::OnBnClickedButtonSetTxTelephonePt) 528 ON_BN_CLICKED(IDC_BUTTON_SEND_TELEPHONE_EVENT, &CTelephonyEvent::OnBnClickedButtonSendTelephoneEvent) 529 ON_BN_CLICKED(IDC_CHECK_DETECT_INBAND, &CTelephonyEvent::OnBnClickedCheckDetectInband) 530 ON_BN_CLICKED(IDC_CHECK_DETECT_OUT_OF_BAND, &CTelephonyEvent::OnBnClickedCheckDetectOutOfBand) 531 ON_BN_CLICKED(IDC_CHECK_EVENT_DETECTION, &CTelephonyEvent::OnBnClickedCheckEventDetection) 532 END_MESSAGE_MAP() 533 534 535 // CTelephonyEvent message handlers 536 537 BOOL CTelephonyEvent::OnInitDialog() 538 { 539 CDialog::OnInitDialog(); 540 541 CString str; 542 GetWindowText(str); 543 str.AppendFormat(_T(" [channel = %d]"), _channel); 544 SetWindowText(str); 545 546 // Update dialog with latest playout state 547 bool enabled(false); 548 _veDTMFPtr->GetDtmfPlayoutStatus(_channel, enabled); 549 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_PLAYOUT_RX); 550 button->SetCheck(enabled ? BST_CHECKED : BST_UNCHECKED); 551 552 // Update dialog with latest feedback state 553 bool directFeedback(false); 554 _veDTMFPtr->GetDtmfFeedbackStatus(enabled, directFeedback); 555 button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_FEEDBACK); 556 button->SetCheck(enabled ? BST_CHECKED : BST_UNCHECKED); 557 button = (CButton*)GetDlgItem(IDC_CHECK_DIRECT_FEEDBACK); 558 button->SetCheck(directFeedback ? BST_CHECKED : BST_UNCHECKED); 559 560 // Default event length is 160 ms 561 SetDlgItemInt(IDC_EDIT_EVENT_LENGTH, 160); 562 563 // Default event attenuation is 10 (<-> -10dBm0) 564 SetDlgItemInt(IDC_EDIT_EVENT_ATTENUATION, 10); 565 566 // Current event-detection status 567 TelephoneEventDetectionMethods detectionMethod(kOutOfBand); 568 if (_veDTMFPtr->GetTelephoneEventDetectionStatus(_channel, enabled, detectionMethod) == 0) 569 { 570 // DTMF detection is supported 571 if (enabled) 572 { 573 button = (CButton*)GetDlgItem(IDC_CHECK_EVENT_DETECTION); 574 button->SetCheck(BST_CHECKED); 575 } 576 if (detectionMethod == kOutOfBand || detectionMethod == kInAndOutOfBand) 577 { 578 button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_OUT_OF_BAND); 579 button->SetCheck(BST_CHECKED); 580 } 581 if (detectionMethod == kInBand || detectionMethod == kInAndOutOfBand) 582 { 583 button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_INBAND); 584 button->SetCheck(BST_CHECKED); 585 } 586 } 587 else 588 { 589 // DTMF detection is not supported 590 GetDlgItem(IDC_CHECK_EVENT_DETECTION)->EnableWindow(FALSE); 591 GetDlgItem(IDC_CHECK_DETECT_OUT_OF_BAND)->EnableWindow(FALSE); 592 GetDlgItem(IDC_CHECK_DETECT_INBAND)->EnableWindow(FALSE); 593 GetDlgItem(IDC_EDIT_ON_EVENT_INBAND)->EnableWindow(FALSE); 594 GetDlgItem(IDC_EDIT_ON_EVENT_OUT_OF_BAND)->EnableWindow(FALSE); 595 } 596 597 // Telephone-event PTs 598 unsigned char pt(0); 599 _veDTMFPtr->GetSendTelephoneEventPayloadType(_channel, pt); 600 SetDlgItemInt(IDC_EDIT_EVENT_TX_PT, pt); 601 602 CodecInst codec; 603 strcpy_s(codec.plname, 32, "telephone-event"); codec.channels = 1; codec.plfreq = 8000; 604 _veCodecPtr->GetRecPayloadType(_channel, codec); 605 SetDlgItemInt(IDC_EDIT_EVENT_RX_PT, codec.pltype); 606 607 if (_modeSingle) 608 { 609 ((CButton*)GetDlgItem(IDC_RADIO_SINGLE))->SetCheck(BST_CHECKED); 610 } 611 else if (_modeStartStop) 612 { 613 ((CButton*)GetDlgItem(IDC_RADIO_START_STOP))->SetCheck(BST_CHECKED); 614 } 615 else if (_modeSequence) 616 { 617 ((CButton*)GetDlgItem(IDC_RADIO_MULTI))->SetCheck(BST_CHECKED); 618 } 619 620 return TRUE; // return TRUE unless you set the focus to a control 621 } 622 void CTelephonyEvent::SendTelephoneEvent(unsigned char eventCode) 623 { 624 BOOL ret; 625 int lengthMs(0); 626 int attenuationDb(0); 627 bool outBand(false); 628 int res(0); 629 630 // tone length 631 if (!_modeStartStop) 632 { 633 lengthMs = GetDlgItemInt(IDC_EDIT_EVENT_LENGTH, &ret); 634 if (ret == FALSE) 635 { 636 // use default length if edit field is empty 637 lengthMs = 160; 638 } 639 } 640 641 // attenuation 642 attenuationDb = GetDlgItemInt(IDC_EDIT_EVENT_ATTENUATION, &ret); 643 if (ret == FALSE) 644 { 645 // use default length if edit field is empty 646 attenuationDb = 10; 647 } 648 649 // out-band or in-band 650 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EVENT_INBAND); 651 int check = button->GetCheck(); 652 outBand = (check == BST_UNCHECKED); 653 654 if (eventCode < 16) 655 SetDlgItemInt(IDC_EDIT_DTMF_EVENT, eventCode); 656 657 if (_PlayDtmfToneLocally) 658 { 659 // --- PlayDtmfTone 660 661 if (_modeSingle) 662 { 663 TEST2(_veDTMFPtr->PlayDtmfTone(eventCode, lengthMs, attenuationDb) == 0, 664 _T("PlayDtmfTone(eventCode=%u, lengthMs=%d, attenuationDb=%d)"), eventCode, lengthMs, attenuationDb); 665 } 666 else if (_modeStartStop) 667 { 668 if (!_playingDTMFTone) 669 { 670 TEST2((res = _veDTMFPtr->StartPlayingDtmfTone(eventCode, attenuationDb)) == 0, 671 _T("StartPlayingDtmfTone(eventCode=%u, attenuationDb=%d)"), eventCode, attenuationDb); 672 } 673 else 674 { 675 TEST2((res = _veDTMFPtr->StopPlayingDtmfTone()) == 0, 676 _T("StopPlayingDTMFTone()")); 677 } 678 if (res == 0) 679 _playingDTMFTone = !_playingDTMFTone; 680 } 681 else if (_modeSequence) 682 { 683 int nTones(1); 684 int sleepMs(0); 685 int lenMult(1); 686 if (eventCode == 1) 687 { 688 nTones = 2; 689 sleepMs = lengthMs; 690 lenMult = 1; 691 } 692 else if (eventCode == 2) 693 { 694 nTones = 2; 695 sleepMs = lengthMs/2; 696 lenMult = 2; 697 } 698 else if (eventCode == 3) 699 { 700 nTones = 3; 701 sleepMs = 0; 702 lenMult = 1; 703 } 704 for (int i = 0; i < nTones; i++) 705 { 706 TEST2(_veDTMFPtr->PlayDtmfTone(eventCode, lengthMs, attenuationDb) == 0, 707 _T("PlayDtmfTone(eventCode=%u, outBand=%d, lengthMs=%d, attenuationDb=%d)"), eventCode, lengthMs, attenuationDb); 708 Sleep(sleepMs); 709 lengthMs = lenMult*lengthMs; 710 eventCode++; 711 } 712 } 713 } 714 else 715 { 716 // --- SendTelephoneEvent 717 718 if (_modeSingle) 719 { 720 TEST2(_veDTMFPtr->SendTelephoneEvent(_channel, eventCode, outBand, lengthMs, attenuationDb) == 0, 721 _T("SendTelephoneEvent(channel=%d, eventCode=%u, outBand=%d, lengthMs=%d, attenuationDb=%d)"), _channel, eventCode, outBand, lengthMs, attenuationDb); 722 } 723 else if (_modeStartStop) 724 { 725 TEST2(false, _T("*** NOT IMPLEMENTED ***")); 726 } 727 else if (_modeSequence) 728 { 729 int nTones(1); 730 int sleepMs(0); 731 int lenMult(1); 732 if (eventCode == 1) 733 { 734 nTones = 2; 735 sleepMs = lengthMs; 736 lenMult = 1; 737 } 738 else if (eventCode == 2) 739 { 740 eventCode = 1; 741 nTones = 2; 742 sleepMs = lengthMs/2; 743 lenMult = 2; 744 } 745 else if (eventCode == 3) 746 { 747 eventCode = 1; 748 nTones = 3; 749 sleepMs = 0; 750 lenMult = 1; 751 } 752 for (int i = 0; i < nTones; i++) 753 { 754 TEST2(_veDTMFPtr->SendTelephoneEvent(_channel, eventCode, outBand, lengthMs, attenuationDb) == 0, 755 _T("SendTelephoneEvent(channel=%d, eventCode=%u, outBand=%d, lengthMs=%d, attenuationDb=%d)"), _channel, eventCode, outBand, lengthMs, attenuationDb); 756 Sleep(sleepMs); 757 lengthMs = lenMult*lengthMs; 758 eventCode++; 759 } 760 } 761 } 762 } 763 764 void CTelephonyEvent::OnBnClickedButtonSendTelephoneEvent() 765 { 766 BOOL ret; 767 unsigned char eventCode(0); 768 769 eventCode = (unsigned char)GetDlgItemInt(IDC_EDIT_EVENT_CODE, &ret); 770 if (ret == FALSE) 771 { 772 return; 773 } 774 SendTelephoneEvent(eventCode); 775 } 776 777 void CTelephonyEvent::OnBnClickedButton1() 778 { 779 SendTelephoneEvent(1); 780 } 781 782 void CTelephonyEvent::OnBnClickedButton2() 783 { 784 SendTelephoneEvent(2); 785 } 786 787 void CTelephonyEvent::OnBnClickedButton3() 788 { 789 SendTelephoneEvent(3); 790 } 791 792 void CTelephonyEvent::OnBnClickedButton4() 793 { 794 SendTelephoneEvent(4); 795 } 796 797 void CTelephonyEvent::OnBnClickedButton5() 798 { 799 SendTelephoneEvent(5); 800 } 801 802 void CTelephonyEvent::OnBnClickedButton6() 803 { 804 SendTelephoneEvent(6); 805 } 806 807 void CTelephonyEvent::OnBnClickedButton7() 808 { 809 SendTelephoneEvent(7); 810 } 811 812 void CTelephonyEvent::OnBnClickedButton8() 813 { 814 SendTelephoneEvent(8); 815 } 816 817 void CTelephonyEvent::OnBnClickedButton9() 818 { 819 SendTelephoneEvent(9); 820 } 821 822 void CTelephonyEvent::OnBnClickedButton10() 823 { 824 // * 825 SendTelephoneEvent(10); 826 } 827 828 void CTelephonyEvent::OnBnClickedButton11() 829 { 830 SendTelephoneEvent(0); 831 } 832 833 void CTelephonyEvent::OnBnClickedButton12() 834 { 835 // # 836 SendTelephoneEvent(11); 837 } 838 839 void CTelephonyEvent::OnBnClickedButtonA() 840 { 841 SendTelephoneEvent(12); 842 } 843 844 void CTelephonyEvent::OnBnClickedButtonB() 845 { 846 SendTelephoneEvent(13); 847 } 848 849 void CTelephonyEvent::OnBnClickedButtonC() 850 { 851 SendTelephoneEvent(14); 852 } 853 854 void CTelephonyEvent::OnBnClickedButtonD() 855 { 856 SendTelephoneEvent(15); 857 } 858 859 void CTelephonyEvent::OnBnClickedCheckDtmfPlayoutRx() 860 { 861 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_PLAYOUT_RX); 862 int check = button->GetCheck(); 863 const bool enable = (check == BST_CHECKED); 864 TEST2(_veDTMFPtr->SetDtmfPlayoutStatus(_channel, enable) == 0, _T("SetDtmfPlayoutStatus(channel=%d, enable=%d)"), _channel, enable); 865 } 866 867 void CTelephonyEvent::OnBnClickedCheckDtmfPlayTone() 868 { 869 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_PLAY_TONE); 870 int check = button->GetCheck(); 871 _PlayDtmfToneLocally = (check == BST_CHECKED); 872 } 873 874 void CTelephonyEvent::OnBnClickedRadioSingle() 875 { 876 _modeStartStop = false; 877 _modeSingle = true; 878 _modeSequence = false; 879 } 880 881 void CTelephonyEvent::OnBnClickedRadioMulti() 882 { 883 _modeStartStop = false; 884 _modeSingle = false; 885 _modeSequence = true; 886 } 887 888 void CTelephonyEvent::OnBnClickedRadioStartStop() 889 { 890 // CButton* button = (CButton*)GetDlgItem(IDC_RADIO_START_STOP); 891 // int check = button->GetCheck(); 892 _modeStartStop = true; 893 _modeSingle = false; 894 _modeSequence = false; 895 // GetDlgItem(IDC_EDIT_EVENT_LENGTH)->EnableWindow(); 896 } 897 898 void CTelephonyEvent::OnBnClickedCheckEventInband() 899 { 900 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EVENT_INBAND); 901 int check = button->GetCheck(); 902 GetDlgItem(IDC_EDIT_EVENT_CODE)->EnableWindow(check?FALSE:TRUE); 903 GetDlgItem(IDC_BUTTON_SEND_TELEPHONE_EVENT)->EnableWindow(check?FALSE:TRUE); 904 } 905 906 void CTelephonyEvent::OnBnClickedCheckDtmfFeedback() 907 { 908 CButton* button(NULL); 909 910 // Retrieve feedback state 911 button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_FEEDBACK); 912 int check = button->GetCheck(); 913 const bool enable = (check == BST_CHECKED); 914 915 // Retrieve direct-feedback setting 916 button = (CButton*)GetDlgItem(IDC_CHECK_DIRECT_FEEDBACK); 917 check = button->GetCheck(); 918 const bool directFeedback = (check == BST_CHECKED); 919 920 // GetDlgItem(IDC_CHECK_DIRECT_FEEDBACK)->EnableWindow(enable ? TRUE : FALSE); 921 922 TEST2(_veDTMFPtr->SetDtmfFeedbackStatus(enable, directFeedback) == 0, 923 _T("SetDtmfFeedbackStatus(enable=%d, directFeedback=%d)"), enable, directFeedback); 924 } 925 926 void CTelephonyEvent::OnBnClickedCheckDirectFeedback() 927 { 928 CButton* button(NULL); 929 930 // Retrieve feedback state 931 button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_FEEDBACK); 932 int check = button->GetCheck(); 933 const bool enable = (check == BST_CHECKED); 934 935 // Retrieve new direct-feedback setting 936 button = (CButton*)GetDlgItem(IDC_CHECK_DIRECT_FEEDBACK); 937 check = button->GetCheck(); 938 const bool directFeedback = (check == BST_CHECKED); 939 940 TEST2(_veDTMFPtr->SetDtmfFeedbackStatus(enable, directFeedback) == 0, 941 _T("SetDtmfFeedbackStatus(enable=%d, directFeedback=%d)"), enable, directFeedback); 942 } 943 944 void CTelephonyEvent::OnBnClickedButtonSetRxTelephonePt() 945 { 946 BOOL ret; 947 int pt = GetDlgItemInt(IDC_EDIT_EVENT_RX_PT, &ret); 948 if (ret == FALSE) 949 return; 950 CodecInst codec; 951 strcpy_s(codec.plname, 32, "telephone-event"); 952 codec.pltype = pt; codec.channels = 1; codec.plfreq = 8000; 953 TEST2(_veCodecPtr->SetRecPayloadType(_channel, codec) == 0, 954 _T("SetSendTelephoneEventPayloadType(channel=%d, codec.pltype=%u)"), _channel, codec.pltype); 955 } 956 957 void CTelephonyEvent::OnBnClickedButtonSetTxTelephonePt() 958 { 959 BOOL ret; 960 int pt = GetDlgItemInt(IDC_EDIT_EVENT_TX_PT, &ret); 961 if (ret == FALSE) 962 return; 963 TEST2(_veDTMFPtr->SetSendTelephoneEventPayloadType(_channel, pt) == 0, 964 _T("SetSendTelephoneEventPayloadType(channel=%d, type=%u)"), _channel, pt); 965 } 966 967 void CTelephonyEvent::OnBnClickedCheckDetectInband() 968 { 969 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_INBAND); 970 int check = button->GetCheck(); 971 _inbandEventDetection = (check == BST_CHECKED); 972 973 bool enabled(false); 974 TelephoneEventDetectionMethods detectionMethod; 975 _veDTMFPtr->GetTelephoneEventDetectionStatus(_channel, enabled, detectionMethod); 976 if (enabled) 977 { 978 // deregister 979 _veDTMFPtr->DeRegisterTelephoneEventDetection(_channel); 980 delete _telephoneEventObserverPtr; 981 _telephoneEventObserverPtr = NULL; 982 SetDlgItemText(IDC_EDIT_ON_EVENT_INBAND,_T("")); 983 SetDlgItemText(IDC_EDIT_ON_EVENT_OUT_OF_BAND,_T("")); 984 } 985 OnBnClickedCheckEventDetection(); 986 } 987 988 void CTelephonyEvent::OnBnClickedCheckDetectOutOfBand() 989 { 990 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_OUT_OF_BAND); 991 int check = button->GetCheck(); 992 _outOfBandEventDetection = (check == BST_CHECKED); 993 994 bool enabled(false); 995 TelephoneEventDetectionMethods detectionMethod; 996 _veDTMFPtr->GetTelephoneEventDetectionStatus(_channel, enabled, detectionMethod); 997 if (enabled) 998 { 999 // deregister 1000 _veDTMFPtr->DeRegisterTelephoneEventDetection(_channel); 1001 delete _telephoneEventObserverPtr; 1002 _telephoneEventObserverPtr = NULL; 1003 SetDlgItemText(IDC_EDIT_ON_EVENT_INBAND,_T("")); 1004 SetDlgItemText(IDC_EDIT_ON_EVENT_OUT_OF_BAND,_T("")); 1005 } 1006 OnBnClickedCheckEventDetection(); 1007 } 1008 1009 void CTelephonyEvent::OnBnClickedCheckEventDetection() 1010 { 1011 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EVENT_DETECTION); 1012 int check = button->GetCheck(); 1013 const bool enable = (check == BST_CHECKED); 1014 1015 if (enable) 1016 { 1017 TelephoneEventDetectionMethods method(kInBand); 1018 if (_inbandEventDetection && !_outOfBandEventDetection) 1019 method = kInBand; 1020 else if (!_inbandEventDetection && _outOfBandEventDetection) 1021 method = kOutOfBand; 1022 else if (_inbandEventDetection && _outOfBandEventDetection) 1023 method = kInAndOutOfBand; 1024 1025 CWnd* wndOut = GetDlgItem(IDC_EDIT_ON_EVENT_OUT_OF_BAND); 1026 CWnd* wndIn = GetDlgItem(IDC_EDIT_ON_EVENT_INBAND); 1027 _telephoneEventObserverPtr = new TelephoneEventObserver(wndOut, wndIn); 1028 1029 TEST2(_veDTMFPtr->RegisterTelephoneEventDetection(_channel, method, *_telephoneEventObserverPtr) == 0, 1030 _T("RegisterTelephoneEventDetection(channel=%d, detectionMethod=%d)"), _channel, method); 1031 } 1032 else 1033 { 1034 TEST2(_veDTMFPtr->DeRegisterTelephoneEventDetection(_channel) == 0, 1035 _T("DeRegisterTelephoneEventDetection(channel=%d)"), _channel); 1036 delete _telephoneEventObserverPtr; 1037 _telephoneEventObserverPtr = NULL; 1038 SetDlgItemText(IDC_EDIT_ON_EVENT_INBAND,_T("")); 1039 SetDlgItemText(IDC_EDIT_ON_EVENT_OUT_OF_BAND,_T("")); 1040 } 1041 } 1042 1043 // ============================================================================ 1044 // CWinTestDlg dialog 1045 // ============================================================================ 1046 1047 CWinTestDlg::CWinTestDlg(CWnd* pParent /*=NULL*/) 1048 : CDialog(CWinTestDlg::IDD, pParent), 1049 _failCount(0), 1050 _vePtr(NULL), 1051 _veBasePtr(NULL), 1052 _veCodecPtr(NULL), 1053 _veNetworkPtr(NULL), 1054 _veFilePtr(NULL), 1055 _veHardwarePtr(NULL), 1056 _veExternalMediaPtr(NULL), 1057 _veApmPtr(NULL), 1058 _veRtpRtcpPtr(NULL), 1059 _transportPtr(NULL), 1060 _externalMediaPtr(NULL), 1061 _externalTransport(false), 1062 _externalTransportBuild(false), 1063 _checkPlayFileIn(0), 1064 _checkPlayFileIn1(0), 1065 _checkPlayFileIn2(0), 1066 _checkPlayFileOut1(0), 1067 _checkPlayFileOut2(0), 1068 _checkAGC(0), 1069 _checkAGC1(0), 1070 _checkNS(0), 1071 _checkNS1(0), 1072 _checkEC(0), 1073 _checkVAD1(0), 1074 _checkVAD2(0), 1075 _checkSrtpTx1(0), 1076 _checkSrtpTx2(0), 1077 _checkSrtpRx1(0), 1078 _checkSrtpRx2(0), 1079 _checkConference1(0), 1080 _checkConference2(0), 1081 _checkOnHold1(0), 1082 _checkOnHold2(0), 1083 _strComboIp1(_T("")), 1084 _strComboIp2(_T("")), 1085 _delayEstimate1(false), 1086 _delayEstimate2(false), 1087 _rxVad(false), 1088 _nErrorCallbacks(0), 1089 _timerTicks(0) 1090 { 1091 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 1092 1093 _vePtr = VoiceEngine::Create(); 1094 1095 VoiceEngine::SetTraceFilter(kTraceNone); 1096 // VoiceEngine::SetTraceFilter(kTraceAll); 1097 // VoiceEngine::SetTraceFilter(kTraceStream | kTraceStateInfo | kTraceWarning | kTraceError | kTraceCritical | kTraceApiCall | kTraceModuleCall | kTraceMemory | kTraceDebug | kTraceInfo); 1098 // VoiceEngine::SetTraceFilter(kTraceStateInfo | kTraceWarning | kTraceError | kTraceCritical | kTraceApiCall | kTraceModuleCall | kTraceMemory | kTraceInfo); 1099 1100 VoiceEngine::SetTraceFile("ve_win_test.txt"); 1101 VoiceEngine::SetTraceCallback(NULL); 1102 1103 if (_vePtr) 1104 { 1105 _veExternalMediaPtr = VoEExternalMedia::GetInterface(_vePtr); 1106 _veVolumeControlPtr = VoEVolumeControl::GetInterface(_vePtr); 1107 _veVideoSyncPtr = VoEVideoSync::GetInterface(_vePtr); 1108 _veNetworkPtr = VoENetwork::GetInterface(_vePtr); 1109 _veFilePtr = VoEFile::GetInterface(_vePtr); 1110 _veApmPtr = VoEAudioProcessing::GetInterface(_vePtr); 1111 1112 _veBasePtr = VoEBase::GetInterface(_vePtr); 1113 _veCodecPtr = VoECodec::GetInterface(_vePtr); 1114 _veHardwarePtr = VoEHardware::GetInterface(_vePtr); 1115 _veRtpRtcpPtr = VoERTP_RTCP::GetInterface(_vePtr); 1116 _transportPtr = new MyTransport(_veNetworkPtr); 1117 _externalMediaPtr = new MediaProcessImpl(); 1118 _connectionObserverPtr = new ConnectionObserver(); 1119 _rxVadObserverPtr = new RxCallback(); 1120 } 1121 1122 _veBasePtr->RegisterVoiceEngineObserver(*this); 1123 1124 std::string resource_path = webrtc::test::ProjectRootPath(); 1125 if (resource_path == webrtc::test::kCannotFindProjectRootDir) { 1126 _long_audio_file_path = "./"; 1127 } else { 1128 _long_audio_file_path = resource_path + "data\\voice_engine\\"; 1129 } 1130 } 1131 1132 CWinTestDlg::~CWinTestDlg() 1133 { 1134 if (_connectionObserverPtr) delete _connectionObserverPtr; 1135 if (_externalMediaPtr) delete _externalMediaPtr; 1136 if (_transportPtr) delete _transportPtr; 1137 if (_rxVadObserverPtr) delete _rxVadObserverPtr; 1138 1139 if (_veExternalMediaPtr) _veExternalMediaPtr->Release(); 1140 if (_veVideoSyncPtr) _veVideoSyncPtr->Release(); 1141 if (_veVolumeControlPtr) _veVolumeControlPtr->Release(); 1142 1143 if (_veBasePtr) _veBasePtr->Terminate(); 1144 if (_veBasePtr) _veBasePtr->Release(); 1145 1146 if (_veCodecPtr) _veCodecPtr->Release(); 1147 if (_veNetworkPtr) _veNetworkPtr->Release(); 1148 if (_veFilePtr) _veFilePtr->Release(); 1149 if (_veHardwarePtr) _veHardwarePtr->Release(); 1150 if (_veApmPtr) _veApmPtr->Release(); 1151 if (_veRtpRtcpPtr) _veRtpRtcpPtr->Release(); 1152 if (_vePtr) 1153 { 1154 VoiceEngine::Delete(_vePtr); 1155 } 1156 VoiceEngine::SetTraceFilter(kTraceNone); 1157 } 1158 1159 void CWinTestDlg::DoDataExchange(CDataExchange* pDX) 1160 { 1161 CDialog::DoDataExchange(pDX); 1162 DDX_CBString(pDX, IDC_COMBO_IP_1, _strComboIp1); 1163 DDX_CBString(pDX, IDC_COMBO_IP_2, _strComboIp2); 1164 } 1165 1166 BEGIN_MESSAGE_MAP(CWinTestDlg, CDialog) 1167 ON_WM_SYSCOMMAND() 1168 ON_WM_PAINT() 1169 ON_WM_QUERYDRAGICON() 1170 ON_WM_TIMER() 1171 //}}AFX_MSG_MAP 1172 ON_BN_CLICKED(IDC_BUTTON_CREATE_1, &CWinTestDlg::OnBnClickedButtonCreate1) 1173 ON_BN_CLICKED(IDC_BUTTON_DELETE_1, &CWinTestDlg::OnBnClickedButtonDelete1) 1174 ON_BN_CLICKED(IDC_BUTTON_CREATE_2, &CWinTestDlg::OnBnClickedButtonCreate2) 1175 ON_BN_CLICKED(IDC_BUTTON_DELETE_2, &CWinTestDlg::OnBnClickedButtonDelete2) 1176 ON_CBN_SELCHANGE(IDC_COMBO_CODEC_1, &CWinTestDlg::OnCbnSelchangeComboCodec1) 1177 ON_BN_CLICKED(IDC_BUTTON_START_LISTEN_1, &CWinTestDlg::OnBnClickedButtonStartListen1) 1178 ON_BN_CLICKED(IDC_BUTTON_STOP_LISTEN_1, &CWinTestDlg::OnBnClickedButtonStopListen1) 1179 ON_BN_CLICKED(IDC_BUTTON_START_PLAYOUT_1, &CWinTestDlg::OnBnClickedButtonStartPlayout1) 1180 ON_BN_CLICKED(IDC_BUTTON_STOP_PLAYOUT_1, &CWinTestDlg::OnBnClickedButtonStopPlayout1) 1181 ON_BN_CLICKED(IDC_BUTTON_START_SEND_1, &CWinTestDlg::OnBnClickedButtonStartSend1) 1182 ON_BN_CLICKED(IDC_BUTTON_STOP_SEND_1, &CWinTestDlg::OnBnClickedButtonStopSend1) 1183 ON_CBN_SELCHANGE(IDC_COMBO_IP_2, &CWinTestDlg::OnCbnSelchangeComboIp2) 1184 ON_CBN_SELCHANGE(IDC_COMBO_IP_1, &CWinTestDlg::OnCbnSelchangeComboIp1) 1185 ON_CBN_SELCHANGE(IDC_COMBO_CODEC_2, &CWinTestDlg::OnCbnSelchangeComboCodec2) 1186 ON_BN_CLICKED(IDC_BUTTON_START_LISTEN_2, &CWinTestDlg::OnBnClickedButtonStartListen2) 1187 ON_BN_CLICKED(IDC_BUTTON_STOP_LISTEN_2, &CWinTestDlg::OnBnClickedButtonStopListen2) 1188 ON_BN_CLICKED(IDC_BUTTON_START_PLAYOUT_2, &CWinTestDlg::OnBnClickedButtonStartPlayout2) 1189 ON_BN_CLICKED(IDC_BUTTON_STOP_PLAYOUT_2, &CWinTestDlg::OnBnClickedButtonStopPlayout2) 1190 ON_BN_CLICKED(IDC_BUTTON_START_SEND_2, &CWinTestDlg::OnBnClickedButtonStartSend2) 1191 ON_BN_CLICKED(IDC_BUTTON_STOP_SEND_2, &CWinTestDlg::OnBnClickedButtonStopSend2) 1192 ON_BN_CLICKED(IDC_CHECK_EXT_TRANS_1, &CWinTestDlg::OnBnClickedCheckExtTrans1) 1193 ON_BN_CLICKED(IDC_CHECK_PLAY_FILE_IN_1, &CWinTestDlg::OnBnClickedCheckPlayFileIn1) 1194 ON_BN_CLICKED(IDC_CHECK_PLAY_FILE_OUT_1, &CWinTestDlg::OnBnClickedCheckPlayFileOut1) 1195 ON_BN_CLICKED(IDC_CHECK_EXT_TRANS_2, &CWinTestDlg::OnBnClickedCheckExtTrans2) 1196 ON_BN_CLICKED(IDC_CHECK_PLAY_FILE_IN_2, &CWinTestDlg::OnBnClickedCheckPlayFileIn2) 1197 ON_BN_CLICKED(IDC_CHECK_PLAY_FILE_OUT_2, &CWinTestDlg::OnBnClickedCheckPlayFileOut2) 1198 ON_BN_CLICKED(IDC_CHECK_PLAY_FILE_IN, &CWinTestDlg::OnBnClickedCheckPlayFileIn) 1199 ON_CBN_SELCHANGE(IDC_COMBO_REC_DEVICE, &CWinTestDlg::OnCbnSelchangeComboRecDevice) 1200 ON_CBN_SELCHANGE(IDC_COMBO_PLAY_DEVICE, &CWinTestDlg::OnCbnSelchangeComboPlayDevice) 1201 ON_BN_CLICKED(IDC_CHECK_EXT_MEDIA_IN_1, &CWinTestDlg::OnBnClickedCheckExtMediaIn1) 1202 ON_BN_CLICKED(IDC_CHECK_EXT_MEDIA_OUT_1, &CWinTestDlg::OnBnClickedCheckExtMediaOut1) 1203 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_INPUT_VOLUME, &CWinTestDlg::OnNMReleasedcaptureSliderInputVolume) 1204 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_OUTPUT_VOLUME, &CWinTestDlg::OnNMReleasedcaptureSliderOutputVolume) 1205 ON_BN_CLICKED(IDC_CHECK_AGC, &CWinTestDlg::OnBnClickedCheckAgc) 1206 ON_BN_CLICKED(IDC_CHECK_NS, &CWinTestDlg::OnBnClickedCheckNs) 1207 ON_BN_CLICKED(IDC_CHECK_EC, &CWinTestDlg::OnBnClickedCheckEc) 1208 ON_BN_CLICKED(IDC_CHECK_VAD_1, &CWinTestDlg::OnBnClickedCheckVad1) 1209 ON_BN_CLICKED(IDC_CHECK_VAD_3, &CWinTestDlg::OnBnClickedCheckVad2) 1210 ON_BN_CLICKED(IDC_CHECK_EXT_MEDIA_IN_2, &CWinTestDlg::OnBnClickedCheckExtMediaIn2) 1211 ON_BN_CLICKED(IDC_CHECK_EXT_MEDIA_OUT_2, &CWinTestDlg::OnBnClickedCheckExtMediaOut2) 1212 ON_BN_CLICKED(IDC_CHECK_MUTE_IN, &CWinTestDlg::OnBnClickedCheckMuteIn) 1213 ON_BN_CLICKED(IDC_CHECK_MUTE_IN_1, &CWinTestDlg::OnBnClickedCheckMuteIn1) 1214 ON_BN_CLICKED(IDC_CHECK_MUTE_IN_2, &CWinTestDlg::OnBnClickedCheckMuteIn2) 1215 ON_BN_CLICKED(IDC_CHECK_SRTP_TX_1, &CWinTestDlg::OnBnClickedCheckSrtpTx1) 1216 ON_BN_CLICKED(IDC_CHECK_SRTP_RX_1, &CWinTestDlg::OnBnClickedCheckSrtpRx1) 1217 ON_BN_CLICKED(IDC_CHECK_SRTP_TX_2, &CWinTestDlg::OnBnClickedCheckSrtpTx2) 1218 ON_BN_CLICKED(IDC_CHECK_SRTP_RX_2, &CWinTestDlg::OnBnClickedCheckSrtpRx2) 1219 ON_BN_CLICKED(IDC_CHECK_EXT_ENCRYPTION_1, &CWinTestDlg::OnBnClickedCheckExtEncryption1) 1220 ON_BN_CLICKED(IDC_CHECK_EXT_ENCRYPTION_2, &CWinTestDlg::OnBnClickedCheckExtEncryption2) 1221 ON_BN_CLICKED(IDC_BUTTON_DTMF_1, &CWinTestDlg::OnBnClickedButtonDtmf1) 1222 ON_BN_CLICKED(IDC_CHECK_REC_MIC, &CWinTestDlg::OnBnClickedCheckRecMic) 1223 ON_BN_CLICKED(IDC_BUTTON_DTMF_2, &CWinTestDlg::OnBnClickedButtonDtmf2) 1224 ON_BN_CLICKED(IDC_BUTTON_TEST_1, &CWinTestDlg::OnBnClickedButtonTest1) 1225 ON_BN_CLICKED(IDC_CHECK_CONFERENCE_1, &CWinTestDlg::OnBnClickedCheckConference1) 1226 ON_BN_CLICKED(IDC_CHECK_CONFERENCE_2, &CWinTestDlg::OnBnClickedCheckConference2) 1227 ON_BN_CLICKED(IDC_CHECK_ON_HOLD_1, &CWinTestDlg::OnBnClickedCheckOnHold1) 1228 ON_BN_CLICKED(IDC_CHECK_ON_HOLD_2, &CWinTestDlg::OnBnClickedCheckOnHold2) 1229 ON_BN_CLICKED(IDC_CHECK_EXT_MEDIA_IN, &CWinTestDlg::OnBnClickedCheckExtMediaIn) 1230 ON_BN_CLICKED(IDC_CHECK_EXT_MEDIA_OUT, &CWinTestDlg::OnBnClickedCheckExtMediaOut) 1231 ON_LBN_SELCHANGE(IDC_LIST_CODEC_1, &CWinTestDlg::OnLbnSelchangeListCodec1) 1232 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_PAN_LEFT, &CWinTestDlg::OnNMReleasedcaptureSliderPanLeft) 1233 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_PAN_RIGHT, &CWinTestDlg::OnNMReleasedcaptureSliderPanRight) 1234 ON_BN_CLICKED(IDC_BUTTON_VERSION, &CWinTestDlg::OnBnClickedButtonVersion) 1235 ON_BN_CLICKED(IDC_CHECK_DELAY_ESTIMATE_1, &CWinTestDlg::OnBnClickedCheckDelayEstimate1) 1236 ON_BN_CLICKED(IDC_CHECK_RXVAD, &CWinTestDlg::OnBnClickedCheckRxvad) 1237 ON_BN_CLICKED(IDC_CHECK_AGC_1, &CWinTestDlg::OnBnClickedCheckAgc1) 1238 ON_BN_CLICKED(IDC_CHECK_NS_1, &CWinTestDlg::OnBnClickedCheckNs1) 1239 ON_BN_CLICKED(IDC_CHECK_REC_CALL, &CWinTestDlg::OnBnClickedCheckRecCall) 1240 ON_BN_CLICKED(IDC_CHECK_TYPING_DETECTION, &CWinTestDlg::OnBnClickedCheckTypingDetection) 1241 ON_BN_CLICKED(IDC_CHECK_RED, &CWinTestDlg::OnBnClickedCheckRED) 1242 ON_BN_CLICKED(IDC_BUTTON_CLEAR_ERROR_CALLBACK, &CWinTestDlg::OnBnClickedButtonClearErrorCallback) 1243 END_MESSAGE_MAP() 1244 1245 BOOL CWinTestDlg::UpdateTest(bool failed, const CString& strMsg) 1246 { 1247 if (failed) 1248 { 1249 SetDlgItemText(IDC_EDIT_MESSAGE, strMsg); 1250 _strErr.Format(_T("FAILED (error=%d)"), _veBasePtr->LastError()); 1251 SetDlgItemText(IDC_EDIT_RESULT, _strErr); 1252 _failCount++; 1253 SetDlgItemInt(IDC_EDIT_N_FAILS, _failCount); 1254 SetDlgItemInt(IDC_EDIT_LAST_ERROR, _veBasePtr->LastError()); 1255 } 1256 else 1257 { 1258 SetDlgItemText(IDC_EDIT_MESSAGE, strMsg); 1259 SetDlgItemText(IDC_EDIT_RESULT, _T("OK")); 1260 } 1261 return TRUE; 1262 } 1263 1264 1265 // CWinTestDlg message handlers 1266 1267 BOOL CWinTestDlg::OnInitDialog() 1268 { 1269 CDialog::OnInitDialog(); 1270 1271 // Add "About..." menu item to system menu. 1272 1273 // IDM_ABOUTBOX must be in the system command range. 1274 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 1275 ASSERT(IDM_ABOUTBOX < 0xF000); 1276 1277 CMenu* pSysMenu = GetSystemMenu(FALSE); 1278 if (pSysMenu != NULL) 1279 { 1280 CString strAboutMenu; 1281 strAboutMenu.LoadString(IDS_ABOUTBOX); 1282 if (!strAboutMenu.IsEmpty()) 1283 { 1284 pSysMenu->AppendMenu(MF_SEPARATOR); 1285 pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 1286 } 1287 } 1288 1289 // Set the icon for this dialog. The framework does this automatically 1290 // when the application's main window is not a dialog 1291 SetIcon(m_hIcon, TRUE); // Set big icon 1292 SetIcon(m_hIcon, FALSE); // Set small icon 1293 1294 // char version[1024]; 1295 // _veBasePtr->GetVersion(version); 1296 // AfxMessageBox(version, MB_OK); 1297 1298 if (_veBasePtr->Init() != 0) 1299 { 1300 AfxMessageBox(_T("Init() failed "), MB_OKCANCEL); 1301 } 1302 1303 int ch = _veBasePtr->CreateChannel(); 1304 if (_veBasePtr->SetSendDestination(ch, 1234, "127.0.0.1") == -1) 1305 { 1306 if (_veBasePtr->LastError() == VE_EXTERNAL_TRANSPORT_ENABLED) 1307 { 1308 _strMsg.Format(_T("*** External transport build ***")); 1309 SetDlgItemText(IDC_EDIT_MESSAGE, _strMsg); 1310 _externalTransportBuild = true; 1311 } 1312 } 1313 _veBasePtr->DeleteChannel(ch); 1314 1315 // --- Add (preferred) local IPv4 address in title 1316 1317 if (_veNetworkPtr) 1318 { 1319 char localIP[64]; 1320 _veNetworkPtr->GetLocalIP(localIP); 1321 CString str; 1322 GetWindowText(str); 1323 str.AppendFormat(_T(" [Local IPv4 address: %s]"), CharToTchar(localIP, 64)); 1324 SetWindowText(str); 1325 } 1326 1327 // --- Volume sliders 1328 1329 if (_veVolumeControlPtr) 1330 { 1331 unsigned int volume(0); 1332 CSliderCtrl* slider(NULL); 1333 1334 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_INPUT_VOLUME); 1335 slider->SetRangeMin(0); 1336 slider->SetRangeMax(255); 1337 _veVolumeControlPtr->GetMicVolume(volume); 1338 slider->SetPos(volume); 1339 1340 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_OUTPUT_VOLUME); 1341 slider->SetRangeMin(0); 1342 slider->SetRangeMax(255); 1343 _veVolumeControlPtr->GetSpeakerVolume(volume); 1344 slider->SetPos(volume); 1345 } 1346 1347 // --- Panning sliders 1348 1349 if (_veVolumeControlPtr) 1350 { 1351 float lVol(0.0); 1352 float rVol(0.0); 1353 int leftVol, rightVol; 1354 CSliderCtrl* slider(NULL); 1355 1356 _veVolumeControlPtr->GetOutputVolumePan(-1, lVol, rVol); 1357 1358 leftVol = (int)(lVol*10.0f); // [0,10] 1359 rightVol = (int)(rVol*10.0f); // [0,10] 1360 1361 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_PAN_LEFT); 1362 slider->SetRange(0,10); 1363 slider->SetPos(10-leftVol); // pos 0 <=> max pan 1.0 (top of slider) 1364 1365 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_PAN_RIGHT); 1366 slider->SetRange(0,10); 1367 slider->SetPos(10-rightVol); 1368 } 1369 1370 // --- APM settings 1371 1372 bool enable(false); 1373 CButton* button(NULL); 1374 1375 AgcModes agcMode(kAgcDefault); 1376 if (_veApmPtr->GetAgcStatus(enable, agcMode) == 0) 1377 { 1378 button = (CButton*)GetDlgItem(IDC_CHECK_AGC); 1379 enable ? button->SetCheck(BST_CHECKED) : button->SetCheck(BST_UNCHECKED); 1380 } 1381 else 1382 { 1383 // AGC is not supported 1384 GetDlgItem(IDC_CHECK_AGC)->EnableWindow(FALSE); 1385 } 1386 1387 NsModes nsMode(kNsDefault); 1388 if (_veApmPtr->GetNsStatus(enable, nsMode) == 0) 1389 { 1390 button = (CButton*)GetDlgItem(IDC_CHECK_NS); 1391 enable ? button->SetCheck(BST_CHECKED) : button->SetCheck(BST_UNCHECKED); 1392 } 1393 else 1394 { 1395 // NS is not supported 1396 GetDlgItem(IDC_CHECK_NS)->EnableWindow(FALSE); 1397 } 1398 1399 EcModes ecMode(kEcDefault); 1400 if (_veApmPtr->GetEcStatus(enable, ecMode) == 0) 1401 { 1402 button = (CButton*)GetDlgItem(IDC_CHECK_EC); 1403 enable ? button->SetCheck(BST_CHECKED) : button->SetCheck(BST_UNCHECKED); 1404 } 1405 else 1406 { 1407 // EC is not supported 1408 GetDlgItem(IDC_CHECK_EC)->EnableWindow(FALSE); 1409 } 1410 1411 // --- First channel section 1412 1413 GetDlgItem(IDC_COMBO_IP_1)->EnableWindow(FALSE); 1414 GetDlgItem(IDC_EDIT_TX_PORT_1)->EnableWindow(FALSE); 1415 GetDlgItem(IDC_EDIT_RX_PORT_1)->EnableWindow(FALSE); 1416 GetDlgItem(IDC_COMBO_CODEC_1)->EnableWindow(FALSE); 1417 GetDlgItem(IDC_LIST_CODEC_1)->EnableWindow(FALSE); 1418 GetDlgItem(IDC_EDIT_CODEC_1)->EnableWindow(FALSE); 1419 GetDlgItem(IDC_BUTTON_DELETE_1)->EnableWindow(FALSE); 1420 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(FALSE); 1421 GetDlgItem(IDC_BUTTON_STOP_LISTEN_1)->EnableWindow(FALSE); 1422 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(FALSE); 1423 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_1)->EnableWindow(FALSE); 1424 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(FALSE); 1425 GetDlgItem(IDC_BUTTON_STOP_SEND_1)->EnableWindow(FALSE); 1426 GetDlgItem(IDC_CHECK_EXT_TRANS_1)->EnableWindow(FALSE); 1427 GetDlgItem(IDC_CHECK_PLAY_FILE_IN_1)->EnableWindow(FALSE); 1428 GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_1)->EnableWindow(FALSE); 1429 GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_1)->EnableWindow(FALSE); 1430 GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_1)->EnableWindow(FALSE); 1431 GetDlgItem(IDC_CHECK_VAD_1)->EnableWindow(FALSE); 1432 GetDlgItem(IDC_CHECK_MUTE_IN_1)->EnableWindow(FALSE); 1433 GetDlgItem(IDC_CHECK_SRTP_TX_1)->EnableWindow(FALSE); 1434 GetDlgItem(IDC_CHECK_SRTP_RX_1)->EnableWindow(FALSE); 1435 GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_1)->EnableWindow(FALSE); 1436 GetDlgItem(IDC_BUTTON_DTMF_1)->EnableWindow(FALSE); 1437 GetDlgItem(IDC_CHECK_CONFERENCE_1)->EnableWindow(FALSE); 1438 GetDlgItem(IDC_CHECK_ON_HOLD_1)->EnableWindow(FALSE); 1439 GetDlgItem(IDC_CHECK_DELAY_ESTIMATE_1)->EnableWindow(FALSE); 1440 GetDlgItem(IDC_CHECK_RXVAD)->EnableWindow(FALSE); 1441 GetDlgItem(IDC_CHECK_AGC_1)->EnableWindow(FALSE); 1442 GetDlgItem(IDC_CHECK_NS_1)->EnableWindow(FALSE); 1443 GetDlgItem(IDC_CHECK_RED)->EnableWindow(FALSE); 1444 1445 CComboBox* comboIP(NULL); 1446 comboIP = (CComboBox*)GetDlgItem(IDC_COMBO_IP_1); 1447 comboIP->AddString(_T("127.0.0.1")); 1448 comboIP->SetCurSel(0); 1449 1450 SetDlgItemInt(IDC_EDIT_TX_PORT_1, 1111); 1451 SetDlgItemInt(IDC_EDIT_RX_PORT_1, 1111); 1452 1453 // --- Add supported codecs to the codec combo box 1454 1455 CComboBox* comboCodec(NULL); 1456 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_CODEC_1); 1457 comboCodec->ResetContent(); 1458 1459 int numCodecs = _veCodecPtr->NumOfCodecs(); 1460 for (int idx = 0; idx < numCodecs; idx++) 1461 { 1462 CodecInst codec; 1463 _veCodecPtr->GetCodec(idx, codec); 1464 if ((_stricmp(codec.plname, "CNNB") != 0) && 1465 (_stricmp(codec.plname, "CNWB") != 0)) 1466 { 1467 CString strCodec; 1468 if (_stricmp(codec.plname, "G7221") == 0) 1469 strCodec.Format(_T("%s (%d/%d/%d)"), CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq/1000, codec.rate/1000); 1470 else 1471 strCodec.Format(_T("%s (%d/%d)"), CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq/1000); 1472 comboCodec->AddString(strCodec); 1473 } 1474 if (idx == 0) 1475 { 1476 SetDlgItemInt(IDC_EDIT_CODEC_1, codec.pltype); 1477 } 1478 } 1479 comboCodec->SetCurSel(0); 1480 1481 CListBox* list = (CListBox*)GetDlgItem(IDC_LIST_CODEC_1); 1482 list->AddString(_T("pltype")); 1483 list->AddString(_T("plfreq")); 1484 list->AddString(_T("pacsize")); 1485 list->AddString(_T("channels")); 1486 list->AddString(_T("rate")); 1487 list->SetCurSel(0); 1488 1489 // --- Add available audio devices to the combo boxes 1490 1491 CComboBox* comboRecDevice(NULL); 1492 CComboBox* comboPlayDevice(NULL); 1493 comboRecDevice = (CComboBox*)GetDlgItem(IDC_COMBO_REC_DEVICE); 1494 comboPlayDevice = (CComboBox*)GetDlgItem(IDC_COMBO_PLAY_DEVICE); 1495 comboRecDevice->ResetContent(); 1496 comboPlayDevice->ResetContent(); 1497 1498 if (_veHardwarePtr) 1499 { 1500 int numPlayout(0); 1501 int numRecording(0); 1502 char nameStr[128]; 1503 char guidStr[128]; 1504 CString strDevice; 1505 AudioLayers audioLayer; 1506 1507 _veHardwarePtr->GetAudioDeviceLayer(audioLayer); 1508 if (kAudioWindowsWave == audioLayer) 1509 { 1510 strDevice.FormatMessage(_T("Audio Layer: Windows Wave API")); 1511 } 1512 else if (kAudioWindowsCore == audioLayer) 1513 { 1514 strDevice.FormatMessage(_T("Audio Layer: Windows Core API")); 1515 } 1516 else 1517 { 1518 strDevice.FormatMessage(_T("Audio Layer: ** UNKNOWN **")); 1519 } 1520 SetDlgItemText(IDC_EDIT_AUDIO_LAYER, (LPCTSTR)strDevice); 1521 1522 _veHardwarePtr->GetNumOfRecordingDevices(numRecording); 1523 1524 for (int idx = 0; idx < numRecording; idx++) 1525 { 1526 _veHardwarePtr->GetRecordingDeviceName(idx, nameStr, guidStr); 1527 strDevice.Format(_T("%s"), CharToTchar(nameStr, 128)); 1528 comboRecDevice->AddString(strDevice); 1529 } 1530 // Select default (communication) device in the combo box 1531 _veHardwarePtr->GetRecordingDeviceName(-1, nameStr, guidStr); 1532 CString tmp = CString(nameStr); 1533 int nIndex = comboRecDevice->SelectString(-1, tmp); 1534 ASSERT(nIndex != CB_ERR); 1535 1536 _veHardwarePtr->GetNumOfPlayoutDevices(numPlayout); 1537 1538 for (int idx = 0; idx < numPlayout; idx++) 1539 { 1540 _veHardwarePtr->GetPlayoutDeviceName(idx, nameStr, guidStr); 1541 strDevice.Format(_T("%s"), CharToTchar(nameStr, 128)); 1542 comboPlayDevice->AddString(strDevice); 1543 } 1544 // Select default (communication) device in the combo box 1545 _veHardwarePtr->GetPlayoutDeviceName(-1, nameStr, guidStr); 1546 nIndex = comboPlayDevice->SelectString(-1, CString(nameStr)); 1547 ASSERT(nIndex != CB_ERR); 1548 } 1549 1550 // --- Second channel section 1551 1552 GetDlgItem(IDC_COMBO_IP_2)->EnableWindow(FALSE); 1553 GetDlgItem(IDC_EDIT_TX_PORT_2)->EnableWindow(FALSE); 1554 GetDlgItem(IDC_EDIT_RX_PORT_2)->EnableWindow(FALSE); 1555 GetDlgItem(IDC_COMBO_CODEC_2)->EnableWindow(FALSE); 1556 GetDlgItem(IDC_BUTTON_DELETE_2)->EnableWindow(FALSE); 1557 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(FALSE); 1558 GetDlgItem(IDC_BUTTON_STOP_LISTEN_2)->EnableWindow(FALSE); 1559 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(FALSE); 1560 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_2)->EnableWindow(FALSE); 1561 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(FALSE); 1562 GetDlgItem(IDC_BUTTON_STOP_SEND_2)->EnableWindow(FALSE); 1563 GetDlgItem(IDC_CHECK_EXT_TRANS_2)->EnableWindow(FALSE); 1564 GetDlgItem(IDC_CHECK_PLAY_FILE_IN_2)->EnableWindow(FALSE); 1565 GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_2)->EnableWindow(FALSE); 1566 GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_2)->EnableWindow(FALSE); 1567 GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_2)->EnableWindow(FALSE); 1568 GetDlgItem(IDC_CHECK_VAD_3)->EnableWindow(FALSE); 1569 GetDlgItem(IDC_CHECK_MUTE_IN_2)->EnableWindow(FALSE); 1570 GetDlgItem(IDC_CHECK_SRTP_TX_2)->EnableWindow(FALSE); 1571 GetDlgItem(IDC_CHECK_SRTP_RX_2)->EnableWindow(FALSE); 1572 GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_2)->EnableWindow(FALSE); 1573 GetDlgItem(IDC_BUTTON_DTMF_2)->EnableWindow(FALSE); 1574 GetDlgItem(IDC_CHECK_CONFERENCE_2)->EnableWindow(FALSE); 1575 GetDlgItem(IDC_CHECK_ON_HOLD_2)->EnableWindow(FALSE); 1576 1577 comboIP = (CComboBox*)GetDlgItem(IDC_COMBO_IP_2); 1578 comboIP->AddString(_T("127.0.0.1")); 1579 comboIP->SetCurSel(0); 1580 1581 SetDlgItemInt(IDC_EDIT_TX_PORT_2, 2222); 1582 SetDlgItemInt(IDC_EDIT_RX_PORT_2, 2222); 1583 1584 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_CODEC_2); 1585 comboCodec->ResetContent(); 1586 1587 if (_veCodecPtr) 1588 { 1589 numCodecs = _veCodecPtr->NumOfCodecs(); 1590 for (int idx = 0; idx < numCodecs; idx++) 1591 { 1592 CodecInst codec; 1593 _veCodecPtr->GetCodec(idx, codec); 1594 CString strCodec; 1595 strCodec.Format(_T("%s (%d/%d)"), CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq/1000); 1596 comboCodec->AddString(strCodec); 1597 } 1598 comboCodec->SetCurSel(0); 1599 } 1600 1601 // --- Start windows timer 1602 1603 SetTimer(0, 1000, NULL); 1604 1605 return TRUE; // return TRUE unless you set the focus to a control 1606 } 1607 1608 void CWinTestDlg::OnSysCommand(UINT nID, LPARAM lParam) 1609 { 1610 if ((nID & 0xFFF0) == IDM_ABOUTBOX) 1611 { 1612 CAboutDlg dlgAbout; 1613 dlgAbout.DoModal(); 1614 } 1615 else if (nID == SC_CLOSE) 1616 { 1617 BOOL ret; 1618 int channel(0); 1619 channel = GetDlgItemInt(IDC_EDIT_1, &ret); 1620 if (ret == TRUE) 1621 { 1622 _veBasePtr->DeleteChannel(channel); 1623 } 1624 channel = GetDlgItemInt(IDC_EDIT_2, &ret); 1625 if (ret == TRUE) 1626 { 1627 _veBasePtr->DeleteChannel(channel); 1628 } 1629 1630 CDialog::OnSysCommand(nID, lParam); 1631 } 1632 else 1633 { 1634 CDialog::OnSysCommand(nID, lParam); 1635 } 1636 1637 } 1638 1639 // If you add a minimize button to your dialog, you will need the code below 1640 // to draw the icon. For MFC applications using the document/view model, 1641 // this is automatically done for you by the framework. 1642 1643 void CWinTestDlg::OnPaint() 1644 { 1645 if (IsIconic()) 1646 { 1647 CPaintDC dc(this); // device context for painting 1648 1649 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); 1650 1651 // Center icon in client rectangle 1652 int cxIcon = GetSystemMetrics(SM_CXICON); 1653 int cyIcon = GetSystemMetrics(SM_CYICON); 1654 CRect rect; 1655 GetClientRect(&rect); 1656 int x = (rect.Width() - cxIcon + 1) / 2; 1657 int y = (rect.Height() - cyIcon + 1) / 2; 1658 1659 // Draw the icon 1660 dc.DrawIcon(x, y, m_hIcon); 1661 } 1662 else 1663 { 1664 CDialog::OnPaint(); 1665 } 1666 } 1667 1668 // The system calls this function to obtain the cursor to display while the user drags 1669 // the minimized window. 1670 HCURSOR CWinTestDlg::OnQueryDragIcon() 1671 { 1672 return static_cast<HCURSOR>(m_hIcon); 1673 } 1674 1675 1676 void CWinTestDlg::OnBnClickedButtonCreate1() 1677 { 1678 int channel(0); 1679 TEST((channel = _veBasePtr->CreateChannel()) >= 0, _T("CreateChannel(channel=%d)"), channel); 1680 if (channel >= 0) 1681 { 1682 _veRtpRtcpPtr->RegisterRTPObserver(channel, *this); 1683 1684 SetDlgItemInt(IDC_EDIT_1, channel); 1685 GetDlgItem(IDC_BUTTON_CREATE_1)->EnableWindow(FALSE); 1686 GetDlgItem(IDC_BUTTON_DELETE_1)->EnableWindow(TRUE); 1687 GetDlgItem(IDC_COMBO_IP_1)->EnableWindow(TRUE); 1688 GetDlgItem(IDC_EDIT_TX_PORT_1)->EnableWindow(TRUE); 1689 GetDlgItem(IDC_EDIT_RX_PORT_1)->EnableWindow(TRUE); 1690 GetDlgItem(IDC_COMBO_CODEC_1)->EnableWindow(TRUE); 1691 GetDlgItem(IDC_LIST_CODEC_1)->EnableWindow(TRUE); 1692 GetDlgItem(IDC_EDIT_CODEC_1)->EnableWindow(TRUE); 1693 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(TRUE); 1694 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(TRUE); 1695 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(TRUE); 1696 GetDlgItem(IDC_CHECK_EXT_TRANS_1)->EnableWindow(TRUE); 1697 GetDlgItem(IDC_CHECK_PLAY_FILE_IN_1)->EnableWindow(TRUE); 1698 GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_1)->EnableWindow(TRUE); 1699 GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_1)->EnableWindow(TRUE); 1700 GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_1)->EnableWindow(TRUE); 1701 GetDlgItem(IDC_CHECK_VAD_1)->EnableWindow(TRUE); 1702 GetDlgItem(IDC_CHECK_MUTE_IN_1)->EnableWindow(TRUE); 1703 GetDlgItem(IDC_CHECK_SRTP_TX_1)->EnableWindow(TRUE); 1704 GetDlgItem(IDC_CHECK_SRTP_RX_1)->EnableWindow(TRUE); 1705 GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_1)->EnableWindow(TRUE); 1706 GetDlgItem(IDC_BUTTON_DTMF_1)->EnableWindow(TRUE); 1707 GetDlgItem(IDC_CHECK_ON_HOLD_1)->EnableWindow(TRUE); 1708 GetDlgItem(IDC_CHECK_DELAY_ESTIMATE_1)->EnableWindow(TRUE); 1709 GetDlgItem(IDC_CHECK_RXVAD)->EnableWindow(TRUE); 1710 GetDlgItem(IDC_CHECK_AGC_1)->EnableWindow(TRUE); 1711 GetDlgItem(IDC_CHECK_NS_1)->EnableWindow(TRUE); 1712 GetDlgItem(IDC_CHECK_RED)->EnableWindow(TRUE); 1713 1714 // Always set send codec to default codec <=> index 0. 1715 CodecInst codec; 1716 _veCodecPtr->GetCodec(0, codec); 1717 _veCodecPtr->SetSendCodec(channel, codec); 1718 } 1719 } 1720 1721 void CWinTestDlg::OnBnClickedButtonCreate2() 1722 { 1723 int channel(0); 1724 TEST((channel = _veBasePtr->CreateChannel()) >=0 , _T("CreateChannel(%d)"), channel); 1725 if (channel >= 0) 1726 { 1727 _veRtpRtcpPtr->RegisterRTPObserver(channel, *this); 1728 1729 SetDlgItemInt(IDC_EDIT_2, channel); 1730 GetDlgItem(IDC_BUTTON_CREATE_2)->EnableWindow(FALSE); 1731 GetDlgItem(IDC_BUTTON_DELETE_2)->EnableWindow(TRUE); 1732 GetDlgItem(IDC_COMBO_IP_2)->EnableWindow(TRUE); 1733 GetDlgItem(IDC_EDIT_TX_PORT_2)->EnableWindow(TRUE); 1734 GetDlgItem(IDC_EDIT_RX_PORT_2)->EnableWindow(TRUE); 1735 GetDlgItem(IDC_COMBO_CODEC_2)->EnableWindow(TRUE); 1736 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(TRUE); 1737 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(TRUE); 1738 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(TRUE); 1739 GetDlgItem(IDC_CHECK_EXT_TRANS_2)->EnableWindow(TRUE); 1740 GetDlgItem(IDC_CHECK_PLAY_FILE_IN_2)->EnableWindow(TRUE); 1741 GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_2)->EnableWindow(TRUE); 1742 GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_2)->EnableWindow(TRUE); 1743 GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_2)->EnableWindow(TRUE); 1744 GetDlgItem(IDC_CHECK_VAD_3)->EnableWindow(TRUE); 1745 GetDlgItem(IDC_CHECK_MUTE_IN_2)->EnableWindow(TRUE); 1746 GetDlgItem(IDC_CHECK_SRTP_TX_2)->EnableWindow(TRUE); 1747 GetDlgItem(IDC_CHECK_SRTP_RX_2)->EnableWindow(TRUE); 1748 GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_2)->EnableWindow(TRUE); 1749 GetDlgItem(IDC_BUTTON_DTMF_2)->EnableWindow(TRUE); 1750 GetDlgItem(IDC_CHECK_CONFERENCE_2)->EnableWindow(TRUE); 1751 GetDlgItem(IDC_CHECK_ON_HOLD_2)->EnableWindow(TRUE); 1752 1753 // Always set send codec to default codec <=> index 0. 1754 CodecInst codec; 1755 _veCodecPtr->GetCodec(0, codec); 1756 _veCodecPtr->SetSendCodec(channel, codec); 1757 } 1758 } 1759 1760 void CWinTestDlg::OnBnClickedButtonDelete1() 1761 { 1762 BOOL ret; 1763 int channel = GetDlgItemInt(IDC_EDIT_1, &ret); 1764 if (ret == TRUE) 1765 { 1766 _delayEstimate1 = false; 1767 _rxVad = false; 1768 _veRtpRtcpPtr->DeRegisterRTPObserver(channel); 1769 TEST(_veBasePtr->DeleteChannel(channel) == 0, _T("DeleteChannel(channel=%d)"), channel); 1770 SetDlgItemText(IDC_EDIT_1, _T("")); 1771 GetDlgItem(IDC_BUTTON_CREATE_1)->EnableWindow(TRUE); 1772 GetDlgItem(IDC_BUTTON_DELETE_1)->EnableWindow(FALSE); 1773 GetDlgItem(IDC_COMBO_IP_1)->EnableWindow(FALSE); 1774 GetDlgItem(IDC_EDIT_TX_PORT_1)->EnableWindow(FALSE); 1775 GetDlgItem(IDC_EDIT_RX_PORT_1)->EnableWindow(FALSE); 1776 GetDlgItem(IDC_COMBO_CODEC_1)->EnableWindow(FALSE); 1777 GetDlgItem(IDC_LIST_CODEC_1)->EnableWindow(FALSE); 1778 GetDlgItem(IDC_EDIT_CODEC_1)->EnableWindow(FALSE); 1779 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(FALSE); 1780 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(FALSE); 1781 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(FALSE); 1782 GetDlgItem(IDC_BUTTON_STOP_LISTEN_1)->EnableWindow(FALSE); 1783 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_1)->EnableWindow(FALSE); 1784 GetDlgItem(IDC_BUTTON_STOP_SEND_1)->EnableWindow(FALSE); 1785 GetDlgItem(IDC_BUTTON_DTMF_1)->EnableWindow(FALSE); 1786 GetDlgItem(IDC_CHECK_EXT_TRANS_1)->EnableWindow(FALSE); 1787 GetDlgItem(IDC_CHECK_PLAY_FILE_IN_1)->EnableWindow(FALSE); 1788 GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_1)->EnableWindow(FALSE); 1789 GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_1)->EnableWindow(FALSE); 1790 GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_1)->EnableWindow(FALSE); 1791 GetDlgItem(IDC_CHECK_VAD_1)->EnableWindow(FALSE); 1792 GetDlgItem(IDC_CHECK_MUTE_IN_1)->EnableWindow(FALSE); 1793 GetDlgItem(IDC_CHECK_SRTP_TX_1)->EnableWindow(FALSE); 1794 GetDlgItem(IDC_CHECK_SRTP_RX_1)->EnableWindow(FALSE); 1795 GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_1)->EnableWindow(FALSE); 1796 GetDlgItem(IDC_CHECK_CONFERENCE_1)->EnableWindow(FALSE); 1797 GetDlgItem(IDC_CHECK_ON_HOLD_1)->EnableWindow(FALSE); 1798 GetDlgItem(IDC_CHECK_DELAY_ESTIMATE_1)->EnableWindow(FALSE); 1799 GetDlgItem(IDC_CHECK_AGC_1)->EnableWindow(FALSE); 1800 GetDlgItem(IDC_CHECK_NS_1)->EnableWindow(FALSE); 1801 GetDlgItem(IDC_CHECK_RXVAD)->EnableWindow(FALSE); 1802 GetDlgItem(IDC_CHECK_RED)->EnableWindow(FALSE); 1803 SetDlgItemText(IDC_EDIT_RXVAD, _T("")); 1804 GetDlgItem(IDC_EDIT_RXVAD)->EnableWindow(FALSE); 1805 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EXT_TRANS_1); 1806 button->SetCheck(BST_UNCHECKED); 1807 button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_IN_1); 1808 button->SetCheck(BST_UNCHECKED); 1809 button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_1); 1810 button->SetCheck(BST_UNCHECKED); 1811 button = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_1); 1812 button->SetCheck(BST_UNCHECKED); 1813 button = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_1); 1814 button->SetCheck(BST_UNCHECKED); 1815 button = (CButton*)GetDlgItem(IDC_CHECK_VAD_1); 1816 button->SetCheck(BST_UNCHECKED); 1817 button = (CButton*)GetDlgItem(IDC_CHECK_MUTE_IN_1); 1818 button->SetCheck(BST_UNCHECKED); 1819 button = (CButton*)GetDlgItem(IDC_CHECK_SRTP_TX_1); 1820 button->SetCheck(BST_UNCHECKED); 1821 button = (CButton*)GetDlgItem(IDC_CHECK_SRTP_RX_1); 1822 button->SetCheck(BST_UNCHECKED); 1823 button = (CButton*)GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_1); 1824 button->SetCheck(BST_UNCHECKED); 1825 button = (CButton*)GetDlgItem(IDC_CHECK_CONFERENCE_1); 1826 button->SetCheck(BST_UNCHECKED); 1827 button = (CButton*)GetDlgItem(IDC_CHECK_ON_HOLD_1); 1828 button->SetCheck(BST_UNCHECKED); 1829 button = (CButton*)GetDlgItem(IDC_CHECK_DELAY_ESTIMATE_1); 1830 button->SetCheck(BST_UNCHECKED); 1831 button = (CButton*)GetDlgItem(IDC_CHECK_AGC_1); 1832 button->SetCheck(BST_UNCHECKED); 1833 button = (CButton*)GetDlgItem(IDC_CHECK_NS_1); 1834 button->SetCheck(BST_UNCHECKED); 1835 button = (CButton*)GetDlgItem(IDC_CHECK_RXVAD); 1836 button->SetCheck(BST_UNCHECKED); 1837 button = (CButton*)GetDlgItem(IDC_CHECK_RED); 1838 button->SetCheck(BST_UNCHECKED); 1839 } 1840 } 1841 1842 void CWinTestDlg::OnBnClickedButtonDelete2() 1843 { 1844 BOOL ret; 1845 int channel = GetDlgItemInt(IDC_EDIT_2, &ret); 1846 if (ret == TRUE) 1847 { 1848 _delayEstimate2 = false; 1849 _veRtpRtcpPtr->DeRegisterRTPObserver(channel); 1850 TEST(_veBasePtr->DeleteChannel(channel) == 0, _T("DeleteChannel(%d)"), channel); 1851 SetDlgItemText(IDC_EDIT_2, _T("")); 1852 GetDlgItem(IDC_BUTTON_CREATE_2)->EnableWindow(TRUE); 1853 GetDlgItem(IDC_BUTTON_DELETE_2)->EnableWindow(FALSE); 1854 GetDlgItem(IDC_COMBO_IP_2)->EnableWindow(FALSE); 1855 GetDlgItem(IDC_EDIT_TX_PORT_2)->EnableWindow(FALSE); 1856 GetDlgItem(IDC_EDIT_RX_PORT_2)->EnableWindow(FALSE); 1857 GetDlgItem(IDC_COMBO_CODEC_2)->EnableWindow(FALSE); 1858 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(FALSE); 1859 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(FALSE); 1860 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(FALSE); 1861 GetDlgItem(IDC_BUTTON_STOP_LISTEN_2)->EnableWindow(FALSE); 1862 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_2)->EnableWindow(FALSE); 1863 GetDlgItem(IDC_BUTTON_STOP_SEND_2)->EnableWindow(FALSE); 1864 GetDlgItem(IDC_CHECK_EXT_TRANS_2)->EnableWindow(FALSE); 1865 GetDlgItem(IDC_CHECK_PLAY_FILE_IN_2)->EnableWindow(FALSE); 1866 GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_2)->EnableWindow(FALSE); 1867 GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_2)->EnableWindow(FALSE); 1868 GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_2)->EnableWindow(FALSE); 1869 GetDlgItem(IDC_CHECK_MUTE_IN_2)->EnableWindow(FALSE); 1870 GetDlgItem(IDC_CHECK_VAD_3)->EnableWindow(FALSE); 1871 GetDlgItem(IDC_CHECK_SRTP_TX_2)->EnableWindow(FALSE); 1872 GetDlgItem(IDC_CHECK_SRTP_RX_2)->EnableWindow(FALSE); 1873 GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_2)->EnableWindow(FALSE); 1874 GetDlgItem(IDC_CHECK_CONFERENCE_2)->EnableWindow(FALSE); 1875 GetDlgItem(IDC_BUTTON_DTMF_2)->EnableWindow(FALSE); 1876 GetDlgItem(IDC_CHECK_ON_HOLD_2)->EnableWindow(FALSE); 1877 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EXT_TRANS_2); 1878 button->SetCheck(BST_UNCHECKED); 1879 button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_IN_2); 1880 button->SetCheck(BST_UNCHECKED); 1881 button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_2); 1882 button->SetCheck(BST_UNCHECKED); 1883 button = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_2); 1884 button->SetCheck(BST_UNCHECKED); 1885 button = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_2); 1886 button->SetCheck(BST_UNCHECKED); 1887 button = (CButton*)GetDlgItem(IDC_CHECK_VAD_3); 1888 button->SetCheck(BST_UNCHECKED); 1889 button = (CButton*)GetDlgItem(IDC_CHECK_MUTE_IN_2); 1890 button->SetCheck(BST_UNCHECKED); 1891 button = (CButton*)GetDlgItem(IDC_CHECK_SRTP_TX_2); 1892 button->SetCheck(BST_UNCHECKED); 1893 button = (CButton*)GetDlgItem(IDC_CHECK_SRTP_RX_2); 1894 button->SetCheck(BST_UNCHECKED); 1895 button = (CButton*)GetDlgItem(IDC_CHECK_EXT_ENCRYPTION_2); 1896 button->SetCheck(BST_UNCHECKED); 1897 button = (CButton*)GetDlgItem(IDC_CHECK_CONFERENCE_2); 1898 button->SetCheck(BST_UNCHECKED); 1899 button = (CButton*)GetDlgItem(IDC_CHECK_ON_HOLD_2); 1900 button->SetCheck(BST_UNCHECKED); 1901 } 1902 } 1903 1904 void CWinTestDlg::OnCbnSelchangeComboIp1() 1905 { 1906 int channel = GetDlgItemInt(IDC_EDIT_1); 1907 CString str; 1908 int port = GetDlgItemInt(IDC_EDIT_TX_PORT_1); 1909 CComboBox* comboIP = (CComboBox*)GetDlgItem(IDC_COMBO_IP_1); 1910 int n = comboIP->GetLBTextLen(0); 1911 comboIP->GetLBText(0, str.GetBuffer(n)); 1912 TEST(_veBasePtr->SetSendDestination(channel, port, TcharToChar(str.GetBuffer(n), -1)) == 0, 1913 _T("SetSendDestination(channel=%d, port=%d, ip=%s)"), channel, port, str.GetBuffer(n)); 1914 str.ReleaseBuffer(); 1915 } 1916 1917 void CWinTestDlg::OnCbnSelchangeComboIp2() 1918 { 1919 int channel = GetDlgItemInt(IDC_EDIT_2); 1920 CString str; 1921 int port = GetDlgItemInt(IDC_EDIT_TX_PORT_2); 1922 CComboBox* comboIP = (CComboBox*)GetDlgItem(IDC_COMBO_IP_2); 1923 int n = comboIP->GetLBTextLen(0); 1924 comboIP->GetLBText(0, str.GetBuffer(n)); 1925 TEST(_veBasePtr->SetSendDestination(channel, port, TcharToChar(str.GetBuffer(n), -1)) == 0, 1926 _T("SetSendDestination(channel=%d, port=%d, ip=%s)"), channel, port, str.GetBuffer(n)); 1927 str.ReleaseBuffer(); 1928 } 1929 1930 void CWinTestDlg::OnCbnSelchangeComboCodec1() 1931 { 1932 int channel = GetDlgItemInt(IDC_EDIT_1); 1933 1934 CodecInst codec; 1935 CComboBox* comboCodec(NULL); 1936 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_CODEC_1); 1937 int index = comboCodec->GetCurSel(); 1938 _veCodecPtr->GetCodec(index, codec); 1939 if (strncmp(codec.plname, "ISAC", 4) == 0) 1940 { 1941 // Set iSAC to adaptive mode by default. 1942 codec.rate = -1; 1943 } 1944 TEST(_veCodecPtr->SetSendCodec(channel, codec) == 0, 1945 _T("SetSendCodec(channel=%d, plname=%s, pltype=%d, plfreq=%d, rate=%d, pacsize=%d, channels=%d)"), 1946 channel, CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq, codec.rate, codec.pacsize, codec.channels); 1947 1948 CListBox* list = (CListBox*)GetDlgItem(IDC_LIST_CODEC_1); 1949 list->SetCurSel(0); 1950 SetDlgItemInt(IDC_EDIT_CODEC_1, codec.pltype); 1951 } 1952 1953 void CWinTestDlg::OnLbnSelchangeListCodec1() 1954 { 1955 int channel = GetDlgItemInt(IDC_EDIT_1); 1956 1957 CListBox* list = (CListBox*)GetDlgItem(IDC_LIST_CODEC_1); 1958 int listIdx = list->GetCurSel(); 1959 if (listIdx < 0) 1960 return; 1961 CString str; 1962 list->GetText(listIdx, str); 1963 1964 CodecInst codec; 1965 _veCodecPtr->GetSendCodec(channel, codec); 1966 1967 int value = GetDlgItemInt(IDC_EDIT_CODEC_1); 1968 if (str == _T("pltype")) 1969 { 1970 codec.pltype = value; 1971 } 1972 else if (str == _T("plfreq")) 1973 { 1974 codec.plfreq = value; 1975 } 1976 else if (str == _T("pacsize")) 1977 { 1978 codec.pacsize = value; 1979 } 1980 else if (str == _T("channels")) 1981 { 1982 codec.channels = value; 1983 } 1984 else if (str == _T("rate")) 1985 { 1986 codec.rate = value; 1987 } 1988 TEST(_veCodecPtr->SetSendCodec(channel, codec) == 0, 1989 _T("SetSendCodec(channel=%d, plname=%s, pltype=%d, plfreq=%d, rate=%d, pacsize=%d, channels=%d)"), 1990 channel, CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq, codec.rate, codec.pacsize, codec.channels); 1991 } 1992 1993 void CWinTestDlg::OnCbnSelchangeComboCodec2() 1994 { 1995 int channel = GetDlgItemInt(IDC_EDIT_2); 1996 1997 CodecInst codec; 1998 CComboBox* comboCodec(NULL); 1999 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_CODEC_2); 2000 int index = comboCodec->GetCurSel(); 2001 _veCodecPtr->GetCodec(index, codec); 2002 TEST(_veCodecPtr->SetSendCodec(channel, codec) == 0, 2003 _T("SetSendCodec(channel=%d, plname=%s, pltype=%d, plfreq=%d, rate=%d, pacsize=%d, channels=%d)"), 2004 channel, CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq, codec.rate, codec.pacsize, codec.channels); 2005 } 2006 2007 void CWinTestDlg::OnBnClickedButtonStartListen1() 2008 { 2009 int ret1(0); 2010 int ret2(0); 2011 int channel = GetDlgItemInt(IDC_EDIT_1); 2012 int port = GetDlgItemInt(IDC_EDIT_RX_PORT_1); 2013 TEST((ret1 = _veBasePtr->SetLocalReceiver(channel, port)) == 0, _T("SetLocalReceiver(channel=%d, port=%d)"), channel, port); 2014 TEST((ret2 = _veBasePtr->StartReceive(channel)) == 0, _T("StartReceive(channel=%d)"), channel); 2015 if (ret1 == 0 && ret2 == 0) 2016 { 2017 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(FALSE); 2018 GetDlgItem(IDC_BUTTON_STOP_LISTEN_1)->EnableWindow(TRUE); 2019 } 2020 } 2021 2022 void CWinTestDlg::OnBnClickedButtonStartListen2() 2023 { 2024 int ret1(0); 2025 int ret2(0); 2026 int channel = GetDlgItemInt(IDC_EDIT_2); 2027 int port = GetDlgItemInt(IDC_EDIT_RX_PORT_2); 2028 TEST((ret1 = _veBasePtr->SetLocalReceiver(channel, port)) == 0, _T("SetLocalReceiver(channel=%d, port=%d)"), channel, port); 2029 TEST((ret2 = _veBasePtr->StartReceive(channel)) == 0, _T("StartReceive(channel=%d)"), channel); 2030 if (ret1 == 0 && ret2 == 0) 2031 { 2032 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(FALSE); 2033 GetDlgItem(IDC_BUTTON_STOP_LISTEN_2)->EnableWindow(TRUE); 2034 } 2035 } 2036 2037 void CWinTestDlg::OnBnClickedButtonStopListen1() 2038 { 2039 int ret(0); 2040 int channel = GetDlgItemInt(IDC_EDIT_1); 2041 TEST((ret = _veBasePtr->StopReceive(channel)) == 0, _T("StopListen(channel=%d)"), channel); 2042 if (ret == 0) 2043 { 2044 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(TRUE); 2045 GetDlgItem(IDC_BUTTON_STOP_LISTEN_1)->EnableWindow(FALSE); 2046 } 2047 } 2048 2049 void CWinTestDlg::OnBnClickedButtonStopListen2() 2050 { 2051 int ret(0); 2052 int channel = GetDlgItemInt(IDC_EDIT_2); 2053 TEST((ret = _veBasePtr->StopReceive(channel)) == 0, _T("StopListen(channel=%d)"), channel); 2054 if (ret == 0) 2055 { 2056 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(TRUE); 2057 GetDlgItem(IDC_BUTTON_STOP_LISTEN_2)->EnableWindow(FALSE); 2058 } 2059 } 2060 2061 void CWinTestDlg::OnBnClickedButtonStartPlayout1() 2062 { 2063 int ret(0); 2064 int channel = GetDlgItemInt(IDC_EDIT_1); 2065 TEST((ret = _veBasePtr->StartPlayout(channel)) == 0, _T("StartPlayout(channel=%d)"), channel); 2066 if (ret == 0) 2067 { 2068 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(FALSE); 2069 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_1)->EnableWindow(TRUE); 2070 } 2071 } 2072 2073 void CWinTestDlg::OnBnClickedButtonStartPlayout2() 2074 { 2075 int ret(0); 2076 int channel = GetDlgItemInt(IDC_EDIT_2); 2077 TEST((ret = _veBasePtr->StartPlayout(channel)) == 0, _T("StartPlayout(channel=%d)"), channel); 2078 if (ret == 0) 2079 { 2080 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(FALSE); 2081 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_2)->EnableWindow(TRUE); 2082 } 2083 } 2084 2085 void CWinTestDlg::OnBnClickedButtonStopPlayout1() 2086 { 2087 int ret(0); 2088 int channel = GetDlgItemInt(IDC_EDIT_1); 2089 TEST((ret = _veBasePtr->StopPlayout(channel)) == 0, _T("StopPlayout(channel=%d)"), channel); 2090 if (ret == 0) 2091 { 2092 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(TRUE); 2093 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_1)->EnableWindow(FALSE); 2094 } 2095 } 2096 2097 void CWinTestDlg::OnBnClickedButtonStopPlayout2() 2098 { 2099 int ret(0); 2100 int channel = GetDlgItemInt(IDC_EDIT_2); 2101 TEST((ret = _veBasePtr->StopPlayout(channel)) == 0, _T("StopPlayout(channel=%d)")); 2102 if (ret == 0) 2103 { 2104 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(TRUE); 2105 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_2)->EnableWindow(FALSE); 2106 } 2107 } 2108 2109 void CWinTestDlg::OnBnClickedButtonStartSend1() 2110 { 2111 UpdateData(TRUE); // update IP address 2112 2113 int ret(0); 2114 int channel = GetDlgItemInt(IDC_EDIT_1); 2115 if (!_externalTransport) 2116 { 2117 CString str; 2118 int port = GetDlgItemInt(IDC_EDIT_TX_PORT_1); 2119 TEST(_veBasePtr->SetSendDestination(channel, port, TcharToChar(_strComboIp1.GetBuffer(7), -1)) == 0, 2120 _T("SetSendDestination(channel=%d, port=%d, ip=%s)"), channel, port, _strComboIp1.GetBuffer(7)); 2121 str.ReleaseBuffer(); 2122 } 2123 2124 //_veVideoSyncPtr->SetInitTimestamp(0,0); 2125 // OnCbnSelchangeComboCodec1(); 2126 2127 TEST((ret = _veBasePtr->StartSend(channel)) == 0, _T("StartSend(channel=%d)"), channel); 2128 if (ret == 0) 2129 { 2130 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(FALSE); 2131 GetDlgItem(IDC_BUTTON_STOP_SEND_1)->EnableWindow(TRUE); 2132 } 2133 } 2134 2135 void CWinTestDlg::OnBnClickedButtonStartSend2() 2136 { 2137 UpdateData(TRUE); // update IP address 2138 2139 int ret(0); 2140 int channel = GetDlgItemInt(IDC_EDIT_2); 2141 if (!_externalTransport) 2142 { 2143 CString str; 2144 int port = GetDlgItemInt(IDC_EDIT_TX_PORT_2); 2145 TEST(_veBasePtr->SetSendDestination(channel, port, TcharToChar(_strComboIp2.GetBuffer(7), -1)) == 0, 2146 _T("SetSendDestination(channel=%d, port=%d, ip=%s)"), channel, port, _strComboIp2.GetBuffer(7)); 2147 str.ReleaseBuffer(); 2148 } 2149 2150 // OnCbnSelchangeComboCodec2(); 2151 2152 TEST((ret = _veBasePtr->StartSend(channel)) == 0, _T("StartSend(channel=%d)"), channel); 2153 if (ret == 0) 2154 { 2155 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(FALSE); 2156 GetDlgItem(IDC_BUTTON_STOP_SEND_2)->EnableWindow(TRUE); 2157 } 2158 } 2159 2160 void CWinTestDlg::OnBnClickedButtonStopSend1() 2161 { 2162 int ret(0); 2163 int channel = GetDlgItemInt(IDC_EDIT_1); 2164 TEST((ret = _veBasePtr->StopSend(channel)) == 0, _T("StopSend(channel=%d)"), channel); 2165 if (ret == 0) 2166 { 2167 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(TRUE); 2168 GetDlgItem(IDC_BUTTON_STOP_SEND_1)->EnableWindow(FALSE); 2169 } 2170 } 2171 2172 void CWinTestDlg::OnBnClickedButtonStopSend2() 2173 { 2174 int ret(0); 2175 int channel = GetDlgItemInt(IDC_EDIT_2); 2176 TEST((ret = _veBasePtr->StopSend(channel)) == 0, _T("StopSend(channel=%d)"), channel); 2177 if (ret == 0) 2178 { 2179 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(TRUE); 2180 GetDlgItem(IDC_BUTTON_STOP_SEND_2)->EnableWindow(FALSE); 2181 } 2182 } 2183 2184 void CWinTestDlg::OnBnClickedCheckExtTrans1() 2185 { 2186 int ret(0); 2187 int channel = GetDlgItemInt(IDC_EDIT_1); 2188 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EXT_TRANS_1); 2189 int check = button->GetCheck(); 2190 const bool enable = (check == BST_CHECKED); 2191 if (enable) 2192 { 2193 TEST((ret = _veNetworkPtr->RegisterExternalTransport(channel, *_transportPtr)) == 0, 2194 _T("RegisterExternalTransport(channel=%d, transport=0x%x)"), channel, _transportPtr); 2195 } 2196 else 2197 { 2198 TEST((ret = _veNetworkPtr->DeRegisterExternalTransport(channel)) == 0, 2199 _T("DeRegisterExternalTransport(channel=%d)"), channel); 2200 } 2201 if (ret == 0) 2202 { 2203 _externalTransport = enable; 2204 } 2205 else 2206 { 2207 // restore inital state since API call failed 2208 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2209 } 2210 } 2211 2212 void CWinTestDlg::OnBnClickedCheckExtTrans2() 2213 { 2214 int ret(0); 2215 int channel = GetDlgItemInt(IDC_EDIT_2); 2216 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EXT_TRANS_2); 2217 int check = button->GetCheck(); 2218 const bool enable = (check == BST_CHECKED); 2219 if (enable) 2220 { 2221 TEST((ret = _veNetworkPtr->RegisterExternalTransport(channel, *_transportPtr)) == 0, 2222 _T("RegisterExternalTransport(channel=%d, transport=0x%x)"), channel, _transportPtr); 2223 } 2224 else 2225 { 2226 TEST((ret = _veNetworkPtr->DeRegisterExternalTransport(channel)) == 0, 2227 _T("DeRegisterExternalTransport(channel=%d)"), channel); 2228 } 2229 if (ret == 0) 2230 { 2231 _externalTransport = enable; 2232 } 2233 else 2234 { 2235 // restore inital state since API call failed 2236 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2237 } 2238 } 2239 2240 void CWinTestDlg::OnBnClickedCheckPlayFileIn1() 2241 { 2242 std::string micFile = _long_audio_file_path + "audio_short16.pcm"; 2243 2244 int ret(0); 2245 int channel = GetDlgItemInt(IDC_EDIT_1); 2246 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_IN_1); 2247 int check = button->GetCheck(); 2248 const bool enable = (check == BST_CHECKED); 2249 if (enable) 2250 { 2251 bool mix; 2252 const bool loop(true); 2253 const FileFormats format = kFileFormatPcm16kHzFile; 2254 const float scale(1.0); 2255 2256 (_checkPlayFileIn1 %2 == 0) ? mix = true : mix = false; 2257 TEST((ret = _veFilePtr->StartPlayingFileAsMicrophone(channel, 2258 micFile.c_str(), loop, mix, format, scale) == 0), 2259 _T("StartPlayingFileAsMicrophone(channel=%d, file=%s, loop=%d, ") 2260 _T("mix=%d, format=%d, scale=%2.1f)"), 2261 channel, CharToTchar(micFile.c_str(), -1), 2262 loop, mix, format, scale); 2263 _checkPlayFileIn1++; 2264 } 2265 else 2266 { 2267 TEST((ret = _veFilePtr->StopPlayingFileAsMicrophone(channel) == 0), 2268 _T("StopPlayingFileAsMicrophone(channel=%d)"), channel); 2269 } 2270 if (ret == -1) 2271 { 2272 // restore inital state since API call failed 2273 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2274 } 2275 } 2276 2277 void CWinTestDlg::OnBnClickedCheckPlayFileIn2() 2278 { 2279 std::string micFile = _long_audio_file_path + "audio_long16.pcm"; 2280 2281 int ret(0); 2282 int channel = GetDlgItemInt(IDC_EDIT_2); 2283 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_IN_2); 2284 int check = button->GetCheck(); 2285 const bool enable = (check == BST_CHECKED); 2286 if (enable) 2287 { 2288 bool mix; 2289 const bool loop(true); 2290 const FileFormats format = kFileFormatPcm16kHzFile; 2291 const float scale(1.0); 2292 2293 (_checkPlayFileIn2 %2 == 0) ? mix = true : mix = false; 2294 TEST((ret = _veFilePtr->StartPlayingFileAsMicrophone(channel, 2295 micFile.c_str(), loop, mix, format, scale) == 0), 2296 _T("StartPlayingFileAsMicrophone(channel=%d, file=%s, loop=%d, ") 2297 _T("mix=%d, format=%d, scale=%2.1f)"), 2298 channel, CharToTchar(micFile.c_str(), -1), 2299 loop, mix, format, scale); 2300 _checkPlayFileIn2++; 2301 } 2302 else 2303 { 2304 TEST((ret = _veFilePtr->StopPlayingFileAsMicrophone(channel) == 0), 2305 _T("StopPlayingFileAsMicrophone(channel=%d)"), channel); 2306 } 2307 if (ret == -1) 2308 { 2309 // restore inital state since API call failed 2310 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2311 } 2312 } 2313 2314 void CWinTestDlg::OnBnClickedCheckPlayFileOut1() 2315 { 2316 const FileFormats formats[8] = {{kFileFormatPcm16kHzFile}, 2317 {kFileFormatWavFile}, 2318 {kFileFormatWavFile}, 2319 {kFileFormatWavFile}, 2320 {kFileFormatWavFile}, 2321 {kFileFormatWavFile}, 2322 {kFileFormatWavFile}, 2323 {kFileFormatWavFile}}; 2324 // File path is relative to the location of 'voice_engine.gyp'. 2325 const char spkrFiles[8][64] = {{"audio_short16.pcm"}, 2326 {"audio_tiny8.wav"}, 2327 {"audio_tiny11.wav"}, 2328 {"audio_tiny16.wav"}, 2329 {"audio_tiny22.wav"}, 2330 {"audio_tiny32.wav"}, 2331 {"audio_tiny44.wav"}, 2332 {"audio_tiny48.wav"}}; 2333 int ret(0); 2334 int channel = GetDlgItemInt(IDC_EDIT_1); 2335 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_1); 2336 int check = button->GetCheck(); 2337 const bool enable = (check == BST_CHECKED); 2338 if (enable) 2339 { 2340 const bool loop(true); 2341 const float volumeScaling(1.0); 2342 const int startPointMs(0); 2343 const int stopPointMs(0); 2344 const FileFormats format = formats[_checkPlayFileOut1 % 8]; 2345 std::string spkrFile = _long_audio_file_path + 2346 spkrFiles[_checkPlayFileOut1 % 8]; 2347 2348 CString str; 2349 if (_checkPlayFileOut1 % 8 == 0) 2350 { 2351 str = _T("kFileFormatPcm16kHzFile"); 2352 } 2353 else 2354 { 2355 str = _T("kFileFormatWavFile"); 2356 } 2357 // (_checkPlayFileOut1 %2 == 0) ? mix = true : mix = false; 2358 TEST((ret = _veFilePtr->StartPlayingFileLocally(channel, 2359 spkrFile.c_str(), loop, format, volumeScaling, 2360 startPointMs,stopPointMs) == 0), 2361 _T("StartPlayingFileLocally(channel=%d, file=%s, loop=%d, ") 2362 _T("format=%s, scale=%2.1f, start=%d, stop=%d)"), 2363 channel, CharToTchar(spkrFile.c_str(), -1), 2364 loop, str, volumeScaling, startPointMs, stopPointMs); 2365 _checkPlayFileOut1++; 2366 } 2367 else 2368 { 2369 TEST((ret = _veFilePtr->StopPlayingFileLocally(channel) == 0), 2370 _T("StopPlayingFileLocally(channel=%d)"), channel); 2371 } 2372 if (ret == -1) 2373 { 2374 // restore inital state since API call failed 2375 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2376 } 2377 } 2378 2379 void CWinTestDlg::OnBnClickedCheckPlayFileOut2() 2380 { 2381 std::string spkrFile = _long_audio_file_path + "audio_long16.pcm"; 2382 2383 int ret(0); 2384 int channel = GetDlgItemInt(IDC_EDIT_2); 2385 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_OUT_2); 2386 int check = button->GetCheck(); 2387 const bool enable = (check == BST_CHECKED); 2388 if (enable) 2389 { 2390 const bool loop(true); 2391 const FileFormats format = kFileFormatPcm16kHzFile; 2392 const float volumeScaling(1.0); 2393 const int startPointMs(0); 2394 const int stopPointMs(0); 2395 2396 // (_checkPlayFileOut2 %2 == 0) ? mix = true : mix = false; 2397 TEST((ret = _veFilePtr->StartPlayingFileLocally(channel, 2398 spkrFile.c_str(), loop, format, volumeScaling, 2399 startPointMs,stopPointMs) == 0), 2400 _T("StartPlayingFileLocally(channel=%d, file=%s, loop=%d, ") 2401 _T("format=%d, scale=%2.1f, start=%d, stop=%d)"), 2402 channel, CharToTchar(spkrFile.c_str(), -1), 2403 loop, format, volumeScaling, startPointMs, stopPointMs); 2404 // _checkPlayFileIn2++; 2405 } 2406 else 2407 { 2408 TEST((ret = _veFilePtr->StopPlayingFileLocally(channel) == 0), 2409 _T("StopPlayingFileLocally(channel=%d)"), channel); 2410 } 2411 if (ret == -1) 2412 { 2413 // restore inital state since API call failed 2414 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2415 } 2416 } 2417 2418 void CWinTestDlg::OnBnClickedCheckExtMediaIn1() 2419 { 2420 int channel = GetDlgItemInt(IDC_EDIT_1); 2421 CButton* buttonExtTrans = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_1); 2422 int check = buttonExtTrans->GetCheck(); 2423 const bool enable = (check == BST_CHECKED); 2424 if (enable) 2425 { 2426 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kRecordingPerChannel, *_externalMediaPtr) == 0, 2427 _T("RegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel, processObject=0x%x)"), channel, _externalMediaPtr); 2428 } 2429 else 2430 { 2431 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kRecordingPerChannel) == 0, 2432 _T("DeRegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel)"), channel); 2433 } 2434 } 2435 2436 void CWinTestDlg::OnBnClickedCheckExtMediaIn2() 2437 { 2438 int channel = GetDlgItemInt(IDC_EDIT_2); 2439 CButton* buttonExtTrans = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_IN_2); 2440 int check = buttonExtTrans->GetCheck(); 2441 const bool enable = (check == BST_CHECKED); 2442 if (enable) 2443 { 2444 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kRecordingPerChannel, *_externalMediaPtr) == 0, 2445 _T("RegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel, processObject=0x%x)"), channel, _externalMediaPtr); 2446 } 2447 else 2448 { 2449 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kRecordingPerChannel) == 0, 2450 _T("DeRegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel)"), channel); 2451 } 2452 } 2453 2454 void CWinTestDlg::OnBnClickedCheckExtMediaOut1() 2455 { 2456 int channel = GetDlgItemInt(IDC_EDIT_1); 2457 CButton* buttonExtTrans = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_1); 2458 int check = buttonExtTrans->GetCheck(); 2459 const bool enable = (check == BST_CHECKED); 2460 if (enable) 2461 { 2462 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kPlaybackPerChannel, *_externalMediaPtr) == 0, 2463 _T("RegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel, processObject=0x%x)"), channel, _externalMediaPtr); 2464 } 2465 else 2466 { 2467 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kPlaybackPerChannel) == 0, 2468 _T("DeRegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel)"), channel); 2469 } 2470 } 2471 2472 void CWinTestDlg::OnBnClickedCheckExtMediaOut2() 2473 { 2474 int channel = GetDlgItemInt(IDC_EDIT_2); 2475 CButton* buttonExtTrans = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT_2); 2476 int check = buttonExtTrans->GetCheck(); 2477 const bool enable = (check == BST_CHECKED); 2478 if (enable) 2479 { 2480 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kPlaybackPerChannel, *_externalMediaPtr) == 0, 2481 _T("RegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel, processObject=0x%x)"), channel, _externalMediaPtr); 2482 } 2483 else 2484 { 2485 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kPlaybackPerChannel) == 0, 2486 _T("DeRegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel)"), channel); 2487 } 2488 } 2489 2490 void CWinTestDlg::OnBnClickedCheckVad1() 2491 { 2492 int ret(0); 2493 int channel = GetDlgItemInt(IDC_EDIT_1); 2494 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_VAD_1); 2495 int check = button->GetCheck(); 2496 const bool enable = (check == BST_CHECKED); 2497 if (enable) 2498 { 2499 CString str; 2500 VadModes mode(kVadConventional); 2501 if (_checkVAD1 % 4 == 0) 2502 { 2503 mode = kVadConventional; 2504 str = _T("kVadConventional"); 2505 } 2506 else if (_checkVAD1 % 4 == 1) 2507 { 2508 mode = kVadAggressiveLow; 2509 str = _T("kVadAggressiveLow"); 2510 } 2511 else if (_checkVAD1 % 4 == 2) 2512 { 2513 mode = kVadAggressiveMid; 2514 str = _T("kVadAggressiveMid"); 2515 } 2516 else if (_checkVAD1 % 4 == 3) 2517 { 2518 mode = kVadAggressiveHigh; 2519 str = _T("kVadAggressiveHigh"); 2520 } 2521 const bool disableDTX(false); 2522 TEST((ret = _veCodecPtr->SetVADStatus(channel, true, mode, disableDTX) == 0), 2523 _T("SetVADStatus(channel=%d, enable=%d, mode=%s, disableDTX=%d)"), channel, enable, str, disableDTX); 2524 _checkVAD1++; 2525 } 2526 else 2527 { 2528 TEST((ret = _veCodecPtr->SetVADStatus(channel, false)) == 0, _T("SetVADStatus(channel=%d, enable=%d)"), channel, false); 2529 } 2530 if (ret == -1) 2531 { 2532 // restore inital state since API call failed 2533 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2534 } 2535 } 2536 2537 void CWinTestDlg::OnBnClickedCheckVad2() 2538 { 2539 int ret(0); 2540 int channel = GetDlgItemInt(IDC_EDIT_2); 2541 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_VAD_2); 2542 int check = button->GetCheck(); 2543 const bool enable = (check == BST_CHECKED); 2544 if (enable) 2545 { 2546 CString str; 2547 VadModes mode(kVadConventional); 2548 if (_checkVAD2 % 4 == 0) 2549 { 2550 mode = kVadConventional; 2551 str = _T("kVadConventional"); 2552 } 2553 else if (_checkVAD2 % 4 == 1) 2554 { 2555 mode = kVadAggressiveLow; 2556 str = _T("kVadAggressiveLow"); 2557 } 2558 else if (_checkVAD2 % 4 == 2) 2559 { 2560 mode = kVadAggressiveMid; 2561 str = _T("kVadAggressiveMid"); 2562 } 2563 else if (_checkVAD2 % 4 == 3) 2564 { 2565 mode = kVadAggressiveHigh; 2566 str = _T("kVadAggressiveHigh"); 2567 } 2568 const bool disableDTX(false); 2569 TEST((ret = _veCodecPtr->SetVADStatus(channel, true, mode, disableDTX)) == 0, 2570 _T("SetVADStatus(channel=%d, enable=%d, mode=%s, disableDTX=%d)"), channel, enable, str, disableDTX); 2571 _checkVAD2++; 2572 } 2573 else 2574 { 2575 TEST((ret = _veCodecPtr->SetVADStatus(channel, false) == 0), _T("SetVADStatus(channel=%d, enable=%d)"), channel, false); 2576 } 2577 if (ret == -1) 2578 { 2579 // restore inital state since API call failed 2580 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2581 } 2582 } 2583 2584 void CWinTestDlg::OnBnClickedCheckMuteIn1() 2585 { 2586 int channel = GetDlgItemInt(IDC_EDIT_1); 2587 CButton* buttonMute = (CButton*)GetDlgItem(IDC_CHECK_MUTE_IN_1); 2588 int check = buttonMute->GetCheck(); 2589 const bool enable = (check == BST_CHECKED); 2590 TEST(_veVolumeControlPtr->SetInputMute(channel, enable) == 0, 2591 _T("SetInputMute(channel=%d, enable=%d)"), channel, enable); 2592 } 2593 2594 void CWinTestDlg::OnBnClickedCheckMuteIn2() 2595 { 2596 int channel = GetDlgItemInt(IDC_EDIT_2); 2597 CButton* buttonMute = (CButton*)GetDlgItem(IDC_CHECK_MUTE_IN_2); 2598 int check = buttonMute->GetCheck(); 2599 const bool enable = (check == BST_CHECKED); 2600 TEST(_veVolumeControlPtr->SetInputMute(channel, enable) == 0, 2601 _T("SetInputMute(channel=%d, enable=%d)"), channel, enable); 2602 } 2603 2604 void CWinTestDlg::OnBnClickedCheckSrtpTx1() 2605 { 2606 TEST(true, "Built-in SRTP support is deprecated."); 2607 } 2608 2609 void CWinTestDlg::OnBnClickedCheckSrtpTx2() 2610 { 2611 TEST(true, "Built-in SRTP support is deprecated."); 2612 } 2613 2614 void CWinTestDlg::OnBnClickedCheckSrtpRx1() 2615 { 2616 TEST(true, "Built-in SRTP support is deprecated."); 2617 } 2618 2619 void CWinTestDlg::OnBnClickedCheckSrtpRx2() 2620 { 2621 TEST(true, "Built-in SRTP support is deprecated."); 2622 } 2623 2624 void CWinTestDlg::OnBnClickedCheckExtEncryption1() 2625 { 2626 TEST(true, "External Encryption has been removed from the API!"); 2627 } 2628 2629 void CWinTestDlg::OnBnClickedCheckExtEncryption2() 2630 { 2631 TEST(true, "External Encryption has been removed from the API!"); 2632 } 2633 2634 void CWinTestDlg::OnBnClickedButtonDtmf1() 2635 { 2636 int channel = GetDlgItemInt(IDC_EDIT_1); 2637 CTelephonyEvent dlgTelephoneEvent(_vePtr, channel, this); 2638 dlgTelephoneEvent.DoModal(); 2639 } 2640 2641 void CWinTestDlg::OnBnClickedButtonDtmf2() 2642 { 2643 int channel = GetDlgItemInt(IDC_EDIT_2); 2644 CTelephonyEvent dlgTelephoneEvent(_vePtr, channel, this); 2645 dlgTelephoneEvent.DoModal(); 2646 } 2647 2648 void CWinTestDlg::OnBnClickedCheckConference1() 2649 { 2650 // Not supported yet 2651 } 2652 2653 void CWinTestDlg::OnBnClickedCheckConference2() 2654 { 2655 // Not supported yet 2656 } 2657 2658 void CWinTestDlg::OnBnClickedCheckOnHold1() 2659 { 2660 SHORT shiftKeyIsPressed = ::GetAsyncKeyState(VK_SHIFT); 2661 2662 CString str; 2663 int channel = GetDlgItemInt(IDC_EDIT_1); 2664 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_ON_HOLD_1); 2665 int check = button->GetCheck(); 2666 2667 if (shiftKeyIsPressed) 2668 { 2669 bool enabled(false); 2670 OnHoldModes mode(kHoldSendAndPlay); 2671 TEST(_veBasePtr->GetOnHoldStatus(channel, enabled, mode) == 0, 2672 _T("GetOnHoldStatus(channel=%d, enabled=?, mode=?)"), channel); 2673 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2674 2675 switch (mode) 2676 { 2677 case kHoldSendAndPlay: 2678 str = _T("kHoldSendAndPlay"); 2679 break; 2680 case kHoldSendOnly: 2681 str = _T("kHoldSendOnly"); 2682 break; 2683 case kHoldPlayOnly: 2684 str = _T("kHoldPlayOnly"); 2685 break; 2686 default: 2687 break; 2688 } 2689 PRINT_GET_RESULT(_T("enabled=%d, mode=%s"), enabled, str); 2690 return; 2691 } 2692 2693 int ret(0); 2694 const bool enable = (check == BST_CHECKED); 2695 if (enable) 2696 { 2697 OnHoldModes mode(kHoldSendAndPlay); 2698 if (_checkOnHold1 % 3 == 0) 2699 { 2700 mode = kHoldSendAndPlay; 2701 str = _T("kHoldSendAndPlay"); 2702 } 2703 else if (_checkOnHold1 % 3 == 1) 2704 { 2705 mode = kHoldSendOnly; 2706 str = _T("kHoldSendOnly"); 2707 } 2708 else if (_checkOnHold1 % 3 == 2) 2709 { 2710 mode = kHoldPlayOnly; 2711 str = _T("kHoldPlayOnly"); 2712 } 2713 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable, mode)) == 0, 2714 _T("SetOnHoldStatus(channel=%d, enable=%d, mode=%s)"), channel, enable, str); 2715 _checkOnHold1++; 2716 } 2717 else 2718 { 2719 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable)) == 0, 2720 _T("SetOnHoldStatus(channel=%d, enable=%d)"), channel, enable); 2721 } 2722 } 2723 2724 void CWinTestDlg::OnBnClickedCheckOnHold2() 2725 { 2726 int ret(0); 2727 int channel = GetDlgItemInt(IDC_EDIT_2); 2728 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_ON_HOLD_2); 2729 int check = button->GetCheck(); 2730 const bool enable = (check == BST_CHECKED); 2731 if (enable) 2732 { 2733 CString str; 2734 OnHoldModes mode(kHoldSendAndPlay); 2735 if (_checkOnHold1 % 3 == 0) 2736 { 2737 mode = kHoldSendAndPlay; 2738 str = _T("kHoldSendAndPlay"); 2739 } 2740 else if (_checkOnHold1 % 3 == 1) 2741 { 2742 mode = kHoldSendOnly; 2743 str = _T("kHoldSendOnly"); 2744 } 2745 else if (_checkOnHold1 % 3 == 2) 2746 { 2747 mode = kHoldPlayOnly; 2748 str = _T("kHoldPlayOnly"); 2749 } 2750 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable, mode)) == 0, 2751 _T("SetOnHoldStatus(channel=%d, enable=%d, mode=%s)"), channel, enable, str); 2752 _checkOnHold1++; 2753 } 2754 else 2755 { 2756 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable)) == 0, 2757 _T("SetOnHoldStatus(channel=%d, enable=%d)"), channel, enable); 2758 } 2759 } 2760 2761 void CWinTestDlg::OnBnClickedCheckDelayEstimate1() 2762 { 2763 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DELAY_ESTIMATE_1); 2764 int check = button->GetCheck(); 2765 const bool enable = (check == BST_CHECKED); 2766 2767 if (enable) 2768 { 2769 _delayEstimate1 = true; 2770 SetDlgItemInt(IDC_EDIT_DELAY_ESTIMATE_1, 0); 2771 } 2772 else 2773 { 2774 _delayEstimate1 = false; 2775 SetDlgItemText(IDC_EDIT_DELAY_ESTIMATE_1, _T("")); 2776 } 2777 } 2778 2779 void CWinTestDlg::OnBnClickedCheckRxvad() 2780 { 2781 int channel = GetDlgItemInt(IDC_EDIT_1); 2782 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_RXVAD); 2783 int check = button->GetCheck(); 2784 const bool enable = (check == BST_CHECKED); 2785 2786 if (enable) 2787 { 2788 _rxVad = true; 2789 _veApmPtr->RegisterRxVadObserver(channel, *_rxVadObserverPtr); 2790 SetDlgItemInt(IDC_EDIT_RXVAD, 0); 2791 } 2792 else 2793 { 2794 _rxVad = false; 2795 _veApmPtr->DeRegisterRxVadObserver(channel); 2796 SetDlgItemText(IDC_EDIT_RXVAD, _T("")); 2797 } 2798 } 2799 2800 void CWinTestDlg::OnBnClickedCheckAgc1() 2801 { 2802 SHORT shiftKeyIsPressed = ::GetAsyncKeyState(VK_SHIFT); 2803 2804 CString str; 2805 int channel = GetDlgItemInt(IDC_EDIT_1); 2806 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_AGC_1); 2807 int check = button->GetCheck(); 2808 const bool enable = (check == BST_CHECKED); 2809 2810 if (shiftKeyIsPressed) 2811 { 2812 bool enabled(false); 2813 AgcModes mode(kAgcAdaptiveDigital); 2814 TEST(_veApmPtr->GetRxAgcStatus(channel, enabled, mode) == 0, 2815 _T("GetRxAgcStatus(channel=%d, enabled=?, mode=?)"), channel); 2816 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED); 2817 2818 switch (mode) 2819 { 2820 case kAgcAdaptiveAnalog: 2821 str = _T("kAgcAdaptiveAnalog"); 2822 break; 2823 case kAgcAdaptiveDigital: 2824 str = _T("kAgcAdaptiveDigital"); 2825 break; 2826 case kAgcFixedDigital: 2827 str = _T("kAgcFixedDigital"); 2828 break; 2829 default: 2830 break; 2831 } 2832 PRINT_GET_RESULT(_T("enabled=%d, mode=%s"), enabled, str); 2833 return; 2834 } 2835 2836 if (enable) 2837 { 2838 CString str; 2839 AgcModes mode(kAgcDefault); 2840 if (_checkAGC1 % 3 == 0) 2841 { 2842 mode = kAgcDefault; 2843 str = _T("kAgcDefault"); 2844 } 2845 else if (_checkAGC1 % 3 == 1) 2846 { 2847 mode = kAgcAdaptiveDigital; 2848 str = _T("kAgcAdaptiveDigital"); 2849 } 2850 else if (_checkAGC1 % 3 == 2) 2851 { 2852 mode = kAgcFixedDigital; 2853 str = _T("kAgcFixedDigital"); 2854 } 2855 TEST(_veApmPtr->SetRxAgcStatus(channel, true, mode) == 0, _T("SetRxAgcStatus(channel=%d, enable=%d, %s)"), channel, enable, str); 2856 _checkAGC1++; 2857 } 2858 else 2859 { 2860 TEST(_veApmPtr->SetRxAgcStatus(channel, false, kAgcUnchanged) == 0, _T("SetRxAgcStatus(channel=%d, enable=%d)"), channel, enable); 2861 } 2862 } 2863 2864 void CWinTestDlg::OnBnClickedCheckNs1() 2865 { 2866 int channel = GetDlgItemInt(IDC_EDIT_1); 2867 CButton* buttonNS = (CButton*)GetDlgItem(IDC_CHECK_NS_1); 2868 int check = buttonNS->GetCheck(); 2869 const bool enable = (check == BST_CHECKED); 2870 if (enable) 2871 { 2872 CString str; 2873 NsModes mode(kNsDefault); 2874 if (_checkNS1 % 6 == 0) 2875 { 2876 mode = kNsDefault; 2877 str = _T("kNsDefault"); 2878 } 2879 else if (_checkNS1 % 6 == 1) 2880 { 2881 mode = kNsConference; 2882 str = _T("kNsConference"); 2883 } 2884 else if (_checkNS1 % 6 == 2) 2885 { 2886 mode = kNsLowSuppression; 2887 str = _T("kNsLowSuppression"); 2888 } 2889 else if (_checkNS1 % 6 == 3) 2890 { 2891 mode = kNsModerateSuppression; 2892 str = _T("kNsModerateSuppression"); 2893 } 2894 else if (_checkNS1 % 6 == 4) 2895 { 2896 mode = kNsHighSuppression; 2897 str = _T("kNsHighSuppression"); 2898 } 2899 else if (_checkNS1 % 6 == 5) 2900 { 2901 mode = kNsVeryHighSuppression; 2902 str = _T("kNsVeryHighSuppression"); 2903 } 2904 TEST(_veApmPtr->SetRxNsStatus(channel, true, mode) == 0, _T("SetRxNsStatus(channel=%d, enable=%d, %s)"), channel, enable, str); 2905 _checkNS1++; 2906 } 2907 else 2908 { 2909 TEST(_veApmPtr->SetRxNsStatus(channel, false, kNsUnchanged) == 0, _T("SetRxNsStatus(channel=%d, enable=%d)"), enable, channel); 2910 } 2911 } 2912 2913 // ---------------------------------------------------------------------------- 2914 // Channel-independent Operations 2915 // ---------------------------------------------------------------------------- 2916 2917 void CWinTestDlg::OnBnClickedCheckPlayFileIn() 2918 { 2919 std::string micFile = _long_audio_file_path + "audio_short16.pcm"; 2920 // std::string micFile = _long_audio_file_path + "audio_long16noise.pcm"; 2921 2922 int channel(-1); 2923 CButton* buttonExtTrans = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_IN); 2924 int check = buttonExtTrans->GetCheck(); 2925 const bool enable = (check == BST_CHECKED); 2926 if (enable) 2927 { 2928 bool mix; 2929 const bool loop(true); 2930 const FileFormats format = kFileFormatPcm16kHzFile; 2931 const float scale(1.0); 2932 2933 (_checkPlayFileIn %2 == 0) ? mix = true : mix = false; 2934 TEST(_veFilePtr->StartPlayingFileAsMicrophone(channel, 2935 micFile.c_str(), loop, mix, format, scale) == 0, 2936 _T("StartPlayingFileAsMicrophone(channel=%d, file=%s, ") 2937 _T("loop=%d, mix=%d, format=%d, scale=%2.1f)"), 2938 channel, CharToTchar(micFile.c_str(), -1), 2939 loop, mix, format, scale); 2940 _checkPlayFileIn++; 2941 } 2942 else 2943 { 2944 TEST(_veFilePtr->StopPlayingFileAsMicrophone(channel) == 0, 2945 _T("StopPlayingFileAsMicrophone(channel=%d)"), channel); 2946 } 2947 } 2948 2949 void CWinTestDlg::OnBnClickedCheckRecMic() 2950 { 2951 std::string micFile = webrtc::test::OutputPath() + 2952 "rec_mic_mono_16kHz.pcm"; 2953 2954 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_REC_MIC); 2955 int check = button->GetCheck(); 2956 const bool enable = (check == BST_CHECKED); 2957 if (enable) 2958 { 2959 TEST(_veFilePtr->StartRecordingMicrophone(micFile.c_str(), NULL) == 0, 2960 _T("StartRecordingMicrophone(file=%s)"), 2961 CharToTchar(micFile.c_str(), -1)); 2962 } 2963 else 2964 { 2965 TEST(_veFilePtr->StopRecordingMicrophone() == 0, 2966 _T("StopRecordingMicrophone()")); 2967 } 2968 } 2969 2970 void CWinTestDlg::OnBnClickedCheckAgc() 2971 { 2972 CButton* buttonAGC = (CButton*)GetDlgItem(IDC_CHECK_AGC); 2973 int check = buttonAGC->GetCheck(); 2974 const bool enable = (check == BST_CHECKED); 2975 if (enable) 2976 { 2977 CString str; 2978 AgcModes mode(kAgcDefault); 2979 if (_checkAGC % 4 == 0) 2980 { 2981 mode = kAgcDefault; 2982 str = _T("kAgcDefault"); 2983 } 2984 else if (_checkAGC % 4 == 1) 2985 { 2986 mode = kAgcAdaptiveAnalog; 2987 str = _T("kAgcAdaptiveAnalog"); 2988 } 2989 else if (_checkAGC % 4 == 2) 2990 { 2991 mode = kAgcAdaptiveDigital; 2992 str = _T("kAgcAdaptiveDigital"); 2993 } 2994 else if (_checkAGC % 4 == 3) 2995 { 2996 mode = kAgcFixedDigital; 2997 str = _T("kAgcFixedDigital"); 2998 } 2999 TEST(_veApmPtr->SetAgcStatus(true, mode) == 0, _T("SetAgcStatus(enable=%d, %s)"), enable, str); 3000 _checkAGC++; 3001 } 3002 else 3003 { 3004 TEST(_veApmPtr->SetAgcStatus(false, kAgcUnchanged) == 0, _T("SetAgcStatus(enable=%d)"), enable); 3005 } 3006 } 3007 3008 void CWinTestDlg::OnBnClickedCheckNs() 3009 { 3010 CButton* buttonNS = (CButton*)GetDlgItem(IDC_CHECK_NS); 3011 int check = buttonNS->GetCheck(); 3012 const bool enable = (check == BST_CHECKED); 3013 if (enable) 3014 { 3015 CString str; 3016 NsModes mode(kNsDefault); 3017 if (_checkNS % 6 == 0) 3018 { 3019 mode = kNsDefault; 3020 str = _T("kNsDefault"); 3021 } 3022 else if (_checkNS % 6 == 1) 3023 { 3024 mode = kNsConference; 3025 str = _T("kNsConference"); 3026 } 3027 else if (_checkNS % 6 == 2) 3028 { 3029 mode = kNsLowSuppression; 3030 str = _T("kNsLowSuppression"); 3031 } 3032 else if (_checkNS % 6 == 3) 3033 { 3034 mode = kNsModerateSuppression; 3035 str = _T("kNsModerateSuppression"); 3036 } 3037 else if (_checkNS % 6 == 4) 3038 { 3039 mode = kNsHighSuppression; 3040 str = _T("kNsHighSuppression"); 3041 } 3042 else if (_checkNS % 6 == 5) 3043 { 3044 mode = kNsVeryHighSuppression; 3045 str = _T("kNsVeryHighSuppression"); 3046 } 3047 TEST(_veApmPtr->SetNsStatus(true, mode) == 0, _T("SetNsStatus(enable=%d, %s)"), enable, str); 3048 _checkNS++; 3049 } 3050 else 3051 { 3052 TEST(_veApmPtr->SetNsStatus(false, kNsUnchanged) == 0, _T("SetNsStatus(enable=%d)"), enable); 3053 } 3054 } 3055 3056 void CWinTestDlg::OnBnClickedCheckEc() 3057 { 3058 CButton* buttonEC = (CButton*)GetDlgItem(IDC_CHECK_EC); 3059 int check = buttonEC->GetCheck(); 3060 const bool enable = (check == BST_CHECKED); 3061 if (enable) 3062 { 3063 CString str; 3064 EcModes mode(kEcDefault); 3065 if (_checkEC % 4 == 0) 3066 { 3067 mode = kEcDefault; 3068 str = _T("kEcDefault"); 3069 } 3070 else if (_checkEC % 4 == 1) 3071 { 3072 mode = kEcConference; 3073 str = _T("kEcConference"); 3074 } 3075 else if (_checkEC % 4 == 2) 3076 { 3077 mode = kEcAec; 3078 str = _T("kEcAec"); 3079 } 3080 else if (_checkEC % 4 == 3) 3081 { 3082 mode = kEcAecm; 3083 str = _T("kEcAecm"); 3084 } 3085 TEST(_veApmPtr->SetEcStatus(true, mode) == 0, _T("SetEcStatus(enable=%d, %s)"), enable, str); 3086 _checkEC++; 3087 } 3088 else 3089 { 3090 TEST(_veApmPtr->SetEcStatus(false, kEcUnchanged) == 0, _T("SetEcStatus(enable=%d)"), enable); 3091 } 3092 } 3093 3094 void CWinTestDlg::OnBnClickedCheckMuteIn() 3095 { 3096 CButton* buttonMute = (CButton*)GetDlgItem(IDC_CHECK_MUTE_IN); 3097 int check = buttonMute->GetCheck(); 3098 const bool enable = (check == BST_CHECKED); 3099 const int channel(-1); 3100 TEST(_veVolumeControlPtr->SetInputMute(channel, enable) == 0, 3101 _T("SetInputMute(channel=%d, enable=%d)"), channel, enable); 3102 } 3103 3104 void CWinTestDlg::OnBnClickedCheckExtMediaIn() 3105 { 3106 const int channel(-1); 3107 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_IN); 3108 int check = button->GetCheck(); 3109 const bool enable = (check == BST_CHECKED); 3110 if (enable) 3111 { 3112 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kRecordingAllChannelsMixed, *_externalMediaPtr) == 0, 3113 _T("RegisterExternalMediaProcessing(channel=%d, kRecordingAllChannelsMixed, processObject=0x%x)"), channel, _externalMediaPtr); 3114 } 3115 else 3116 { 3117 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kRecordingAllChannelsMixed) == 0, 3118 _T("DeRegisterExternalMediaProcessing(channel=%d, kRecordingAllChannelsMixed)"), channel); 3119 } 3120 } 3121 3122 void CWinTestDlg::OnBnClickedCheckExtMediaOut() 3123 { 3124 const int channel(-1); 3125 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EXT_MEDIA_OUT); 3126 int check = button->GetCheck(); 3127 const bool enable = (check == BST_CHECKED); 3128 if (enable) 3129 { 3130 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kPlaybackAllChannelsMixed, *_externalMediaPtr) == 0, 3131 _T("RegisterExternalMediaProcessing(channel=%d, kPlaybackAllChannelsMixed, processObject=0x%x)"), channel, _externalMediaPtr); 3132 } 3133 else 3134 { 3135 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kPlaybackAllChannelsMixed) == 0, 3136 _T("DeRegisterExternalMediaProcessing(channel=%d, kPlaybackAllChannelsMixed)"), channel); 3137 } 3138 } 3139 3140 void CWinTestDlg::OnCbnSelchangeComboRecDevice() 3141 { 3142 CComboBox* comboCodec(NULL); 3143 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_REC_DEVICE); 3144 int index = comboCodec->GetCurSel(); 3145 TEST(_veHardwarePtr->SetRecordingDevice(index) == 0, 3146 _T("SetRecordingDevice(index=%d)"), index); 3147 } 3148 3149 void CWinTestDlg::OnCbnSelchangeComboPlayDevice() 3150 { 3151 CComboBox* comboCodec(NULL); 3152 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_PLAY_DEVICE); 3153 int index = comboCodec->GetCurSel(); 3154 TEST(_veHardwarePtr->SetPlayoutDevice(index) == 0, 3155 _T("SetPlayoutDevice(index=%d)"), index); 3156 } 3157 3158 void CWinTestDlg::OnNMReleasedcaptureSliderInputVolume(NMHDR *pNMHDR, LRESULT *pResult) 3159 { 3160 CSliderCtrl* slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_INPUT_VOLUME); 3161 slider->SetRangeMin(0); 3162 slider->SetRangeMax(255); 3163 int pos = slider->GetPos(); 3164 3165 TEST(_veVolumeControlPtr->SetMicVolume(pos) == 0, _T("SetMicVolume(volume=%d)"), pos); 3166 3167 *pResult = 0; 3168 } 3169 3170 void CWinTestDlg::OnNMReleasedcaptureSliderOutputVolume(NMHDR *pNMHDR, LRESULT *pResult) 3171 { 3172 CSliderCtrl* slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_OUTPUT_VOLUME); 3173 slider->SetRangeMin(0); 3174 slider->SetRangeMax(255); 3175 int pos = slider->GetPos(); 3176 3177 TEST(_veVolumeControlPtr->SetSpeakerVolume(pos) == 0, _T("SetSpeakerVolume(volume=%d)"), pos); 3178 3179 *pResult = 0; 3180 } 3181 3182 void CWinTestDlg::OnNMReleasedcaptureSliderPanLeft(NMHDR *pNMHDR, LRESULT *pResult) 3183 { 3184 CSliderCtrl* slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_PAN_LEFT); 3185 slider->SetRange(0,10); 3186 int pos = 10 - slider->GetPos(); // 0 <=> lower end, 10 <=> upper end 3187 3188 float left(0.0); 3189 float right(0.0); 3190 const int channel(-1); 3191 3192 // Only left channel will be modified 3193 _veVolumeControlPtr->GetOutputVolumePan(channel, left, right); 3194 3195 left = (float)((float)pos/10.0f); 3196 3197 TEST(_veVolumeControlPtr->SetOutputVolumePan(channel, left, right) == 0, 3198 _T("SetOutputVolumePan(channel=%d, left=%2.1f, right=%2.1f)"), channel, left, right); 3199 3200 *pResult = 0; 3201 } 3202 3203 void CWinTestDlg::OnNMReleasedcaptureSliderPanRight(NMHDR *pNMHDR, LRESULT *pResult) 3204 { 3205 CSliderCtrl* slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_PAN_RIGHT); 3206 slider->SetRange(0,10); 3207 int pos = 10 - slider->GetPos(); // 0 <=> lower end, 10 <=> upper end 3208 3209 float left(0.0); 3210 float right(0.0); 3211 const int channel(-1); 3212 3213 // Only right channel will be modified 3214 _veVolumeControlPtr->GetOutputVolumePan(channel, left, right); 3215 3216 right = (float)((float)pos/10.0f); 3217 3218 TEST(_veVolumeControlPtr->SetOutputVolumePan(channel, left, right) == 0, 3219 _T("SetOutputVolumePan(channel=%d, left=%2.1f, right=%2.1f)"), channel, left, right); 3220 3221 *pResult = 0; 3222 } 3223 3224 void CWinTestDlg::OnBnClickedButtonVersion() 3225 { 3226 if (_veBasePtr) 3227 { 3228 char version[1024]; 3229 if (_veBasePtr->GetVersion(version) == 0) 3230 { 3231 AfxMessageBox(CString(version), MB_OK); 3232 } 3233 else 3234 { 3235 AfxMessageBox(_T("FAILED!"), MB_OK); 3236 } 3237 } 3238 } 3239 3240 void CWinTestDlg::OnBnClickedCheckRecCall() 3241 { 3242 // Not supported 3243 } 3244 3245 void CWinTestDlg::OnBnClickedCheckTypingDetection() 3246 { 3247 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_TYPING_DETECTION); 3248 int check = button->GetCheck(); 3249 const bool enable = (check == BST_CHECKED); 3250 TEST(_veApmPtr->SetTypingDetectionStatus(enable) == 0, _T("SetTypingDetectionStatus(enable=%d)"), enable); 3251 } 3252 3253 void CWinTestDlg::OnBnClickedCheckRED() 3254 { 3255 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_RED); 3256 int channel = GetDlgItemInt(IDC_EDIT_1); 3257 int check = button->GetCheck(); 3258 const bool enable = (check == BST_CHECKED); 3259 TEST(_veRtpRtcpPtr->SetREDStatus(channel, enable) == 0, 3260 _T("SetREDStatus(enable=%d)"), enable); 3261 } 3262 3263 // ---------------------------------------------------------------------------- 3264 // Message Handlers 3265 // ---------------------------------------------------------------------------- 3266 3267 void CWinTestDlg::OnTimer(UINT_PTR nIDEvent) 3268 { 3269 CString str; 3270 3271 unsigned int svol(0); 3272 unsigned int mvol(0); 3273 3274 _timerTicks++; 3275 3276 // Get speaker and microphone volumes 3277 _veVolumeControlPtr->GetSpeakerVolume(svol); 3278 _veVolumeControlPtr->GetMicVolume(mvol); 3279 3280 // Update speaker volume slider 3281 CSliderCtrl* sliderSpkr = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_OUTPUT_VOLUME); 3282 sliderSpkr->SetRangeMin(0); 3283 sliderSpkr->SetRangeMax(255); 3284 sliderSpkr->SetPos(svol); 3285 3286 // Update microphone volume slider 3287 CSliderCtrl* sliderMic = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_INPUT_VOLUME); 3288 sliderMic->SetRangeMin(0); 3289 sliderMic->SetRangeMax(255); 3290 sliderMic->SetPos(mvol); 3291 3292 unsigned int micLevel; 3293 unsigned int combinedOutputLevel; 3294 3295 // Get audio levels 3296 _veVolumeControlPtr->GetSpeechInputLevel(micLevel); 3297 _veVolumeControlPtr->GetSpeechOutputLevel(-1, combinedOutputLevel); 3298 3299 // Update audio level controls 3300 CProgressCtrl* progressMic = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS_AUDIO_LEVEL_IN); 3301 progressMic->SetRange(0,9); 3302 progressMic->SetStep(1); 3303 progressMic->SetPos(micLevel); 3304 CProgressCtrl* progressOut = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS_AUDIO_LEVEL_OUT); 3305 progressOut->SetRange(0,9); 3306 progressOut->SetStep(1); 3307 progressOut->SetPos(combinedOutputLevel); 3308 3309 // Update playout delay (buffer size) 3310 if (_veVideoSyncPtr) 3311 { 3312 int bufferMs(0); 3313 _veVideoSyncPtr->GetPlayoutBufferSize(bufferMs); 3314 SetDlgItemInt(IDC_EDIT_PLAYOUT_BUFFER_SIZE, bufferMs); 3315 } 3316 3317 if (_delayEstimate1 && _veVideoSyncPtr) 3318 { 3319 const int channel = GetDlgItemInt(IDC_EDIT_1); 3320 int delayMs(0); 3321 _veVideoSyncPtr->GetDelayEstimate(channel, delayMs); 3322 SetDlgItemInt(IDC_EDIT_DELAY_ESTIMATE_1, delayMs); 3323 } 3324 3325 if (_rxVad && _veApmPtr && _rxVadObserverPtr) 3326 { 3327 SetDlgItemInt(IDC_EDIT_RXVAD, _rxVadObserverPtr->vad_decision); 3328 } 3329 3330 if (_veHardwarePtr) 3331 { 3332 int load1, load2; 3333 _veHardwarePtr->GetSystemCPULoad(load1); 3334 _veHardwarePtr->GetCPULoad(load2); 3335 str.Format(_T("CPU load (system/VoE): %d/%d [%%]"), load1, load2); 3336 SetDlgItemText(IDC_EDIT_CPU_LOAD, (LPCTSTR)str); 3337 } 3338 3339 BOOL ret; 3340 int channel = GetDlgItemInt(IDC_EDIT_1, &ret); 3341 3342 if (_veCodecPtr) 3343 { 3344 if (ret == TRUE) 3345 { 3346 CodecInst codec; 3347 if (_veCodecPtr->GetRecCodec(channel, codec) == 0) 3348 { 3349 str.Format(_T("RX codec: %s, freq=%d, pt=%d, rate=%d, size=%d"), CharToTchar(codec.plname, 32), codec.plfreq, codec.pltype, codec.rate, codec.pacsize); 3350 SetDlgItemText(IDC_EDIT_RX_CODEC_1, (LPCTSTR)str); 3351 } 3352 } 3353 } 3354 3355 if (_veRtpRtcpPtr) 3356 { 3357 if (ret == TRUE) 3358 { 3359 CallStatistics stats; 3360 if (_veRtpRtcpPtr->GetRTCPStatistics(channel, stats) == 0) 3361 { 3362 str.Format(_T("RTCP | RTP: cum=%u, ext=%d, frac=%u, jitter=%u | TX=%d, RX=%d, RTT=%d"), 3363 stats.cumulativeLost, stats.extendedMax, stats.fractionLost, stats.jitterSamples, stats.packetsSent, stats.packetsReceived, stats.rttMs); 3364 SetDlgItemText(IDC_EDIT_RTCP_STAT_1, (LPCTSTR)str); 3365 } 3366 } 3367 } 3368 3369 SetTimer(0, 1000, NULL); 3370 CDialog::OnTimer(nIDEvent); 3371 } 3372 3373 void CWinTestDlg::OnBnClickedButtonClearErrorCallback() 3374 { 3375 _nErrorCallbacks = 0; 3376 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, _T("")); 3377 } 3378 3379 // ---------------------------------------------------------------------------- 3380 // TEST 3381 // ---------------------------------------------------------------------------- 3382 3383 void CWinTestDlg::OnBnClickedButtonTest1() 3384 { 3385 // add tests here... 3386 } 3387