Cross-Channel Media Relay
pauseAllChannelMediaRelay
Pauses media stream relay to all destination channels.
public abstract int pauseAllChannelMediaRelay();
You can call this method to pause media stream relay to all destination channels. To resume relaying, call the resumeAllChannelMediaRelay method.
Return Values
- 0: Success.
- < 0: Failure.
- -5: The call is rejected. No media stream relay is currently running.
pauseAllChannelMediaRelayEx
Pauses media stream relay to all destination channels.
public abstract int pauseAllChannelMediaRelayEx(RtcConnection connection);
- Deprecated
- Deprecated since v4.2.0. Use startOrUpdateChannelMediaRelayEx instead.
You can call this method to pause media stream relay to all destination channels. To resume relay, call resumeAllChannelMediaRelay.
Scenario
This method is applicable in multi-channel scenarios.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure.
- -5: Call rejected; no ongoing media stream relay.
resumeAllChannelMediaRelay
Resumes media stream relay to all destination channels.
public abstract int resumeAllChannelMediaRelay();
After calling pauseAllChannelMediaRelay, you can call this method to resume media stream relay.
Return Values
- 0: Success.
- < 0: Failure.
- -5: The call is rejected. No paused media stream relay found.
resumeAllChannelMediaRelayEx
Resumes media stream relay to all destination channels.
public abstract int resumeAllChannelMediaRelayEx(RtcConnection connection);
After calling pauseAllChannelMediaRelayEx, you can call this method to resume media stream relay.
Scenario
This method is applicable in multi-channel scenarios.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure.
- -5: Call rejected. There is no media stream relay currently in a paused state.
startOrUpdateChannelMediaRelay
Starts or updates media stream relay across channels.
public abstract int startOrUpdateChannelMediaRelay(ChannelMediaRelayConfiguration channelMediaRelayConfiguration);
- Since
- Added since v4.2.0.
The first successful call to this method relays the media stream from the source channel to the destination channel. To relay to additional channels or stop relaying to a specific channel, call this method again to update the destination channels. This feature supports relaying to up to six destination channels.
Parameters
- channelMediaRelayConfiguration
- The configuration for media stream relay. See ChannelMediaRelayConfiguration.
Return Values
- 0: Success.
- < 0: Failure.
- -1: A general error occurred (no specific reason).
- -2: Invalid parameter.
- -8: Internal state error, possibly because the user is not a broadcaster.
startOrUpdateChannelMediaRelayEx
Starts or updates media stream relay across channels.
public abstract int startOrUpdateChannelMediaRelayEx(ChannelMediaRelayConfiguration channelMediaRelayConfiguration, RtcConnection connection);
- Since
- Added since v4.2.0.
The first successful call to this method starts relaying media streams from the source channel to the destination channel. To relay to other channels or stop relaying to a specific channel, call this method again to update the destination channels. This feature supports up to six destination channels.
- Call this method after joining a channel.
- This method is only effective when you are a broadcaster in a live streaming channel.
- Contact technical support to enable media stream relay across channels.
- This API does not support string user accounts.
Scenario
This method applies to multi-channel scenarios.
Parameters
- channelMediaRelayConfiguration
- The configuration for media stream relay. See ChannelMediaRelayConfiguration.
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure.
- -1: General error (no specific reason).
- -2: Invalid parameters.
- -8: Internal state error, possibly because the user is not a broadcaster.
stopChannelMediaRelay
Stops media stream relay across channels.
public abstract int stopChannelMediaRelay();
After calling this method, the broadcaster leaves all destination channels.
RELAY_ERROR_SERVER_NO_RESPONSE (2) or RELAY_ERROR_SERVER_CONNECTION_LOST (8) through the onChannelMediaRelayStateChanged callback. You can also call the leaveChannel method to leave the channel, and the media stream relay will automatically stop.Return Values
- 0: Success.
- < 0: Failure.
- -5: The call is rejected. No media stream relay is currently running.
stopChannelMediaRelayEx
Stops media stream relay across channels.
public abstract int stopChannelMediaRelayEx(RtcConnection connection);
Call this method to stop media stream relay across channels. Once stopped, the broadcaster exits all destination channels.
RELAY_ERROR_SERVER_NO_RESPONSE (2) or RELAY_ERROR_SERVER_CONNECTION_LOST (8) via the onChannelMediaRelayStateChanged callback. You can call leaveChannel to leave the channel, and the media stream relay will stop automatically.Scenario
This method is applicable in multi-channel scenarios.
Parameters
- connection
- Connection information. See RtcConnection.
Return Values
- 0: Success.
- < 0: Failure.
- -5: Call was rejected. No active media stream relay across channels.
onChannelMediaRelayStateChanged
Callback when the state of media relay across channels changes.
public void onChannelMediaRelayStateChanged(int state, int code)
This callback returns the error information of the current media relay across channels.
Trigger Timing
This callback is triggered when the state of media relay across channels changes.
Parameters
- state
- The state code of the media relay across channels:
RELAY_STATE_IDLE: The SDK is initializing.RELAY_STATE_CONNECTING: The SDK tries to relay the media stream to the target channel.RELAY_STATE_RUNNING: The SDK successfully relays the media stream to the target channel.RELAY_STATE_FAILURE: An error occurs. See code.
- code
- The error code of the media relay across channels:
RELAY_OK: Everything works fine.RELAY_ERROR_SERVER_ERROR_RESPONSE: Server error response.RELAY_ERROR_SERVER_NO_RESPONSE: No response from the server. This error may be caused by poor network connectivity. If this error occurs when starting media relay, you can try again later; if it occurs during relay, you can callleaveChannelto leave the channel. This error may also occur if the project has not enabled the media relay service. You can contact technical support to enable it.RELAY_ERROR_NO_RESOURCE_AVAILABLE: The SDK cannot access the service, possibly due to limited server resources.RELAY_ERROR_FAILED_JOIN_SRC: The server fails to send the relay request.RELAY_ERROR_FAILED_JOIN_DEST: The server fails to accept the relay request.RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC: The server fails to receive the media stream.RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST: The server fails to send the media stream.RELAY_ERROR_SERVER_CONNECTION_LOST: The SDK loses connection with the server due to poor network. You can callleaveChannelto leave the channel.RELAY_ERROR_INTERNAL_ERROR: Internal server error.RELAY_ERROR_SRC_TOKEN_EXPIRED: The token of the source channel has expired.RELAY_ERROR_DEST_TOKEN_EXPIRED: The token of the destination channel has expired.