| 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 |
| 4 | using UnityEngine; |
| 5 | using System.Collections; |
| 6 | using System; |
| 7 | |
| 8 | |
| 9 | namespace Oculus.Platform { |
| 10 | |
| 11 | public 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 |