Handle a Remote Stream

The Flutter SDK provides the following methods to handle a remote stream:

Subscribe to a Remote Stream

The EnxRtc.subscribe() method is used to receive the media stream of other users connected to a room. This method must be called for each participant's media stream individually to receive it.

Class: EnxRtc

Method: static Future<void> subscribe(String streamId)

Parameters

ParameterData TypeDescription
streamIdStringStream ID to subscribe to
onSubscribeStreamJSON ObjectAcknowledgment to the subscriber when they have subscribed to the Stream successfully.

Sample Code

EnxRtc.onStreamAdded = (Map<dynamic, dynamic> map) {
String streamId;
setState(() {
streamId = map['streamId'];
});
EnxRtc.subscribe(streamId);
};
EnxRtc.onSubscribedStream= (Map<dynamic, dynamic> map) {
};

Mute or Unmute Audio of Subscribed Streams

The muteSubscriberStreamsAudio() method allows you to mute or unmute the audio of subscribed streams.

Class: EnxRtc

Method: static Future<void> muteSubscriberStreamsAudio(bool isMute)

ParametersData TypeDescription
isMuteBooleanSet it to true to mute audio; Set it to false to unmute audio.

Sample Code

EnxRtc.muteSubscriberStreamsAudio(true); // To mute
EnxRtc.muteSubscriberStreamsAudio(false); // To unmute

Handle Active Talkers

Get The Maximum Permissible Talker Count

The EnxRtc.getMaxTalkers() method provides the maximum number of active talkers allowed for the room.

Class: EnxRtc

Method: static Future<void> getMaxTalkers()

Event Listener: onMaxTalkerCount: To get the number of maximum talkers allowed in the room.

Sample Code

EnxRtc.getMaxTalkers();
EnxRtc.onMaxTalkerCount= (Map<dynamic, dynamic> map) {
// Talker info in response JSONObject
// {"result": 0, "maxTalkers": 4}
}

Get The Talker Count

It may be necessary to know how many talkers are expected to receive onActiveTalkerList event listener, that is to know either the preset value of talkers or any custom value in effect, either by the application developer or opted by the endpoint user.

Class: EnxRtc

Method: static Future<void> getTalkerCount()

Event Listener: onGetTalkerCount: Gets the talker count.

Sample Code

EnxRtc.getTalkerCount();
EnxRtc.onGetTalkerCount = (Map<dynamic, dynamic> map) {
// Talker info in response JSONObject
// {"result": 0, "maxTalkers": 4}
}

Set The Talker Count

onActiveTalkerList sets a maximum of 6 active talkers in the list. However, if required, you can receive fewer talkers at a client endpoint. This may either be a predefined value, or this value may be set at runtime in a connected session. If needed, you can create UI for the connected user to opt for the number of active talkers the user wants to receive. The EnxRtc.setTalkerCount() method allows you to customize the number of active talkers you want to receive.

Class: EnxRtc

Method: Future<void> setTalkerCount(int count)

Parameters

ParameterData TypeDescription
int countNumericNumber of talkers you want to receive. You can input from 0 up to 6 talkers
onSetTalkerCountJSON ObjectNumber of talkers

Note: If you set the count to 0 (zero), the talker list doesn't become empty. Instead, you receive 3 audio streams only. If you set the count to any value between 1 and 6, you will receive that number of talkers in the list.

Sample Code

EnxRtc.setTalkerCount(2);
EnxRtc.onSetTalkerCount = (Map <dynamic, dynamic> map) {
// Talker info in response jsonobject:
// {"result": 0, "maxTalkers": 4}
}