Advanced

Learn how to mute audio and disable video.

Mute audio

Mute the audio by calling the enableAudio() method with sessionId, userId, and enable parameters. Using this method we can tell SDK to send/not send audio data from a remote or local peer in the specified call session.

String sessionId = "5d4175afa0eb4715cae5b63f";
bool enable = true;
double userId = 923874;

try {
  await QB.webrtc.enableAudio(sessionId, enable: enable, userId: userId);
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details 
}
ArgumentRequiredDesription
sessionIdyesCall session identifier.
muteyesBoolean parameter. true is muted, false is unmuted.
userIdnoID of the user. This is an optional parameter. If the userId is not passed to this method, a local audio stream is muted/unmuted. If the userId is passed, a remote audio stream is muted/unmuted (by userId provided).

Disable video

Turn off the video by calling the enableVideo() method with sessionId, userId, and enable parameters. Using this method we can tell SDK not to send video data from a remote or local peer in the specified call session.

String sessionId = "5d4175afa0eb4715cae5b63f";
bool enable = true;
double userId = 923874;

try {
  await QB.webrtc.enableVideo(sessionId, enable: enable, userId: userId);
} on PlatformException catch (e) {
	// Some error occurred, look at the exception message for more details      
}
ArgumentRequiredDescription
sessionIdyesCall session identifier.
enableyesBoolean parameter. true is enabled, false is disabled.
userIdnoID of the user. If the userId is not passed to this method, a remote video stream is turned on/off. If userId is passed, a remote video stream is rendered/not rendered (by userId provided).

Mirror local video

The mirror functionality allows flipping the video horizontally. To enable mirroring, use the setMirror() method in the RTCVideoViewController.

//Widget

RTCVideoViewController? _localVideoViewController;

child: Container(
  margin: new EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
  width: 160.0,
  height: 160.0,
  child: RTCVideoView(
    onVideoViewCreated: _onLocalVideoViewCreated,
  ),
  decoration: BoxDecoration(color: Colors.black54),
)

void _onLocalVideoViewCreated(RTCVideoViewController controller) {
  _localVideoViewController = controller;
}

Future<void> setMirror(bool isMirror) async {
  try {
    _localVideoViewController?.setMirror(true);
  } on PlatformException catch (e) {
    // handel error
  }
}

General settings

You can change different settings for your calls using QB.rtcConfig class. All of them are listed below.

Answer time interval

If an opponent hasn't answered within an answer time interval, the QBRTCEventTypes.NOT_ANSWER event type will be received. The answer time interval shows how much time an opponent has to answer your call. Set the answer time interval using the code snippet below.

//Interval in seconds
int interval = 15;

try {
  await QB.rtcConfig.setAnswerTimeInterval(interval);
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details 
}

📘

By default, the answer time interval is 60 seconds.
The minimum value is 10 seconds.

Dialing time interval

Dialing time interval indicates how often to notify your opponents about your call. Set the dialing time interval using the code snippet below.

//Interval in seconds
int interval = 15;

try {
  await QB.rtcConfig.setDialingTimeInterval(interval);
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details 
}

📘

By default, the dialing time interval is 5 seconds.
The minimum value is 3 seconds.

Switch audio output device

You can switch an audio output. Call the switchAudioOutput() method and pass the type of the audio device to it.

🚧

You can switch the audio input only after receiving/creating a webrtc session.

// Audio output
// EARSPEAKER = 0
// LOUDSPEAKER = 1
// HEADPHONES = 2
// BLUETOOTH = 3

int output = QBRTCAudioOutputTypes.LOUDSPEAKER;

try {
  await QB.webrtc.switchAudioOutput(output);
} on PlatformException catch (e) {
  // Some error occurred, look at the exception message for more details
}
ArgumentRequiredDescription
outputyesType of the audio device:
QBRTCAudioOutputTypes.EARSPEAKER ,
QBRTCAudioOutputTypes.LOUDSPEAKER ,
QBRTCAudioOutputTypes.HEADPHONES,
QBRTCAudioOutputTypes.BLUETOOTH.

What’s Next