private int GetNextPageInfo(H264_DVR_FINDINFO searchInfo) { H264_DVR_FILE_DATA[] szSend = new H264_DVR_FILE_DATA[100]; int nNum = 0; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * 100); int ret = XMSDK.H264_DVR_FindFile(m_lLoginID, ref searchInfo, ptr, 100, out nNum, 5000); //for (int index = 0; index < 100; index++) //{ // unsafe // { // int* pDev = (int*)ptr.ToPointer(); // pDev += Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * index / 4; // IntPtr ptrTemp = new IntPtr(pDev); // szSend[index] = (H264_DVR_FILE_DATA)Marshal.PtrToStructure(ptrTemp, typeof(H264_DVR_FILE_DATA)); // } //} return(ret); }
private void PlayByTime() { m_nFastTypeNet = 0; m_nSlowTypeNet = 0; if (m_nNetPlayHandle == 0) { H264_DVR_FINDINFO info = new H264_DVR_FINDINFO(); info.nChannelN0 = comboChannel.SelectedIndex; //channel No. info.nFileType = comboRecordType.SelectedIndex; //file type info.startTime.dwYear = beginDate.Value.Year; info.startTime.dwMonth = beginDate.Value.Month; info.startTime.dwDay = beginDate.Value.Day; info.startTime.dwHour = beginTime.Value.Hour; info.startTime.dwMinute = beginTime.Value.Minute; info.startTime.dwSecond = beginTime.Value.Second; info.endTime.dwYear = endDate.Value.Year; info.endTime.dwMonth = endDate.Value.Month; info.endTime.dwDay = endDate.Value.Day; info.endTime.dwHour = endTime.Value.Hour; info.endTime.dwMinute = endTime.Value.Minute; info.endTime.dwSecond = endTime.Value.Second; info.hWnd = (uint)pictureBoxNetVideoWnd.Handle; XMSDK.fDownLoadPosCallBack DownloadCallback = new XMSDK.fDownLoadPosCallBack(DownLoadPosCallback); XMSDK.fRealDataCallBack realDataCallBack = new XMSDK.fRealDataCallBack(RealDataCallBack); m_nNetPlayHandle = XMSDK.H264_DVR_PlayBackByTimeEx(m_lLoginID, ref info, null, this.Handle.ToInt32(), null, this.Handle.ToInt32()); if (m_nNetPlayHandle <= 0) { MessageBox.Show("Playback fail"); m_nNetPlayHandle = 0; return; } timerNetPlayBack.Start(); } else { if (m_bPauseNetPlay) { XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_CONTINUE, 0); m_bPauseNetPlay = !m_bPauseNetPlay; } XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_FAST, 0); m_nFastTypeNet = 0; m_nSlowTypeNet = 0; } }
private void DownloadByTime() { if (m_DownLoadFileHandle > 0) { timerDownload.Stop(); XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle); m_DownLoadFileHandle = 0; progressBarDownloadPos.Value = 0; btnDownload.Text = "Download"; return; } string strSaveName = ""; //strSaveName.Format("c:\\record"); strSaveName = BrowseForFolder(this.Handle); if (strSaveName == "") //未选择路径时退出 { return; } H264_DVR_FINDINFO info = new H264_DVR_FINDINFO(); info.nChannelN0 = comboChannel.SelectedIndex; //channel No. info.nFileType = comboRecordType.SelectedIndex; //file type info.startTime.dwYear = beginDate.Value.Year; info.startTime.dwMonth = beginDate.Value.Month; info.startTime.dwDay = beginDate.Value.Day; info.startTime.dwHour = beginTime.Value.Hour; info.startTime.dwMinute = beginTime.Value.Minute; info.startTime.dwSecond = beginTime.Value.Second; info.endTime.dwYear = endDate.Value.Year; info.endTime.dwMonth = endDate.Value.Month; info.endTime.dwDay = endDate.Value.Day; info.endTime.dwHour = endTime.Value.Hour; info.endTime.dwMinute = endTime.Value.Minute; info.endTime.dwSecond = endTime.Value.Second; int nRecordFileType = comboRecordType.SelectedIndex; info.nFileType = (nRecordFileType <= (int)PlayBackFileType.SDK_RECORD_MANUAL) ? nRecordFileType : ((int)PlayBackFileType.SDK_PIC_ALL + nRecordFileType - (int)PlayBackFileType.SDK_RECORD_MANUAL - 1); m_DownLoadFileHandle = XMSDK.H264_DVR_GetFileByTime(m_lLoginID, ref info, strSaveName, false, null, 0); if (m_DownLoadFileHandle > 0) { progressBarDownloadPos.Value = 0; btnDownload.Text = "Stop"; //update the progress control timerDownload.Start(); } else { string sTemp; sTemp = string.Format("dowload fail ERROR = {0}", XMSDK.H264_DVR_GetLastError()); MessageBox.Show(sTemp); } }
private void btnPrePage_Click(object sender, EventArgs e) { if (m_nGetPage <= 1 || m_nCurPage <= 1) { return; } m_nCurPage--; m_nGetPage--; ClearResult(); m_ListFindNum = m_ListFindNum - 1; if (GetNextPageInfo(m_listFindInfo[--m_ListFindNum]) > 0) { H264_DVR_FILE_DATA[] szSend = new H264_DVR_FILE_DATA[100]; int nNum = 0; H264_DVR_FINDINFO findinfo = m_listFindInfo[m_ListFindNum]; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * 100); int nRet = XMSDK.H264_DVR_FindFile(m_lLoginID, ref findinfo, ptr, 100, out nNum, 5000); for (int index = 0; index < 100; index++) { unsafe { int *pDev = (int *)ptr.ToPointer(); pDev += Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * index / 4; IntPtr ptrTemp = new IntPtr(pDev); szSend[index] = (H264_DVR_FILE_DATA)Marshal.PtrToStructure(ptrTemp, typeof(H264_DVR_FILE_DATA)); } } m_nCurRecNum = nNum; if (nRet > 0 && nNum > 0) //处理没有录象的情况 { if (m_nCurRecNum > m_listFile.Capacity) { m_listFile.Capacity = m_nCurRecNum; } for (int i = 0; i < m_nCurRecNum; i++) { m_listFile.Add(szSend[i]); } //m_nSearchInfo.nChannelN0 = m_nSearchInfo.nChannelN0; //m_nSearchInfo.nFileType = m_nSearchInfo.nFileType; m_nSearchInfo.startTime.dwYear = szSend[m_nCurRecNum - 1].stEndTime.year; m_nSearchInfo.startTime.dwMonth = szSend[m_nCurRecNum - 1].stEndTime.month; m_nSearchInfo.startTime.dwDay = szSend[m_nCurRecNum - 1].stEndTime.day; m_nSearchInfo.startTime.dwHour = szSend[m_nCurRecNum - 1].stEndTime.hour; m_nSearchInfo.startTime.dwMinute = szSend[m_nCurRecNum - 1].stEndTime.minute; m_nSearchInfo.startTime.dwSecond = szSend[m_nCurRecNum - 1].stEndTime.second; m_nSearchInfo.endTime = m_listFindInfo[m_ListFindNum].endTime; m_ListFindNum++; } else { } AddFileListInfo(m_nCurRecNum); SetPageBtnState(); } }
private void btnSearch_Click(object sender, EventArgs e) { // 条件检测 if (comboDev.SelectedIndex < 0) { MessageBox.Show("Select a Device!"); return; } if (!checkFile.Checked && !checkTime.Checked) { MessageBox.Show("Select a Search mode!"); return; } ClearResult(); H264_DVR_TIME StartTime; H264_DVR_TIME StopTime; int nChannel = comboChannel.SelectedIndex; //channel No. int nFileType = comboRecordType.SelectedIndex; //file type StartTime.dwYear = beginDate.Value.Year; StartTime.dwMonth = beginDate.Value.Month; StartTime.dwDay = beginDate.Value.Day; StartTime.dwHour = beginTime.Value.Hour; StartTime.dwMinute = beginTime.Value.Minute; StartTime.dwSecond = beginTime.Value.Second; StopTime.dwYear = endDate.Value.Year; StopTime.dwMonth = endDate.Value.Month; StopTime.dwDay = endDate.Value.Day; StopTime.dwHour = endDate.Value.Hour; StopTime.dwMinute = endDate.Value.Minute; StopTime.dwSecond = endDate.Value.Second; H264_DVR_FILE_DATA[] szSend = new H264_DVR_FILE_DATA[100]; ComboxItem item = (ComboxItem)comboDev.SelectedItem; if (item.Value != null) { DEV_INFO devInfo = (DEV_INFO)item.Value; int lLoginID = devInfo.lLoginID; int nMaxLen = 100; int waitTime = 4000; int nNum = 0; H264_DVR_FINDINFO searchInfo = new H264_DVR_FINDINFO(); searchInfo.startTime = StartTime; searchInfo.endTime = StopTime; searchInfo.nChannelN0 = nChannel; searchInfo.nFileType = nFileType; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * 100); int nRet = XMSDK.H264_DVR_FindFile(lLoginID, ref searchInfo, ptr, nMaxLen, out nNum, waitTime); m_nCurRecNum = nNum; for (int index = 0; index < 100; index++) { unsafe { int *pDev = (int *)ptr.ToPointer(); pDev += Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * index / 4; IntPtr ptrTemp = new IntPtr(pDev); szSend[index] = (H264_DVR_FILE_DATA)Marshal.PtrToStructure(ptrTemp, typeof(H264_DVR_FILE_DATA)); } } if (nRet > 0) { if (nNum > 0) { m_nGetPage++; m_nCurPage = 1; if (m_nCurRecNum > m_listFile.Capacity) { m_listFile.Capacity = m_nCurRecNum; } for (int i = 0; i < m_nCurRecNum; i++) { m_listFile.Add(szSend[i]); } m_nSearchInfo.nChannelN0 = nChannel; m_nSearchInfo.nFileType = nFileType; m_nSearchInfo.startTime.dwYear = szSend[m_nCurRecNum - 1].stEndTime.year; m_nSearchInfo.startTime.dwMonth = szSend[m_nCurRecNum - 1].stEndTime.month; m_nSearchInfo.startTime.dwDay = szSend[m_nCurRecNum - 1].stEndTime.day; m_nSearchInfo.startTime.dwHour = szSend[m_nCurRecNum - 1].stEndTime.hour; m_nSearchInfo.startTime.dwMinute = szSend[m_nCurRecNum - 1].stEndTime.minute; m_nSearchInfo.startTime.dwSecond = szSend[m_nCurRecNum - 1].stEndTime.second; m_nSearchInfo.endTime = searchInfo.endTime; if (nNum < PLAYBACK_MAX_FILE_NUM) { m_nTotalPage = m_nGetPage; } AddFileListInfo(m_nCurRecNum);//add list item SetPageBtnState(); } else { MessageBox.Show("No File"); } } else { MessageBox.Show("SearchFail"); } } }
public static extern int H264_DVR_PlayBackByTimeEx(int lLoginID, ref H264_DVR_FINDINFO lpFindInfo, fRealDataCallBack fDownLoadDataCallBack, int dwDataUser, fDownLoadPosCallBack cbDownLoadPos, int dwPosUser);
public static extern int H264_DVR_FindFile(int lLoginID, ref H264_DVR_FINDINFO lpFindInfo, IntPtr ptr, int lMaxCount, out int findcount, int waittime);
public static extern int H264_DVR_GetFileByTime(int lLoginID, ref H264_DVR_FINDINFO lpFindInfo, string sSavedFileDIR, bool bMerge, fDownLoadPosCallBack cbDownLoadPos, int dwDataUser);
public static extern int H264_DVR_GetFileByTime(int lLoginID, ref H264_DVR_FINDINFO lpFindInfo, string sSavedFileDIR, bool bMerge, fDownLoadPosCallBack cbDownLoadPos , int dwDataUser);
public static extern int H264_DVR_PlayBackByTimeEx(int lLoginID, ref H264_DVR_FINDINFO lpFindInfo,fRealDataCallBack fDownLoadDataCallBack, int dwDataUser, fDownLoadPosCallBack cbDownLoadPos, int dwPosUser);
private int GetNextPageInfo(H264_DVR_FINDINFO searchInfo) { H264_DVR_FILE_DATA[] szSend = new H264_DVR_FILE_DATA[100]; int nNum=0; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * 100); int ret = XMSDK.H264_DVR_FindFile(m_lLoginID, ref searchInfo, ptr ,100, out nNum, 5000); //for (int index = 0; index < 100; index++) //{ // unsafe // { // int* pDev = (int*)ptr.ToPointer(); // pDev += Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * index / 4; // IntPtr ptrTemp = new IntPtr(pDev); // szSend[index] = (H264_DVR_FILE_DATA)Marshal.PtrToStructure(ptrTemp, typeof(H264_DVR_FILE_DATA)); // } //} return ret; }
private void DownloadByTime() { if (m_DownLoadFileHandle > 0) { timerDownload.Stop(); XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle); m_DownLoadFileHandle = 0; progressBarDownloadPos.Value = 0; btnDownload.Text = "Download"; return; } string strSaveName = ""; //strSaveName.Format("c:\\record"); strSaveName = BrowseForFolder(this.Handle) ; if ( strSaveName == "") //未选择路径时退出 { return; } H264_DVR_FINDINFO info = new H264_DVR_FINDINFO(); info.nChannelN0 = comboChannel.SelectedIndex; //channel No. info.nFileType = comboRecordType.SelectedIndex; //file type info.startTime.dwYear = beginDate.Value.Year; info.startTime.dwMonth = beginDate.Value.Month; info.startTime.dwDay = beginDate.Value.Day; info.startTime.dwHour = beginTime.Value.Hour; info.startTime.dwMinute = beginTime.Value.Minute; info.startTime.dwSecond = beginTime.Value.Second; info.endTime.dwYear = endDate.Value.Year; info.endTime.dwMonth = endDate.Value.Month; info.endTime.dwDay = endDate.Value.Day; info.endTime.dwHour = endTime.Value.Hour; info.endTime.dwMinute = endTime.Value.Minute; info.endTime.dwSecond = endTime.Value.Second; int nRecordFileType = comboRecordType.SelectedIndex; info.nFileType = (nRecordFileType <= (int)PlayBackFileType.SDK_RECORD_MANUAL) ? nRecordFileType : ((int)PlayBackFileType.SDK_PIC_ALL + nRecordFileType - (int)PlayBackFileType.SDK_RECORD_MANUAL - 1); m_DownLoadFileHandle = XMSDK.H264_DVR_GetFileByTime(m_lLoginID, ref info, strSaveName, false, null, 0); if (m_DownLoadFileHandle > 0) { progressBarDownloadPos.Value = 0; btnDownload.Text = "Stop"; //update the progress control timerDownload.Start(); } else { string sTemp; sTemp = string.Format("dowload fail ERROR = {0}",XMSDK.H264_DVR_GetLastError()); MessageBox.Show(sTemp); } }
private void btnSearch_Click(object sender, EventArgs e) { // 条件检测 if(comboDev.SelectedIndex < 0) { MessageBox.Show("Select a Device!"); return; } if (!checkFile.Checked && !checkTime.Checked) { MessageBox.Show("Select a Search mode!"); return; } ClearResult(); H264_DVR_TIME StartTime; H264_DVR_TIME StopTime; int nChannel = comboChannel.SelectedIndex; //channel No. int nFileType = comboRecordType.SelectedIndex; //file type StartTime.dwYear = beginDate.Value.Year; StartTime.dwMonth = beginDate.Value.Month; StartTime.dwDay = beginDate.Value.Day; StartTime.dwHour = beginTime.Value.Hour; StartTime.dwMinute = beginTime.Value.Minute; StartTime.dwSecond = beginTime.Value.Second; StopTime.dwYear = endDate.Value.Year; StopTime.dwMonth = endDate.Value.Month; StopTime.dwDay = endDate.Value.Day; StopTime.dwHour =endDate.Value.Hour; StopTime.dwMinute = endDate.Value.Minute; StopTime.dwSecond = endDate.Value.Second; H264_DVR_FILE_DATA[] szSend = new H264_DVR_FILE_DATA[100]; ComboxItem item = (ComboxItem)comboDev.SelectedItem; if (item.Value != null) { DEV_INFO devInfo = (DEV_INFO)item.Value; int lLoginID = devInfo.lLoginID; int nMaxLen = 100; int waitTime = 4000; int nNum = 0; H264_DVR_FINDINFO searchInfo = new H264_DVR_FINDINFO(); searchInfo.startTime = StartTime; searchInfo.endTime = StopTime; searchInfo.nChannelN0 = nChannel; searchInfo.nFileType = nFileType; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * 100); int nRet = XMSDK.H264_DVR_FindFile(lLoginID, ref searchInfo, ptr, nMaxLen, out nNum, waitTime); m_nCurRecNum = nNum; for (int index = 0; index < 100; index++) { unsafe { int* pDev = (int*)ptr.ToPointer(); pDev += Marshal.SizeOf(typeof(H264_DVR_FILE_DATA)) * index / 4; IntPtr ptrTemp = new IntPtr(pDev); szSend[index] = (H264_DVR_FILE_DATA)Marshal.PtrToStructure(ptrTemp, typeof(H264_DVR_FILE_DATA)); } } if ( nRet > 0 ) { if ( nNum > 0) { m_nGetPage++; m_nCurPage = 1; if (m_nCurRecNum > m_listFile.Capacity) { m_listFile.Capacity = m_nCurRecNum; } for (int i = 0; i < m_nCurRecNum; i++) { m_listFile.Add(szSend[i]); } m_nSearchInfo.nChannelN0 = nChannel; m_nSearchInfo.nFileType = nFileType; m_nSearchInfo.startTime.dwYear = szSend[m_nCurRecNum - 1].stEndTime.year; m_nSearchInfo.startTime.dwMonth = szSend[m_nCurRecNum - 1].stEndTime.month; m_nSearchInfo.startTime.dwDay = szSend[m_nCurRecNum - 1].stEndTime.day; m_nSearchInfo.startTime.dwHour = szSend[m_nCurRecNum - 1].stEndTime.hour; m_nSearchInfo.startTime.dwMinute = szSend[m_nCurRecNum - 1].stEndTime.minute; m_nSearchInfo.startTime.dwSecond = szSend[m_nCurRecNum - 1].stEndTime.second; m_nSearchInfo.endTime = searchInfo.endTime; if (nNum < PLAYBACK_MAX_FILE_NUM) { m_nTotalPage = m_nGetPage; } AddFileListInfo(m_nCurRecNum);//add list item SetPageBtnState(); } else { MessageBox.Show("No File"); } } else { MessageBox.Show("SearchFail"); } } }
private void PlayByTime() { m_nFastTypeNet = 0; m_nSlowTypeNet = 0; if(m_nNetPlayHandle == 0) { H264_DVR_FINDINFO info = new H264_DVR_FINDINFO(); info.nChannelN0 = comboChannel.SelectedIndex; //channel No. info.nFileType = comboRecordType.SelectedIndex; //file type info.startTime.dwYear = beginDate.Value.Year; info.startTime.dwMonth = beginDate.Value.Month; info.startTime.dwDay = beginDate.Value.Day; info.startTime.dwHour = beginTime.Value.Hour; info.startTime.dwMinute = beginTime.Value.Minute; info.startTime.dwSecond = beginTime.Value.Second; info.endTime.dwYear = endDate.Value.Year; info.endTime.dwMonth = endDate.Value.Month; info.endTime.dwDay = endDate.Value.Day; info.endTime.dwHour = endTime.Value.Hour; info.endTime.dwMinute = endTime.Value.Minute; info.endTime.dwSecond = endTime.Value.Second; info.hWnd = (uint)pictureBoxNetVideoWnd.Handle; XMSDK.fDownLoadPosCallBack DownloadCallback = new XMSDK.fDownLoadPosCallBack(DownLoadPosCallback); XMSDK.fRealDataCallBack realDataCallBack = new XMSDK.fRealDataCallBack(RealDataCallBack); m_nNetPlayHandle = XMSDK.H264_DVR_PlayBackByTimeEx(m_lLoginID, ref info, null, this.Handle.ToInt32(), null, this.Handle.ToInt32()); if (m_nNetPlayHandle <= 0) { MessageBox.Show("Playback fail"); m_nNetPlayHandle = 0; return; } timerNetPlayBack.Start(); } else { if (m_bPauseNetPlay) { XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_CONTINUE, 0 ); m_bPauseNetPlay = !m_bPauseNetPlay; } XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_FAST, 0); m_nFastTypeNet = 0; m_nSlowTypeNet = 0; } }