com.adrenak.univoice 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Runtime/ChatroomAgent.cs
CHANGED
|
@@ -150,23 +150,21 @@ namespace Adrenak.UniVoice {
|
|
|
150
150
|
RemovePeer(id);
|
|
151
151
|
|
|
152
152
|
// Stream the incoming audio data using the right peer output
|
|
153
|
-
Network.OnAudioReceived += data => {
|
|
153
|
+
Network.OnAudioReceived += (peerID, data) => {
|
|
154
154
|
// if we're muting all, no point continuing.
|
|
155
155
|
if (MuteOthers) return;
|
|
156
156
|
|
|
157
|
-
var id = data.id;
|
|
158
157
|
var index = data.segmentIndex;
|
|
159
158
|
var frequency = data.frequency;
|
|
160
159
|
var channels = data.channelCount;
|
|
161
160
|
var samples = data.samples;
|
|
162
161
|
|
|
163
|
-
EnsurePeerStreamer(
|
|
162
|
+
EnsurePeerStreamer(peerID, frequency, channels, samples.Length);
|
|
164
163
|
|
|
165
|
-
if (HasSettingsForPeer(
|
|
166
|
-
PeerOutputs[
|
|
164
|
+
if (HasSettingsForPeer(peerID) && !PeerSettings[peerID].muteThem)
|
|
165
|
+
PeerOutputs[peerID].Feed(index, frequency, channels, samples);
|
|
167
166
|
};
|
|
168
167
|
|
|
169
|
-
|
|
170
168
|
AudioInput.OnSegmentReady += (index, samples) => {
|
|
171
169
|
if (MuteSelf) return;
|
|
172
170
|
|
|
@@ -179,8 +177,7 @@ namespace Adrenak.UniVoice {
|
|
|
179
177
|
|
|
180
178
|
// Send the audio segment to every deserving recipient
|
|
181
179
|
foreach (var recipient in recipients)
|
|
182
|
-
Network.SendAudioSegment(new ChatroomAudioSegment {
|
|
183
|
-
id = recipient,
|
|
180
|
+
Network.SendAudioSegment(recipient, new ChatroomAudioSegment {
|
|
184
181
|
segmentIndex = index,
|
|
185
182
|
frequency = AudioInput.Frequency,
|
|
186
183
|
channelCount = AudioInput.ChannelCount,
|
|
@@ -208,9 +205,9 @@ namespace Adrenak.UniVoice {
|
|
|
208
205
|
bool HasSettingsForPeer(short id) => PeerSettings.ContainsKey(id);
|
|
209
206
|
|
|
210
207
|
void EnsurePeerStreamer(
|
|
211
|
-
short id,
|
|
212
|
-
int frequency,
|
|
213
|
-
int channels,
|
|
208
|
+
short id,
|
|
209
|
+
int frequency,
|
|
210
|
+
int channels,
|
|
214
211
|
int segmentLength
|
|
215
212
|
) {
|
|
216
213
|
if (!PeerOutputs.ContainsKey(id) && PeerSettings.ContainsKey(id)) {
|
|
@@ -20,7 +20,7 @@ namespace Adrenak.UniVoice {
|
|
|
20
20
|
/// Provides an exception as event data.
|
|
21
21
|
/// </summary>
|
|
22
22
|
event Action<Exception> OnChatroomCreationFailed;
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
/// <summary>
|
|
25
25
|
/// Fired when a chatroom is closed.
|
|
26
26
|
/// </summary>
|
|
@@ -58,12 +58,12 @@ namespace Adrenak.UniVoice {
|
|
|
58
58
|
/// <summary>
|
|
59
59
|
/// Fired when the network receives audio data from a peer.
|
|
60
60
|
/// </summary>
|
|
61
|
-
event Action<ChatroomAudioSegment> OnAudioReceived;
|
|
61
|
+
event Action<short, ChatroomAudioSegment> OnAudioReceived;
|
|
62
62
|
|
|
63
63
|
/// <summary>
|
|
64
64
|
/// Fired when the local user sets audio data to a peer.
|
|
65
65
|
/// </summary>
|
|
66
|
-
event Action<ChatroomAudioSegment> OnAudioSent;
|
|
66
|
+
event Action<short, ChatroomAudioSegment> OnAudioSent;
|
|
67
67
|
#endregion
|
|
68
68
|
|
|
69
69
|
// ====================================================================
|
|
@@ -111,7 +111,7 @@ namespace Adrenak.UniVoice {
|
|
|
111
111
|
/// Sends audio data over the network
|
|
112
112
|
/// </summary>
|
|
113
113
|
/// <param name="data">The data to be transmitted.</param>
|
|
114
|
-
void SendAudioSegment(ChatroomAudioSegment data);
|
|
114
|
+
void SendAudioSegment(short peerID, ChatroomAudioSegment data);
|
|
115
115
|
#endregion
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
namespace Adrenak.UniVoice {
|
|
2
|
+
[System.Serializable]
|
|
2
3
|
/// <summary>
|
|
3
4
|
/// A data structure representing the audio transmitted over the network.
|
|
4
5
|
/// </summary>
|
|
5
6
|
public struct ChatroomAudioSegment {
|
|
6
|
-
/// <summary>
|
|
7
|
-
/// ID of the peer that has sent the data
|
|
8
|
-
/// </summary>
|
|
9
|
-
public short id;
|
|
10
|
-
|
|
11
7
|
/// <summary>
|
|
12
8
|
/// The segment index of the audio samples
|
|
13
9
|
/// </summary>
|