public CVideoSource(IVideoSourceConfig config, IVideoDevice device, IVideoSourceFactory factory) : base() { mConfig = config; mDevice = device; mFactory = factory; }
public override IVideoSource CreateVideoSource(IVideoSourceConfig config, IntPtr hWnd) { try { IVideoDevice device = GetVideoDevice(config.IP, config.Port, config.UserName, config.Password, false); if (device != null) { IVideoSource vs = device.GetPlayer(config.Name); if (vs == null) { vs = device.InitRealPlayer(config, hWnd); } return(vs); } return(null); } catch (Exception e) { IConfig pc = config.GetValue("LinkConfig") as IConfig; if (pc != null) { pc.SetValue("ThrowException", e); } return(null); } }
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); }
public override IVideoSource CreateVideoSource(IVideoSourceConfig config, IntPtr hWnd) { if (!config.FileName.Equals("")) { string extension = System.IO.Path.GetExtension(config.FileName).ToUpper(); IVideoSource vs = null; if (extension.Equals(".AVI")) { vs = new AVIVideoSource(config, this, hWnd); } else if (extension.Equals(".BMP") || extension.Equals(".JPG")) { vs = new ImageVideoSource(config, this, hWnd); } else { throw new Exception(string.Format("无法播放不支持的文件类型:{0}", extension)); } return(vs); } return(null); }
private void dataGridView_alarm_record_SelectionChanged(object sender, EventArgs e) { BackPlayer.Close(); DataGridViewRow row = dataGridView_alarm_record.CurrentRow; if (row != null) { IAlarmInfo alarmInfo = row.Cells[1].Value as IAlarmInfo; if (alarmInfo != null) { if (!alarmInfo.VideoSource.Equals("")) { IVideoSourceConfig vsConfig = alarmInfo.GetVideoSourceConfig(); if (vsConfig != null) { IVideoSourceConfig backVSConfig = GetBackPlayVSConfig(vsConfig, alarmInfo); if (backVSConfig != null) { BackPlayer.Config = backVSConfig; BackPlayer.DefaultImage = alarmInfo.GetAlarmImage(); label_alarm_monitor.Text = alarmInfo.ToString(); label_alarm_type.Text = alarmInfo.GetAlarmType(); label_alarm_time.Text = alarmInfo.AlarmTime.ToString("yyyy年MM月dd日 HH时mm分ss秒"); label_transact_time.Text = alarmInfo.TransactTime.ToString("yyyy年MM月dd日 HH时mm分ss秒"); label_transact_user.Text = alarmInfo.Transactor; } } } } } }
public HKCardPlayer(IVideoSourceConfig config, IVideoSourceFactory factory, IntPtr hWnd) : base(config, null, factory) { HWnd = hWnd; Target = (Int32)config.Channel; }
private void button_play_Click(object sender, EventArgs e) { VideoPlayer player = videoPlayerManageCtrl1.ActiveBox; if (player != null) { if (player.Active) { player.Close(); player.Config = null; player.Refresh(); } else { IVideoSourceConfig vsConfig = null; TreeNode node = dataTreeView1.SelectedNode; if (node != null) { vsConfig = VSUtil.GetRealPlayConfig(node.Tag as DataRow); } if (vsConfig != null) { player.Config = vsConfig; player.Play(); } } } }
private void button_backplay_Click(object sender, EventArgs e) { VideoPlayer player = videoPlayerManageCtrl1.ActiveBox; if (player != null) { if (player.Active) { player.Close(); player.Config = null; player.Refresh(); } else { IVideoSourceConfig vsConfig = null; TreeNode node = dataTreeView1.SelectedNode; if (node != null) { vsConfig = VSUtil.GetBackPlayConfig(node.Tag as DataRow); //vsConfig.StopTime = DateTime.Now; //vsConfig.StartTime = vsConfig.StopTime.AddDays(-1); vsConfig.StartTime = dateTimePicker_begin.Value; vsConfig.StopTime = dateTimePicker_end.Value; } if (vsConfig != null) { player.Config = vsConfig; player.Play(); } } } }
protected bool SetConfig() { if (mConfig == null && mManager != null) { mConfig = mManager.CreateConfigInstance(); } if (mConfig != null) { (mConfig as CConfig).Name = textBox_name.Text; mConfig.SetValue("Name", textBox_name.Text); mConfig.Desc = textBox_desc.Text; mConfig.Type = CtrlUtil.GetComboBoxText(comboBox_type); mConfig.FPS = (int)numericUpDown_fps.Value; mConfig.IP = textBox_ip.Text; mConfig.Port = (short)numericUpDown_port.Value; mConfig.Channel = (int)numericUpDown_channel.Value; mConfig.ShowOSDType = (int)numericUpDown_osd.Value; mConfig.UserName = textBox_username.Text; mConfig.Password = textBox_password.Text; mConfig.IsRecord = checkBox_record.Checked; mConfig.Enabled = checkBox_enabled.Checked; return(true); } return(false); }
public BackPlayer() { InitializeComponent(); mTimer.Enabled = false; mTimer.Interval = 1000; mTimer.Tick += new EventHandler(OnTimerTick); mConfig = new CVideoSourceConfig(this.Name); mConfig.Type = "HKDVRBackPlayVideoSource"; mConfig.Enabled = true; ((CConfig)mConfig).SystemContext = CLocalSystem.ActiveSystem.SystemContext; mFactory = CLocalSystem.ActiveSystem.SystemContext.VideoSourceManager.GetVideoSourceFactory(mConfig) as CHKDVRBackPlayerFactory; //mPlayer = (MediaRecoPlay)CMonitorSystemContext.LocalSystemContext.VideoSourceManager.GetVideoSourceFactory(mConfig); //if (mPlayer != null) //{ // mPlayer.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStatusChanged); // mPlayer.OnRecordFileDownProgress += new RECORDFILE_DOWNPROGRESS(DoRecordFileDownProgress); //} toolStripButton_Fast.Enabled = false; toolStripButton_Slow.Enabled = false; toolStripButton_Frame.Enabled = false; toolStripButton_Normal.Enabled = false; }
public IVideoSourceFactory GetVideoSourceFactory(IVideoSourceConfig config) { if (config != null) { return(GetVideoSourceFactory(mSystemContext.VideoSourceTypeManager.GetConfig(config.Type))); } return(null); }
public StreamMediaVideoSource(StreamMediaClientManager manager, IVideoSourceConfig config, IVideoSourceFactory factory, IntPtr hWnd) : base(config, null, factory) { HWnd = hWnd; mStreamMidiaClientManager = manager; mHikClientPtr = Marshal.AllocHGlobal(Marshal.SizeOf(mHikClientAdviseSink)); }
private AlarmClient GetAlarmClient(IVideoSourceConfig vsConfig) { if (vsConfig != null && vsConfig.Type.StartsWith("HKDVR")) { return(CHKDVRDevice.GetAlarmClient(vsConfig.IP, (short)vsConfig.Port, vsConfig.UserName, vsConfig.Password)); } return(null); }
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); }
private void comboBox_vs_SelectedIndexChanged(object sender, EventArgs e) { mVSConfig = comboBox_vs.SelectedItem as IVideoSourceConfig; if (mVSConfig != null) { InitVSUI(mVSConfig); } alertAreaConfigCtrl_alertArea.VSConfig = mVSConfig; }
public override IVideoSource CreateVideoSource(IVideoSourceConfig config, IntPtr hWnd) { IVideoDevice device = GetVideoDevice(config.IP, config.Port, config.UserName, config.Password, false); if (device != null) { return(device.InitBackPlayer(config, hWnd)); } return(null); }
public override IVideoSource CreateVideoSource(IVideoSourceConfig config, IntPtr hWnd) { StreamMediaClientManager clientManager = StreamMediaClientManager.GetClientManager(); if (clientManager != null) { return(clientManager.InitVideoSource(config, this, hWnd)); } return(null); }
public VideoPlayer() { InitializeComponent(); mTimer.Enabled = false; mTimer.Interval = 1000; mTimer.Tick += new EventHandler(OnTimerTick); mVSConfig = new CVideoSourceConfig(StrUtil.NewGuid()); mVSConfig.Enabled = false; button_play.Enabled = false; }
public IVideoSource Open(IVideoSourceConfig config, IntPtr hWnd) { if (config != null) { IVideoSourceType type = mSystemContext.VideoSourceTypeManager.GetConfig(config.Type); if (type != null) { return(Open(config, type, hWnd)); } } return(null); }
public FilePlayer() { InitializeComponent(); mVSConfig = new CVideoSourceConfig(StrUtil.NewGuid()); ((CVideoSourceConfig)mVSConfig).SystemContext = CLocalSystem.LocalSystemContext; mVSConfig.Type = "FileVideoSource"; mVSConfig.IsCycle = false; mVSConfig.IsRecord = false; mVSConfig.Enabled = true; mVSConfig.SystemContext.VideoSourceManager.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStatusChanged); }
public HKMP4FilePlayer(IVideoSourceConfig config, IVideoSourceFactory factory, IntPtr hWnd) : base(config, null, factory) { HWnd = hWnd; mPort = Handle % 64; mTimer.Enabled = false; mTimer.Interval = 500; mTimer.Tick += new EventHandler(OnTimerTick); Target = config.FileName; }
public IVideoSource Open(string name, IntPtr hWnd) { IVideoSourceConfig vsConfig = mSystemContext.GetVideoSourceConfig(name); if (vsConfig != null) { return(Open(vsConfig, hWnd)); } else { return(null); } }
protected override bool ExecuteAction(object source, IActionParam param) { //System.Console.Out.WriteLine("CPTZAction.ExecuteAction: Action=" + Config.Desc); CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}[{1}]).ExecuteAction", Config.Desc, Name)); IVisionAlarm alarm = source as IVisionAlarm; if (alarm != null) { //System.Console.Out.WriteLine("CPTZAction.ExecuteAction: Sender=" + alarm.Sender + ", AlarmID=" + alarm.ID); CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).ExecuteAction: Sender={1}, AlarmID={2}, ActionParam={3}", Name, alarm.Sender, alarm.ID, param.Name)); //alarm.OnTransactAlarm += new TransactAlarm(DoTransactAlarm); if (System.Threading.Monitor.TryEnter(mPTZLockObj)) { try { IVisionMonitorConfig vmc = alarm.Monitor.Config as IVisionMonitorConfig; if (vmc != null) { IConfigManager <IVideoSourceConfig> vsConfigManager = vmc.SystemContext.VideoSourceConfigManager; if (vsConfigManager != null) { CVideoSourceConfig vcConfig = vsConfigManager.GetConfig(vmc.VisionParamConfig.VSName) as CVideoSourceConfig; if (vcConfig != null) { string vsName = vcConfig.StrValue("PTZVSName"); CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).ExecuteAction: PTZVSName={1}", Config.Desc, vsName)); if (!vsName.Equals("")) { IVideoSourceConfig ptzvsConfig = vsConfigManager.GetConfig(vsName); if (ptzvsConfig != null) { return(StartPTZ(ptzvsConfig, alarm.AreaIndex)); } } } } } } finally { System.Threading.Monitor.Exit(mPTZLockObj); } } } return(false); }
public ImageVideoSource(IVideoSourceConfig config, IVideoSourceFactory factory, IntPtr hWnd) : base(config, factory, hWnd) { if (HWnd != IntPtr.Zero) { mGraophics = Graphics.FromHwnd(HWnd); } mTimer.Enabled = false; mTimer.Interval = 25; mTimer.Tick += new EventHandler(OnTimerTick); Target = config.FileName; }
public IVideoSource GetVideoSource() { IVisionMonitorConfig config = VisionMonitorConfig; if (config != null) { IVideoSourceConfig vsConfig = SystemContext.GetVideoSourceConfig(config.VisionParamConfig.VSName); if (vsConfig != null) { return(SystemContext.VideoSourceManager.GetVideoSource(vsConfig.Name)); } } return(null); }
public IVideoSource Open(IVideoSourceConfig config, IVideoSourceType type, IntPtr hWnd) { if (config != null && config.Enabled) { IVideoSource vs = GetVideoSource(config.Name); if (vs == null) { IVideoSourceFactory vsFactory = GetVideoSourceFactory(type); if (vsFactory != null) { vs = vsFactory.CreateVideoSource(config, hWnd); if (vs != null) { lock (mVideoSources.SyncRoot) { if (vs.Open(null)) { vs.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged); vs.OnRecordProgress += new RECORD_PROGRESS(DoRecordProgress); (vs as IKernelVideoSource).OnKernelStatus += new KERNELSTATUS_CHANGED(DoKernelStatus); mVideoSources.Add(vs.Name, vs); vs.RefreshState(); } else { return(null); } } } } } else { if (hWnd != IntPtr.Zero) { vs.HWnd = hWnd; } if (!vs.IsOpen) { vs.Open(null); } } return(vs); } return(null); }
private void toolStripButton_close_Click(object sender, EventArgs e) { if (ActivePlayBox != null) { CFuncNode node = ActivePlayBox.LinkObj as CFuncNode; if (node != null) { IVideoSourceConfig vsConfig = node.ExtConfigObj as IVideoSourceConfig; if (vsConfig != null) { vsConfig.SystemContext.VideoSourceManager.Close(vsConfig.Name); } } } }
private bool StartPTZ(IVideoSourceConfig vsConfig, int index) { CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ Begin...", Name)); IPTZCtrl ptz = GetPTZCtrl(vsConfig); if (ptz != null) { if (System.Threading.Monitor.TryEnter(ptz)) { try { if (ptz.GotoPreset(index)) { CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ OK: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index)); int interval = PTZConfig.Interval; if (interval > 0) { System.Threading.Thread.Sleep(interval); } return(true); } else { CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ GOTO_PRESET Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index)); } } catch (Exception e) { CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ(PTZVSName={1}, Channel={2}, PresetIndex={3}) Exception: {4}", Name, vsConfig.Name, vsConfig.Channel, index, e)); } finally { System.Threading.Monitor.Exit(ptz); } } else { CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ TryEnter Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index)); } } else { CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ GetHKPTZCtrl Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index)); } return(false); }
public bool CloseVideoSource(IVideoSourceConfig config) { if (config != null) { StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo); sb.Append(config.Name + "<VideoSource>"); sb.Append("Close<Command>"); IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem; if (rs != null) { return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString())); } } return(false); }
private IPTZCtrl GetPTZCtrl(IVideoSourceConfig vsConfig) { CHKDVRDevice device = null; CHKDVRVideoSource vs = vsConfig.SystemContext.VideoSourceManager.GetVideoSource(vsConfig.Name) as CHKDVRVideoSource; if (vs != null) { device = vs.DVRDevice; } else { device = CHKDVRDevice.GetHKDevice(vsConfig.IP, vsConfig.Port, vsConfig.UserName, vsConfig.Password); } return(device.GetPTZCtrl(vsConfig.Channel)); }