ODIN Web SDK Reference Documentation Links

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

Class

OdinClient Class

Definition

Name
OdinClient
Link to documentation
https://www.4players.io/odin/sdk/web/classes/odinclient
export class OdinClient

Class providing static methods to handle ODIN client connections.

Properties

NameDescription
public config: IOdinClientSettingsGlobal settings for ODIN connections.
public connectionState: OdinConnectionStateThe current state of the main stream connection.
public rooms: OdinRoom[]An array of available OdinRoom instances.

Methods

NameDescription
public addEventListener(eventName: Event, handler: IOdinClientEvents[Event]): voidRegisters to client events from IOdinClientEvents.
public disconnect(state: OdinConnectionState): voidDisconnects from all rooms and stops all audio handling.
public initRoom(token: string, gateway?: string, audioContext?: AudioContext): Promise<OdinRoom>Authenticates against the ODIN server and returns an OdinRoom instance for the first room set in the specified token. This function accepts an optional AudioContext parameter for audio capture. The AudioContext interface is a part of the Web Audio API that represents an audio-processing graph, which can be used to control and manipulate audio signals in web applications. If the AudioContext is not provided or explicitly set to undefined, we will try to create one internally.
public initRooms(token: string, gateway?: string, audioContext?: AudioContext): Promise<OdinRoom[]>Authenticates against the ODIN server and returns OdinRoom instances for all rooms set in the specified token. This function accepts an optional AudioContext parameter for audio capture. The AudioContext interface is a part of the Web Audio API that represents an audio-processing graph, which can be used to control and manipulate audio signals in web applications. If the AudioContext is not provided or explicitly set to undefined, we will try to create one internally.

OdinMedia Class

Definition

Name
OdinMedia
Link to documentation
https://www.4players.io/odin/sdk/web/classes/odinmedia
export class OdinMedia

Class describing a single media stream inside an OdinRoom.

Properties

NameDescription
public active: booleanIndicates wether or not the media is currently sending/receiving data.
public id: numberThe ID of the media.
public paused: booleanIndicates wether or not the media is paused.
public peerId: numberThe ID of the peer that owns the media.
public remote: booleanIndicates wether or not the media belongs to a remote peer.
public started: booleanIndicates whether or not the media is registered in the audio service instance (e.g. started).
public volume: numberThe individual playback volume of the media stream.

Methods

NameDescription
public addEventListener(eventName: Event, handler: IOdinMediaEvents[Event]): voidRegisters to media events from IOdinMediaEvents.
public changeVolume(volume: number): voidChanges the playback volume of the media.
public pause(): Promise<void>Paused the media stream on the server to stop receiving data on it.
public resume(): Promise<void>Paused the media stream on the server to start receiving data on it.
public start(): Promise<void>Starts the media stream by initiating the encoder/decoder and adding it to the room if it belongs to the local peer.
public stop(): Promise<void>Stops the media stream by terminating the encoder/decoder and removing it from the room if it belongs to the local peer.

OdinPeer Class

Definition

Name
OdinPeer
Link to documentation
https://www.4players.io/odin/sdk/web/classes/odinpeer
export class OdinPeer

Class describing a single peer inside an OdinRoom.

Properties

NameDescription
public data: Uint8ArrayThe arbitrary user data of the peer.
public id: numberThe ID of the peer.
public medias: Map<number><OdinMedia>A list of media instances owned by the peer.
public remote: booleanIndicates, whether the peer is a remote peer or not.
public userId: stringThe identifier of the peer.

Methods

NameDescription
public addEventListener(eventName: Event, handler: IOdinPeerEvents[Event]): voidRegisters to peer events from IOdinPeerEvents.
public addMedia(media: OdinMedia): voidAdds a media to the list of active medias and starts decoding.
public createMedia(): OdinMediaCreates a local media, configures audio capture/playback and returns the new OdinMedia instance.
public removeMedia(media: OdinMedia): voidRemoves a media from the list of active medias and stops decoding.
public removeMediaById(id: number): voidRemoves a media from the list of active medias by the given ID and stops decoding.
public sendMessage(message: Uint8Array): Promise<void>Sends a message with arbitrary data to this peer.
public startMedias(mediaIds?: number[]): Promise<void>Starts all active medias or a list of specific active medias.
public stopMedias(mediaIds?: number[]): Promise<void>Stops all active medias or a list of specific active medias.
public update(): Promise<void>Sends user data of the peer to the server.

OdinRoom Class

Definition

Name
OdinRoom
Link to documentation
https://www.4players.io/odin/sdk/web/classes/odinroom
export class OdinRoom

Class describing an OdinRoom.

Properties

NameDescription
public connectionState: OdinConnectionStateThe current state of the room stream connection.
public customer: stringThe customer identifier this room is assigned to.
public data: Uint8ArrayThe arbitrary user data of the room.
public id: stringThe ID of the room.
public ownPeer: OdinPeerAn instance of your own OdinPeer in the room.
public position: anyThe current three-dimensional position of our own OdinPeer in the room.
public remotePeers: Map<number><OdinPeer>A map of all remote OdinPeer instances in the room using the peer ID as index.
public serverAddress: stringThe address of the voice server this room is living on.

Methods

NameDescription
public addEventListener(eventName: OdinEvent, handler: IOdinRoomEvents[OdinEvent]): voidRegister to peer events from IOdinRoomEvents.
public changeMediaStream(mediaStream: MediaStream): Promise<void>Changes the active capture stream (e.g. when switching to another input device).
public changeVolume(volume: number): voidChange the global master volume for the room (should be between 0 and 2).
public createMedia(mediaStream: MediaStream, audioSettings?: IOdinAudioSettings): Promise<OdinMedia>Creates a new local media using the specified stream.
public disableVAD(): voidDisables RNN-based voice activity detection.
public disableVolumeGate(): voidDisables RNN-based voice activity detection.
public enableVAD(): voidEnables RNN-based voice activity detection.
public enableVolumeGate(): voidEnables RNN-based voice activity detection.
public flushOwnPeerDataUpdate(): Promise<void>Sends updated user data of your own peer to the server.
public getAudioSettings(): undefined | IOdinAudioSettingsReturns the current voice processing config for VAD and volume gate.
public getMediaById(id: number): undefined | OdinMediaReturns the OdinMedia instance matching the specified ID.
public getPeerById(id: number): undefined | OdinPeerReturns the OdinPeer instance matching the specified ID.
public join(userData?: Uint8Array, position?: any): Promise<OdinPeer>Joins the room and returns your own peer instance after the room was successfully joined.
public sendMessage(message: Uint8Array, targetPeerIds?: number[]): Promise<void>Sends a message with arbitrary data to all peers in the room or optionally to a list of specified peers.
public setPosition(offsetX: number, offsetY: number, offsetZ: number): voidUpdates the three-dimensional position of our own OdinPeer in the room to apply server-side culling.
public startVADMeter(): voidEnables emitting of RNN-based voice activity detection statistics.
public stopVADMeter(): voidDisables emitting of RNN-based voice activity detection statistics.
public updateVADThresholds(attackProbability: number, releaseProbability?: number): voidUpdates thresholds for vice activity detection (between 0 and 1).
public updateVolumeGateThresholds(attackLoudness: number, releaseLoudness?: number): voidUpdates thresholds for the input volume gate (between -90 and 0).

Interface

IOdinAudioSettings Interface

Definition

Name
IOdinAudioSettings
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinaudiosettings
export interface IOdinAudioSettings

Interface describing audio settings to be applied on connect.

Properties

NameDescription
public voiceActivityDetection: booleanEnable or disable RNN-based voice activity detection.
public voiceActivityDetectionAttackProbability: numberVoice probability value when the VAD should engage
public voiceActivityDetectionReleaseProbability: numberVoice probability value when the VAD should disengage
public volumeGate: booleanEnables or disables the input volume gate
public volumeGateAttackLoudness: numberRoot mean square power (dBFS) when the volume gate should engage
public volumeGateReleaseLoudness: numberRoot mean square power (dBFS) when the volume gate should disengage

IOdinAudioStats Interface

Definition

Name
IOdinAudioStats
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinaudiostats
export interface IOdinAudioStats

Interface describing encoder/decoder statistics from the audio worker.

Properties

NameDescription
public decoder: {avg_decode_time: number, cache_length: number, packets_invalid: number, packets_lost: number, packets_processed: number, packets_repeated: number, packets_seen: number, packets_too_early: number, packets_too_late: number, rewinds: number}Internal Opus decoder statistics.
public encoder: {avg_encode_time: number, complexity: number, complexity_factor: number, fec: boolean, fec_packet_loss: number, voip: boolean}Internal Opus encoder statistics.

IOdinAudioStatsEventPayload Interface

Definition

Name
IOdinAudioStatsEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinaudiostatseventpayload
export interface IOdinAudioStatsEventPayload

Interface describing the payload of an OdinAudioStatsEvent.

Properties

NameDescription
public room: OdinRoomThe OdinRoom instance the stats ere coming from.
public stats: IOdinAudioStatsThe internal Opus encoder/decoder stats.

IOdinClientEvents Interface

Definition

Name
IOdinClientEvents
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinclientevents
export interface IOdinClientEvents

Interface describing possible media events.

Properties

NameDescription
public ConnectionStateChanged: OdinConnectionStateChangedEventMain stream connection state updates.

IOdinClientSettings Interface

Definition

Name
IOdinClientSettings
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinclientsettings
export interface IOdinClientSettings

Interface describing custom options for ODIN clients.

Properties

NameDescription
public gatewayUrl: stringThe URL of the ODIN gateway to use.

IOdinConnectionStateChangedEventPayload Interface

Definition

Name
IOdinConnectionStateChangedEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinconnectionstatechangedeventpayload
export interface IOdinConnectionStateChangedEventPayload

Interface describing the payload of an OdinConnectionStateChangedEvent.

Properties

NameDescription
public newState: OdinConnectionStateCurrent state of the connection.
public oldState: OdinConnectionStatePrevious state of the connection.

IOdinEvent Interface

Definition

Name
IOdinEvent
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinevent
export interface IOdinEvent

Interface extending default JavaScript events with custom information.

Properties

NameDescription
public payload: TCustom payload of the event (see IOdin*Payload interfaces).

IOdinMediaActivityChangedEventPayload Interface

Definition

Name
IOdinMediaActivityChangedEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinmediaactivitychangedeventpayload
export interface IOdinMediaActivityChangedEventPayload

Interface describing the payload of an OdinMediaActivityChangedEvent.

Properties

NameDescription
public media: OdinMediaThe media that was updated.
public peer: OdinPeerThe peer that owns the media.
public room: OdinRoomThe room the media is added to.

IOdinMediaEvents Interface

Definition

Name
IOdinMediaEvents
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinmediaevents
export interface IOdinMediaEvents

Interface describing possible media events.

Properties

NameDescription
public Activity: OdinMediaActivityChangedEventThe media is sending/receiving data.

IOdinMediaStartedStoppedEventPayload Interface

Definition

Name
IOdinMediaStartedStoppedEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinmediastartedstoppedeventpayload
export interface IOdinMediaStartedStoppedEventPayload

Interface describing the payload of an OdinMediaStartedStoppedEvent.

Properties

NameDescription
public media: OdinMediaThe media that was added/removed.
public peer: OdinPeerThe peer that owns the media.
public room: OdinRoomThe room where the media was added/removed.

IOdinMessageReceivedEventPayload Interface

Definition

Name
IOdinMessageReceivedEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinmessagereceivedeventpayload
export interface IOdinMessageReceivedEventPayload

Interface describing the payload of an OdinMessageReceivedEvent.

Properties

NameDescription
public message: Uint8ArrayA byte array with the message.
public room: OdinRoomThe room where the message was received.
public senderId: numberThe ID of the peer that sent the message (might not be in proximity).

IOdinPeerDataChangedEventPayload Interface

Definition

Name
IOdinPeerDataChangedEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinpeerdatachangedeventpayload
export interface IOdinPeerDataChangedEventPayload

Interface describing the payload of an OdinPeerDataChangedEvent.

Properties

NameDescription
public peer: OdinPeerThe updated OdinPeer instance.
public room: OdinRoomThe room where the peer was updated.

IOdinPeerEvents Interface

Definition

Name
IOdinPeerEvents
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinpeerevents
export interface IOdinPeerEvents

Interface describing possible peer events.

Properties

NameDescription
public MediaActivity: OdinMediaActivityChangedEventA media owned by the peer is sending/receiving data.
public MediaStarted: OdinMediaStartedStoppedEventPeer added a new media stream.
public MediaStopped: OdinMediaStartedStoppedEventPeer removed a media stream.
public MessageReceived: OdinMessageReceivedEventPeer sent a message with arbitrary data.
public UserDataChanged: OdinPeerDataChangedEventPeer updated its user data.

IOdinPeerJoinedLeftEventPayload Interface

Definition

Name
IOdinPeerJoinedLeftEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinpeerjoinedlefteventpayload
export interface IOdinPeerJoinedLeftEventPayload

Interface describing the payload of an OdinPeerJoinedLeftEvent.

Properties

NameDescription
public peer: OdinPeerThe peer that joined/left.
public room: OdinRoomThe room the peer joined/left.

IOdinRoomDataChangedEventPayload Interface

Definition

Name
IOdinRoomDataChangedEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinroomdatachangedeventpayload
export interface IOdinRoomDataChangedEventPayload

Interface describing the payload of an OdinRoomDataChangedEvent.

Properties

NameDescription
public room: OdinRoomThe updated OdinRoom instance.

IOdinRoomEvents Interface

Definition

Name
IOdinRoomEvents
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinroomevents
export interface IOdinRoomEvents

Interface describing possible room events.

Properties

NameDescription
public AudioStats: OdinAudioStatsEventInternal encoder/decoder stats updates.
public ConnectionStateChanged: OdinConnectionStateChangedEventRoom stream connection state updates.
public Joined: OdinRoomJoinedLeftEventThe room was joined successfully.
public Left: OdinRoomJoinedLeftEventThe room was left.
public MediaActivity: OdinMediaActivityChangedEventA media in the room is sending/receiving data.
public MediaStarted: OdinMediaStartedStoppedEventA new media stream was added to the room.
public MediaStopped: OdinMediaStartedStoppedEventA media stream was removed from the room.
public MessageReceived: OdinMessageReceivedEventReceived a message with arbitrary data.
public PeerJoined: OdinPeerJoinedLeftEventA new peer entered the room.
public PeerLeft: OdinPeerJoinedLeftEventA peer left the room.
public PeerUserDataChanged: OdinPeerDataChangedEventA peer in the room updated its user data.
public UserDataChanged: OdinRoomDataChangedEventThe global room user data was updated.
public VoiceProcessingStats: OdinVoiceProcessingStatsEventInternal RNN VAD stats updates.

IOdinRoomJoinedLeftEventPayload Interface

Definition

Name
IOdinRoomJoinedLeftEventPayload
Link to documentation
https://www.4players.io/odin/sdk/web/interfaces/iodinroomjoinedlefteventpayload
export interface IOdinRoomJoinedLeftEventPayload

Interface describing the payload of an OdinRoomJoinedLeftEvent.

Properties

NameDescription
public room: OdinRoomThe room that was joined/left.

Type

OdinAudioStatsEvent Type

Definition

Name
OdinAudioStatsEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinaudiostatsevent

OdinConnectionStateChangedEvent Type

Definition

Name
OdinConnectionStateChangedEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinconnectionstatechangedevent

OdinMediaActivityChangedEvent Type

Definition

Name
OdinMediaActivityChangedEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinmediaactivitychangedevent

OdinMediaStartedStoppedEvent Type

Definition

Name
OdinMediaStartedStoppedEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinmediastartedstoppedevent

OdinMessageReceivedEvent Type

Definition

Name
OdinMessageReceivedEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinmessagereceivedevent

OdinPeerDataChangedEvent Type

Definition

Name
OdinPeerDataChangedEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinpeerdatachangedevent

OdinPeerJoinedLeftEvent Type

Definition

Name
OdinPeerJoinedLeftEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinpeerjoinedleftevent

OdinRoomDataChangedEvent Type

Definition

Name
OdinRoomDataChangedEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinroomdatachangedevent

OdinRoomJoinedLeftEvent Type

Definition

Name
OdinRoomJoinedLeftEvent
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinroomjoinedleftevent

Type alias

OdinConnectionState Type alias

Definition

Name
OdinConnectionState
Link to documentation
https://www.4players.io/odin/sdk/web/types/odinconnectionstate
export type OdinConnectionState

Enum defining all possible connection states of the ODIN client.