예제 #1
0
        /// <summary>
        /// 云台控制
        /// </summary>
        /// <param name="deviceID">设备编码</param>
        /// <param name="PTZCmd">云台控制命令</param>
        /// <param name="controlPriority">优先级</param>
        /// <returns></returns>
        public EM_SIP_RESULT PtzControl(string deviceID, string ptzCmd, string controlPriority)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.PtzControl deviceID = {0}.", deviceID);
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                //设备目录查询消息体
                string xmlstr = @"<?xml version='1.0'?><Control><CmdType>DeviceControl</CmdType><SN>" + DeviceControlSN + "</SN><DeviceID>" + deviceID + @"</DeviceID>
                                    <PTZCmd>" + ptzCmd + @"</PTZCmd>
                                    <Info>
                                    <ControlPriority>" + controlPriority + @"</ControlPriority>
                                    </Info></Control>";
                DeviceControlSN++;
                iRet = SipSDKInterface.SIP_SDK_MESSAGE(deviceID, xmlstr);
                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.PtzControl Error = {0}.", Enum.GetName(typeof(EM_SIP_RESULT), iRet));
                }
                logEx.Trace("Leave: SipStackAdapter.PtzControl deviceID = {0}.", deviceID);
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.PtzControl Error = {0}.", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }
예제 #2
0
        /// <summary>
        /// 该函数用于发送SIP ACK消息
        /// </summary>
        /// <param name="iResponseID">iResponseID</param>
        public EM_SIP_RESULT SIP_SDK_ACK(int iResponseID)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.SIP_SDK_ACK().");
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                iRet = SipSDKInterface.SIP_SDK_ACK(iResponseID);

                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.SIP_SDK_ACK ,iResponseID:{0}", iResponseID);
                }
                else
                {
                    logEx.Info("SipStackAdapter.SIP_SDK_ACK ,iResponseID={0}", iResponseID);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.SIP_SDK_ACK ,Exception:{0}", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }
예제 #3
0
        /// <summary>
        /// 该函数用于发送SIP Invite消息
        /// </summary>
        /// <param name="pAccount">对方账号</param>
        /// <param name="pSdpBody">SDP描述字符串</param>
        public EM_SIP_RESULT SIP_SDK_INVITE(string pAccount, string pSdpBody, ref int iResponseID, StringBuilder strRemoteBody)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.SIP_SDK_INVITE().");
            iResponseID = 0;
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                iRet = SipSDKInterface.SIP_SDK_INVITE(pAccount, pSdpBody, ref iResponseID, strRemoteBody);
                SIP_SDK_ACK(iResponseID);
                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.SIP_SDK_INVITE ,pSdpBody:{0}", pSdpBody);
                }
                else
                {
                    logEx.Info("SipStackAdapter.SIP_SDK_INVITE ,iResponseID={0}", iResponseID);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.SIP_SDK_INVITE ,Exception:{0}", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }
예제 #4
0
        /// <summary>
        /// sip保活
        /// </summary>
        /// <param name="localSignalGateway">网关对接T28181监控平台时,网关视为监控平台外域,该编码是标识网关的域编码,即是监控平台配置界面添加网关时的外域编码。</param>
        public void StartKeepalive(string serverID, string localID)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: T28181VideoMonitor.StartConnectRegisterSip().");
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            //初始话定时器
            this.keepLiveTimer.AutoReset = true;
            this.keepLiveTimer.Elapsed  += new System.Timers.ElapsedEventHandler((x, y)
                                                                                 =>
            {
                //sip保活,deviceID为用户名
                string strBody = @"<?xml version='1.0'?><Notify><CmdType>Keepalive</CmdType><SN>" + KeepaliveSN + "</SN><DeviceID>" + localID + "</DeviceID><Status>OK</Status></Notify>";
                KeepaliveSN++;
                iRet = SipSDKInterface.SIP_SDK_MESSAGE(serverID, strBody);
                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Warn("SipStackAdapter.Keepalive Failed");
                    //保活失败,重新注册. zWX231378 .2015/6/24
                    SIP_SDK_REGISTER();
                }
                else
                {
                    logEx.Trace("SipStackAdapter.Keepalive Success");
                }
            });
            //保活时间为10秒
            this.keepLiveTimer.Interval = CgwConst.Thread_Sleep_Time * 10;
            keepLiveTimer.Start();
        }
예제 #5
0
        /// <summary>
        /// 该函数用于发送SIP Register消息
        /// </summary>
        public EM_SIP_RESULT SIP_SDK_REGISTER()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.SIP_SDK_REGISTER().");
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                iRet = SipSDKInterface.SIP_SDK_REGISTER();

                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.SIP_SDK_REGISTER Error = {0}.", Enum.GetName(typeof(EM_SIP_RESULT), iRet));
                }
                else
                {
                    logEx.Info("SipStackAdapter.SIP_SDK_REGISTER Success");
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.SIP_SDK_REGISTER ,Exception:{0}", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }
예제 #6
0
        /// <summary>
        /// 获取系统设备列表
        /// </summary>
        /// <param name="serverSignalGateway">要查询的域编码</param>
        /// <param name="deviceID">要查询的根设备编码</param>
        public void GetDeviceList(string serverSignalGateway, string deviceID)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.GetDeviceList deviceID = {0}.", deviceID);

            try
            {
                //设备总数清空
                if (deviceItemOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                {
                    deviceNum = 0;
                    deviceList.Clear();
                }
            }
            finally
            {
                deviceItemOperateLock.ExitWriteLock();
            }

            try
            {
                //设备目录查询消息体
                string xmlstr = "<?xml version='1.0'?>" +
                                "<Query><CmdType>Catalog</CmdType><SN>" + iCateLogSN + "</SN><DeviceID>" + deviceID + "</DeviceID></Query>";

                iCateLogSN++;
                EM_SIP_RESULT iRet = SipSDKInterface.SIP_SDK_MESSAGE(serverSignalGateway, xmlstr);
                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.GetDeviceList Error = {0}.", Enum.GetName(typeof(EM_SIP_RESULT), iRet));
                    isRefreshSucess = false;
                }
                logEx.Trace("Leave: SipStackAdapter.GetDeviceList deviceID = {0}.", deviceID);
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.GetDeviceList Error = {0}.", ex.ToString());
                isRefreshSucess = false;
            }
        }
예제 #7
0
        /// <summary>
        /// 该函数用于发送subscribe消息
        /// </summary>
        public EM_SIP_RESULT SIP_SDK_Subscribe(string pBody)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.SIP_SDK_Subscribe().");
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                iRet = SipSDKInterface.SIP_SDK_Subscribe(pBody);

                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.SIP_SDK_Subscribe ,pBody:{0}", pBody);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.SIP_SDK_Subscribe ,Exception:{0}", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }
예제 #8
0
        /// <summary>
        /// 该函数用于发送SIP BYE消息
        /// </summary>
        public EM_SIP_RESULT SIP_SDK_BYE(int responseID)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.SIP_SDK_BYE() responseID ={0}.", responseID);
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                iRet = SipSDKInterface.SIP_SDK_BYE(responseID);

                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.SIP_SDK_BYE Error = {0}.", Enum.GetName(typeof(EM_SIP_RESULT), iRet));
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.SIP_SDK_BYE,Exception:{0}", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }
예제 #9
0
        /// <summary>
        /// 初始化SIP协议栈
        /// </summary>
        public EM_SIP_RESULT SIP_SDK_Init(string pSipAccount, string pSipPasswd, string pLocalID, int iLocalPort, string pServerSipAccount, string pServerSipPasswd, string pServerID, string pServerIP, int iServerPort, EventHandler receivedAllDevice)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: SipStackAdapter.SIP_SDK_Init().");
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;

            try
            {
                //string pLocalIP = GetLocalIP(pServerIP, iServerPort, iLocalPort);
                if (string.IsNullOrEmpty(localIP))
                {
                    localIP = GetLocalIP(pServerIP, iServerPort, iLocalPort);
                }
                ReceivedAllDevice = receivedAllDevice;

                sip_CallBack = SIP_CallBackMethod;

                iRet = SipSDKInterface.SIP_SDK_Init(pSipAccount, pSipPasswd, pLocalID, localIP, iLocalPort, pServerSipAccount, pServerSipPasswd, pServerID, pServerIP, iServerPort, sip_CallBack);
                if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                {
                    logEx.Error("SipStackAdapter.SIP_SDK_Init Failed ,pAccount:{0}", pSipAccount);
                }

                //设置NETSOURCE日志目录
                IVS_NETSOURCE_RESULT iNet = NetSourcedInterface.IVS_NETSOURCE_Init(AppDomain.CurrentDomain.BaseDirectory + "\\logs");
                if (iNet != IVS_NETSOURCE_RESULT.SUCCESS)
                {
                    logEx.Error("SipStackAdapter.IVS_NETSOURCE_Init Failed,pAccount:{0}", pSipAccount);
                    iRet = EM_SIP_RESULT.RET_FAILURE;
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("SipStackAdapter.SIP_SDK_Init ,Exception:{0}", ex.ToString());
                iRet = EM_SIP_RESULT.RET_FAILURE;
            }
            return(iRet);
        }