From 0b91f43a3ff05d3be770dfa65c2a832288f43496 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sat, 14 Oct 2023 22:35:17 +0800 Subject: [PATCH] updates --- pkg/rtc/room.go | 42 ------------------------------------------ pkg/rtc/utils.go | 32 ++++++++++---------------------- 2 files changed, 10 insertions(+), 64 deletions(-) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 039bf4609..72e24d15c 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -288,17 +288,6 @@ func (r *Room) Join(participant types.LocalParticipant, requestSource routing.Me return ErrMaxParticipantsExceeded } } - if r.protoRoom.AppMode == livekit.AppMode_AM_LIVESTREAM && participant.IsPublisher() { - numPublishers := 0 - for _, p := range r.participants { - if p.CanPublish() { - numPublishers++ - } - } - if numPublishers >= LiveStreamPublisherLimit { - return ErrMaxPublishersExceeded - } - } if r.FirstJoinedAt() == 0 { r.joinedAt.Store(time.Now().Unix()) @@ -1024,37 +1013,6 @@ func (r *Room) sendParticipantUpdates(updates []*livekit.ParticipantInfo) { return } - if r.protoRoom.AppMode == livekit.AppMode_AM_LIVESTREAM { - otherUpdates := make([]*livekit.ParticipantInfo, 0, len(updates)) - publisherUpdates := make([]*livekit.ParticipantInfo, 0, len(updates)) - for _, u := range updates { - if u.Permission.CanPublish { - publisherUpdates = append(publisherUpdates, u) - } else { - otherUpdates = append(otherUpdates, u) - } - } - - if len(otherUpdates) > 0 { - // non-publishers are only sent to admins - for _, op := range r.GetParticipants() { - if op.IsAdmin() { - err := op.SendParticipantUpdate(otherUpdates) - if err != nil { - r.Logger.Errorw("could not send update to participant", err, - "participant", op.Identity(), "pID", op.ID()) - } - } - } - } - - if len(publisherUpdates) == 0 { - return - } - - updates = publisherUpdates - } - for _, op := range r.GetParticipants() { err := op.SendParticipantUpdate(updates) if err != nil { diff --git a/pkg/rtc/utils.go b/pkg/rtc/utils.go index 2652112f7..77568a938 100644 --- a/pkg/rtc/utils.go +++ b/pkg/rtc/utils.go @@ -198,6 +198,9 @@ func LoggerWithCodecMime(l logger.Logger, mime string) logger.Logger { } func UpdateRoomFromRequest(rm *livekit.Room, internal *livekit.RoomInternal, req *livekit.CreateRoomRequest) *livekit.RoomInternal { + if internal == nil { + internal = &livekit.RoomInternal{} + } if req.EmptyTimeout > 0 { rm.EmptyTimeout = req.EmptyTimeout } @@ -208,32 +211,17 @@ func UpdateRoomFromRequest(rm *livekit.Room, internal *livekit.RoomInternal, req rm.Metadata = req.Metadata } if req.Egress != nil && req.Egress.Tracks != nil { - internal = &livekit.RoomInternal{TrackEgress: req.Egress.Tracks} + internal.TrackEgress = req.Egress.Tracks } - if req.AppMode != nil { - rm.AppMode = *req.AppMode - if rm.AppMode == livekit.AppMode_AM_LIVESTREAM { - rm.PlayoutDelay = &livekit.PlayoutDelay{ - Enabled: true, - // 150ms by default in livestream mode - Min: 150, - } - } - } - if rm.AppMode == livekit.AppMode_AM_DEFAULT { - if rm.MaxParticipants == 0 || rm.MaxParticipants > 3000 { - rm.MaxParticipants = 3000 - } - } - if req.MinPlayoutDelay > 0 { - rm.PlayoutDelay = &livekit.PlayoutDelay{ + if req.MinPlayoutDelay > 0 || req.MaxPlayoutDelay > 0 { + internal.PlayoutDelay = &livekit.PlayoutDelay{ Enabled: true, Min: req.MinPlayoutDelay, + Max: req.MaxPlayoutDelay, } - } else { - rm.PlayoutDelay = &livekit.PlayoutDelay{ - Enabled: false, - } + } + if req.SyncStreams { + internal.SyncStreams = true } if len(req.EnabledCodecs) > 0 { rm.EnabledCodecs = req.EnabledCodecs