VoipAudioSource.cs
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//This file is deprecated. Use the high level voip system instead:
// https://developer3.oculus.com/documentation/platform/latest/concepts/dg-core-content/#dg-cc-voip
#if false
namespace Oculus.Platform
{
using UnityEngine;
using System.Collections.Generic;
public class VoipAudioSource : MonoBehaviour
{
public bool spatialize = true;
BufferedAudioStream bufferedAudioStream;
Decoder decoder;
protected List<float> debugOutputData;
void Start()
{
AudioSource audioSource = gameObject.AddComponent<AudioSource>();
Debug.Log(audioSource);
audioSource.spatialize = spatialize;
bufferedAudioStream = new BufferedAudioStream(audioSource);
decoder = new Decoder();
}
public void Stop()
{
}
public void AddCompressedData(byte[] compressedData)
{
if(decoder == null || bufferedAudioStream == null)
{
throw new System.Exception("VoipAudioSource failed to init");
}
float[] decompressedData = decoder.Decode(compressedData);
if (decompressedData != null && decompressedData.Length > 0)
{
bufferedAudioStream.AddData(decompressedData);
if (debugOutputData != null)
{
debugOutputData.AddRange(decompressedData);
}
}
}
void Update()
{
if (bufferedAudioStream == null)
{
throw new System.Exception("VoipAudioSource failed to init");
}
bufferedAudioStream.Update();
}
}
}
#endif