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.

59 lines
1.5 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. namespace Oculus.Platform
  5. {
  6. using UnityEngine;
  7. using System.Collections.Generic;
  8. public class VoipAudioSource : MonoBehaviour
  9. {
  10. public bool spatialize = true;
  11. BufferedAudioStream bufferedAudioStream;
  12. Decoder decoder;
  13. protected List<float> debugOutputData;
  14. void Start()
  15. {
  16. AudioSource audioSource = gameObject.AddComponent<AudioSource>();
  17. Debug.Log(audioSource);
  18. audioSource.spatialize = spatialize;
  19. bufferedAudioStream = new BufferedAudioStream(audioSource);
  20. decoder = new Decoder();
  21. }
  22. public void Stop()
  23. {
  24. }
  25. public void AddCompressedData(byte[] compressedData)
  26. {
  27. if(decoder == null || bufferedAudioStream == null)
  28. {
  29. throw new System.Exception("VoipAudioSource failed to init");
  30. }
  31. float[] decompressedData = decoder.Decode(compressedData);
  32. if (decompressedData != null && decompressedData.Length > 0)
  33. {
  34. bufferedAudioStream.AddData(decompressedData);
  35. if (debugOutputData != null)
  36. {
  37. debugOutputData.AddRange(decompressedData);
  38. }
  39. }
  40. }
  41. void Update()
  42. {
  43. if (bufferedAudioStream == null)
  44. {
  45. throw new System.Exception("VoipAudioSource failed to init");
  46. }
  47. bufferedAudioStream.Update();
  48. }
  49. }
  50. }
  51. #endif