Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webRTC - Video conferece multiple rooms

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.

like image 483
Odd Avatar asked Oct 23 '25 03:10

Odd


1 Answers

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})
}
like image 134
Odd Avatar answered Oct 25 '25 17:10

Odd