mirror of
https://github.com/livekit/livekit.git
synced 2026-11-12 20:49:07 +00:00
* sfu: don't count opus useinbandfec=0 as FEC in the down track DownTrack decides whether opus FEC is on by looking for "fec" anywhere in the fmtp line, both on Bind and when the upstream codec changes. "useinbandfec=0" contains "fec", so a publisher that turns FEC off is scored as if FEC were on. The connection quality scorer then lowers the packet loss weight for opus from 8.0 to 5.33, and a subscriber with 8% audio loss is reported as GOOD instead of POOR. The receiver side already checks for useinbandfec=1, so the publisher's and subscribers' scores disagree about the same stream. Add utils.IsOpusInbandFECEnabled, which reads the useinbandfec parameter by key and treats only a value of 1 as on, and use it for all three FEC checks in the down track. The RED path already looked for useinbandfec=1 and only gains tolerance of spaces around the parameter. * sfu: read FEC from the upstream codec when the down track's codec changes handleUpstreamCodecChange took the FEC flag from the codec the subscriber negotiated, while Bind takes it from the upstream codec. FEC describes what the publisher encodes, so after RED falls back to opus, a publisher with useinbandfec=1 and a subscriber with useinbandfec=0 was scored as having no FEC, and the reverse as having FEC. Decide FEC in one place from the upstream codecs, using the upstream opus codec for RED, and use it in both Bind and the codec change path. Log the flag on codec change as Bind already does. * sfu: use the same useinbandfec=1 check as the RED path for FEC Drop utils.IsOpusInbandFECEnabled and check FEC with strings.Contains(strings.ToLower(fmtp), "useinbandfec=1"), as the RED path already did. * sfu: move the FEC check to utils and match useinbandfec with a regex Move the check to utils.IsFECEnabled, as asked in review, and match useinbandfec=1 as one fmtp parameter with a regex, ignoring case and spaces around the parameter and the "=". A publisher that sends "minptime=10; useinbandfec = 1" was scored as having no FEC. Move the tests to utils/helpers_test.go.