Publishing to Transcoder (WebRTC)
You can utilize either the WHIPClient
or RTCPublisher
from the SDK to start a broadcast for ABR:
WHEPClient
With the WHEPClient
, the negotiation sequence with a Stream Manager is handled server side. As such, it is very similar to how you would normally publish to the server:
import { WHIPClient } from 'red5pro-webrtc-sdk'
const publish = async () => {
const publisher = new WHIPClient()
await publisher.init({
host: 'yourstreammanager.com',
app: 'live',
streamName: 'mystream_1',
protocol: 'wss',
port: 443,
mediaConstraints: {
audio: true,
video: {
width: 1280,
height: 780
}
},
bandwidth: {
video: 1000
},
})
await publisher.publish()
}
RTCPublisher
Since the RTCPublisher
requires secure websockets to broadcast, in a Red5 Pro Autoscale environment the stream manager proxies the websocket connection between the publisher and the transcoder (or origin) node.
In the case where the response to the GET
request at:
https://yourstreammanager.com/streammanager/api/4.0/event/live/mystream?action=broadcast&transcode=true
is the following:
{
"serverAddress": "10.0.0.0",
"scope": "live",
"name": "mystream_1"
}
Your initialization configuration for an RTCPublisher
will look like the following:
import { RTCPublisher } from 'red5pro-webrtc-sdk'
const publish = async() => {
var publisher = new RTCPublisher()
await 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'
}
})
await publisher.publish()
}
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 broadcasts, you assign the top-level configuration app
property as streammanager
, and provide a connectionParams
object that details the endpoint to proxy to.
Additionally, note the mediaContraints
object on the initialization configuration and that it defines the video contraint with the corresponding variant qualities for mystream_1
from the above examples. This will be used in accessing the getUserMedia
of the browser client.