adrenak / Univoice
Projects that are alternatives of or similar to Univoice
UniVoice
A Peer to Peer Voice Over IP (VoIP) solution for Unity
Intro
UniVoice uses UniMic to capture audio and AirPeer to form WebRTC based peer to peer connections between which audio data can be exchanged.
Usage
Basic
-
Voice.New(AudioSource src)
to create a newVoice
instance.src
is theAudioSource
component that will play the incoming audio.
var voice = Voice.New(GetComponent<AudioSource>());
-
Voice.Create(string name, Action<bool> callback)
creates a new room for voice chat.name
should be unique (globally),callback
is true if the room was created successfully, else false.
voice.Create("a3b4cd", success => Debug.Log("Room create success: " + success));
-
Voice.Join(string name, Action<bool> callback)
attempts to join an existing room.name
should be the one to be joined.callback
is true if the join was successful, else false.
voice.Join("a3b4cd", success => Debug.Log("Room join success: " + success));
-
Voice.OnJoin(ConnectionId id)
event fired on aVoice
instance that is serving as a host (ie..Create
was called on it) everytime a peer joins the room -
Voice.OnLeave(ConnectionId id)
event fired on aVoice
instance that is serving as a host (ie..Create
was called on it) everytime a peer leaves the room -
Voice.OnSendVoiceSegment(int index, float[] segment)
event fired everytime an audio segment was sent over the network.segment
is thefloat
representation of the audio andindex
represents the index of the segment. Eg. The first segment is indexed as 0 -
Voice.OnGetVoiceSegment(int index, float[] segment)
event fired everytime an audio segment is received over the network.segment
is thefloat
representation of the audio andindex
represents the index of the segment. Eg. The first segment is indexed as 0
Known Issues
- Room creation/join fails. This happens less often on mobile data (as compared to WiFi).
- More