示例#1
0
 internal RemoteVideoFile(NET_DVR_FINDDATA_V30 findData)
 {
     this.Name      = findData.sFileName;
     this.StartTime = findData.struStartTime.ToDateTime();
     this.StopTime  = findData.struStopTime.ToDateTime();
     this.Size      = findData.dwFileSize;
 }
示例#2
0
        protected override int FindNext(int findId, ref ISourceFile source)
        {
            NET_DVR_FINDDATA_V30 findData = default(NET_DVR_FINDDATA_V30);
            int res = SdkHelper.InvokeSDK(() => NET_DVR_FindNextFile_V30(findId, ref findData));

            source = findData;
            return(res);
        }
 public static extern int NET_DVR_FindNextFile_V30(int lFindHandle, NET_DVR_FINDDATA_V30 lpFindData);
示例#4
0
 public static extern int NET_DVR_FindNextFile_V30(int lFindHandle, ref NET_DVR_FINDDATA_V30 lpFindData);
示例#5
0
        //private void Preview(DvrUseInfo info)
        //{
        //    HikVideoApi.NET_DVR_StopRealPlay(info.RealId);
        //    var hwnd = ptzImage.Handle;
        //    NET_DVR_PREVIEWINFO lpPreviewInfo = new NET_DVR_PREVIEWINFO();
        //    lpPreviewInfo.hPlayWnd = hwnd;//预览窗口
        //    lpPreviewInfo.lChannel = cbxPTZChannel.SelectedIndex + 1;//预te览的设备通道
        //    lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
        //    lpPreviewInfo.dwLinkMode = 0;//连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
        //    lpPreviewInfo.bBlocked = true; //0- 非阻塞取流,1- 阻塞取流
        //    lpPreviewInfo.dwDisplayBufNum = 15; //播放库播放缓冲区最大缓冲帧数
        //    REALDATACALLBACK RealData = new REALDATACALLBACK(RealDataCallBack);//预览实时流回调函数
        //    IntPtr pUser = new IntPtr();//用户数据
        //    打开预览 Start live view
        //    info.RealId = HikVideoApi.NET_DVR_RealPlay_V40(info.UserId, ref lpPreviewInfo, null/*RealData*/, pUser);
        //    realId = info.RealId;
        //    dvrUseInfos.Find(o => o.DvrIp == cbxPTZIp.Text).RealId = info.RealId;
        //    TxtPTZMsg(AppLogHelper.GetLogStr(string.Format("DvrIp:{0} 端口:{1} 名称:{2} {3} ({4})", info.DvrIp, info.DvrPoint, info.DvrName, realId >= 0 ? "预览图像成功" : "预览图像失败:" + HikOperate.GetLastError(), DateTime.Now), "图像预览"));
        //}

        #endregion

        #region 录像查找
        /// <summary>
        /// 录像文件查找
        /// </summary>
        /// <param name="info">登录设备时的UseInfo对象</param>
        /// <param name="channel">通道号</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="useCardNo">是否带ATM信息进行查询</param>
        /// <param name="fileType">录象文件类型(根据dwUseCardNo参数是否带卡号查找分为两类,参考枚举 NocardSelectFileType 和 UseCardSelectFileType)</param>
        /// <param name="isLocked">是否锁定:0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)</param>
        /// <returns>返回文件列表</returns>
        public List <BackFile> SearchBackFile(ref DvrUseInfo info, int channel, DateTime startTime, DateTime endTime, uint useCardNo = (uint)UseCardSelectWay.带ATM信息, uint fileType = 0xff, uint isLocked = 0xff)
        {
            List <BackFile> files = new List <BackFile>();

            NET_DVR_FILECOND_V40 struFileCond_V40 = new NET_DVR_FILECOND_V40()
            {
                lChannel = channel, /*通道号 Channel number*/ dwFileType = fileType, /*0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...*/ dwIsLocked = isLocked /*0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)*/, dwUseCardNo = useCardNo
            };

            //设置录像查找的开始时间 Set the starting time to search video files
            struFileCond_V40.struStartTime.dwYear   = (uint)startTime.Year;
            struFileCond_V40.struStartTime.dwMonth  = (uint)startTime.Month;
            struFileCond_V40.struStartTime.dwDay    = (uint)startTime.Day;
            struFileCond_V40.struStartTime.dwHour   = (uint)startTime.Hour;
            struFileCond_V40.struStartTime.dwMinute = (uint)startTime.Minute;
            struFileCond_V40.struStartTime.dwSecond = (uint)startTime.Second;

            //设置录像查找的结束时间 Set the stopping time to search video files
            struFileCond_V40.struStopTime.dwYear   = (uint)endTime.Year;
            struFileCond_V40.struStopTime.dwMonth  = (uint)endTime.Month;
            struFileCond_V40.struStopTime.dwDay    = (uint)endTime.Day;
            struFileCond_V40.struStopTime.dwHour   = (uint)endTime.Hour;
            struFileCond_V40.struStopTime.dwMinute = (uint)endTime.Minute;
            struFileCond_V40.struStopTime.dwSecond = (uint)endTime.Second;

            //开始录像文件查找 Start to search video files
            int m_lFindHandle = HikVideoApi.NET_DVR_FindFile_V40(info.UserId, ref struFileCond_V40);

            if (m_lFindHandle >= 0)
            {
                NET_DVR_FINDDATA_V30 struFileData = new NET_DVR_FINDDATA_V30();;
                while (true)
                {
                    //逐个获取查找到的文件信息 Get file information one by one.
                    int result = HikVideoApi.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);

                    if (result == (int)SelectFileState.NET_DVR_ISFINDING)  //正在查找请等待 Searching, please wait
                    {
                        continue;
                    }
                    else if (result == (int)SelectFileState.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
                    {
                        files.Add(new BackFile()
                        {
                            FileName = struFileData.sFileName, StartTime = new DateTime((int)struFileData.struStartTime.dwYear, (int)struFileData.struStartTime.dwMonth, (int)struFileData.struStartTime.dwDay, (int)struFileData.struStartTime.dwHour, (int)struFileData.struStartTime.dwMinute, (int)struFileData.struStartTime.dwSecond), EndTime = new DateTime((int)struFileData.struStopTime.dwYear, (int)struFileData.struStopTime.dwMonth, (int)struFileData.struStopTime.dwDay, (int)struFileData.struStopTime.dwHour, (int)struFileData.struStopTime.dwMinute, (int)struFileData.struStopTime.dwSecond), FileSize = (int)struFileData.dwFileSize, FileType = (int)struFileData.byFileType, Locked = (int)struFileData.byLocked, CardNum = struFileData.sCardNum
                        });
                    }
                    else if (result == (int)SelectFileState.NET_DVR_FILE_NOFIND || result == (int)SelectFileState.NET_DVR_NOMOREFILE)
                    {
                        break; //未查找到文件或者查找结束,退出   No file found or no more file found, search is finished
                    }
                    else
                    {
                        break;
                    }
                }
                HikVideoApi.NET_DVR_FindClose_V30(m_lFindHandle);
            }
            else
            {
                int error = HikOperate.GetLastError();
                if (error == 19 || error == 4)
                {
                    HikVideoApi.NET_DVR_FindClose_V30(m_lFindHandle);
                    return(files);
                }
                if (error == 7 || error == 73)
                {
                    return(null);
                }
            }
            return(files);
        }