In a video calling application, clients share audio/video streams using PeerJS, while Socket.io handles signaling and real-time communication between clients and the server.
Now, when this event occurs the server will tell all the other clients that the new user is connected.
Implementing Core Functionality
We capture the user's audio and video streams using the WebRTC getUserMedia API, which enables access to media devices and provides a media stream for peer-to-peer transmission.
Step 1: Capture User Media
Step 2: Send Stream to Other Clients
To share the stream, we use PeerJS call(), which enables peer-to-peer media exchange.
Client 1 (Caller): Initiates a call using peer.call() and sends its media stream.
Client 2 (Receiver): Listens for incoming calls using peer.on('call') and responds using call.answer().