Constructor
new EasyRTCClient(master, settings)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
master |
AVMaster | The master orchestration instance |
settings |
AVSettings | The audio/video settings being used |
Extends
Methods
_enableMediaTracks(tracks, enable)
- Source:
Enables or disables media tracks See https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/enabled
Parameters:
Name | Type | Description |
---|---|---|
tracks |
Array.<object> | The tracks to enable/disable |
enable |
boolean | Whether to enable or disable the tracks |
(async) _initializeLocal(audioSrc, videoSrc, temporary) → {Promise.MediaStream}
- Source:
Initialize a local media stream Capture the local audio and video and returns the stream associated with them.
If @temporary is false (default), then this will initialize the master stream, not the actual streams being sent to individual users. However, if a master stream was already created, it will automatically get closed and every individual streams derived from it that are being sent to connected users will be removed from the calls. Each established or subsequent calls will receive a copy of the created stream (A/V depending on user permissions)
If @temporary is true then this only applies to a temporary stream and does not affect the master stream or any streams in existing calls. Note that this assumes only one temporary stream can be created at a time.
Parameters:
Name | Type | Description |
---|---|---|
audioSrc |
string | null | ID of the audio source to capture from or null to disable Audio |
videoSrc |
string | null | ID of the video source to capture from or null to disable Video |
temporary |
boolean | Whether to create a temporary stream or the master stream |
Returns:
Returns the local stream or null
if none could be created
- Type
- Promise.MediaStream
_userIdToEasyRtcId(userId) → {string|null}
- Source:
Obtain the EasyRTC user ID of a user based on their Foundry VTT user ID
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The ID of the user |
Returns:
The EasyRtcId of the peer
- Type
- string | null
(async) connect() → {Promise.<boolean>}
- Source:
- Overrides:
Connect to any servers or services needed in order to provide audio/video functionality. Any parameters needed in order to establish the connection should be drawn from the settings object. This function should return a boolean for whether the connection attempt was successful.
Returns:
Was the connection attempt successful?
- Type
- Promise.<boolean>
(async) disconnect() → {Promise.<boolean>}
- Source:
- Overrides:
Disconnect from any servers or services which are used to provide audio/video functionality. This function should return a boolean for whether a valid disconnection occurred.
Returns:
Did a disconnection occur?
- Type
- Promise.<boolean>
enableStreamAudio(stream, enable)
- Source:
Enable or disable the audio tracks in a stream
Disabling a track represents what a typical user would consider muting it.
We use the term 'enable' here instead of 'mute' to match the MediaStreamTrack
field name and to avoid confusion with the 'muted' read-only field of the MediaStreamTrack
as well as the video element's muted
field which only stops playing the audio.
Muting by definition stops rendering any of the data, while a disabled track in this case
is still rendering its data, but is simply generating disabled content (silence and black frames)
See https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/enabled
Parameters:
Name | Type | Default | Description |
---|---|---|---|
stream |
MediaStream | The stream to modify |
|
enable |
boolean |
true
|
(optional) Whether to enable or disable the tracks |
enableStreamVideo(stream, enable)
- Source:
Enable or disable the video tracks in a stream
Disabling a track represents what a typical user would consider muting it. We use the term 'enable' here instead
of 'mute' to match the MediaStreamTrack field name and to avoid confusion with the 'muted' read-only field of the
MediaStreamTrack as well as the video element's muted
field which only stops playing the audio.
Muting by definition stops rendering any of the data, while a disabled track in this case is still rendering its data, but is simply generating disabled content (silence and black frames).
See https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/enabled
Parameters:
Name | Type | Default | Description |
---|---|---|---|
stream |
MediaStream | The stream to modify |
|
enable |
boolean |
true
|
(optional) Whether to enable or disable the tracks |
(async) getAudioSinks() → {Promise.<{string: string}>}
- Source:
- Overrides:
Provide an Object of available audio sources which can be used by this implementation. Each object key should be a device id and the key should be a human-readable label.
Returns:
- Type
- Promise.<{string: string}>
(async) getAudioSources() → {Promise.<{string: string}>}
- Source:
- Overrides:
Provide an Object of available audio sources which can be used by this implementation. Each object key should be a device id and the key should be a human-readable label.
Returns:
- Type
- Promise.<{string: string}>
getConnectedStreams() → {Array.<object>}
- Source:
Get MediaStream instances for every connected peer in the room.
Returns:
An array of stream information for each peer
- Type
- Array.<object>
getConnectedUsers() → {Array.<string>}
- Source:
- Overrides:
Return an array of Foundry User IDs which are currently connected to A/V. The current user should also be included as a connected user in addition to all peers.
Returns:
The connected User IDs
- Type
- Array.<string>
getMediaStreamForUser(userId) → {MediaStream|null}
- Source:
- Overrides:
Provide a MediaStream instance for a given user ID
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The User id |
Returns:
The MediaStream for the user, or null if the user does not have one
- Type
- MediaStream | null
(async) getVideoSources() → {Promise.<{string: string}>}
- Source:
- Overrides:
Provide an Object of available video sources which can be used by this implementation. Each object key should be a device id and the key should be a human-readable label.
Returns:
- Type
- Promise.<{string: string}>
(async) initialize() → {Promise.<void>}
- Source:
- Overrides:
One-time initialization actions that should be performed for this client implementation. This will be called only once when the Game object is first set-up.
Returns:
- Type
- Promise.<void>
isAudioEnabled() → {boolean}
- Source:
- Overrides:
Is outbound audio enabled for the current user?
Returns:
- Type
- boolean
isVideoEnabled() → {boolean}
- Source:
- Overrides:
Is outbound video enabled for the current user?
Returns:
- Type
- boolean
onSettingsChanged(changed)
- Source:
- Overrides:
Handle changes to A/V configuration settings.
Parameters:
Name | Type | Description |
---|---|---|
changed |
object | The settings which have changed |
(async) setUserVideo(userId, videoElement)
- Source:
- Overrides:
Set the Video Track for a given User ID to a provided VideoElement
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | The User ID to set to the element |
videoElement |
HTMLVideoElement | The HTMLVideoElement to which the video should be set |
toggleAudio(enable)
- Source:
- Overrides:
Handle a request to enable or disable the outbound audio feed for the current game user.
Parameters:
Name | Type | Description |
---|---|---|
enable |
boolean | Whether the outbound audio track should be enabled (true) or disabled (false) |
toggleBroadcast(broadcast)
- Source:
- Overrides:
Set whether the outbound audio feed for the current game user is actively broadcasting. This can only be true if audio is enabled, but may be false if using push-to-talk or voice activation modes.
Parameters:
Name | Type | Description |
---|---|---|
broadcast |
boolean | Whether outbound audio should be sent to connected peers or not? |
toggleVideo(enable)
- Source:
- Overrides:
Handle a request to enable or disable the outbound video feed for the current game user.
Parameters:
Name | Type | Description |
---|---|---|
enable |
boolean | Whether the outbound audio track should be enabled (true) or disabled (false) |