Red5 Documentation

WHEP Client

WHEPClient

There are two ways in which you can start a subscriber session using the WHEPClient:

  • Using the constructor of a new WHEPClient instance to provide the WHEP endpoint and the target media element discussed here
  • Using an API similar to RTCSubscriber to provide an init configuration and request to subscribe discussed here

Providing endpoint and video element for WHEP

If you want to allow the usual default configuration properties of a RTCSubscriber (of which the WHEPClient is an extension), you can simply provide the WHEP endpoint and target media element ot the constructor of WHEPClient:

const whepEndpoint =
  'https://yourred5pro.com/live/whep/endpoint/stream1?resourceId=abc123'
const subscriber = new WHEPClient(
  whepEndpoint,
  document.querySelector('#red5pro-subscriber')
)
subscriber.on('*', (event) => console.log(event))

When providing the endpoint and target media element in the constructor for WHEPClient, the SDK will automatically start of the connection calls and continue on to playback once available.

The construction of the WHEP endpoint URL is the following:

https://<your server deployment FQDN>/<app scope>/whep/endpoint/<stream name>?resourceId=<unique id>
  • app scope – the target webapp scope to stream to. Typically live.
  • stream name – the name of the stream to subscribe to.
  • unqique id – the resourceId query param needs to be a unique id for each subscriber.

Using Similar API to RTCSubscriber

Alternatively, you can use a similar API to the RTCSubscriber which allows you to provide more granular init configuration properties if required:

const config = {
  host: 'yourred5pro.com',
  streamName: 'stream1',
  ...more,
}
const subscriber = await new WHEPClient().init(config)
subscriber.on('*', (event) => console.log(event))
await subscriber.subscribe()

By not supplying any arguments to the WHEPClient constructor, you are instructing the SDK that you will call the subsequent init and subscribe methods to start a connection and playback session.

Please refer to the Subscriber documentation for more information related for configuration details and lifecycle.

Additional WHEP Configuration Properties.

There are two additional configuration properties that pertain to WHEP clients only:

  • trickleIce: flag to send candidates after establishing a connection and generation. Default: true. By default, the SDK will send ICE candidates in a patch after POST of an Offer. By turning this to false, it will send an all candidates along in the POST of the Offer.
  • enableChannelSignaling: flag to also open a data channel for messaging. Default: true. You can turn this to false to not open an additional data channel, though be warned that this will also turn off any essential messaging that comes from the server.