Beispiel #1
0
        //获取accesstoken
        public static string GetAccessToken()
        {
            IntPtr iMessage;
            int    iLength;
            string jsonStr = BuildParams("token");
            int    ret     = HkSDK.OpenSDK_HttpSendWithWait(ApiUrl, jsonStr, "", out iMessage, out iLength);

            string returnstr = Marshal.PtrToStringAnsi(iMessage, iLength);

            if (0 == ret)
            {
                JObject result = (JObject)JsonConvert.DeserializeObject(returnstr);
                if (result["result"]["code"].ToString() == "200")
                {
                    AccessToken = result["result"]["data"]["accessToken"].ToString();

                    Debug.WriteLine(AccessToken);
                }
                else
                {
                    Debug.WriteLine(result["result"]["code"].ToString());
                }
            }
            return(AccessToken);
        }
Beispiel #2
0
        /*
         * public static bool Login()
         * {
         *  return (HkSDK.OpenSDK_Mid_Login(ref AccessToken, ref TokenLth) == 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);
        }
Beispiel #3
0
 //截图
 public static bool CapturePicture(string fileName)
 {
     if (!String.IsNullOrWhiteSpace(fileName))
     {
         return(HkSDK.OpenSDK_CapturePicture(SessionId, fileName) == 0 ? true : false);
     }
     return(false);
 }
Beispiel #4
0
 //停止播放(预览)重载无参
 public static bool Stop1()
 {
     closeAllocion1();//每次播放结束会话
     if (HkSDK.OpenSDK_StopRealPlay(SessionId, 0) == 0)
     {
         return(HkSDK.OpenSDK_StopRealPlay(SessionId, 0) == 0);
     }
     else
     {
         return(false);
     }
 }
Beispiel #5
0
        //申请设备列表
        public static string playList()
        {
            IntPtr iMessage;
            int    iLength;

            int    aaa       = HkSDK.OpenSDK_Data_GetDevList(AccessToken, 0, 50, out iMessage, out iLength);
            string returnstr = Marshal.PtrToStringAnsi(iMessage);

            if (aaa == 0)
            {
                JObject result = (JObject)JsonConvert.DeserializeObject(returnstr);
            }
            //Marshal.FreeHGlobal(iMessage);
            return(returnstr);
        }
Beispiel #6
0
 //反初始化库
 public static bool Close()
 {
     return(HkSDK.OpenSDK_FiniLib() == 0);
 }
Beispiel #7
0
 //初始化库
 public static bool Start()
 {
     return(HkSDK.OpenSDK_InitLib(AuthAddr, PlatformAddr, AppKey) == 0);
 }
Beispiel #8
0
 //停止播放(预览)
 public static bool Stop(IntPtr SessionId)
 {
     closeAllocion(SessionId);//每次播放结束会话
     return(HkSDK.OpenSDK_StopRealPlay(SessionId, 0) == 0);
 }
Beispiel #9
0
 //播放视频(预览)
 public static bool Play(IntPtr PlayWnd, string CameraId, IntPtr SessionId)
 {
     return(HkSDK.OpenSDK_StartRealPlay(SessionId, PlayWnd, CameraId, AccessToken, level, _SafeKey, AppKey, 0) == 0);
 }
Beispiel #10
0
        //结束会话重载无参
        public static bool closeAllocion1()
        {
            string sid1 = SessionId.ToString();

            return(HkSDK.OpenSDK_FreeSession(sid1) == 0);
        }
Beispiel #11
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);
        }
Beispiel #12
0
        //第三方登录
        public static bool Login()
        {
            int num = HkSDK.OpenSDK_Mid_Login(ref AccessToken, ref TokenLth);

            return(HkSDK.OpenSDK_Mid_Login(ref AccessToken, ref TokenLth) == 0);
        }