public bool Init() { pc = new paramclass(); Cp = new callparam(); Sds = new SDSParam(); SapEntityList1 = new List <ClientDemo.SapEntity>(); Categories = new List <GroupEntry>(); Devicelist = new List <DeviceEntry>(); //BusinessCenter.Instance.OnDataback += update; //BusinessCenter.Instance.showDialog += showdialog; Hytera.Commom.Log.Logger.configLogger(); //string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //Directory.SetCurrentDirectory(path); MediaManager.GetInstance().InitMediaTerm(); //LoginPara loginpara = Hytera.I18N.XMLHelper.DeSerializeFromFile<LoginPara>(fileName); Loginpara = new LoginPara(); Loginpara.LoginName = "anzheng"; Loginpara.Password = "******"; Loginpara.LocolSipIP = "20.0.0.99"; Loginpara.LocolSipPort = "7060"; Loginpara.ServerIP = "20.0.0.11"; Loginpara.ServerPort = "12000"; Loginpara.ServerSipIP = "20.0.0.11"; Loginpara.ServerSipPort = "6060"; BusinessCenter.Instance.OnIncomingCallEvent += Instance_OnIncomingCallEvent; return(true); }
public CC CreateCCSession(callparam cp, string cmdGuid) { CC session = new CC(); session.pictrueboxHandle = cp.pictrueboxHandle; session.LocalIp = _localSipIP; session.IsDuplex = cp.IsDuplex == "1" ? true : false; session.CallID = cp.cmd_guid; session.CallMode = cp.CallMode; //if (cp.CallMode == GlobalCommandName.CallMode.Audio) // session.CallMode = "0"; //if (cp.CallMode == GlobalCommandName.CallMode.video) // session.CallMode = "1"; //if (cp.CallMode == GlobalCommandName.CallMode.AudioAndVideo) // session.CallMode = "2"; if (session.LocalIp != null) { try { switch (cp.CallMode) { case GlobalCommandName.CallMode.video: { session.VideoPtrRecv = MediaManager.GetInstance().GetVedioPtrRecvBycmdGuid(session.LocalIp, cmdGuid); IntPtr ptr = MediaManager.MediaTerm_GetHndPara(session.VideoPtrRecv); ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo result = (ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)Marshal.PtrToStructure(ptr, typeof(ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)); if (result.localPort != 0) { session.Media = new Media(); session.Media.Video = new AudioEntity(); session.Media.Video.Rtp_local_ip = result.ipAddr; session.Media.Video.Rtp_local_port = result.localPort.ToString(); //CurrentCCSession = session; return(session); //此时已经规定本Session的本地端口 } else { return(null); } } case GlobalCommandName.CallMode.Audio: { session.VoicePtrRecv = MediaManager.GetInstance().GetVoicePtrRecvBycmdGuid(session.LocalIp, cmdGuid); IntPtr ptr = MediaManager.MediaTerm_GetHndPara(session.VoicePtrRecv); ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo result = (ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)Marshal.PtrToStructure(ptr, typeof(ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)); if (result.localPort != 0) { session.Media = new Media(); session.Media.Audio = new AudioEntity(); session.Media.Audio.Rtp_local_ip = result.ipAddr; session.Media.Audio.Rtp_local_port = result.localPort.ToString(); // CurrentCCSession = session; //return session;//此时已经规定本Session的本地端口 } else { return(null); } session.VoicePrtRecvSip = MediaManager.GetInstance().GetVoicePtrRecvBycmdGuid(session.LocalIp, cmdGuid); IntPtr ptrSip = MediaManager.MediaTerm_GetHndPara(session.VoicePrtRecvSip); ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo result1 = (ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)Marshal.PtrToStructure(ptrSip, typeof(ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)); if (result1.localPort != 0) { session.VoiceRecvSipPort = result1.localPort; return(session); } else { return(null); } } case GlobalCommandName.CallMode.AudioAndVideo: { session.VideoPtrRecv = MediaManager.GetInstance().GetVedioPtrRecvBycmdGuid(session.LocalIp, cmdGuid); IntPtr ptr1 = MediaManager.MediaTerm_GetHndPara(session.VideoPtrRecv); ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo result1 = (ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)Marshal.PtrToStructure(ptr1, typeof(ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)); session.Media = new Media(); if (result1.localPort != 0) { session.Media.Video = new AudioEntity(); session.Media.Video.Rtp_local_ip = result1.ipAddr; session.Media.Video.Rtp_local_port = result1.localPort.ToString(); } else { return(null); } session.VoicePtrRecv = MediaManager.GetInstance().GetVoicePtrRecvBycmdGuid(session.LocalIp, cmdGuid); IntPtr ptr2 = MediaManager.MediaTerm_GetHndPara(session.VoicePtrRecv); ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo result2 = (ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)Marshal.PtrToStructure(ptr2, typeof(ClientDemo.PUCApiAdapter.mediaPlgTermHndInfo)); if (result2.localPort != 0) { session.Media.Audio = new AudioEntity(); session.Media.Audio.Rtp_local_ip = result2.ipAddr; session.Media.Audio.Rtp_local_port = result2.localPort.ToString(); } else { return(null); } //CurrentCCSession = session; return(session); } default: { return(null); } } } catch (Exception ex) { MessageBox.Show("创建本地rtp接收端口失败,请确认语音设备正常运行。"); Hytera.Commom.Log.Logger.Error("session.VoicePtrRecv:" + session.VoicePtrRecv, ex); return(null); } } else { MessageBox.Show("请先登录,获取本地ip失败"); return(null); } }