0

I'am develop group call like google meet using WebRTC and SFU method for routing. my project work well, until i open chrome://webrtc-internals to see webrtc connection status. and i compare with google meet.

  • Google meet
    • only 1 peer connection is active.
  • my project.
    • 1 peer connection active for broadcast.

    • n-1 peer connection active as consumer.

      so if total users in a room is 5. then on each client side has 5 peer connections are active too (1 as broadcaster, 4 as consumers).

enter image description here

so my question is, how i can using only 1 peer connection as consumer? or using 1 peer connection as broadcast and also as consumer? maybe my method wrong? or misunderstood the implementation of SFU. any suggestions or solutions?

mamena tech
  • 496
  • 5
  • 16

1 Answers1

0

I am still discovering/learning the stack of webrtc and related architectures, so take what I am saying with a grain of salt.

With a SFU architecture you can have multiple strategies to distribute the streams between your clients. In all case, you save bandwidth for the local user by only sending his streams once to the SFU.

  1. As you state, for n users you can open 1 RTCPeerConnection with the SFU for the local user and n-1 RTCPeerConnection for remote users.

  2. You can open only one RTCPeerConnection with the SFU for any number of users in the "room". To achieve this, when a new user enters the SFU session, his streams need to be added to the tracks of the PeerConnection present at the SFU. It will trigger some renegotiation through signaling, and your users will know a new track (stream) has been added. The client (javascript code for example) needs to identify the new tracks to a specific user, for that you can add the information of this user in the signaling payload. From the point of view of a given user, these new tracks (audio+video) will correspond to a new user.

The first approach is simpler but takes more ressources, more ice candidate to gather, stun request, connections to the SFU, etc.. The second one is more efficient but harder to implements. Both on the client and the server.

A link to bloggeek.me, which provides excellent ressources for webrtc, and talks about these two approaches, far better than me. The post states that Jitsi server, use only one peer connection with the SFU, per user.

  1. Other strategies exist, in livekit server, a SFU implementation in Golang, they use 2 PeerConnection per user. One for publishing the streams of the local user and the second to receive streams from all other users. Here a link to the client protocol of Livekit server

For approach 2 and 3, how SFU servers wire up all these streams correctly between each PeerConnection with a local user, I really don't know. It seems really specific to the project.

You have to check the SFU server API you are using, and see what is possible to do with it. But what you are looking for is definitely possible, given the "right" project for your use case.

For the client side it depends on project your are using too.

If you are in the early stage of your project, you can maybe check livekit server. It is an open source project, Apache 2.0 license, develop in golang, and provides a lot of interesting features out of the box. Auto scaling SFU instances through redis, kubernetes setup, client libraries in JavaScript, Flutter, a server sdk to interact with SFU instances in various langage, etc.. The ecosystem seems really nice and the documentation is good too.

Hope it helps a bit

Loulou BadWeed
  • 146
  • 1
  • 6