/

Subscribing with HLS


Subscribing with HLS

Adaptive Bitrate is supported also by HLS subscribers. In this case it is necessary to subscribe to the m3u8 stream with the GUID name. The stream variants are defined in the m3u8 manifest and the HLS playback element has the capability to switch between them based on the conditions of the network.

This is a little more complicated because making a subscribe request for the GUID will not return results because technically, that stream does not exist on the edge servers. As such, the first step involves requesting an edge endpoint from the stream manager by using the stream name one of the existing variants. For example:

Method:GET

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

Where:

  • yourstreammanager.com: is the host of your Stream Manager.
  • mystream_1: is one of the stream variants.

A successful response will look like the following:

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

This response is then used in the initialization configuration for the HLSSubscriber to the stream GUID, which will look like the following:

(function (red5prosdk) {

  var subscriber = new red5prosdk.HLSSubscriber()
  subscriber.init({
    host: '10.0.0.0',
    app: 'live',
    streamName: 'mystream',
    protocol: 'html',
    port: 5080
  })
  .then(function () {
    subscriber.subscribe()
  })
  .catch(function (e) {
    console.error(e)
  })

})(window.red5prosdk)

This will make the Red5 Pro SDL request to subscribe to the HLS stream at:

http://10.0.0.0:5080/live/mystream.m3u8