From 0586009e0df08110937777ae240f97bce7fd3679 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 5 May 2023 22:38:17 -0700 Subject: [PATCH] Do not send hidden participants after resume (#1689) --- README.md | 5 +++-- pkg/rtc/room.go | 15 ++++++++++++++- pkg/rtc/utils.go | 10 ---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 16fd9dd8b..d6690a9e0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ # LiveKit: Real-time video, audio and data for developers -[LiveKit](https://livekit.io) is an open source project that provides scalable, multi-user conferencing based on WebRTC. It's designed to provide everything you need to build real-time video audio data capabilities in your applications. +[LiveKit](https://livekit.io) is an open source project that provides scalable, multi-user conferencing based on WebRTC. +It's designed to provide everything you need to build real-time video audio data capabilities in your applications. LiveKit's server is written in Go, using the awesome [Pion WebRTC](https://github.com/pion/webrtc) implementation. @@ -41,7 +42,7 @@ https://docs.livekit.io ## Live Demos -- [LiveKit Meet](https://meet.livekit.io) ([source](https://github.com/livekit/meet)) +- [LiveKit Meet](https://meet.livekit.io) ([source](https://github.com/livekit-examples/meet)) - [Spatial Audio](https://spatial-audio-demo.livekit.io/) ([source](https://github.com/livekit-examples/spatial-audio)) - Livestreaming from OBS Studio ([source](https://github.com/livekit-examples/livestream)) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 6d339d83f..0441a56b4 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -412,7 +412,8 @@ func (r *Room) ResumeParticipant(p types.LocalParticipant, requestSource routing return err } - updates := ToProtoParticipants(r.GetParticipants()) + // include the local participant's info as well, since metadata could have been changed + updates := r.getOtherParticipantInfo("") if err := p.SendParticipantUpdate(updates); err != nil { return err } @@ -730,6 +731,18 @@ func (r *Room) SimulateScenario(participant types.LocalParticipant, simulateScen return nil } +func (r *Room) getOtherParticipantInfo(identity livekit.ParticipantIdentity) []*livekit.ParticipantInfo { + participants := r.GetParticipants() + pi := make([]*livekit.ParticipantInfo, 0, len(participants)) + for _, p := range participants { + if !p.Hidden() && p.Identity() != identity { + pi = append(pi, p.ToProto()) + } + } + + return pi +} + // checks if participant should be autosubscribed to new tracks, assumes lock is already acquired func (r *Room) autoSubscribe(participant types.LocalParticipant) bool { opts := r.participantOpts[participant.Identity()] diff --git a/pkg/rtc/utils.go b/pkg/rtc/utils.go index 95db5606d..0b49d02af 100644 --- a/pkg/rtc/utils.go +++ b/pkg/rtc/utils.go @@ -10,8 +10,6 @@ import ( "github.com/livekit/protocol/livekit" "github.com/livekit/protocol/logger" - - "github.com/livekit/livekit-server/pkg/rtc/types" ) const ( @@ -45,14 +43,6 @@ func UnpackDataTrackLabel(packed string) (participantID livekit.ParticipantID, t return } -func ToProtoParticipants(participants []types.LocalParticipant) []*livekit.ParticipantInfo { - infos := make([]*livekit.ParticipantInfo, 0, len(participants)) - for _, op := range participants { - infos = append(infos, op.ToProto()) - } - return infos -} - func ToProtoSessionDescription(sd webrtc.SessionDescription) *livekit.SessionDescription { return &livekit.SessionDescription{ Type: sd.Type.String(),