/// <summary> /// 卸载 SDK /// </summary> /// <returns></returns> public static bool CleanupSDK() { Status = false; try { return(ISCSDK.Video_Fini() == 0); } catch { } return(false); }
/// <summary> /// 初始化SDK /// </summary> /// <param name="ip">ISC平台地址</param> /// <param name="port">端口号 默认80</param> /// <param name="appkey">appkey</param> /// <param name="secret">secret</param> /// <returns></returns> public static bool InitSDK(string ip, int port, string appkey, string secret) { try { HttpUtillib.SetPlatformInfo(appkey, secret, ip, port, false); Status = ISCSDK.Video_Init(string.Empty) == 0; return(Status); } catch { } Status = false; return(Status); }
/// <summary> /// 开始预览 /// </summary> /// <returns></returns> public bool StartPreview(string cameraCode, IntPtr intptr) { this.CameraCode = cameraCode; try { int iStreamType = 0; //码流模式,0:主码流 1:子码流 Dictionary <string, object> paramMaps = new Dictionary <string, object>(); paramMaps.Add("cameraIndexCode", this.CameraCode); paramMaps.Add("streamType", iStreamType); paramMaps.Add("protocol", "rtsp"); paramMaps.Add("transmode", 1); paramMaps.Add("expand", "streamform=ps"); string uri = "/artemis/api/video/v1/cameras/previewURLs"; string body = JsonHelper.SerializeObject(paramMaps); byte[] resultByte = HttpUtillib.HttpPost(uri, body, 20); string resultStr = Encoding.UTF8.GetString(resultByte); Result result = JsonHelper.DeserializeJsonToObject <Result>(resultStr); if (result.Code.Equals("0")) { Dictionary <string, object> cameraPreviewResult = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(result.Data.ToString()); m_strURL = cameraPreviewResult["url"].ToString(); VIDEO_PLAY_REQ vpr = new VIDEO_PLAY_REQ(); vpr.iHardWareDecode = 0; vpr.fnStream = _pfnStreamCallback; vpr.fnMsg = _pfnMsgCallback; vpr.fnDecodedStream = _pfnDecodeDataCallback; m_lPlayHandle = ISCSDK.Video_StartPreview(m_strURL, intptr, ref vpr); return(m_lPlayHandle != -1); } } catch { } return(false); }
/// <summary> /// 停止预览 /// </summary> /// <returns></returns> public bool StopPreview() { int iRet = ISCSDK.Video_StopPreview(m_lPlayHandle); return(iRet == 0); }