示例#1
0
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (-1 != m_nIndex)
            {
                XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.Handle);
                ClientDemo clientdemo = (ClientDemo)this.Parent;
                clientdemo.DrawActivePage(false);

                foreach (TreeNode node in clientdemo.devForm.DevTree.Nodes)
                {
                    if (node.Name == "Device")
                    {
                        foreach (TreeNode channelnode in node.Nodes)
                        {
                            if (channelnode.Name == "Channel")
                            {
                                CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag;
                                if (chInfo.nWndIndex == m_nIndex)
                                {
                                    chInfo.nWndIndex = -1;
                                    channelnode.Tag  = chInfo;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
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);
        }
示例#3
0
        public int SetDevChnColor(ref SDK_CONFIG_VIDEOCOLOR pVideoColor)
        {
            IntPtr ptr = new IntPtr();

            Marshal.StructureToPtr(pVideoColor, ptr, true);
            return(XMSDK.H264_DVR_SetDevConfig(m_lLogin, (uint)SDK_CONFIG_TYPE.E_SDK_VIDEOCOLOR, m_iChannel, ptr, (uint)Marshal.SizeOf(pVideoColor), 3000));
        }
示例#4
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            // fileDialog.InitialDirectory = "d:\\";
            fileDialog.Title            = "选择文件";
            fileDialog.Filter           = "h264 files (*.h264)|*.h264";
            fileDialog.FilterIndex      = 1;
            fileDialog.RestoreDirectory = true;

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                String fileName = fileDialog.FileName;
                // 使用文件名
                m_nLocalplayHandle = Convert.ToInt32(XMSDK.H264_DVR_StartLocalPlay(fileName, pictureBoxVideoWnd.Handle, null, Convert.ToUInt32(0)));
                if (m_nLocalplayHandle > 0)
                {
                    //   MessageBox.Show("success");
                    timerLocalPlayBack.Elapsed  += new System.Timers.ElapsedEventHandler(recordTime);
                    timerLocalPlayBack.AutoReset = true;
                    timerLocalPlayBack.Enabled   = true;
                    XMSDK.fLocalPlayFileCallBack fileEndCallBack = new XMSDK.fLocalPlayFileCallBack(FileEndCallBack);
                    XMSDK.H264_DVR_SetFileEndCallBack(m_nLocalplayHandle, fileEndCallBack, this.Handle);
                }
                else
                {
                    MessageBox.Show("failed");
                }
            }
            else
            {
                // 没有选择文件时的操作
            }
        }
示例#5
0
        bool StartTalk(ref DEV_INFO pDevice)
        {
            IntPtr pdev = new IntPtr();

            Marshal.StructureToPtr(pDevice, pdev, false);

            unsafe
            {
                if (pdev.ToPointer() == null)
                {
                    return(false);
                }

                if (m_lTalkHandle.ToPointer() == null)
                {
                    return(false);
                }
                else
                {
                    m_lTalkHandle = (IntPtr)XMSDK.H264_DVR_StartLocalVoiceCom(pDevice.lLoginID);
                    if (m_lTalkHandle != (IntPtr)null)
                    {
                        return(true);
                    }
                    else
                    {
                        m_lTalkHandle = (IntPtr)null;;
                        return(false);
                    }
                }
            }
        }
示例#6
0
 private void btnLocalPause_Click(object sender, EventArgs e)
 {
     if (XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_PAUSE, 0))
     {
         m_bPauseLocalPlay = true;
     }
 }
示例#7
0
        void DisConnectBackCallFunc(int lLoginID, string pchDVRIP, int nDVRPort, IntPtr dwUser)
        {
            for (int i = 0; i < 16; i++)
            {
                if (lLoginID == m_videoform[i].GetLoginHandle())
                {
                    m_videoform[i].OnDisconnct();
                }
            }


            foreach (DEV_INFO devinfo in dictDevInfo.Values)
            {
                if (devinfo.lLoginID == lLoginID)
                {
                    XMSDK.H264_DVR_Logout(lLoginID);
                    dictDevInfo.Remove(devinfo.lLoginID);
                    dictDiscontDev.Add(devinfo.lLoginID, devinfo);
                    break;
                }
            }

            if (dictDiscontDev.Count > 0)
            {
                timerDisconnect.Enabled = true;
                timerDisconnect.Start();
            }
        }
示例#8
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",
                                               "c:",
                                               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);
        }
示例#9
0
 public bool OnCloseSound()
 {
     if (XMSDK.H264_DVR_CloseSound(m_iPlayhandle))
     {
         m_bSound = false;
         return(true);
     }
     return(false);
 }
示例#10
0
 public bool OnOpenSound()
 {
     if (XMSDK.H264_DVR_OpenSound(m_iPlayhandle))
     {
         m_bSound = true;
         return(true);
     }
     return(false);
 }
示例#11
0
        private void ClientDemo_FormClosed(object sender, FormClosedEventArgs e)
        {
            foreach (DEV_INFO devinfo in dictDevInfo.Values)
            {
                XMSDK.H264_DVR_Logout(devinfo.lLoginID);
            }

            timerDisconnect.Stop();
        }
示例#12
0
 private void btnLocalStop_Click(object sender, EventArgs e)
 {
     if (XMSDK.H264_DVR_StopLocalPlay(m_nLocalplayHandle))
     {
         m_nLocalplayHandle = 0;
     }
     timerLocalPlayBack.Enabled = false;
     trackBarLocalPlayPos.Value = 0;
 }
示例#13
0
 void FileEndCallBack(uint lPlayHand, uint nUser)
 {
     if (XMSDK.H264_DVR_StopLocalPlay(m_nLocalplayHandle))
     {
         m_nLocalplayHandle = 0;
     }
     timerLocalPlayBack.Enabled = false;
     trackBarLocalPlayPos.Value = 0;
 }
示例#14
0
 private void btnLocalSlow_Click(object sender, EventArgs e)
 {
     if (++m_nSlowTypeLocal > 4)
     {
         m_nSlowTypeLocal = 1;
     }
     m_nFastTypeLocal = 0;
     XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_SLOW, Convert.ToUInt32(m_nSlowTypeLocal));
 }
示例#15
0
 private void btnNetSlow_Click(object sender, EventArgs e)
 {
     if (++m_nSlowTypeNet > 4)
     {
         m_nSlowTypeNet = 1;
     }
     m_nFastTypeNet = 0;
     XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_SLOW, m_nSlowTypeNet);
 }
 private void button_close_Click(object sender, EventArgs e)
 {
     if (XMSDK.H264_DVR_CloseTransComChannel(lLoginID, SERIAL_TYPE.RS485))
     {
         MessageBox.Show(@"close ok");
     }
     else
     {
         MessageBox.Show(@"close wrong");
     }
 }
示例#17
0
 private void btnNetPause_Click(object sender, EventArgs e)
 {
     if (!m_bPauseNetPlay)
     {
         XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_PAUSE, 0);
     }
     else
     {
         XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_CONTINUE, 0);
     }
     m_bPauseNetPlay = !m_bPauseNetPlay;
 }
示例#18
0
 private void btnNetPlayStop_Click(object sender, EventArgs e)
 {
     timerNetPlayBack.Enabled = false;
     if (m_nNetPlayHandle >= 0)
     {
         XMSDK.H264_DVR_StopPlayBack(m_nNetPlayHandle);
         m_nNetPlayHandle = 0;
     }
     trackBarNetPlayPos.Value = 0;
     m_bOpenAudio             = false;
     m_bPauseNetPlay          = false;
 }
        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;
            }
        }
示例#20
0
        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;
            }
        }
示例#21
0
 bool StopTalk(ref DEV_INFO pDevice)
 {
     unsafe
     {
         if (m_lTalkHandle.ToPointer() != null)
         {
             XMSDK.H264_DVR_StopVoiceCom(m_lTalkHandle.ToInt32());
             m_lTalkHandle = (IntPtr)null;
             return(true);
         }
         return(false);
     }
 }
示例#22
0
 public void OnDisconnct()
 {
     if (m_iPlayhandle > 0)
     {
         XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.Handle);
         m_iPlayhandle = -1;
     }
     if (m_bSound)
     {
         OnCloseSound();
     }
     m_lLogin = -1;
 }
        private void btn_Drag_Scroll(object sender, EventArgs e)
        {
            if (!m_bDownloadByTime)
            {
                m_SliderPos = trackBarNetPlayPos.Value;
                m_PreTime   = System.DateTime.Now.Ticks;

                timerNetPlayBack.Stop();
                XMSDK.H264_DVR_SetPlayPos(m_nNetPlayHandle, m_SliderPos / (float)1000.0);
                Thread.Sleep(200);
                timerNetPlayBack.Start();
            }
        }
        private void button_write_Click(object sender, EventArgs e)
        {
            string strWrite = this.textBox_write.Text.ToString();

            if (XMSDK.H264_DVR_SerialWrite(lLoginID, SERIAL_TYPE.RS485, strWrite, strWrite.Length))
            {
                MessageBox.Show(@"write ok");
            }
            else
            {
                MessageBox.Show(@"write wrong");
            }
        }
示例#25
0
        public void recordTime(object source, System.Timers.ElapsedEventArgs e)
        {
            if (!m_bPauseLocalPlay)
            {
                float pos = XMSDK.H264_DVR_GetPlayPos(m_nLocalplayHandle);
                trackBarLocalPlayPos.Value = Convert.ToInt32(pos * 1000);
            }

            if (!m_bPauseNetPlay)
            {
                float pos = XMSDK.H264_DVR_GetPlayPos(m_nNetPlayHandle);
                trackBarNetPlayPos.Value = Convert.ToInt32(pos * 1000);
            }

            if (m_DownLoadFileHandle != 0)
            {
                int nPos = XMSDK.H264_DVR_GetDownloadPos(m_DownLoadFileHandle);
                if (nPos < 0)           //fail
                {
                    XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle);
                    progressBarDownloadPos.Value = 0;
                    m_DownLoadFileHandle         = 0;
                    btnDownload.Text             = "Download";
                    MessageBox.Show("Get download process fail !");
                    timerDownload.Stop();
                }
                if (nPos == 100)                //download end
                {
                    XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle);
                    m_DownLoadFileHandle = 0;

                    timerDownload.Stop();
                    progressBarDownloadPos.Value = 0;
                    btnDownload.Text             = "Download";
                    MessageBox.Show("Download Finished");
                    return;
                }
                if (nPos > 100)         //abnormal
                {
                    XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle);
                    m_DownLoadFileHandle         = 0;
                    progressBarDownloadPos.Value = 0;
                    btnDownload.Text             = "Download";
                    MessageBox.Show("Download Error");
                }
                else
                {
                    progressBarDownloadPos.Value = nPos;
                }
            }
        }
示例#26
0
        public void GetColor(out int nBright, out int nContrast, out int nSaturation, out int nHue)
        {
            if (m_iPlayhandle <= 0)
            {
                nBright     = -1;
                nContrast   = -1;
                nSaturation = -1;
                nHue        = -1;
                return;
            }
            uint nRegionNum = 0;

            XMSDK.H264_DVR_LocalGetColor(m_iPlayhandle, nRegionNum, out nBright, out nContrast, out nSaturation, out nHue);
        }
示例#27
0
 public void NetAlarmMsg(uint dwValue, uint dwState)
 {
     if (m_devInfo.lLoginID > 0)
     {
         SDK_NetAlarmInfo vAlarmInfo;
         vAlarmInfo.iEvent = 0;
         vAlarmInfo.iState = (int)(dwState << (int)dwValue);
         m_nCurIndex       = m_nCurIndex < 0 ? 0 : m_nCurIndex;
         if (!XMSDK.H264_DVR_SendNetAlarmMsg(m_devInfo.lLoginID, ref vAlarmInfo))
         {
             MessageBox.Show("AccountMSG.Failed");
         }
     }
 }
示例#28
0
        public int InitSDK()
        {
            //initialize
            disCallback = new XMSDK.fDisConnect(DisConnectBackCallFunc);
            GC.KeepAlive(disCallback);
            int bResult = XMSDK.H264_DVR_Init(disCallback, this.Handle);

            //he messages received in SDK from DVR which need to upload, such as alarm information,diary information,may do through callback function
            msgcallback = new XMSDK.fMessCallBack(MessCallBack);
            XMSDK.H264_DVR_SetDVRMessCallBack(msgcallback, this.Handle);

            XMSDK.H264_DVR_SetConnectTime(5000, 3);

            return(bResult);
        }
示例#29
0
        private void PlayBackForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (m_nNetPlayHandle > 0)
            {
                XMSDK.H264_DVR_StopPlayBack(m_nNetPlayHandle);
                m_nNetPlayHandle = -1;
            }


            ClearResult();
            //ClearMapResult();
            timerLocalPlayBack.Stop();
            timerDownload.Stop();
            timerNetPlayBack.Stop();
        }
示例#30
0
        private void PTZControl(int nCommand, bool bStop, int nSpeed)
        {
            ClientDemo clientForm    = (ClientDemo)this.Owner;
            int        nCurVideoform = clientForm.m_nCurIndex;

            if (nCurVideoform >= 0)
            {
                int nPlayHandel = clientForm.m_videoform[nCurVideoform].m_iPlayhandle;
                if (nPlayHandel > 0)
                {
                    int nLoginID = clientForm.m_videoform[nCurVideoform].m_lLogin;
                    int nChannel = clientForm.m_videoform[nCurVideoform].m_iChannel;
                    XMSDK.H264_DVR_PTZControl(nLoginID, nChannel, (int)nCommand, bStop, nSpeed);
                }
            }
        }