private void btnInit_Click(object sender, EventArgs e) { try { pmAgent.strSoftPhoneNum = this.txtSoftPhoneNum.Text; pmAgent.strLeftPhoneNum = this.txtLeftHandleNum.Text; pmAgent.strRightPhoneNum = this.txtRightHandleNum.Text; pmAgent.strSoftPhonePwd = this.txtSoftPhonePwd.Text; string[] strTemp = this.txtSipServerIP.Text.ToString().Split(':'); strSipServerIP = strTemp[0]; if (strTemp.Length > 1) { if (strTemp[1] == "") { nSipPort = 5060; } else { nSipPort = DispatchClient.Base.atoi(strTemp[1]); } } if (strSipServerIP == "") { strSipServerIP = strDispatchServerIP; } pmPhone.strSipServerIP = strSipServerIP; pmPhone.nServerPort = nSipPort; pmPhone.nLocalPort = 6060; pmPhone.strLocalIP = this.txtLocalIP.Text; if (!pmPhone.IsRegistered && (pmAgent.nStatus == e_Status.nLogin))//注册 { SIPPhoneSDK.SDKInit(pmPhone.strLocalIP, pmPhone.nLocalPort); LoadDevices(); pmPhone.IsRegistered = SIPPhoneSDK.Regist(pmPhone.strSipServerIP + ":" + pmPhone.nServerPort, pmAgent.strSoftPhoneNum, pmAgent.strSoftPhonePwd); if (pmPhone.IsRegistered) { this.Invoke((EventHandler)(delegate { this.btnInit.Text = "注销"; })); } string strInfo = String.Format("DTC->DTS; KEY=REGISTERSOFTPHONE; SOFTPHONENUM={0}; RESULT={1};", pmAgent.strSoftPhoneNum, pmPhone.IsRegistered.ToString()); ShowDebugInfo(strInfo); } else//注销 { SIPPhoneSDK.UnRegist(); SIPPhoneSDK.SDKDestory(); this.Invoke((EventHandler)(delegate { this.btnInit.Text = "注册"; pmPhone.IsRegistered = false; })); } } catch (System.Exception ex) { ShowDebugInfo(ex.ToString()); } }
private void AllClear() { this.EmployeeTree.Nodes.Clear(); this.RadioTree.Nodes.Clear(); this.VideoDeviceTree.Nodes.Clear(); this.VideoEmployeeTree.Nodes.Clear(); if (Base.g_GroupNum_IsLoaded != null) { Base.g_GroupNum_IsLoaded.Clear(); } Base.g_VideoTreeRootNode = null; if (pmPhone.IsRegistered) { SIPPhoneSDK.UnRegist(); pmPhone.IsRegistered = false; } }
private void LoadDevices() { //LoadInputAudioDevice and LoadOutputAudioDevice int audLen; SIPPhoneSDK.GetAudioDevices(Base.g_AudioDevices, out audLen); this.cmbAudioInputDevices.Items.Clear(); this.cmbAudioOutputDevices.Items.Clear(); if (audLen > 0) { foreach (SIPPhoneSDK.AudioDeviceInfo audio in Base.g_AudioDevices) { if (audio.name == "Wave mapper") { continue; } if (audio.inputCnt > 0) { this.cmbAudioInputDevices.Items.Add(audio.id.ToString() + "-" + audio.name); } if (audio.outputCnt > 0) { this.cmbAudioOutputDevices.Items.Add(audio.id.ToString() + "-" + audio.name); } } if (this.cmbAudioInputDevices.Items.Count >= 1) { this.cmbAudioInputDevices.SelectedIndex = 0; } if (this.cmbAudioOutputDevices.Items.Count >= 1) { this.cmbAudioOutputDevices.SelectedIndex = 0; } } //LoadInputVideoDevice int nTemp; SIPPhoneSDK.GetVideoDevices(Base.g_VideoDevices, out nTemp); this.cmbVideoDevices.Items.Clear(); if (nTemp > 0) { foreach (SIPPhoneSDK.VideoDeviceInfo video in Base.g_VideoDevices) { if (video.name == "SDL renderer" || video.name == "Colorbar generator" || video.name == "Colorbar-active" || video.name == "") { continue; } this.cmbVideoDevices.Items.Add(video.id.ToString() + "-" + video.name); } if (this.cmbVideoDevices.Items.Count >= 1) { this.cmbVideoDevices.SelectedIndex = 0; } else { this.cmbVideoDevices.Items.Add("无"); this.cmbVideoDevices.SelectedIndex = 0; } } }