Exemplo n.º 1
0
		public VoicePeer(VoiceCodec codec, int quality, VoicePacketPool pool)
		{
			_codec = new CodecInfo(codec, quality);
			_buffer = new JitterBuffer(_codec);
			_pool = pool;
			this.InitAudio();
		}
Exemplo n.º 2
0
		/// <summary>
		/// Construct a new voice loopback session.
		/// </summary>
		/// <param name="codec">An audio codec to encode and decode with.</param>
		/// <param name="quality">The encoding quality (usually the sample rate).</param>
		public VoiceLoopback(VoiceCodec codec, int quality)
		{
			var info = new CodecInfo(codec, quality);
			_waveIn = new WaveIn(this, info.DecodedFormat, info.DecodedBufferSize);
			_waveOut = new WaveOut(this, info.EncodedFormat, info.EncodedBufferSize);
			_encoder = new AudioConverter(info.DecodedBufferSize, info.DecodedFormat, info.EncodedFormat);
		}
Exemplo n.º 3
0
        public CodecInfo(VoiceCodec codec, int sampleRate)
        {
            switch (codec)
            {
            case VoiceCodec.Gsm610:
                this.PayloadType = Gsm610PayloadType;
                this.SampleRate  = sampleRate;

                int blocksPerPacket = 1;
                while ((blocksPerPacket * Gsm610SamplesPerBlock * 1000) / sampleRate <= MinBufferLength)
                {
                    blocksPerPacket++;
                }

                this.SamplesPerPacket  = Gsm610SamplesPerBlock * blocksPerPacket;
                this.EncodedBufferSize = Gsm610BytesPerBlock * blocksPerPacket;
                this.DecodedBufferSize = this.SamplesPerPacket * 2;
                this.EncodedFormat     = new WaveFormatGsm610(sampleRate);
                this.DecodedFormat     = new WaveFormatPcm(sampleRate, 16, 1);
                break;

            default:
                throw new ArgumentException("Unsupported codec.");
            }
        }
Exemplo n.º 4
0
 public VoicePeer(VoiceCodec codec, int quality, VoicePacketPool pool)
 {
     _codec  = new CodecInfo(codec, quality);
     _buffer = new JitterBuffer(_codec);
     _pool   = pool;
     this.InitAudio();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Construct a new voice loopback session.
        /// </summary>
        /// <param name="codec">An audio codec to encode and decode with.</param>
        /// <param name="quality">The encoding quality (usually the sample rate).</param>
        public VoiceLoopback(VoiceCodec codec, int quality)
        {
            var info = new CodecInfo(codec, quality);

            _waveIn  = new WaveIn(this, info.DecodedFormat, info.DecodedBufferSize);
            _waveOut = new WaveOut(this, info.EncodedFormat, info.EncodedBufferSize);
            _encoder = new AudioConverter(info.DecodedBufferSize, info.DecodedFormat, info.EncodedFormat);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add a peer to the session.
        /// </summary>
        /// <param name="codec">The peer's audio codec.</param>
        /// <param name="quality">The peer's audio quality (usually the sample rate).</param>
        /// <param name="endpoint">The peer's public endpoint.</param>
        public void AddPeer(VoiceCodec codec, int quality, IPEndPoint endpoint)
        {
            base.AddPeer(endpoint);
            var peer = new VoicePeer(codec, quality, _pool);

            peer.Volume = _outputVolume;
            peer.Gain   = _outputGain;
            _peers.Add(endpoint, peer);
        }
Exemplo n.º 7
0
 private void AddPeer(string nick, VoiceCodec codec, int quality, IPEndPoint endpoint)
 {
     if (_nickList.Contains(nick) && !_peers.ContainsKey(endpoint))
     {
         _peers.Add(endpoint, new VoicePeer() { User = _nickList[nick] });
         _voice.AddPeer(codec, quality, endpoint);
         SetIsVoiceChat(_nickList[nick], true);
     }
 }
Exemplo n.º 8
0
		public CodecInfo(VoiceCodec codec, int sampleRate)
		{
			switch (codec)
			{
				case VoiceCodec.Gsm610:
					this.PayloadType = Gsm610PayloadType;
					this.SampleRate = sampleRate;

					int blocksPerPacket = 1;
					while ((blocksPerPacket * Gsm610SamplesPerBlock * 1000) / sampleRate <= MinBufferLength)
					{
						blocksPerPacket++;
					}

					this.SamplesPerPacket = Gsm610SamplesPerBlock * blocksPerPacket;
					this.EncodedBufferSize = Gsm610BytesPerBlock * blocksPerPacket;
					this.DecodedBufferSize = this.SamplesPerPacket * 2;
					this.EncodedFormat = new WaveFormatGsm610(sampleRate);
					this.DecodedFormat = new WaveFormatPcm(sampleRate, 16, 1);
					break;
				default:
					throw new ArgumentException("Unsupported codec.");
			}
		}
Exemplo n.º 9
0
		/// <summary>
		/// Add a peer to the session.
		/// </summary>
		/// <param name="codec">The peer's audio codec.</param>
		/// <param name="quality">The peer's audio quality (usually the sample rate).</param>
		/// <param name="endpoint">The peer's public endpoint.</param>
		public void AddPeer(VoiceCodec codec, int quality, IPEndPoint endpoint)
		{
			base.AddPeer(endpoint);
			var peer = new VoicePeer(codec, quality, _pool);
			peer.Volume = _outputVolume;
			peer.Gain = _outputGain;
			_peers.Add(endpoint, peer);
		}