Advanced

Learn how to mute audio, disable video, switch camera and audio output, etc.

Mute audio

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

const enableAudioParams = { sessionId, userId, enable: false };

QB.webrtc
  .enableAudio(enableAudioParams)
  .then(() => { /* muted audio successfully */ })
  .catch(e => { /* handle error */ })

The enableAudio() method accepts one argument of the object type that has the following fields:

FieldRequiredDescription
sessionIdyesCall session identifier.
userIdyesID of the user. This is an optional parameter. If userId is not passed to this method, a local audio stream is muted/unmuted. If userId is passed, a remote audio stream is muted/unmuted (by userid provided).
enableyesBoolean parameter. true is enabled, false is disabled.

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 either from a local or remote peer in the specified call session. The video is disabled when the argument is set to false and enabled when true.

const enableVideoParams = { sessionId, userId, enable: false };

QB.webrtc
  .enableVideo(enableVideoParams)
  .then(() => { /* muted video successfully */ })
  .catch(e => { /* handle error */ })

The enableVideo() method accepts one argument of the object type that has the following fields:

FieldRequiredDescription
sessionIdyesCall session identifier.
userIdnoID of the user. If userId is not passed to this method, a local video stream is turned on/off. If userId is passed, a remote video stream is rendered/not rendered (by userId provided).
enableyesBoolean parameter. true is enabled, false is disabled.

Switch camera

You can switch the video camera during a call (by default is front camera) by passing switchCamera() with sessionId parameter.

const switchCameraParams = { sessionId };

QB.webrtc
  .switchCamera(switchCameraParams)
  .then(() => { /* camera switched successfully */ })
  .catch(e => { /* handle error */ })

The switchCamera() method accepts one argument of the object type that has the following fields:

FieldRequiredDescription
sessionIdyesCall session identifier.

Mirror local video

Mirror functionality allows to flip the video horizontally. Enable the mirror by setting mirror prop as true.

import WebRTCView from 'quickblox-react-native-sdk/RTCView'
//...
render() {
  //...
  <WebRTCView
    mirror={true}
    sessionId={sessionId}
    style={styles.video}
    userId={userId}
  />
  //...
}
ParametersDescription
mirrorBoolean parameter. true is enabled, false is disabled.
sessionIdCall session identifier.
styleView style.
userIdID of the user.

Switch audio output

You can switch the audio output to a loudspeaker or to ear-speaker during a call.

const audioOutputParams = { output: QB.webrtc.AUDIO_OUTPUT.LOUDSPEAKER };

QB.webrtc
  .switchAudioOutput(audioOutputParams)
  .then(() => { /* audio should now go through loudspeaker */ })
  .catch(e => { /* handle error */ })

Custom ICE servers

🚧

This feature is coming soon. Please check back later. For more updates and questions, feel free to contact our Customer Support Team.

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 you within an answer time interval, the QB.webrtc.EVENT_TYPE.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.

QB.rtcconfig
  .setAnswerTimeInterval(30) // value should be a number and should be >= 10
  .then(function () { /* success */ })
  .catch(function (error) { /* handle error */ }

Get the answer time interval using the code snippet below.

QB.rtcconfig
  .getAnswerTimeInterval()
  .then(function (interval) { })
  .catch(function (error) { /* handle error */ })

📘

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.

QB.rtcconfig
  .setDialingTimeInterval(5) // value should be a number and should be >= 3
  .then(function () { /* success */ })
  .catch(function (error) { /* handle error */ })

Get the dialing time interval using the code snippet below.

QB.rtcconfig
  .getDialingTimeInterval()
  .then(function (interval) { })
  .catch(function (error) { /* handle error */ })

📘

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


What’s Next