For phase 1, only 2 users can video / audio chat at the same time in Crugo. This will eventually be developed to allow multiple user video / audio chat.
User A goes to the direct tag of User B and presses the call button. User A is presenting with a calling UI. User B received that call and is shown the being called UI. User B Then presses answer. At this stage both User A and User B are taken into the video chat UI. WebRTC does its thing and the call is initialised.
User A requests to start a call with user B. User A emits the following socket message to the server.
{
"caller": "myUserID"
”tag”: tagID,
“receiver”: personWhoImCallingId,
“payload”: {
“type”: “call”
"action": "start"
}
}
When this socket is sent to the server, the client listens for inCall
boolean on the emit acknowledge. If the user is in the User busy step, the socket isnt sent to user B and the User busy is show by user A
Expected result User A: UI showing user 1 calling user B with the option to hang up
Expected result User B: UI Showing user 1 calling user B with the options to cancel or accept
{
"caller": "myUserID"
”tag”: tagID,
“receiver”: personWhoImCallingId,
“payload”: {
“type”: “call”
"action": "stop"
}
}
Expected result User A: UI Dismisses, A new chat message for missed call is posted in the tag
Expected result User B: UI Dismisses, A new chat message for missed call is posted in the tag
{
"caller": "personWhoStartedTheOriginalCallId"
”tag”: tagID,
“receiver”: "myUserID",
“payload”: {
“type”: “answer”,
“action”: accept
}
}
Expected result User A: UI dismisses and present the video calling View
Expected result User B: UI dismisses and present the video calling View
After the call is accepted, both user A and user B should now be in the User Busy state so that they cant receive calls from any other users
{
"caller": "personWhoStartedTheOriginalCallId"
”tag”: tagID,
“receiver”: "myUserID",
“payload”: {
“type”: “answer”,
“action”: decline
}
}
Expected result User A: UI displays User 2 busy
Expected result User B: UI dismisses
Once both users are in the video calling UI, one of the two users is responsble for calling the other. This happens with the following
{
“payload”: {
“type”: “sdp-offer”,
“data”: {
"type": "#sdp_candidate#",
"sdp": "#sdp_descrption#"
},
"from": "#user_ID#",
"to": "#person_to_call_ID#",
"callerID": "#the_id_of_the_user_making_the_call#"
}
}
This message will be sent over the socket and sent to the other user. At which point that will send back an answer.
{
“payload”: {
“type”: “sdp-answer”,
“data”: {
"type": "#sdp_candidate#",
"sdp": "#sdp_descrption#"
},
"from": "#user_ID#",
"to": "#person_to_call_ID#",
"callerID": "#the_id_of_the_user_making_the_call#"
}
}
Once the call has been answers and throughout the offer / answer phase, Ice candidates are also exchanged across the socket. The format for these are below.
{
“payload”: {
“type”: “ice”,
“data”: {
"candidate": "#candidarte_sdp#",
"sdpMid": "#candidate_sdpMid#",
"sdpMLineIndex": "#candidate_sdpMLineIndex#"
},
"from": "#user_ID#",
"to": "#person_to_call_ID#",
"callerID": "#the_id_of_the_user_making_the_call#"
}
}
Once the call has been accepted and the ice candidates have been exchanged, the call will begin.
During the call we have an additional socket message than can be sent to inform the other user of changes. This is used for when one of the user mutes their video and when the orientation of one of the devices changes.
{
“payload”: {
“type”: “options”,
“data”: {
"video": "#video_muted#",
"isPortrait": "#is_device_portrait#",
},
"from": "#user_ID#",
"to": "#person_to_call_ID#",
"callerID": "#the_id_of_the_user_making_the_call#"
}
}
Throughout the call, both clients also ping the server every 30 seconds
This is an empty socket messages with key = "webrtc.incall"
Finally, to hang up the call one of the user sends a socket message to end the call
{
“payload”: {
“type”: “hang”,
"from": "#user_ID#",
"to": "#person_to_call_ID#",
"callerID": "#the_id_of_the_user_making_the_call#"
}
}
Once the hang is received by the other client, the ui is dismissed. At this point we expect there to be a new chat message in the tag showing the length of the call. Also both users should now be out of the busy state.