switch participant callbacks to room to listener interface (#4136)
* switch participant callbacks to room to listener interface * mage generate * clean up * clear listener * clean up * use interface in up data track manager * tweaks * Paul feedback - should reduce the diff as this keeps the room handlers as is except making methods for a couple of anonymous handlers * clean up
This commit is contained in:
@@ -16,25 +16,12 @@ package rtc
|
||||
|
||||
import (
|
||||
"github.com/livekit/livekit-server/pkg/rtc/datatrack"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/livekit/protocol/utils"
|
||||
"github.com/livekit/protocol/utils/guid"
|
||||
)
|
||||
|
||||
func (p *ParticipantImpl) OnUpdateDataSubscriptions(callback func(types.LocalParticipant, *livekit.UpdateDataSubscription)) {
|
||||
p.lock.Lock()
|
||||
p.onUpdateDataSubscriptions = callback
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) getOnUpdateDataSubscriptions() func(types.LocalParticipant, *livekit.UpdateDataSubscription) {
|
||||
p.lock.RLock()
|
||||
defer p.lock.RUnlock()
|
||||
return p.onUpdateDataSubscriptions
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishDataTrackRequest) {
|
||||
if !p.CanPublishData() || !p.params.EnableDataTracks {
|
||||
p.pubLogger.Warnw("no permission to publish data track", nil, "req", logger.Proto(req))
|
||||
@@ -138,9 +125,7 @@ func (p *ParticipantImpl) HandleUnpublishDataTrackRequest(req *livekit.Unpublish
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) HandleUpdateDataSubscription(req *livekit.UpdateDataSubscription) {
|
||||
if onUpdateDataSubscriptions := p.getOnUpdateDataSubscriptions(); onUpdateDataSubscriptions != nil {
|
||||
onUpdateDataSubscriptions(p, req)
|
||||
}
|
||||
p.listener().OnUpdateDataSubscriptions(p, req)
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) onReceivedDataTrackMessage(data []byte) {
|
||||
@@ -152,7 +137,5 @@ func (p *ParticipantImpl) onReceivedDataTrackMessage(data []byte) {
|
||||
|
||||
p.UpDataTrackManager.HandleReceivedDataTrackMessage(data, &packet)
|
||||
|
||||
if onDataTrackMessage := p.getOnDataTrackMessage(); onDataTrackMessage != nil {
|
||||
onDataTrackMessage(p, data, &packet)
|
||||
}
|
||||
p.listener().OnDataTrackMessage(p, data, &packet)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user