示例#1
0
        public static async void ConnectToVoiceChannel(VoiceServerUpdate data)
        {
            string name;

            if (data.GuildId == null)
            {
                data.GuildId = data.ChannelId;
                name         = $"DM - {LocalState.DMs[data.ChannelId].Name}";
            }
            else
            {
                name = $"{LocalState.Guilds[data.GuildId].Raw.Name} - {LocalState.Guilds[data.GuildId].channels[LocalState.VoiceState.ChannelId].raw.Name}";
            }
            App.UpdateLocalDeaf(false);
            App.UpdateVoiceStateHandler += App_UpdateVoiceStateHandler;
            //App.UpdateLocalMute(true); //LocalState.Muted);
            VoiceConnection = new VoiceConnection(data, LocalState.VoiceState);
            VoiceConnection.VoiceDataRecieved += VoiceConnection_VoiceDataRecieved;
            await VoiceConnection.ConnectAsync();

            ConnectoToVoiceHandler?.Invoke(typeof(App), new ConnectToVoiceArgs()
            {
                ChannelId = LocalState.VoiceState.ChannelId, GuildId = data.GuildId
            });
            AudioManager.InputRecieved += AudioManager_InputRecieved;
            if (Storage.Settings.BackgroundVoice)
            {
                VoipCallCoordinator vcc = VoipCallCoordinator.GetDefault();
                voipCall = vcc.RequestNewOutgoingCall("", name, "Quarrel", VoipPhoneCallMedia.Audio);
                voipCall.NotifyCallActive();
            }
        }
        private async void ConnectToVoiceChannel(VoiceServerUpdate data, VoiceState state)
        {
            voipCall?.NotifyCallEnded();
            VoipCallCoordinator vcc = VoipCallCoordinator.GetDefault();
            var status = await vcc.ReserveCallResourcesAsync("WebRTCBackgroundTask.VoipBackgroundTask");

            // TODO: More info for Mobile
            voipCall = vcc.RequestNewOutgoingCall(string.Empty, string.Empty, "Quarrel", VoipPhoneCallMedia.Audio);
            voipCall.NotifyCallActive();

            voiceConnection        = new VoiceConnection(data, state, webrtcManager);
            voiceConnection.Speak += Speak;
            await voiceConnection.ConnectAsync();
        }
示例#3
0
        internal async Task ConnectToStream()
        {
            _voiceConnection = new VoiceConnection(
                unhandledMessageEncountered: e => _client.LogException(ClientLogEvent.VoiceExceptionHandled, e),
                knownOperationEncountered: e => _client.LogOperation(ClientLogEvent.KnownVoiceOperationEncountered, (int)e),
                unhandledOperationEncountered: e => _client.LogOperation(ClientLogEvent.UnhandledVoiceOperationEncountered, (int)e),
                unknownOperationEncountered: e => _client.LogOperation(ClientLogEvent.UnknownVoiceOperationEncountered, e),
                voiceConnectionStatusChanged: _ => { },
                ready: OnReady,
                sessionDescription: OnSessionDescription,
                speaking: OnSpeaking,
                video: OnVideo);

            await _voiceConnection.ConnectAsync(_connectionUrl);

            await _voiceConnection.IdentifySelfToVoiceConnection(_serverId, _sessionId, _token, _userId, true, new VoiceIdentity.VoiceIdentityStream[] { new() { Quality = 100, Rid = "100", Type = "video" } });