Beispiel #1
0
    // Token: 0x06004C3B RID: 19515 RVA: 0x00197B6C File Offset: 0x00195F6C
    public short[] Decode(byte[] data, BandMode mode)
    {
        if (!this.isInitialized)
        {
            this.CreateEncoders();
        }
        if (mode != BandMode.Opus48k)
        {
            Debug.LogError(string.Concat(new string[]
            {
                "OpusCodec: Decode: bandwidth mode must be ",
                BandMode.Opus48k.ToString(),
                "! (set to ",
                mode.ToString(),
                ")"
            }));
        }
        int num = 0;

        byte[] array = this._decoder.Decode(data, (data == null) ? 0 : data.Length, out num);
        if (num != this._bytesPerSegment)
        {
            int num2 = (data == null) ? 0 : data.Length;
            Debug.LogError(string.Concat(new object[]
            {
                "OpusCodec: Decode failed! Output PCM data is ",
                num,
                " bbytes, expected ",
                this._bytesPerSegment,
                " (compressed packet size was ",
                num2,
                ")"
            }));
            USpeakPoolUtils.Return(array);
        }
        short[] @short = USpeakPoolUtils.GetShort(this._bytesPerSegment / 2);
        Buffer.BlockCopy(array, 0, @short, 0, this._bytesPerSegment);
        USpeakPoolUtils.Return(array);
        return(@short);
    }
Beispiel #2
0
    // Token: 0x06004C3A RID: 19514 RVA: 0x00197A78 File Offset: 0x00195E78
    public byte[] Encode(short[] data, BandMode mode)
    {
        if (!this.isInitialized)
        {
            this.CreateEncoders();
        }
        if (mode != BandMode.Opus48k)
        {
            Debug.LogError(string.Concat(new string[]
            {
                "OpusCodec: Encode: bandwidth mode must be ",
                BandMode.Opus48k.ToString(),
                "! (set to ",
                mode.ToString(),
                ")"
            }));
        }
        if (data.Length != this._segmentFrames)
        {
            Debug.LogError(string.Concat(new object[]
            {
                "OpusCodec: Encode failed! Input PCM data is ",
                data.Length,
                " frames, expected ",
                this._segmentFrames
            }));
            return(new byte[0]);
        }
        byte[] @byte = USpeakPoolUtils.GetByte(data.Length * 2);
        Buffer.BlockCopy(data, 0, @byte, 0, data.Length * 2);
        int num = 0;

        byte[] result = this._encoder.Encode(@byte, this._bytesPerSegment, out num);
        USpeakPoolUtils.Return(@byte);
        return(result);
    }