海康SDK(四) 设置视频通道编码ID

要修改的地方:
海康SDK(四) 设置视频通道编码ID

具体接口

海康SDK(四) 设置视频通道编码ID
海康SDK(四) 设置视频通道编码ID

具体实现

        /// <summary>
        /// 设置视频通道编码ID
        /// </summary>
        /// <param name="channel">通道号</param>
        /// <param name="devId">视频通道编码ID</param>
        public void SetDeviceChannelId(uint channel, string devId)
        {
            //lpInBuffer对应结构体
            CHCNetSDK.NET_DVR_STREAM_INFO mlpInBuffer = new CHCNetSDK.NET_DVR_STREAM_INFO();
            Int32 dwInBufferSize = Marshal.SizeOf(mlpInBuffer);
            mlpInBuffer.dwSize = (uint)dwInBufferSize;
            mlpInBuffer.dwChannel = channel;
            IntPtr ptrInBuffCond = Marshal.AllocHGlobal(dwInBufferSize);
            Marshal.StructureToPtr(mlpInBuffer, ptrInBuffCond, false);

            //lpInParamBuffer对应结构体
            CHCNetSDK.NET_DVR_GBT28181_CHANINFO_CFG mlpOutBuffer = new CHCNetSDK.NET_DVR_GBT28181_CHANINFO_CFG();
            Int32 dwOutBufferSize = Marshal.SizeOf(mlpOutBuffer);
            mlpOutBuffer.szVideoChannelNumID = devId;
            mlpOutBuffer.dwSize = (uint)dwOutBufferSize;
            IntPtr ptrOutbuffCfg = Marshal.AllocHGlobal(dwOutBufferSize);
            Marshal.StructureToPtr(mlpOutBuffer, ptrOutbuffCfg, false);

            UInt32 dwStatusList = 0;
            IntPtr lpStatusList = Marshal.AllocHGlobal(4);
            Marshal.StructureToPtr(dwStatusList, lpStatusList, false);

            //调用接口 3252:NET_DVR_SET_GBT28181_CHANINFO_CFG
            bool r = CHCNetSDK.NET_DVR_SetDeviceConfig(m_lUserID, 3252, 1, ptrInBuffCond, dwInBufferSize, lpStatusList, ptrOutbuffCfg, dwOutBufferSize);
            if (r)
            { 
                //CHCNetSDK.NET_DVR_GBT28181_CHANINFO_CFG focusModeCfg2 = (CHCNetSDK.NET_DVR_GBT28181_CHANINFO_CFG)Marshal.PtrToStructure(ptrOutbuffCfg, typeof(CHCNetSDK.NET_DVR_GBT28181_CHANINFO_CFG)); 
            }
            else
            {
                uint iLastErr = CHCNetSDK.NET_DVR_GetLastError(); 
            }
            Marshal.FreeHGlobal(ptrInBuffCond);//释放指针 
            Marshal.FreeHGlobal(ptrOutbuffCfg);//释放指针 
            Marshal.FreeHGlobal(lpStatusList);//释放指针  
        }
上一篇:Java标识符和关键字


下一篇:010、py43-day11-sky-20210817