2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
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"
21 using namespace webrtc;
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};
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)
33 TCHAR* temp = convertBufferSwitch ? convertTemp1 : convertTemp2;
34 convertBufferSwitch = !convertBufferSwitch;
35 memset(temp, 0, sizeof(convertTemp1));
36 MultiByteToWideChar(CP_UTF8, 0, str, len, temp, 256);
43 // Hack to convert TCHAR to char
44 char convertTemp3[256] = {0};
45 char* TcharToChar(TCHAR* str, int len)
48 memset(convertTemp3, 0, sizeof(convertTemp3));
49 WideCharToMultiByte(CP_UTF8, 0, str, len, convertTemp3, 256, 0, 0);
56 // ----------------------------------------------------------------------------
57 // VoEConnectionObserver
58 // ----------------------------------------------------------------------------
60 class ConnectionObserver : public VoEConnectionObserver
64 virtual void OnPeriodicDeadOrAlive(int channel, bool alive);
67 ConnectionObserver::ConnectionObserver()
71 void ConnectionObserver::OnPeriodicDeadOrAlive(int channel, bool alive)
74 str.Format(_T("OnPeriodicDeadOrAlive(channel=%d) => alive=%d"), channel, alive);
75 OutputDebugString(str);
78 // ----------------------------------------------------------------------------
79 // VoiceEngineObserver
80 // ----------------------------------------------------------------------------
82 void CWinTestDlg::CallbackOnError(int channel, int errCode)
87 str.Format(_T("[#%d] CallbackOnError(channel=%d) => errCode = %d"), _nErrorCallbacks, channel, errCode);
88 if (errCode == VE_RECEIVE_PACKET_TIMEOUT)
90 str += _T(" <=> VE_RECEIVE_PACKET_TIMEOUT");
92 else if (errCode == VE_PACKET_RECEIPT_RESTARTED)
94 str += _T(" <=> VE_PACKET_RECEIPT_RESTARTED");
96 else if (errCode == VE_RUNTIME_PLAY_WARNING)
98 str += _T(" <=> VE_RUNTIME_PLAY_WARNING");
100 else if (errCode == VE_RUNTIME_REC_WARNING)
102 str += _T(" <=> VE_RUNTIME_REC_WARNING");
104 else if (errCode == VE_RUNTIME_PLAY_ERROR)
106 str += _T(" <=> VE_RUNTIME_PLAY_ERROR");
108 else if (errCode == VE_RUNTIME_REC_ERROR)
110 str += _T(" <=> VE_RUNTIME_REC_ERROR");
112 else if (errCode == VE_SATURATION_WARNING)
114 str += _T(" <=> VE_SATURATION_WARNING");
116 else if (errCode == VE_TYPING_NOISE_WARNING)
118 str += _T(" <=> VE_TYPING_NOISE_WARNING");
120 else if (errCode == VE_REC_DEVICE_REMOVED)
122 str += _T(" <=> VE_REC_DEVICE_REMOVED");
124 // AfxMessageBox((LPCTSTR)str, MB_OK);
125 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, (LPCTSTR)str);
128 // ----------------------------------------------------------------------------
130 // ----------------------------------------------------------------------------
132 void CWinTestDlg::OnIncomingCSRCChanged(int channel, unsigned int CSRC, bool added)
135 str.Format(_T("OnIncomingCSRCChanged(channel=%d) => CSRC=%u, added=%d"), channel, CSRC, added);
136 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, (LPCTSTR)str);
139 void CWinTestDlg::OnIncomingSSRCChanged(int channel, unsigned int SSRC)
142 str.Format(_T("OnIncomingSSRCChanged(channel=%d) => SSRC=%u"), channel, SSRC);
143 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, (LPCTSTR)str);
146 // ----------------------------------------------------------------------------
148 // ----------------------------------------------------------------------------
150 class MyTransport : public Transport
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);
157 VoENetwork* _veNetworkPtr;
160 MyTransport::MyTransport(VoENetwork* veNetwork) :
161 _veNetworkPtr(veNetwork)
166 MyTransport::SendPacket(int channel, const void *data, int len)
168 _veNetworkPtr->ReceivedRTPPacket(channel, data, len);
173 MyTransport::SendRTCPPacket(int channel, const void *data, int len)
175 _veNetworkPtr->ReceivedRTCPPacket(channel, data, len);
179 // ----------------------------------------------------------------------------
181 // ----------------------------------------------------------------------------
183 class MediaProcessImpl : public VoEMediaProcess
187 virtual void Process(int channel,
188 ProcessingTypes type,
189 int16_t audio_10ms[],
195 MediaProcessImpl::MediaProcessImpl()
199 void MediaProcessImpl::Process(int channel,
200 ProcessingTypes type,
201 int16_t audio_10ms[],
206 int x = rand() % 100;
208 for (int i = 0; i < length; i++)
212 if (type == kPlaybackAllChannelsMixed)
217 audio_10ms[i] = (audio_10ms[i] << 2);
221 audio_10ms[2*i] = (audio_10ms[2*i] << 2);
222 audio_10ms[2*i+1] = (audio_10ms[2*i+1] << 2);
227 // recording: emulate packet loss by "dropping" 10% of the packets
228 if (x >= 0 && x < 10)
237 audio_10ms[2*i+1] = 0;
244 if (type == kPlaybackPerChannel)
254 audio_10ms[2*i+1] = 0;
259 // recording: emulate packet loss by "dropping" 50% of the packets
260 if (x >= 0 && x < 50)
269 audio_10ms[2*i+1] = 0;
277 // ----------------------------------------------------------------------------
278 // TelephoneEventObserver
279 // ----------------------------------------------------------------------------
281 class TelephoneEventObserver: public VoETelephoneEventObserver
284 TelephoneEventObserver(CWnd* editControlOut, CWnd* editControlIn);
285 virtual void OnReceivedTelephoneEventInband(int channel, int eventCode,
287 virtual void OnReceivedTelephoneEventOutOfBand(int channel, int eventCode,
290 CWnd* _editControlOutPtr;
291 CWnd* _editControlInPtr;
294 TelephoneEventObserver::TelephoneEventObserver(CWnd* editControlOut, CWnd* editControlIn) :
295 _editControlOutPtr(editControlOut),
296 _editControlInPtr(editControlIn)
300 void TelephoneEventObserver::OnReceivedTelephoneEventInband(int channel,
307 msg.AppendFormat(_T("%d [END]"), eventCode);
308 _editControlInPtr->SetWindowText((LPCTSTR)msg);
312 msg.AppendFormat(_T("%d [START]"), eventCode);
313 _editControlInPtr->SetWindowText((LPCTSTR)msg);
317 void TelephoneEventObserver::OnReceivedTelephoneEventOutOfBand(int channel,
324 msg.AppendFormat(_T("%d [END]"), eventCode);
325 _editControlOutPtr->SetWindowText((LPCTSTR)msg);
329 msg.AppendFormat(_T("%d [START]"), eventCode);
330 _editControlOutPtr->SetWindowText((LPCTSTR)msg);
334 // ----------------------------------------------------------------------------
336 // ----------------------------------------------------------------------------
338 class RxCallback : public VoERxVadCallback
341 RxCallback() : vad_decision(-1) {};
343 virtual void OnRxVad(int , int vadDecision)
345 vad_decision = vadDecision;
351 // ----------------------------------------------------------------------------
353 // ----------------------------------------------------------------------------
355 class CAboutDlg : public CDialog
361 enum { IDD = IDD_ABOUTBOX };
364 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
368 DECLARE_MESSAGE_MAP()
371 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
375 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
377 CDialog::DoDataExchange(pDX);
380 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
383 // ----------------------------------------------------------------------------
384 // CTelephonyEvent dialog
385 // ----------------------------------------------------------------------------
387 class CTelephonyEvent : public CDialog
389 DECLARE_DYNAMIC(CTelephonyEvent)
392 CTelephonyEvent(VoiceEngine* voiceEngine, int channel, CDialog* pParentDialog, CWnd* pParent = NULL); // standard constructor
393 virtual ~CTelephonyEvent();
396 enum { IDD = IDD_DTMF_DIALOG };
399 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
400 virtual BOOL OnInitDialog();
402 DECLARE_MESSAGE_MAP()
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();
437 void SendTelephoneEvent(unsigned char eventCode);
443 VoECodec* _veCodecPtr;
446 CDialog* _parentDialogPtr;
447 TelephoneEventObserver* _telephoneEventObserverPtr;
448 bool _PlayDtmfToneLocally;
452 bool _playingDTMFTone;
453 bool _outOfBandEventDetection;
454 bool _inbandEventDetection;
457 IMPLEMENT_DYNAMIC(CTelephonyEvent, CDialog)
459 CTelephonyEvent::CTelephonyEvent(VoiceEngine* voiceEngine,
461 CDialog* pParentDialog,
462 CWnd* pParent /*=NULL*/)
463 : _vePtr(voiceEngine),
465 _PlayDtmfToneLocally(false),
466 _modeStartStop(false),
468 _modeSequence(false),
469 _playingDTMFTone(false),
470 _outOfBandEventDetection(true),
471 _inbandEventDetection(false),
472 _parentDialogPtr(pParentDialog),
473 _telephoneEventObserverPtr(NULL),
474 CDialog(CTelephonyEvent::IDD, pParent)
476 _veBasePtr = VoEBase::GetInterface(_vePtr);
477 _veDTMFPtr = VoEDtmf::GetInterface(_vePtr);
478 _veCodecPtr = VoECodec::GetInterface(_vePtr);
481 CTelephonyEvent::~CTelephonyEvent()
483 _veDTMFPtr->Release();
484 _veCodecPtr->Release();
485 _veBasePtr->Release();
487 if (_telephoneEventObserverPtr)
489 _veDTMFPtr->DeRegisterTelephoneEventDetection(_channel);
490 delete _telephoneEventObserverPtr;
491 _telephoneEventObserverPtr = NULL;
495 void CTelephonyEvent::DoDataExchange(CDataExchange* pDX)
497 CDialog::DoDataExchange(pDX);
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)
535 // CTelephonyEvent message handlers
537 BOOL CTelephonyEvent::OnInitDialog()
539 CDialog::OnInitDialog();
543 str.AppendFormat(_T(" [channel = %d]"), _channel);
546 // Update dialog with latest playout state
548 _veDTMFPtr->GetDtmfPlayoutStatus(_channel, enabled);
549 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_PLAYOUT_RX);
550 button->SetCheck(enabled ? BST_CHECKED : BST_UNCHECKED);
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);
560 // Default event length is 160 ms
561 SetDlgItemInt(IDC_EDIT_EVENT_LENGTH, 160);
563 // Default event attenuation is 10 (<-> -10dBm0)
564 SetDlgItemInt(IDC_EDIT_EVENT_ATTENUATION, 10);
566 // Current event-detection status
567 TelephoneEventDetectionMethods detectionMethod(kOutOfBand);
568 if (_veDTMFPtr->GetTelephoneEventDetectionStatus(_channel, enabled, detectionMethod) == 0)
570 // DTMF detection is supported
573 button = (CButton*)GetDlgItem(IDC_CHECK_EVENT_DETECTION);
574 button->SetCheck(BST_CHECKED);
576 if (detectionMethod == kOutOfBand || detectionMethod == kInAndOutOfBand)
578 button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_OUT_OF_BAND);
579 button->SetCheck(BST_CHECKED);
581 if (detectionMethod == kInBand || detectionMethod == kInAndOutOfBand)
583 button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_INBAND);
584 button->SetCheck(BST_CHECKED);
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);
597 // Telephone-event PTs
599 _veDTMFPtr->GetSendTelephoneEventPayloadType(_channel, pt);
600 SetDlgItemInt(IDC_EDIT_EVENT_TX_PT, pt);
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);
609 ((CButton*)GetDlgItem(IDC_RADIO_SINGLE))->SetCheck(BST_CHECKED);
611 else if (_modeStartStop)
613 ((CButton*)GetDlgItem(IDC_RADIO_START_STOP))->SetCheck(BST_CHECKED);
615 else if (_modeSequence)
617 ((CButton*)GetDlgItem(IDC_RADIO_MULTI))->SetCheck(BST_CHECKED);
620 return TRUE; // return TRUE unless you set the focus to a control
622 void CTelephonyEvent::SendTelephoneEvent(unsigned char eventCode)
626 int attenuationDb(0);
633 lengthMs = GetDlgItemInt(IDC_EDIT_EVENT_LENGTH, &ret);
636 // use default length if edit field is empty
642 attenuationDb = GetDlgItemInt(IDC_EDIT_EVENT_ATTENUATION, &ret);
645 // use default length if edit field is empty
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);
655 SetDlgItemInt(IDC_EDIT_DTMF_EVENT, eventCode);
657 if (_PlayDtmfToneLocally)
663 TEST2(_veDTMFPtr->PlayDtmfTone(eventCode, lengthMs, attenuationDb) == 0,
664 _T("PlayDtmfTone(eventCode=%u, lengthMs=%d, attenuationDb=%d)"), eventCode, lengthMs, attenuationDb);
666 else if (_modeStartStop)
668 if (!_playingDTMFTone)
670 TEST2((res = _veDTMFPtr->StartPlayingDtmfTone(eventCode, attenuationDb)) == 0,
671 _T("StartPlayingDtmfTone(eventCode=%u, attenuationDb=%d)"), eventCode, attenuationDb);
675 TEST2((res = _veDTMFPtr->StopPlayingDtmfTone()) == 0,
676 _T("StopPlayingDTMFTone()"));
679 _playingDTMFTone = !_playingDTMFTone;
681 else if (_modeSequence)
692 else if (eventCode == 2)
695 sleepMs = lengthMs/2;
698 else if (eventCode == 3)
704 for (int i = 0; i < nTones; i++)
706 TEST2(_veDTMFPtr->PlayDtmfTone(eventCode, lengthMs, attenuationDb) == 0,
707 _T("PlayDtmfTone(eventCode=%u, outBand=%d, lengthMs=%d, attenuationDb=%d)"), eventCode, lengthMs, attenuationDb);
709 lengthMs = lenMult*lengthMs;
716 // --- SendTelephoneEvent
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);
723 else if (_modeStartStop)
725 TEST2(false, _T("*** NOT IMPLEMENTED ***"));
727 else if (_modeSequence)
738 else if (eventCode == 2)
742 sleepMs = lengthMs/2;
745 else if (eventCode == 3)
752 for (int i = 0; i < nTones; i++)
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);
757 lengthMs = lenMult*lengthMs;
764 void CTelephonyEvent::OnBnClickedButtonSendTelephoneEvent()
767 unsigned char eventCode(0);
769 eventCode = (unsigned char)GetDlgItemInt(IDC_EDIT_EVENT_CODE, &ret);
774 SendTelephoneEvent(eventCode);
777 void CTelephonyEvent::OnBnClickedButton1()
779 SendTelephoneEvent(1);
782 void CTelephonyEvent::OnBnClickedButton2()
784 SendTelephoneEvent(2);
787 void CTelephonyEvent::OnBnClickedButton3()
789 SendTelephoneEvent(3);
792 void CTelephonyEvent::OnBnClickedButton4()
794 SendTelephoneEvent(4);
797 void CTelephonyEvent::OnBnClickedButton5()
799 SendTelephoneEvent(5);
802 void CTelephonyEvent::OnBnClickedButton6()
804 SendTelephoneEvent(6);
807 void CTelephonyEvent::OnBnClickedButton7()
809 SendTelephoneEvent(7);
812 void CTelephonyEvent::OnBnClickedButton8()
814 SendTelephoneEvent(8);
817 void CTelephonyEvent::OnBnClickedButton9()
819 SendTelephoneEvent(9);
822 void CTelephonyEvent::OnBnClickedButton10()
825 SendTelephoneEvent(10);
828 void CTelephonyEvent::OnBnClickedButton11()
830 SendTelephoneEvent(0);
833 void CTelephonyEvent::OnBnClickedButton12()
836 SendTelephoneEvent(11);
839 void CTelephonyEvent::OnBnClickedButtonA()
841 SendTelephoneEvent(12);
844 void CTelephonyEvent::OnBnClickedButtonB()
846 SendTelephoneEvent(13);
849 void CTelephonyEvent::OnBnClickedButtonC()
851 SendTelephoneEvent(14);
854 void CTelephonyEvent::OnBnClickedButtonD()
856 SendTelephoneEvent(15);
859 void CTelephonyEvent::OnBnClickedCheckDtmfPlayoutRx()
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);
867 void CTelephonyEvent::OnBnClickedCheckDtmfPlayTone()
869 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_PLAY_TONE);
870 int check = button->GetCheck();
871 _PlayDtmfToneLocally = (check == BST_CHECKED);
874 void CTelephonyEvent::OnBnClickedRadioSingle()
876 _modeStartStop = false;
878 _modeSequence = false;
881 void CTelephonyEvent::OnBnClickedRadioMulti()
883 _modeStartStop = false;
885 _modeSequence = true;
888 void CTelephonyEvent::OnBnClickedRadioStartStop()
890 // CButton* button = (CButton*)GetDlgItem(IDC_RADIO_START_STOP);
891 // int check = button->GetCheck();
892 _modeStartStop = true;
894 _modeSequence = false;
895 // GetDlgItem(IDC_EDIT_EVENT_LENGTH)->EnableWindow();
898 void CTelephonyEvent::OnBnClickedCheckEventInband()
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);
906 void CTelephonyEvent::OnBnClickedCheckDtmfFeedback()
908 CButton* button(NULL);
910 // Retrieve feedback state
911 button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_FEEDBACK);
912 int check = button->GetCheck();
913 const bool enable = (check == BST_CHECKED);
915 // Retrieve direct-feedback setting
916 button = (CButton*)GetDlgItem(IDC_CHECK_DIRECT_FEEDBACK);
917 check = button->GetCheck();
918 const bool directFeedback = (check == BST_CHECKED);
920 // GetDlgItem(IDC_CHECK_DIRECT_FEEDBACK)->EnableWindow(enable ? TRUE : FALSE);
922 TEST2(_veDTMFPtr->SetDtmfFeedbackStatus(enable, directFeedback) == 0,
923 _T("SetDtmfFeedbackStatus(enable=%d, directFeedback=%d)"), enable, directFeedback);
926 void CTelephonyEvent::OnBnClickedCheckDirectFeedback()
928 CButton* button(NULL);
930 // Retrieve feedback state
931 button = (CButton*)GetDlgItem(IDC_CHECK_DTMF_FEEDBACK);
932 int check = button->GetCheck();
933 const bool enable = (check == BST_CHECKED);
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);
940 TEST2(_veDTMFPtr->SetDtmfFeedbackStatus(enable, directFeedback) == 0,
941 _T("SetDtmfFeedbackStatus(enable=%d, directFeedback=%d)"), enable, directFeedback);
944 void CTelephonyEvent::OnBnClickedButtonSetRxTelephonePt()
947 int pt = GetDlgItemInt(IDC_EDIT_EVENT_RX_PT, &ret);
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);
957 void CTelephonyEvent::OnBnClickedButtonSetTxTelephonePt()
960 int pt = GetDlgItemInt(IDC_EDIT_EVENT_TX_PT, &ret);
963 TEST2(_veDTMFPtr->SetSendTelephoneEventPayloadType(_channel, pt) == 0,
964 _T("SetSendTelephoneEventPayloadType(channel=%d, type=%u)"), _channel, pt);
967 void CTelephonyEvent::OnBnClickedCheckDetectInband()
969 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_INBAND);
970 int check = button->GetCheck();
971 _inbandEventDetection = (check == BST_CHECKED);
974 TelephoneEventDetectionMethods detectionMethod;
975 _veDTMFPtr->GetTelephoneEventDetectionStatus(_channel, enabled, detectionMethod);
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(""));
985 OnBnClickedCheckEventDetection();
988 void CTelephonyEvent::OnBnClickedCheckDetectOutOfBand()
990 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DETECT_OUT_OF_BAND);
991 int check = button->GetCheck();
992 _outOfBandEventDetection = (check == BST_CHECKED);
995 TelephoneEventDetectionMethods detectionMethod;
996 _veDTMFPtr->GetTelephoneEventDetectionStatus(_channel, enabled, detectionMethod);
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(""));
1006 OnBnClickedCheckEventDetection();
1009 void CTelephonyEvent::OnBnClickedCheckEventDetection()
1011 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_EVENT_DETECTION);
1012 int check = button->GetCheck();
1013 const bool enable = (check == BST_CHECKED);
1017 TelephoneEventDetectionMethods method(kInBand);
1018 if (_inbandEventDetection && !_outOfBandEventDetection)
1020 else if (!_inbandEventDetection && _outOfBandEventDetection)
1021 method = kOutOfBand;
1022 else if (_inbandEventDetection && _outOfBandEventDetection)
1023 method = kInAndOutOfBand;
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);
1029 TEST2(_veDTMFPtr->RegisterTelephoneEventDetection(_channel, method, *_telephoneEventObserverPtr) == 0,
1030 _T("RegisterTelephoneEventDetection(channel=%d, detectionMethod=%d)"), _channel, method);
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(""));
1043 // ============================================================================
1044 // CWinTestDlg dialog
1045 // ============================================================================
1047 CWinTestDlg::CWinTestDlg(CWnd* pParent /*=NULL*/)
1048 : CDialog(CWinTestDlg::IDD, pParent),
1053 _veNetworkPtr(NULL),
1055 _veHardwarePtr(NULL),
1056 _veExternalMediaPtr(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),
1079 _checkConference1(0),
1080 _checkConference2(0),
1083 _strComboIp1(_T("")),
1084 _strComboIp2(_T("")),
1085 _delayEstimate1(false),
1086 _delayEstimate2(false),
1088 _nErrorCallbacks(0),
1091 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
1093 _vePtr = VoiceEngine::Create();
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);
1100 VoiceEngine::SetTraceFile("ve_win_test.txt");
1101 VoiceEngine::SetTraceCallback(NULL);
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);
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();
1122 _veBasePtr->RegisterVoiceEngineObserver(*this);
1124 std::string resource_path = webrtc::test::ProjectRootPath();
1125 if (resource_path == webrtc::test::kCannotFindProjectRootDir) {
1126 _long_audio_file_path = "./";
1128 _long_audio_file_path = resource_path + "data\\voice_engine\\";
1132 CWinTestDlg::~CWinTestDlg()
1134 if (_connectionObserverPtr) delete _connectionObserverPtr;
1135 if (_externalMediaPtr) delete _externalMediaPtr;
1136 if (_transportPtr) delete _transportPtr;
1137 if (_rxVadObserverPtr) delete _rxVadObserverPtr;
1139 if (_veExternalMediaPtr) _veExternalMediaPtr->Release();
1140 if (_veVideoSyncPtr) _veVideoSyncPtr->Release();
1141 if (_veVolumeControlPtr) _veVolumeControlPtr->Release();
1143 if (_veBasePtr) _veBasePtr->Terminate();
1144 if (_veBasePtr) _veBasePtr->Release();
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();
1154 VoiceEngine::Delete(_vePtr);
1156 VoiceEngine::SetTraceFilter(kTraceNone);
1159 void CWinTestDlg::DoDataExchange(CDataExchange* pDX)
1161 CDialog::DoDataExchange(pDX);
1162 DDX_CBString(pDX, IDC_COMBO_IP_1, _strComboIp1);
1163 DDX_CBString(pDX, IDC_COMBO_IP_2, _strComboIp2);
1166 BEGIN_MESSAGE_MAP(CWinTestDlg, CDialog)
1169 ON_WM_QUERYDRAGICON()
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)
1245 BOOL CWinTestDlg::UpdateTest(bool failed, const CString& strMsg)
1249 SetDlgItemText(IDC_EDIT_MESSAGE, strMsg);
1250 _strErr.Format(_T("FAILED (error=%d)"), _veBasePtr->LastError());
1251 SetDlgItemText(IDC_EDIT_RESULT, _strErr);
1253 SetDlgItemInt(IDC_EDIT_N_FAILS, _failCount);
1254 SetDlgItemInt(IDC_EDIT_LAST_ERROR, _veBasePtr->LastError());
1258 SetDlgItemText(IDC_EDIT_MESSAGE, strMsg);
1259 SetDlgItemText(IDC_EDIT_RESULT, _T("OK"));
1265 // CWinTestDlg message handlers
1267 BOOL CWinTestDlg::OnInitDialog()
1269 CDialog::OnInitDialog();
1271 // Add "About..." menu item to system menu.
1273 // IDM_ABOUTBOX must be in the system command range.
1274 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
1275 ASSERT(IDM_ABOUTBOX < 0xF000);
1277 CMenu* pSysMenu = GetSystemMenu(FALSE);
1278 if (pSysMenu != NULL)
1280 CString strAboutMenu;
1281 strAboutMenu.LoadString(IDS_ABOUTBOX);
1282 if (!strAboutMenu.IsEmpty())
1284 pSysMenu->AppendMenu(MF_SEPARATOR);
1285 pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
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
1294 // char version[1024];
1295 // _veBasePtr->GetVersion(version);
1296 // AfxMessageBox(version, MB_OK);
1298 if (_veBasePtr->Init() != 0)
1300 AfxMessageBox(_T("Init() failed "), MB_OKCANCEL);
1303 int ch = _veBasePtr->CreateChannel();
1304 if (_veBasePtr->SetSendDestination(ch, 1234, "127.0.0.1") == -1)
1306 if (_veBasePtr->LastError() == VE_EXTERNAL_TRANSPORT_ENABLED)
1308 _strMsg.Format(_T("*** External transport build ***"));
1309 SetDlgItemText(IDC_EDIT_MESSAGE, _strMsg);
1310 _externalTransportBuild = true;
1313 _veBasePtr->DeleteChannel(ch);
1315 // --- Add (preferred) local IPv4 address in title
1320 _veNetworkPtr->GetLocalIP(localIP);
1323 str.AppendFormat(_T(" [Local IPv4 address: %s]"), CharToTchar(localIP, 64));
1327 // --- Volume sliders
1329 if (_veVolumeControlPtr)
1331 unsigned int volume(0);
1332 CSliderCtrl* slider(NULL);
1334 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_INPUT_VOLUME);
1335 slider->SetRangeMin(0);
1336 slider->SetRangeMax(255);
1337 _veVolumeControlPtr->GetMicVolume(volume);
1338 slider->SetPos(volume);
1340 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_OUTPUT_VOLUME);
1341 slider->SetRangeMin(0);
1342 slider->SetRangeMax(255);
1343 _veVolumeControlPtr->GetSpeakerVolume(volume);
1344 slider->SetPos(volume);
1347 // --- Panning sliders
1349 if (_veVolumeControlPtr)
1353 int leftVol, rightVol;
1354 CSliderCtrl* slider(NULL);
1356 _veVolumeControlPtr->GetOutputVolumePan(-1, lVol, rVol);
1358 leftVol = (int)(lVol*10.0f); // [0,10]
1359 rightVol = (int)(rVol*10.0f); // [0,10]
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)
1365 slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_PAN_RIGHT);
1366 slider->SetRange(0,10);
1367 slider->SetPos(10-rightVol);
1373 CButton* button(NULL);
1375 AgcModes agcMode(kAgcDefault);
1376 if (_veApmPtr->GetAgcStatus(enable, agcMode) == 0)
1378 button = (CButton*)GetDlgItem(IDC_CHECK_AGC);
1379 enable ? button->SetCheck(BST_CHECKED) : button->SetCheck(BST_UNCHECKED);
1383 // AGC is not supported
1384 GetDlgItem(IDC_CHECK_AGC)->EnableWindow(FALSE);
1387 NsModes nsMode(kNsDefault);
1388 if (_veApmPtr->GetNsStatus(enable, nsMode) == 0)
1390 button = (CButton*)GetDlgItem(IDC_CHECK_NS);
1391 enable ? button->SetCheck(BST_CHECKED) : button->SetCheck(BST_UNCHECKED);
1395 // NS is not supported
1396 GetDlgItem(IDC_CHECK_NS)->EnableWindow(FALSE);
1399 EcModes ecMode(kEcDefault);
1400 if (_veApmPtr->GetEcStatus(enable, ecMode) == 0)
1402 button = (CButton*)GetDlgItem(IDC_CHECK_EC);
1403 enable ? button->SetCheck(BST_CHECKED) : button->SetCheck(BST_UNCHECKED);
1407 // EC is not supported
1408 GetDlgItem(IDC_CHECK_EC)->EnableWindow(FALSE);
1411 // --- First channel section
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);
1445 CComboBox* comboIP(NULL);
1446 comboIP = (CComboBox*)GetDlgItem(IDC_COMBO_IP_1);
1447 comboIP->AddString(_T("127.0.0.1"));
1448 comboIP->SetCurSel(0);
1450 SetDlgItemInt(IDC_EDIT_TX_PORT_1, 1111);
1451 SetDlgItemInt(IDC_EDIT_RX_PORT_1, 1111);
1453 // --- Add supported codecs to the codec combo box
1455 CComboBox* comboCodec(NULL);
1456 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_CODEC_1);
1457 comboCodec->ResetContent();
1459 int numCodecs = _veCodecPtr->NumOfCodecs();
1460 for (int idx = 0; idx < numCodecs; idx++)
1463 _veCodecPtr->GetCodec(idx, codec);
1464 if ((_stricmp(codec.plname, "CNNB") != 0) &&
1465 (_stricmp(codec.plname, "CNWB") != 0))
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);
1471 strCodec.Format(_T("%s (%d/%d)"), CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq/1000);
1472 comboCodec->AddString(strCodec);
1476 SetDlgItemInt(IDC_EDIT_CODEC_1, codec.pltype);
1479 comboCodec->SetCurSel(0);
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"));
1489 // --- Add available audio devices to the combo boxes
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();
1501 int numRecording(0);
1505 AudioLayers audioLayer;
1507 _veHardwarePtr->GetAudioDeviceLayer(audioLayer);
1508 if (kAudioWindowsWave == audioLayer)
1510 strDevice.FormatMessage(_T("Audio Layer: Windows Wave API"));
1512 else if (kAudioWindowsCore == audioLayer)
1514 strDevice.FormatMessage(_T("Audio Layer: Windows Core API"));
1518 strDevice.FormatMessage(_T("Audio Layer: ** UNKNOWN **"));
1520 SetDlgItemText(IDC_EDIT_AUDIO_LAYER, (LPCTSTR)strDevice);
1522 _veHardwarePtr->GetNumOfRecordingDevices(numRecording);
1524 for (int idx = 0; idx < numRecording; idx++)
1526 _veHardwarePtr->GetRecordingDeviceName(idx, nameStr, guidStr);
1527 strDevice.Format(_T("%s"), CharToTchar(nameStr, 128));
1528 comboRecDevice->AddString(strDevice);
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);
1536 _veHardwarePtr->GetNumOfPlayoutDevices(numPlayout);
1538 for (int idx = 0; idx < numPlayout; idx++)
1540 _veHardwarePtr->GetPlayoutDeviceName(idx, nameStr, guidStr);
1541 strDevice.Format(_T("%s"), CharToTchar(nameStr, 128));
1542 comboPlayDevice->AddString(strDevice);
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);
1550 // --- Second channel section
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);
1577 comboIP = (CComboBox*)GetDlgItem(IDC_COMBO_IP_2);
1578 comboIP->AddString(_T("127.0.0.1"));
1579 comboIP->SetCurSel(0);
1581 SetDlgItemInt(IDC_EDIT_TX_PORT_2, 2222);
1582 SetDlgItemInt(IDC_EDIT_RX_PORT_2, 2222);
1584 comboCodec = (CComboBox*)GetDlgItem(IDC_COMBO_CODEC_2);
1585 comboCodec->ResetContent();
1589 numCodecs = _veCodecPtr->NumOfCodecs();
1590 for (int idx = 0; idx < numCodecs; idx++)
1593 _veCodecPtr->GetCodec(idx, codec);
1595 strCodec.Format(_T("%s (%d/%d)"), CharToTchar(codec.plname, 32), codec.pltype, codec.plfreq/1000);
1596 comboCodec->AddString(strCodec);
1598 comboCodec->SetCurSel(0);
1601 // --- Start windows timer
1603 SetTimer(0, 1000, NULL);
1605 return TRUE; // return TRUE unless you set the focus to a control
1608 void CWinTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
1610 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
1615 else if (nID == SC_CLOSE)
1619 channel = GetDlgItemInt(IDC_EDIT_1, &ret);
1622 _veBasePtr->DeleteChannel(channel);
1624 channel = GetDlgItemInt(IDC_EDIT_2, &ret);
1627 _veBasePtr->DeleteChannel(channel);
1630 CDialog::OnSysCommand(nID, lParam);
1634 CDialog::OnSysCommand(nID, lParam);
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.
1643 void CWinTestDlg::OnPaint()
1647 CPaintDC dc(this); // device context for painting
1649 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
1651 // Center icon in client rectangle
1652 int cxIcon = GetSystemMetrics(SM_CXICON);
1653 int cyIcon = GetSystemMetrics(SM_CYICON);
1655 GetClientRect(&rect);
1656 int x = (rect.Width() - cxIcon + 1) / 2;
1657 int y = (rect.Height() - cyIcon + 1) / 2;
1660 dc.DrawIcon(x, y, m_hIcon);
1668 // The system calls this function to obtain the cursor to display while the user drags
1669 // the minimized window.
1670 HCURSOR CWinTestDlg::OnQueryDragIcon()
1672 return static_cast<HCURSOR>(m_hIcon);
1676 void CWinTestDlg::OnBnClickedButtonCreate1()
1679 TEST((channel = _veBasePtr->CreateChannel()) >= 0, _T("CreateChannel(channel=%d)"), channel);
1682 _veRtpRtcpPtr->RegisterRTPObserver(channel, *this);
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);
1714 // Always set send codec to default codec <=> index 0.
1716 _veCodecPtr->GetCodec(0, codec);
1717 _veCodecPtr->SetSendCodec(channel, codec);
1721 void CWinTestDlg::OnBnClickedButtonCreate2()
1724 TEST((channel = _veBasePtr->CreateChannel()) >=0 , _T("CreateChannel(%d)"), channel);
1727 _veRtpRtcpPtr->RegisterRTPObserver(channel, *this);
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);
1753 // Always set send codec to default codec <=> index 0.
1755 _veCodecPtr->GetCodec(0, codec);
1756 _veCodecPtr->SetSendCodec(channel, codec);
1760 void CWinTestDlg::OnBnClickedButtonDelete1()
1763 int channel = GetDlgItemInt(IDC_EDIT_1, &ret);
1766 _delayEstimate1 = 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);
1842 void CWinTestDlg::OnBnClickedButtonDelete2()
1845 int channel = GetDlgItemInt(IDC_EDIT_2, &ret);
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);
1904 void CWinTestDlg::OnCbnSelchangeComboIp1()
1906 int channel = GetDlgItemInt(IDC_EDIT_1);
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();
1917 void CWinTestDlg::OnCbnSelchangeComboIp2()
1919 int channel = GetDlgItemInt(IDC_EDIT_2);
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();
1930 void CWinTestDlg::OnCbnSelchangeComboCodec1()
1932 int channel = GetDlgItemInt(IDC_EDIT_1);
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)
1941 // Set iSAC to adaptive mode by default.
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);
1948 CListBox* list = (CListBox*)GetDlgItem(IDC_LIST_CODEC_1);
1950 SetDlgItemInt(IDC_EDIT_CODEC_1, codec.pltype);
1953 void CWinTestDlg::OnLbnSelchangeListCodec1()
1955 int channel = GetDlgItemInt(IDC_EDIT_1);
1957 CListBox* list = (CListBox*)GetDlgItem(IDC_LIST_CODEC_1);
1958 int listIdx = list->GetCurSel();
1962 list->GetText(listIdx, str);
1965 _veCodecPtr->GetSendCodec(channel, codec);
1967 int value = GetDlgItemInt(IDC_EDIT_CODEC_1);
1968 if (str == _T("pltype"))
1970 codec.pltype = value;
1972 else if (str == _T("plfreq"))
1974 codec.plfreq = value;
1976 else if (str == _T("pacsize"))
1978 codec.pacsize = value;
1980 else if (str == _T("channels"))
1982 codec.channels = value;
1984 else if (str == _T("rate"))
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);
1993 void CWinTestDlg::OnCbnSelchangeComboCodec2()
1995 int channel = GetDlgItemInt(IDC_EDIT_2);
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);
2007 void CWinTestDlg::OnBnClickedButtonStartListen1()
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)
2017 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(FALSE);
2018 GetDlgItem(IDC_BUTTON_STOP_LISTEN_1)->EnableWindow(TRUE);
2022 void CWinTestDlg::OnBnClickedButtonStartListen2()
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)
2032 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(FALSE);
2033 GetDlgItem(IDC_BUTTON_STOP_LISTEN_2)->EnableWindow(TRUE);
2037 void CWinTestDlg::OnBnClickedButtonStopListen1()
2040 int channel = GetDlgItemInt(IDC_EDIT_1);
2041 TEST((ret = _veBasePtr->StopReceive(channel)) == 0, _T("StopListen(channel=%d)"), channel);
2044 GetDlgItem(IDC_BUTTON_START_LISTEN_1)->EnableWindow(TRUE);
2045 GetDlgItem(IDC_BUTTON_STOP_LISTEN_1)->EnableWindow(FALSE);
2049 void CWinTestDlg::OnBnClickedButtonStopListen2()
2052 int channel = GetDlgItemInt(IDC_EDIT_2);
2053 TEST((ret = _veBasePtr->StopReceive(channel)) == 0, _T("StopListen(channel=%d)"), channel);
2056 GetDlgItem(IDC_BUTTON_START_LISTEN_2)->EnableWindow(TRUE);
2057 GetDlgItem(IDC_BUTTON_STOP_LISTEN_2)->EnableWindow(FALSE);
2061 void CWinTestDlg::OnBnClickedButtonStartPlayout1()
2064 int channel = GetDlgItemInt(IDC_EDIT_1);
2065 TEST((ret = _veBasePtr->StartPlayout(channel)) == 0, _T("StartPlayout(channel=%d)"), channel);
2068 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(FALSE);
2069 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_1)->EnableWindow(TRUE);
2073 void CWinTestDlg::OnBnClickedButtonStartPlayout2()
2076 int channel = GetDlgItemInt(IDC_EDIT_2);
2077 TEST((ret = _veBasePtr->StartPlayout(channel)) == 0, _T("StartPlayout(channel=%d)"), channel);
2080 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(FALSE);
2081 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_2)->EnableWindow(TRUE);
2085 void CWinTestDlg::OnBnClickedButtonStopPlayout1()
2088 int channel = GetDlgItemInt(IDC_EDIT_1);
2089 TEST((ret = _veBasePtr->StopPlayout(channel)) == 0, _T("StopPlayout(channel=%d)"), channel);
2092 GetDlgItem(IDC_BUTTON_START_PLAYOUT_1)->EnableWindow(TRUE);
2093 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_1)->EnableWindow(FALSE);
2097 void CWinTestDlg::OnBnClickedButtonStopPlayout2()
2100 int channel = GetDlgItemInt(IDC_EDIT_2);
2101 TEST((ret = _veBasePtr->StopPlayout(channel)) == 0, _T("StopPlayout(channel=%d)"));
2104 GetDlgItem(IDC_BUTTON_START_PLAYOUT_2)->EnableWindow(TRUE);
2105 GetDlgItem(IDC_BUTTON_STOP_PLAYOUT_2)->EnableWindow(FALSE);
2109 void CWinTestDlg::OnBnClickedButtonStartSend1()
2111 UpdateData(TRUE); // update IP address
2114 int channel = GetDlgItemInt(IDC_EDIT_1);
2115 if (!_externalTransport)
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();
2124 //_veVideoSyncPtr->SetInitTimestamp(0,0);
2125 // OnCbnSelchangeComboCodec1();
2127 TEST((ret = _veBasePtr->StartSend(channel)) == 0, _T("StartSend(channel=%d)"), channel);
2130 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(FALSE);
2131 GetDlgItem(IDC_BUTTON_STOP_SEND_1)->EnableWindow(TRUE);
2135 void CWinTestDlg::OnBnClickedButtonStartSend2()
2137 UpdateData(TRUE); // update IP address
2140 int channel = GetDlgItemInt(IDC_EDIT_2);
2141 if (!_externalTransport)
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();
2150 // OnCbnSelchangeComboCodec2();
2152 TEST((ret = _veBasePtr->StartSend(channel)) == 0, _T("StartSend(channel=%d)"), channel);
2155 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(FALSE);
2156 GetDlgItem(IDC_BUTTON_STOP_SEND_2)->EnableWindow(TRUE);
2160 void CWinTestDlg::OnBnClickedButtonStopSend1()
2163 int channel = GetDlgItemInt(IDC_EDIT_1);
2164 TEST((ret = _veBasePtr->StopSend(channel)) == 0, _T("StopSend(channel=%d)"), channel);
2167 GetDlgItem(IDC_BUTTON_START_SEND_1)->EnableWindow(TRUE);
2168 GetDlgItem(IDC_BUTTON_STOP_SEND_1)->EnableWindow(FALSE);
2172 void CWinTestDlg::OnBnClickedButtonStopSend2()
2175 int channel = GetDlgItemInt(IDC_EDIT_2);
2176 TEST((ret = _veBasePtr->StopSend(channel)) == 0, _T("StopSend(channel=%d)"), channel);
2179 GetDlgItem(IDC_BUTTON_START_SEND_2)->EnableWindow(TRUE);
2180 GetDlgItem(IDC_BUTTON_STOP_SEND_2)->EnableWindow(FALSE);
2184 void CWinTestDlg::OnBnClickedCheckExtTrans1()
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);
2193 TEST((ret = _veNetworkPtr->RegisterExternalTransport(channel, *_transportPtr)) == 0,
2194 _T("RegisterExternalTransport(channel=%d, transport=0x%x)"), channel, _transportPtr);
2198 TEST((ret = _veNetworkPtr->DeRegisterExternalTransport(channel)) == 0,
2199 _T("DeRegisterExternalTransport(channel=%d)"), channel);
2203 _externalTransport = enable;
2207 // restore inital state since API call failed
2208 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2212 void CWinTestDlg::OnBnClickedCheckExtTrans2()
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);
2221 TEST((ret = _veNetworkPtr->RegisterExternalTransport(channel, *_transportPtr)) == 0,
2222 _T("RegisterExternalTransport(channel=%d, transport=0x%x)"), channel, _transportPtr);
2226 TEST((ret = _veNetworkPtr->DeRegisterExternalTransport(channel)) == 0,
2227 _T("DeRegisterExternalTransport(channel=%d)"), channel);
2231 _externalTransport = enable;
2235 // restore inital state since API call failed
2236 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2240 void CWinTestDlg::OnBnClickedCheckPlayFileIn1()
2242 std::string micFile = _long_audio_file_path + "audio_short16.pcm";
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);
2252 const bool loop(true);
2253 const FileFormats format = kFileFormatPcm16kHzFile;
2254 const float scale(1.0);
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++;
2267 TEST((ret = _veFilePtr->StopPlayingFileAsMicrophone(channel) == 0),
2268 _T("StopPlayingFileAsMicrophone(channel=%d)"), channel);
2272 // restore inital state since API call failed
2273 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2277 void CWinTestDlg::OnBnClickedCheckPlayFileIn2()
2279 std::string micFile = _long_audio_file_path + "audio_long16.pcm";
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);
2289 const bool loop(true);
2290 const FileFormats format = kFileFormatPcm16kHzFile;
2291 const float scale(1.0);
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++;
2304 TEST((ret = _veFilePtr->StopPlayingFileAsMicrophone(channel) == 0),
2305 _T("StopPlayingFileAsMicrophone(channel=%d)"), channel);
2309 // restore inital state since API call failed
2310 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2314 void CWinTestDlg::OnBnClickedCheckPlayFileOut1()
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"}};
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);
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];
2349 if (_checkPlayFileOut1 % 8 == 0)
2351 str = _T("kFileFormatPcm16kHzFile");
2355 str = _T("kFileFormatWavFile");
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++;
2369 TEST((ret = _veFilePtr->StopPlayingFileLocally(channel) == 0),
2370 _T("StopPlayingFileLocally(channel=%d)"), channel);
2374 // restore inital state since API call failed
2375 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2379 void CWinTestDlg::OnBnClickedCheckPlayFileOut2()
2381 std::string spkrFile = _long_audio_file_path + "audio_long16.pcm";
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);
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);
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++;
2408 TEST((ret = _veFilePtr->StopPlayingFileLocally(channel) == 0),
2409 _T("StopPlayingFileLocally(channel=%d)"), channel);
2413 // restore inital state since API call failed
2414 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2418 void CWinTestDlg::OnBnClickedCheckExtMediaIn1()
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);
2426 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kRecordingPerChannel, *_externalMediaPtr) == 0,
2427 _T("RegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel, processObject=0x%x)"), channel, _externalMediaPtr);
2431 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kRecordingPerChannel) == 0,
2432 _T("DeRegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel)"), channel);
2436 void CWinTestDlg::OnBnClickedCheckExtMediaIn2()
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);
2444 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kRecordingPerChannel, *_externalMediaPtr) == 0,
2445 _T("RegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel, processObject=0x%x)"), channel, _externalMediaPtr);
2449 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kRecordingPerChannel) == 0,
2450 _T("DeRegisterExternalMediaProcessing(channel=%d, kRecordingPerChannel)"), channel);
2454 void CWinTestDlg::OnBnClickedCheckExtMediaOut1()
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);
2462 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kPlaybackPerChannel, *_externalMediaPtr) == 0,
2463 _T("RegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel, processObject=0x%x)"), channel, _externalMediaPtr);
2467 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kPlaybackPerChannel) == 0,
2468 _T("DeRegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel)"), channel);
2472 void CWinTestDlg::OnBnClickedCheckExtMediaOut2()
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);
2480 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kPlaybackPerChannel, *_externalMediaPtr) == 0,
2481 _T("RegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel, processObject=0x%x)"), channel, _externalMediaPtr);
2485 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kPlaybackPerChannel) == 0,
2486 _T("DeRegisterExternalMediaProcessing(channel=%d, kPlaybackPerChannel)"), channel);
2490 void CWinTestDlg::OnBnClickedCheckVad1()
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);
2500 VadModes mode(kVadConventional);
2501 if (_checkVAD1 % 4 == 0)
2503 mode = kVadConventional;
2504 str = _T("kVadConventional");
2506 else if (_checkVAD1 % 4 == 1)
2508 mode = kVadAggressiveLow;
2509 str = _T("kVadAggressiveLow");
2511 else if (_checkVAD1 % 4 == 2)
2513 mode = kVadAggressiveMid;
2514 str = _T("kVadAggressiveMid");
2516 else if (_checkVAD1 % 4 == 3)
2518 mode = kVadAggressiveHigh;
2519 str = _T("kVadAggressiveHigh");
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);
2528 TEST((ret = _veCodecPtr->SetVADStatus(channel, false)) == 0, _T("SetVADStatus(channel=%d, enable=%d)"), channel, false);
2532 // restore inital state since API call failed
2533 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2537 void CWinTestDlg::OnBnClickedCheckVad2()
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);
2547 VadModes mode(kVadConventional);
2548 if (_checkVAD2 % 4 == 0)
2550 mode = kVadConventional;
2551 str = _T("kVadConventional");
2553 else if (_checkVAD2 % 4 == 1)
2555 mode = kVadAggressiveLow;
2556 str = _T("kVadAggressiveLow");
2558 else if (_checkVAD2 % 4 == 2)
2560 mode = kVadAggressiveMid;
2561 str = _T("kVadAggressiveMid");
2563 else if (_checkVAD2 % 4 == 3)
2565 mode = kVadAggressiveHigh;
2566 str = _T("kVadAggressiveHigh");
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);
2575 TEST((ret = _veCodecPtr->SetVADStatus(channel, false) == 0), _T("SetVADStatus(channel=%d, enable=%d)"), channel, false);
2579 // restore inital state since API call failed
2580 button->SetCheck((check == BST_CHECKED) ? BST_UNCHECKED : BST_CHECKED);
2584 void CWinTestDlg::OnBnClickedCheckMuteIn1()
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);
2594 void CWinTestDlg::OnBnClickedCheckMuteIn2()
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);
2604 void CWinTestDlg::OnBnClickedCheckSrtpTx1()
2606 TEST(true, "Built-in SRTP support is deprecated.");
2609 void CWinTestDlg::OnBnClickedCheckSrtpTx2()
2611 TEST(true, "Built-in SRTP support is deprecated.");
2614 void CWinTestDlg::OnBnClickedCheckSrtpRx1()
2616 TEST(true, "Built-in SRTP support is deprecated.");
2619 void CWinTestDlg::OnBnClickedCheckSrtpRx2()
2621 TEST(true, "Built-in SRTP support is deprecated.");
2624 void CWinTestDlg::OnBnClickedCheckExtEncryption1()
2626 TEST(true, "External Encryption has been removed from the API!");
2629 void CWinTestDlg::OnBnClickedCheckExtEncryption2()
2631 TEST(true, "External Encryption has been removed from the API!");
2634 void CWinTestDlg::OnBnClickedButtonDtmf1()
2636 int channel = GetDlgItemInt(IDC_EDIT_1);
2637 CTelephonyEvent dlgTelephoneEvent(_vePtr, channel, this);
2638 dlgTelephoneEvent.DoModal();
2641 void CWinTestDlg::OnBnClickedButtonDtmf2()
2643 int channel = GetDlgItemInt(IDC_EDIT_2);
2644 CTelephonyEvent dlgTelephoneEvent(_vePtr, channel, this);
2645 dlgTelephoneEvent.DoModal();
2648 void CWinTestDlg::OnBnClickedCheckConference1()
2650 // Not supported yet
2653 void CWinTestDlg::OnBnClickedCheckConference2()
2655 // Not supported yet
2658 void CWinTestDlg::OnBnClickedCheckOnHold1()
2660 SHORT shiftKeyIsPressed = ::GetAsyncKeyState(VK_SHIFT);
2663 int channel = GetDlgItemInt(IDC_EDIT_1);
2664 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_ON_HOLD_1);
2665 int check = button->GetCheck();
2667 if (shiftKeyIsPressed)
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);
2677 case kHoldSendAndPlay:
2678 str = _T("kHoldSendAndPlay");
2681 str = _T("kHoldSendOnly");
2684 str = _T("kHoldPlayOnly");
2689 PRINT_GET_RESULT(_T("enabled=%d, mode=%s"), enabled, str);
2694 const bool enable = (check == BST_CHECKED);
2697 OnHoldModes mode(kHoldSendAndPlay);
2698 if (_checkOnHold1 % 3 == 0)
2700 mode = kHoldSendAndPlay;
2701 str = _T("kHoldSendAndPlay");
2703 else if (_checkOnHold1 % 3 == 1)
2705 mode = kHoldSendOnly;
2706 str = _T("kHoldSendOnly");
2708 else if (_checkOnHold1 % 3 == 2)
2710 mode = kHoldPlayOnly;
2711 str = _T("kHoldPlayOnly");
2713 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable, mode)) == 0,
2714 _T("SetOnHoldStatus(channel=%d, enable=%d, mode=%s)"), channel, enable, str);
2719 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable)) == 0,
2720 _T("SetOnHoldStatus(channel=%d, enable=%d)"), channel, enable);
2724 void CWinTestDlg::OnBnClickedCheckOnHold2()
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);
2734 OnHoldModes mode(kHoldSendAndPlay);
2735 if (_checkOnHold1 % 3 == 0)
2737 mode = kHoldSendAndPlay;
2738 str = _T("kHoldSendAndPlay");
2740 else if (_checkOnHold1 % 3 == 1)
2742 mode = kHoldSendOnly;
2743 str = _T("kHoldSendOnly");
2745 else if (_checkOnHold1 % 3 == 2)
2747 mode = kHoldPlayOnly;
2748 str = _T("kHoldPlayOnly");
2750 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable, mode)) == 0,
2751 _T("SetOnHoldStatus(channel=%d, enable=%d, mode=%s)"), channel, enable, str);
2756 TEST((ret = _veBasePtr->SetOnHoldStatus(channel, enable)) == 0,
2757 _T("SetOnHoldStatus(channel=%d, enable=%d)"), channel, enable);
2761 void CWinTestDlg::OnBnClickedCheckDelayEstimate1()
2763 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_DELAY_ESTIMATE_1);
2764 int check = button->GetCheck();
2765 const bool enable = (check == BST_CHECKED);
2769 _delayEstimate1 = true;
2770 SetDlgItemInt(IDC_EDIT_DELAY_ESTIMATE_1, 0);
2774 _delayEstimate1 = false;
2775 SetDlgItemText(IDC_EDIT_DELAY_ESTIMATE_1, _T(""));
2779 void CWinTestDlg::OnBnClickedCheckRxvad()
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);
2789 _veApmPtr->RegisterRxVadObserver(channel, *_rxVadObserverPtr);
2790 SetDlgItemInt(IDC_EDIT_RXVAD, 0);
2795 _veApmPtr->DeRegisterRxVadObserver(channel);
2796 SetDlgItemText(IDC_EDIT_RXVAD, _T(""));
2800 void CWinTestDlg::OnBnClickedCheckAgc1()
2802 SHORT shiftKeyIsPressed = ::GetAsyncKeyState(VK_SHIFT);
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);
2810 if (shiftKeyIsPressed)
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);
2820 case kAgcAdaptiveAnalog:
2821 str = _T("kAgcAdaptiveAnalog");
2823 case kAgcAdaptiveDigital:
2824 str = _T("kAgcAdaptiveDigital");
2826 case kAgcFixedDigital:
2827 str = _T("kAgcFixedDigital");
2832 PRINT_GET_RESULT(_T("enabled=%d, mode=%s"), enabled, str);
2839 AgcModes mode(kAgcDefault);
2840 if (_checkAGC1 % 3 == 0)
2843 str = _T("kAgcDefault");
2845 else if (_checkAGC1 % 3 == 1)
2847 mode = kAgcAdaptiveDigital;
2848 str = _T("kAgcAdaptiveDigital");
2850 else if (_checkAGC1 % 3 == 2)
2852 mode = kAgcFixedDigital;
2853 str = _T("kAgcFixedDigital");
2855 TEST(_veApmPtr->SetRxAgcStatus(channel, true, mode) == 0, _T("SetRxAgcStatus(channel=%d, enable=%d, %s)"), channel, enable, str);
2860 TEST(_veApmPtr->SetRxAgcStatus(channel, false, kAgcUnchanged) == 0, _T("SetRxAgcStatus(channel=%d, enable=%d)"), channel, enable);
2864 void CWinTestDlg::OnBnClickedCheckNs1()
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);
2873 NsModes mode(kNsDefault);
2874 if (_checkNS1 % 6 == 0)
2877 str = _T("kNsDefault");
2879 else if (_checkNS1 % 6 == 1)
2881 mode = kNsConference;
2882 str = _T("kNsConference");
2884 else if (_checkNS1 % 6 == 2)
2886 mode = kNsLowSuppression;
2887 str = _T("kNsLowSuppression");
2889 else if (_checkNS1 % 6 == 3)
2891 mode = kNsModerateSuppression;
2892 str = _T("kNsModerateSuppression");
2894 else if (_checkNS1 % 6 == 4)
2896 mode = kNsHighSuppression;
2897 str = _T("kNsHighSuppression");
2899 else if (_checkNS1 % 6 == 5)
2901 mode = kNsVeryHighSuppression;
2902 str = _T("kNsVeryHighSuppression");
2904 TEST(_veApmPtr->SetRxNsStatus(channel, true, mode) == 0, _T("SetRxNsStatus(channel=%d, enable=%d, %s)"), channel, enable, str);
2909 TEST(_veApmPtr->SetRxNsStatus(channel, false, kNsUnchanged) == 0, _T("SetRxNsStatus(channel=%d, enable=%d)"), enable, channel);
2913 // ----------------------------------------------------------------------------
2914 // Channel-independent Operations
2915 // ----------------------------------------------------------------------------
2917 void CWinTestDlg::OnBnClickedCheckPlayFileIn()
2919 std::string micFile = _long_audio_file_path + "audio_short16.pcm";
2920 // std::string micFile = _long_audio_file_path + "audio_long16noise.pcm";
2923 CButton* buttonExtTrans = (CButton*)GetDlgItem(IDC_CHECK_PLAY_FILE_IN);
2924 int check = buttonExtTrans->GetCheck();
2925 const bool enable = (check == BST_CHECKED);
2929 const bool loop(true);
2930 const FileFormats format = kFileFormatPcm16kHzFile;
2931 const float scale(1.0);
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);
2944 TEST(_veFilePtr->StopPlayingFileAsMicrophone(channel) == 0,
2945 _T("StopPlayingFileAsMicrophone(channel=%d)"), channel);
2949 void CWinTestDlg::OnBnClickedCheckRecMic()
2951 std::string micFile = webrtc::test::OutputPath() +
2952 "rec_mic_mono_16kHz.pcm";
2954 CButton* button = (CButton*)GetDlgItem(IDC_CHECK_REC_MIC);
2955 int check = button->GetCheck();
2956 const bool enable = (check == BST_CHECKED);
2959 TEST(_veFilePtr->StartRecordingMicrophone(micFile.c_str(), NULL) == 0,
2960 _T("StartRecordingMicrophone(file=%s)"),
2961 CharToTchar(micFile.c_str(), -1));
2965 TEST(_veFilePtr->StopRecordingMicrophone() == 0,
2966 _T("StopRecordingMicrophone()"));
2970 void CWinTestDlg::OnBnClickedCheckAgc()
2972 CButton* buttonAGC = (CButton*)GetDlgItem(IDC_CHECK_AGC);
2973 int check = buttonAGC->GetCheck();
2974 const bool enable = (check == BST_CHECKED);
2978 AgcModes mode(kAgcDefault);
2979 if (_checkAGC % 4 == 0)
2982 str = _T("kAgcDefault");
2984 else if (_checkAGC % 4 == 1)
2986 mode = kAgcAdaptiveAnalog;
2987 str = _T("kAgcAdaptiveAnalog");
2989 else if (_checkAGC % 4 == 2)
2991 mode = kAgcAdaptiveDigital;
2992 str = _T("kAgcAdaptiveDigital");
2994 else if (_checkAGC % 4 == 3)
2996 mode = kAgcFixedDigital;
2997 str = _T("kAgcFixedDigital");
2999 TEST(_veApmPtr->SetAgcStatus(true, mode) == 0, _T("SetAgcStatus(enable=%d, %s)"), enable, str);
3004 TEST(_veApmPtr->SetAgcStatus(false, kAgcUnchanged) == 0, _T("SetAgcStatus(enable=%d)"), enable);
3008 void CWinTestDlg::OnBnClickedCheckNs()
3010 CButton* buttonNS = (CButton*)GetDlgItem(IDC_CHECK_NS);
3011 int check = buttonNS->GetCheck();
3012 const bool enable = (check == BST_CHECKED);
3016 NsModes mode(kNsDefault);
3017 if (_checkNS % 6 == 0)
3020 str = _T("kNsDefault");
3022 else if (_checkNS % 6 == 1)
3024 mode = kNsConference;
3025 str = _T("kNsConference");
3027 else if (_checkNS % 6 == 2)
3029 mode = kNsLowSuppression;
3030 str = _T("kNsLowSuppression");
3032 else if (_checkNS % 6 == 3)
3034 mode = kNsModerateSuppression;
3035 str = _T("kNsModerateSuppression");
3037 else if (_checkNS % 6 == 4)
3039 mode = kNsHighSuppression;
3040 str = _T("kNsHighSuppression");
3042 else if (_checkNS % 6 == 5)
3044 mode = kNsVeryHighSuppression;
3045 str = _T("kNsVeryHighSuppression");
3047 TEST(_veApmPtr->SetNsStatus(true, mode) == 0, _T("SetNsStatus(enable=%d, %s)"), enable, str);
3052 TEST(_veApmPtr->SetNsStatus(false, kNsUnchanged) == 0, _T("SetNsStatus(enable=%d)"), enable);
3056 void CWinTestDlg::OnBnClickedCheckEc()
3058 CButton* buttonEC = (CButton*)GetDlgItem(IDC_CHECK_EC);
3059 int check = buttonEC->GetCheck();
3060 const bool enable = (check == BST_CHECKED);
3064 EcModes mode(kEcDefault);
3065 if (_checkEC % 4 == 0)
3068 str = _T("kEcDefault");
3070 else if (_checkEC % 4 == 1)
3072 mode = kEcConference;
3073 str = _T("kEcConference");
3075 else if (_checkEC % 4 == 2)
3080 else if (_checkEC % 4 == 3)
3083 str = _T("kEcAecm");
3085 TEST(_veApmPtr->SetEcStatus(true, mode) == 0, _T("SetEcStatus(enable=%d, %s)"), enable, str);
3090 TEST(_veApmPtr->SetEcStatus(false, kEcUnchanged) == 0, _T("SetEcStatus(enable=%d)"), enable);
3094 void CWinTestDlg::OnBnClickedCheckMuteIn()
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);
3104 void CWinTestDlg::OnBnClickedCheckExtMediaIn()
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);
3112 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kRecordingAllChannelsMixed, *_externalMediaPtr) == 0,
3113 _T("RegisterExternalMediaProcessing(channel=%d, kRecordingAllChannelsMixed, processObject=0x%x)"), channel, _externalMediaPtr);
3117 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kRecordingAllChannelsMixed) == 0,
3118 _T("DeRegisterExternalMediaProcessing(channel=%d, kRecordingAllChannelsMixed)"), channel);
3122 void CWinTestDlg::OnBnClickedCheckExtMediaOut()
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);
3130 TEST(_veExternalMediaPtr->RegisterExternalMediaProcessing(channel, kPlaybackAllChannelsMixed, *_externalMediaPtr) == 0,
3131 _T("RegisterExternalMediaProcessing(channel=%d, kPlaybackAllChannelsMixed, processObject=0x%x)"), channel, _externalMediaPtr);
3135 TEST(_veExternalMediaPtr->DeRegisterExternalMediaProcessing(channel, kPlaybackAllChannelsMixed) == 0,
3136 _T("DeRegisterExternalMediaProcessing(channel=%d, kPlaybackAllChannelsMixed)"), channel);
3140 void CWinTestDlg::OnCbnSelchangeComboRecDevice()
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);
3149 void CWinTestDlg::OnCbnSelchangeComboPlayDevice()
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);
3158 void CWinTestDlg::OnNMReleasedcaptureSliderInputVolume(NMHDR *pNMHDR, LRESULT *pResult)
3160 CSliderCtrl* slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_INPUT_VOLUME);
3161 slider->SetRangeMin(0);
3162 slider->SetRangeMax(255);
3163 int pos = slider->GetPos();
3165 TEST(_veVolumeControlPtr->SetMicVolume(pos) == 0, _T("SetMicVolume(volume=%d)"), pos);
3170 void CWinTestDlg::OnNMReleasedcaptureSliderOutputVolume(NMHDR *pNMHDR, LRESULT *pResult)
3172 CSliderCtrl* slider = (CSliderCtrl*)GetDlgItem(IDC_SLIDER_OUTPUT_VOLUME);
3173 slider->SetRangeMin(0);
3174 slider->SetRangeMax(255);
3175 int pos = slider->GetPos();
3177 TEST(_veVolumeControlPtr->SetSpeakerVolume(pos) == 0, _T("SetSpeakerVolume(volume=%d)"), pos);
3182 void CWinTestDlg::OnNMReleasedcaptureSliderPanLeft(NMHDR *pNMHDR, LRESULT *pResult)
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
3190 const int channel(-1);
3192 // Only left channel will be modified
3193 _veVolumeControlPtr->GetOutputVolumePan(channel, left, right);
3195 left = (float)((float)pos/10.0f);
3197 TEST(_veVolumeControlPtr->SetOutputVolumePan(channel, left, right) == 0,
3198 _T("SetOutputVolumePan(channel=%d, left=%2.1f, right=%2.1f)"), channel, left, right);
3203 void CWinTestDlg::OnNMReleasedcaptureSliderPanRight(NMHDR *pNMHDR, LRESULT *pResult)
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
3211 const int channel(-1);
3213 // Only right channel will be modified
3214 _veVolumeControlPtr->GetOutputVolumePan(channel, left, right);
3216 right = (float)((float)pos/10.0f);
3218 TEST(_veVolumeControlPtr->SetOutputVolumePan(channel, left, right) == 0,
3219 _T("SetOutputVolumePan(channel=%d, left=%2.1f, right=%2.1f)"), channel, left, right);
3224 void CWinTestDlg::OnBnClickedButtonVersion()
3229 if (_veBasePtr->GetVersion(version) == 0)
3231 AfxMessageBox(CString(version), MB_OK);
3235 AfxMessageBox(_T("FAILED!"), MB_OK);
3240 void CWinTestDlg::OnBnClickedCheckRecCall()
3245 void CWinTestDlg::OnBnClickedCheckTypingDetection()
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);
3253 void CWinTestDlg::OnBnClickedCheckRED()
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);
3263 // ----------------------------------------------------------------------------
3265 // ----------------------------------------------------------------------------
3267 void CWinTestDlg::OnTimer(UINT_PTR nIDEvent)
3271 unsigned int svol(0);
3272 unsigned int mvol(0);
3276 // Get speaker and microphone volumes
3277 _veVolumeControlPtr->GetSpeakerVolume(svol);
3278 _veVolumeControlPtr->GetMicVolume(mvol);
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);
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);
3292 unsigned int micLevel;
3293 unsigned int combinedOutputLevel;
3296 _veVolumeControlPtr->GetSpeechInputLevel(micLevel);
3297 _veVolumeControlPtr->GetSpeechOutputLevel(-1, combinedOutputLevel);
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);
3309 // Update playout delay (buffer size)
3310 if (_veVideoSyncPtr)
3313 _veVideoSyncPtr->GetPlayoutBufferSize(bufferMs);
3314 SetDlgItemInt(IDC_EDIT_PLAYOUT_BUFFER_SIZE, bufferMs);
3317 if (_delayEstimate1 && _veVideoSyncPtr)
3319 const int channel = GetDlgItemInt(IDC_EDIT_1);
3321 _veVideoSyncPtr->GetDelayEstimate(channel, delayMs);
3322 SetDlgItemInt(IDC_EDIT_DELAY_ESTIMATE_1, delayMs);
3325 if (_rxVad && _veApmPtr && _rxVadObserverPtr)
3327 SetDlgItemInt(IDC_EDIT_RXVAD, _rxVadObserverPtr->vad_decision);
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);
3340 int channel = GetDlgItemInt(IDC_EDIT_1, &ret);
3347 if (_veCodecPtr->GetRecCodec(channel, codec) == 0)
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);
3359 CallStatistics stats;
3360 if (_veRtpRtcpPtr->GetRTCPStatistics(channel, stats) == 0)
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);
3369 SetTimer(0, 1000, NULL);
3370 CDialog::OnTimer(nIDEvent);
3373 void CWinTestDlg::OnBnClickedButtonClearErrorCallback()
3375 _nErrorCallbacks = 0;
3376 SetDlgItemText(IDC_EDIT_ERROR_CALLBACK, _T(""));
3379 // ----------------------------------------------------------------------------
3381 // ----------------------------------------------------------------------------
3383 void CWinTestDlg::OnBnClickedButtonTest1()
3385 // add tests here...