예제 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     playersForm.StopAll();
     if (button2.Enabled)
     {
         button2.Enabled = false;
         waveIn.StopRecording();
         while (notEncodedBuffer.Length > bytesPerSegment)
         {
         }
         System.Threading.Thread.Sleep(2 * waveIn.BufferMilliseconds);
         session.SendGoodbyeFrame();
         session.OnRtpPacketReceived -= Session_OnRtpPacketReceived;
         session                = null;
         button1.Enabled        = true;
         comboBox1.Enabled      = true;
         outputList.Enabled     = true;
         inputList.Enabled      = true;
         label5.Visible         = false;
         button1.ForeColor      = Color.Black;
         button1.BackColor      = SystemColors.Control;
         playersForm.IsEncoding = false;
         Decoder.Dispose();
     }
 }
예제 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (button2.Enabled)
     {
         button2.Enabled = false;
         waveIn.StopRecording();
         System.Threading.Thread.Sleep(2 * waveIn.BufferMilliseconds);
         session.SendGoodbyeFrame();
         session.OnRtpPacketReceived -= Session_OnRtpPacketReceived;
         session            = null;
         button1.Enabled    = true;
         comboBox1.Enabled  = true;
         outputList.Enabled = true;
         inputList.Enabled  = true;
         label5.Visible     = false;
         button1.ForeColor  = Color.Black;
         button1.BackColor  = SystemColors.Control;
     }
 }
예제 #3
0
        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;
        }
예제 #4
0
        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;
        }