-
Notifications
You must be signed in to change notification settings - Fork 2
Room calls migration guide
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.
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.
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.
//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:
-
optionsmethod that returns theRoomCallOptionsthat the room call was started with, -
namemethod that returns the room name, -
statusmethod that returns the room call status, -
durationmethod that returns the duration of the room call in seconds calculated from the time the room was joined, -
joinTimemethod that returns the time when the participant joined the room, -
leaveTimemethod that returns the time when the participant left the room, -
sendDTMFmethod that simulates key-press by sending DTMF entry, -
cameraOrientationmethod that returns the current camera orientation used during the WebRTC call, -
setCameraOrientationmethod that sets a local camera orientation during the room call, -
audioFilterandvideoFiltermethods that return the audio/video filter being used during the room call, -
setAudioFilter(audioFilter)andsetVideoFilter(videoFilter)methods that configure audio and video filters.
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
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 }Events that are emitted when calling cameraVideo(cameraVideo) and/or
screenShare(screenShare) methods have changed, hence you should handle:
-
CAMERA_VIDEO_ADDEDinstead oflocal-camera-video-added, -
CAMERA_VIDEO_UPDATEDinstead oflocal-camera-video-updated, -
CAMERA_VIDEO_REMOVEDinstead oflocal-camera-video-removed, -
SCREEN_SHARE_ADDEDinstead oflocal-screen-share-added, -
SCREEN_SHARE_REMOVEDinstead oflocal-screen-share-added.
Payload of SCREEN_SHARE_REMOVED event has changed, and now includes a
VideoRemovalReason enum value.
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:
-
PARTICIPANT_JOINEDreplacesuser-joined, -
PARTICIPANT_LEFTreplacesuser-left, -
PARTICIPANT_MUTEDreplacesuser-muted, -
PARTICIPANT_UNMUTEDreplacesuser-unmuted, -
PARTICIPANT_STARTED_TALKINGreplacesuser-talking, -
PARTICIPANT_STOPPED_TALKINGreplacesuser-stopped-talking.
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.
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:
-
PARTICIPANT_CAMERA_VIDEO_ADDEDreplacesuser-camera-video-added, -
PARTICIPANT_CAMERA_VIDEO_REMOVEDreplacesuser-camera-video-removed, -
PARTICIPANT_SCREEN_SHARE_ADDEDreplacesuser-screenshare-added, -
PARTICIPANT_SCREEN_SHARE_REMOVED) replacesuser-screenshare-removed.
As previously explained, the payloads of listed events contain the Participant object, instead of the
previously used ConferenceUser.
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.
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;
});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.