/// <summary> /// 雄迈SDK初始化 /// </summary> /// <returns></returns> public static Enum_SDKState XMSDK_Init() { disCallback = new SDK_XMSDK.fDisConnect(DisConnectBackCallFunc); XMSDKState = SDK_XMSDK.H264_DVR_Init(disCallback, IntPtr.Zero) == 1 ? Enum_SDKState.SDK_Init : Enum_SDKState.SDK_InitFail; SDK_XMSDK.H264_DVR_SetConnectTime(2000, 3); return(XMSDKState); }
public void H264_DVR_PTZControlTest() { int iLogin = -1; int intResult = 0; bool bolResult = false; SDKState.XMSDK_Init(); H264_DVR_DEVICEINFO OutDev; int nError = 0; iLogin = SDK_XMSDK.H264_DVR_Login_Cloud("4bba3f71cdd143cb", 34567, "admin", "123456", out OutDev, out nError, ""); H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO(); playstru.nChannel = 0; //playstru.nChannel = 0; playstru.nStream = 0; playstru.nMode = 1; playstru.hWnd = IntPtr.Zero; int m_iPlayhandle = SDK_XMSDK.H264_DVR_RealPlay(Convert.ToInt32(iLogin), ref playstru); bolResult = SDK_XMSDK.H264_DVR_PTZControl(iLogin, 0, Convert.ToInt32(SDK_XMSDK.PTZ_ControlType.PAN_LEFTTOP), false, 10); //bolResult = SDK_XMSDK.H264_DVR_PTZControl(1, 0,1, false, 4); //(long lLoginID, int nChannelNo, long lPTZCommand, bool bStop DEF_PARAM(0), long lSpeed DEF_PARAM(4)); Thread.Sleep(1000); SDK_XMSDK.H264_DVR_PTZControl(iLogin, 0, Convert.ToInt32(SDK_XMSDK.PTZ_ControlType.PAN_RIGTHDOWN), true, 0); //SDK_XMSDK.H264_DVR_PTZControl(iLogin, 1, Convert.ToInt64(SDK_XMSDK.PTZ_ControlType.TILT_DOWN), false, 100); //bool bolResult = SDK_XMSDK.H264_DVR_PTZControl(Convert.ToInt32(lLogin), CurrentCameraInfo.Channel, Convert.ToInt32(XMVideoPtzType), !bolStart, CurrentVideoPlaySet.PTZSpeed); SDK_XMSDK.H264_DVR_Logout(Convert.ToInt32(intResult)); SDKState.XMSDK_Release(); Assert.IsTrue(bolResult); }
/// <summary> /// 雄迈视频录像 /// </summary> public bool XMVideo_VideoRecordStart(string strRecFilePath) { StringBuilder sbRecFilePath = new StringBuilder(); if (string.IsNullOrEmpty(strRecFilePath)) { //不存在路径 使用默认路径 strRecFilePath = ProgConstants.strXMVideo_RecDicPath + "\\" + CurrentVideoInfo.DVSAddress; //默认路径 if (!Directory.Exists(strRecFilePath)) { //文件夹不存在,创建文件夹 Directory.CreateDirectory(strRecFilePath); } } if (!strRecFilePath.EndsWith(".h264")) { //后缀错误,使用默认文件生成 //默认路径格式 [当前工作路径/XMVideoRecFile/DVSAddress/时间(yyyyMMddHHmmss)_通道号(01)] strRecFilePath += "\\" + VideoRecord.VideoRecordInfoConvert.GetVideoRecordName(CurrentVideoInfo.DVSNumber, CurrentCameraInfo.Channel - 1, CurrentVideoInfo.VideoType); } bool bolResult = SDK_XMSDK.H264_DVR_StartLocalRecord(m_iPlayhandle, strRecFilePath, Convert.ToInt32(MEDIA_FILE_TYPE.MEDIA_FILE_NONE)); VideoRecordStatus = true; return(bolResult); }
int m_nSlowTypeLocal = 0; // 本地慢播速度 #endregion private bool XMVideo_PlayVideoRecord() { SDK_XMSDK.H264_DVR_StartLocalPlay(CurrentVideoRecordInfo.RecordPath, picPlaybackMain.Handle, null, Convert.ToUInt32(0)); SDK_XMSDK.fLocalPlayFileCallBack fileEndCallBack = new SDK_XMSDK.fLocalPlayFileCallBack(FileEndCallBack); SDK_XMSDK.H264_DVR_SetFileEndCallBack(m_nLocalplayHandle, fileEndCallBack, this.Handle); return(true); }
/// <summary> /// 文件播放完毕回调 /// </summary> /// <param name="lPlayHand"></param> /// <param name="nUser"></param> void FileEndCallBack(uint lPlayHand, uint nUser) { if (SDK_XMSDK.H264_DVR_StopLocalPlay(m_nLocalplayHandle)) { m_nLocalplayHandle = 0; } //timerLocalPlayBack.Enabled = false; //trackBarLocalPlayPos.Value = 0; }
/// <summary> /// 雄迈SDK 释放 /// </summary> /// <returns></returns> public static Enum_SDKState XMSDK_Release() { XMSDKState = SDK_XMSDK.H264_DVR_Cleanup() ? Enum_SDKState.SDK_Release : Enum_SDKState.SDK_ReleaseFail; foreach (VideoInfo v in SDK_XMSDK.dicXMVideoList.Values) { v.LoginHandle = -1; v.LoginState = 0; } return(XMSDKState); }
public void H264_DVR_LoginTest() { SDKState.XMSDK_Init(); H264_DVR_DEVICEINFO OutDev; int nError = 0; int intResult = SDK_XMSDK.H264_DVR_Login("192.168.2.165", 34567, "admin", "", out OutDev, out nError, SocketStyle.TCPSOCKET); SDK_XMSDK.H264_DVR_Logout(Convert.ToInt32(intResult)); SDKState.XMSDK_Release(); Assert.AreEqual(intResult, 1); }
public void H264_DVR_Login_CloudTest() { SDKState.XMSDK_Init(); H264_DVR_DEVICEINFO OutDev; int nError = 0; int intResult = SDK_XMSDK.H264_DVR_Login_Cloud("93c4de073e976f89", 34567, "admin", "", out OutDev, out nError, ""); SDK_XMSDK.H264_DVR_Logout(Convert.ToInt32(intResult)); SDKState.XMSDK_Release(); Assert.AreEqual(intResult, 1); }
public bool VideoPTZControl(Enum_VideoPTZControl PTZControl, bool bolStart) { bool bolResult = false; SDK_XMSDK.PTZ_ControlType XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.EXTPTZ_TOTAL; //云台控制类型改变 switch (PTZControl) //云视通仅 上下 { case Enum_VideoPTZControl.PTZControl_Up: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.TILT_UP; break; case Enum_VideoPTZControl.PTZControl_Down: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.TILT_DOWN; break; case Enum_VideoPTZControl.PTZControl_Left: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.PAN_LEFT; break; case Enum_VideoPTZControl.PTZControl_Right: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.PAN_RIGHT; break; case Enum_VideoPTZControl.PTZControl_LeftUp: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.PAN_LEFTTOP; break; case Enum_VideoPTZControl.PTZControl_LeftDown: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.PAN_LEFTDOWN; break; case Enum_VideoPTZControl.PTZControl_RightUp: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.PAN_RIGTHTOP; break; case Enum_VideoPTZControl.PTZControl_RightDown: XMVideoPtzType = SDK_XMSDK.PTZ_ControlType.PAN_RIGTHDOWN; break; } if (XMVideoPtzType != SDK_XMSDK.PTZ_ControlType.EXTPTZ_TOTAL) { bool bolTemp = !bolStart; if (lLogin > 0) { bolResult = SDK_XMSDK.H264_DVR_PTZControl(lLogin, CurrentCameraInfo.Channel - 1, Convert.ToInt32(XMVideoPtzType), bolTemp, CurrentVideoPlaySet.PTZSpeed); } } return(bolResult); }
private static void DisConnectBackCallFunc(int lLoginID, string pchDVRIP, int nDVRPort, IntPtr dwUser) { int Temp_intResult = -1; foreach (VideoInfo v in SDK_XMSDK.dicXMVideoList.Values) { if (v.LoginHandle == lLoginID) { //释放登陆信息句柄 Temp_intResult = SDK_XMSDK.H264_DVR_Logout(v.LoginHandle); v.LoginHandle = -1; v.LoginState = 0; } } }
public bool VideoClose() { bool bolResule = false; int intResult = -1; bool bolResult = false; bolRequestRealVideoFlag = false; Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "CloseStart"); bolResult = SDK_XMSDK.H264_DVR_StopLocalPlay(m_iPlayhandle); //停止录像 VideoRecordStatus = false; intResult = SDK_XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)intptrPlayMain); //SDK关闭事件 currentVideoInfo.VideoLoginStateChangeEvent -= VideoLoginStateChanged; //程序取消事件注册 VideoPlayState = Enum_VideoPlayState.NotInPlayState; Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "CloseEnd"); return(bolResule); }
public void H264_DVR_Check_Device_Exist_V2Test() { int iLogin = -1; int intResult = 0; bool bolResult = false; SDKState.XMSDK_Init(); H264_DVR_DEVICEINFO OutDev; int nError = 0; VideoInfo v = TestDataSource.TestDataSource.XMDataSource2(); SDK_XMSDK.SDK_SDevicesState state = new SDK_XMSDK.SDK_SDevicesState(); state.nun = 2; state.state = new int[32]; state.state[0] = 1; state.state[1] = 1; state.uuid = new SDK_XMSDK.SDK_UUID[32]; state.uuid[0].uuid = v.DVSAddress; state.uuid[1].uuid = "4bba3f71cdd143cb"; IntPtr iUserData = Marshal.StringToHGlobalAnsi("hongdongcheng"); SDK_XMSDK.OnFoundDevCB callBack = new SDK_XMSDK.OnFoundDevCB(OnFoundDevCB); Ezviz_gchMsgBack = GCHandle.Alloc(callBack); IntPtr iData = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDK_XMSDK.SDK_SDevicesState))); Marshal.StructureToPtr(state, iData, true); int intResut = SDK_XMSDK.H264_DVR_Check_Device_Exist_V2(ref iData, 3, callBack, iUserData); var result = Marshal.PtrToStructure(iData, typeof(SDK_XMSDK.SDK_SDevicesState)); SDK_XMSDK.SDK_SDevicesState A = (SDK_XMSDK.SDK_SDevicesState)result; int error = SDK_XMSDK.H264_DVR_GetLastError(); iLogin = SDK_XMSDK.H264_DVR_Login_Cloud(v.DVSAddress, 34567, v.UserName, v.Password, out OutDev, out nError, ""); //H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO(); //playstru.nChannel = 0; //playstru.nStream = 0; //playstru.nMode = 1; //playstru.hWnd = IntPtr.Zero; //int m_iPlayhandle = SDK_XMSDK.H264_DVR_RealPlay(Convert.ToInt32(iLogin), ref playstru); bolResult = SDK_XMSDK.H264_DVR_PTZControlEx(iLogin, 0, Convert.ToInt32(SDK_XMSDK.PTZ_ControlType.EXTPTZ_POINT_MOVE_CONTROL), 1, 0, 0, false); SDK_XMSDK.H264_DVR_Logout(Convert.ToInt32(intResult)); SDKState.XMSDK_Release(); Assert.IsTrue(bolResult); }
public void H264_DVR_PTZControlExTest() { int iLogin = -1; int intResult = 0; bool bolResult = false; SDKState.XMSDK_Init(); H264_DVR_DEVICEINFO OutDev; int nError = 0; iLogin = SDK_XMSDK.H264_DVR_Login_Cloud("4bba3f71cdd143cb", 34567, "admin", "123456", out OutDev, out nError, ""); //H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO(); //playstru.nChannel = 0; //playstru.nStream = 0; //playstru.nMode = 1; //playstru.hWnd = IntPtr.Zero; //int m_iPlayhandle = SDK_XMSDK.H264_DVR_RealPlay(Convert.ToInt32(iLogin), ref playstru); bolResult = SDK_XMSDK.H264_DVR_PTZControlEx(iLogin, 0, Convert.ToInt32(SDK_XMSDK.PTZ_ControlType.EXTPTZ_POINT_MOVE_CONTROL), 1, 0, 0, false); SDK_XMSDK.H264_DVR_Logout(Convert.ToInt32(intResult)); SDKState.XMSDK_Release(); Assert.IsTrue(bolResult); }
public bool VideoPlayEx() { bool bolResule = false; currentVideoInfo.VideoLoginStateChangeEvent += VideoLoginStateChanged; //注册事件 VideoPlayState = Enum_VideoPlayState.Connecting; //状态置为连接中 VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.LoginStart }); //开始登陆 //如果当前未登录,通过登陆状态改变回调触发实时播放 //如果已经登陆,直接获取登陆句柄进行实时预览 string Temp_strKey = GetDevListKey(CurrentVideoInfo); if (SDK_XMSDK.DeviceLogin(Temp_strKey)) { lLogin = CurrentVideoInfo.LoginHandle; Thread t = new Thread(new ThreadStart(VideoRealPlay)); t.IsBackground = true; t.Start(); } return(bolResule); }
private void VideoRealPlay() { H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO(); playstru.nChannel = CurrentCameraInfo.Channel - 1; playstru.nStream = 1; playstru.nMode = 0; playstru.hWnd = intptrPlayMain; bolRequestRealVideoFlag = true; int Temp_intCount = 0; while (bolRequestRealVideoFlag) { VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.RequestConn }); m_iPlayhandle = SDK_XMSDK.H264_DVR_RealPlay(Convert.ToInt32(lLogin), ref playstru); if (m_iPlayhandle > 0) { CurrentVideoInfo.NetworkState = 1;//在线 VideoPlayState = Enum_VideoPlayState.InPlayState; VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.VideoPlay }); //开始播放 bolRequestRealVideoFlag = false; if (CurrentVideoPlaySet.VideoRecordEnable) { XMVideo_VideoRecordStart(CurrentVideoPlaySet.VideoRecordFilePath); } } else { VideoPlayState = Enum_VideoPlayState.NotInPlayState; int intResult = SDK_XMSDK.H264_DVR_GetLastError(); //视频播放异常,后期根据 H264_DVR_GetLastError 获取错误码进行操作及 提示 switch (intResult) { case (int)SDK_RET_CODE.H264_DVR_NATCONNET_REACHED_MAX: VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.ConnNumMax }); //达到最大连接数量 break; case (int)SDK_RET_CODE.H264_DVR_INVALID_HANDLE: //句柄错误 VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.VideoPlayException, EventContent = intResult.ToString() + "句柄错误" }); //视频播放异常 //退出,重新登陆 //注意: 有可能是后台登陆成功后触发这个错误 重新调用登陆接口打开新线程进行登陆 //将重连播放的标签置为Flase 结束前一个登陆线程 int Temp_intResult = SDK_XMSDK.H264_DVR_Logout(lLogin); CurrentVideoInfo.LoginHandle = -1; CurrentVideoInfo.LoginState = 0; SDK_XMSDK.DeviceLogin(CurrentVideoInfo); bolRequestRealVideoFlag = false; break; default: VideoPlayCallback(new VideoPlayCallbackValue { evType = Enum_VideoPlayEventType.VideoPlayException, EventContent = intResult.ToString() }); //视频播放异常 break; } Thread.Sleep(2000); } if (Temp_intCount > c_intMaxRealPlayNum || m_iPlayhandle > 0) { bolRequestRealVideoFlag = false; } Temp_intCount++; } }
private bool XMVideo_SetVideoRecordPos(float fltPoValue) { SDK_XMSDK.H264_DVR_SetPlayPos(m_nLocalplayHandle, fltPoValue); return(true); }
private bool XMVideo_PauseVideoRecord() { SDK_XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_PAUSE, 0); return(true); }
private bool XMVideo_StopVideoRecord() { SDK_XMSDK.H264_DVR_StopLocalPlay(m_nLocalplayHandle); return(true); }