this is a quick demo about using webrtc on nodejs server to allow Broadcasting video/audio by Broadcaster and allow clients to watch it in real time
Start the application using Node:
# Install dependencies for server
npm install
# Run the server
node src/server.js
The application should now be running on your localhost:8080 and you test it by connecting to localhost:8080
you can click on Broadcaster in home page to act as Broadcaster
after that, then you can open new tab in same browser or any other browser to try to act as client using same url localhost:8080 but by clicking on client button which you should get the video that is streamed from the broadcaster.
- we run the server
- you visit as broadcasteer
- we create rtc peer connection and save id of broadcaster
- we find and set ice candidate
- after previewing the video we wait for any client to watch
- when client visit watching page we start our client cycle
- we connect client to server
- we notify server that new client is connect which notify broadcaster
- broadcaster will init offer and send it to watcher
- watcher get the offer and init answer and send it to broadcaster
- both broadcaster and client/watcher have sdp info which makes it ready for both to connect and preview real time connection