public bool StartPlayback(CameraInfo camera, VideoSourceInfo videoSourceInfo, VideoControl vc, DateTime start, DateTime end) { if (vc.Locked == true)//图像被锁定 { return(false); } this.LogModule?.Debug($"准备打开回放: ({camera.ID}){camera.Name} 设备:{videoSourceInfo.IP}:{videoSourceInfo.Port} 连接码:{camera.CameraCode} 时间:{start}--{end}"); vc.ErrorMessage = ""; //关闭已经打开的视频 if (vc.Mode != ShowMode.Stop) { this.StopVideo(vc); } VideoSourceBase vs = this.getVideoSourceByType(videoSourceInfo.Type); if (vs == null) { this.LogModule?.Error("未支持的设备类型"); return(false); } camera.VideoSourceInfo = videoSourceInfo; bool ret = vs.StartPlaybackByTime(camera, vc, start, end); if (ret == true) { vc.Mode = ShowMode.Playback; this.m_VideoControlTable[vc] = vs; vc.CurrentCamera = camera; vc.PBStatus = VideoControl.PB_Status.Play; } return(ret); }
private void changeStreamIndex(VideoControlActionEventArgs vca) { if (this.config.AutoChangeStreamIndex == false) { return; } if (vca.Camera == null) { return; } if (vca.VControl.CurrentCamera == null) { return; } if (vca.VControl.Mode != ShowMode.Real) { return; } VideoSourceBase vs = this.getVideoSourceByVideoControl(vca.VControl); VideoPanel panel = this.m_VideoPanelTable[vca.VControl.VideoPanelID] as VideoPanel; //if (vca.VControl.IsMax) // vs?.ChangeStreamIndex(vca.VControl.VControl, 0); //else //{ // if (this.CurLayout.ControlList.Count > 4) // { // this.m_StreamManager.ChangeStreamIndex(vca.VControl.VControl, 1); // } //} }
public bool StartPreview(CameraInfo camera, VideoSourceInfo videoSourceInfo, VideoControl vc, int streamIndex = 0) { if (vc.Locked == true)//图像被锁定 { return(false); } vc.ErrorMessage = ""; this.LogModule?.Debug($"准备打开实时预览: ({camera.ID}){camera.Name} 设备:{videoSourceInfo.IP}:{videoSourceInfo.Port} 连接码:{camera.CameraCode}"); //关闭已经打开的视频 if (vc.Mode != ShowMode.Stop) { this.StopVideo(vc); } VideoSourceBase vs = this.getVideoSourceByType(videoSourceInfo.Type); if (vs == null) { this.LogModule?.Error("未支持的设备类型"); return(false); } camera.VideoSourceInfo = videoSourceInfo; bool ret = vs.StartPreview(camera, vc, streamIndex); if (ret == true) { vc.Mode = ShowMode.Real; this.m_VideoControlTable[vc] = vs; vc.CurrentCamera = camera; } return(ret); }
private void closeVideo(VideoControl vc) { VideoSourceBase vs = this.getVideoSourceByVideoControl(vc); switch (vc.Mode) { case ShowMode.Real: vs?.StopPreview(vc); break; case ShowMode.Playback: case ShowMode.PlayFile: vs?.StopPlayback(vc); break; default: break; } }
private void Vc_PtzEvent(object sender, PTZControlArgs args) { VideoSourceBase vs = this.m_VideoControlTable[args.VideoControl] as VideoSourceBase; switch (args.Type) { case PTZControlArgs.PtzType.Direction: vs?.Ptz_DirCamera(args.VideoControl, args.dirDirection, args.hSpeed, args.vSpeed); break; case PTZControlArgs.PtzType.Len: vs?.Ptz_LenCamera(args.VideoControl, args.lenType); break; case PTZControlArgs.PtzType.AutoFindDirection: //vs?.Client_CameraAutoFindDirection(args.VideoControl,args.ol) //todo break; default: break; } }
/// <summary> /// 关闭视频 /// </summary> /// <param name="vc"></param> public void StopVideo(VideoControl vc) { VideoSourceBase vs = this.getVideoSourceByVideoControl(vc); switch (vc.Mode) { case ShowMode.Real: vs?.StopPreview(vc); break; case ShowMode.Playback: case ShowMode.PlayFile: vs?.StopPlayback(vc); vc.PBStatus = VideoControl.PB_Status.BeforeStart; break; default: break; } vc.Mode = ShowMode.Stop; vc.CurrentCamera = null; this.m_VideoControlTable[vc] = null; vc.ErrorMessage = ""; }
private void snap(VideoControl vc) { VideoSourceBase vs = this.getVideoSourceByVideoControl(vc); bool? ret = false; string file = ""; switch (vc.Mode) { case ShowMode.Real: file = getFileName(DateTime.Now); ret = vs?.Snap(vc, file); //this.SnapPicture(vca.VControl); break; case ShowMode.Playback: DateTime time = DateTime.Now; vs.PB_GetCurTime(vc, out time); file = getFileName(time); ret = vs?.PB_Snap(vc, file); break; } if (ret == true) { this.SnapEvent?.Invoke(this, new Event.SnapEventArgs() { VC = vc, FileName = file }); } //获取文件名 string getFileName(DateTime time) { CameraInfo camera = vc.CurrentCamera; string fileName = $"{ FileHelper.GetCorrectFileName(camera.Name)}{time.ToString("yyyyMMddhhmmss")}.jpg"; if (string.IsNullOrEmpty(this.config.SnapPath) == true) { System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "JPG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp|AllFile(*.*)|*.*"; sfd.FilterIndex = 1; sfd.DefaultExt = "jpg"; sfd.FileName = fileName; if (sfd.ShowDialog() == DialogResult.OK) { fileName = sfd.FileName; } } else { if (this.config.SnapPath.EndsWith("\\") == false) { this.config.SnapPath += "\\"; } fileName = $"{this.config.SnapPath}{fileName}"; } return(fileName); } }