private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 1000; i++) { Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int intResult = SDK_EzvizSDK.GetDevOnlineState("75621791412", 1); Console.WriteLine(intResult); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Thread.Sleep(30); } }
public void GetDevOnlineStateTest() { TestInit(); for (int i = 0; i < 100; i++) { Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int intResult = SDK_EzvizSDK.GetDevOnlineState("756217914", 1); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Thread.Sleep(300); } SDK_EzvizSDK.OpenSDK_FiniLib(); Assert.AreEqual(1, 1); }
public void OpenSDK_StartRealPlayExTest() { VideoPlayControl.ProgParameter.strEzviz__AppID = "5b97c1d157474f96b8d4c75b936a0057"; VideoPlayControl.ProgParameter.strEzviz_AppSecret = "4318d0cc4c43ca156052ba688bc9006a"; int intResult = 0; intResult = SDK_EzvizSDK.OpenSDK_InitLib(ProgParameter.strEzviz__AuthAddr, ProgParameter.strEzviz__PlatForm, ProgParameter.strEzviz__AppID); JsonRequestResult result = SDK_EzvizSDK.GetAccessToken(); IntPtr intptrToken = Marshal.StringToHGlobalAnsi(ProgParameter.strEzviz_AccessToken); intResult = SDK_EzvizSDK.OpenSDK_SetAccessToken(intptrToken); IntPtr intptrSession = IntPtr.Zero; int intLenght = 0; PictureBox pic = new PictureBox(); SDK_EzvizSDK.MsgHandler m = new SDK_EzvizSDK.MsgHandler(MsgHandler); timStartTime = DateTime.Now; intResult = SDK_EzvizSDK.OpenSDK_AllocSessionEx(m, IntPtr.Zero, out intptrSession, out intLenght); //intResult = SDK_EzvizSDK.OpenSDK_SetVideoLevel(intptrSession, 1, 1); SDK_EzvizSDK.DataCallBack callback = new SDK_EzvizSDK.DataCallBack(DataCallBack); //IntPtr inptrUser = Marshal.StringToHGlobalAnsi("10086"); //intResult = SDK_EzvizSDK.OpenSDK_SetDataCallBack(intptrSession, callback, inptrUser); intResult = SDK_EzvizSDK.GetDevOnlineState("797085722", 1); IntPtr ii = Marshal.StringToHGlobalAnsi("797085722"); intResult = SDK_EzvizSDK.OpenSDK_StartRealPlayEx(intptrSession, IntPtr.Zero, ii, 1, "CHZUVA"); //int intErrorCode = 0; //string strErrorDesc = ""; //if (intResult == -1) //{ // //错误码 // intErrorCode = SDK_EzvizSDK.OpenSDK_GetLastErrorCode(); // IntPtr i = SDK_EzvizSDK.OpenSDK_GetLastErrorDesc(); // strErrorDesc = Marshal.PtrToStringAnsi(i); //} Delay_Millisecond(10000); intResult = SDK_EzvizSDK.OpenSDK_StopRealPlayEx(intptrSession); intResult = SDK_EzvizSDK.OpenSDK_FreeSession(intptrSession); SDK_EzvizSDK.OpenSDK_FiniLib(); Assert.AreEqual("1", intResult); }
private bool Ezviz_VideoPlay() { bool bolResult = false; int intLenght = 0; int intResult = 0; //CurrentVideoInfo.NetworkState = SDK_EzvizSDK.GetDevOnlineState(CurrentVideoInfo.DVSAddress, CurrentCameraInfo.Channel); int Temp_intResult = SDK_EzvizSDK.GetDevOnlineState(CurrentVideoInfo.DVSAddress, CurrentCameraInfo.Channel); if (Temp_intResult == -2) { //设备无权限 VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.NoDeviceAuthority }); return(bolResult); } CurrentVideoInfo.NetworkState = Temp_intResult; if (Temp_intResult == 0) { //设备离线 VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.VideoDeviceNotOnline }); return(bolResult); } //状态未明进行连接 callBack = new SDK_EzvizSDK.MsgHandler(Ezviz_MsgCallback); Ezviz_gchMsgBack = GCHandle.Alloc(callBack); strUser = CurrentVideoInfo.DVSAddress + "_" + CurrentCameraInfo.Channel; iUser = Marshal.StringToHGlobalAnsi(strUser); VideoPlayState = Enum_VideoPlayState.Connecting; intResult = SDK_EzvizSDK.OpenSDK_AllocSessionEx(callBack, iUser, out intptrSessionID, out intLenght); if (CurrentVideoPlaySet.VideoRecordEnable) { //录像启用 strRealSavePath = GetLocalSavePath(CurrentVideoPlaySet.VideoRecordFilePath, CurrentVideoPlaySet.VideoRecordFileName); if (!Directory.Exists(CurrentVideoPlaySet.VideoRecordFilePath)) { Directory.CreateDirectory(CurrentVideoPlaySet.VideoRecordFilePath); } Ezviz_DataCallBack = new SDK_EzvizSDK.DataCallBack(Ezviz_DataCallBackEvent); Ezviz_gchVideoRecord = GCHandle.Alloc(Ezviz_DataCallBack); intResult = SDK_EzvizSDK.OpenSDK_SetDataCallBack(intptrSessionID, Ezviz_DataCallBack, iUser); VideoRecordStatus = true; } IntPtr intptrdevSerial = Marshal.StringToHGlobalAnsi(CurrentVideoInfo.DVSAddress); if (CurrentVideoInfo.DVSAddress.StartsWith("C")) { intResult = SDK_EzvizSDK.OpenSDK_StartPlayWithStreamType(intptrSessionID, intptrPlayMain, intptrdevSerial, CurrentCameraInfo.Channel, CurrentVideoInfo.Password, -1); } else { intResult = SDK_EzvizSDK.OpenSDK_StartRealPlayEx(intptrSessionID, intptrPlayMain, intptrdevSerial, CurrentCameraInfo.Channel, CurrentVideoInfo.Password); } if (intResult == 0) { VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.ConnSuccess }); } else { VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.ConnFailed }); } return(bolResult); }