public ChannelDlg(TeamTalk tt, ChannelDlgType dlgtype, int channelid, int parentid) { ttclient = tt; this.dlgtype = dlgtype; InitializeComponent(); if (channelid > 0 && ttclient.GetChannel(channelid, ref chan)) { string path = ""; ttclient.GetChannelPath(channelid, ref path); chanpathTextBox.Text = path; channameTextBox.Text = chan.szName; topicTextBox.Text = chan.szTopic; passwdTextBox.Text = chan.szPassword; maxusersNumericUpDown.Value = chan.nMaxUsers; diskquotaNumericUpDown.Value = chan.nDiskQuota / 1024; permchannelCheckBox.Checked = chan.uChannelType.HasFlag(ChannelType.CHANNEL_PERMANENT); singletxCheckBox.Checked = chan.uChannelType.HasFlag(ChannelType.CHANNEL_SOLO_TRANSMIT); classroomCheckBox.Checked = chan.uChannelType.HasFlag(ChannelType.CHANNEL_CLASSROOM); oprecvonlyCheckBox.Checked = chan.uChannelType.HasFlag(ChannelType.CHANNEL_OPERATOR_RECVONLY); novoiceactCheckBox.Checked = chan.uChannelType.HasFlag(ChannelType.CHANNEL_NO_VOICEACTIVATION); norecordCheckBox.Checked = chan.uChannelType.HasFlag(ChannelType.CHANNEL_NO_RECORDING); switch (chan.audiocodec.nCodec) { case Codec.SPEEX_CODEC: tabControl1.SelectedIndex = (int)CodecTabs.SPEEX_CBR_TAB; speexnbRadioButton.Checked = chan.audiocodec.speex.nBandmode == 0; speexwbRadioButton.Checked = chan.audiocodec.speex.nBandmode == 1; speexuwbRadioButton.Checked = chan.audiocodec.speex.nBandmode == 2; speexqualityTrackBar.Value = chan.audiocodec.speex.nQuality; speexTxInterval.Value = chan.audiocodec.speex.nTxIntervalMSec; speexstereoCheckBox.Checked = chan.audiocodec.speex.bStereoPlayback; break; case Codec.SPEEX_VBR_CODEC : tabControl1.SelectedIndex = (int)CodecTabs.SPEEX_VBR_TAB; speexvbrnbRadioButton.Checked = chan.audiocodec.speex_vbr.nBandmode == 0; speexvbrwbRadioButton.Checked = chan.audiocodec.speex_vbr.nBandmode == 1; speexvbruwbRadioButton.Checked = chan.audiocodec.speex_vbr.nBandmode == 2; speexvbrqualityTrackBar.Value = chan.audiocodec.speex_vbr.nQuality; speexvbrbitrateNumericUpDown.Value = chan.audiocodec.speex_vbr.nBitRate; speexvbrmaxbrNumericUpDown.Value = chan.audiocodec.speex_vbr.nMaxBitRate; speexvbrTxInterval.Value = chan.audiocodec.speex_vbr.nTxIntervalMSec; speexvbrdtxCheckBox.Checked = chan.audiocodec.speex_vbr.bDTX; speexvbrstereoCheckBox.Checked = chan.audiocodec.speex_vbr.bStereoPlayback; break; case Codec.OPUS_CODEC: tabControl1.SelectedIndex = (int)CodecTabs.OPUS_TAB; int i = opussamplerateComboBox.FindString(chan.audiocodec.opus.nSampleRate.ToString()); if (i < 0) i = 0; opussamplerateComboBox.SelectedIndex = i; opuschannelsComboBox.SelectedIndex = chan.audiocodec.opus.nChannels - 1; switch (chan.audiocodec.opus.nApplication) { case OpusConstants.OPUS_APPLICATION_AUDIO : opusaudioRadioButton.Checked = true; break; case OpusConstants.OPUS_APPLICATION_VOIP : opusvoipRadioButton.Checked = true; break; default: opusvoipRadioButton.Checked = true; break; } opuscomplexityNumericUpDown.Value = chan.audiocodec.opus.nComplexity; opusfecCheckBox.Checked = chan.audiocodec.opus.bFEC; opusdtxCheckBox.Checked = chan.audiocodec.opus.bDTX; opusvbrCheckBox.Checked = chan.audiocodec.opus.bVBR; opusvbrconstraintCheckBox.Checked = chan.audiocodec.opus.bVBRConstraint; opusbitrateNumericUpDown.Value = chan.audiocodec.opus.nBitRate / 1000; opusTxIntervalNumericUpDown.Value = chan.audiocodec.opus.nTxIntervalMSec; break; } agcCheckBox.Checked = chan.audiocfg.bEnableAGC; gainlevelTrackBar.Value = chan.audiocfg.nGainLevel; } else { string path = ""; ttclient.GetChannelPath(parentid, ref path); chanpathTextBox.Text = path; chan.nParentID = parentid; } UserType usertype = ttclient.GetMyUserType(); switch (dlgtype) { case ChannelDlgType.JOIN_CHANNEL : //when joining a channel 'disk quota' and 'max users' are set to server's default values diskquotaNumericUpDown.ReadOnly = true; maxusersNumericUpDown.ReadOnly = true; goto case ChannelDlgType.CREATE_CHANNEL; case ChannelDlgType.CREATE_CHANNEL : opussamplerateComboBox.SelectedIndex = 0; opuschannelsComboBox.SelectedIndex = 0; opuschannelsComboBox.SelectedIndex = 0; //only admins can change static channel property permchannelCheckBox.Enabled = ttclient.UserRights.HasFlag(UserRight.USERRIGHT_MODIFY_CHANNELS); diskquotaNumericUpDown.ReadOnly = !ttclient.UserRights.HasFlag(UserRight.USERRIGHT_MODIFY_CHANNELS); agcCheckBox.Checked = true; gainlevelTrackBar.Value = 8000; break; case ChannelDlgType.UPDATE_CHANNEL : break; case ChannelDlgType.VIEW_CHANNEL : channameTextBox.ReadOnly = true; topicTextBox.ReadOnly = true; passwdTextBox.ReadOnly = true; oppasswdTextBox.ReadOnly = true; maxusersNumericUpDown.ReadOnly = true; diskquotaNumericUpDown.ReadOnly = true; permchannelCheckBox.Enabled = false; singletxCheckBox.Enabled = false; classroomCheckBox.Enabled = false; oprecvonlyCheckBox.Enabled = false; novoiceactCheckBox.Enabled = false; norecordCheckBox.Enabled = false; agcCheckBox.Enabled = false; gainlevelTrackBar.Enabled = false; tabControl1.Enabled = false; break; } }
void VoiceTxRx(TeamTalk ttclient, int TEST_DURATION, int VOICE_TX_DURATION, int SILENCE_DURATION) { Debug.WriteLine("Total Duration {0} {1} {2}", TEST_DURATION, VOICE_TX_DURATION, SILENCE_DURATION); Channel chan = new Channel(); Assert.IsTrue(ttclient.GetChannel(ttclient.ChannelID, ref chan)); TTMessage msg = new TTMessage(); int tx_interval = chan.audiocodec.opus.nTxIntervalMSec; int test_duration = 0, voice_tx_duration; while (test_duration < TEST_DURATION) { Debug.WriteLine("Duration {0}", test_duration); voice_tx_duration = 0; AudioBlock block; Assert.IsTrue(ttclient.EnableVoiceTransmission(true)); Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_STATECHANGE, 1000, ref msg)); Assert.IsTrue(((User)msg.DataToObject()).uUserState.HasFlag(UserState.USERSTATE_VOICE)); do { Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_AUDIOBLOCK, 1000)); block = ttclient.AcquireUserAudioBlock(StreamType.STREAMTYPE_VOICE, ttclient.UserID); Assert.IsTrue(block.nStreamID > 0); Assert.IsTrue(ttclient.ReleaseUserAudioBlock(block)); } while ((voice_tx_duration += tx_interval) < VOICE_TX_DURATION); Assert.IsTrue(ttclient.EnableVoiceTransmission(false)); Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_STATECHANGE, 5000, ref msg)); Assert.IsFalse(((User)msg.DataToObject()).uUserState.HasFlag(UserState.USERSTATE_VOICE)); WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_NONE, SILENCE_DURATION); //drain queue do { block = ttclient.AcquireUserAudioBlock(StreamType.STREAMTYPE_VOICE, ttclient.UserID); if(block.nStreamID>0) ttclient.ReleaseUserAudioBlock(block); } while(block.nStreamID>0); while(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_USER_AUDIOBLOCK, 0)) test_duration += voice_tx_duration; test_duration += SILENCE_DURATION; } }