BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Platform / Scripts / Decoder.cs

Decoder.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
Decoder.cs 1.0 KiB Download Raw
1//This file is deprecated. Use the high level voip system instead:
2// https://developer3.oculus.com/documentation/platform/latest/concepts/dg-core-content/#dg-cc-voip
3#if false
4using UnityEngine;
5using System.Collections;
6using System;
7
8namespace Oculus.Platform {
9
10 public class Decoder : IDisposable {
11
12 IntPtr dec;
13 float[] decodedScratchBuffer;
14
15 public Decoder() {
16 dec = CAPI.ovr_Voip_CreateDecoder();
17 decodedScratchBuffer = new float[480 * 10];
18 }
19
20 public void Dispose()
21 {
22 if (dec != IntPtr.Zero)
23 {
24 CAPI.ovr_Voip_DestroyEncoder(dec);
25 dec = IntPtr.Zero;
26 }
27 }
28
29 public float[] Decode(byte[] data) {
30 CAPI.ovr_VoipDecoder_Decode(dec, data, (uint)data.Length);
31
32 ulong gotSize = (ulong)CAPI.ovr_VoipDecoder_GetDecodedPCM(dec, decodedScratchBuffer, (UIntPtr)decodedScratchBuffer.Length);
33
34 if (gotSize > 0)
35 {
36 float[] pcm = new float[gotSize];
37 Array.Copy(decodedScratchBuffer, pcm, (int)gotSize);
38 return pcm;
39 }
40
41 return null;
42 }
43 }
44}
45#endif