private void btPause_Click(object sender, EventArgs e) { if (this.btPause.Text == Messages.Pause) { try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(this.MainDevice.Vsid); VideoServerClient videoServerClient = new VideoServerClient(); videoServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcVideoServer.Ip + ":" + (string)(object)bcVideoServer.Port + "/VideoStreamServer/VideoServer"); videoServerClient.Open(); videoServerClient.Pause(this.MainDevice.Id); this.btPause.Text = Messages.Continue; videoServerClient.Abort(); } catch (Exception ex) { } } else { try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(this.MainDevice.Vsid); VideoServerClient videoServerClient = new VideoServerClient(); videoServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcVideoServer.Ip + ":" + (string)(object)bcVideoServer.Port + "/VideoStreamServer/VideoServer"); videoServerClient.Open(); this.btPause.Text = Messages.Pause; videoServerClient.Run(this.MainDevice.Id); videoServerClient.Abort(); } catch (Exception ex) { } } }
private void frmVideo_Load(object sender, EventArgs e) { this.Text = this.MainDevice.Name; this.FormClosing += new FormClosingEventHandler(this.frmVideo_FormClosing); this.MainThread = new Thread(new ThreadStart(this.WorkerThread)) { IsBackground = true }; this.MainThread.Start(); if (this.MainDevice.Type == "File") { this.groupControl1.Visible = true; this.trackBarControl1.Visible = true; BcVideoServer vs = BcVideoServer.LoadById(this.MainDevice.Vsid); WcfExtensions.Using <VideoServerClient>(new VideoServerClient(), (Action <VideoServerClient>)(service => { service.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)vs.Ip + ":" + (string)(object)vs.Port + "/VideoStreamServer/VideoServer"); service.Open(); Thread.Sleep(1000); try { this.trackBarControl1.Properties.Maximum = (int)service.GetDuration(this.MainDevice.Id); } catch (Exception ex) { } })); } else { this.pictureEdit1.Size = new Size(this.pictureEdit1.Width, this.pictureEdit1.Height + this.groupControl1.Height); } }
private void btPlay_Click(object sender, EventArgs e) { try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(this.MainDevice.Vsid); VideoServerClient videoServerClient = new VideoServerClient(); videoServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcVideoServer.Ip + ":" + (string)(object)bcVideoServer.Port + "/VideoStreamServer/VideoServer"); videoServerClient.Open(); this.trackBarControl1.Visible = true; this.trackBarControl1.Value = 0; this.btPause.Visible = true; this.btPlay.Visible = true; this.btStop.Visible = true; videoServerClient.PlayStart(this.MainDevice.Id); try { Thread.Sleep(2000); this.trackBarControl1.Properties.Maximum = (int)videoServerClient.GetDuration(this.MainDevice.Id); } catch (Exception ex) { } this.btPause.Text = "Пауза"; videoServerClient.Abort(); } catch (Exception ex) { } }
public void WorkerThread() { while (!FrmDevices.ClosFlag) { if (this.CloseForm) { break; } try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(this.MainDevice.Vsid); if (bcVideoServer.Id != Guid.Empty) { int num = 0; VideoServerClient videoServerClient = new VideoServerClient(); videoServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcVideoServer.Ip + ":" + (string)(object)bcVideoServer.Port + "/VideoStreamServer/VideoServer"); videoServerClient.Open(); while (!FrmDevices.ClosFlag) { ++num; if (!this.CloseForm) { byte[] imageFromDevice = videoServerClient.GetImageFromDevice(this.MainDevice.Id); if (imageFromDevice != null && imageFromDevice.Length > 0) { using (MemoryStream memoryStream = new MemoryStream(imageFromDevice)) this.Invoke((Delegate) new FrmVideo.NewImageFunc(this.NewImage), (object)new Bitmap((Stream)memoryStream)); } Thread.Sleep(20); if (num >= 20 && this.MainDevice.Type == "File") { try { this._nextPos = true; this.Invoke((Delegate) new FrmVideo.SetNewPosFunc(this.SetNewPos), (object)(int)videoServerClient.GetCurrentPos(this.MainDevice.Id)); this._nextPos = false; num = 0; } catch (Exception ex) { } } } else { break; } } } } catch (Exception ex) { } Thread.Sleep(1000); } }
private void btStop_Click(object sender, EventArgs e) { try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(this.MainDevice.Vsid); VideoServerClient videoServerClient = new VideoServerClient(); videoServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcVideoServer.Ip + ":" + (string)(object)bcVideoServer.Port + "/VideoStreamServer/VideoServer"); videoServerClient.Open(); this.trackBarControl1.Value = 0; videoServerClient.Stop(this.MainDevice.Id); videoServerClient.Abort(); } catch (Exception ex) { } }
private BcVideoServer TryLoadVideServer(Guid vsid) { try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(vsid); if (!(bcVideoServer.Id == Guid.Empty)) { return(bcVideoServer); } this._log.WarnFormat("Information about the object id={0} not found in DB", (object)vsid); return((BcVideoServer)null); } catch (Exception ex) { this._log.Error((object)ex); return((BcVideoServer)null); } }
private void trackBarControl1_EditValueChanged(object sender, EventArgs e) { if (!this._nextPos) { try { BcVideoServer bcVideoServer = BcVideoServer.LoadById(this.MainDevice.Vsid); VideoServerClient videoServerClient = new VideoServerClient(); videoServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcVideoServer.Ip + ":" + (string)(object)bcVideoServer.Port + "/VideoStreamServer/VideoServer"); videoServerClient.Open(); videoServerClient.SetPos(this.MainDevice.Id, (double)this.trackBarControl1.Value); videoServerClient.Abort(); } catch (Exception ex) { } } this.lbPeriod.Text = this.GetTime((double)this.trackBarControl1.Value) + "//" + this.GetTime((double)this.trackBarControl1.Properties.Maximum); }
public void Load(Guid serverId) { this._logger.Info((object)"Starting VideoServer"); if (BcVideoServer.LoadById(serverId) == null) { this._logger.ErrorFormat("Server with id {0} not found. Service will be stopped", (object)serverId); throw new ArgumentException(); } this.Id = serverId; Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal; try { this._logger.Info((object)"Loading devices from database"); this.LoadDevices(); this.StartProcessing(); } catch (Exception ex) { this._logger.Error((object)"Error loading server", ex); } }