startChannelMediaRelay method Null safety
Start relaying media streams across rooms.
- The method can invite for co-hosting across rooms. Media streams from up to four rooms can be relayed. A room can receive multiple relayed media streams.
- After you call this method, the SDK triggers
onMediaRelayStatesChangeandonMediaRelayReceiveEvent. The callback returns the status and events about the current relayed media streams across rooms.
Call this method after you join a room. Before you call the method, you must configure the destination room by specifying NERtcChannelMediaRelayConfiguration.destMediaInfo in config.
The method is applicable only to hosts in live streaming.
If you want to call the method again, you must first call the stopChannelMediaRelay method to exit the current relay status.
If you succeed in relaying the media stream across rooms and want to change the destination room, for example, adding or removing the destination room, you can call updateChannelMediaRelay to update the information about the destination room.
config specifies the configuration for media stream relay across rooms. For more information, see NERtcChannelMediaRelayConfiguration.
Implementation
Future<int> startChannelMediaRelay(
NERtcChannelMediaRelayConfiguration config) async {
StartOrUpdateChannelMediaReplayRequest request =
StartOrUpdateChannelMediaReplayRequest();
request.sourceMediaInfo = config.sourceMediaInfo?._toMap();
request.destMediaInfo = {};
config.destMediaInfo.forEach((key, value) {
request.destMediaInfo![key] = value._toMap();
});
IntValue reply = await _api.startChannelMediaReplay(request);
return reply.value ?? -1;
}