WHEPClient(url, element, trickleIce)

new WHEPClient(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 -> subscribe as RTCSubscriber.

Parameters:
Name Type Default Description
url string

Optional endpoint for WHEP. Example: https://your-red5pro.com/live/whep/endpoint/stream1

element HTMLMediaElement

Optional media element to play media in.

trickleIce boolean true

Optional request to trickle candidates. Preferred: true.

Methods

async init(options, mediaTransform) → {Promise}

Request to initialize the WebRTC-based Subscriber 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

async subscribe() → {Promise}

Request to begin subscribing to a stream.

Returns:
Promise -

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