Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

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