Ejemplo n.º 1
0
        public List <Video> GetVideoList()
        {
            StructDataDef.stPageReq stReq = new StructDataDef.stPageReq();
            StructDataDef.stPageRsp stRsp = new StructDataDef.stPageRsp();
            int   iPageNo          = 1;
            Int64 i64TmpUpdateTime = 0;
            int   iSize            = Marshal.SizeOf(typeof(StructDataDef.stDevice));
            int   iNeedMem         = 800 * iSize;

            stReq.iPageRows = 800;

            #region getvideoinfo

            iPageNo         = 1;
            iSize           = Marshal.SizeOf(typeof(StructDataDef.stCamera));
            iNeedMem        = 800 * iSize;
            stReq.iPageRows = 800;

            List <Video> resutl = new List <Video>();

            while (true)
            {
                IntPtr pCamera = Marshal.AllocHGlobal(iNeedMem);
                for (int i = 0; i < iNeedMem; ++i)
                {
                    Marshal.WriteByte(pCamera, 0);
                }

                stReq.iPageNo = iPageNo;
                int  iStartTime  = Environment.TickCount;
                int  iRet        = HIKPlatformSDK.ISMS_GetCameraInfo(ref stReq, ref stRsp, pCamera);
                int  iTimeElapse = Environment.TickCount - iStartTime;
                bool bSuccess    = iRet == 0;
                //string szDesc = true != bSuccess ? string.Format("全量获取第{0}页设备失败,耗时{1}毫秒", iPageNo, iTimeElapse)  : string.Format("共有{0}页记录,获取第{1}页成功,该页有{2}条记录,耗时{3}毫秒", stRsp.iTotalPage, iPageNo, stRsp.iRealRows, iTimeElapse);
                if (true != bSuccess)
                {
                    Marshal.FreeHGlobal(pCamera);
                    return(null);
                }

                if (0 == stRsp.iRealRows || stRsp.iPageNo != stReq.iPageNo)
                {
                    Marshal.FreeHGlobal(pCamera);
                    break;
                }

                if (1 == iPageNo)
                {
                    i64TmpUpdateTime = stRsp.iUpdateTime;
                }
                else
                {
                    if (i64TmpUpdateTime > stRsp.iUpdateTime)
                    {
                        i64TmpUpdateTime = stRsp.iUpdateTime;
                    }
                }

                //InsertOperLogInfo("ISMS_GetCameraInfo", szDesc, bSuccess ? 0 : InterfaceDef.ISMS_GetLastError());
                IntPtr pTmp = pCamera;
                for (int j = 0; j < stRsp.iRealRows; ++j)
                {
                    StructDataDef.stCamera pSingle = (StructDataDef.stCamera)Marshal.PtrToStructure(pTmp, typeof(StructDataDef.stCamera));

                    Video vii = new Video()
                    {
                        UUID      = pSingle.szCameraUuid,
                        DeviceID  = pSingle.szDeviceUuid,
                        VideoName = pSingle.szCameraName
                    };
                    resutl.Add(vii);


                    pTmp = new IntPtr(pTmp.ToInt32() + iSize);
                }

                ++iPageNo;
                Marshal.FreeHGlobal(pCamera);
            }

            return(resutl);

            #endregion
        }
Ejemplo n.º 2
0
 void GetCammerInfoByUUID(string camuuid)
 {
     StructDataDef.stCamera camera = new StructDataDef.stCamera();
     HIKPlatformSDK.ISMS_GetCameraInfoByUuid(camuuid, ref camera);
 }