コード例 #1
0
        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);
        }
コード例 #2
0
        private void PlayByName()
        {
            if (m_nNetPlayHandle >= 0)
            {
                timerNetPlayBack.Enabled = false;
                XMSDK.H264_DVR_StopPlayBack(m_nNetPlayHandle);
                m_nNetPlayHandle         = 0;
                trackBarNetPlayPos.Value = 0;
                m_bOpenAudio             = false;
                m_bPauseNetPlay          = false;
            }


            m_nFastTypeNet = 0;
            m_nSlowTypeNet = 0;
            if (m_nNetPlayHandle == 0)
            {
                string csFileName = "";

                int nSelected = listFile.SelectedItems.Count;
                if (nSelected == 0)
                {
                    MessageBox.Show("SelectFile");
                    return;
                }

                H264_DVR_FILE_DATA FileInfo = (H264_DVR_FILE_DATA)listFile.FocusedItem.Tag;
                FileInfo.hWnd = (IntPtr)pictureBoxNetVideoWnd.Handle;


                XMSDK.fDownLoadPosCallBack downloadCallBack  = new XMSDK.fDownLoadPosCallBack(DownLoadPosCallback);
                XMSDK.fRealDataCallBack_V2 netdatacallbackv2 = new XMSDK.fRealDataCallBack_V2(NetCallBack_V2);

                m_nNetPlayHandle = XMSDK.H264_DVR_PlayBackByName_V2(m_lLoginID, ref FileInfo, downloadCallBack, netdatacallbackv2, this.Handle.ToInt32());
                if (m_nNetPlayHandle <= 0)
                {
                    MessageBox.Show("Playback fail");
                    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;
            }
        }
コード例 #3
0
ファイル: XMSDK.cs プロジェクト: cray888/Surveillance_c_sharp
 public static extern int H264_DVR_PlayBackByName_V2(int lLoginID, ref H264_DVR_FILE_DATA sPlayBackFile, fDownLoadPosCallBack cbDownLoadPos, fRealDataCallBack_V2 fDownLoadDataCallBack, int dwDataUser);
コード例 #4
0
ファイル: XMSDK.cs プロジェクト: cray888/Surveillance_c_sharp
 public static extern int H264_DVR_GetFileByName(int lLoginID, ref H264_DVR_FILE_DATA sPlayBackFile, string sSavedFileName,
                                                 fDownLoadPosCallBack cbDownLoadPos, int dwDataUser, fRealDataCallBack fDownLoadDataCallBack);
コード例 #5
0
        private void DownloadByName()
        {
            if (m_DownLoadFileHandle > 0)
            {
                timerDownload.Stop();
                XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle);
                m_DownLoadFileHandle         = 0;
                progressBarDownloadPos.Value = 0;

                btnDownload.Text = "Download";

                return;
            }

            string csFileName;

            //inCount;
            //if ( nSelected < 0 )
            //{
            //    MessageBox.Show("SelectFile !");
            //    return;
            //}


            H264_DVR_FILE_DATA FileInfo = (H264_DVR_FILE_DATA)listFile.FocusedItem.Tag;


            string strSaveName;
            //strSaveName.Format("c:\\record\\record.h264");
            int nSelectedIndex = comboDev.SelectedIndex;

            if (nSelectedIndex < 0)
            {
                MessageBox.Show("SelectDevice !");
                return;
            }
            DEV_INFO DevTemp = (DEV_INFO)((ComboxItem)comboDev.SelectedItem).Value;

            string strInitDir;

            strInitDir = Application.StartupPath;
            if (strInitDir.EndsWith("\\"))
            {
                strInitDir += "Download";
            }
            else
            {
                strInitDir += "\\Download";
            }

            DirectoryInfo dir = new DirectoryInfo(strInitDir);

            //if ( dir.Attributes )
            {
                dir.Create();
            }

            string strFileTpye = "h264";
            string strFileName = FileInfo.sFileName;

            if (strFileName.EndsWith(".h264"))
            {
                strFileTpye = "h264";
            }
            else
            {
                strFileTpye = "jpg";
            }
            strFileName = string.Format("{0}_{1}_{2}-{3}_{4}{5}{6}{7}.{8}",
                                        DevTemp.szDevName, FileInfo.ch + 1,
                                        FileInfo.stBeginTime.year, FileInfo.stBeginTime.month,
                                        FileInfo.stBeginTime.day, FileInfo.stBeginTime.hour,
                                        FileInfo.stBeginTime.minute, FileInfo.stBeginTime.second, strFileTpye);

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.AddExtension     = true;
            dlg.CheckPathExists  = true;
            dlg.DefaultExt       = ".h264";
            dlg.Filter           = "All File(*.h264;*.jpg)|*.*||";
            dlg.InitialDirectory = strInitDir;          //默认路径

            dlg.FileName = strFileName;
            int count = listFile.SelectedItems[0].Index;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                strSaveName = dlg.FileName;
                //m_lSaveHandle = H264_DVR_GetFileByName(m_lLoginID, pstrFileInfo,strSaveName.GetBuffer(0),SDKDownLoadPosCallback,(DWORD)this);
                m_DownLoadFileHandle = XMSDK.H264_DVR_GetFileByName(m_lLoginID, ref FileInfo, strSaveName, null, 0, null);
                if (m_DownLoadFileHandle >= 0)
                {
                    progressBarDownloadPos.Value = 0;
                    btnDownload.Text             = "Stop";
                    //update the progress control
                    //SetTimer(1,0,NULL);
                }
                else
                {
                    string sTemp = string.Format("dowload fail ERROR = {0}", XMSDK.H264_DVR_GetLastError());
                    MessageBox.Show(sTemp);
                }
            }
        }
コード例 #6
0
        private void btnNextPage_Click(object sender, EventArgs e)
        {
            if (m_nGetPage <= 0)
            {
                return;
            }

            ClearResult();

            //if (GetNextPageInfo(m_nSearchInfo) > 0 && (m_nCurPage == m_nGetPage))
            {
                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 nRet = XMSDK.H264_DVR_FindFile(m_lLoginID, ref m_nSearchInfo[m_nCurPage], ptr, 100, out nNum, 5000);

                for (int index = 0; index < nNum; 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_listFile[index] = szSend[index];
                    }
                }

                m_listFile.Clear();
                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_nCurPage++;
                    m_nSearchInfo[m_nCurPage].nChannelN0         = m_nSearchInfo[0].nChannelN0;
                    m_nSearchInfo[m_nCurPage].nFileType          = m_nSearchInfo[0].nFileType;
                    m_nSearchInfo[m_nCurPage].startTime.dwYear   = szSend[m_nCurRecNum - 1].stEndTime.year;
                    m_nSearchInfo[m_nCurPage].startTime.dwMonth  = szSend[m_nCurRecNum - 1].stEndTime.month;
                    m_nSearchInfo[m_nCurPage].startTime.dwDay    = szSend[m_nCurRecNum - 1].stEndTime.day;
                    m_nSearchInfo[m_nCurPage].startTime.dwHour   = szSend[m_nCurRecNum - 1].stEndTime.hour;
                    m_nSearchInfo[m_nCurPage].startTime.dwMinute = szSend[m_nCurRecNum - 1].stEndTime.minute;
                    m_nSearchInfo[m_nCurPage].startTime.dwSecond = szSend[m_nCurRecNum - 1].stEndTime.second;
                    m_nSearchInfo[m_nCurPage].endTime            = m_nSearchInfo[0].endTime;

                    m_nGetPage++;
                    if (m_nCurRecNum < PLAYBACK_MAX_FILE_NUM)
                    {
                        m_nTotalPage = m_nGetPage;
                    }



                    AddFileListInfo(m_nCurRecNum);

                    SetPageBtnState(nNum);
                }
                else
                {
                }
            }
        }
コード例 #7
0
        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 m_nSearchInfo[m_nCurPage - 1], ptr, 100, out nNum, 5000);

                for (int index = 0; index < nNum; 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_listFile[index] = szSend[index];
                    }
                }
                m_listFile.Clear();

                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_ListFindNum++;
                }
                else
                {
                }
                AddFileListInfo(m_nCurRecNum);
                SetPageBtnState(nNum);
            }
        }
コード例 #8
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            m_nGetPage   = 0;
            m_nCurPage   = 0;
            m_nTotalPage = 0;

            // 条件检测
            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

            if (nFileType >= 5)
            {
                nFileType += 5;
            }

            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[64];

            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 < nNum; 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_listFile[index] = szSend[index];
                    }
                }
                m_listFile.Clear();
                if (nRet > 0)
                {
                    if (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[m_nCurPage] = searchInfo;
                        m_nCurPage = 1;
                        m_nSearchInfo[m_nCurPage].nChannelN0         = nChannel;
                        m_nSearchInfo[m_nCurPage].nFileType          = nFileType;
                        m_nSearchInfo[m_nCurPage].startTime.dwYear   = szSend[m_nCurRecNum - 1].stEndTime.year;
                        m_nSearchInfo[m_nCurPage].startTime.dwMonth  = szSend[m_nCurRecNum - 1].stEndTime.month;
                        m_nSearchInfo[m_nCurPage].startTime.dwDay    = szSend[m_nCurRecNum - 1].stEndTime.day;
                        m_nSearchInfo[m_nCurPage].startTime.dwHour   = szSend[m_nCurRecNum - 1].stEndTime.hour;
                        m_nSearchInfo[m_nCurPage].startTime.dwMinute = szSend[m_nCurRecNum - 1].stEndTime.minute;
                        m_nSearchInfo[m_nCurPage].startTime.dwSecond = szSend[m_nCurRecNum - 1].stEndTime.second;
                        m_nSearchInfo[m_nCurPage].endTime            = searchInfo.endTime;

                        m_nGetPage++;

                        if (nNum < PLAYBACK_MAX_FILE_NUM)
                        {
                            m_nTotalPage = m_nGetPage;
                        }

                        AddFileListInfo(m_nCurRecNum);//add list item
                        SetPageBtnState(nNum);
                    }
                    else
                    {
                        MessageBox.Show("No File");
                    }
                }
                else
                {
                    MessageBox.Show("SearchFail");
                }
            }
        }