Skip to content

Room calls migration guide

Ajša Terko edited this page Feb 15, 2024 · 8 revisions

Note

Start your migration process by updating infobip-rtc dependency to version 2.1.0 or newer. As before, we publish it as an NPM package and as a standalone JS file hosted on a CDN.

WebRTC Conferencing is replaced by WebRTC Rooms, and thereby the former conferencing methods are renamed accordingly. If you previously used the joinConference method, start by migrating to the newly added joinRoom method.

Arguments

The first argument conferenceId is replaced by roomName which refers to the name of the room that the user wants to join. Moreover, the type of the second argument has changed. RoomCallOptions are introduced and should be used instead of previously used ConferenceOptions.

Note that by switching to RoomCallOptions, you will be able to configure the use of audio and video filters when joining your room calls.

Returns

The return type has changed to RoomCall and should be used instead of the previously available Conference. Consult the documentation of the RoomCall to get familiar with the newly added methods that can be used with it.

Example

//Join a conference in SDK 1.x
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(true).build());
//Join a room in SDK 2.0
let roomCall = infobipRTC.joinRoom('room-demo', RoomCallOptions.builder().audio(true).video(true).build());

While the newly added RoomCall supports all the methods available when using the deprecated Conference, there are several new methods that are available for the use:

Examples of how to use all the listed methods are available in the RoomCall documentation.

If you previously configured RecordingOptions on your individual conferences, please note that this is not supported yet when migrating to RTC SDK 2.0. For more details, consult Recording section of the migration guide.

There are several breaking changes concerning the configuration of the event handler.

Types of eventName and eventHandler have changed. Get familiar with the new types to understand emitted events and how to handle them:

  • eventName: CallsApiEvent
  • eventHandler: CallsEventHandlers - Function that will be called when a specified event occurs, with exactly one parameter being passed to the function containing event information.

ROOM_JOINED event replaces the previously emitted joined event, and its payload is expanded.

//Payload of `joined` event in SDK 1.x
event = { stream: MediaStream, users: ConferenceUser[] }
//Payload of CallsApiEvent.ROOM_JOINED event in SDK 2.0
event = { id: string, name: string, participants: Participant[], stream: MediaStream }

ROOM_LEFT event

ROOM_LEFT event replaces the previously emitted left event, and its payload is expanded.

//Payload of `left` event in SDK 1.x
event = {}
//Payload of CallsApiEvent.ROOM_LEFT event in SDK 2.0
event = { errorCode: ErrorCode, totalMediaStats: TotalMediaStats }

ERROR event

ERROR event replaces the previously emitted error event, and its payload is expanded.

When using SDK 2.0, you may encounter Calls API error codes and WebRTC error codes.

//Payload of `error` event in SDK 1.x
event = {}
//Payload of CallsApiEvent.ERROR event in SDK 2.0
event = { errorCode: ErrorCode }

Local video events

Events that are emitted when calling cameraVideo(cameraVideo) and/or screenShare(screenShare) methods have changed, hence you should handle:

Payload of SCREEN_SHARE_REMOVED event has changed, and now includes a VideoRemovalReason enum value.

Participants' state events

To handle events emitted when a room participant joins, leaves, or its state changes, there is a list of changes in configuring the event handler that should be made:

The payloads of listed events represent the Participant object, instead of the previously used ConferenceUser.

//Payload of the participants' state events in SDK 1.x
event = { user: ConferenceUser }
//Payload of the participants' state events in SDK 2.0
event = { participant: Participant }

Additionally, several events are newly available when migrating to SDK 2.0, including:

Descriptions of the listed events and examples of how to handle them are available in the RoomCall documentation.

Participants' video events

To handle events emitted when room participant shares or stops sharing camera and/or screen video streams, there is a list of changes in configuring the event handler that should be made:

As previously explained, the payloads of listed events contain the Participant object, instead of the previously used ConferenceUser.

Reconnect events

Note that events reconnecting and reconnected, previously available in SDK 1.x, are not supported at the time of release of SDK 2.0, but should be added shortly after.

Example

Let's assume you have an audio HTML element with the id remoteAudio and video HTML elements with the ids localVideo and localScreenShare.

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();

let roomCall = infobipRTC.joinRoom('test_room', RoomCallOptions.builder().build());

roomCall.on(CallsApiEvent.ROOM_JOINED, function (event) {
  $('#remoteAudio').srcObject = event.stream;
  var participants = event.participants.map(participant => participant.endpoint.identifier).join(', ');
  console.log(`You have joined the room with ${event.participants.length} more participants: ${participants}`);
});

roomCall.on(CallsApiEvent.ROOM_LEFT, function (event) {
  console.log(`You have left the room with error code: ${event.errorCode.name}.`);
});

roomCall.on(CallsApiEvent.ERROR, function (event) {
  console.log(`Error! ${event.errorCode.name}`);
});

roomCall.on(CallsApiEvent.PARTICIPANT_JOINED, function (event) {
  console.log(`${event.participant.endpoint.identifier} joined the room call.`);
});

roomCall.on(CallsApiEvent.PARTICIPANT_LEFT, function (event) {
  console.log(`${event.participant.endpoint.identifier} left the room call.`);
});

roomCall.on(CallsApiEvent.PARTICIPANT_MUTED, function (event) {
  console.log(`${event.participant.endpoint.identifier} muted.`);
});

roomCall.on(CallsApiEvent.PARTICIPANT_UNMUTED, function (event) {
  console.log(`${event.participant.endpoint.identifier} unmuted.`);
});

roomCall.on(CallsApiEvent.CAMERA_VIDEO_ADDED, function (event) {
  $('#localVideo').srcObject = event.stream;
});

roomCall.on(CallsApiEvent.CAMERA_VIDEO_UPDATED, function (event) {
  $('#localVideo').srcObject = event.stream;
});

roomCall.on(CallsApiEvent.CAMERA_VIDEO_REMOVED, function (event) {
  $('#localVideo').srcObject = null;
});

Recording

If you already have Recording add-on enabled on account level, you can set the recording preferences under Channels & Numbers > WebRTC > Recording or control it via ALWAYS, ON_DEMAND and DISABLED recording flag when generating the token for the session.

When ON_DEMAND flag is used, RecordingOptions should be passed via RoomCallOptions. Note that RecordingOptions are different from the previously available RecordingOptions (1.x).

To determine the expected behaviour when combining any of these three elements, consult the Outcome of the recording table.

To access recording files, use the available API or Portal, passing call identifier as the callId parameter.

Tutorials

Migration guides

Reference documentation

Clone this wiki locally