/

Publishing to a transcoder with WebRTC


Publishing to a transcoder with WebRTC

When publishing with WebRTC it is necessary to use the Stream Manager SSL proxy. The proxy will transfer the publish request to the transcoder provided. This is necessary because browsers require that WebRTC broadcasts are served over SSL. Moreover, in an autoscale environment in which Red5 Pro instances are spun up and down dynamically based on load, it can be unfeasible to have certs on each of them.

As an example, if the Stream Manager response to a request to publish using a transcoder is:

{
  "serverAddress": "192.168.0.13",
  "scope": "live",
  "name": "mystream"
}

Then the initialization configuration for a RTCPublisher will look like the following:

(function (red5prosdk) {

  var publisher = new red5prosdk.RTCPublisher()
  publisher.init({
    host: 'yourstreammanager.com',
    app: 'streammanager',
    streamName: 'mystream_1',
    protocol: 'wss',
    port: 443,
    mediaConstraints: {
      audio: true,
      video: {
        width: 1280,
        height: 780
      }
    },
    bandwidth: {
      video: 1000
    },
    connectionParams: {
      host: '10.0.0.0',
      app: 'live'
    }
  })
  .then(function () {
    publisher.publish()
  })
  .catch(function (e) {
    console.error(e)
  })

})(window.red5prosdk)

Where it is necessary to assign the top-level app property as streammanager and provide a connectionParams object that details the endpoint to proxy to.