ODIN Unity SDK Reference

This document provides links to all the ODIN types available in the Unity SDK.

Classes

OdinHandler Class

Definition

Name
OdinHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinhandler
public class OdinHandler : MonoBehaviour

Properties

NameDescription
public static OdinEditorConfig Config { get; }Static reference to the global Unity
public static OdinHandler Instance { get; }Singleton reference to this OdinHandler
public bool HasConnections { get; }True if any Room is joined
public MicrophoneReader MicrophoneUnity Component that handles one Microphone where data gets routed through (n) Media
public RoomCollection Rooms { get; }
public RoomJoinProxy OnRoomJoinCalled before an actual room join
public RoomJoinedProxy OnRoomJoinedCalled after a room is joined successfully
public RoomLeaveProxy OnRoomLeaveCalled before a room leave
public RoomLeftProxy OnRoomLeftCalled after a room is destroyed
public PeerJoinedProxy OnPeerJoinedCalled on every Peer that joins the room(s) we're connected to
public PeerUserDataChangedProxy OnPeerUserDataChangedCalled on every Peer that updates his UserData in the same room(s)
public PeerLeftProxy OnPeerLeftCalled on every Peer that left in the same room(s)
public MediaAddedProxy OnMediaAddedCalled on every Peer that created a media in the same room(s)
public MediaRemovedProxy OnMediaRemovedCalled on every Peer that closed/destroyed one of his own media in the same room(s)
public MediaActiveStateChangedProxy OnMediaActiveStateChangedCalled on every activity change of a media in the same room(s)
public RoomUserDataChangedProxy OnRoomUserDataChangedCalled on the Room that updates his UserData
public MessageReceivedProxy OnMessageReceivedCalled on every Peer that received message from a peer by UInt64%5b%5d%2cSystem
public ConnectionStateChangedProxy OnConnectionStateChangedCalled on the Room that changed the connection state
public UnityCreatedMediaObject OnCreatedMediaObjectCalled if this OdinHandler created a MediaStream that was requested by the MediaQueue
public UnityDeleteMediaObject OnDeleteMediaObjectCalled if this OdinHandler destroyed a MediaStream that was closed by a remote peer and was requested by the MediaQueue
public readonly string UnityAudioSourceTagIdentify by Unity-Tag to attach a Audio
public bool Use3DAudioEnable 3D Audio via preset Odin
public bool CreatePlaybackCreates Room_OnMediaAdded(System events
public AudioMixer PlaybackAudioMixer
public AudioMixerGroup PlaybackAudioMixerGroup

Methods

NameDescription
public IUserData GetUserData()
public async void JoinRoom(string roomName, IUserData userData = null, Action<Room> setup = null)Join or create a room by name and attach a Media
public async void JoinRoom(string roomAlias, string token, UserData userData = null, Action<Room> setup = null)Join or create a room by name and attach a Media
public async void LeaveRoom(string roomName)Leave and free the Room by name
public PlaybackComponent AddPlaybackComponent(string gameObjectTag, string roomName, ulong peerId, long mediaStreamId, bool autoDestroySource = true)Tries to identifiy a gameobject by tag to assign the PlaybackComponent
public PlaybackComponent AddPlaybackComponent(GameObject peerContainer, string roomName, ulong peerId, long mediaStreamId, bool autoDestroySource = true)Tries to identifiy a gameobject by tag to assign the PlaybackComponent
public MicrophoneStream GetOrCreateMicrophoneStream(string roomName, OdinMediaConfig config = null)Returns the attached Audio
public void RoomsSetPositionScale(float scale)Configures the allowed 'view' distance for proximity calculation of peers in each room
public void RoomsUpdatePosition(float x, float y)Updates the two-dimensional position of our own peer in each room
public void UpdateUserData(IUserData userData)Updates the Rooms
public Room GetRoom(string id)Gets the room object from Odin
public Peer GetPeer(string roomId, ulong peerId)Gets the a Peer object from a specified room matching a peer ID
public PlaybackStream GetMedia(string roomId, long mediaStreamId)Get the PlaybackStream of a peer in the room
public IEnumerable<Peer> GetPeers(string roomId, bool includeSelf = false)Get all remote peers inside a room
public void BroadcastMessage(byte[] data)Sends arbitrary data to a all remote peers in all rooms
public PlaybackComponent[] GetPlaybackComponents()Gets all Audio across all rooms
public PlaybackComponent[] GetPlaybackComponents(string roomId)Gets all Audio across all rooms
public PlaybackComponent[] GetPlaybackComponents(ulong peerId)Gets all Audio across all rooms
public PlaybackComponent[] GetPlaybackComponents(long mediaStreamId)Gets all Audio across all rooms
public PlaybackComponent GetPlaybackComponent(string roomId, ulong peerId, long mediaStreamId)Gets a Audio
public void DestroyPlaybackComponents()Destroys all Audio instances
public void DestroyPlaybackComponents(string roomId)Destroys all Audio instances
public void DestroyPlaybackComponents(ulong peerId)Destroys all Audio instances
public void DestroyPlaybackComponents(long mediaStreamId)Destroys all Audio instances

NativeBindings Class

Definition

Name
NativeBindings
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/nativebindings
public static class NativeBindings

C# bindings for the native ODIN runtime

Properties

NameDescription
public const string OdinVersion = "1.0.0"ODIN_VERSION

OdinException Class

Definition

Name
OdinException
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinexception
public class OdinException : Exception

Exception type for the native ODIN runtime

Properties

NameDescription
public uint ErrorCodeOdinErrorCode

OdinLibrary Class

Definition

Name
OdinLibrary
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinlibrary
public static class OdinLibrary

Main lib entry class

Properties

NameDescription
public static bool IsInitialized { get; }Indicates whether or not the native ODIN runtime has been loaded and initialized
public static string NativeBinary { get; }Location of the native ODIN runtime binary
public static SupportedPlatform Platform { get; }Platform the library is running on

Methods

NameDescription
public static void Initialize()Initializes the native ODIN runtime
public static void Initialize(OdinLibraryParameters parameters)Initializes the native ODIN runtime
public static void Release()Releases the unmanaged resources used by the Core-Instance

OdinLibraryParameters Class

Definition

Name
OdinLibraryParameters
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinlibraryparameters
public class OdinLibraryParameters

A set of values that are used when initializing the native ODIN runtime

Properties

NameDescription
public string[] PossibleNativeBinaryLocations { get; set; }Possible install location of the native ODIN runtime binary
public SupportedPlatform Platform { get; set; }Determines which platform specific code needs to be executed

Methods

NameDescription
public static bool TryGetNativeBinaryName(out string[] names, out SupportedPlatform platform)Returns the name of the native ODIN runtime binary that fits the current environment

OdinMediaConfig Class

Definition

Name
OdinMediaConfig
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinmediaconfig
public class OdinMediaConfig

ODIN audio stream configuration

Properties

NameDescription
public MediaSampleRate SampleRate { get; set; }The number audio samples carried per second in Hz
public MediaChannels Channels { get; set; }The number of audio channels

Methods

NameDescription
public override string ToString()Debug

OdinRoomConfig Class

Definition

Name
OdinRoomConfig
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinroomconfig
public class OdinRoomConfig : IOdinApmConfig

Audio processing configuration of an ODIN room

Properties

NameDescription
public bool VoiceActivityDetection { get; set; }Enables or disables voice activity detection (VAD)
public float VoiceActivityDetectionAttackProbability { get; set; }Voice probability value when the VAD should engage.
public float VoiceActivityDetectionReleaseProbability { get; set; }Voice probability value when the VAD should disengage after previously being engaged.
public bool VolumeGate { get; set; }Enables or disables volume gate
public float VolumeGateAttackLoudness { get; set; }Root mean square power (dBFS) when the volume gate should engage.
public float VolumeGateReleaseLoudness { get; set; }Root mean square power (dBFS) when the volume gate should disengage after previously being engaged.
public bool EchoCanceller { get; set; }Enable or disable echo cancellation
public bool HighPassFilter { get; set; }Enable or disable high pass filtering
public bool PreAmplifier { get; set; }Enable or disable the pre amplifier
public OdinNoiseSuppressionLevel NoiseSuppressionLevel { get; set; }Set the aggressiveness of the suppression
public bool TransientSuppressor { get; set; }Enable or disable the transient suppressor

Methods

NameDescription
public static OdinRoomConfig GetOdinDefault()Creates Apm OdinRoomConfig based on Odin
public override string ToString()Debug

Utility Class

Definition

Name
Utility
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/utility
public static class Utility

Properties

NameDescription
public const uint OK = 0URepresentative ErrorCode for Ok.

Methods

NameDescription
public static int RateToSamples(MediaSampleRate sampleRate = MediaSampleRate.Hz48000, int ms = 20)Get sample size by samplerate and time
public static bool IsError(uint error)Determines if the specified error code identifies an actual error.

MediaCollection Class

Definition

Name
MediaCollection
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediacollection
public class MediaCollection : IReadOnlyCollection&lt;MediaStream&gt;, IEqualityComparer&lt;MediaStream&gt;

Internal collection of available media streams

Properties

NameDescription
public MediaStream this[long key] { get; }Try to get a media stream by ID
public int Count { get; }Count of streams in the collection
public bool IsReadOnly { get; }Indicates whether elements can be added or removed from the collection

Methods

NameDescription
public bool Add(MediaStream item)Add a stream to the collection
public void Clear()Free and empty the collection
public bool Contains(long id)Determines whether the stream by id is in the collection
public bool Contains(MediaStream item)Determines whether the stream by id is in the collection
public void CopyTo(MediaStream[] array, int arrayIndex)Copies stream of the collection to an array
public bool Equals(MediaStream x, MediaStream y)Determines whether the streams are equal
public IEnumerator<MediaStream> GetEnumerator()Get enumerator for iteration
public int GetHashCode(MediaStream obj)Default GetHashCode
public bool Remove(long id)Remove a stream by handle id from the collection
public bool Remove(MediaStream item)Remove a stream by handle id from the collection
public void SetMute(bool value)Set IsMuted on each Media

MediaStream Class

Definition

Name
MediaStream
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediastream
public abstract class MediaStream : IVideoStream, IAudioStream, IDisposable

Base stream

Properties

NameDescription
public long Id { get; }Handle ID
public OdinMediaConfig MediaConfig { get; }Audio config of the media stream
public CancellationTokenSource CancellationSource { get; }Control of async read and write tasks
public bool IsPaused { get; set; }Indicates wether or not the media stream is paused
public bool IsMuted { get; set; }Indicates wether or not the media stream is muted
public bool IsActive { get; }Indicates wether or not the media stream is active and sending/receiving data
public bool HasErrors { get; }
public bool IsInvalid { get; }

Methods

NameDescription
public ushort GetMediaId()Returns the media stream ID and updates Id.
public ulong GetPeerId()Returns the ID of the peer that own this media stream.
public void SetPause(bool value)Sets IsPaused.
public void TogglePause()Toggles IsPaused.
public void SetMute(bool value)Sets IsMuted.
public void ToggleMute()Toggles IsMuted.
public virtual void AudioPushData(float[] buffer)Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.
public virtual void AudioPushData(float[] buffer, int length)Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.
public virtual Task AudioPushDataTask(float[] buffer, CancellationToken cancellationToken)Sends data to the audio stream. The data has to be interleaved [-1, 1] float data.
public virtual async void AudioPushDataAsync(float[] buffer)Sends audio data using a custom CancellationSource. The data has to be interleaved [-1, 1] float data.
public virtual uint AudioReadData(float[] buffer)Reads data from the audio stream.
public virtual uint AudioReadData(float[] buffer, int length)Reads data from the audio stream.
public virtual Task<uint> AudioReadDataTask(float[] buffer, CancellationToken cancellationToken)Reads data from the audio stream.
public virtual async Task<uint> AudioReadDataAsync(float[] buffer)Read audio data using a custom custom CancellationSource.
public virtual uint AudioDataLength()Get the number of samples available in the audio buffer.
public virtual bool AudioResample(float[] input, uint outputSampleRate, out float[] output, out int capacity)Set a resampler and resamples a chunk of audio.
public virtual uint AudioResample(float[] input, uint outputSampleRate, float[] output, int capacity)Set a resampler and resamples a chunk of audio.
public bool Cancel()Cancel the custom CancellationSource.
public override string ToString()Debug
public void Dispose()On dispose will free the stream and resampler

MicrophoneStream Class

Definition

Name
MicrophoneStream
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/microphonestream
public class MicrophoneStream : MediaStream, IVideoStream, IAudioStream, IDisposable

Representation of a write only audio stream

Methods

NameDescription
public override uint AudioReadData(float[] buffer)AudioReadData and AudioReadDataAsync are not supported!
public override Task<uint> AudioReadDataTask(float[] buffer, CancellationToken cancellationToken)AudioReadData and AudioReadDataAsync are not supported!
public override Task<uint> AudioReadDataAsync(float[] buffer)AudioReadData and AudioReadDataAsync are not supported!
public override uint AudioDataLength()Get the number of samples available in the audio buffer.

PlaybackStream Class

Definition

Name
PlaybackStream
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/playbackstream
public class PlaybackStream : MediaStream, IVideoStream, IAudioStream, IDisposable

Representation of a read only audio stream

Methods

NameDescription
public override void AudioPushData(float[] buffer)AudioPushDataTask and AudioPushDataAsync are not supported!
public override Task AudioPushDataTask(float[] buffer, CancellationToken cancellationToken)AudioPushDataTask and AudioPushDataAsync are not supported!
public override void AudioPushDataAsync(float[] buffer)AudioPushDataTask and AudioPushDataAsync are not supported!

OdinClient Class

Definition

Name
OdinClient
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinclient
public class OdinClient : IDisposable

Client Wrapper for ODIN ffi OdinLibrary

Properties

NameDescription
public RoomCollection Rooms { get; }A collection of all Room
public Uri EndPoint { get; }Connection EndPoint. Default from OdinEditorConfig.
public string AccessKey { get; }Client AccessKey for all new rooms. Default from OdinHandler config.
public IUserData UserData { get; set; }Client custom UserData

Methods

NameDescription
public async Task<Room> JoinRoom(string name, string userId)Join or create a Room by name via a gateway
public async Task<Room> JoinRoom(string name, string userId, Action<Room> setup = null)Join or create a Room by name via a gateway
public async Task<Room> JoinRoom(string name, string userId, IUserData userData, Action<Room> setup)Join or create a Room by name via a gateway
public async Task<Room> JoinRoom(string token, IUserData userData, Action<Room> setup)Join or create a Room by name via a gateway
public async Task<Room> JoinNamedRoom(string roomalias, string token, IUserData userData = null, Action<Room> setup = null)Join or create a named Room by token via a gateway
public async void UpdateUserData(IUserData userData)Updates the Rooms for the current peer
public async void SetPositionScale(float scale)Updates the Rooms
public async void UpdatePosition(float x, float y)Updates the Rooms
public async Task<bool> LeaveRoom(string name)Leave a joined Room
public void Close()Completly closes this Client and all Room associated.
public void Dispose()On dispose will free all NativeMethods

OdinDefaults Class

Definition

Name
OdinDefaults
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odindefaults
public static class OdinDefaults

ODIN default configuration

Properties

NameDescription
public static bool VerboseEnable additional logs
public static bool DebugEnable additional debug logs
public static string AccessKey { get; set; }Default access key
public static string Server { get; set; }Default server url
public static string UserDataText { get; set; }Default text representation of UserData
public static MediaSampleRate DeviceSampleRate { get; set; }Microphone default Sample-Rate
public static MediaChannels DeviceChannels { get; set; }Microphone default Channel
public static MediaSampleRate RemoteSampleRate { get; set; }Playback default Sample-Rate
public static MediaChannels RemoteChannels { get; set; }Playback default Channel
public static bool PeerJoinedEventIdicates whether the event is enabled by default
public static bool PeerLeftEventIdicates whether the event is enabled by default
public static bool PeerUpdatedEventIdicates whether the event is enabled by default
public static bool MediaAddedEventIdicates whether the event is enabled by default
public static bool MediaRemovedEventIdicates whether the event is enabled by default
public static bool RoomUpdatedEventIdicates whether the event is enabled by default
public static bool MediaActiveStateChangedEventIdicates whether the event is enabled by default
public static bool MessageReceivedEventIdicates whether the event is enabled by default
public static ulong TokenLifetime { get; set; }JWT room token lifetime
public static bool VoiceActivityDetectionIdicates whether the ApmConfig setting is enabled by default
public static float VoiceActivityDetectionAttackProbabilityIdicates the vad attack probability ApmConfig setting by default
public static float VoiceActivityDetectionReleaseProbabilityIdicates the vad release probability ApmConfig setting by default
public static bool VolumeGateIdicates whether the ApmConfig setting is enabled by default
public static float VolumeGateAttackLoudnessIdicates the gate attack loudness ApmConfig setting by default
public static float VolumeGateReleaseLoudnessIdicates the gate release loudness ApmConfig setting by default
public static bool EchoCancellerIdicates whether the ApmConfig setting is enabled by default
public static bool HighPassFilterIdicates whether the ApmConfig setting is enabled by default
public static bool PreAmplifierIdicates whether the ApmConfig setting is enabled by default
public static NativeBindings.OdinNoiseSuppressionLevel NoiseSuppressionLevelIdicates the level of noise suppression ApmConfig setting by default
public static bool TransientSuppressorIdicates whether the ApmConfig setting is enabled by default

Peer Class

Definition

Name
Peer
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peer
public class Peer : IDisposable

Client/Remote peer

Properties

NameDescription
public ulong Id { get; }Peer id
public string RoomName { get; }Associated room name of this peer
public string UserId { get; }Peers user id
public UserData UserData { get; }Peer userdata
public MediaCollection Medias { get; }Associated medias of this peer

Methods

NameDescription
public void AddMedia(PlaybackStream stream)Associate a media with the peer
public bool RemoveMedia(long mediaStreamId)Remove a associated media from the peer
public List<long> GetMediaStreamIds()Get a copy of all ids of Media from this peer
public void SetMuteMedias(bool value)Set IsMuted on each current associated Media
public override string ToString()Debug
public void Dispose()Free peer with all associated medias

PeerCollection Class

Definition

Name
PeerCollection
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peercollection
public class PeerCollection : IReadOnlyCollection&lt;Peer&gt;, IEqualityComparer&lt;Peer&gt;

Intern peer dictionary

Properties

NameDescription
public Peer this[ulong key] { get; }Try to get Peer by id
public int Count { get; }Count of peers in the collection
public bool IsReadOnly { get; }Indicates whether elements can be added or removed from the collection

Methods

NameDescription
public bool Add(Peer item)Add a peer to the collection
public void Clear()Free and empty the collection
public bool Contains(ulong id)Determines whether the peer by id is in the collection
public bool Contains(Peer item)Determines whether the peer by id is in the collection
public void CopyTo(Peer[] array, int arrayIndex)Copies peers of the collection to an array
public bool Equals(Peer x, Peer y)Determines whether the peers are equal
public IEnumerator<Peer> GetEnumerator()Get enumerator for iteration
public int GetHashCode(Peer obj)Default GetHashCode
public bool Remove(ulong id)Remove a peer by id from the collection
public bool Remove(Peer item)Remove a peer by id from the collection

ConnectionStateChangedEventArgs Class

Definition

Name
ConnectionStateChangedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/connectionstatechangedeventargs
public class ConnectionStateChangedEventArgs : EventArgs

Arguments for ConnectionStateChanged events in the current room

Properties

NameDescription
public NativeBindings.OdinRoomConnectionState ConnectionState { get; }Connection state of the ODIN client
public NativeBindings.OdinRoomConnectionStateChangeReason ChangeReason { get; }Reason of connection state
public int Retry { get; }Connection retry count

MediaActiveStateChangedEventArgs Class

Definition

Name
MediaActiveStateChangedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediaactivestatechangedeventargs
public class MediaActiveStateChangedEventArgs : EventArgs

Arguments for MediaActiveStateChanged events in the current room

Properties

NameDescription
public long MediaStreamId { get; }stream handle id
public ulong PeerId { get; }peer id
public bool Active { get; }state of the media

MediaAddedEventArgs Class

Definition

Name
MediaAddedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediaaddedeventargs
public class MediaAddedEventArgs : EventArgs

Arguments for MediaAdded events in the current room

Properties

NameDescription
public ulong PeerId { get; }peer id
public Peer Peerpeer object
public PlaybackStream MediaMedia

MediaRemovedEventArgs Class

Definition

Name
MediaRemovedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediaremovedeventargs
public class MediaRemovedEventArgs : EventArgs

Arguments for MediaRemoved events in the current room

Properties

NameDescription
public long MediaStreamId { get; }stream handle id
public Peer Peerpeer object

MessageReceivedEventArgs Class

Definition

Name
MessageReceivedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/messagereceivedeventargs
public class MessageReceivedEventArgs : EventArgs

Arguments for MessageReceived events in the current room

Properties

NameDescription
public ulong PeerId { get; }peer id
public byte[] Dataarbitrary data

PeerJoinedEventArgs Class

Definition

Name
PeerJoinedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peerjoinedeventargs
public class PeerJoinedEventArgs : EventArgs

Arguments for PeerJoined events in the current room

Properties

NameDescription
public ulong PeerId { get; }peer Id
public string UserId { get; }user Id
public Peer Peerpeer object

PeerLeftEventArgs Class

Definition

Name
PeerLeftEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peerlefteventargs
public class PeerLeftEventArgs : EventArgs

Arguments for PeerLeft events in the current room

Properties

NameDescription
public ulong PeerId { get; }peer id

PeerUserDataChangedEventArgs Class

Definition

Name
PeerUserDataChangedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peeruserdatachangedeventargs
public class PeerUserDataChangedEventArgs : EventArgs

Arguments for PeerUserDataChanged events in the current room

Properties

NameDescription
public ulong PeerId { get; }peer id
public Peer Peerpeer object
public UserData UserDatapeer userdata

Room Class

Definition

Name
Room
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/room
public class Room : IDisposable

Main Room

Properties

NameDescription
public static KeyValuePair<OdinRoomConnectionState, OdinRoomConnectionStateChangeReason> ConnectionState { get; }ConnectionState of the Room that is set by ODIN
public int ConnectionRetry { get; }The count of ConnectionState OdinRoomConnectionState retry for reconnects. Reset on Connected
public readonly RoomConfig ConfigRoom configuration
public bool IsJoined { get; }true on successful Join or false
public Peer Self { get; }Client Peer
public UserData RoomUserData { get; }
public PeerCollection RemotePeers { get; }Conatiner of room peers
public IEnumerable<MediaCollection> PlaybackMedias { get; }Get all medias of room peers
public MicrophoneStream MicrophoneMedia { get; }Current room microphone data route

Methods

NameDescription
public string GetRoomId()Retrieves the room ID (e.g. the name of the room)
public string GetRoomCustomer()Retrieves the identifier of the customer the room
public ulong GetRoomPeerId()Retrieves your own peer ID
public bool SetApmConfig(OdinRoomConfig config)Set rooms new Apm config
public bool Join(string name, string userId, IUserData userData = null)Join the room via Odin gateway
public bool Join(string token)Join the room via Odin gateway
public bool CreateMicrophoneMedia(OdinMediaConfig config)Try to add a MicrophoneMedia
public bool UpdatePeerUserData(IUserData userData)Updates the user data for our own peer. The server will populate this data to all other visible peers in the same room.
public async Task<bool> UpdatePeerUserDataAsync(IUserData userData)Updates the user data for our own peer. The server will populate this data to all other visible peers in the same room.
public bool UpdateRoomUserData(IUserData userData)Updates the user data for the current room.
public async Task<bool> UpdateRoomUserDataAsync(IUserData userData)Updates the user data for the current room.
public bool SendMessage(ulong[] peerIdList, byte[] data)Sends arbitrary data to a array of target peerIds.
public async Task<bool> SendMessageAsync(ulong[] peerIdList, byte[] data)Sends arbitrary data to a array of target peerIds.
public bool BroadcastMessage(byte[] data, bool includeSelf = false)Sends arbitrary data to a all remote peers in this room.
public async Task<bool> BroadcastMessageAsync(byte[] data, bool includeSelf = false)Sends arbitrary data to a all remote peers in this room.
public List<ulong> GetRemotePeersIds(bool includeSelf)Get a copy of all PeerIds in this room
public ILookup<ulong, IEnumerable<long>> GetRemotePeersMediaStreamIds()All ids of Media from remote peers in this room
public bool SetMicrophoneMute(bool mute)Will set the room MicrophoneMedia to mute
public bool SetPositionScale(float scale)Configures the allowed 'view' distance for proximity calculation of peers in the room
public bool UpdatePosition(float x, float y)Updates the two-dimensional position of our own peer in the room
public override string ToString()Debug
public void Leave()Leave a room and free all remote peers and associated medias
public void Dispose()On dispose will free the room and token generator

RoomCollection Class

Definition

Name
RoomCollection
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomcollection
public class RoomCollection : IReadOnlyCollection&lt;Room&gt;, IEqualityComparer&lt;Room&gt;

Intern room dictionary

Properties

NameDescription
public Room this[string key] { get; }Try to get room by name
public int Count { get; }Count of rooms in the collection
public bool IsRemoveOnly { get; }Indicates whether elements can be removed from the collection

Methods

NameDescription
public bool Add(Room item)Add a room to the collection
public void Clear()Free and empty the collection
public bool Contains(string key)Determines whether the room by name/token is in the collection
public bool Contains(Room item)Determines whether the room by name/token is in the collection
public void CopyTo(Room[] array, int arrayIndex)Copies rooms of the collection to an array
public bool Equals(Room x, Room y)Compares two rooms by name
public IEnumerator<Room> GetEnumerator()Get enumerator for iteration
public int GetHashCode(Room obj)Default GetHashCode
public bool Remove(string key)Removes the room from this collection
public bool Remove(Room item)Removes the room from this collection
public void Leave(string key)Get the room and leave

RoomConfig Class

Definition

Name
RoomConfig
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomconfig
public class RoomConfig

A set of values that are used when creating Rooms

Properties

NameDescription
public string AccessKeyRoom associated AccessKey
public ulong TokenLifetimeRoom associated Token lifetime
public string NameRoom name
public string TokenRoom token
public string ServerRoom associated endpoint
public bool HasEventCallbackstrue if Room where set and registered in ODIN ffi
public OdinRoomConfig ApmConfigConfiguration for NativeBindings
public OdinMediaConfig PlaybackMediaConfigConfiguration for Media on new medias

Methods

NameDescription
public override string ToString()Debug

RoomJoinEventArgs Class

Definition

Name
RoomJoinEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomjoineventargs
public class RoomJoinEventArgs : EventArgs

Arguments for RoomJoin events right before the room is joined

Properties

NameDescription
public Room Roomroom object

RoomJoinedEventArgs Class

Definition

Name
RoomJoinedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomjoinedeventargs
public class RoomJoinedEventArgs : EventArgs

Arguments for RoomJoined events when the room was joined successfully

Properties

NameDescription
public Room Roomroom object

RoomLeaveEventArgs Class

Definition

Name
RoomLeaveEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomleaveeventargs
public class RoomLeaveEventArgs : EventArgs

Arguments for RoomLeave events right before the room handle is destroyed

Properties

NameDescription
public Room Roomroom object

RoomLeftEventArgs Class

Definition

Name
RoomLeftEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomlefteventargs
public class RoomLeftEventArgs : EventArgs

Arguments for RoomLeft events when the room handle was destroyed

Properties

NameDescription
public string RoomNameroom name

RoomUserDataChangedEventArgs Class

Definition

Name
RoomUserDataChangedEventArgs
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomuserdatachangedeventargs
public class RoomUserDataChangedEventArgs : EventArgs

Arguments for RoomUserDataChanged events in the current room

Properties

NameDescription
public string RoomName { get; }room name
public UserData Dataroom userdata

UserData Class

Definition

Name
UserData
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/userdata
public class UserData : IUserData

Odin UserData helper for marshal byte arrays

Properties

NameDescription
public Encoding Encoding { get; set; }Default Encoding
public byte[] Buffer { get; set; }Raw UserData

Methods

NameDescription
public virtual void CopyFrom(IntPtr ptr, ulong size)Copies data from memory to Buffer
public virtual bool IsEmpty()Indicates whether data is null or empty
public virtual bool Contains(string value)Indicates whether substring occurs
public virtual bool Contains(byte value)Indicates whether substring occurs
public virtual IEnumerable<int> PatternAt(byte[] pattern)Indicates whether two sequence are equal
public virtual UserData Clone()Creates a shallow copy of the Buffer
public virtual byte[] ToBytes()Used for converting Data on network level
public override string ToString()String representation of Buffer based on the specified encoding

MicrophoneReader Class

Definition

Name
MicrophoneReader
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/microphonereader
public class MicrophoneReader : MonoBehaviour

Handles microphone input data and sends input to ODIN

Properties

NameDescription
public bool HasPermission { get; }Check if the user has authorized use of the microphone
public bool RedirectCapturedAudioSkips registered PushAudio for the OnMicrophoneData event
public bool SilenceCapturedAudioZero out the event audio buffer for PushAudio.
public bool ContinueRecording
public int AudioClipLength
public bool OverrideSampleRateUse set DeviceSampleRate on false
public MediaSampleRate SampleRateThe recording Core
public bool CustomInputDeviceEnable/Disable the use of InputDevice as a new/fixed device name
public string InputDeviceThe device name to use as microphone in Unity. (i.e Microphone.Start)
public bool AutostartListenUse (Microphone.Start) in MicrophoneReader
public bool CustomMicVolumeScale
public float MicVolumeScale
public bool LoopbackCreate and play (AudioSource) with a Microphone (AudioClip) on loop.
public MicrophoneReader.MicrophoneCallbackDelegate OnMicrophoneDataEvent is fired if raw microphone data is available

Methods

NameDescription
public bool StartListen()Start Unity microphone capture
public void StopListen()Stop Unity Microphone capture if this AudioSender created the recording

PlaybackComponent Class

Definition

Name
PlaybackComponent
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/playbackcomponent
public class PlaybackComponent : MonoBehaviour

Handles the Playback for received ODIN audio data.

Properties

NameDescription
public AudioSource PlaybackSourceThe Unity AudioSource component for playback
public bool AutoDestroyAudioSourceOn true destroy the PlaybackSource in dispose to not leak (AudioSource) or false for manually manage sources
public bool AutoDestroyMediaStreamOn true destroy the Media in dispose to not leak or false for manually manage stream
public MediaSampleRate SampleRateThe playback Core
public bool Mute { get; set; }The Unity AudioSource mute property
public string RoomName { get; set; }Room name for this playback. Change this value to change the PlaybackStream by Rooms from the Client.
public ulong PeerId { get; set; }Peer id for this playback. Change this value to change the PlaybackStream by RemotePeers in the Room.
public long MediaStreamId { get; set; }Media id for this playback. Change this value to pick a PlaybackStream by media id from peers Medias.
public bool HasActivity { get; }

Methods

NameDescription
public NativeBindings.OdinAudioStreamStats GetOdinAudioStreamStats()

PlaybackStats Class

Definition

Name
PlaybackStats
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/playbackstats
public class PlaybackStats : MonoBehaviour

Properties

NameDescription
public bool Log
public bool PauseAnimationCurve
public uint PacketsProcessed
public uint PacketsDroppedEarly
public uint PacketsDroppedLate
public uint PacketsLost
public AnimationCurve PacketsAvailableDifference

ConnectionStateChangedProxy Class

Definition

Name
ConnectionStateChangedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/connectionstatechangedproxy
public class ConnectionStateChangedProxy : UnityEvent&lt;object, ConnectionStateChangedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

MediaActiveStateChangedProxy Class

Definition

Name
MediaActiveStateChangedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediaactivestatechangedproxy
public class MediaActiveStateChangedProxy : UnityEvent&lt;object, MediaActiveStateChangedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

MediaAddedProxy Class

Definition

Name
MediaAddedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediaaddedproxy
public class MediaAddedProxy : UnityEvent&lt;object, MediaAddedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

MediaRemovedProxy Class

Definition

Name
MediaRemovedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/mediaremovedproxy
public class MediaRemovedProxy : UnityEvent&lt;object, MediaRemovedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

MessageReceivedProxy Class

Definition

Name
MessageReceivedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/messagereceivedproxy
public class MessageReceivedProxy : UnityEvent&lt;object, MessageReceivedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

PeerJoinedProxy Class

Definition

Name
PeerJoinedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peerjoinedproxy
public class PeerJoinedProxy : UnityEvent&lt;object, PeerJoinedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

PeerLeftProxy Class

Definition

Name
PeerLeftProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peerleftproxy
public class PeerLeftProxy : UnityEvent&lt;object, PeerLeftEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

PeerUserDataChangedProxy Class

Definition

Name
PeerUserDataChangedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/peeruserdatachangedproxy
public class PeerUserDataChangedProxy : UnityEvent&lt;object, PeerUserDataChangedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

RoomJoinProxy Class

Definition

Name
RoomJoinProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomjoinproxy
public class RoomJoinProxy : UnityEvent&lt;RoomJoinEventArgs&gt;

This class provides the base functionality for ODIN SDK UnityEvents. A persistent callback that can be saved with the Scene.

RoomJoinedProxy Class

Definition

Name
RoomJoinedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomjoinedproxy
public class RoomJoinedProxy : UnityEvent&lt;RoomJoinedEventArgs&gt;

This class provides the base functionality for ODIN SDK UnityEvents. A persistent callback that can be saved with the Scene.

RoomLeaveProxy Class

Definition

Name
RoomLeaveProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomleaveproxy
public class RoomLeaveProxy : UnityEvent&lt;RoomLeaveEventArgs&gt;

This class provides the base functionality for ODIN SDK UnityEvents. A persistent callback that can be saved with the Scene.

RoomLeftProxy Class

Definition

Name
RoomLeftProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomleftproxy
public class RoomLeftProxy : UnityEvent&lt;RoomLeftEventArgs&gt;

This class provides the base functionality for ODIN SDK UnityEvents. A persistent callback that can be saved with the Scene.

RoomUserDataChangedProxy Class

Definition

Name
RoomUserDataChangedProxy
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/roomuserdatachangedproxy
public class RoomUserDataChangedProxy : UnityEvent&lt;object, RoomUserDataChangedEventArgs&gt;

This class provides the base functionality for UnityEvents based Room. A persistent callback that can be saved with the Scene. Unity Inspector event wrapper (UnityEvent)

UnityCreatedMediaObject Class

Definition

Name
UnityCreatedMediaObject
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/unitycreatedmediaobject
public class UnityCreatedMediaObject : UnityEvent&lt;string, ulong, long&gt;

UnityDeleteMediaObject Class

Definition

Name
UnityDeleteMediaObject
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/unitydeletemediaobject
public class UnityDeleteMediaObject : UnityEvent&lt;long&gt;

Unity Inspector event wrapper (UnityEvent)

OdinBanner Class

Definition

Name
OdinBanner
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odinbanner
public class OdinBanner : MonoBehaviour

OdinEditorConfig Class

Definition

Name
OdinEditorConfig
Link to documentation
https://www.4players.io/odin/sdk/unity/classes/odineditorconfig
public class OdinEditorConfig : MonoBehaviour, IOdinApmConfig

UnityEditor UI component for instance config of Odin

Properties

NameDescription
public bool VerboseEnable additional Logs
public bool VerboseDebugEnable additional Logs
public string AccessKeyOdin Client ApiKey
public string ClientIdOdin Client ID
public string ServerGateway
public string UserDataTextDefault UserData content
public MediaSampleRate DeviceSampleRateMicrophone Sample-Rate
public MediaChannels DeviceChannelsMicrophone Channels
public MediaSampleRate RemoteSampleRatePlayback Sample-Rate
public MediaChannels RemoteChannelsPlayback Channels
public bool PeerJoinedEvent
public bool PeerLeftEvent
public bool PeerUpdatedEvent
public bool MediaAddedEvent
public bool MediaRemovedEvent
public bool RoomUpdatedEvent
public bool MediaActiveStateChangedEvent
public bool MessageReceivedEvent
public ulong TokenLifetimeTime untill the token expires
public bool VoiceActivityDetectionTurns VAD on and off
public float VoiceActivityDetectionAttackProbabilitySetup engage of VAD
public float VoiceActivityDetectionReleaseProbabilitySetup disengage of VAD
public bool VolumeGateTurns volume gate on and off
public float VolumeGateAttackLoudnessSetup engage of volume gate
public float VolumeGateReleaseLoudnessSetup disengage of volume gate
public bool EchoCancellerTurns Echo cancellation on and off
public bool HighPassFilterReduces lower frequencies of the input (Automatic game control)
public bool PreAmplifierAmplifies the audio input
public NativeBindings.OdinNoiseSuppressionLevel NoiseSuppressionLevelTurns noise suppression on and off
public bool TransientSuppressorFilters high amplitude noices
public bool GainControllerTurns gain controller on and off

Methods

NameDescription
public void GenerateUIAccessKey()

Interfaces

IOdinApmConfig Interface

Definition

Name
IOdinApmConfig
Link to documentation
https://www.4players.io/odin/sdk/unity/interfaces/iodinapmconfig
public interface IOdinApmConfig

Interface for Audio processing configuration of an ODIN room

IUserData Interface

Definition

Name
IUserData
Link to documentation
https://www.4players.io/odin/sdk/unity/interfaces/iuserdata
public interface IUserData

interface for transmitting UserData

Methods

NameDescription
bool IsEmpty()Indicates whether data is null or empty
byte[] ToBytes()Used for converting Data on network level

Enums

OdinNoiseSuppressionLevel Enum

Definition

Name
OdinNoiseSuppressionLevel
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/odinnoisesuppressionlevel
public enum OdinNoiseSuppressionLevel

Valid levels for aggressiveness of the noise suppression

Properties

NameDescription
None = 0None
Low = 16dB
Moderate = 212 dB
High = 318 dB
VeryHigh = 421 dB

OdinRoomConnectionState Enum

Definition

Name
OdinRoomConnectionState
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/odinroomconnectionstate
public enum OdinRoomConnectionState

Connection state of the ODIN client

Properties

NameDescription
Connecting = 0Connection is being established
Connected = 1Connection is established
Disconnected = 2Connection is closed

OdinRoomConnectionStateChangeReason Enum

Definition

Name
OdinRoomConnectionStateChangeReason
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/odinroomconnectionstatechangereason
public enum OdinRoomConnectionStateChangeReason

Reason of connection state

Properties

NameDescription
ClientRequested = 0Connection state change was initiated by the user
ServerRequested = 1Connection state change was initiated by the server (e.g. peer was kicked)
ConnectionLost = 2Connection state change was caused by a timeout

OdinUserDataTarget Enum

Definition

Name
OdinUserDataTarget
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/odinuserdatatarget
public enum OdinUserDataTarget

Supported targets for user data updates.

Properties

NameDescription
OdinUserDataTarget_Peer = 0Peer UserData
OdinUserDataTarget_Room = 1Room UserData

MediaChannels Enum

Definition

Name
MediaChannels
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/mediachannels
public enum MediaChannels : byte

Supported values for audio channel count

Properties

NameDescription
Mono = 1Defines a single (monaural) channel
Stereo = 2Defines two (stereo) channels

MediaSampleRate Enum

Definition

Name
MediaSampleRate
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/mediasamplerate
public enum MediaSampleRate : uint

Supported audio sample rate values

Properties

NameDescription
Device_Min = 0UHardware device min samplerate
Device_Max = 1UHardware device max samplerate
Hz8000 = 8000U8khz
Hz11025 = 11025U11.025khz
Hz12000 = 12000U12khz
Hz16000 = 16000U16khz
Hz22050 = 22050U22.05khz
Hz24000 = 24000U24khz
Hz32000 = 32000U32khz
Hz44100 = 44100U44.1khz
Hz48000 = 48000U48khz
Hz96000 = 96000U96khz
Hz128000 = 128000U128khz
Hz144000 = 144000U144khz
Hz192000 = 192000U192khz

SupportedPlatform Enum

Definition

Name
SupportedPlatform
Link to documentation
https://www.4players.io/odin/sdk/unity/enums/supportedplatform
public enum SupportedPlatform

Platforms supported by the native ODIN runtime

Properties

NameDescription
Android = 0
MacOSX = 1
Linux = 2
Windows = 3

Delegates

MediaActiveStateChangedEventHandler Delegate

Definition

Name
MediaActiveStateChangedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/mediaactivestatechangedeventhandler
public delegate void MediaActiveStateChangedEventHandler(object sender, MediaActiveStateChangedEventArgs e);

EventHandler in the current room

RoomConnectionStateChangedEventHandler Delegate

Definition

Name
RoomConnectionStateChangedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roomconnectionstatechangedeventhandler
public delegate void RoomConnectionStateChangedEventHandler(object sender, ConnectionStateChangedEventArgs e);

EventHandler in the current room

RoomMediaAddedEventHandler Delegate

Definition

Name
RoomMediaAddedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roommediaaddedeventhandler
public delegate void RoomMediaAddedEventHandler(object sender, MediaAddedEventArgs e);

EventHandler in the current room

RoomMediaRemovedEventHandler Delegate

Definition

Name
RoomMediaRemovedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roommediaremovedeventhandler
public delegate void RoomMediaRemovedEventHandler(object sender, MediaRemovedEventArgs e);

EventHandler in the current room

RoomMessageReceivedEventHandler Delegate

Definition

Name
RoomMessageReceivedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roommessagereceivedeventhandler
public delegate void RoomMessageReceivedEventHandler(object sender, MessageReceivedEventArgs e);

EventHandler in the current room

RoomPeerJoinedEventHandler Delegate

Definition

Name
RoomPeerJoinedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roompeerjoinedeventhandler
public delegate void RoomPeerJoinedEventHandler(object sender, PeerJoinedEventArgs e);

EventHandler in the current room

RoomPeerLeftEventHandler Delegate

Definition

Name
RoomPeerLeftEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roompeerlefteventhandler
public delegate void RoomPeerLeftEventHandler(object sender, PeerLeftEventArgs e);

EventHandler in the current room

RoomPeerUserDataChangedEventHandler Delegate

Definition

Name
RoomPeerUserDataChangedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roompeeruserdatachangedeventhandler
public delegate void RoomPeerUserDataChangedEventHandler(object sender, PeerUserDataChangedEventArgs e);

EventHandler in the current room

RoomUserDataChangedEventHandler Delegate

Definition

Name
RoomUserDataChangedEventHandler
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/roomuserdatachangedeventhandler
public delegate void RoomUserDataChangedEventHandler(object sender, RoomUserDataChangedEventArgs e);

EventHandler in the current room

MicrophoneCallbackDelegate Delegate

Definition

Name
MicrophoneCallbackDelegate
Link to documentation
https://www.4players.io/odin/sdk/unity/delegates/microphonecallbackdelegate
public delegate void MicrophoneCallbackDelegate(float[] buffer, int position);