/// <summary> /// 开始记录视频 /// 按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> private void btnStartRecording_Click(object sender, EventArgs e) { string path = string.Format("flight_{0:yyyy_MM_dd_HH_mm}" + ARDroneTrackFileExt, DateTime.Now); using (var dialog = new SaveFileDialog { DefaultExt = ARDroneTrackFileExt, Filter = ARDroneTrackFilesFilter, FileName = path }) { if (dialog.ShowDialog(this) == DialogResult.OK) { StopRecording(); _recorderStream = new FileStream(dialog.FileName, FileMode.OpenOrCreate); _packetRecorderWorker = new PacketRecorder(_recorderStream); _packetRecorderWorker.Start(); _viconPositionGet.Start(); //_pwrite.Start(); //string file = string.Format(@"vicon_{0:yyyy_MM_dd_HH_mm}.txt", DateTime.Now); //string dir = Path.GetDirectoryName(dialog.FileName); //_viconFileStream = new FileStream(dir + @"/" + file, FileMode.OpenOrCreate); //_viconWriteStream = new StreamWriter(_viconFileStream); //_viconPositionGet.Start(); } } }
/// <summary> /// 停止录像 /// 释放使用的资源 /// </summary> /// <returns></returns> private void StopRecording() { if (_packetRecorderWorker != null) { _packetRecorderWorker.Stop(); _packetRecorderWorker.Join(); _packetRecorderWorker = null; } if (_recorderStream != null) { _recorderStream.Dispose(); _recorderStream = null; } if (_viconPositionGet != null) { _viconPositionGet.Stop(); } if (_viconWriteStream != null) { _viconWriteStream.Dispose(); _viconWriteStream = null; } if (_viconFileStream != null) { _viconFileStream.Dispose(); _viconFileStream = null; } }
private void StopRecording() { if (_packetRecorderWorker != null) { _packetRecorderWorker.Stop(); _packetRecorderWorker.Join(); _packetRecorderWorker = null; } if (_recorderStream != null) { _recorderStream.Dispose(); _recorderStream = null; } }
private void btnStartRecording_Click(object sender, EventArgs e) { string path = string.Format("flight_{0:yyyy_MM_dd_HH_mm}" + ARDroneTrackFileExt, DateTime.Now); using (var dialog = new SaveFileDialog { DefaultExt = ARDroneTrackFileExt, Filter = ARDroneTrackFilesFilter, FileName = path }) { if (dialog.ShowDialog(this) == DialogResult.OK) { StopRecording(); _recorderStream = new FileStream(dialog.FileName, FileMode.OpenOrCreate); _packetRecorderWorker = new PacketRecorder(_recorderStream); _packetRecorderWorker.Start(); } } }
public ClientHandler(Socket socket, string title = "Client", params object[] args) { this.Title = title; Log.Inform("Preparing {0}...", this.Title.ToLower()); this.Socket = socket; this.Cryptograph = new TCryptograph(); this.ReceivalBuffer = new ByteBuffer() { Limit = 0 }; this.IsAlive = true; this.Prepare(args); Log.Success(string.Format("{0} connected from {1}.", this.Title, this.RemoteEndPoint.Address)); this.Initialize(); this.Register(); packetRecorder = new PacketRecorder(); while (this.IsAlive && this.IsServerAlive) { this.ReceiveDone.Reset(); try { this.Socket.BeginReceive(this.ReceivalBuffer.Array, this.ReceivalBuffer.Limit, this.ReceivalBuffer.Capacity - this.ReceivalBuffer.Limit, SocketFlags.None, new AsyncCallback(this.OnReceive), null); } catch (Exception e) { Log.Error(e); this.Stop(); } this.ReceiveDone.WaitOne(); } this.Dispose(); }
public ARDrone2() { _videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnVideoPacketDecoded); _videoPacketDecoderWorker.Start(); string path = string.Format("flight_{0:yyyy-MM-dd-HH-mm}.ardrone", DateTime.Now); var stream = new FileStream(path, FileMode.OpenOrCreate); _packetRecorderWorker = new PacketRecorder(stream); _packetRecorderWorker.Start(); _droneClient = new DroneClient(); _droneClient.NavigationPacketAcquired += OnNavigationPacketAcquired; _droneClient.VideoPacketAcquired += OnVideoPacketAcquired; _droneClient.ConfigurationUpdated += OnConfigurationUpdated; _droneClient.Active = true; //tmrStateUpdate.Enabled = true; //tmrVideoUpdate.Enabled = true; }
public MainForm() { InitializeComponent(); Text += Environment.Is64BitProcess ? " [64-bit]" : " [32-bit]"; _videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnVideoPacketDecoded); _videoPacketDecoderWorker.Start(); string path = string.Format("flight_{0:yyyy-MM-dd-HH-mm}.ardrone", DateTime.Now); var stream = new FileStream(path, FileMode.OpenOrCreate); _packetRecorderWorker = new PacketRecorder(stream); _packetRecorderWorker.Start(); _droneClient = new DroneClient(); _droneClient.NavigationPacketAcquired += OnNavigationPacketAcquired; _droneClient.VideoPacketAcquired += OnVideoPacketAcquired; _droneClient.ConfigurationUpdated += OnConfigurationUpdated; _droneClient.Active = true; tmrStateUpdate.Enabled = true; tmrVideoUpdate.Enabled = true; }