From 4c1047d8c3b52f9902e4a1f5bfc4776bffcc8a9a Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Thu, 21 Dec 2023 18:52:49 +0530 Subject: [PATCH] Populate simulcast codec layers. (#2334) Previously, it was done on read. Missed populating it on write in the TrackInfo consolidation effort. Fix by populating layers when adding pending track itself. As all codecs will have same layers, clone the top level layers and add it all codecs. --- pkg/rtc/participant.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 6f07849b8..b9c4d4942 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -1670,9 +1670,15 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l continue } seenCodecs[mime] = struct{}{} + + clonedLayers := make([]*livekit.VideoLayer, 0, len(req.Layers)) + for _, l := range req.Layers { + clonedLayers = append(clonedLayers, proto.Clone(l).(*livekit.VideoLayer)) + } ti.Codecs = append(ti.Codecs, &livekit.SimulcastCodecInfo{ MimeType: mime, Cid: codec.Cid, + Layers: clonedLayers, }) }