Class: MatrixCall

webrtc/call~MatrixCall

new MatrixCall(opts)

Construct a new Matrix Call.
Parameters:
Name Type Description
opts Object Config options.
Properties
Name Type Description
roomId string The room ID for this call.
webRtc Object The WebRTC globals from the browser.
URL Object The URL global.
turnServers Array.<Object> Optional. A list of TURN servers.
client MatrixClient The Matrix Client instance to send events to.
Source:

Members

(static) CALL_TIMEOUT_MS

The length of time a call can be ringing for.
Source:

(static) ERR_LOCAL_OFFER_FAILED

An error code when the local client failed to create an offer.
Source:

(static) ERR_NO_USER_MEDIA

An error code when there is no local mic/camera to use. This may be because the hardware isn't plugged in, or the user has explicitly denied access.
Source:

(static) FALLBACK_STUN_SERVER

The fallback server to use for STUN.
Source:

Methods

(protected) _gotRemoteIceCandidate(cand)

Used by MatrixClient.
Parameters:
Name Type Description
cand Object
Source:

(protected) _initWithHangup(event)

Configure this call from a hangup event. Used by MatrixClient.
Parameters:
Name Type Description
event MatrixEvent The m.call.hangup event
Source:

(protected) _initWithInvite(event)

Configure this call from an invite event. Used by MatrixClient.
Parameters:
Name Type Description
event MatrixEvent The m.call.invite event
Source:

(protected) _onAnsweredElsewhere(msg)

Used by MatrixClient.
Parameters:
Name Type Description
msg Object
Source:

(protected) _onHangupReceived(msg)

Used by MatrixClient.
Parameters:
Name Type Description
msg Object
Source:

(protected) _receivedAnswer(msg)

Used by MatrixClient.
Parameters:
Name Type Description
msg Object
Source:

(protected) _replacedBy(newCall)

Replace this call with a new call, e.g. for glare resolution. Used by MatrixClient.
Parameters:
Name Type Description
newCall MatrixCall The new call.
Source:

answer()

Answer a call.
Source:

assignElement(HTMLMediaElement, src, queueId)

Assign the given HTMLMediaElement by setting the .src attribute on it, serialising the operation into a chain of promises to avoid racing access to the element
Parameters:
Name Type Description
HTMLMediaElement Element element to pause
src string the src attribute value to assign to the element
queueId string Arbitrary ID to track the chain of promises to be used
Source:

getLocalVideoElement() → {Element}

Retrieve the local <video> DOM element.
Source:
Returns:
The dom element
Type
Element

getRemoteAudioElement() → {Element}

Retrieve the remote <audio> DOM element used for playing back audio only streams.
Source:
Returns:
The dom element
Type
Element

getRemoteVideoElement() → {Element}

Retrieve the remote <video> DOM element used for playing back video capable streams.
Source:
Returns:
The dom element
Type
Element

hangup(reason, suppressEvent)

Hangup a call.
Parameters:
Name Type Description
reason string The reason why the call is being hung up.
suppressEvent boolean True to suppress emitting an event.
Source:

isLocalVideoMuted() → {Boolean}

Check if local video is muted. If there are multiple video tracks, all of the tracks need to be muted for this to return true. This means if there are no video tracks, this will return true.
Source:
Returns:
True if the local preview video is muted, else false (including if the call is not set up yet).
Type
Boolean

isMicrophoneMuted() → {Boolean}

Check if the microphone is muted. If there are multiple audio tracks, all of the tracks need to be muted for this to return true. This means if there are no audio tracks, this will return true.
Source:
Returns:
True if the mic is muted, else false (including if the call is not set up yet).
Type
Boolean

pauseElement(HTMLMediaElement, queueId)

Pause the given HTMLMediaElement, serialising the operation into a chain of promises to avoid racing access to the element
Parameters:
Name Type Description
HTMLMediaElement Element element to pause
queueId string Arbitrary ID to track the chain of promises to be used
Source:

placeScreenSharingCall(remoteVideoElement, localVideoElement)

Place a screen-sharing call to this room. This includes audio. This method is EXPERIMENTAL and subject to change without warning. It only works in Google Chrome.
Parameters:
Name Type Description
remoteVideoElement Element a <video> DOM element to render video to.
localVideoElement Element a <video> DOM element to render the local camera preview.
Source:
Throws:
If you have not specified a listener for 'error' events.

placeVideoCall(remoteVideoElement, localVideoElement)

Place a video call to this room.
Parameters:
Name Type Description
remoteVideoElement Element a <video> DOM element to render video to.
localVideoElement Element a <video> DOM element to render the local camera preview.
Source:
Throws:
If you have not specified a listener for 'error' events.

placeVoiceCall()

Place a voice call to this room.
Source:
Throws:
If you have not specified a listener for 'error' events.

playElement(HTMLMediaElement, queueId)

Play the given HTMLMediaElement, serialising the operation into a chain of promises to avoid racing access to the element
Parameters:
Name Type Description
HTMLMediaElement Element element to play
queueId string Arbitrary ID to track the chain of promises to be used
Source:

setLocalVideoElement(element)

Set the local <video> DOM element. If this call is active, video will be rendered to it immediately.
Parameters:
Name Type Description
element Element The <video> DOM element.
Source:

setLocalVideoMuted(muted)

Set whether the local video preview should be muted or not.
Parameters:
Name Type Description
muted boolean True to mute the local video.
Source:

setMicrophoneMuted(muted)

Set whether the microphone should be muted or not.
Parameters:
Name Type Description
muted boolean True to mute the mic.
Source:

setRemoteAudioElement(element)

Set the remote <audio> DOM element. If this call is active, the first received audio-only stream will be rendered to it immediately. The audio will *not* be rendered from the remoteVideoElement.
Parameters:
Name Type Description
element Element The <video> DOM element.
Source:

setRemoteVideoElement(element)

Set the remote <video> DOM element. If this call is active, the first received video-capable stream will be rendered to it immediately.
Parameters:
Name Type Description
element Element The <video> DOM element.
Source: