Screen Share Session
555 JS SDK supports screen share between its users. Make sure that the app is connected to RTC server before initiating a call. If RTC connection got disconnected due to inactivity, the user should again request for connection to make a successful call.
Screen share is initially started with no streams shared. Once session is created user can share his screen. Session related API requests have their respective callbacks to notify the user about the status of the request. List of callbacks specific to video session, in addition to the generic callbacks for any session type (audio, video or chat).
Initiate an Screen Share Session
Once the RTC connection is made, dial a valid user id to make an outgoing call. A 555 session is then created with the necessary config using IrisRtcSession class.
createSession API is invoked to create a video session, which involves creating and starting a screen share session using the room id for the room which has been already allocated for the involved participants. This API takes three params, userConfig a json object with attributes explained below, IrisRtcConnection object from rtc connetion and IrisRtcStream object from local stream
var irisRtcSession = new IrisRtcSession();
var userConfig = {
type : "video",
domain : "<app domain>",
sessionType : "create",
useBridge : true,
useAnonymousLogin : true,
stream:"nostream"
irisToken : "<JWT Token>",
routingId: "<Routing Id of the caller"
}
irisRtcSession.createSession(userConfig, irisRtcConn, irisRtcStream);
Parameters passed to createSession
API are :
Parameters | |
---|---|
userConfig | JSON object for setting session configuration parameters |
irisRtcConn | IrisRtcConnection object after rtc is connetion is successfully established |
irisRtcStream | IrisRtcStream object after local stream is successfully created |
userConfig
JSON contains below parameters :
Parameters | |
---|---|
type | Call type must be video |
irisToken | 555 JWT token |
routingId | Routing id of the caller |
useAnonymousLogin | true for anonymous Calls |
useBridge | true for PSTN Call |
stream | nostream for scree share session |
traceId | Unique time based UUID to identify call uniquely |
sessionType | Session type 'create' |
publicId | Public id of the caller |
Screen Share API
IrisRtcSession provides an API for sharing screen irisRtcSession.screenShare
to be called with below
stream config.
var irisRtcSession = new IrisRtcSession();
var streamConfig = {
constraints: {
audio: false,
video: {
mandatory: {
chromeMediaSource: "desktop",
chromeMediaSourceId: streamId,
maxWidth: window.screen.width,
maxHeight: window.screen.height,
minFrameRate: 15,
maxFrameRate: 15,
},
optional: []
}
},
screenShare: true,
useGetDisplayMedia: false
}
irisRtcSession.screenShare(roomId, irisRtcStream, streamConfig);
Moderator Controls
Admin/Moderator who owns the room has special privileges like he can lock or unlock room, he can grant or revoke moderator privileges to other participants in the session. Here are the list of APIs available for these functionality. At present admin can only grant screen share as one of the moderator privilege.
Grant moderator privilege to participants
Admin can grant moderator privilege to other participant with below API. admin
object is generated for only admin/moderators
irisRtcSession.admin.grantModeratorPrivilege(roomId, remoteParticipantJid, { screenShare: true });
Revoke moderator privilege to participants
Admin can revoke moderator privilege to other participant with below API. admin
object is generated for only admin/moderators
irisRtcSession.admin.revokeModeratorPrivilege(roomId, remoteParticipantJid, { screenShare: false });
Grant moderator privilege to all participants in the session
Admin can grant moderator privilege to all the participants in the room with below API. admin
object is generated for only admin/moderators
irisRtcSession.admin.grantAllModeratorPrivilege(roomId, { screenShare: true });
Revoke moderator privilege from all participants in the session
Admin can revoke moderator privilege from all the participants in the room with below API. admin
object is generated for only admin/moderators
irisRtcSession.admin.revokeAllModeratorPrivilege(roomId, { screenShare: false });
Lock room
Admin can a lock a room once required participants are joined. Once room is locked no other participant will be allowed to join the room, If anyone tries to join he will be errored out. Admin can decide on whether a disconnected participant is allowed to rejoin or not with the flag rejoin
set while locking the room. If rejoin
is true and a participant got disconnected or left the session he can join back. If rejoin
is false he won't be able to join back.
irisRtcSession.admin.lockRoom(roomId, rejoin);
Unlock room
Admin can unlock the room at any point of time in session, once unlocked whoever has invite can join the room.
irisRtcSession.admin.unlockRoom(roomId);
End an Active Call
On end call, all data and objects associated with that particular call must be cleared for efficiency and to avoid memory leak . While closing a video call session following things must be kept in mind.
- Close 555 Rtc session
By invoking endSession() API in IrisRtcSession, 555 session will get closed by releasing all objects associated with it. - Close stream
The close operation of stream class is synchronous and can take time while closing the stream. Closing the stream during a session can cause an error in video or audio sessions. Hence it is advisable to use stopMediaStream() API once the session is closed.
var irisRtcSession = new IrisRtcSession();
irisRtcSession.endSession(roomId);
Call Related Callbacks
onRemoteStream
This callback gets invoked when the remote stream is added to peerconnection (the mechanism in WebRTC that provides all the communication capabilities of WebRTC).
var irisRtcSession = new IrisRtcSession();
irisRtcSession.onRemoteStream = (roomId, remoteStream) => {
// Remote stream is received from participant
};
Parameters | |
---|---|
roomId | Room id received from Iris backend |
remoteStream | Media stream of the participant |
onRemoveRemoteStream
This callback gets invoked when the remote stream is removed from the peerconnection.
var irisRtcSession = new IrisRtcSession();
irisRtcSession.onRemoteStreamRemove = (roomId, participantId) => {
// Other participant has removed his media stream from session
};
Parameters | |
---|---|
participantId | Routing id of the participant |
roomId | Room id received from Iris backend |
onSessionStreamReceiveComplete
This callback gets invoked after the onRemoteStream
callback and this signifies that remote stream is received and a response
to other participant is already sent.
var irisRtcSession = new IrisRtcSession();
irisRtcSession.onSessionStreamReceiveComplete = (roomId, participantId) => {
// Stream is received and response is sent
};
Parameters | |
---|---|
participantId | Routing id of the participant |
roomId | Room id received from Iris backend |