private void sndTestCheckBox_CheckedChanged(object sender, EventArgs e) { ItemData input = (ItemData)sndinputComboBox.SelectedItem; ItemData output = (ItemData)sndoutputComboBox.SelectedItem; if (sndTestCheckBox.Checked) { //Extract input device and get its default samplerate. //WASAPI devices only support one sample rate so it's important to use the correct one. SoundDevice[] devs; TeamTalk.GetSoundDevices(out devs); int in_samplerate = 0; foreach (SoundDevice dev in devs) { if (dev.nDeviceID == input.id) { in_samplerate = dev.nDefaultSampleRate; } } SpeexDSP spxdsp = new SpeexDSP(true); spxdsp.bEnableAGC = true; spxdsp.bEnableDenoise = true; spxdsp.bEnableEchoCancellation = echocancelCheckBox.Checked; soundloop = TeamTalk.StartSoundLoopbackTest(input.id, output.id, in_samplerate, 1, duplexCheckBox.Checked, spxdsp); if (soundloop == IntPtr.Zero) { MessageBox.Show("Failed to test selected device"); sndTestCheckBox.Checked = false; } } else { TeamTalk.CloseSoundLoopbackTest(soundloop); } }
private void button1_Click(object sender, EventArgs e) { ClientFlag flags = ttclient.GetFlags(); //Audio-tab if ((ttclient.Flags & ClientFlag.CLIENT_SNDINOUTPUT_DUPLEX) == ClientFlag.CLIENT_SNDINOUTPUT_DUPLEX) { ttclient.CloseSoundDuplexDevices(); } else { ttclient.CloseSoundInputDevice(); ttclient.CloseSoundOutputDevice(); } ItemData inputItem = (ItemData)sndinputComboBox.SelectedItem; ItemData outputItem = (ItemData)sndoutputComboBox.SelectedItem; settings.sndinputid = inputItem.id; settings.sndoutputid = outputItem.id; if (duplexCheckBox.Checked) { if (!ttclient.InitSoundDuplexDevices(settings.sndinputid, settings.sndoutputid)) { MessageBox.Show("Failed to init sound devices"); } SpeexDSP spxdsp = new SpeexDSP(false); ttclient.GetSoundInputPreprocess(ref spxdsp); spxdsp.nEchoSuppress = SpeexDSPConstants.DEFAULT_ECHO_SUPPRESS; spxdsp.nEchoSuppressActive = SpeexDSPConstants.DEFAULT_ECHO_SUPPRESS_ACTIVE; spxdsp.bEnableEchoCancellation = echocancelCheckBox.Checked; ttclient.SetSoundInputPreprocess(spxdsp); } else { if (!ttclient.InitSoundInputDevice(settings.sndinputid)) { MessageBox.Show("Failed to init sound input device"); } if (!ttclient.InitSoundOutputDevice(settings.sndoutputid)) { MessageBox.Show("Failed to init sound output device"); } } if (wasapiRadioButton.Checked) { settings.soundsystem = SoundSystem.SOUNDSYSTEM_WASAPI; } else if (dsoundRadioButton.Checked) { settings.soundsystem = SoundSystem.SOUNDSYSTEM_DSOUND; } else if (winmmRadioButton.Checked) { settings.soundsystem = SoundSystem.SOUNDSYSTEM_WINMM; } //Video-tab if (viddevComboBox.Items.Count > 0) { VideoCodec codec = new VideoCodec(); codec.nCodec = Codec.WEBM_VP8_CODEC; codec.webm_vp8.nRcTargetBitrate = (int)vidbitrateNumericUpDown.Value; codec.webm_vp8.nEncodeDeadline = WebMVP8CodecConstants.WEBM_VPX_DL_REALTIME; VideoFormat capformat = videodevs[viddevComboBox.SelectedIndex].videoFormats[formatComboBox.SelectedIndex]; if (ttclient.Flags.HasFlag(ClientFlag.CLIENT_VIDEOCAPTURE_READY) && !(settings.videoid == videodevs[viddevComboBox.SelectedIndex].szDeviceID && Util.Equals(codec, settings.codec) && Util.Equals(capformat, settings.capformat))) { ttclient.CloseVideoCaptureDevice(); } settings.codec.nCodec = Codec.WEBM_VP8_CODEC; settings.codec.webm_vp8.nRcTargetBitrate = (int)vidbitrateNumericUpDown.Value; settings.videoid = videodevs[viddevComboBox.SelectedIndex].szDeviceID; settings.capformat = capformat; if (!ttclient.Flags.HasFlag(ClientFlag.CLIENT_VIDEOCAPTURE_READY)) { if (!ttclient.InitVideoCaptureDevice(settings.videoid, settings.capformat)) { MessageBox.Show("Failed to initialize video capture device"); } } } //Advanced-tab if (fwCheckBox.Checked != WindowsFirewall.AppExceptionExists(Application.ExecutablePath)) { if (fwCheckBox.Checked) { WindowsFirewall.AddAppException(Application.ProductName, Application.ExecutablePath); } else { WindowsFirewall.RemoveAppException(Application.ExecutablePath); } } }