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
The OdinHandler class is the global ODIN manager within Unity. It’s built as a singleton. Create an empty game object in your scene and add this script to it. OdinHandler uses DontDestroyOnLoad to keep the singleton alive even if the scene changes.
Properties
Name | Description |
---|---|
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 Microphone | Unity Component that handles one Microphone where data gets routed through (n) Media |
public RoomCollection Rooms { get; } | |
public RoomJoinProxy OnRoomJoin | Called before an actual room join |
public RoomJoinedProxy OnRoomJoined | Called after a room is joined successfully |
public RoomLeaveProxy OnRoomLeave | Called before a room leave |
public RoomLeftProxy OnRoomLeft | Called after a room is destroyed |
public PeerJoinedProxy OnPeerJoined | Called on every Peer that joins the room(s) we're connected to |
public PeerUserDataChangedProxy OnPeerUserDataChanged | Called on every Peer that updates his UserData in the same room(s) |
public PeerLeftProxy OnPeerLeft | Called on every Peer that left in the same room(s) |
public MediaAddedProxy OnMediaAdded | Called on every Peer that created a media in the same room(s) |
public MediaRemovedProxy OnMediaRemoved | Called on every Peer that closed/destroyed one of his own media in the same room(s) |
public MediaActiveStateChangedProxy OnMediaActiveStateChanged | Called on every activity change of a media in the same room(s) |
public RoomUserDataChangedProxy OnRoomUserDataChanged | Called on the Room that updates his UserData. Changing a Room's UserData is only possible via request to Odin server API, but not supported inside the client SDK. |
public MessageReceivedProxy OnMessageReceived | Called on every Peer that received message from a peer by UInt64%5b%5d%2cSystem |
public ConnectionStateChangedProxy OnConnectionStateChanged | Called on the Room that changed the connection state |
public UnityCreatedMediaObject OnCreatedMediaObject | Called if this OdinHandler created a MediaStream that was requested by the MediaQueue |
public UnityDeleteMediaObject OnDeleteMediaObject | Called if this OdinHandler destroyed a MediaStream that was closed by a remote peer and was requested by the MediaQueue |
public readonly string UnityAudioSourceTag | Identify |
public bool Use3DAudio | Enable 3D Audio via preset Odin |
public bool CreatePlayback | Creates Room_OnMediaAdded(System events |
public AudioMixer PlaybackAudioMixer | |
public AudioMixerGroup PlaybackAudioMixerGroup |
Methods
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
Name | Description |
---|---|
public const string OdinVersion = "1.6.7" | ODIN_VERSION |
public const uint BlockSamplerate = 48000U | Block_SAMPLE_RATE |
OdinException Class
Definition
- Name
- OdinException
- Link to documentation
- https://www.4players.io/odin/sdk/unity/classes/odinexception
public class OdinException : Exception, ISerializable, _Exception
Exception type for the native ODIN runtime
Properties
Name | Description |
---|---|
public uint ErrorCode | OdinErrorCode |
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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 |
public bool GainController { get; set; } | Enable or disable the gain controller |
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
public const uint OK = 0U | Representative ErrorCode for Ok. |
Methods
Name | Description |
---|---|
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<MediaStream>, IEnumerable<MediaStream>, IEnumerable, IEqualityComparer<MediaStream>
Internal collection of available media streams
Properties
Name | Description |
---|---|
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
Name | Description |
---|---|
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 |
IEnumerator IEnumerable.GetEnumerator() |
MediaStream Class
Definition
- Name
- MediaStream
- Link to documentation
- https://www.4players.io/odin/sdk/unity/classes/mediastream
public abstract class MediaStream : IDisposable
Base stream
Properties
Name | Description |
---|---|
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 IsActive { get; } | Indicates wether or not the media stream is active and sending/receiving data |
public bool HasErrors { get; } | Indicates wether or not the last media stream api call result is an error code |
public bool IsInvalid { get; } | Indicates wether or not the media stream handle is invalid or closed |
Methods
MicrophoneStream Class
Definition
- Name
- MicrophoneStream
- Link to documentation
- https://www.4players.io/odin/sdk/unity/classes/microphonestream
public class MicrophoneStream : MediaStream, IDisposable
Representation of a write only audio stream
Properties
Name | Description |
---|---|
public bool IsMuted { get; } |
Methods
Name | Description |
---|---|
public void MuteStream(bool mute) | |
public override void AudioPushData(float[] buffer, int length) | |
public override bool AudioStats(out NativeBindings.OdinAudioStreamStats stats) | AudioReadData and AudioReadDataAsync are not supported! |
public override bool AudioReset() | AudioReset is not supported! |
public override uint AudioReadData(float[] buffer) | AudioReadData is not supported! |
public override Task<uint> AudioReadDataTask(float[] buffer, CancellationToken cancellationToken) | AudioReadDataTask is not supported! |
public override Task<uint> AudioReadDataAsync(float[] buffer) | AudioReadDataAsync is not supported! |
PlaybackStream Class
Definition
- Name
- PlaybackStream
- Link to documentation
- https://www.4players.io/odin/sdk/unity/classes/playbackstream
public class PlaybackStream : MediaStream, IDisposable
Representation of a read only audio stream
Methods
Name | Description |
---|---|
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! |
public override bool AudioReset() | This operation resets the internal Opus encoder/decoder, ensuring a clean state. Additionally, it clears internal buffers, providing a fresh start. |
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
Name | Description |
---|---|
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
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
Name | Description |
---|---|
public static bool Verbose | Enable additional logs |
public static bool Debug | Enable 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 PeerJoinedEvent | Idicates whether the event is enabled by default |
public static bool PeerLeftEvent | Idicates whether the event is enabled by default |
public static bool PeerUpdatedEvent | Idicates whether the event is enabled by default |
public static bool MediaAddedEvent | Idicates whether the event is enabled by default |
public static bool MediaRemovedEvent | Idicates whether the event is enabled by default |
public static bool RoomUpdatedEvent | Idicates whether the event is enabled by default |
public static bool MediaActiveStateChangedEvent | Idicates whether the event is enabled by default |
public static bool MessageReceivedEvent | Idicates whether the event is enabled by default |
public static ulong TokenLifetime { get; set; } | JWT room token lifetime |
public static bool VoiceActivityDetection | Idicates whether the ApmConfig setting is enabled by default |
public static float VoiceActivityDetectionAttackProbability | Idicates the vad attack probability ApmConfig setting by default |
public static float VoiceActivityDetectionReleaseProbability | Idicates the vad release probability ApmConfig setting by default |
public static bool VolumeGate | Idicates whether the ApmConfig setting is enabled by default |
public static float VolumeGateAttackLoudness | Idicates the gate attack loudness ApmConfig setting by default |
public static float VolumeGateReleaseLoudness | Idicates the gate release loudness ApmConfig setting by default |
public static bool EchoCanceller | Idicates whether the ApmConfig setting is enabled by default |
public static bool HighPassFilter | Idicates whether the ApmConfig setting is enabled by default |
public static bool PreAmplifier | Idicates whether the ApmConfig setting is enabled by default |
public static NativeBindings.OdinNoiseSuppressionLevel NoiseSuppressionLevel | Idicates the level of noise suppression ApmConfig setting by default |
public static bool TransientSuppressor | Idicates whether the ApmConfig setting is enabled by default |
public static bool GainController | Idicates 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
Name | Description |
---|---|
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
Name | Description |
---|---|
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 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<Peer>, IEnumerable<Peer>, IEnumerable, IEqualityComparer<Peer>
Intern peer dictionary
Properties
Name | Description |
---|---|
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
Name | Description |
---|---|
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 |
IEnumerator IEnumerable.GetEnumerator() |
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
Name | Description |
---|---|
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
Name | Description |
---|---|
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
Name | Description |
---|---|
public ulong PeerId { get; } | peer id |
public Peer Peer | peer object |
public PlaybackStream Media | Media |
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
Name | Description |
---|---|
public long MediaStreamId { get; } | stream handle id |
public Peer Peer | peer 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
Name | Description |
---|---|
public ulong PeerId { get; } | peer id |
public byte[] Data | arbitrary 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
Name | Description |
---|---|
public ulong PeerId { get; } | peer Id |
public string UserId { get; } | user Id |
public Peer Peer | peer 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
Name | Description |
---|---|
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
Name | Description |
---|---|
public ulong PeerId { get; } | peer id |
public Peer Peer | peer object |
public UserData UserData | peer 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
Name | Description |
---|---|
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 Config | Room configuration |
public bool IsJoined { get; } | true on successful Join or false |
public Peer Self { get; } | Client Peer |
public UserData RoomUserData { get; } | Odin UserData helper for marshal byte arrays on Room level |
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
Name | Description |
---|---|
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 OdinConnectionStats GetRoomConnectionStats() | Retrieves statistics for the underlying connection of this room |
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 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 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 bool AudioProcessReverse(float[] buffer) | Processes the reverse audio stream, also known as the loopback data to be used in the ODIN echo canceller.This should only be done if you are NOT using AudioMixStreams(RoomHandle%2cStreamHandle%5b%5d%2cSystem. |
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<Room>, IEnumerable<Room>, IEnumerable, IEqualityComparer<Room>
Intern room dictionary
Properties
Name | Description |
---|---|
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
Name | Description |
---|---|
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 |
IEnumerator IEnumerable.GetEnumerator() |
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
Name | Description |
---|---|
public string AccessKey | Room associated AccessKey |
public ulong TokenLifetime | Room associated Token lifetime |
public string Name | Room name |
public string Token | Room token |
public string Server | Room associated endpoint |
public bool HasEventCallbacks | true if Room where set and registered in ODIN ffi |
public OdinRoomConfig ApmConfig | Configuration for NativeBindings |
public OdinMediaConfig PlaybackMediaConfig | Configuration for Media on new medias |
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
public Room Room | room 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
Name | Description |
---|---|
public Room Room | room 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
Name | Description |
---|---|
public Room Room | room 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
Name | Description |
---|---|
public string RoomName | room 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
Name | Description |
---|---|
public string RoomName { get; } | room name |
public UserData Data | room 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
Name | Description |
---|---|
public Encoding Encoding { get; set; } | Default Encoding |
public byte[] Buffer { get; set; } | Raw UserData |
Methods
Name | Description |
---|---|
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
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
public AudioSource PlaybackSource | The Unity AudioSource component for playback |
public bool AutoDestroyAudioSource | On true destroy the PlaybackSource in dispose to not leak |
public bool AutoDestroyMediaStream | On true destroy the Media in dispose to not leak or false for manually manage stream |
public MediaSampleRate SampleRate | The 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
Name | Description |
---|---|
public void SetMediaInfo(string roomName, ulong peerId, long mediaId) | |
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
ConnectionStateChangedProxy Class
Definition
- Name
- ConnectionStateChangedProxy
- Link to documentation
- https://www.4players.io/odin/sdk/unity/classes/connectionstatechangedproxy
[Serializable]
public class ConnectionStateChangedProxy : UnityEvent<object, ConnectionStateChangedEventArgs>
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
[Serializable]
public class MediaActiveStateChangedProxy : UnityEvent<object, MediaActiveStateChangedEventArgs>
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
[Serializable]
public class MediaAddedProxy : UnityEvent<object, MediaAddedEventArgs>
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
[Serializable]
public class MediaRemovedProxy : UnityEvent<object, MediaRemovedEventArgs>
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
[Serializable]
public class MessageReceivedProxy : UnityEvent<object, MessageReceivedEventArgs>
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
[Serializable]
public class PeerJoinedProxy : UnityEvent<object, PeerJoinedEventArgs>
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
[Serializable]
public class PeerLeftProxy : UnityEvent<object, PeerLeftEventArgs>
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
[Serializable]
public class PeerUserDataChangedProxy : UnityEvent<object, PeerUserDataChangedEventArgs>
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
[Serializable]
public class RoomJoinProxy : UnityEvent<RoomJoinEventArgs>
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
[Serializable]
public class RoomJoinedProxy : UnityEvent<RoomJoinedEventArgs>
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
[Serializable]
public class RoomLeaveProxy : UnityEvent<RoomLeaveEventArgs>
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
[Serializable]
public class RoomLeftProxy : UnityEvent<RoomLeftEventArgs>
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
[Serializable]
public class RoomUserDataChangedProxy : UnityEvent<object, RoomUserDataChangedEventArgs>
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
[Serializable]
public class UnityCreatedMediaObject : UnityEvent<string, ulong, long>
UnityDeleteMediaObject Class
Definition
- Name
- UnityDeleteMediaObject
- Link to documentation
- https://www.4players.io/odin/sdk/unity/classes/unitydeletemediaobject
[Serializable]
public class UnityDeleteMediaObject : UnityEvent<long>
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
UnityEditor UI component for instance config of Odin
Properties
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
bool IsEmpty() | Indicates whether data is null or empty |
byte[] ToBytes() | Used for converting Data on network level |
Structs
OdinAudioStreamStats Struct
Definition
- Name
- OdinAudioStreamStats
- Link to documentation
- https://www.4players.io/odin/sdk/unity/structs/odinaudiostreamstats
public struct OdinAudioStreamStats
Audio stream statistics.
Properties
Name | Description |
---|---|
public uint jitter_packets_processed | The number of packets processed by the medias jitter buffer. |
public uint jitter_packets_dropped_too_early | The number of packets dropped because they seemed to arrive too early. |
public uint jitter_packets_dropped_too_late | The number of packets processed because they seemed to arrive too late. |
public uint jitter_packets_lost | The number of packets marked as lost during transmission. |
OdinConnectionStats Struct
Definition
- Name
- OdinConnectionStats
- Link to documentation
- https://www.4players.io/odin/sdk/unity/structs/odinconnectionstats
public struct OdinConnectionStats
Statistics for the underlying connection of a room.
Properties
Name | Description |
---|---|
public ulong udp_tx_datagrams | The amount of outgoing UDP datagrams observed |
public ulong udp_tx_acks | The amount of outgoing acknowledgement frames observed |
public ulong udp_tx_bytes | The total amount of bytes which have been transferred inside outgoing UDP datagrams |
public ulong udp_rx_datagrams | The amount of incoming UDP datagrams observed |
public ulong udp_rx_acks | The amount of incoming acknowledgement frames observed |
public ulong udp_rx_bytes | The total amount of bytes which have been transferred inside incoming UDP datagrams |
public ulong cwnd | Current congestion window of the connection |
public ulong congestion_events | Congestion events on the connection |
public float rtt | Current best estimate of the connection latency (round-trip-time) in milliseconds |
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
Name | Description |
---|---|
None = 0 | None |
Low = 1 | 6dB |
Moderate = 2 | 12 dB |
High = 3 | 18 dB |
VeryHigh = 4 | 21 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
Name | Description |
---|---|
Connecting = 0 | Connection is being established |
Connected = 1 | Connection is established |
Disconnected = 2 | Connection 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
Name | Description |
---|---|
ClientRequested = 0 | Connection state change was initiated by the user |
ServerRequested = 1 | Connection state change was initiated by the server (e.g. peer was kicked) |
ConnectionLost = 2 | Connection state change was caused by a timeout |
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
Name | Description |
---|---|
Mono = 1 | Defines a single (monaural) channel |
Stereo = 2 | Defines 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
Name | Description |
---|---|
Device_Min = 0U | Hardware device min samplerate |
Device_Max = 1U | Hardware device max samplerate |
Hz8000 = 8000U | 8khz |
Hz11025 = 11025U | 11.025khz |
Hz12000 = 12000U | 12khz |
Hz16000 = 16000U | 16khz |
Hz22050 = 22050U | 22.05khz |
Hz24000 = 24000U | 24khz |
Hz32000 = 32000U | 32khz |
Hz44100 = 44100U | 44.1khz |
Hz48000 = 48000U | 48khz |
Hz96000 = 96000U | 96khz |
Hz128000 = 128000U | 128khz |
Hz144000 = 144000U | 144khz |
Hz192000 = 192000U | 192khz |
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
Name | Description |
---|---|
Android = 0 | |
iOS = 1 | |
MacOSX = 2 | |
Linux = 3 | |
Windows = 4 |
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. Changing a Room's UserData is only possible via request to Odin server API, but not supported inside the client SDK.
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);