WebsiteBeaver/simple-webrtc-video-chat-using-firebase

Adding more than two users?

tehfailsafe opened this issue · 5 comments

Is there an easy approach to adding more users to a video call? Say I want to have 3, 4, or even 5 people all on a call at the same time?

That's a good question. Take a look at https://mediasoup.org. It's uses SFU which allows you to add multiple people to a video chat.

Ah, so I need to host a full node server setup? No way with peerConnection and firebase serverless style?

You can have a multi-party video chat with just firebase, but it's not recommended. Take a look at http://www.allthingsrtc.org/wp-content/uploads/2017/08/liveswitchchart.jpg. The best way is SFU. The worst way is mesh

It's totally just a prototype to see if we should invest more into it or not. If I don't have to host a full server it would be much easier for me in the short term.

What would I need to change in this example to enable a 3rd user?

I've never tried implementing a 3-way chat, but here's how I assume you would do it. In a 2 person video chat, you only need to complete the webrtc handshake 1 time. In a 3 person video chat, you need to complete the webrtc handshake 3 times. In a 4 person video chat, you need to complete the webrtc handshake 6 times. So you need to create a peerconnection for each user (3 in your case). Then create descriptions and send them along with ice candidates to everyone. From what I've read this stops working well after 3 or 4 users, which is why they recommend using the SFU model.