英文:
webRTC - Video conferece multiple rooms
问题
我正在使用Pion SFU-WS,它是一个基于Go语言的WebRTC应用程序Pion-SFU。
虽然一切都很顺利,但我对如何运行多个会议(就像我们在Microsoft Teams或Zoom中所知道的那样)一无所知。以下是我尝试做的一个示例:
房间1:
https://localhost:7676/?room-id=12345
房间1的参与者:A、B、C、D
房间2:
https://localhost:7676/?room-id=67890
房间2的参与者:E、F、G、H
我可以想象,必须传递一个“静态会话ID”给
peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
然而,我所有的努力/方法都失败了。
非常感谢任何帮助。
英文:
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.
答案1
得分: 2
经过一些调试,我提出了以下的“解决方案”。虽然我现在可以将对等方隔离到特定的房间,但我不确定这是否是处理使用webRTC的多个房间的正确方式。
因此,我还没有接受这个答案。特别是,我希望Pion的专家之一能够就这种方法的性能问题发表评论。
这个想法是将对等连接的列表绑定到特定的房间ID上:
// 使对等连接列表全局可访问
// 示例:peerconnections[1234][..]peerConnectionState{peerConnection, c}
var peerConnections map[string][]peerConnectionState
// 创建新的PeerConnection
// peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
peerConnection, err := webrtc.NewPeerConnection(peerConnectionConfig)
// 连接列表
// 初始化连接列表
if peerConnections == nil {
peerConnections = make(map[string][]peerConnectionState, 0)
}
// 将对等连接推送到特定房间的对等连接列表中
if peerConnections[roomId] == nil {
peerConnections[roomId] = []peerConnectionState{peerConnectionState{peerConnection, c}}
} else {
peerConnections[roomId] = append(peerConnections[roomId], peerConnectionState{peerConnection, c})
}
英文:
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})
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论