private IVideoSourceConfig GetBackPlayVSConfig(IVideoSourceConfig vsConfig, IAlarmInfo alarmInfo) { CVideoSourceConfig newVSConfig = vsConfig.Clone() as CVideoSourceConfig; if (newVSConfig != null) { newVSConfig.Name = vsConfig.Name + "_BackPlay_" + newVSConfig.Handle; newVSConfig.StartTime = alarmInfo.AlarmTime.AddSeconds(-10); newVSConfig.StopTime = alarmInfo.AlarmTime; newVSConfig.IsRecord = false; newVSConfig.IsCycle = false; newVSConfig.Enabled = true; } IVideoSourceType vsType = vsConfig.SystemContext.VideoSourceTypeManager.GetConfig(vsConfig.Type); if (vsType != null) { string backPlayType = vsType.BackPlayType; if (!backPlayType.Equals("")) { newVSConfig.Type = backPlayType; newVSConfig.FileName = ""; } } return(newVSConfig); }
private Image GetFrame(IVideoSourceConfig config, int delay) { Image image = null; if (config != null) { IVideoSource vs = config.SystemContext.VideoSourceManager.GetVideoSource(config.Name); if (vs != null && vs.IsPlay) { image = vs.GetFrame(); } else { IVideoSourceConfig tempVSConfig = config.Clone() as IVideoSourceConfig; if (tempVSConfig != null) { tempVSConfig.ACEnabled = false; ((CVideoSourceConfig)tempVSConfig).Name += ("_" + tempVSConfig.Handle); vs = config.SystemContext.VideoSourceManager.Open(tempVSConfig, IntPtr.Zero); if (vs != null) { vs.Play(); if (delay > 0) { Thread.Sleep(delay); } int n = 3; image = vs.GetFrame(); while (image == null) { n--; if (n < 0) { break; } Thread.Sleep(100); image = vs.GetFrame(); } config.SystemContext.VideoSourceManager.Close(vs.Name); } } } } if (image != null) { label_imageSize.Text = string.Format("ͼÏñ³ß´ç£º{0}X{1}", image.Width, image.Height); } return(image); }
public bool Preview() { if (mRealPlayVS != null && mRealPlayVS.IsOpen) { mRealPlayVS.SystemContext.VideoSourceManager.Close(mRealPlayVS.Name); } else { CFuncNode node = mLinkObj as CFuncNode; if (node != null) { IVisionMonitorConfig config = node.ExtConfigObj as IVisionMonitorConfig; if (config != null) { IVideoSourceConfig vsConfig = config.SystemContext.VideoSourceConfigManager.GetConfig(config.VisionParamConfig.VSName); CVideoSourceConfig newVSConfig = vsConfig.Clone() as CVideoSourceConfig; if (newVSConfig != null) { newVSConfig.Name = vsConfig.Name + "_RealPlay_" + newVSConfig.Handle; newVSConfig.Enabled = true; if (mRealPlayVS != null) { mRealPlayVS.SystemContext.VideoSourceManager.Close(mRealPlayVS.Name); mRealPlayVS = null; } mRealPlayVS = config.SystemContext.VideoSourceManager.Open(newVSConfig, HWnd); if (mRealPlayVS != null) { mRealPlayVS.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged); return(mRealPlayVS.Play()); } } } } } return(false); }
public bool Playback() { if (mBackPlayVS != null && mBackPlayVS.IsOpen) { mBackPlayVS.SystemContext.VideoSourceManager.Close(mBackPlayVS.Name); } else if (mCurIndex >= 0 && mCurIndex < Count) { IVisionMonitorAlarm visionAlarm = Goto(mCurIndex) as IVisionMonitorAlarm; if (visionAlarm != null) { IVisionMonitor monitor = visionAlarm.Monitor as IVisionMonitor; if (monitor != null) { IVisionMonitorConfig config = monitor.Config as IVisionMonitorConfig; if (config != null) { IVideoSourceConfig vsConfig = monitor.SystemContext.VideoSourceConfigManager.GetConfig(config.VisionParamConfig.VSName); if (vsConfig != null) { if (!vsConfig.IsRecord) { IVideoSourceType vsType = vsConfig.SystemContext.VideoSourceTypeManager.GetConfig(vsConfig.Type); if (vsType != null) { string backPlayType = vsType.BackPlayType; if (backPlayType.Equals("")) { backPlayType = vsConfig.Type; } if (!backPlayType.Equals("")) { CVideoSourceConfig newVSConfig = vsConfig.Clone() as CVideoSourceConfig; if (newVSConfig != null) { newVSConfig.Name = vsConfig.Name + "_BackPlay_" + newVSConfig.Handle; newVSConfig.Type = backPlayType; newVSConfig.StartTime = visionAlarm.AlarmTime.AddSeconds(-10); newVSConfig.StopTime = visionAlarm.AlarmTime; if (!backPlayType.Equals("FileVideoSource")) { newVSConfig.FileName = ""; } newVSConfig.IsRecord = false; newVSConfig.IsCycle = false; newVSConfig.Enabled = true; if (mBackPlayVS != null) { mBackPlayVS.SystemContext.VideoSourceManager.Close(mBackPlayVS.Name); mBackPlayVS = null; } mBackPlayVS = vsType.SystemContext.VideoSourceManager.Open(newVSConfig, HWnd); if (mBackPlayVS != null) { mBackPlayVS.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged); if (!mBackPlayVS.Play()) { MessageBox.Show("回放失败,可能是回放录像还未生成,请稍后再试!", "回放错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("打开录像失败,可能是回放录像还未生成,请稍后再试!", "回放错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } return(true); } } } } if (!visionAlarm.IsRecord && !visionAlarm.IsPlay) { return(visionAlarm.PlayAlarmRecord(HWnd)); } } } return(false); }