public MumbleClient(string hostName, int port, AudioPlayerCreatorMethod createMumbleAudioPlayerMethod, AudioPlayerRemoverMethod removeMumbleAudioPlayerMethod, DebugValues debugVals = null)
        {
            IPAddress[] addresses = Dns.GetHostAddresses(hostName);
            if (addresses.Length == 0)
            {
                throw new ArgumentException(
                          "Unable to retrieve address from specified host name.",
                          hostName
                          );
            }
            var host = new IPEndPoint(addresses[0], port);

            _udpConnection = new MumbleUdpConnection(host, this);
            _tcpConnection = new MumbleTcpConnection(host, hostName, _udpConnection.UpdateOcbServerNonce, _udpConnection, this);
            _udpConnection.SetTcpConnection(_tcpConnection);
            _audioPlayerCreator   = createMumbleAudioPlayerMethod;
            _audioPlayerDestroyer = removeMumbleAudioPlayerMethod;

            if (debugVals == null)
            {
                debugVals = new DebugValues();
            }
            _debugValues = debugVals;

            //Maybe do Lazy?
            _codec = new OpusCodec();

            _manageSendBuffer = new ManageAudioSendBuffer(_codec, _udpConnection, this);
        }
예제 #2
0
 public ManageAudioSendBuffer(OpusCodec codec, MumbleUdpConnection udpConnection, MumbleClient mumbleClient)
 {
     _udpConnection  = udpConnection;
     _codec          = codec;
     _mumbleClient   = mumbleClient;
     _pcmArrays      = new List <PcmArray>();
     _encodingBuffer = new AudioEncodingBuffer();
 }
예제 #3
0
        public ManageAudioSendBuffer(OpusCodec codec, MumbleUdpConnection udpConnection, MumbleClient mumbleClient)
        {
            _udpConnection  = udpConnection;
            _codec          = codec;
            _mumbleClient   = mumbleClient;
            _pcmArrays      = new List <PcmArray>();
            _encodingBuffer = new AudioEncodingBuffer();

            _encodingThread = new Thread(EncodingThreadEntry)
            {
                IsBackground = true
            };
        }
        public ArraySegment <byte> Encode(OpusCodec codec, out bool isStop, out bool isEmpty)
        {
            isStop  = false;
            isEmpty = false;
            PcmArray nextPcmToSend = null;

            lock (_unencodedBuffer)
            {
                if (_unencodedBuffer.Count == 0)
                {
                    isEmpty = true;
                }
                else
                {
                    if (_unencodedBuffer.Count == 1 && _isWaitingToSendLastPacket)
                    {
                        isStop = true;
                        _isWaitingToSendLastPacket = false;
                    }

                    TargettedSpeech speech = _unencodedBuffer.Dequeue();
                    isStop = isStop || speech.IsStop;
                    if (!isStop)
                    {
                        nextPcmToSend             = speech.PcmData;
                        nextPcmToSend.IsAvailable = true;
                    }
                }
            }

            if (nextPcmToSend == null || nextPcmToSend.Pcm.Length == 0)
            {
                isEmpty = true;
            }

            if (isEmpty)
            {
                return(EmptyByteSegment);
            }

            //Debug.Log("Will encode: " + nextPcmToSend.Length);
            return(codec.Encode(nextPcmToSend.Pcm));
        }
예제 #5
0
        private void Init(IPAddress[] addresses)
        {
            //Debug.Log("Host addresses recv");
            if (addresses == null || addresses.Length == 0)
            {
                Debug.LogError("Failed to get addresses!");
                throw new ArgumentException(
                          "Unable to retrieve address from specified host name.",
                          _hostName
                          );
            }
            var endpoint = new IPEndPoint(addresses[0], _port);

            _udpConnection = new MumbleUdpConnection(endpoint, this);
            _tcpConnection = new MumbleTcpConnection(endpoint, _hostName, _udpConnection.UpdateOcbServerNonce, _udpConnection, this);
            _udpConnection.SetTcpConnection(_tcpConnection);
            _codec            = new OpusCodec();
            _manageSendBuffer = new ManageAudioSendBuffer(_codec, _udpConnection, this);
            ReadyToConnect    = true;
        }
예제 #6
0
 public AudioDecodingBuffer(OpusCodec codec)
 {
     _codec = codec;
 }