Fix potential ssrc collision between participants (#1173)
This commit is contained in:
+3
-3
@@ -51,7 +51,7 @@ type Room struct {
|
|||||||
// map of identity -> Participant
|
// map of identity -> Participant
|
||||||
participants map[livekit.ParticipantIdentity]types.LocalParticipant
|
participants map[livekit.ParticipantIdentity]types.LocalParticipant
|
||||||
participantOpts map[livekit.ParticipantIdentity]*ParticipantOptions
|
participantOpts map[livekit.ParticipantIdentity]*ParticipantOptions
|
||||||
bufferFactory *buffer.Factory
|
bufferFactory *buffer.FactoryOfBufferFactory
|
||||||
|
|
||||||
// batch update participant info for non-publishers
|
// batch update participant info for non-publishers
|
||||||
batchedUpdates map[livekit.ParticipantIdentity]*livekit.ParticipantInfo
|
batchedUpdates map[livekit.ParticipantIdentity]*livekit.ParticipantInfo
|
||||||
@@ -93,7 +93,7 @@ func NewRoom(
|
|||||||
serverInfo: serverInfo,
|
serverInfo: serverInfo,
|
||||||
participants: make(map[livekit.ParticipantIdentity]types.LocalParticipant),
|
participants: make(map[livekit.ParticipantIdentity]types.LocalParticipant),
|
||||||
participantOpts: make(map[livekit.ParticipantIdentity]*ParticipantOptions),
|
participantOpts: make(map[livekit.ParticipantIdentity]*ParticipantOptions),
|
||||||
bufferFactory: buffer.NewBufferFactory(config.Receiver.PacketBufferSize),
|
bufferFactory: buffer.NewFactoryOfBufferFactory(config.Receiver.PacketBufferSize),
|
||||||
batchedUpdates: make(map[livekit.ParticipantIdentity]*livekit.ParticipantInfo),
|
batchedUpdates: make(map[livekit.ParticipantIdentity]*livekit.ParticipantInfo),
|
||||||
closed: make(chan struct{}),
|
closed: make(chan struct{}),
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ func (r *Room) GetActiveSpeakers() []*livekit.SpeakerInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Room) GetBufferFactory() *buffer.Factory {
|
func (r *Room) GetBufferFactory() *buffer.Factory {
|
||||||
return r.bufferFactory
|
return r.bufferFactory.CreateBufferFactory()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Room) FirstJoinedAt() int64 {
|
func (r *Room) FirstJoinedAt() int64 {
|
||||||
|
|||||||
@@ -9,16 +9,13 @@ import (
|
|||||||
"github.com/livekit/mediatransportutil/pkg/bucket"
|
"github.com/livekit/mediatransportutil/pkg/bucket"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Factory struct {
|
type FactoryOfBufferFactory struct {
|
||||||
sync.RWMutex
|
videoPool *sync.Pool
|
||||||
videoPool *sync.Pool
|
audioPool *sync.Pool
|
||||||
audioPool *sync.Pool
|
|
||||||
rtpBuffers map[uint32]*Buffer
|
|
||||||
rtcpReaders map[uint32]*RTCPReader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBufferFactory(trackingPackets int) *Factory {
|
func NewFactoryOfBufferFactory(trackingPackets int) *FactoryOfBufferFactory {
|
||||||
return &Factory{
|
return &FactoryOfBufferFactory{
|
||||||
videoPool: &sync.Pool{
|
videoPool: &sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
b := make([]byte, trackingPackets*bucket.MaxPktSize)
|
b := make([]byte, trackingPackets*bucket.MaxPktSize)
|
||||||
@@ -31,11 +28,26 @@ func NewBufferFactory(trackingPackets int) *Factory {
|
|||||||
return &b
|
return &b
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FactoryOfBufferFactory) CreateBufferFactory() *Factory {
|
||||||
|
return &Factory{
|
||||||
|
videoPool: f.videoPool,
|
||||||
|
audioPool: f.audioPool,
|
||||||
rtpBuffers: make(map[uint32]*Buffer),
|
rtpBuffers: make(map[uint32]*Buffer),
|
||||||
rtcpReaders: make(map[uint32]*RTCPReader),
|
rtcpReaders: make(map[uint32]*RTCPReader),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Factory struct {
|
||||||
|
sync.RWMutex
|
||||||
|
videoPool *sync.Pool
|
||||||
|
audioPool *sync.Pool
|
||||||
|
rtpBuffers map[uint32]*Buffer
|
||||||
|
rtcpReaders map[uint32]*RTCPReader
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Factory) GetOrNew(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser {
|
func (f *Factory) GetOrNew(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser {
|
||||||
f.Lock()
|
f.Lock()
|
||||||
defer f.Unlock()
|
defer f.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user