public SumoAudioRecorder(SumoSender _sender) { sumoSender = _sender; waveSource = new WaveIn(WaveCallbackInfo.FunctionCallback()) { WaveFormat = new WaveFormat(8000, 16, 1), NumberOfBuffers = 1, BufferMilliseconds = 50 }; waveSource.DataAvailable += WaveSource_DataAvailable; }
/// <summary> /// Establish a connection to the drone and start receiving and sending data /// </summary> /// <returns></returns> public bool Connect() { if (IsConnected) { Disconnect(); } Ping_Should_run = false; Task <bool> disc = Task <bool> .Factory.StartNew(() => _discovery()); disc.Wait(); IsConnected = disc.Result; if (IsConnected) { this.sender = new SumoSender(this.deviceIp, this.c2d_port); this.receiver = new SumoReceiver(this.deviceIp, this.d2c_port, this.sender, ref sumoInformations); this.receiver.SumoEvents += Receiver_SumoEvents; // Set Video this.video = new SumoVideo(this.receiver); video.ImageInSeparateOpenCVWindow = EnableOpenCV; this.video.ImageAvailable += Display_ImageAvailable; // Run Threads this.receiver.RunThread(); this.sender.RunThread(); this.sender.Init(); this.video.RunThread(); if (this.piloting != null) { this.piloting.InstallHook(); this.piloting.RunPilotingThread(); this.piloting.RunKeyboardThread(); } EnableVideo(); // Inform UI that is connected OnSumoEvents(new SumoEventArgs(SumoEnumCustom.TypeOfEvents.Connected, sumoInformations)); } return(IsConnected); }