コード例 #1
0
ファイル: VoicePeer.cs プロジェクト: derrickcreamer/Floe
		public VoicePeer(VoiceCodec codec, int quality, VoicePacketPool pool)
		{
			_codec = new CodecInfo(codec, quality);
			_buffer = new JitterBuffer(_codec);
			_pool = pool;
			this.InitAudio();
		}
コード例 #2
0
ファイル: VoiceLoopback.cs プロジェクト: derrickcreamer/Floe
		/// <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);
		}
コード例 #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.");
            }
        }
コード例 #4
0
ファイル: VoicePeer.cs プロジェクト: ryanflannery/Floe
 public VoicePeer(VoiceCodec codec, int quality, VoicePacketPool pool)
 {
     _codec  = new CodecInfo(codec, quality);
     _buffer = new JitterBuffer(_codec);
     _pool   = pool;
     this.InitAudio();
 }
コード例 #5
0
ファイル: VoiceLoopback.cs プロジェクト: ryanflannery/Floe
        /// <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);
        }
コード例 #6
0
ファイル: VoiceClient.cs プロジェクト: ryanflannery/Floe
        /// <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);
        }
コード例 #7
0
ファイル: VoiceControl.xaml.cs プロジェクト: yjh0502/Floe
 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);
     }
 }
コード例 #8
0
ファイル: CodecInfo.cs プロジェクト: derrickcreamer/Floe
		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.");
			}
		}
コード例 #9
0
ファイル: VoiceClient.cs プロジェクト: derrickcreamer/Floe
		/// <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);
		}