HLS

HLS streaming provides better buffering than WebRTC, at the cost having a slight delay in your livestreams.

Start and stop HLS broadcast

There are two ways to start/stop HLS broadcast:

call.startHLSBroadcasting();

// to end broadcasting
call.stopHLSBroadcasting();

Or, if you’re using backstage mode, you can do that when going live:

call.goLive();

// optionally start HLS broadcast and/or recording
call.goLive({ start_hls: true, start_recording: true });

Once the live ended, the HLS broadcast will be stopped as well.

User permissions

To perform these operations, users need the following capabilities:

  • start-broadcast-call
  • stop-broadcast-call

Broadcast state

You can check if the call is being broadcast like this:

const resp = await call.getOrCreate();
const isBroadcasting = resp.call.egress.broadcasting;

Events

These events are sent to users connected to the call and your webhook/SQS:

  • call.broadcasting_started
  • call.broadcasting_stopped
  • call.broadcasting_failed

Consuming HLS broadcast

Users don’t need to join the call to consume the HLS broadcast, but they need to have the URL of the broadcast:

const resp = await call.getOrCreate();
const URL = resp.call.egress.hls?.playlist_url;

Multitracking

Multitracking allows you to provide multiple quality streams to your users, so they can choose the one that fits their network conditions. Lower quality streams will be downsampled from the highest quality stream. Using portrait and landscape orientations in the same stream is not supported. To enable multitracking, you need to override the quality_tracks field in the HLS settings or update call type settings on the dashboard.

const callType = "default";
const callId = "my-call";
const call = client.video.call(callType, callId);

// optionally provide additional data
call.getOrCreate({
  data: {
    created_by_id: "john",
    settings_override: {
      broadcasting: {
        enabled: true,
        hls: {
          quality_tracks: ["720p", "480p", "360p"],
        },
      },
    },
  },
});
© Getstream.io, Inc. All Rights Reserved.