startChannelMediaRelayEx

Starts relaying media streams across channels. This method can be used to implement scenarios such as co-host across channels.

public abstract int startChannelMediaRelayEx(
      ChannelMediaRelayConfiguration channelMediaRelayConfiguration, RtcConnection connection);

Details

Deprecated:
This method is deprecated. Use startOrUpdateChannelMediaRelayEx instead.
After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks return the state and events of the media stream relay.
  • If the onChannelMediaRelayStateChanged callback returns RELAY_STATE_RUNNING (2) and RELAY_OK (0), and the onChannelMediaRelayEvent callback returns RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL (4), it means that the SDK starts relaying media streams between the source channel and the target channel.
  • If the onChannelMediaRelayStateChanged callback returns RELAY_STATE_FAILURE (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.
  • After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelayEx method to quit the current relay.
  • 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

channelMediaRelayConfiguration
The configuration of the media stream relay. See ChannelMediaRelayConfiguration.
connection
The connection information. See RtcConnection.

Returns

  • 0: Success.
  • < 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.