我正在使用 Pion SFU-WS,基本上是一个基于 golang 的 webRTC 应用程序 Pion- SFU .
虽然一切都很顺利,但我对如何召开多个 session 一无所知(就像我们从 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
我可以想象必须将一个static session-id
传递给
peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
然而,我所有的努力/方法都失败了。
如有任何帮助,我们将不胜感激。
最佳答案
经过一些调试,我想出了以下“解决方案”。虽然我现在可以将同行隔离到一个特定的房间,但我不确定这是否是使用 webRTC 处理多个房间的正确方法。
因此,我还没有接受这个答案。特别是,我希望其中一位 Pion 专家能够对这种方法的性能问题发表评论。
想法是将对等连接列表绑定(bind)到特定房间 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})
}
关于javascript - webRTC - 多房间视频 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70098206/