예제 #1
0
        /// <summary>
        /// 获取IP通道信息
        /// </summary>
        /// <param name="info">登录设备时的UseInfo对象</param>
        /// <returns>通道属性对象集合</returns>
        private List <ChannelState> GetIPChannelInfo(ref DvrUseInfo info)
        {
            NET_DVR_IPPARACFG_V40    m_struIpParaCfgV40 = new NET_DVR_IPPARACFG_V40();
            NET_DVR_GET_STREAM_UNION m_unionGetStream   = new NET_DVR_GET_STREAM_UNION();
            NET_DVR_IPCHANINFO       m_struChanInfo     = new NET_DVR_IPCHANINFO();
            List <ChannelState>      states             = new List <ChannelState>();
            uint dwSize = (uint)Marshal.SizeOf(m_struIpParaCfgV40);

            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(m_struIpParaCfgV40, ptrIpParaCfgV40, false);

            uint dwReturn = 0;

            if (!HikApi.NET_DVR_GetDVRConfig(info.UserId, NET_DVR_GET_IPPARACFG_V40, -1, ptrIpParaCfgV40, dwSize, ref dwReturn))
            {
                return(states);
            }
            else
            {
                m_struIpParaCfgV40 = (NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ptrIpParaCfgV40, typeof(NET_DVR_IPPARACFG_V40));

                byte byStreamType;
                for (int i = 0; i < m_struIpParaCfgV40.dwDChanNum; i++)
                {
                    ChannelState state = new ChannelState();
                    iChannelNum[i + dwAChanTotalNum] = i + (int)m_struIpParaCfgV40.dwStartDChan;
                    byStreamType     = m_struIpParaCfgV40.struStreamMode[i].byGetStreamType;
                    m_unionGetStream = m_struIpParaCfgV40.struStreamMode[i].uGetStream;
                    switch (byStreamType)
                    {
                    //目前NVR仅支持 0- 直接从设备取流一种方式
                    case 0:
                        dwSize = (uint)Marshal.SizeOf(m_unionGetStream);
                        IntPtr ptrChanInfo = Marshal.AllocHGlobal((Int32)dwSize);
                        Marshal.StructureToPtr(m_unionGetStream, ptrChanInfo, false);
                        m_struChanInfo    = (NET_DVR_IPCHANINFO)Marshal.PtrToStructure(ptrChanInfo, typeof(NET_DVR_IPCHANINFO));
                        state.Num         = i + 1;
                        state.IsIpChannel = true;

                        if (m_struChanInfo.byIPID == 0)
                        {
                            state.IsNull = true;      //通道空闲,没有添加前端设备
                        }
                        else
                        {
                            state.IsNull = false;
                            if (m_struChanInfo.byEnable == 0)
                            {
                                state.IsOnline = false;     //通道不在线
                            }
                            else
                            {
                                state.IsOnline = true;     //通道在线
                            }
                        }
                        Marshal.FreeHGlobal(ptrChanInfo);
                        states.Add(state);
                        break;

                    default:
                        break;
                    }
                }
            }
            Marshal.FreeHGlobal(ptrIpParaCfgV40);
            return(states);
        }
예제 #2
0
        public void InfoIPChannel()
        {
            NET_DVR_IPPARACFG_V40  m_struIpParaCfgV40 = new NET_DVR_IPPARACFG_V40();
            NET_DVR_DEVICEINFO_V30 DeviceInfo         = new NET_DVR_DEVICEINFO_V30();
            NET_DVR_STREAM_MODE    m_struStreamMode   = new NET_DVR_STREAM_MODE();
            NET_DVR_IPCHANINFO     m_struChanInfo     = new NET_DVR_IPCHANINFO();

            NET_DVR_IPCHANINFO_V40 m_struChanInfoV40 = new NET_DVR_IPCHANINFO_V40();

            uint dwSize = (uint)Marshal.SizeOf(m_struIpParaCfgV40);

            IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize);

            Marshal.StructureToPtr(m_struIpParaCfgV40, ptrIpParaCfgV40, false);

            uint dwReturn = 0;

            if (!NET_DVR_GetDVRConfig(_intDVRHwd, NET_DVR_GET_IPPARACFG_V40, 0, ptrIpParaCfgV40, dwSize, ref dwReturn))
            {
            }
            else
            {
                m_struIpParaCfgV40 = (NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ptrIpParaCfgV40, typeof(NET_DVR_IPPARACFG_V40));

                for (iip = 0; iip < dwAChanTotalNum; iip++)
                {
                    iChannelNum[iip] = iip + (int)DeviceInfo.byStartChan + 1;
                    //iChannelNum[iip] = iip + (int)DeviceInfo.byStartChan;
                }

                byte byStreamType;
                for (iip = 0; iip < m_struIpParaCfgV40.dwDChanNum; iip++)
                {
                    iChannelNum[iip + dwAChanTotalNum] = iip + (int)m_struIpParaCfgV40.dwStartDChan;
                    byStreamType = m_struIpParaCfgV40.struStreamMode[iip].byGetStreamType;
                    switch (byStreamType)
                    {
                    //目前NVR仅支持0- 直接从设备取流一种方式 NVR supports only one mode: 0- get stream from device directly
                    case 0:
                        dwSize = (uint)Marshal.SizeOf(m_struStreamMode);
                        IntPtr ptrChanInfo = Marshal.AllocHGlobal((Int32)dwSize);
                        Marshal.StructureToPtr(m_struIpParaCfgV40.struStreamMode[iip].uGetStream, ptrChanInfo, false);
                        m_struChanInfo = (NET_DVR_IPCHANINFO)Marshal.PtrToStructure(ptrChanInfo, typeof(NET_DVR_IPCHANINFO));
                        Marshal.FreeHGlobal(ptrChanInfo);
                        break;

                    case 6:
                        IntPtr ptrChanInfoV40 = Marshal.AllocHGlobal((Int32)dwSize);
                        Marshal.StructureToPtr(m_struIpParaCfgV40.struStreamMode[iip].uGetStream, ptrChanInfoV40, false);
                        m_struChanInfoV40 = (NET_DVR_IPCHANINFO_V40)Marshal.PtrToStructure(ptrChanInfoV40, typeof(NET_DVR_IPCHANINFO_V40));

                        //列出IP通道 List the IP channel
                        //iIPDevID[i] = m_struChanInfoV40.wIPID - iGroupNo * 64 - 1;

                        Marshal.FreeHGlobal(ptrChanInfoV40);
                        break;

                    default:
                        break;
                    }
                }
            }
        }