Пример #1
0
 //截图
 public static bool CapturePicture(string fileName)
 {
     if (!String.IsNullOrWhiteSpace(fileName))
     {
         return(HkSDK.OpenSDK_CapturePicture(SessionId, fileName) == 0 ? true : false);
     }
     return(false);
 }
Пример #2
0
        //申请会话
        public static IntPtr AllocSession()
        {
            IntPtr userID = Marshal.StringToHGlobalAnsi(userId);
            bool   flag   = HkSDK.OpenSDK_AllocSession(callBack, userID, ref SessionId, ref SessionIdLth, false, uint.MaxValue) == 0;

            SessionIdstr = Marshal.PtrToStringAnsi(SessionId, SessionIdLth);
            return(SessionId);
        }
Пример #3
0
 //停止播放(预览)重载无参
 public static bool StopAll()
 {
     closeAllocionAll();//每次播放结束会话
     if (HkSDK.OpenSDK_StopRealPlay(SessionId, 0) == 0)
     {
         return(HkSDK.OpenSDK_StopRealPlay(SessionId, 0) == 0);
     }
     else
     {
         return(false);
     }
 }
Пример #4
0
        //申请告警列表
        public static string AlarmList(string CameraId, string StartTime, string EndTime)
        {
            IntPtr iMessage;
            int    iLength;
            int    iResult   = HkSDK.OpenSDK_Data_GetAlarmList(AccessToken, CameraId, StartTime, EndTime, -1, 2, 0, 50, out iMessage, out iLength);
            string strResult = Marshal.PtrToStringAnsi(iMessage);

            if (iResult == 0)
            {
                JObject result = (JObject)JsonConvert.DeserializeObject(strResult);
            }
            //Marshal.FreeHGlobal(iMessage);
            return(strResult);
        }
Пример #5
0
        //申请设备列表
        public static string playList()
        {
            IntPtr iMessage;
            int    iLength;
            string strResult = string.Empty;

            int iResult = HkSDK.OpenSDK_Data_GetDevList(AccessToken, 0, 50, out iMessage, out iLength);

            if (iResult == 0)
            {
                strResult = Marshal.PtrToStringAnsi(iMessage);
                JObject jsonResult = (JObject)JsonConvert.DeserializeObject(strResult);
            }
            //Marshal.FreeHGlobal(iMessage);
            return(strResult);
        }
Пример #6
0
        //获取accesstoken
        public static string GetAccessToken()
        {
            IntPtr iMessage;
            int    iLength;

            string jsonStr   = BuildParams("token");
            int    iResult   = HkSDK.OpenSDK_HttpSendWithWait(ApiUrl, jsonStr, "", out iMessage, out iLength);
            string strResult = Marshal.PtrToStringAnsi(iMessage, iLength);

            if (iResult == 0)
            {
                JObject jsonResult = (JObject)JsonConvert.DeserializeObject(strResult);
                if (jsonResult["result"]["code"].ToString() == "200")
                {
                    AccessToken = jsonResult["result"]["data"]["accessToken"].ToString();
                    Debug.WriteLine(AccessToken);
                }
                else
                {
                    Debug.WriteLine(jsonResult["result"]["code"].ToString());
                }
            }
            return(AccessToken);
        }
Пример #7
0
 //反初始化库
 public static bool Close()
 {
     return(HkSDK.OpenSDK_FiniLib() == 0);
 }
Пример #8
0
 //初始化库
 public static bool Start()
 {
     return(HkSDK.OpenSDK_InitLib(AuthAddr, PlatformAddr, AppKey) == 0);
 }
Пример #9
0
        public static void on_insPtzStop(IntPtr SessionId, string CameraId, HkSDK.PTZCommand emDirect)
        {
            if (SessionId == null)
            {
                MessageBox.Show("请先开启预览才能进行云台控制!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            int iRet = 0;

            HkSDK.NSCBMsg cbMsg;
            cbMsg.iErrorCode   = 0;
            cbMsg.pMessageInfo = "";
            IntPtr pMsg = Marshal.AllocHGlobal(Marshal.SizeOf(cbMsg));

            try
            {
                Marshal.StructureToPtr(cbMsg, pMsg, false);
                switch (emDirect)
                {
                case HkSDK.PTZCommand.UP:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.UP, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.DOWN:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.DOWN, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.LEFT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.LEFT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.RIGHT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.RIGHT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.UPLEFT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.UPLEFT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.DOWNLEFT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.DOWNLEFT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.UPRIGHT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.UPRIGHT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.DOWNRIGHT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.DOWNRIGHT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.ZOOMIN:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.ZOOMIN, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.ZOOMOUT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.ZOOMOUT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.FOCUSNEAR:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.FOCUSNEAR, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.FOCUSFAR:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.FOCUSFAR, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.IRISSTARTUP:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.IRISSTARTUP, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.IRISSTOPDOWN:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.IRISSTOPDOWN, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.LIGHT:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.LIGHT, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.WIPER:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.WIPER, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                case HkSDK.PTZCommand.AUTO:
                    iRet = HkSDK.OpenSDK_PTZCtrl(SessionId, AccessToken, CameraId, HkSDK.PTZCommand.AUTO, HkSDK.PTZAction.STOP, ptz_speed, pMsg);
                    break;

                default:
                    break;
                }
            }
            finally
            {
                Marshal.FreeHGlobal(pMsg);
            }

            if (iRet != 0)
            {
                MessageBox.Show("PTZ控制失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Пример #10
0
 //停止播放(预览)
 public static bool Stop(IntPtr SessionId)
 {
     closeAllocion(SessionId);//每次播放结束会话
     return(HkSDK.OpenSDK_StopRealPlay(SessionId, 0) == 0);
 }
Пример #11
0
 //播放视频(预览)
 public static bool Play(IntPtr PlayWnd, string CameraId, IntPtr SessionId)
 {
     //MessageBox.Show("AAAAA:\r\n" + SessionId.ToString() + "\r\n" + PlayWnd.ToString() + "\r\n" + CameraId + "\r\n" + AccessToken + "\r\n" + level + "\r\n" + _SafeKey + "\r\n" + AppKey, "提示", MessageBoxButton.OK, MessageBoxImage.Information);
     return(HkSDK.OpenSDK_StartRealPlay(SessionId, PlayWnd, CameraId, AccessToken, level, _SafeKey, AppKey, 0) == 0);
 }
Пример #12
0
        //结束会话重载无参
        public static bool closeAllocionAll()
        {
            string sid1 = SessionId.ToString();

            return(HkSDK.OpenSDK_FreeSession(sid1) == 0);
        }
Пример #13
0
        /*
         * public static bool allocion()
         * {
         *  HkSDK.MsgHandler Handler = new HkSDK.MsgHandler(HkSDK.HandlerWork);
         *  IntPtr UserID =Marshal.StringToHGlobalAnsi(userId);
         *  bool result = (HkSDK.OpenSDK_AllocSession(Handler, UserID, ref SessionId, ref SessionIdLth, false, 0xEA60) == 0);
         *  SessionIdstr = Marshal.PtrToStringAnsi(SessionId, SessionIdLth);
         *  return SessionIdstr;
         * }*/

        //结束会话
        public static bool closeAllocion(IntPtr sid)
        {
            string sid1 = sid.ToString();

            return(HkSDK.OpenSDK_FreeSession(sid1) == 0);
        }
Пример #14
0
 //第三方登录
 public static bool Login()
 {
     return(HkSDK.OpenSDK_Mid_Login(ref AccessToken, ref TokenLth) == 0);
 }