Beispiel #1
0
        private void onFrame(int channelId, int playerId, byte voiceId, byte evNumber, byte[] receivedBytes)
        {
            if (this.DebugLostPercent > 0 && rnd.Next(100) < this.DebugLostPercent)
            {
                this.frontend.LogWarning("[PV] Debug Lost Sim: 1 packet dropped");
                return;
            }
            FramesReceived++;
            Dictionary <int, Dictionary <byte, RemoteVoice> > channelVoices = null;

            if (this.remoteVoices.TryGetValue(channelId, out channelVoices))
            {
                Dictionary <byte, RemoteVoice> playerVoices = null;
                if (channelVoices.TryGetValue(playerId, out playerVoices))
                {
                    RemoteVoice voice = null;
                    if (playerVoices.TryGetValue(voiceId, out voice))
                    {
                        voice.receiveBytes(receivedBytes, evNumber);
                    }
                    else
                    {
                        this.frontend.LogWarning("[PV] Frame event for not inited voice #" + voiceId + " of player " + this.playerStr(playerId) + " at channel " + this.channelStr(channelId));
                    }
                }
                else
                {
                    this.frontend.LogWarning("[PV] Frame event for voice #" + voiceId + " of not inited player " + this.playerStr(playerId) + " at channel " + this.channelStr(channelId));
                }
            }
            else
            {
                this.frontend.LogWarning("[PV] Frame event for voice #" + voiceId + " of not inited channel " + this.channelStr(channelId));
            }
        }
Beispiel #2
0
 private void receiveFrame(byte[] frame, RemoteVoice remoteVoice, int playerId, byte voiceId)
 {
     float[] decodedSamples = remoteVoice.decompress(frame);
     if (this.OnAudioFrameAction != null)
     {
         this.OnAudioFrameAction(playerId, voiceId, decodedSamples);
     }
 }
Beispiel #3
0
        private void onFrame(EventData ev, object[] content)
        {
            var playerId = (int)ev[LoadBalancing.ParameterCode.ActorNr];
            Dictionary <byte, RemoteVoice> playerVoices = null;

            byte voiceId  = (byte)content[0];
            byte evNumber = (byte)content[1];

            byte[] receivedBytes = (byte[])content[2];

            if (this.DebugLostPercent > 0 && rnd.Next(100) < this.DebugLostPercent)
            {
                this.DebugReturn(DebugLevel.WARNING, "[PV] Debug Lost Sim: 1 packet dropped");
                return;
            }

            FramesReceived++;

            if (this.remoteVoices.TryGetValue(playerId, out playerVoices))
            {
                RemoteVoice voice = null;
                if (playerVoices.TryGetValue(voiceId, out voice))
                {
                    // receive-gap detection and compensation
                    if (evNumber != voice.lastEvNumber)
                    {
                        int missing = byteDiff(evNumber, voice.lastEvNumber);
                        if (missing != 0)
                        {
                            this.DebugReturn(DebugLevel.ALL, "[PV] evNumer: " + evNumber + " playerVoice.lastEvNumber: " + voice.lastEvNumber + " missing: " + missing);
                        }

                        voice.lastEvNumber = evNumber;

                        if (this.UseLossCompensation)
                        {
                            for (int i = 0; i < missing; i++)
                            {
                                receiveFrame(null, voice, playerId, voiceId);
                            }
                        }

                        FramesLost += missing;
                    }
                    receiveFrame(receivedBytes, voice, playerId, voiceId);
                }
                else
                {
                    this.DebugReturn(DebugLevel.WARNING, "[PV] Frame event for not inited voice #" + voiceId + " of player " + playerId);
                }
            }
            else
            {
                this.DebugReturn(DebugLevel.WARNING, "[PV] Frame event for voice #" + voiceId + " of not inited player " + playerId);
            }
        }
        private void onVoiceInfo(int channelId, int playerId, object payload)
        {
            Dictionary <int, Dictionary <byte, RemoteVoice> > channelVoices = null;

            if (!this.remoteVoices.TryGetValue(channelId, out channelVoices))
            {
                channelVoices = new Dictionary <int, Dictionary <byte, RemoteVoice> >();
                this.remoteVoices[channelId] = channelVoices;
            }
            Dictionary <byte, RemoteVoice> playerVoices = null;

            if (!channelVoices.TryGetValue(playerId, out playerVoices))
            {
                playerVoices            = new Dictionary <byte, RemoteVoice>();
                channelVoices[playerId] = playerVoices;
            }

            foreach (var el in (object[])payload)
            {
                var h       = (Hashtable)el;
                var voiceId = (byte)h[(byte)EventParam.VoiceId];
                if (!playerVoices.ContainsKey(voiceId))
                {
                    var samplingRate    = (int)h[(byte)EventParam.SamplingRate];
                    var channels        = (int)h[(byte)EventParam.Channels];
                    var frameDurationUs = (int)h[(byte)EventParam.FrameDurationUs];
                    var bitrate         = (int)h[(byte)EventParam.Bitrate];
                    var userData        = h[(byte)EventParam.UserData];

                    var eventNumber = (byte)h[(byte)EventParam.EventNumber];

                    this.frontend.DebugReturn(DebugLevel.INFO, "[PV] Channel " + this.channelStr(channelId) + " player " + this.playerStr(playerId) + " voice #" + voiceId + " info received: f=" + samplingRate + ", ch=" + channels + " d=" + frameDurationUs + " b=" + bitrate + " ud=" + userData + " ev=" + eventNumber);

                    var info = new VoiceInfo((int)samplingRate, (int)channels, frameDurationUs, bitrate, userData);
                    playerVoices[voiceId] = new RemoteVoice(this, channelId, playerId, voiceId, info, eventNumber);
                    if (this.frontend.OnRemoteVoiceInfoAction != null)
                    {
                        this.frontend.OnRemoteVoiceInfoAction(channelId, playerId, voiceId, info);
                    }
                }
                else
                {
                    if (!this.SuppressInfoDuplicateWarning)
                    {
                        this.frontend.DebugReturn(DebugLevel.WARNING, "[PV] Info duplicate for voice #" + voiceId + " of player " + this.playerStr(playerId) + " at channel " + this.channelStr(channelId));
                    }
                }
            }
        }
Beispiel #5
0
        private void onVoiceInfo(int channelId, int playerId, object payload)
        {
            Dictionary <int, Dictionary <byte, RemoteVoice> > channelVoices = null;

            if (!this.remoteVoices.TryGetValue(channelId, out channelVoices))
            {
                channelVoices = new Dictionary <int, Dictionary <byte, RemoteVoice> >();
                this.remoteVoices[channelId] = channelVoices;
            }
            Dictionary <byte, RemoteVoice> playerVoices = null;

            if (!channelVoices.TryGetValue(playerId, out playerVoices))
            {
                playerVoices            = new Dictionary <byte, RemoteVoice>();
                channelVoices[playerId] = playerVoices;
            }

            foreach (var el in (object[])payload)
            {
                var h       = (Dictionary <byte, Object>)el;
                var voiceId = (byte)h[(byte)EventParam.VoiceId];
                if (!playerVoices.ContainsKey(voiceId))
                {
                    var eventNumber = (byte)h[(byte)EventParam.EventNumber];

                    var info = VoiceInfo.CreateFromEventPayload(h);
                    this.frontend.LogInfo("[PV] ch#" + this.channelStr(channelId) + " p#" + this.playerStr(playerId) + " v#" + voiceId + " Info received: " + info.ToString() + " ev=" + eventNumber);

                    // create default decoder
                    RemoteVoiceOptions options = new RemoteVoiceOptions();
                    // create default decoder
                    // may be overwritten in OnRemoteVoiceInfoAction call
                    options.Decoder = VoiceCodec.CreateDefaultDecoder(channelId, playerId, voiceId, info);
                    if (this.OnRemoteVoiceInfoAction != null)
                    {
                        this.OnRemoteVoiceInfoAction(channelId, playerId, voiceId, info, ref options);
                    }
                    playerVoices[voiceId] = new RemoteVoice(this, options, channelId, playerId, voiceId, info, eventNumber);
                }
                else
                {
                    if (!this.SuppressInfoDuplicateWarning)
                    {
                        this.frontend.LogWarning("[PV] Info duplicate for voice #" + voiceId + " of player " + this.playerStr(playerId) + " at channel " + this.channelStr(channelId));
                    }
                }
            }
        }
Beispiel #6
0
        private void onVoiceInfo(EventData ev, object payload)
        {
            var playerId = (int)ev[LoadBalancing.ParameterCode.ActorNr];
            Dictionary <byte, RemoteVoice> playerVoices = null;

            if (!this.remoteVoices.TryGetValue(playerId, out playerVoices))
            {
                playerVoices = new Dictionary <byte, RemoteVoice>();
                this.remoteVoices[playerId] = playerVoices;
            }
            playerVoices = this.remoteVoices[playerId];
            foreach (var el in (object[])payload)
            {
                var h       = (Hashtable)el;
                var voiceId = (byte)h[(byte)EventParam.VoiceId];
                if (!playerVoices.ContainsKey(voiceId))
                {
                    var samplingRate = (SamplingRate)h[(byte)EventParam.SamplingRate];
                    var channels     = (Channels)h[(byte)EventParam.Channels];
                    var encoderDelay = (int)h[(byte)EventParam.EncoderDelay];
                    var bitrate      = (int)h[(byte)EventParam.Bitrate];
                    var userData     = h[(byte)EventParam.UserData];

                    var eventNumber = (byte)h[(byte)EventParam.EventNumber];

                    this.DebugReturn(DebugLevel.INFO, "[PV] Player " + playerId + " voice #" + voiceId + " info received: f=" + samplingRate + ", ch=" + channels + " d=" + encoderDelay + " b=" + bitrate + " ud=" + userData + " ev=" + eventNumber);

                    var info = new VoiceInfo((int)samplingRate, (int)channels, encoderDelay, bitrate, userData);
                    playerVoices[voiceId] = new RemoteVoice(this, info, samplingRate, channels, eventNumber);
                    if (this.OnRemoteVoiceInfoAction != null)
                    {
                        this.OnRemoteVoiceInfoAction(playerId, voiceId, info);
                    }
                }
                else
                {
                    this.DebugReturn(DebugLevel.WARNING, "[PV] Info duplicate for voice #" + voiceId + " of player " + playerId);
                }
            }
        }