/// <summary> /// 获取窗口参数 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="struWinParamCfg">输出配置参数</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallGetWinParam(ref WinCtrlInfo info, ref NET_DVR_WALLWINPARAM struWinParamCfg) { uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); //窗口相关参数 struWinParamCfg = new NET_DVR_WALLWINPARAM(); Int32 nSize = Marshal.SizeOf(struWinParamCfg); IntPtr lpOutBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(struWinParamCfg, lpOutBuffer, false); UInt32 dwReturn = 0; bool b = NET_DVR_GetDVRConfig(info.UserId, NET_DVR_WALLWINPARAM_GET, (int)dwWinNum, lpOutBuffer, (UInt32)nSize, ref dwReturn); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_WALLWINPARAM_GET failed, error code= " + iLastErr; //获取窗口相关参数失败,输出错误号 Failed to get the window parameters of device and output the error code } else { struWinParamCfg = (NET_DVR_WALLWINPARAM)Marshal.PtrToStructure(lpOutBuffer, typeof(NET_DVR_WALLWINPARAM)); } Marshal.FreeHGlobal(lpOutBuffer); return(b); }
/// <summary> /// 开始主动解码 /// </summary> /// <param name="userId">用户id</param> /// <param name="cameraInfo">摄像头信息</param> /// <param name="info">窗口操作信息</param> /// <param name="chanType">通道类型:0-普通通道,1-零通道,2-流ID,3-本地输入源</param> /// <param name="transProtocol">传输协议类型0-TCP,1-UDP</param> /// <param name="transMode">传输码流模式 0-主码流 1-子码流</param> /// <param name="isStreamSever">是否使用流媒体服务</param> /// <param name="streamIP">流媒体服务器IP地址或者域名</param> /// <param name="streamPort">流媒体服务器端口</param> /// <param name="streamProcotol">传输协议类型 0-TCP,1-UDP</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallStartDecodeByIp(int userId, CameraInfo cameraInfo, WinCtrlInfo info, int chanType = 0, int transProtocol = 0, int transMode = 0, bool isStreamSever = false, string streamIP = "", int streamPort = 0, int streamProcotol = 0) { //子窗口号(组号):1字节电视墙号 + 1字节子窗口号 + 2字节窗口号 int decoderChannel = (int)(((info.WallNo & 0xff) << 24) + ((info.SubWinNo & 0xff) << 16) + (info.WinNo & 0xff)); return((new HikDecoderOperate()).StartDecodeByIp(userId, (uint)decoderChannel, cameraInfo, chanType, transProtocol, transMode, isStreamSever, streamIP, streamPort, streamProcotol)); }
/// <summary> /// 停止主动解码 /// </summary> /// <param name="userId">用户id</param> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallStopDecode(int userId, WinCtrlInfo info) { //子窗口号(组号):1字节电视墙号 + 1字节子窗口号 + 2字节窗口号 int decoderChannel = (int)(((info.WallNo & 0xff) << 24) + ((info.SubWinNo & 0xff) << 16) + (info.WinNo & 0xff)); return((new HikDecoderOperate()).StopDecode(userId, (uint)decoderChannel)); }
/// <summary> /// 设置窗口分割 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallSetWinParam(WinCtrlInfo info) { NET_DVR_WALLWINPARAM m_struWinParamCfg = new NET_DVR_WALLWINPARAM(); uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); //窗口相关参数 Int32 nSize = Marshal.SizeOf(m_struWinParamCfg); m_struWinParamCfg.dwSize = (uint)nSize; m_struWinParamCfg.byWinMode = byte.Parse(info.SplitNum.ToString()); IntPtr lpInBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(m_struWinParamCfg, lpInBuffer, false); bool b = NET_DVR_SetDVRConfig(info.UserId, NET_DVR_WALLWINPARAM_SET, (int)dwWinNum, lpInBuffer, (UInt32)nSize); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_WALLWINPARAM_SET failed, error code= " + iLastErr; //设置窗口相关参数失败,输出错误号 Failed to set the window parameters of device and output the error code } Marshal.FreeHGlobal(lpInBuffer); return(b); }
/// <summary> /// 设置输出口位置 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool SetWallDisplayPosition(WinCtrlInfo info) { NET_DVR_VIDEOWALLDISPLAYPOSITION m_struWallPositionCfg = new NET_DVR_VIDEOWALLDISPLAYPOSITION(); uint m_dwDeviceNo = (info.DeviceNo & 0xff) << 24; uint m_dwRes = (0 & 0xff) << 16; uint m_dwOutputNo = info.OutNo & 0xff; //显示输出号(组合):1字节设备号+1字节保留+2字节显示输出号 uint m_dwOutputChan = m_dwDeviceNo + m_dwRes + m_dwOutputNo; IntPtr lpInBuffer = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(m_dwOutputChan, lpInBuffer, false); UInt32 dwStatusList = 0; IntPtr lpStatusList = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwStatusList, lpStatusList, false); //显示输出口参数 m_struWallPositionCfg.byEnable = info.IsEnable; m_struWallPositionCfg.dwVideoWallNo = 1 << 24; //1字节墙号+ 1字节(保留或子窗口)+ 2字节(窗口号),目前设备只支持一个电视墙 m_struWallPositionCfg.dwDisplayNo = m_dwOutputChan; m_struWallPositionCfg.struRectCfg.dwXCoordinate = (ushort)(info.IndexX * winBaseX); m_struWallPositionCfg.struRectCfg.dwYCoordinate = (ushort)(info.IndexY * winBaseY); Int32 dwInParamBufferSize = Marshal.SizeOf(m_struWallPositionCfg); IntPtr ptrWallPositionCfg = Marshal.AllocHGlobal(dwInParamBufferSize); Marshal.StructureToPtr(m_struWallPositionCfg, ptrWallPositionCfg, false); bool b = NET_DVR_SetDeviceConfig(info.UserId, NET_DVR_SET_VIDEOWALLDISPLAYPOSITION, 1, lpInBuffer, 4, lpStatusList, ptrWallPositionCfg, (UInt32)dwInParamBufferSize); Marshal.FreeHGlobal(lpInBuffer); Marshal.FreeHGlobal(lpStatusList); Marshal.FreeHGlobal(ptrWallPositionCfg); if (b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_SET_VIDEOWALLDISPLAYPOSITION failed, error code= " + iLastErr; //设置电视墙屏幕参数失败,输出错误号 Failed to set the wall parameters of device and output the error code return(false); } else { return(true); } }
/// <summary> /// 窗口操作 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="cmd">控制命令</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallWinControl(WinCtrlInfo info, WinControlCmd cmd) { uint m_dwPlatNum = info.WallNo; uint m_dwSubWinNo = info.SubWinNo; uint m_dwWinNo = info.WinNo; //子窗口号(组号):1字节电视墙号+1字节子窗口号+2字节窗口号 uint dwDispChanNum = ((m_dwPlatNum & 0xff) << 24) + ((m_dwSubWinNo & 0xff) << 16) + (m_dwWinNo & 0xff); bool b = NET_DVR_MatrixDiaplayControl(info.UserId, dwDispChanNum, (uint)cmd, m_dwSubWinNo); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_MatrixDiaplayControl failed, error code= " + iLastErr; } return(b); }
/// <summary> /// 获取开窗 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="struWinCfg">窗口信息</param> /// <param name="struWinParamCfg">窗口其他信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallGetWinCfg(ref WinCtrlInfo info, ref NET_DVR_VIDEOWALLWINDOWPOSITION struWinCfg, ref NET_DVR_WALLWINPARAM struWinParamCfg) { uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); IntPtr lpInBuffer = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpInBuffer, false); //窗口参数 struWinCfg = new NET_DVR_VIDEOWALLWINDOWPOSITION(); Int32 nSize = Marshal.SizeOf(struWinCfg); IntPtr lpOutBuffer = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(struWinCfg, lpOutBuffer, false); //状态参数 UInt32 dwStatusList = 0; IntPtr lpStatusList = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwStatusList, lpStatusList, false); bool b = false; if (!NET_DVR_GetDeviceConfig(info.UserId, NET_DVR_GET_VIDEOWALLWINDOWPOSITION, 1, lpInBuffer, 4, lpStatusList, lpOutBuffer, (UInt32)nSize)) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_WALLWIN_GET failed, error code= " + iLastErr; //获取窗口参数失败,输出错误号 Failed to set the window parameters of device and output the error code return(false); } else { struWinCfg = (NET_DVR_VIDEOWALLWINDOWPOSITION)Marshal.PtrToStructure(lpOutBuffer, typeof(NET_DVR_VIDEOWALLWINDOWPOSITION)); //窗口在电视墙上的坐标位置 b = WallGetWinParam(ref info, ref struWinParamCfg); } Marshal.FreeHGlobal(lpInBuffer); Marshal.FreeHGlobal(lpOutBuffer); Marshal.FreeHGlobal(lpStatusList); return(b); }
/// <summary> /// 获取电视墙输出位置 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="struWallPositionCfg">电视墙输出位置参数</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool GetWallDisplayPosition(ref WinCtrlInfo info, ref NET_DVR_VIDEOWALLDISPLAYPOSITION struWallPositionCfg) { uint m_dwDeviceNo = (info.DeviceNo & 0xff) << 24; uint m_dwRes = (0 & 0xff) << 16; uint m_dwOutputNo = info.WinNo & 0xff; //显示输出号(组合):1字节设备号+1字节保留+2字节显示输出号 uint m_dwOutputChan = m_dwDeviceNo + m_dwRes + m_dwOutputNo; IntPtr lpInBuffer = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(m_dwOutputChan, lpInBuffer, false); UInt32 dwStatusList = 0; IntPtr lpStatusList = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwStatusList, lpStatusList, false); Int32 dwOutBufferSize = Marshal.SizeOf(struWallPositionCfg); IntPtr ptrWallPositionCfg = Marshal.AllocHGlobal(dwOutBufferSize); Marshal.StructureToPtr(struWallPositionCfg, ptrWallPositionCfg, false); bool b = NET_DVR_GetDeviceConfig(info.UserId, NET_DVR_GET_VIDEOWALLDISPLAYPOSITION, 1, lpInBuffer, 4, lpStatusList, ptrWallPositionCfg, (UInt32)dwOutBufferSize); //每次获取一个显示输出口位置参数 if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_GET_VIDEOWALLDISPLAYPOSITION failed, error code= " + iLastErr; //获取电视墙屏幕参数失败,输出错误号 Failed to get the wall parameters of device and output the error code } else { struWallPositionCfg = (NET_DVR_VIDEOWALLDISPLAYPOSITION)Marshal.PtrToStructure(ptrWallPositionCfg, typeof(NET_DVR_VIDEOWALLDISPLAYPOSITION)); info.IndexX = (ushort)(struWallPositionCfg.struRectCfg.dwXCoordinate / winBaseX); info.IndexY = (ushort)(struWallPositionCfg.struRectCfg.dwYCoordinate / winBaseY); } Marshal.FreeHGlobal(lpInBuffer); Marshal.FreeHGlobal(lpStatusList); Marshal.FreeHGlobal(ptrWallPositionCfg); return(b); }
/// <summary> /// 窗口置顶置底 /// </summary> /// <param name="info">窗口操作信息</param> /// <param name="cmd">命令类型</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallSetWinDisplay(WinCtrlInfo info, WinControlCmd cmd) { uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); //窗口相关参数 IntPtr lpInBuffer = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpInBuffer, false); bool b = NET_DVR_RemoteControl(info.UserId, (uint)cmd, lpInBuffer, 4); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_SWITCH_WIN_BOTTOM failed, error code= " + iLastErr; //窗口置底失败,输出错误号 Failed to set the window down to bottom and output the error code } Marshal.FreeHGlobal(lpInBuffer); return(b); }
/// <summary> /// 窗口置顶 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallSetWinTop(WinCtrlInfo info) { return(WallSetWinDisplay(info, WinControlCmd.NET_DVR_SWITCH_WIN_TOP)); }
/// <summary> /// 窗口置底 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool SetWinBottom(WinCtrlInfo info) { return(WallSetWinDisplay(info, WinControlCmd.NET_DVR_SWITCH_WIN_BOTTOM)); }
/// <summary> /// 开窗设置 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallSetWinCfg(WinCtrlInfo info) { NET_DVR_VIDEOWALLWINDOWPOSITION m_struWinCfg = new NET_DVR_VIDEOWALLWINDOWPOSITION(); uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); /////////////////////////////////////////////////////////////////////////////// //输入参数 NET_DVR_IN_PARAM struInputParam = new NET_DVR_IN_PARAM(); IntPtr lpBuf = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpBuf, false); struInputParam.struCondBuf.pBuf = lpBuf; //输入参数缓冲区,开窗的电视墙号,窗口号由设备自动分配 struInputParam.struCondBuf.nLen = 4; //窗口参数,包括使能、位置坐标等 m_struWinCfg.dwSize = (uint)Marshal.SizeOf(m_struWinCfg); m_struWinCfg.byEnable = info.IsEnable; m_struWinCfg.struRect.dwXCoordinate = ushort.Parse((info.IndexX * winBaseX).ToString()); m_struWinCfg.struRect.dwYCoordinate = ushort.Parse((info.IndexY * winBaseY).ToString()); m_struWinCfg.struRect.dwWidth = winBaseX; m_struWinCfg.struRect.dwHeight = winBaseY; Int32 nSize = Marshal.SizeOf(m_struWinCfg); IntPtr lpInBuf = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(m_struWinCfg, lpInBuf, false); struInputParam.struInParamBuf.pBuf = lpInBuf; //输入参数缓冲区,开窗的窗口参数 struInputParam.struInParamBuf.nLen = (uint)nSize; struInputParam.dwRecvTimeOut = 0; //数据接收超时时间,0表示接口默认超时 ///////////////////////////////////////////////////////////////////////////// //输出参数 NET_DVR_OUT_PARAM struOutParam = new NET_DVR_OUT_PARAM(); //输出参数缓冲区,dwCount个窗口号(组合),dwCount为0 IntPtr lpOutBuf = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpOutBuf, false); struOutParam.struOutBuf.pBuf = lpOutBuf; struOutParam.struOutBuf.nLen = 4; //状态参数 UInt32 dwStatusList = 0; IntPtr lpStatusList = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwStatusList, lpStatusList, false); bool b = NET_DVR_SetDeviceConfigEx(info.UserId, NET_DVR_SET_VIDEOWALLWINDOWPOSITION, 1, ref struInputParam, ref struOutParam); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_SET_VIDEOWALLWINDOWPOSITION failed, error code= " + iLastErr; //设置窗口参数失败,输出错误号 Failed to set the window parameters of device and output the error code } Marshal.FreeHGlobal(lpBuf); Marshal.FreeHGlobal(lpInBuf); Marshal.FreeHGlobal(lpOutBuf); Marshal.FreeHGlobal(lpStatusList); return(b); }