Am implementation of a simple 1-1 Video Calling Web App
- NodeJS : For Signalling Server and Web Backend
- WebRTC : To implement the Video Call Part
Defines a Room Object used in the server side where two peers can join to start a Video Call.
- Integer : room_id
- Integer : max number of Users
- JSON(Peer ID : Peer)
Defines a Peer Object in the server to save the details of a Peer for further use.
- String : Peer Name
- String : Peer ID
- Socket : Peer Connection Object
- Create New Room : Lets user create a Room ID and join one.
- Generate Random number => Room ID (Must be unique)
- Go to '/r/room_id/'
- Join Existing Room : Lets a user join an existing room created by another peer.
- Enter Room ID
- Go to '/r/room_id/'
- Get Room ID from window.location.href
- Take a Name as input for Peer
- Get User Media for Demo display
- Create Socket Connection on Global NameSpace
- Can Show existing members of the room
- On Join :
- Emit 'join' message with room_id and peer_name
- Get User Media for Local Stream and Local Video
- Create RTCPeerConnection
- Listen to Signalling Server :
- 'user-arrived' : Create Offer and Send
- 'offer' : Add Remote SDP to self and Create Answer and Send
- 'answer' : Add Remote SDP to self and Start sedning streams
- 'cut-the-call' : Close RTCPeerConnection and MediaStream and redirect to main page
- Create Express App
- Create a Socket to listen
- '/' : Render index.html
- '/r/:room_id/' :
- If Room Exists : Render videocall.html ? Render index.html
- 'create-room' :
- If Empty Room with that Room ID exists : return the URL for that room
- Else :
- Create Room and on No error : return the URL for that room
- If error : Ask to create again
- 'join' :
- If Room is Empty :
- Create Peer Obj and Add socket to Room
- Else If Room Not Empty
- If has Space :
- Create Peer Obj and Add socket to Room
- Broadcast to other users in the room 'user-arrived' with peer_id
- Else
- Emit 'full-room'
- If has Space :
- If Room is Empty :
- 'offer' :
- Emit to added user the Offer
- 'answer :
- Emit to added user the Answer
- 'cut-the-call' :
- Remove Peer Obj and delete socket from the room