コード例 #1
0
        public MumbleClient(string hostName, int port, AudioPlayerCreatorMethod createMumbleAudioPlayerMethod, AudioPlayerRemoverMethod removeMumbleAudioPlayerMethod, bool async = false, SpeakerCreationMode speakerCreationMode = SpeakerCreationMode.ALL, DebugValues debugVals = null)
        {
            _hostName             = hostName;
            _port                 = port;
            _audioPlayerCreator   = createMumbleAudioPlayerMethod;
            _audioPlayerDestroyer = removeMumbleAudioPlayerMethod;
            _speakerCreationMode  = speakerCreationMode;

            switch (AudioSettings.outputSampleRate)
            {
            case 8000:
            case 12000:
            case 16000:
            case 24000:
            case 48000:
                _outputSampleRate = AudioSettings.outputSampleRate;
                break;

            default:
                Debug.LogError("Incorrect sample rate of:" + AudioSettings.outputSampleRate + ". It should be 48000 please set this in Edit->Audio->SystemSampleRate");
                _outputSampleRate = 48000;
                break;
            }
            Debug.Log("Using output sample rate: " + _outputSampleRate);

            switch (AudioSettings.speakerMode)
            {
            case AudioSpeakerMode.Mono:
                // TODO sometimes, even though the speaker mode is mono,
                // on audiofilterread wants two channels
                _outputChannelCount = 1;
                break;

            case AudioSpeakerMode.Stereo:
                _outputChannelCount = 2;
                break;

            default:
                Debug.LogError("Unsupported speaker mode " + AudioSettings.speakerMode + " please set this in Edit->Audio->DefaultSpeakerMode to either Mono or Stereo");
                _outputChannelCount = 2;
                break;
            }
            Debug.Log("Using output channel count of: " + _outputChannelCount);

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

            if (async)
            {
                Dns.BeginGetHostAddresses(hostName, OnHostRecv, null);
            }
            else
            {
                IPAddress[] addresses = Dns.GetHostAddresses(hostName);
                Init(addresses);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public MumbleClient(string hostName, int port, AudioPlayerCreatorMethod createMumbleAudioPlayerMethod, AudioPlayerRemoverMethod removeMumbleAudioPlayerMethod, bool async = false, DebugValues debugVals = null)
        {
            _hostName = hostName;
            _port     = port;
            if (async)
            {
                Dns.BeginGetHostAddresses(hostName, OnHostRecv, null);
            }
            else
            {
                IPAddress[] addresses = Dns.GetHostAddresses(hostName);
                Init(addresses);
            }
            _audioPlayerCreator   = createMumbleAudioPlayerMethod;
            _audioPlayerDestroyer = removeMumbleAudioPlayerMethod;

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