private void btnOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Title            = "Select video file";
            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)
                {
                    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
            {
            }
        }
        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 btnLocalPause_Click(object sender, EventArgs e)
 {
     if (XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_PAUSE, 0))
     {
         m_bPauseLocalPlay = true;
     }
 }
Esempio n. 4
0
        void DisConnectBackCallFunc(int lLoginID, string pchDVRIP, int nDVRPort, IntPtr dwUser)
        {
            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".DisConnectBackCallFunc(" + lLoginID.ToString() + "," + pchDVRIP + "," + nDVRPort.ToString() + ",dwUser" + ")", "DVR INFO");

            isConnected  = false;
            chanelOpened = 0;

            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();
            }
        }
Esempio n. 5
0
        public void Close()
        {
            if (-1 != m_nIndex)
            {
                decodeRuning = false;
                XMSDK.H264_DVR_DelRealDataCallBack_V2(m_iPlayhandle, realDataCallBack_V2, Handle.ToInt32());

                XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.panelVideo.Handle);
                DVR2Mjpeg DVR2Mjpeg = (DVR2Mjpeg)Parent;
                DVR2Mjpeg.DrawActivePage(false);

                foreach (TreeNode node in DVR2Mjpeg.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;
                                }
                            }
                        }
                    }
                }

                deleteImageOnServer();
            }
        }
Esempio n. 6
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));
        }
Esempio n. 7
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);
                    }
                }
            }
        }
Esempio n. 8
0
 private void DVR2Mjpeg_FormClosed(object sender, FormClosedEventArgs e)
 {
     foreach (DEV_INFO devinfo in dictDevInfo.Values)
     {
         XMSDK.H264_DVR_Logout(devinfo.lLoginID);
     }
     timerDisconnect.Stop();
 }
 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);
 }
Esempio n. 10
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;
 }
Esempio n. 11
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));
 }
Esempio n. 12
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);
        }
Esempio n. 13
0
 public bool OnCloseSound()
 {
     if (XMSDK.H264_DVR_CloseSound(m_iPlayhandle))
     {
         m_bSound = false;
         return(true);
     }
     return(false);
 }
Esempio n. 14
0
 public bool OnOpenSound()
 {
     if (XMSDK.H264_DVR_OpenSound(m_iPlayhandle))
     {
         m_bSound = true;
         return(true);
     }
     return(false);
 }
Esempio n. 15
0
 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");
     }
 }
Esempio n. 16
0
        private void catchPictureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //return;
            if (m_nIndex > -1 && m_iPlayhandle > 0 && m_bSaveImageStart == false)
            {
                String    strPath;
                DVR2Mjpeg DVR2Mjpeg = (DVR2Mjpeg)Parent;

                foreach (TreeNode node in DVR2Mjpeg.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)
                                {
                                    strPath = String.Format(@"Z:\Pictures\bmp\{0}.bmp", m_nIndex + 1);

                                    bool bCatch = false;

                                    m_bSaveImageStart = true;

                                    try
                                    {
                                        if (DVR2Mjpeg.isConnected)
                                        {
                                            bCatch = XMSDK.H264_DVR_LocalCatchPic(m_iPlayhandle, strPath);
                                        }
                                    }
                                    catch (AccessViolationException ex)
                                    {
                                        Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".catchPictureToolStripMenuItem_Click.AccessViolationException", "DVR ERROR");
                                        Debug.WriteLine(ex.ToString());
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".catchPictureToolStripMenuItem_Click.Exception", "DVR ERROR");
                                        Debug.WriteLine(ex.ToString());
                                    }

                                    m_bSaveImageStart = false;

                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 17
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;
            }
        }
Esempio n. 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;
 }
Esempio n. 19
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;
 }
Esempio n. 20
0
        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");
            }
        }
Esempio n. 21
0
        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();
            }
        }
Esempio n. 22
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);
     }
 }
Esempio n. 23
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);
        }
Esempio n. 24
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();
        }
Esempio n. 25
0
        private void PTZControl(int nCommand, bool bStop, int nSpeed)
        {
            DVR2Mjpeg clientForm    = (DVR2Mjpeg)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);
                }
            }
        }
Esempio n. 26
0
        void FileEndCallBack(uint lPlayHand, uint nUser)
        {
            if (XMSDK.H264_DVR_StopLocalPlay(m_nLocalplayHandle))
            {
                m_nLocalplayHandle = 0;
            }
            timerLocalPlayBack.Enabled = false;

            if (InvokeRequired)
            {
                BeginInvoke((MethodInvoker)(() => trackBarLocalPlayPos.Value = 0));
            }
            else
            {
                trackBarLocalPlayPos.Value = 0;
            }
        }
Esempio n. 27
0
        public int InitSDK()
        {
            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss - ") + TAG + ".InitSDK()", "DVR INFO");

            //initialize
            disCallback = new XMSDK.fDisConnect(DisConnectBackCallFunc);
            GC.KeepAlive(disCallback);
            int bResult = XMSDK.H264_DVR_Init(disCallback, Handle);

            msgcallback = new XMSDK.fMessCallBack(MessCallBack);
            GC.KeepAlive(msgcallback);
            XMSDK.H264_DVR_SetDVRMessCallBack(msgcallback, Handle);

            XMSDK.H264_DVR_SetConnectTime(5000, 25);

            return(bResult);
        }
Esempio n. 28
0
        int DevLogin(ref DEV_INFO pdev)
        {
            if (Convert.ToBoolean(pdev.bSerialID))
            {
                int         maxDeviceNum = 100;
                DDNS_INFO[] pDDNSInfo    = new DDNS_INFO[maxDeviceNum];
                SearchMode  searchmode;
                int         nReNum = 0;
                searchmode.nType        = (int)SearchModeType.DDNS_SERIAL;
                searchmode.szSerIP      = pdev.szSerIP;
                searchmode.nSerPort     = pdev.nSerPort;
                searchmode.szSerialInfo = pdev.szSerialInfo;
                bool bret = Convert.ToBoolean(XMSDK.H264_DVR_GetDDNSInfo(ref searchmode, out pDDNSInfo, maxDeviceNum, out nReNum));
                if (!bret)
                {
                    return(0);
                }
                pdev.szIpaddress = pDDNSInfo[0].IP;
                pdev.nPort       = pDDNSInfo[0].MediaPort;
            }

            H264_DVR_DEVICEINFO OutDev;
            int nError = 0;

            XMSDK.H264_DVR_SetConnectTime(3000, 1);

            int lLogin = XMSDK.H264_DVR_Login(pdev.szIpaddress, Convert.ToUInt16(pdev.nPort), pdev.szUserName,
                                              pdev.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET);

            if (lLogin <= 0)
            {
                int nErr = XMSDK.H264_DVR_GetLastError();
                if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID)
                {
                    MessageBox.Show("Error.PwdErr");
                }
                else
                {
                    MessageBox.Show("Error.NotFound");
                }
                return(lLogin);
            }
            XMSDK.H264_DVR_SetupAlarmChan(lLogin);
            return(lLogin);
        }
Esempio n. 29
0
        private void button_login_Click(object sender, EventArgs e)
        {
            H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO();
            short         nError       = 0;
            StringBuilder strIP        = new StringBuilder(this.textBox_ip.Text.ToString().Trim());
            ushort        usPort       = Convert.ToUInt16(this.textBox_port.Text.ToString().Trim());
            StringBuilder strUserName  = new StringBuilder(this.textBox_username.Text.ToString());
            StringBuilder strPassword  = new StringBuilder(this.textBox_password.Text.ToString());

            lLoginID = XMSDK.H264_DVR_Login(strIP, usPort, strUserName, strPassword, out OutDev, out nError, SocketStyle.TCPSOCKET);
            if (lLoginID <= 0)
            {
                MessageBox.Show(@"login wrong");
            }
            else
            {
                MessageBox.Show(@"login ok");
            }
        }
Esempio n. 30
0
        private void btnLocalPlay_Click(object sender, EventArgs e)
        {
            if (m_bPauseLocalPlay)
            {
                XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_CONTINUE, 0);
                m_bPauseLocalPlay = false;
            }

            if (m_nSlowTypeLocal != 0)
            {
                XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_SLOW, 0);
            }
            if (m_nFastTypeLocal != 0)
            {
                XMSDK.H264_DVR_LocalPlayCtrl(m_nLocalplayHandle, SDK_LoalPlayAction.SDK_Local_PLAY_FAST, 0);
            }
            m_nSlowTypeLocal = 0;
            m_nFastTypeLocal = 0;
        }