예제 #1
0
 /// <summary>
 /// 注销
 /// </summary>
 /// <returns></returns>
 public override KeyValuePair <bool, string> Logout()
 {
     if (!this.IsLogin)
     {
         return(new KeyValuePair <bool, string>(true, "注销成功!"));
     }
     //如果存在实时预览,则执行停止
     if (this.IsRealPlay)
     {
         this.StopRealPlay();
     }
     try
     {
         var ret = SDKWrap.Logout(this.userId);
         if (ret.Key)
         {
             this.userId = -1;
         }
         return(ret);
     }
     catch (Exception e)
     {
         return(new KeyValuePair <bool, string>(false, e.Message));
     }
 }
예제 #2
0
        /// <summary>
        /// 设置实时预览回调
        /// </summary>
        /// <returns></returns>
        public KeyValuePair <bool, string> SetRealDataCallBack()
        {
            this.realDataCallback = new SDKTypes.FPlayESCallBack(this.RealDataCallBack);

            var ret = SDKWrap.SetESRealPlayCallBack(this.realPlayHandle, this.realDataCallback, this.userPtr);

            return(ret);
        }
예제 #3
0
 /// <summary>
 /// 获取最后一次错误消息
 /// </summary>
 /// <returns></returns>
 public string GetLastError()
 {
     try
     {
         return(SDKWrap.GetLastErrorMsg());
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
예제 #4
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <returns></returns>
        public override KeyValuePair <bool, string> Login()
        {
            if (this.IsLogin)
            {
                this.Logout();
            }
            try
            {
                //Sdk 初始化
                if (!this.sdkInit)
                {
                    if (!SDKWrap.NET_DVR_Init())
                    {
                        return(new KeyValuePair <bool, string>(false, string.Format("初始化SDK失败,错误消息:{0}", this.GetLastError())));
                    }
                    else
                    {
                        this.sdkInit = true;
                    }
                }

                var deviceInfo = new SDKTypes.NET_DVR_DEVICEINFO_V30();

                //执行SDK登录
                int ret = SDKWrap.NET_DVR_Login_V30(this.IP, this.Port, this.UserName, this.Password, ref deviceInfo);

                if (ret < 0)
                {
                    return(new KeyValuePair <bool, string>(false, string.Format("登录失败,错误消息:{0}", this.GetLastError())));
                }
                else
                {
                    this.userId     = ret;
                    this.DeviceInfo = deviceInfo;
                    return(new KeyValuePair <bool, string>(true, "登录成功!"));
                }
            }
            catch (Exception ex)
            {
                return(new KeyValuePair <bool, string>(false, string.Format("登录失败,异常消息:{0}", ex.Message)));
            }
        }
예제 #5
0
 /// <summary>
 /// 停止实时预览
 /// </summary>
 /// <returns></returns>
 public override KeyValuePair <bool, string> StopRealPlay()
 {
     if (!this.IsRealPlay)
     {
         return(new KeyValuePair <bool, string>(true, "未启动实时预览!"));
     }
     try
     {
         var ret = SDKWrap.StopRealPlay(this.realPlayHandle);
         if (ret.Key)
         {
             this.realPlayHandle = IntPtr.Zero;
         }
         return(ret);
     }
     catch (Exception e)
     {
         return(new KeyValuePair <bool, string>(false, e.Message));
     }
 }
예제 #6
0
        /// <summary>
        /// 启动实时预览
        /// </summary>
        /// <returns></returns>
        public override KeyValuePair <bool, string> StartRealPlay()
        {
            if (!this.IsLogin)
            {
                return(new KeyValuePair <bool, string>(false, "未登录!"));
            }
            if (this.IsRealPlay)
            {
                this.StopRealPlay();
            }
            try
            {
                SDKTypes.NET_DVR_PREVIEWINFO previewInfo = this.PreviewInfo;

                previewInfo.hPlayWnd = this.RealPlayWnd;

                return(SDKWrap.RealPlay_V40(this.userId, ref previewInfo, ref this.realPlayHandle, IntPtr.Zero));
            }
            catch (Exception e)
            {
                return(new KeyValuePair <bool, string>(false, e.Message));
            }
        }