new IrisRtcSession()
Constructor for IrisRtcSession. This class maintains APIs required for creating session for video call, audio call. Handles session related events and callbacks.
Methods
addPSTNParticipant(roomId, toTN, toRoutingId)
This API allows user to add a participant to the ongoing PSTN call
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Unique id for the room |
toTN |
E.164 | (MANDATORY) Telephone number of callee in e.164 format |
toRoutingId |
string | (MANDATORY) Routing id of the callee |
addStream(localStream)
Add Stream to webrtc based on the call
Parameters:
Name | Type | Description |
---|---|---|
localStream |
object | Local stream to be added to conference |
audioMuteToggle(roomId)
Mute or Unmute local audio
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Unique Id for participants in a room |
createChatSession(config, connection)
This API creates new Iris chat only session, where number of participants share chat messages over a conference.
Parameters:
Name | Type | Description |
---|---|---|
config |
json | (MANDATORY) Session config params requied to create a chat session |
connection |
object | (MANDATORY) Rtc connection object |
createSession(sessionConfig, connection, irisRtcStream)
Creating new session, A session represents a real time audio or video session where number of participants are allowed to share their video or audio with each other to create a conference. It can be a one-to-one conversation or a multiparty conference.
There are two types of session, Anonymous and Non-Anonymous session. In case of anonymous session, a participant may not be a registered user with Iris Platform, he uses a random id as his unique identfier known as routing Id.
Incase of a Non-anonymous session, a participant must be a registered user with Iris Platform, Iris will assign a routing id to the user.
A session created with this API can be Audio, Video or Screen Share
This API takes three attributes a sessionConfig
JSON object as described below,
a connection
object which is an instance of IrisRtcConnection and
a irisRtcStream
object which is an instance of IrisRtcStream.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sessionConfig |
json | (MANDATORY) A json object having all parameters required to create a session Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||
connection |
object | (MANDATORY) IrisRtcConnection object |
||||||||||||||||||||||||||||||||||||||||||||||||
irisRtcStream |
object | (MANDATORY) Instance of IrisRtcStream after stream is created. |
createSessionWithTN(sessionConfig, connection, irisRtcStream)
Creating new PSTN session, A real time audio session with a PSTN participant of outside world or another iris participant.
To create a PSTN session, user must be a registered with Iris and must have a valid Telephone number associated with the account.
PSTN session supports features like call hold/unhold, swap and merge.
This API takes three attributes a sessionConfig
JSON object as described below,
a connection
object which is an instance of IrisRtcConnection and
a irisRtcStream
object which is an instance of IrisRtcStream where local audio stream is created.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sessionConfig |
json | (MANDATORY) A json object having all parameters required to create a room Properties
|
||||||||||||||||||||||||||||||||||||
connection |
object | (MANDATORY) IrisRtcConnection object |
||||||||||||||||||||||||||||||||||||
irisRtcStream |
object | (MANDATORY) IrisRtcStream instance after the stream is created. |
downgradeToChat(downgradeConfig, notificationPayload)
Downgrade existing video/audio session to chat session
Parameters:
Name | Type | Description |
---|---|---|
downgradeConfig |
json | (MANDATORY) user config for downgrading a session to chat |
notificationPayload |
json | (MANDATORY) notification data for joining a chat session |
endSession()
API to end the session
getRealTimeStats(roomId)
This API gets real time media stats
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Unique Id for participants in a room |
joinChatSession(config, connection, notificationPayload)
This API allows to join a chat only session when participant gets an invitation for chat session.
Parameters:
Name | Type | Description |
---|---|---|
config |
json | (MANDATORY) A json object having all parameters required to create a room |
connection |
object | (MANDATORY) IrisRtcConnection object |
notificationPayload |
json | (MANDATORY) Notification payload having roomid, roomtoken and roomtokenexpirytime |
joinSession(sessionConfig, Connection, irisRtcStream, notificationPayload)
This API is called to join a Iris Rtc session incase of non-anonymous call.
For incoming calls client should pass notification information having required parameters to join session.
notification payload sent to this API must have roomid
, roomtoken
and roomtokenexpirytime
.
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sessionConfig |
json | (MANDATORY) A json object having all parameters required to create a room Properties
|
||||||||||||||||||
Connection |
object | (MANDATORY) IrisRtcConnection object |
||||||||||||||||||
irisRtcStream |
object | (MANDATORY) Instance of IrisRtcStream after stream is created. |
||||||||||||||||||
notificationPayload |
json | (MANDATORY) Notification payload having roomid, roomtoken and roomtokenexpirytime |
muteParticipantAudio(roomId, jid, mute)
Mute remote participant's audio
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Unique Id for participants in a room |
jid |
string | (MANDATORY) Remote participant's id |
mute |
boolean | (MANDATORY) true -> mute, false -> unmute |
muteParticipantVideo(roomId, jid, mute)
Mute remote participant's video
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Unique Id for participants in a room |
jid |
string | (MANDATORY) Remote participant's id |
mute |
boolean | (MANDATORY) true -> mute, false -> unmute |
onChatAck(roomId, chatAckJson)
Acknowledgement API for chat messages sent
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomId |
string | Unique to participants |
|||||||||||||||||||||
chatAckJson |
json | Unique id for the each chat message sent Properties
|
onChatMessage(roomId, chatMsgJson)
API to receive the chat messages from other participants
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomId |
string | Unique to participants |
||||||||||||||||||
chatMsgJson |
json | Chat message json from the other participant Properties
|
onChatState(roomId, participantJid, chatState)
This callback is called when chat state of a participant is changed
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room ID |
participantJid |
string | Participant Jid |
chatState |
string | chat state indicator |
onDataChannelMessage()
When a text message is received through datachannel
onMessage(roomId, colibriClass, obj)
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | RoomId |
colibriClass |
string | Data channel colibriclass |
obj |
json | info |
onRemoteStream(roomId, stream)
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of current session. |
stream |
object | Media stream of remote participant |
onRemoteStreamRemove(roomId, participantJid)
Callback when a stream is removed from the session.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | |
participantJid |
string |
onRoomLocked(roomId, lock, rejoin)
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of the session locked/unlocked |
lock |
boolean | lock/unlock status of the room, true - locked, false - unlocked |
rejoin |
boolean | true - room is locked with rejoin as true |
onSessionAdministratorJoined(roomId, adminJid, lock, rejoin)
This callback is triggered when room Admin is joined.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of the current session |
adminJid |
string | Jid of the Administrator |
lock |
boolean | lock/unlock status of the room, true - locked, false - unlocked |
rejoin |
boolean | true - room is locked with rejoin as true |
onSessionAdministratorLeft(roomId, adminJid)
This is callback is triggered when a room admin leaves, and session will be ended as soon as Admin leaves the room.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of the session where admin is left the room |
adminJid |
string | Jid of the admin |
onSessionConnected(roomId)
Callback to inform session is connected successfully
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id |
onSessionCreated(roomId, traceId, msg)
Callback for succeffully created session
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | roomId created |
traceId |
string | Identifies each session uniquely |
msg |
string | A message string for any warning from backend, ex. Max participants, if max participants value is already set by someone, it can't be overrriden but session is still created. |
onSessionDataChannelOpen(roomId)
This callback will be sent when data channel is opened with video bridge
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string |
onSessionEnd(roomId)
Callback to inform the session id for the session ended
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id unique to participants |
onSessionError(roomId, errorCode, errorMessage)
Callback to inform about the session relarted errors
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room ID |
errorCode |
string | Error code |
errorMessage |
string | Error message |
onSessionJoined(roomId, myJid)
onSessionJoined is called when caller joins session.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | RoomId to which user has joined |
myJid |
string | Jid of the caller |
onSessionParticipantAudioMuted(roomId, jid, audioMute)
Called when participant's auido is muted or unmuted
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of curret session |
jid |
string | Unique jid of the participant |
audioMute |
string | Status of audio. True - Muted. False - Not muted |
onSessionParticipantJoined(roomId, participantJid)
Callback to inform remote participant joined successfully
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room name of the participant joined |
participantJid |
string | Unique Jid of the remote participant |
onSessionParticipantLeft(roomId, participantJid, closeSession)
Callback to inform remote participant has left the session
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room name of the participant joined |
participantJid |
string | Unique Jid of the remote participant |
closeSession |
boolean | Boolean value to close the session if all remote participants leave room |
onSessionParticipantNotResponding(roomId, participantJid)
Callback for notifying client of about a not responding participant in the room
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room id |
participantJid |
string | Unique Jid of the remote participant |
onSessionParticipantVideoMuted(roomId, jid, videoMute)
Called when participant's video is muted or unmuted
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Unique Id for participants |
jid |
string | Unique jid of the participant |
videoMute |
string | Status of video. True - Muted. False - Not muted |
onSessionRejoin(roomId)
Called with session is trying to rejoin incase of black screen
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room id of the current session |
onSessionRestartFailed(roomId)
This is called when black screen is seen and tried peer connection restart to bring back video but still if we see black screen then report via this callback
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | RoomId of the session |
onSessionScreenShareStopped(roomId, message)
Called when moderator rights are revoked and screen share is stopped
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of the session |
message |
string | Information on why screen share is stopped. |
onSessionSIPStatus(roomId, jid, status)
Different states of a PSTN Call
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Unique Id for room |
jid |
string | Unique jid of user |
status |
string | status of pstn call. Possible states initializing, connecting, ringing, connected, hold and disconnected |
onSessionStreamReceiveComplete(roomId, toJid)
Called when remote participants video is received and answer is sent
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Room Id of current session. |
toJid |
string | toJid |
onSessionTypeChange(roomId, participantJid, type)
This is called when a participant changes type of the call ex. From chat > video or video > chat, callType will be "video" for a video call "audio" for a audio call "chat" for a chat session
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Unique to participants in the room |
participantJid |
string | Jid of the participant whose session type has changed |
type |
string | Session type changed to ex. video, chat |
onUserProfileChange(roomId, jid, profileJson)
Called when there is a change in user profile. ex. Dispaly name
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomId |
string | Unique Id for room |
||||||||||||
jid |
string | Unique jid of the user |
||||||||||||
profileJson |
json | Json with user profile Properties
|
pstnHold(roomId, participantJid)
This API allows user put a PSTN call on hold
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | room id |
participantJid |
string | Jid of the pstn participant |
pstnMerge(roomId, firstParticipantJid, secondSession, secondParticipantJid)
This API allows user to merge two pstn calls
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room Id |
firstParticipantJid |
string | (MANDATORY) Jid of the participant in first call |
secondSession |
object | (MANDATORY) IrisRtcSession of the second participant |
secondParticipantJid |
string | (MANDATORY) Jid of the participant in second call |
pstnUnHold(roomId, participantJid)
This API allows user to unhold a PSTN call
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room id |
participantJid |
string | (MANDATORY) Jid of the pstn participant |
removeStream(localStream)
Removes streams from conference
Parameters:
Name | Type | Description |
---|---|---|
localStream |
object | Stream to be removed from the conference |
screenShare(roomId, irisRtcStream, streamConfig, useGetDisplayMedia)
This API allows user to share desktop screen. Example for streamConfig to be sent while sharing screen
Example
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
}
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomId |
string | Room Id |
||||||||||||||||||
irisRtcStream |
object | (MANDATORY) IrisRtcStream object |
||||||||||||||||||
streamConfig |
json | (MANDATORY) Stream config json example as mentioned above Properties
|
||||||||||||||||||
useGetDisplayMedia |
boolean | (OPTIONAL) true if user wants to use new getDisplayMedia of chrome for screen share |
selectParticipant(roomId, participantId)
Elects the participant with the given id to be the selected participant in order to receive higher video quality.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room ID |
participantId |
string | (MANDATORY) the identifier of the participant |
sendChatMessage(roomId, id, message, topic)
This API is called to send a chat message.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room ID |
id |
string | (MANDATORY) Unique Id for each message sent. |
message |
string | (MANDATORY) Chat message to be sent |
topic |
string | (OPTIONAL) Notification topic that user subscribed for chat Format: appdomain/type, ex: abcd.comcast.com/chat |
sendChatState(roomId, chatState)
This API is called to set chat state like active, composing, paused inactive, gone
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room Id |
chatState |
string | (MANDATORY) Permitted chatState values are active, composing, paused, inactive or gone |
sendDataChannelMessage(roomId, msg, to)
Send a message through data channel to a participant or to all participants in conference
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room ID |
msg |
string | (MANDATORY) Message to be sent |
to |
string | (MANDATORY) Participant jid or to send to all - "" |
sendDTMFTone(roomId, tone, duration, interToneGap)
This API allows user to send DTMF tones
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room Id |
tone |
string | (MANDATORY) DTMF tone |
duration |
integer | (OPTIONAL) duration of the tone. Should be with in (70, 6000) |
interToneGap |
integer | (OPTIONAL) inter tone gap. Should be more than 50 |
setDisplayName(roomId, name)
API to set dispaly name for the user
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room ID |
name |
string | (MANDATORY) Name for the user |
setLastN(roomId, lastN)
Selects a new value for "lastN". The requested amount of videos are going to be delivered after the value is in effect. Set to -1 for unlimited or all available videos.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room ID |
lastN |
integer | (MANDATORY) the new number of videos the user would like to receive. |
stopScreenShare(roomId)
Call this API once screen share is stopped. This is API removes desktop stream from conference.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | (MANDATORY) Room Id |
switchAudioStream(streamConfig)
API allows users to switch their mic during the call
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
streamConfig |
json | (MANDATORY) Stream config json example as mentioned above Properties
|
switchStream(roomId, irisRtcStream, streamConfig)
This API allows user to switch the stream between the camera, this can used for screen share with the constraints having source id for desktop sourceid
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
roomId |
string | (MANDATORY) Room Id |
||||||||||||||||||||||||
irisRtcStream |
object | (MANDATORY) IrisRtcStream object |
||||||||||||||||||||||||
streamConfig |
json | (MANDATORY) Stream config json example as mentioned above Properties
|
updateVideoElementRef(roomId, videoElement)
Update with the remote video's html element reference This function will check if video is playing or not and restart peer connection if video doesn't show up
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | roomId created |
videoElement |
object | Remote video element reference |
upgradeToAudio(irisRtcStream, upgradeConfig, notificationPayload)
Move to a audio session from chat session
Parameters:
Name | Type | Description |
---|---|---|
irisRtcStream |
object | (MANDATORY) IrisRtcStream instance after stream is created |
upgradeConfig |
json | (MANDATORY) user config for upgrading to a audio session |
notificationPayload |
json | (MANDATORY) notification data for joining a chat session |
upgradeToVideo(irisRtcStream, upgradeConfig, notificationPayload)
Move to a video session from chat session
Parameters:
Name | Type | Description |
---|---|---|
irisRtcStream |
object | (MANDATORY) IrisRtcStream instance after stream is created |
upgradeConfig |
json | (MANDATORY) user config for upgrading to a video session |
notificationPayload |
json | (MANDATORY) notification data for joining a chat session |
videoMuteToggle(roomId)
Mute or unmute local video
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Unique Id for participants in a room |