Unlabeled (pass through) data channels. (#3567)
* Unlabeled (pass through) data channels. Support data channels than can pass through raw data without any LK protocol marshaling/unmarshaling. * statischeck * test * error -> warn * reset data message callback
This commit is contained in:
+24
-2
@@ -484,6 +484,7 @@ func (r *Room) Join(participant types.LocalParticipant, requestSource routing.Me
|
||||
participant.OnTrackUnpublished(r.onTrackUnpublished)
|
||||
participant.OnParticipantUpdate(r.onParticipantUpdate)
|
||||
participant.OnDataPacket(r.onDataPacket)
|
||||
participant.OnDataMessage(r.onDataMessage)
|
||||
participant.OnMetrics(r.onMetrics)
|
||||
participant.OnSubscribeStatusChanged(func(publisherID livekit.ParticipantID, subscribed bool) {
|
||||
if subscribed {
|
||||
@@ -731,6 +732,7 @@ func (r *Room) RemoveParticipant(identity livekit.ParticipantIdentity, pID livek
|
||||
p.OnStateChange(nil)
|
||||
p.OnParticipantUpdate(nil)
|
||||
p.OnDataPacket(nil)
|
||||
p.OnDataMessage(nil)
|
||||
p.OnMetrics(nil)
|
||||
p.OnSubscribeStatusChanged(nil)
|
||||
|
||||
@@ -1285,6 +1287,10 @@ func (r *Room) onDataPacket(source types.LocalParticipant, kind livekit.DataPack
|
||||
BroadcastDataPacketForRoom(r, source, kind, dp, r.Logger)
|
||||
}
|
||||
|
||||
func (r *Room) onDataMessage(source types.LocalParticipant, data []byte) {
|
||||
BroadcastDataMessageForRoom(r, source, data, r.Logger)
|
||||
}
|
||||
|
||||
func (r *Room) onMetrics(source types.Participant, dp *livekit.DataPacket) {
|
||||
BroadcastMetricsForRoom(r, source, dp, r.Logger)
|
||||
}
|
||||
@@ -1760,7 +1766,13 @@ func (r *Room) IsDataMessageUserPacketDuplicate(up *livekit.UserPacket) bool {
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
func BroadcastDataPacketForRoom(r types.Room, source types.LocalParticipant, kind livekit.DataPacket_Kind, dp *livekit.DataPacket, logger logger.Logger) {
|
||||
func BroadcastDataPacketForRoom(
|
||||
r types.Room,
|
||||
source types.LocalParticipant,
|
||||
kind livekit.DataPacket_Kind,
|
||||
dp *livekit.DataPacket,
|
||||
logger logger.Logger,
|
||||
) {
|
||||
dp.Kind = kind // backward compatibility
|
||||
dest := dp.GetUser().GetDestinationSids()
|
||||
if u := dp.GetUser(); u != nil {
|
||||
@@ -1813,7 +1825,17 @@ func BroadcastDataPacketForRoom(r types.Room, source types.LocalParticipant, kin
|
||||
}
|
||||
|
||||
utils.ParallelExec(destParticipants, dataForwardLoadBalanceThreshold, 1, func(op types.LocalParticipant) {
|
||||
op.SendDataPacket(kind, dpData)
|
||||
op.SendDataMessage(kind, dpData)
|
||||
})
|
||||
}
|
||||
|
||||
func BroadcastDataMessageForRoom(r types.Room, source types.LocalParticipant, data []byte, logger logger.Logger) {
|
||||
utils.ParallelExec(r.GetLocalParticipants(), dataForwardLoadBalanceThreshold, 1, func(op types.LocalParticipant) {
|
||||
if source != nil && op.ID() == source.ID() {
|
||||
return
|
||||
}
|
||||
|
||||
op.SendDataMessageUnlabeled(data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user