new WHIPClient(url, element, trickleIce)
Constructor. Providing arguments will automatically kick of connection sequence. Leaving arguments unset allows for more control and follows same pattern of init -> publish as RTCPublisher.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
url |
string | Optional endpoint for WHIP. Example: https://your-red5pro.com/live/whip/endpoint/stream1 |
|
element |
HTMLMediaElement | Optional media element to play media in. |
|
trickleIce |
boolean | false | Optional request to trickle candidates. Preferred: false, send with SDP offer. |
Methods
-
async init(options) → {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 errorString
in failure.Parameters:
Name Type Description options
Object The initialization configuration map.
Returns:
Promise -
async initWithStream(options, mediaStream) → {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 errorString
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.
Returns:
Promise -
async 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 ininit()
configuration.promise
Promise null Optional
Promise
object to resolve/reject on based on sequence of events in establishing a broadcast, otherwise defaulting toPromise
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. -
async 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