Ejemplo n.º 1
0
        public DGDecoder(CodecType Type, int SampleRate, int Channels)
        {
            CodecType = Type;
            switch (CodecType)
            {
            case CodecType.AAC:
                decoder = new AACDecode();
                break;

            case CodecType.Opus:
                decoder = new OpusDecoder(SampleRate, Channels);
                break;
            }
        }
Ejemplo n.º 2
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;
        }