buffer messages
This commit is contained in:
@@ -10,6 +10,10 @@ import (
|
|||||||
"github.com/livekit/livekit-server/proto/livekit"
|
"github.com/livekit/livekit-server/proto/livekit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
dataBufferSize = 50
|
||||||
|
)
|
||||||
|
|
||||||
// DataTrack wraps a WebRTC DataChannel to satisfy the PublishedTrack interface
|
// DataTrack wraps a WebRTC DataChannel to satisfy the PublishedTrack interface
|
||||||
// it shall forward tracks to all of its subscribers
|
// it shall forward tracks to all of its subscribers
|
||||||
type DataTrack struct {
|
type DataTrack struct {
|
||||||
@@ -30,7 +34,7 @@ func NewDataTrack(participantId string, dc *webrtc.DataChannel) *DataTrack {
|
|||||||
id: utils.NewGuid(utils.TrackPrefix),
|
id: utils.NewGuid(utils.TrackPrefix),
|
||||||
participantId: participantId,
|
participantId: participantId,
|
||||||
dataChannel: dc,
|
dataChannel: dc,
|
||||||
msgChan: make(chan livekit.DataMessage),
|
msgChan: make(chan livekit.DataMessage, dataBufferSize),
|
||||||
lock: sync.RWMutex{},
|
lock: sync.RWMutex{},
|
||||||
subscribers: make(map[string]*DownDataChannel),
|
subscribers: make(map[string]*DownDataChannel),
|
||||||
}
|
}
|
||||||
@@ -110,6 +114,7 @@ func (t *DataTrack) forwardWorker() {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
msg := <-t.msgChan
|
msg := <-t.msgChan
|
||||||
|
|
||||||
if msg.Value == nil {
|
if msg.Value == nil {
|
||||||
// track closed
|
// track closed
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user