public bool login() { if (this.monitor == null) { MessageBox.Show("未指定监控器!"); return(false); } toolStripStatusLabel.Text = "正在登陆监控控制器!"; H264_DVR_DEVICEINFO dvrdevInfo = new H264_DVR_DEVICEINFO(); int nError; int nLoginID = XMSDK.H264_DVR_Login(monitor.nvrDevice.IP, (ushort)monitor.nvrDevice.port, monitor.nvrDevice.username, monitor.nvrDevice.password, out dvrdevInfo, out nError, SocketStyle.TCPSOCKET); if (nLoginID <= 0) { int iLastErr = XMSDK.H264_DVR_GetLastError(); string str = "H264_DVR_Login failed, error code= " + iLastErr + "!登录失败,请检查配置参数,并重新启动!"; //登录失败,输出错误号 toolStripStatusLabel.Text = "H264_DVR_Login failed, error code= " + iLastErr + "!登录失败,请检查配置参数,并重新启动!"; MessageBox.Show(str); return(false); } this.monitor.nvrDevice.userID = nLoginID; XMSDK.H264_DVR_SetupAlarmChan(nLoginID); toolStripStatusLabel.Text = "就绪!"; return(true); }
public void logout(NVRDevice device) { if (device.userID > 0) { XMSDK.H264_DVR_Logout(device.userID); device.userID = -1; } }
public bool closeSound() { if (XMSDK.H264_DVR_CloseSound(m_iPlayhandle)) { m_bSound = false; return(true); } return(false); }
private bool m_bSound = false; //声音 public bool preview() { if (this.monitor == null) { MessageBox.Show("未指定监控器!"); return(false); } //if device did not login,login first if (this.monitor.nvrDevice.userID <= 0) { bool loginSuccess = this.login(); if (!loginSuccess) { return(false); } } if (this.monitor.nvrDevice.userID > 0) { if (m_iPlayhandle != -1) { string thead = Thread.CurrentThread.Name; if (0 != XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.pictureBox.Handle)) { //TRACE("H264_DVR_StopRealPlay fail m_iPlayhandle = %d", m_iPlayhandle); } if (m_bSound) { closeSound(); } } H264_DVR_CLIENTINFO playstru = new H264_DVR_CLIENTINFO(); playstru.nChannel = this.monitor.channel; playstru.nStream = 0; playstru.nMode = 0; playstru.hWnd = this.pictureBox.Handle; m_iPlayhandle = XMSDK.H264_DVR_RealPlay(this.monitor.nvrDevice.userID, ref playstru); if (m_iPlayhandle <= 0) { Int32 dwErr = XMSDK.H264_DVR_GetLastError(); StringBuilder sTemp = new StringBuilder(""); sTemp.AppendFormat("登录 {0} 通道{1} 失败, 错误码 = {2}", this.monitor.nvrDevice.IP, this.monitor.channel, dwErr); MessageBox.Show(sTemp.ToString()); return(false); } else { XMSDK.H264_DVR_MakeKeyFrame(this.monitor.nvrDevice.userID, this.monitor.channel, 0); } } return(true); }
public void stop() { if (m_nNetPlayHandle > 0) { if (m_nNetPlayHandle >= 0) { XMSDK.H264_DVR_StopPlayBack(m_nNetPlayHandle); m_nNetPlayHandle = 0; } m_bPauseNetPlay = false; m_nFastTypeNet = 0; m_nSlowTypeNet = 0; } }
public bool stopCurrentPreview() { if (m_iPlayhandle > 0) { XMSDK.H264_DVR_StopRealPlay(m_iPlayhandle, (uint)this.pictureBox.Handle); m_iPlayhandle = -1; } if (m_bSound) { closeSound(); } return(true); }
public void slow() { if (m_nNetPlayHandle > 0) { if (++m_nSlowTypeNet > 4) { m_nSlowTypeNet = 1; } m_nFastTypeNet = 0; XMSDK.H264_DVR_PlayBackControl(m_nNetPlayHandle, (int)PlayBackAction.SDK_PLAY_BACK_SLOW, m_nSlowTypeNet); } else { MessageBox.Show("未播放!"); } }
public void pause() { if (m_nNetPlayHandle > 0) { 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; } else { MessageBox.Show("未播放!"); } }
public bool init() { //initialize disCallback = new XMSDK.fDisConnect(DisConnectBackCallFunc); GC.KeepAlive(disCallback); int bResult = XMSDK.H264_DVR_Init(disCallback, pictureBox.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, pictureBox.Handle); //XMSDK.H264_DVR_SetConnectTime(5000, 3); XMSDK.H264_DVR_SetConnectTime(1000, 1); if (bResult <= 0) { MessageBox.Show("H264_DVR_Init error!配置参数错误,请检查配置文件!"); return(false); } return(true); }
public bool play(GateRecord gateRecord) { //if device did not login,login first if (this.monitor != null && this.monitor.nvrDevice != null && this.monitor.nvrDevice.userID <= 0) { bool loginSuccess = this.login(); if (!loginSuccess) { return(false); } } if (m_nNetPlayHandle == 0) { H264_DVR_FINDINFO info = new H264_DVR_FINDINFO(); //test by dyl info.nChannelN0 = monitor.channel; //channel No. info.nFileType = 0; //file type DateTime nvr_begintime = gateRecord.nvr_begintime; //DateTime nvr_begintime = DateTime.Parse("2014-12-30 21:30:00"); info.startTime.dwYear = nvr_begintime.Year; info.startTime.dwMonth = nvr_begintime.Month; info.startTime.dwDay = nvr_begintime.Day; info.startTime.dwHour = nvr_begintime.Hour; info.startTime.dwMinute = nvr_begintime.Minute; info.startTime.dwSecond = nvr_begintime.Second; DateTime nvr_endtime = gateRecord.nvr_endtime; //DateTime nvr_endtime = DateTime.Parse("2014-12-30 22:30:00"); info.endTime.dwYear = nvr_endtime.Year; info.endTime.dwMonth = nvr_endtime.Month; info.endTime.dwDay = nvr_endtime.Day; info.endTime.dwHour = nvr_endtime.Hour; info.endTime.dwMinute = nvr_endtime.Minute; info.endTime.dwSecond = nvr_endtime.Second; info.hWnd = (uint)this.pictureBox.Handle; XMSDK.fDownLoadPosCallBack DownloadCallback = new XMSDK.fDownLoadPosCallBack(DownLoadPosCallback); XMSDK.fRealDataCallBack realDataCallBack = new XMSDK.fRealDataCallBack(RealDataCallBack); m_nNetPlayHandle = XMSDK.H264_DVR_PlayBackByTimeEx(monitor.nvrDevice.userID, ref info, null, this.pictureBox.Handle.ToInt32(), null, this.pictureBox.Handle.ToInt32()); if (m_nNetPlayHandle <= 0) { int iLastErr = XMSDK.H264_DVR_GetLastError(); string str = "H264_DVR_PlayBackByTimeEx failed, 错误号= " + iLastErr + "!播放失败!"; //播放失败 MessageBox.Show(str); m_nNetPlayHandle = 0; return(false); } } 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; } return(true); }
public bool quit() { return(XMSDK.H264_DVR_Cleanup()); }