Пример #1
0
        public void Start(string inputDevice)
        {
            if (Started)
            {
                throw new Exception("Input already started");
            }

            //waveIn = new WaveIn(WaveCallbackInfo.FunctionCallback());
            waveIn = new WaveInEvent();
            waveIn.BufferMilliseconds = 20;
            //Console.WriteLine("Input device: " + WaveIn.GetCapabilities(0).ProductName);
            waveIn.DeviceNumber   = ClientAudioUtilities.MapInputDevice(inputDevice);
            waveIn.DataAvailable += _waveIn_DataAvailable;
            waveIn.WaveFormat     = new WaveFormat(sampleRate, 16, 1);

            inputVolumeStreamArgs = new InputVolumeStreamEventArgs()
            {
                DeviceNumber = waveIn.DeviceNumber, PeakRaw = 0, PeakDB = float.NegativeInfinity, PeakVU = 0
            };
            opusDataAvailableArgs = new OpusDataAvailableEventArgs();

            //inputControls = ClientAudioUtilities.GetWaveInMixerControls(waveIn.DeviceNumber);
            waveIn.StartRecording();

            Started = true;
        }
Пример #2
0
        private void Input_OpusDataAvailable(object sender, OpusDataAvailableEventArgs e)
        {
            if (transmittingTransceivers == null)
            {
                return;
            }

            if (transmittingTransceivers.Length > 0)
            {
                if (transmit)
                {
                    if (Connection.IsConnected)
                    {
                        Connection.VoiceServerTransmitQueue.Add(new AudioTxDto()
                        {
                            Callsign        = Callsign,
                            SequenceCounter = e.SequenceCounter,
                            Audio           = e.Audio,
                            LastPacket      = false,
                            Transceivers    = transmittingTransceivers
                        });

                        //Debug.WriteLine("Sending Audio:" + e.SequenceCounter);
                    }
                }
                if (!transmit && transmitHistory)
                {
                    if (Connection.IsConnected)
                    {
                        Connection.VoiceServerTransmitQueue.Add(new AudioTxDto()
                        {
                            Callsign        = Callsign,
                            SequenceCounter = e.SequenceCounter,
                            Audio           = e.Audio,
                            LastPacket      = true,
                            Transceivers    = transmittingTransceivers
                        });
                    }
                }
                transmitHistory = transmit;
            }
        }