3

I'm using Pion SFU-WS, basically a golang based webRTC application Pion- SFU.

Although things work like a charm, I'm clueless about how to run multiple conferences (like we know from Microsoft Teams or Zoom). Here is an example of what I'm trying to do:

Room 1: https://localhost:7676/?room-id=12345

Participants of room 1 = A, B, C, D

Room 2: https://localhost:7676/?room-id=67890

Participants of room 2 = E, F, G, H

I can imagine that a static session-id must be passed to

peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})

However, all my efforts/approaches have failed.

Any help would be immensely appreciated.

Odd
  • 563
  • 8
  • 20
  • 1
    check this, may give u some idea. its multiple stream broadcast & consumer https://github.com/Mamena2020/WebRTCBroadCast – mamena tech Nov 02 '22 at 01:26
  • Although my question is specific to Pion, I still like the research and the related links you've added to your repository, thanks. – Odd Nov 02 '22 at 11:54
  • I've implemented the room system, starting point from that code, you can use star topology with SFU method. i use flutter for the app. node for backend media server – mamena tech Nov 06 '22 at 03:20

1 Answers1

2

After some debugging, I have come up with the following "solution". Though I can now isolate peers to a particular room, I'm not sure if this is the correct way of handling multiple rooms with webRTC.

Hence, I'm not accepting the answer yet. In particular, I'm hoping that one of the Pion experts would comment on the performance issues with this approach.

The idea is to bind the list of peer connections to a specific room id:

// make list of peer connections globally accessable
// example: peerconnections[1234][..]peerConnectionState{peerConnection, c}
var peerConnections map[string][]peerConnectionState

// Create new PeerConnection
// peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
peerConnection, err := webrtc.NewPeerConnection(peerConnectionConfig)


// the list of connections
// initialize connections list
if peerConnections == nil {
    peerConnections = make(map[string][]peerConnectionState, 0)
}

// push peer connection to the list of peer connections of a specific room
if peerConnections[roomId] == nil {
    peerConnections[roomId] = []peerConnectionState{peerConnectionState{peerConnection, c}}
}else{
    peerConnections[roomId] = append(peerConnections[roomId], peerConnectionState{peerConnection, c})
}
Odd
  • 563
  • 8
  • 20
  • This looks exactly right to me! Pion WebRTC has no concept of rooms, it just creates a 1:1 connection between peers. – Sean DuBois Nov 29 '21 at 16:24
  • 1
    It means a lot when experts like Sean DuBois agree with a method. Cheers and long live opensource – Odd Nov 29 '21 at 19:04