コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <summary>
        /// 获取输出口信息
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="info">输出输出口信息列表</param>
        /// <returns>TRUE:成功 FALSE:失败</returns>
        public static bool GetDisplayInfo(int userId, ref List <DisplayInfo> info)
        {
            info = new List <DisplayInfo>();
            /////////////////////////////////////////////////////////////////////////////////////
            //批量获取显示输出口位置配置
            uint  uDisplayCount    = 0;
            Int32 nWallDisplaySize = Marshal.SizeOf(typeof(NET_DVR_VIDEOWALLDISPLAYPOSITION));
            int   outBufSize       = 4 + 512 * (int)nWallDisplaySize;

            byte[] pTemp    = new byte[outBufSize];
            IntPtr lpOutBuf = Marshal.AllocHGlobal(outBufSize);

            Marshal.Copy(pTemp, 0, lpOutBuf, outBufSize);

            //每次获取一个显示输出口位置参数
            if (!NET_DVR_GetDeviceConfig(userId, NET_DVR_GET_VIDEOWALLDISPLAYPOSITION, 0xffffffff, IntPtr.Zero, 0, IntPtr.Zero, lpOutBuf, (UInt32)outBufSize))
            {
                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
                return(false);
            }
            else
            {
                Marshal.Copy(lpOutBuf, pTemp, 0, (int)outBufSize);
                uDisplayCount = ((uint)pTemp[0] & 0xff)
                                | (((uint)pTemp[1] << 8) & 0xff00)
                                | (((uint)pTemp[2] << 16) & 0xff0000)
                                | (((uint)pTemp[3] << 24) & 0xff000000);
            }

            NET_DVR_VIDEOWALLDISPLAYPOSITION[] arrstruWallPos = new NET_DVR_VIDEOWALLDISPLAYPOSITION[uDisplayCount];
            for (int i = 0; i < uDisplayCount; i++)
            {
                arrstruWallPos[i] = new NET_DVR_VIDEOWALLDISPLAYPOSITION();
                arrstruWallPos[i] = (NET_DVR_VIDEOWALLDISPLAYPOSITION)Marshal.PtrToStructure((IntPtr)((Int32)lpOutBuf + i * nWallDisplaySize + 4), typeof(NET_DVR_VIDEOWALLDISPLAYPOSITION));
            }
            Marshal.FreeHGlobal(lpOutBuf);
            //////////////////////////////////////////////
            NET_DVR_DISPLAYCFG m_struDispNoCfg = new NET_DVR_DISPLAYCFG();
            //获取显示输出口号信息
            Int32  nSize       = Marshal.SizeOf(m_struDispNoCfg);
            IntPtr lpOutBuffer = Marshal.AllocHGlobal(nSize);

            Marshal.StructureToPtr(m_struDispNoCfg, lpOutBuffer, false);

            UInt32 dwReturn = 0;

            if (!NET_DVR_GetDVRConfig(userId, NET_DVR_GET_VIDEOWALLDISPLAYNO, 0, lpOutBuffer, (UInt32)nSize, ref dwReturn))
            {
                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
                return(false);
            }
            else
            {
                m_struDispNoCfg = (NET_DVR_DISPLAYCFG)Marshal.PtrToStructure(lpOutBuffer, typeof(NET_DVR_DISPLAYCFG));
            }
            Marshal.FreeHGlobal(lpOutBuffer);
            //////////////////////////////////////////
            //添加显示输出口信息到列表里面
            for (int i = 0; i < uDisplayCount; i++)
            {
                uint dwDisplayNo = m_struDispNoCfg.struDisplayParam[i].dwDisplayNo;

                if (dwDisplayNo > 0)
                {
                    string displayno    = Convert.ToString(dwDisplayNo);
                    string displaynoCom = Convert.ToString(dwDisplayNo >> 24) + "_" + Convert.ToString((dwDisplayNo >> 16) & 0xff) + "_" + Convert.ToString(dwDisplayNo & 0xffff); //显示输出口号组合方式显示

                    string DisplayType = "";
                    switch (m_struDispNoCfg.struDisplayParam[i].byDispChanType)
                    {
                    case 1:
                        DisplayType = "BNC";
                        break;

                    case 2:
                        DisplayType = "VGA";
                        break;

                    case 3:
                        DisplayType = "HDMI";
                        break;

                    case 4:
                        DisplayType = "DVI";
                        break;

                    case 0xff:
                        DisplayType = "无效";
                        break;

                    default:
                        DisplayType = "";
                        break;
                    }
                    string enabled     = Convert.ToString(arrstruWallPos[i].byEnable);
                    string xCoordinate = Convert.ToString(arrstruWallPos[i].struRectCfg.dwXCoordinate);
                    string yCoordinate = Convert.ToString(arrstruWallPos[i].struRectCfg.dwYCoordinate);
                    info.Add(new DisplayInfo()
                    {
                        Displayno = displayno, DisplaynoCom = displaynoCom, XCoordinate = xCoordinate, YCoordinate = yCoordinate, Enabled = enabled, DisplayType = DisplayType
                    });                                                                                                                                                                                    //获取的显示输出口信息
                }
            }
            return(true);
        }