AVMaster

AVMaster

The master Audio/Video controller instance. This is available as the singleton game.webrtc

Constructor

new AVMaster(settings)

Parameters:
Name Type Description
settings AVSettings

The Audio/Video settings to use

Members

_connected :boolean

Flag to determine if we are connected to the signalling server or not. This is required for synchronization between connection and reconnection attempts.

Type:
  • boolean

broadcasting :boolean

A flag to track whether the current user is actively broadcasting their microphone.

Type:
  • boolean

client :AVClient

The Audio/Video client class

Type:

Methods

_onPTTEnd(context)

Handle deactivation of a push-to-talk key or button.

Parameters:
Name Type Description
context KeyboardEventContext

The context data of the event

_onPTTStart(context)

Handle activation of a push-to-talk key or button.

Parameters:
Name Type Description
context KeyboardEventContext

The context data of the event

_resetSpeakingHistory()

Resets the speaking history of a user If the user was considered speaking, then mark them as not speaking

activateVoiceDetection(stream, msopt)

Activate voice detection tracking for a userId on a provided MediaStream. Currently only a MediaStream is supported because MediaStreamTrack processing is not yet supported cross-browser.

Parameters:
Name Type Attributes Description
stream MediaStream

The MediaStream which corresponds to that User

ms number <optional>

A number of milliseconds which represents the voice activation volume interval

broadcast(intent)

Trigger a change in the audio broadcasting state when using a push-to-talk workflow.

Parameters:
Name Type Description
intent boolean

The user's intent to broadcast. Whether an actual broadcast occurs will depend on whether or not the user has muted their audio feed.

canUserBroadcastAudio(userId) → {boolean}

A user can broadcast audio if the AV mode is compatible and if they are allowed to broadcast.

Parameters:
Name Type Description
userId string
Returns:
Type
boolean

canUserBroadcastVideo(userId) → {boolean}

A user can broadcast video if the AV mode is compatible and if they are allowed to broadcast.

Parameters:
Name Type Description
userId string
Returns:
Type
boolean

canUserShareAudio(userId) → {boolean}

A user can share audio if they are allowed to broadcast and if they have not muted themselves or been blocked.

Parameters:
Name Type Description
userId string
Returns:
Type
boolean

canUserShareVideo(userId) → {boolean}

A user can share video if they are allowed to broadcast and if they have not hidden themselves or been blocked.

Parameters:
Name Type Description
userId string
Returns:
Type
boolean

(async) connect() → {Promise.<boolean>}

Connect to the Audio/Video client.

Returns:

Was the connection attempt successful?

Type
Promise.<boolean>

deactivateVoiceDetection()

Actions which the orchestration layer should take when a peer user disconnects from the audio/video service.

(async) disconnect() → {Promise.<boolean>}

Disconnect from the Audio/Video client.

Returns:

Whether an existing connection was terminated?

Type
Promise.<boolean>

onRender()

Render the audio/video streams to the CameraViews UI. Assign each connected user to the correct video frame element.

onSettingsChanged(changed)

Respond to changes which occur to AV Settings. Changes are handled in descending order of impact.

Parameters:
Name Type Description
changed Object

The object of changed AV settings

(async) reestablish() → {Promise.<void>}

Callback actions to take when the user becomes disconnected from the server.

Returns:
Type
Promise.<void>