Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            chan.szName       = channameTextBox.Text;
            chan.szTopic      = topicTextBox.Text;
            chan.szPassword   = passwdTextBox.Text;
            chan.szOpPassword = oppasswdTextBox.Text;
            chan.nMaxUsers    = (int)maxusersNumericUpDown.Value;
            chan.nDiskQuota   = (long)diskquotaNumericUpDown.Value * 1024;

            switch (tabControl1.SelectedIndex)
            {
            case (int)CodecTabs.SPEEX_CBR_TAB:

                chan.audiocodec.nCodec = Codec.SPEEX_CODEC;
                if (speexnbRadioButton.Checked)
                {
                    chan.audiocodec.speex.nBandmode = 0;
                }
                else if (speexwbRadioButton.Checked)
                {
                    chan.audiocodec.speex.nBandmode = 1;
                }
                else if (speexuwbRadioButton.Checked)
                {
                    chan.audiocodec.speex.nBandmode = 2;
                }
                chan.audiocodec.speex.nQuality        = speexqualityTrackBar.Value;
                chan.audiocodec.speex.nTxIntervalMSec = (int)speexTxInterval.Value;
                chan.audiocodec.speex.bStereoPlayback = speexstereoCheckBox.Checked;
                break;

            case (int)CodecTabs.SPEEX_VBR_TAB:

                chan.audiocodec.nCodec = Codec.SPEEX_VBR_CODEC;
                if (speexvbrnbRadioButton.Checked)
                {
                    chan.audiocodec.speex_vbr.nBandmode = 0;
                }
                else if (speexvbrwbRadioButton.Checked)
                {
                    chan.audiocodec.speex_vbr.nBandmode = 1;
                }
                else if (speexvbruwbRadioButton.Checked)
                {
                    chan.audiocodec.speex_vbr.nBandmode = 2;
                }
                chan.audiocodec.speex_vbr.nQuality        = speexvbrqualityTrackBar.Value;
                chan.audiocodec.speex_vbr.nBitRate        = (int)speexvbrbitrateNumericUpDown.Value;
                chan.audiocodec.speex_vbr.nMaxBitRate     = (int)speexvbrmaxbrNumericUpDown.Value;
                chan.audiocodec.speex_vbr.bDTX            = speexvbrdtxCheckBox.Checked;
                chan.audiocodec.speex_vbr.nTxIntervalMSec = (int)speexvbrTxInterval.Value;
                chan.audiocodec.speex_vbr.bStereoPlayback = speexvbrstereoCheckBox.Checked;
                break;

            case (int)CodecTabs.OPUS_TAB:

                chan.audiocodec.nCodec           = Codec.OPUS_CODEC;
                chan.audiocodec.opus.nSampleRate = int.Parse(opussamplerateComboBox.Text);
                chan.audiocodec.opus.nBitRate    = (int)opusbitrateNumericUpDown.Value * 1000;
                chan.audiocodec.opus.nChannels   = opuschannelsComboBox.SelectedIndex + 1;
                if (opusvoipRadioButton.Checked)
                {
                    chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_VOIP;
                }
                else
                {
                    chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
                }
                chan.audiocodec.opus.nComplexity     = (int)opuscomplexityNumericUpDown.Value;
                chan.audiocodec.opus.bDTX            = opusdtxCheckBox.Checked;
                chan.audiocodec.opus.bFEC            = opusfecCheckBox.Checked;
                chan.audiocodec.opus.bVBR            = opusvbrCheckBox.Checked;
                chan.audiocodec.opus.bVBRConstraint  = opusvbrconstraintCheckBox.Checked;
                chan.audiocodec.opus.nTxIntervalMSec = (int)opusTxIntervalNumericUpDown.Value;
                break;
            }
            chan.uChannelType |= permchannelCheckBox.Checked ? ChannelType.CHANNEL_PERMANENT : ChannelType.CHANNEL_DEFAULT;
            chan.uChannelType |= singletxCheckBox.Checked ? ChannelType.CHANNEL_SOLO_TRANSMIT : ChannelType.CHANNEL_DEFAULT;
            chan.uChannelType |= classroomCheckBox.Checked ? ChannelType.CHANNEL_CLASSROOM: ChannelType.CHANNEL_DEFAULT;
            chan.uChannelType |= oprecvonlyCheckBox.Checked ? ChannelType.CHANNEL_OPERATOR_RECVONLY : ChannelType.CHANNEL_DEFAULT;
            chan.uChannelType |= novoiceactCheckBox.Checked ? ChannelType.CHANNEL_NO_VOICEACTIVATION : ChannelType.CHANNEL_DEFAULT;
            chan.uChannelType |= norecordCheckBox.Checked ? ChannelType.CHANNEL_NO_RECORDING : ChannelType.CHANNEL_DEFAULT;


            chan.audiocfg.bEnableAGC = agcCheckBox.Checked;
            chan.audiocfg.nGainLevel = gainlevelTrackBar.Value;

            switch (dlgtype)
            {
            case ChannelDlgType.JOIN_CHANNEL:
                if (ttclient.DoJoinChannel(chan) < 0)
                {
                    MessageBox.Show("Unable to join channel", "Join Channel");
                }
                //else wait for OnCmdChannelNew event
                break;

            case ChannelDlgType.CREATE_CHANNEL:
                if (ttclient.DoMakeChannel(chan) < 0)
                {
                    MessageBox.Show("Unable to create channel", "Create Channel");
                }
                //else wait for OnCmdChannelNew event
                break;

            case ChannelDlgType.UPDATE_CHANNEL:
                if (permchannelCheckBox.Checked)
                {
                    chan.uChannelType |= ChannelType.CHANNEL_PERMANENT;
                }
                else
                {
                    chan.uChannelType &= ~ChannelType.CHANNEL_PERMANENT;
                }
                if (singletxCheckBox.Checked)
                {
                    chan.uChannelType |= ChannelType.CHANNEL_SOLO_TRANSMIT;
                }
                else
                {
                    chan.uChannelType &= ~ChannelType.CHANNEL_SOLO_TRANSMIT;
                }
                if (classroomCheckBox.Checked)
                {
                    chan.uChannelType |= ChannelType.CHANNEL_CLASSROOM;
                }
                else
                {
                    chan.uChannelType &= ~ChannelType.CHANNEL_CLASSROOM;
                }
                if (oprecvonlyCheckBox.Checked)
                {
                    chan.uChannelType |= ChannelType.CHANNEL_OPERATOR_RECVONLY;
                }
                else
                {
                    chan.uChannelType &= ~ChannelType.CHANNEL_OPERATOR_RECVONLY;
                }
                if (novoiceactCheckBox.Checked)
                {
                    chan.uChannelType |= ChannelType.CHANNEL_NO_VOICEACTIVATION;
                }
                else
                {
                    chan.uChannelType &= ~ChannelType.CHANNEL_NO_VOICEACTIVATION;
                }
                if (norecordCheckBox.Checked)
                {
                    chan.uChannelType |= ChannelType.CHANNEL_NO_RECORDING;
                }
                else
                {
                    chan.uChannelType &= ~ChannelType.CHANNEL_NO_RECORDING;
                }

                if (ttclient.DoUpdateChannel(chan) < 0)
                {
                    MessageBox.Show("Unable to update channel", "Update Channel");
                }
                break;
            }
        }