This project is build on top of repo forked from : https://github.com/fireship-io/webrtc-firebase-demo.git
This project is created with VITE in vanilla JS.
- Used for peer to peer connection, mostly browser to browser. Uses UDP protocol, so it's good to use this for for media transfer. This is used mostly for video call, audio call, etc. For important file transfer this might not be appropriate.
- In real world, tere is no true peer to peer conenction, we need signaling server to establish connection between peer to peer. WebRTC makes use of signaling server to help it establish connection with other peers.
- Due to the firewall that sits on our network, the address for the device keeps on changing. Hence, to communicate properly, ICE collects all available candidates (local IP addresses, reflexive addresses – STUN). All the collected addresses are then sent to the remote peer via SDP.
- Session Description Protocol. SDP is used by WebRTC to negotiate the session’s parameters. Since there is no signaling in WebRTC, the SDP created and used by WebRTC is assumed to be communicated by the application and not by WebRTC itself.
- A STUN server is a server that runs on the public network and replies to incoming requests. The responses it sends out include the public IP address the request was sent to him from. This effectively answers the question “what is my IP address?”. Giants like google provide free stun servers.
- We use firebase to be a signaling server for our video call.
- Create an .env file with firebase configuration. (check env.sample for example)
- From the firebaes console, initialize firestore in test mode.
STEPS:
- Login to console.firebase.com.
- Add project name and continue with default settings.
- Click on firestore databse -> create database -> start in test mode. (select any location)
- Create web project from settings panel.
- Copy the project config and use it in your code.
- Fork / clone this repo.
- run
npm install
- configure your
.env
file. - run
npm run dev
- Start a call. (url will be copied, you can use that in another tab)
- Paste the link in another tab.
- There is echo when starting camera with {audio: true}
- Hangup in remote peer is detected late to the caller. And many more issues that I am yet to encounter.
NOTE: Any suggestinos and PR to improvise this project is highly appreciated.