Пример #1
0
        // Token: 0x06000167 RID: 359 RVA: 0x000049B0 File Offset: 0x00002BB0
        public void Decode(OpusDecoder decoder, ReadOnlySpan <byte> opus, ref Span <byte> target, bool useFec, out AudioFormat outputFormat)
        {
            int num;
            int num2;
            int num3;
            int frameSize;

            Interop.OpusGetPacketMetrics(opus, this.AudioFormat.SampleRate, out num, out num2, out num3, out frameSize);
            outputFormat = ((this.AudioFormat.ChannelCount != num) ? new AudioFormat(this.AudioFormat.SampleRate, num, this.AudioFormat.VoiceApplication) : this.AudioFormat);
            if (decoder.AudioFormat.ChannelCount != num)
            {
                decoder.Initialize(outputFormat);
            }
            int sampleCount = Interop.OpusDecode(decoder.Decoder, opus, frameSize, target, useFec);
            int num4        = outputFormat.SampleCountToSampleSize(sampleCount);

            target = target.Slice(0, num4);
        }
Пример #2
0
        public void Decode(OpusDecoder decoder, ReadOnlySpan <byte> opus, ref Span <byte> target, bool useFec, out AudioFormat outputFormat)
        {
            //if (target.Length != this.AudioFormat.CalculateMaximumFrameSize())
            //    throw new ArgumentException("PCM target buffer size needs to be equal to maximum buffer size for specified audio format.", nameof(target));

            Interop.OpusGetPacketMetrics(opus, AudioFormat.SampleRate, out var channels, out var frames, out var samplesPerFrame, out var frameSize);
            outputFormat = AudioFormat.ChannelCount != channels ? new AudioFormat(AudioFormat.SampleRate, channels, AudioFormat.VoiceApplication) : AudioFormat;

            if (decoder.AudioFormat.ChannelCount != channels)
            {
                decoder.Initialize(outputFormat);
            }

            var sampleCount = Interop.OpusDecode(decoder.Decoder, opus, frameSize, target, useFec);

            var sampleSize = outputFormat.SampleCountToSampleSize(sampleCount);

            target = target.Slice(0, sampleSize);
        }