RTCPublisher()

Main entry for WebRTC-based Publisher.

new RTCPublisher()

Extends

Methods

callServer(methodName, args) → {Promise}

Request to invoke a method on the Application Adapter related to the app config setting.

Parameters:
Name Type Description
methodName String

The name of the method to invoke on thw Application Adapter

args Array

The ordered list of arguments to invoke on the method. Do not provide anything if the method takes no arguments.

Returns:
Promise

getDataChannel() → {RTCDataChannel}

Returns the current RTCDataChannel is available.

Returns:
RTCDataChannel

getMediaStream() → {MediaStream}

Returns the MediaStream instance if generated through getUserMedia and exists for broadcast.

Returns:
MediaStream

getOptions() → {Object}

Returns the initialization configuration used in init().

Returns:
Object

getPeerConnection() → {RTCPeerConnection}

Returns the current RTCPeerConnection helper if established.

Returns:
RTCPeerConnection

getType() → {String}

Returns the type of implementation: RTC.

Returns:
String

init(options, mediaTransform) → {Promise}

Request to initialize the WebRTC-based Publisher based on configuration. The returned Promise will either resolve with a reference to this instance or reject with an error String in failure.

Parameters:
Name Type Description
options Object

The initialization configuration map.

mediaTransform Object

The defined transforms to pipe decoding through. InsertableStreams API. { video: (function|null), audio: (function|null), worker: { video: (Worker|null), audio: (Worker|null) }, transformFrameType: (TransformFrameTypes), pipeOptions: (object), } If you have transform functions that can run on the main thread, provide them in video and/or audio. If you have transform functions that should be run in a separate thread, utilize the worker option providing a WebWorker. By default, the transform function will be supplied an RTCEncodedVideoFrame or RTCEncodedAudioFrame. If you would prefer to receive either a VideoFrame or AudioData instead, use the transfromFrameType of TransformFrameTypes.PACKET. You can provide some options that will be sent when defining pipe as pipeOptions. Read more here: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeThrough The WebWorker - if utilized - needs to confirm to a specific API that will be called from the SDK.

Returns:
Promise

initWithStream(options, mediaStream, mediaTransform) → {Promise}

Request to initialize the WebRTC-based Publisher based on configuration and previously established MediaStream. USE WITH CAUTION. It is assumed you know what you are doing in accessing a MediaStream outside of the API available from the SDK. The returned Promise will either resolve with a reference to this instance or reject with an error String in failure.

Parameters:
Name Type Description
options Object

The initialization configuration map.

mediaStream MediaStream

A previously established MediaStream, most likely receieved through getUserMedia() outside of SDK use.

mediaTransform Object

The defined transforms to pipe decoding through. InsertableStreams API. { video: (function|null), audio: (function|null), worker: { video: (Worker|null), audio: (Worker|null) }, transformFrameType: (TransformFrameTypes), pipeOptions: (object), } If you have transform functions that can run on the main thread, provide them in video and/or audio. If you have transform functions that should be run in a separate thread, utilize the worker option providing a WebWorker. By default, the transform function will be supplied an RTCEncodedVideoFrame or RTCEncodedAudioFrame. If you would prefer to receive either a VideoFrame or AudioData instead, use the transfromFrameType of TransformFrameTypes.PACKET. You can provide some options that will be sent when defining pipe as pipeOptions. Read more here: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeThrough The WebWorker - if utilized - needs to confirm to a specific API that will be called from the SDK.

Returns:
Promise

muteAudio()

Request to mute the audio of the broadcast. Can only be called once the broadcast has begun.

muteVideo()

Request to mute (not send) the video of the broadcast. Can only be called once the broadcast has begun.

off(type, fn)

Remove a callback handler for an event type.

Parameters:
Name Type Description
type String
fn function
Overrides:

on(type, fn)

Assign a callback handler to an event type.

Parameters:
Name Type Description
type String
fn function
Overrides:

preview() → {Promise}

Request to preview the generate MediaStream in the target view prior to publishing. Automatically called when invoking publish().

Returns:
Promise
See:

publish(streamName, promise) → {Promise}

Request to begin a broadcast session after initialization has occured.

Parameters:
Name Type Default Description
streamName String null

Optional stream name to broadcast on, otherwise defaulting to the streamName provided in init() configuration.

promise Promise null

Optional Promise object to resolve/reject on based on sequence of events in establishing a broadcast, otherwise defaulting to Promise created internally and returned.

Returns:
Promise -

The returned Promise will resolve or reject on successful start of a broadcast.
There are several processes that occur in order to establish a WebRTC broadcast that involve - but are not limited to - ICE communication and assigning of local and remote SDPs on peer connections.

send(methodName, data)

Request to send a message to all subscribers.

Parameters:
Name Type Description
methodName String

The method name associated with the message to be accepted by all subscribers.

data Object

The data object to send associated with the method name.

sendLog(level, message)

Sends an RPC log to the server which will be printed out in server logs.

Parameters:
Name Type Description
level String

Valid values: TRACE, INFO, DEBUG, WARN or ERROR

message Object

Either a String or a JSON-serializable Object. This param will be converted to a string to be sent to the server.

trigger(event)

Dispatch an event to be handled by any assigned callbacks.

Parameters:
Name Type Description
event Event
Overrides:

unmuteAudio()

Request to unmute the audio of a broadcast that has been previously muted.

unmuteVideo()

Request to unmute (resume sending) the video of a previously video-muted broadcast.

unpreview()

Clears the MediaStream from the target view and releases the camera from the browser. If clearMediaOnUnpublish is set in the initialization configuration, this will be invoked internally when unpublish is called.

See:

unpublish(andRemove) → {Promise}

Request to stop a broadcast. The returned Promise will either resolve or reject on successful stop of broadcast.

Parameters:
Name Type Default Description
andRemove Boolean false

Flag to additionally remove the preview.

Returns:
Promise