public int InitSDK() { Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".InitSDK()", "DVR INFO"); //initialize disCallback = new XMSDK.fDisConnect(DisConnectBackCallFunc); GC.KeepAlive(disCallback); int bResult = XMSDK.H264_DVR_Init(disCallback, Handle); msgcallback = new XMSDK.fMessCallBack(MessCallBack); GC.KeepAlive(msgcallback); XMSDK.H264_DVR_SetDVRMessCallBack(msgcallback, Handle); XMSDK.H264_DVR_SetConnectTime(5000, 25); return(bResult); }
int DevLogin(ref DEV_INFO pdev) { if (Convert.ToBoolean(pdev.bSerialID)) { int maxDeviceNum = 100; DDNS_INFO[] pDDNSInfo = new DDNS_INFO[maxDeviceNum]; SearchMode searchmode; int nReNum = 0; searchmode.nType = (int)SearchModeType.DDNS_SERIAL; searchmode.szSerIP = pdev.szSerIP; searchmode.nSerPort = pdev.nSerPort; searchmode.szSerialInfo = pdev.szSerialInfo; bool bret = Convert.ToBoolean(XMSDK.H264_DVR_GetDDNSInfo(ref searchmode, out pDDNSInfo, maxDeviceNum, out nReNum)); if (!bret) { return(0); } pdev.szIpaddress = pDDNSInfo[0].IP; pdev.nPort = pDDNSInfo[0].MediaPort; } H264_DVR_DEVICEINFO OutDev; int nError = 0; XMSDK.H264_DVR_SetConnectTime(3000, 1); int lLogin = XMSDK.H264_DVR_Login(pdev.szIpaddress, Convert.ToUInt16(pdev.nPort), pdev.szUserName, pdev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET); if (lLogin <= 0) { int nErr = XMSDK.H264_DVR_GetLastError(); if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID) { MessageBox.Show("Error.PwdErr"); } else { MessageBox.Show("Error.NotFound"); } return(lLogin); } XMSDK.H264_DVR_SetupAlarmChan(lLogin); return(lLogin); }