/

WHIP Client


WHIPClient

The WHIPClient is an extension of RTCPublisher. It can be used very similar to the RTCPublisher with much of the same event life cycle - with the exception of those events related to WebSocket connection.

There are two ways in which you can start a publish session using the WHIPClient:

  • Using the constructor of a new WHIPClient instance to provide the WHIP endpoint and the target media element discussed here
  • Using an API similar to RTCPublisher to provide an init configuration and request to publish discussed here

Providing endpoint and video element for WHIP

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

const whipEndpoint = 'https://yourred5pro.com/live/whip/endpoint/stream1'
const publisher = new WHIPClient(
  whipEndpoint,
  document.querySelector('#red5pro-publisher')
)
publisher.on('*', (event) => console.log(event))

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

The construction of the WHIP endpoint URL is the following:

https://<your server deployment FQDN>/<app scope>/whip/endpoint/<stream name>
  • app scope - the target webapp scope to stream to. Typically live.
  • stream name - the unique name of the stream to publish on.

Using Similar API to RTCPublisher

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

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

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

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

Additional WHIP Configuration Properties.

There are two additional configuration properties that pertain to WHIP 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.