/

ABR Subscribing with WebRTC


When subscribing to an ABR-Provisioned stream on the Stream Manager using the Red5 Pro WebRTC SDK, you will first request the edge node endpoint to access the stream and then use one of the variant stream names to start subscribing. Once the subscriber stream has started playback the stream will be dynamically upgraded or downgraded based on network conditions.

It is dependent on your project requirements, but if running an ABR with different broadcast quality settings, we recommend first subscribing to the lowest variant, to ensure that your client can connect.

Since most WebRTC clients require secure websockets to subscribe, in a Red5 Pro Autoscale environment the stream manager proxies the websocket connection between the subscriber and the edge node.

In the case where the response to the GET request at:

https://yourstreammanager.com/streammanager/api/4.0/event/live/mystream_3?action=subscribe

is the following:

{
  "serverAddress": "10.0.0.0",
  "scope": "live",
  "name": "mystream_2"
}

Your initialization configuration for an RTCSubscriber will look like the following:

(function (red5prosdk) {

  var subscriber = new red5prosdk.RTCSubscriber()
  subscriber.init({
    host: 'yourstreammanager.com',
    app: 'streammanager',
    streamName: 'mystream_2',
    protocol: 'wss',
    port: 443,
    connectionParams: {
      host: '10.0.0.0',
      app: 'live'
    },
    subscriptionId: 'subscriber-' + Math.floor(Math.random() * 0x10000).toString(16)
  })
  .then(function () {
    subscriber.subscribe()
  })
  .catch(function (e) {
    console.error(e)
  })

})(window.red5prosdk)

The above is a very basic configuration. Your webapp may need additional configurations depending on requirements and deployment.

When utilizing the Stream Manager proxy for WebRTC subscriptions, you assign the top-level configuration app property as streammanager, and provide a connectionParams object that details the endpoint to proxy to.

In this example, the mystream_2 stream is requested. In doing so, the subscriber is started with a mid-level variant. As conditions improve or worsen the stream variant will be dynamically switched to higher or lower quality, respectively.