Skip to main content

Broadcasting

Broadcasting serves as a means of transmitting live or pre-recorded content to a wide audience.

We can choose from two approaches to broadcasting the media:

  1. HLS - slight delay, better buffering
  2. WebRTC - lower latency, less reliability

It is up to the integrators to decide, what approach will be used in their apps for the audience to consume the streams.

Call type for broadcasting

Stream infrastructure recognizes few pre-built call types. Among them, the type livestream type is the best suited for broadcasting events. When a livestream call is created, it is set to backstage mode by default.

Starting and stopping the broadcasting

We have the following Call methods at our disposal to start and stop the broadcasting:

call.startHLS();
call.stopHLS();

Once started broadcasting, the data source URL is available through playlist_url property accessible through the Call state:

// omitted code ...
const call: Call;
// m3u8 playlist URL
const playlistUrl = call.state.egress?.hls?.playlist_url;

To play the video over HLS, a third-party library is required (for example HLS.js).

If you want to use WebRTC based streaming, your viewers would have to follow the join steps discussed previously.

Broadcasting via RTMP

Our systems provide first-class support for streaming from RTMP clients as OBS. To connect your OBS project in a Stream Call, please follow the next steps:

RTMP URL and stream key

Our call instance exposes its RTMP address through call.state.ingress and call.state.ingress$ observable. Stream Key in our case is a standard user token.

You can take this information and use it to configure OBS:

const call = client.call(type, id);
await call.getOrCreate();

const { ingress } = call.state;

const rtmpURL = ingress?.rtmp.address;
const streamKey = myUserAuthService.getUserToken(rtmpUserId);

console.log('RTMP url:', rtmpURL, 'Stream key:', streamKey);

Configure OBS

  • Go to Settings > Stream
  • Select custom service
  • Server: enter the rtmpURL logged in the console
  • Stream Key: enter the streamKey logged in the console

Press Start Streaming in OBS and the RTMP stream will now show up in your call just like a regular video participant.

Did you find this page helpful?