Example #1
0
        public bool LoginCam()
        {
            if (!m_bInit)
            {
                // MessageBox.Show("Library Initialization Failed");
                return false;
            }

            //Obtain Device User Information
            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int error = 0;
            m_nLoginID = NETClient.NETLogin(ipCamGlobal1, ushort.Parse("37777"),
                        "admin", "admin", out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                m_nChannelNum = deviceInfo.byChanNum;
                //query json ability.
                Int32 dwRetLen = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    // MessageBox.Show("Query device ability failed");
                    return false;
                }

                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int nRetLen = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                       , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return false;
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    //  MessageBox.Show("Get Snap Configuration Failed!");
                    return false;
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                   , typeof(NETDEV_SNAP_CFG));
                    }
                }
            }

            NET_DEVICEINFO deviceInfo2 = new NET_DEVICEINFO();
            int error2 = 0;
            m_nLoginID2 = NETClient.NETLogin(ipCamGlobal2, ushort.Parse("37777"),
                        "admin", "admin", out deviceInfo2, out error2);
            if (m_nLoginID2 > 0)
            {
                //query json ability.
                Int32 dwRetLen = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID2, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return false;
                }

                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON2 = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON2 == false)
                {
                    int nRetLen = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID2, (int)NETClient.NET_DEVSTATE_SNAP
                                                       , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return false;
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID2, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return false;
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                   , typeof(NETDEV_SNAP_CFG));
                    }
                }//else
            }//if login

            NET_DEVICEINFO deviceInfo3 = new NET_DEVICEINFO();
            int error3 = 0;
            m_nLoginID3 = NETClient.NETLogin(ipCamGlobal3, ushort.Parse("37777"),
                        "admin", "admin", out deviceInfo3, out error3);
            if (m_nLoginID3 > 0)
            {
                //query json ability.
                Int32 dwRetLen = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID3, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return false;
                }

                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON3 = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON3 == false)
                {
                    int nRetLen = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID3, (int)NETClient.NET_DEVSTATE_SNAP
                                                       , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return false;
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID3, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return false;
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                   , typeof(NETDEV_SNAP_CFG));
                    }
                }//else
            }//if login

            NET_DEVICEINFO deviceInfo4 = new NET_DEVICEINFO();
            int error4 = 0;
            m_nLoginID4 = NETClient.NETLogin(ipCamGlobal4, ushort.Parse("37777"),
                        "admin", "admin", out deviceInfo4, out error4);
            if (m_nLoginID4 > 0)
            {
                //query json ability.
                Int32 dwRetLen = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID4, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return false;
                }

                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON4 = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON4 == false)
                {
                    int nRetLen = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID4, (int)NETClient.NET_DEVSTATE_SNAP
                                                       , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return false;
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID4, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return false;
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                   , typeof(NETDEV_SNAP_CFG));
                    }
                }//else
            }//if login

            return true;
        }
Example #2
0
        public bool InitCamera(string ipCam1, string ipCam2, string ipCam3, string ipCam4)
        {
            m_bEnable = false;
            m_bEnable2 = false;

            m_nLoginID = 0;
            m_nLoginID2 = 0;
            m_nLoginID3 = 0;
            m_nLoginID4 = 0;
            m_bInit = false;

            ipCamGlobal1 = ipCam1;
            ipCamGlobal2 = ipCam2;
            ipCamGlobal3 = ipCam3;
            ipCamGlobal4 = ipCam4;

            m_stuSnapCfg = new NETDEV_SNAP_CFG[32];
            for (int i = 0; i < 32; ++i)
            {
                m_stuSnapCfg[i].struSnapEnc = new NET_VIDEOENC_OPT[32];
            }

            m_stuSnapAttr = new NET_SNAP_ATTR_EN();
            m_stuSnapAttr.stuSnap = new NET_QUERY_SNAP_INFO[16];

            m_stuSnapAttrEx = new NET_SNAP_ATTR_EN_EX();
            m_stuSnapAttrEx.m_bQueried = new Int32[32];
            m_stuSnapAttrEx.m_stuSnapAttrEx = new CFG_SNAPCAPINFO_INFO[32];

            //Resolution
            m_dicPix = new Dictionary<string, int>();
            m_dicPix["D1"] = 0;
            m_dicPix["HD1"] = 1;
            m_dicPix["BCIF"] = 2;
            m_dicPix["CIF"] = 3;
            m_dicPix["QCIF"] = 4;
            m_dicPix["VGA"] = 5;
            m_dicPix["QVGA"] = 6;
            m_dicPix["SVCD"] = 7;
            m_dicPix["QQVGA"] = 8;
            m_dicPix["SVGA"] = 9;
            m_dicPix["XVGA"] = 10;
            m_dicPix["WXGA"] = 11;
            m_dicPix["SXGA"] = 12;
            m_dicPix["WSXGA"] = 13;
            m_dicPix["UXGA"] = 14;
            m_dicPix["WUXGA"] = 15;
            m_dicPix["LTF"] = 16;
            m_dicPix["720p"] = 17;
            m_dicPix["1080p"] = 18;
            m_dicPix["1.3M"] = 19;
            m_dicPix["NR"] = 20;

            m_dicQuality = new Dictionary<string, int>();
            m_dicSnapSpace = new Dictionary<string, int>();
            m_dicSnapMode = new Dictionary<string, int>();

            return InitSDK();
        }