BlueGit

blue-star ggj-2020

Files

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

Encoder.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
Encoder.cs 1.1 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
8
9namespace Oculus.Platform {
10
11public class Encoder : IDisposable {
12 IntPtr enc;
13
14 public Encoder() {
15 enc = CAPI.ovr_Voip_CreateEncoder();
16 }
17
18 public void Dispose()
19 {
20 if (enc != IntPtr.Zero)
21 {
22 CAPI.ovr_Voip_DestroyEncoder(enc);
23 enc = IntPtr.Zero;
24 }
25 }
26
27 public byte[] Encode(float[] samples) {
28 CAPI.ovr_VoipEncoder_AddPCM(enc, samples, (uint)samples.Length);
29
30 ulong size = (ulong)CAPI.ovr_VoipEncoder_GetCompressedDataSize(enc);
31 if(size > 0) {
32 byte[] compressedData = new byte[size]; //TODO 10376403 - pool this
33 ulong sizeRead = (ulong)CAPI.ovr_VoipEncoder_GetCompressedData(enc, compressedData, (UIntPtr)size);
34
35 if (sizeRead != size)
36 {
37 throw new Exception("Read size differed from reported size");
38 }
39 return compressedData;
40 }
41 return null;
42 }
43 }
44}
45#endif