private void button1_Click(object sender, EventArgs e) { playersForm.StopAll(); Remote remote = settings.Remotes[comboBox1.SelectedIndex]; try { farEnd = remote.GetIPEndPoint(); } catch { MessageBox.Show("This is not a valid IP Address"); return; } button2.Enabled = true; button1.Enabled = false; label5.Visible = true; segmentFrames = 960; encoder = OpusEncoder.Create(48000, 1, FragLabs.Audio.Codecs.Opus.Application.Audio); Decoder = new DGDecoder(remote.CodecType, 48000, 1); encoder.Bitrate = 64000; bytesPerSegment = encoder.FrameByteCount(segmentFrames); waveIn = new WaveIn(WaveCallbackInfo.FunctionCallback()); waveIn.DeviceNumber = inputList.SelectedIndex; waveIn.DataAvailable += waveIn_DataAvailable; waveIn.WaveFormat = new WaveFormat(48000, 16, 1); liveInput = new BufferedWaveProvider(waveIn.WaveFormat); List <ISampleProvider> sampleProviders = new List <ISampleProvider>(); sampleProviders.Add(liveInput.ToSampleProvider()); sampleProviders.Add(playersForm.Mixer); MixingSampleProvider = new MixingSampleProvider(sampleProviders); playBuffer = new BufferedWaveProvider(new WaveFormat(44100, 16, 2)); playBuffer.DiscardOnBufferOverflow = true; waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()); waveOut.DeviceNumber = outputList.SelectedIndex; playersForm.PlaybackDeviceNum = outputList.SelectedIndex; session = new ComrexSession(); session.SetDestination(SDPMediaTypesEnum.audio, farEnd, farEnd); session.OnRtpPacketReceived += Session_OnRtpPacketReceived; session.Start(); killsession = false; waveOut.Init(playBuffer); waveIn.StartRecording(); if (timer == null) { timer = new Timer(); timer.Interval = 100; timer.Tick += timer_Tick; } timer.Start(); comboBox1.Enabled = false; outputList.Enabled = false; inputList.Enabled = false; }
private void button1_Click(object sender, EventArgs e) { try { farEnd = settings.Remotes[comboBox1.SelectedIndex].GetIPEndPoint(); } catch { MessageBox.Show("This is not a valid IP Address"); return; } button2.Enabled = true; button1.Enabled = false; label5.Visible = true; segmentFrames = 960; encoder = OpusEncoder.Create(48000, 1, FragLabs.Audio.Codecs.Opus.Application.Audio); decoder = OpusDecoder.Create(48000, 1); aacDecoder = new Decode(); encoder.Bitrate = 64000; bytesPerSegment = encoder.FrameByteCount(segmentFrames); waveIn = new WaveIn(WaveCallbackInfo.FunctionCallback()); //waveIn.BufferMilliseconds = 20; waveIn.DeviceNumber = inputList.SelectedIndex; waveIn.DataAvailable += waveIn_DataAvailable; waveIn.WaveFormat = new WaveFormat(48000, 16, 1); playBuffer = new BufferedWaveProvider(new WaveFormat(44100, 16, 2)); playBuffer.DiscardOnBufferOverflow = true; waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()); waveOut.DeviceNumber = outputList.SelectedIndex; session = new ComrexSession(); session.SetDestination(SDPMediaTypesEnum.audio, farEnd, farEnd); session.OnRtpPacketReceived += Session_OnRtpPacketReceived; //session.addTrack(track); session.Start(); killsession = false; //participant = new RtpParticipant("dennis","DGoLive"); //session = new RtpSession(farEnd, participant, true, true); //rtpsender = session.CreateRtpSender("test", PayloadType.Opus, null); waveOut.Init(playBuffer); waveIn.StartRecording(); if (timer == null) { timer = new Timer(); timer.Interval = 100; timer.Tick += timer_Tick; } timer.Start(); comboBox1.Enabled = false; outputList.Enabled = false; inputList.Enabled = false; }