BlueGit

blue-star ggj-2020

Files

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

VoipAudioSource.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
VoipAudioSource.cs 1.5 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
4namespace 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