Example #1
0
        public static int InitLib()
        {
            var result = HkSdk.OpenSDK_InitLib(AuthAddr, PlatformAddr, AppKey);

            if (result != 0)
            {
                return(result);
            }

            result = AllocSession();
            if (result != 0)
            {
                return(result);
            }

            result = GetAccessToken();
            if (result != 0)
            {
                return(result);
            }

            result = FatchCameraList();
            if (result != 0)
            {
                return(result);
            }

            return(result);
        }
Example #2
0
        private static int GetAccessToken()
        {
            var jsonStr = BuildParams("token");

            var result = HkSdk.OpenSDK_HttpSendWithWait(ApiUrl, jsonStr, "", out var iMessage, out var iLength);

            var returnStr = Marshal.PtrToStringAnsi(iMessage, iLength);

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

                    Debug.WriteLine(AccessToken);
                }
                else
                {
                    Debug.WriteLine(jObject["result"]["code"].ToString());
                }
            }

            return(result);
        }
Example #3
0
        public static bool CapturePicture(string fileName)
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                return(HkSdk.OpenSDK_CapturePicture(_sessionId, fileName) == 0);
            }

            return(false);
        }
Example #4
0
        private static int AllocSession()
        {
            var userId = Marshal.StringToHGlobalAnsi(UserId);

            var result = HkSdk.OpenSDK_AllocSession(CallBack, userId, ref _sessionId, ref _sessionIdLength, false, uint.MaxValue);

            SessionIdstr = Marshal.PtrToStringAnsi(_sessionId, _sessionIdLength);

            return(result);
        }
Example #5
0
        private static int FatchCameraList()
        {
            var page = 0;
            int result;
            int readCount;
            var finalArray = new JArray();

            do
            {
                result = HkSdk.OpenSDK_Data_GetDevList(AccessToken, page, 256, out var iMessage, out int _);
                var resultStr = Marshal.PtrToStringAnsi(iMessage);

                if (result != 0)
                {
                    return(result);
                }

                var jsonObj = JObject.Parse(resultStr);

                var cameraList = JArray.Parse(jsonObj["cameraList"].ToString());
                readCount = cameraList.Count;
                foreach (var cam in cameraList)
                {
                    finalArray.Add(cam);
                }
                page++;
            } while (readCount > 0);


            foreach (var cam in finalArray)
            {
                var cameraObj = JObject.Parse(cam.ToString());
                CameraList.Add(cameraObj["cameraName"].ToString());
                CameraIdList.Add(cameraObj["cameraId"].ToString());
            }

            return(result);
        }
Example #6
0
 public static string GetLastErrorDesc()
 => HkSdk.OpenSDK_GetLastErrorDesc();
Example #7
0
 public static int GetLastErrorCode()
 => HkSdk.OpenSDK_GetLastErrorCode();
Example #8
0
 /// <summary>
 /// 云台控制
 /// </summary>
 /// <param name="cameraId"></param>
 /// <param name="command"></param>
 /// <param name="action"></param>
 /// <param name="speed"></param>
 /// <returns></returns>
 public static int PtzCtrl(string cameraId, PTZCommand command,
                           PTZACtion action, int speed)
 => HkSdk.OpenSDK_PTZCtrl(_sessionId, AccessToken, cameraId, command, action, speed, 0);
Example #9
0
 public static int StopPlay()
 {
     CloseAllocion(_sessionId);
     return(HkSdk.OpenSDK_StopRealPlay(_sessionId, 0));
 }
Example #10
0
 public static int StartSearch(string cameraId, string startTime, string endTime)
 => HkSdk.OpenSDK_StartSearch(_sessionId, cameraId, AccessToken, startTime, endTime, 0);
Example #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cameraId"></param>
 /// <param name="channelNumber"></param>
 /// <param name="startTime"></param>
 /// <param name="endTime"></param>
 /// <returns></returns>
 public static int StartSearchEx(string cameraId, int channelNumber, string startTime,
                                 string endTime)
 => HkSdk.OpenSDK_StartSearchEx(_sessionId, cameraId, channelNumber, startTime, endTime);
Example #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="handleIntPtr"></param>
 /// <param name="cameraId"></param>
 /// <param name="channelNumber"></param>
 /// <param name="safeKey"></param>
 /// <param name="startTime"></param>
 /// <param name="endTime"></param>
 /// <returns></returns>
 public static int StartPlayBackEx(IntPtr handleIntPtr, string cameraId, int channelNumber, string safeKey, string startTime,
                                   string endTime)
 => HkSdk.OpenSDK_StartPlayBackEx(_sessionId, handleIntPtr, cameraId, channelNumber, safeKey, startTime, endTime);
Example #13
0
 public static int StopPlayBack()
 => HkSdk.OpenSDK_StopPlayBack(_sessionId, 0);
Example #14
0
 public static int StartPlayBack(IntPtr handleIntPtr, string cameraId, string safeKey, string startTime,
                                 string endTime)
 => HkSdk.OpenSDK_StartPlayBack(_sessionId, handleIntPtr, cameraId, AccessToken, safeKey, startTime, endTime, AppKey, 0);
Example #15
0
 public static int StartPlay(IntPtr handleIntPtr, string cameraId, string safeKey)
 => HkSdk.OpenSDK_StartRealPlay(_sessionId, handleIntPtr, cameraId, AccessToken, _playLever, safeKey, AppKey, 0);
Example #16
0
        private static int CloseAllocion(IntPtr sid)
        {
            var sid1 = sid.ToString();

            return(HkSdk.OpenSDK_FreeSession(sid1));
        }