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