/// <summary>
        /// PTZ云台控制
        /// </summary>
        /// <param name="deviceId">设备ID</param>
        /// <param name="ucommand">控制命令</param>
        /// <param name="dwStop">开始或结束</param>
        /// <param name="dwSpeed">速度</param>
        public void PtzContrl(string deviceId, int ucommand, int dwStop, int dwSpeed)
        {
            if (LocalEndPoint == null)
            {
                OnSIPServiceChange(deviceId, SipServiceStatus.Wait);
                return;
            }
            string     fromTag    = CallProperties.CreateNewTag();
            string     toTag      = CallProperties.CreateNewTag();
            int        cSeq       = CallProperties.CreateNewCSeq();
            string     callId     = CallProperties.CreateNewCallId();
            SIPRequest catalogReq = QueryItems(fromTag, toTag, cSeq, callId);
            string     cmdStr     = GetPtzCmd(ucommand, dwStop, dwSpeed);

            PTZControl ptz = new PTZControl()
            {
                CommandType = CommandType.DeviceControl,
                DeviceID    = deviceId,
                SN          = new Random().Next(9999),
                PTZCmd      = cmdStr
            };
            string xmlBody = PTZControl.Instance.Save <PTZControl>(ptz);

            catalogReq.Body = xmlBody;
            Transport.SendRequest(RemoteEndPoint, catalogReq);
            _catalogTask             = new TaskTiming(catalogReq, Transport);
            this.SendRequestTimeout += _catalogTask.MessageSendRequestTimeout;
            _catalogTask.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 暂停录像播放
        /// </summary>
        public void BackVideoPauseControlReq()
        {
            if (_msgCore.LocalEndPoint == null)
            {
                OnSIPServiceChange(_deviceName + "-" + _deviceId, SipServiceStatus.Wait);
                return;
            }
            if (_mediaPort == null)
            {
                _mediaPort = _msgCore.SetMediaPort();
            }

            string localIp = _msgCore.LocalEndPoint.Address.ToString();
            string fromTag = CallProperties.CreateNewTag();
            int    cSeq    = CallProperties.CreateNewCSeq();
            string callId  = CallProperties.CreateNewCallId();
            //this.Stop();
            SIPRequest realReq = BackVideoPauseControlReq(localIp, _mediaPort, fromTag, cSeq, callId);

            _msgCore.Transport.SendRequest(_msgCore.RemoteEndPoint, realReq);
            _realTask = new TaskTiming(realReq, _msgCore.Transport);
            _msgCore.SendRequestTimeout += _realTask.MessageSendRequestTimeout;
            _realTask.OnCloseRTPChannel += Task_OnCloseRTPChannel;
            _realTask.Start();
        }
        /// <summary>
        /// 设备目录查询
        /// </summary>
        /// <param name="deviceId">目的设备编码</param>
        public void DeviceCatalogQuery(string deviceId)
        {
            if (LocalEndPoint == null)
            {
                OnSIPServiceChange(deviceId, SipServiceStatus.Wait);
                return;
            }
            string       fromTag    = CallProperties.CreateNewTag();
            string       toTag      = CallProperties.CreateNewTag();
            int          cSeq       = CallProperties.CreateNewCSeq();
            string       callId     = CallProperties.CreateNewCallId();
            SIPRequest   catalogReq = QueryItems(fromTag, toTag, cSeq, callId);
            CatalogQuery catalog    = new CatalogQuery()
            {
                CommandType = CommandType.Catalog,
                DeviceID    = deviceId,
                SN          = new Random().Next(9999)
            };
            string xmlBody = CatalogQuery.Instance.Save <CatalogQuery>(catalog);

            catalogReq.Body = xmlBody;
            Transport.SendRequest(RemoteEndPoint, catalogReq);
            _catalogTask             = new TaskTiming(catalogReq, Transport);
            this.SendRequestTimeout += _catalogTask.MessageSendRequestTimeout;
            _catalogTask.Start();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 结束录像点播视频请求
        /// </summary>
        /// <returns></returns>
        public void BackVideoStopPlayingControlReq()
        {
            if (_realReqSession == null)
            {
                OnSIPServiceChange(_deviceName + "-" + _deviceId, SipServiceStatus.Wait);
                return;
            }
            SIPURI        localUri  = new SIPURI(_msgCore.LocalSIPId, _msgCore.LocalEndPoint.ToHost(), "");
            SIPURI        remoteUri = new SIPURI(_deviceId, _msgCore.RemoteEndPoint.ToHost(), "");
            SIPFromHeader from      = new SIPFromHeader(null, localUri, _realReqSession.Header.From.FromTag);
            SIPToHeader   to        = new SIPToHeader(null, remoteUri, _realReqSession.Header.To.ToTag);
            SIPRequest    byeReq    = _msgCore.Transport.GetRequest(SIPMethodsEnum.BYE, remoteUri);
            SIPHeader     header    = new SIPHeader(from, to, _realReqSession.Header.CSeq, _realReqSession.Header.CallId);

            header.CSeqMethod  = byeReq.Header.CSeqMethod;
            header.Vias        = byeReq.Header.Vias;
            header.MaxForwards = byeReq.Header.MaxForwards;
            header.UserAgent   = _msgCore.UserAgent;
            byeReq.Header.From = from;
            byeReq.Header      = header;
            this.Stop();
            _msgCore.Transport.SendRequest(_msgCore.RemoteEndPoint, byeReq);
            _byeTask = new TaskTiming(byeReq, _msgCore.Transport);
            _msgCore.SendRequestTimeout += _byeTask.MessageSendRequestTimeout;
            _byeTask.OnCloseRTPChannel  += Task_OnCloseRTPChannel;
            _byeTask.Start();
        }