startOrUpdateChannelMediaRelay

Starts relaying media streams across channels or updates channels for media relay.

Future<void> startOrUpdateChannelMediaRelay(
      ChannelMediaRelayConfiguration configuration);

Details

The first successful call to this method starts relaying media streams from the source channel to the destination channels. To relay the media stream to other channels, or exit one of the current media relays, you can call this method again to update the destination channels. This feature supports relaying media streams to a maximum of six destination channels.

After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback, and this callback returns the state of the media stream relay. Common states are as follows:
  • If the onChannelMediaRelayStateChanged callback returns relayStateRunning (2) and relayOk (0), it means that the SDK starts relaying media streams from the source channel to the destination channel.
  • If the onChannelMediaRelayStateChanged callback returns relayStateFailure (3), an exception occurs during the media stream relay.
Attention:
  • Call this method after joining the channel.
  • This method takes effect only when you are a host in a live streaming channel.
  • The relaying media streams across channels function needs to be enabled by contacting technical support.
  • Agora does not support string user accounts in this API.

Parameters

configuration
The configuration of the media stream relay. See ChannelMediaRelayConfiguration.

Exceptions

When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown; and you need to catch the exception and handle it accordingly.

  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.
    • -7: The method call was rejected. It may be because the SDK has not been initialized successfully, or the user role is not a host.
    • -8: Internal state error. Probably because the user is not a broadcaster.