com.adrenak.univoice 1.2.1 → 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.
@@ -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(id, frequency, channels, samples.Length);
162
+ EnsurePeerStreamer(peerID, frequency, channels, samples.Length);
164
163
 
165
- if (HasSettingsForPeer(id) && !PeerSettings[id].muteThem)
166
- PeerOutputs[id].Feed(index, frequency, channels, samples);
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,4 +1,5 @@
1
1
  namespace Adrenak.UniVoice {
2
+ [System.Serializable]
2
3
  /// <summary>
3
4
  /// Represents the mode that a <see cref="ChatroomAgent"/> is in.
4
5
  /// </summary>
@@ -4,11 +4,6 @@
4
4
  /// A data structure representing the audio transmitted over the network.
5
5
  /// </summary>
6
6
  public struct ChatroomAudioSegment {
7
- /// <summary>
8
- /// ID of the peer that has sent the data
9
- /// </summary>
10
- public short id;
11
-
12
7
  /// <summary>
13
8
  /// The segment index of the audio samples
14
9
  /// </summary>
@@ -1,4 +1,5 @@
1
1
  namespace Adrenak.UniVoice {
2
+ [System.Serializable]
2
3
  /// <summary>
3
4
  /// Represents settings associated with a peer in the chatroom
4
5
  /// </summary>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.adrenak.univoice",
3
- "version": "1.2.1",
3
+ "version": "2.0.0",
4
4
  "displayName": "Adrenak.UniVoice",
5
5
  "description": "Voice chat/VoIP solution for Unity.",
6
6
  "unity": "2019.4",