Beispiel #1
0
        public bool SaveRecord()
        {
            if (m_iPlayhandle <= 0)
            {
                return(false);
            }

            DateTime time      = DateTime.Now;
            String   cFilename = String.Format(@"{0}\\Record\\{1}{2}{3}_{4}{5}{6}.h264",
                                               "Z:",
                                               time.Year,
                                               time.Month,
                                               time.Day,
                                               time.Hour,
                                               time.Minute,
                                               time.Second);

            if (m_bRecord)
            {
                if (XMSDK.H264_DVR_StopLocalRecord(m_iPlayhandle))
                {
                    m_bRecord = false;
                    MessageBox.Show(@"stop record OK.");
                }
            }
            else
            {
                int    nTemp = 0;
                string strPr = "\\";
                for (; ;)
                {
                    int nIndex = cFilename.IndexOfAny(strPr.ToCharArray(), nTemp);
                    if (nIndex == -1)
                    {
                        break;
                    }
                    String str = cFilename.Substring(0, nIndex + 1);
                    nTemp = nIndex + 1; nTemp = nIndex + 1;
                    DirectoryInfo dir = new DirectoryInfo(str);
                    if (!dir.Exists)
                    {
                        dir.Create();
                    }
                }

                if (XMSDK.H264_DVR_StartLocalRecord(m_iPlayhandle, cFilename, (int)MEDIA_FILE_TYPE.MEDIA_FILE_NONE))
                {
                    m_bRecord = true;
                    MessageBox.Show(@"start record OK.");
                }
                else
                {
                    MessageBox.Show(@"start record fail.");
                }
            }
            return(true);
        }