new RTCPublisher()
Extends
Methods
-
callServer(methodName, args) → {Promise}
-
Request to invoke a method on the Application Adapter related to the
appconfig setting.Parameters:
Name Type Description methodNameString The name of the method to invoke on thw Application Adapter
argsArray 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
MediaStreaminstance if generated throughgetUserMediaand 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
Promisewill either resolve with a reference to this instance or reject with an errorStringin failure.Parameters:
Name Type Description optionsObject The initialization configuration map.
mediaTransformObject 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
videoand/oraudio. If you have transform functions that should be run in a separate thread, utilize theworkeroption providing aWebWorker. 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 aspipeOptions. Read more here: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeThrough TheWebWorker- 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
Promisewill either resolve with a reference to this instance or reject with an errorStringin failure.Parameters:
Name Type Description optionsObject The initialization configuration map.
mediaStreamMediaStream A previously established MediaStream, most likely receieved through getUserMedia() outside of SDK use.
mediaTransformObject 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
videoand/oraudio. If you have transform functions that should be run in a separate thread, utilize theworkeroption providing aWebWorker. 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 aspipeOptions. Read more here: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeThrough TheWebWorker- 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 typeString fnfunction - Overrides:
-
on(type, fn)
-
Assign a callback handler to an event type.
Parameters:
Name Type Description typeString fnfunction - 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 streamNameString null Optional stream name to broadcast on, otherwise defaulting to the
streamNameprovided ininit()configuration.promisePromise null Optional
Promiseobject to resolve/reject on based on sequence of events in establishing a broadcast, otherwise defaulting toPromisecreated internally and returned.Returns:
Promise -The returned
Promisewill 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 methodNameString The method name associated with the message to be accepted by all subscribers.
dataObject 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 levelString Valid values: TRACE, INFO, DEBUG, WARN or ERROR
messageObject 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 eventEvent - 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
clearMediaOnUnpublishis set in the initialization configuration, this will be invoked internally whenunpublishis called.- See:
-
unpublish(andRemove) → {Promise}
-
Request to stop a broadcast. The returned
Promisewill either resolve or reject on successful stop of broadcast.Parameters:
Name Type Default Description andRemoveBoolean false Flag to additionally remove the preview.
Returns:
Promise