undefined

Video Conferencing

ConnectyCube Multiparty Video Conferencing API is built on top of WebRTC protocol and based on top of WebRTC SFU architecture.

Max people per Conference call is 12.

Video Conferencing is available starting from Hobby plan (you still can play with it on a Free plan).

To get a difference between P2P calling and Conference calling please read our ConnectyCube Calling API comparison blog page.

Features supported

  • Video/Audio Conference with up to 12 people
  • Join-Rejoin video room functionality (like Skype)
  • Guest rooms
  • Mute/Unmute audio/video streams
  • Display bitrate
  • Switch video input device (camera)
  • Switch audio input device (microphone)

Code samples

There are ready-to-go FREE code samples to help you better understand how to integrate multiparty video conferencing capabilities in your apps:

  • Multiparty Video Conferencing code sample for browser - src code

Set up config

In order to start working with Multiparty Video Conferencing API you need to initialize a client:

const credentials = {
  appId: ...,
  authKey: "...",
  authSecret: "..."
}

const MULTIPARTY_SERVER_ENDPOINT = 'wss://...:8989';

const appConfig = {
  debug: { mode: 1 },
  conference: { server: MULTIPARTY_SERVER_ENDPOINT },
}

ConnectyCube.init(credentials, appConfig)

Default multiparty server endpoint is wss://janus.connectycube:8989.

Create session

Once ConnectyCube SDK has been initialized, you can start creating session. Normally, each browser tab will need a single session with the server:

const session = ConnectyCube.videochatconference.createNewSession()

Once a session is created, you can interact with a Video Conferencing API.

Access local media stream

In order to have a video chat session you need to get an access to the user's devices (webcam / microphone):

const mediaParams = {
    audio: true,
    video: true,
    options: {
        muted: true,
        mirror: true
    }
};

session
    .getUserMedia(mediaParams)
    .then(localStream => {})
    .catch(error => {});

This method lets the browser ask the user for permission to use devices. You should allow this dialog to access the stream. Otherwise, the browser can't obtain access and will throw an error for getUserMedia callback function.

For more information about possible audio/video constraints, here is a good code sample from WebRTC team how to work with getUserMedia constraints: https://webrtc.github.io/samples/src/content/getusermedia/resolution/

HD video quality

If HD video quality is required - the following audio/video constraints are required to pass:

{video: { width: 1280, height: 720 }, audio: true}

More info about all possible is are available here https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

Attach local media stream

Then you should attach your local media stream to HTML video element.

For Web-like environments, including Cordova - use the following method:

session.attachMediaStream('myVideoElementId', localStream);

For ReactNative environment - use the following method:

import {RTCView} from 'react-native-connectycube';

// pass a local or remote stream to the RTCView component
...
<RTCView  objectFit="cover" style={styles.rtcView} key={userId} streamURL={localStream.toURL()} />
...

Join video room

To jump into video chat with users you should join it:

session.join(roomId, userId, userDisplayName)
    .then(() => {})
    .catch(error => {})

To check current joined video room use the following property:

const roomId = session.currentRoomId

List online participants

To list online users in a room:

session.listOfOnlineParticipants()
    .then(participants => {})
    .catch(error => {})

Events

There are 6 events you can listen for:

ConnectyCube.videochatconference.onParticipantJoinedListener = (session, userId, userDisplayName) => {}
ConnectyCube.videochatconference.onParticipantLeftListener = (session, userId) => {}
ConnectyCube.videochatconference.onRemoteStreamListener = (session, userId, stream) => {}
ConnectyCube.videochatconference.onSlowLinkListener = (session, userId, uplink, nacks) => {}
ConnectyCube.videochatconference.onRemoteConnectionStateChangedListener = (session, userId, iceState) => {}
ConnectyCube.videochatconference.onSessionConnectionStateChangedListener = (session, iceState) => {}

Mute/Unmute audio

You can mute/unmute your own audio:

// mute
session.muteAudio()

// unmute
session.unmuteAudio()

//check mute state
session.isAudioMuted() // true/false

Mute/Unmute video

You can mute/unmute your own video:

// mute
session.muteVideo()

// unmute
session.unmuteVideo()

//check mute state
session.isVideoMuted() // true/false

List of devices

// get all devices
ConnectyCube.videochatconference.getMediaDevices()
    .then(allDevices => {})
    .catch(error => {})

// only video devices
ConnectyCube.videochatconference.getMediaDevices(ConnectyCube.videochatconference.DEVICE_INPUT_TYPES.VIDEO)
    .then(videoDevices => {})
    .catch(error => {})

// only audio devices
ConnectyCube.videochatconference.getMediaDevices(ConnectyCube.videochatconference.DEVICE_INPUT_TYPES.AUDIO)
    .then(audioDevices => {})
    .catch(error => {})

Switch video(camera)/audio(microphone) input device

const deviceId = '...';

// switch video
session.switchMediaTracks({ video: deviceId })
    .then(updatedLocaStream => {}) // you can reattach local stream
    .catch(error => {})
// switch audio
session.switchMediaTracks({ audio: deviceId })
    .then(updatedLocaStream => {}) // you can reattach local stream
    .catch(error => {})

Screen Sharing

Request a desktop stream by calling getDisplayMedia:

const constraints = {
  video: {
    width: 1280,
    height: 720,
    frameRate: { ideal: 10, max: 15 }
  },
  audio: true };

ConnectyCube.videochatconference.getDisplayMedia(constraints)
    .then(localDesktopStream => {})
    .catch(error => {});

More info about what else options can be passed can be found here https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia

If you want to replace the existing camera stream with a desktop one, just pass a true value as a 2nd argument:

ConnectyCube.videochatconference.getDisplayMedia(constraints, true)
    .then(localDesktopStream => {})
    .catch(error => {});

Get remote user bitrate

const bitrate = session.getRemoteUserBitrate(userId);

Get remote user mic level

const micLevel = session.getRemoteUserVolume(userId);

Leave room and destroy conf session

To leave current joined video room:

session.leave()
    .then(() => {})
    .catch(error => {})

Continue calling in background

If you are developing dedicated apps for iOS and Android - it's required to apply additional configure for the app to continue playing calling audio when it goes into the background.

On iOS: there is no way to continue a video call in background because of some OS restrictions. What is supported there is to continue with voice calling while an app is in background. Basically, the recommended to achieve this is to switch off device camera when an app goes to background and then switch camera on back when an app goes to foreground.

Furthermore, even voice background call are blocked by default on iOS. To unblock - you need to setup proper background mode capabilities in your project. Please find the Enabling Background Audio link with more information how to do it properly.

For Android, we also recommend to implement the same camera switch flow when go to background and then return to foreground.