livqenoDocs

Live StreamingHosts & Co-hosts

Hosts & Co-hosts

Add and remove people who can broadcast. The creator is the first host.

Hosts and co-hosts are the people who can broadcast video and audio in a stream. Everyone else is a viewer.

A typical use: Alice hosts a live interview and brings Bob "on stage" as a guest. Alice is the HOST. Bob becomes a CO_HOST for as long as he's on.

Where this fits: you've created a stream. Now your backend makes a credential for each person who will broadcast, and sends it to their app. The person you named in hostIdentity when creating the stream is already registered as HOST, but still needs addHost to get credentials.

Add or remove a host

On your backend, after your own check that this user may broadcast:

const credential = await livqeno.liveStreams.addHost(streamId, { identity: 'bob', role: 'CO_HOST' });
await livqeno.liveStreams.removeHost(streamId, 'bob');

What addHost does:

  1. Registers the person as a host of this stream (or updates them, if they already are).
  2. Adds them to the stream's chat with the matching scope.
  3. Returns their credentials: an rtc token that can broadcast and a chat token.
  4. Sends the live_stream.host_joined webhook. Note that this fires when the credentials are made, not when the host actually connects.

Which role do they get?

  • Pass role: 'HOST' or role: 'CO_HOST' to set it.
  • Leave role out for someone new, and they become CO_HOST.
  • Leave role out for someone already registered, and they keep their role. So refreshing a host's credentials never demotes them.

HOST vs. CO_HOST

HOSTCO_HOST
Broadcast audio/video✓✓
Chat moderation scopeADMINMODERATOR

Both can broadcast exactly the same things. The difference is the chat scope, and the label your app shows. Adding and removing hosts is always done by your backend with the API key, so it's up to your app to decide whether a co-host may bring on other guests.

What removing a host does

removeHost marks the person as removed (removedAt is set) and takes them out of the stream's chat. Their past chat messages stay. Your backend gets the live_stream.host_left webhook.

Join as a host

Send the credential from addHost to the host's app, unchanged. In the host's app, join and turn on the camera and mic. Turning a device on is what broadcasts it:

import { LiveStream } from '@livqeno/live';
 
const stream = await LiveStream.join(credentials); // role: 'HOST' or 'CO_HOST'
 
await stream.room.enableCamera();
await stream.room.enableMicrophone();

On every SDK, isHost is true for both HOST and CO_HOST. To tell them apart, check role.

Common errors

ErrorCauseFix
RAVEN_STREAM_INVALID_STATE on addHostThe stream has ENDED.You can't add hosts to an ended stream. Create a new one.
RAVEN_USAGE_LIMIT_EXCEEDED (403) on addHostThe account has used all 100 live-streaming host-hours.See paid plans. Viewer credentials still work.
RAVEN_STREAM_NOT_FOUNDWrong stream id, or the stream is in another project or environment.Use the id from create().
RAVEN_NOT_FOUND on removeHostThat person was never added, or was already removed.Check the host list with get() or livqeno streams inspect first.

Production tips

  • To refresh a host's credentials, call addHost again with the same identity. Do this when the host rejoins, or after a reconnect fails because the token expired. It also re-activates a removed host.
  • Only call addHost from your backend, after your own permission check. It's the only way to give someone broadcast access.

Next steps

  • Viewers: give the audience watch-only credentials.
  • Moderation: what hosts can do in chat.
  • Network quality: keep a host's broadcast going when their network drops.