Commit Graph

1035 Commits

Author SHA1 Message Date
Raja Subramanian 086704128c Limit buffer queue before Bind. (#3634)
* Limit buffer queue before Bind.

* more generic
2025-05-01 13:49:06 +05:30
cnderrauber 847239c3f2 Disable vp9 for safari 18.4 (#3631)
* Disable vp9 for safari 18.4

safari 18.4's svc encoding is broken

* more flex on test timeout
2025-04-29 13:17:39 +08:00
Raja Subramanian f24152b4c0 Call Broadcast in lock scope. (#3625)
* Call Broadcast in lock scope.

Seems like there is a possible window where things can hang forever
if a goroutine enters the Wait) after the lock is released but before
Broadcast gets called, it will never see that broadcast and will hang forever.

* RLock
2025-04-25 12:12:10 +05:30
Raja Subramanian 34a2e2c107 Check for multiple layers for managed track. (#3622)
The previous check was checking only for simulcast and would have made a
screen share track published with multiple layers using SVC as
unmanaged.
2025-04-24 10:02:38 +05:30
Anunay Maheshwari 52ce18d56e fix: revert recent changes to determine simulcast from sdp (#3565)
* Revert "Audio uses signal SignalCid and SdpCid. (#3564)"

This reverts commit cdfbb106d1.

* Revert "Keep simulcast information tied to receiver. (#3563)"

This reverts commit ed5e2f16b2.

* Revert "chore(logs): log VLS type for VP9/AV1 (#3561)"

This reverts commit ad010cfc43.

* Revert "fix(video): determine svc/simulcast from SDP for advanced codecs (#3549)"

This reverts commit 15f565510c.

* chore(deps): update protocol
2025-03-31 23:15:44 +05:30
Raja Subramanian ed5e2f16b2 Keep simulcast information tied to receiver. (#3563)
* Keep simulcast information tied to receiver.

`simulcast` flag in `TrackInfo` is at track lavel. With codec simulcast,
the primary codec (in most cases) is SVC and the backup codec is
simulcast. Back up codec publish changing the track info setting to true
meant that the primary receiver was treated as simulcast if a subscriber
for primary codec joined after the backup codec was published.

Keep track of simulcast flag in receiver.

Also, TrackInfo Cids are from signal. So, keep track of SDP cids
separately. The `simulcastTrackIds` map uses SDP cid. Clean up by all
the SDP cids of a track

* clean up

* clean up

* clean up

* clean up

* test

* Store SdpCid and IsSimulcast in Trackinfo

* clean up

* mock
2025-03-31 19:25:57 +05:30
Anunay Maheshwari ad010cfc43 chore(logs): log VLS type for VP9/AV1 (#3561) 2025-03-31 12:11:08 +05:30
Anunay Maheshwari 15f565510c fix(video): determine svc/simulcast from SDP for advanced codecs (#3549)
* fix(video): determine svc/simulcast from SDP for advanced codecs

* fix(explicit-svc): cleanup

* fix(explicit-svc): remove from list on close/remove

* fix(explicit-svc): reorder VLS selection, cleanup

* fix(explicit-svc): todo comments for temporal layer selector

* fix(explicit-svc): remove from simulcastTrackIds even if client does not support unpublish
2025-03-26 16:22:32 +05:30
Raja Subramanian b0abb0ae6e Add option to use different pacer with send side bwe. (#3552)
Seeing a lot of queuing delay based back offs. Trying a couple of things
1. Accept a bit more queuing.
2. An option to try a different pacer. Would like to try with pass
   through. That will produce some out-of-order packets. Remains to be
   seen if it will have a negative impact.
2025-03-25 12:57:42 +05:30
cnderrauber e118aff125 Fire track subscribed when the subscriber connected (#3540) 2025-03-20 17:47:21 +08:00
Raja Subramanian 8eb81388e6 Use a generation to counter to stop key frame seeder on codec change (#3531) 2025-03-18 07:41:30 +05:30
Raja Subramanian 507fc9cf76 Do not instantiate 0 sized sequencer. (#3529)
This happens due to improper track type.

One possible option is to check the mime type of the track and calculate
the size, but there are other places in the code which work off provided
track type. So, just doing a defensive fix. Have to review code for all
uses of type and how it affects things if client provides incorrect
type.
2025-03-17 10:31:32 +05:30
Raja Subramanian a6cb00b31e Reduce seeder duration to 30s and also do not force send PLI. (#3525)
Can use the normal PLI throttle cadence.
2025-03-13 10:41:42 +05:30
Raja Subramanian c823320528 Add a key frame seeder in up track. (#3524) 2025-03-12 22:11:27 +05:30
Raja Subramanian 50ab47c11b Log packet drops/forward. (#3510)
Seeing an error in an e2e test, after migration, no packets are
forwarded. The only reason seems to be payload type mismatch (assuming
there are no errors in the forwarding loop pulling packets from buffer).

So, logging some packet stats in forwarding loop.
2025-03-10 16:36:25 +05:30
Raja Subramanian 6c04909f88 Use atomic to store codec. (#3505)
* Use atomic to store codec.

It can change on up stream codec change, but not seeing any racy
behaviour with atomic access.

Reverting the previous change to mute with this change.

* no mime arg
2025-03-09 11:51:48 +05:30
Raja Subramanian 7f6afe05ad Prevent bind lock deadlock on muted. (#3504)
Need to re-visit the bind lock scope and maybe make the codec/mime
atomic and access them without bind lock. But, doing a whack-a-mole a
bit first to move things forward. Will look at making them atomics.
2025-03-09 11:21:09 +05:30
Paul Wells 48063df5b8 load mime type before calling writeBlankFrameRTP (#3502) 2025-03-07 23:12:20 -08:00
Raja Subramanian d2e6cd150e Do not bind lock across flush which could take time (#3501) 2025-03-08 11:13:35 +05:30
NinaLua c2f17a1072 refactor: using slices.Contains to simplify the code (#3495)
Signed-off-by: NinaLua <iturf@sina.cn>
2025-03-07 14:08:47 +05:30
cnderrauber ff9115b228 Disable dd parser for vp8 if extension is not found (#3492)
Browser would not send dd extension for vp8 in some case even if
it is negotiated.
2025-03-06 17:20:00 +08:00
Raja Subramanian f0edfbba8d Fix receiver rtt/jitter. (#3487) 2025-03-04 21:22:17 +05:30
Raja Subramanian 05dfd30d5b Take RTT and jitter from receiver view while reporting track stats for (#3483)
* Take RTT and jitter from receiver view while reporting track stats for
down stream tracks.

* adjust jitter in aggregate
2025-03-03 18:48:37 +05:30
Raja Subramanian 1cffe30cd0 Use a RED transformer to consolidate both RED -> Opus OR Opus -> RED (#3481)
* Use a RED transformer to consolidate both RED -> Opus OR Opus -> RED

* public

* clean up

* clean up debug
2025-03-02 13:29:56 +05:30
Raja Subramanian 591888f712 Fix missing RTCP sender report when forwarding RED as Opus. (#3480)
With publish RED and subscribe Opus, the RTCP sender reports were not
sent to down track as publisher sender reports were not forwarded to the
down track.
2025-03-02 11:52:17 +05:30
Raja Subramanian 83a839811c Transfer metadata cache over flow counter. (#3472)
* Transfer metadata cache over flow coutner.

Without that, logging was not getting sampled.

* sender
2025-02-27 11:21:11 +05:30
Raja Subramanian 6d44e433f4 Fix panic with invalid layer. (#3470)
* Fix panic with invalid layer.

Log an error so that we can understand which track porduces that.

* drop bad layer packet without forwarding
2025-02-27 09:48:13 +05:30
Raja Subramanian fcb05e97c5 Properly initialise DD layer selector. (#3467) 2025-02-26 09:48:54 +05:30
Paul Wells 43bd251575 simplify vls base access (#3465) 2025-02-26 09:34:59 +05:30
Raja Subramanian 7350e99331 transfer from non-null for codec change (#3464) 2025-02-25 23:31:14 +05:30
Raja Subramanian ca4526048c structured logging (#3461) 2025-02-24 11:47:35 +05:30
cnderrauber 4b04b26a73 fix data channel slow reader test (#3453) 2025-02-20 10:40:25 +08:00
cnderrauber b2a54729f5 Don't drop message if calculate duration is too small (#3442)
* Don't drop message if calculate duration is too small

* fix test
2025-02-18 14:41:41 +08:00
Raja Subramanian b3da3ff2cb Give more cache for RTX. (#3438)
- With probing the packet rate can get high suddenly and remote may not
  have sent receiver report as it might be sending for the non-spikey
  rate. That causes metadata cache overflows. So, give RTX more cahe.
- Don't need a large cache for primary as either reports come in
  regularly (or they are missing for a long time and having a biger
  cache is not the solution for that, so reduce primary cache size)
- Check for receiver report falling exactly back by (1 << 16). Had done
  that change in the inside for loop, but missed the top level check :-(
2025-02-15 22:43:28 +05:30
Raja Subramanian 0c966e6a7e Move a few logs to Debugw (#3437) 2025-02-15 22:16:17 +05:30
Raja Subramanian 9fd80c8919 Catch up if the diff is exactly (1 << 16) also. (#3433) 2025-02-14 12:50:52 +05:30
cnderrauber 7e4df818ee Fix timing issue between track republish (#3428) 2025-02-13 13:59:03 +08:00
Raja Subramanian f160f6200a Do not log no packets in delta. (#3427)
Can happen a lot with dynacast layer turn off.
2025-02-13 11:25:57 +05:30
Raja Subramanian 1c3c70a136 Check for nil in sender view stats. (#3426)
Seeing some panic due to sender view being nil. It is possible to have
nil sender view and not-nil receiver view. For analytics, only sender
view is used. Handle nil properly.
2025-02-13 10:55:23 +05:30
Raja Subramanian 7fef374b19 Split down stream snapshot into sender view and receiver view. (#3422)
Receiver view is used for connection quality.

Sender view is used for analytics. One thing that this introduces is
that sender view uses the packet loss information from receiver view as
true loss is available only in the RTCP Receiver Reports received from
the remote side. So, the time alignment is off, i. e. receiver report
happens periodically and it includes information till the time at which
it was sent from remote side, but sender could have sent more packets
after that time.

The split should ensure that analytics does not rely on remote side
sending proper receiver repoerts albeit at slight misalignment of loss
statistic for remotes that send RTCP RR (which should be majority of the
cases)
2025-02-11 16:05:00 +05:30
Raja Subramanian 5e1431f433 Do not use separate struct field for mime. (#3421) 2025-02-11 12:08:02 +05:30
cnderrauber 4b709d3d88 Fix codec match in downtrack (#3420) 2025-02-11 11:45:22 +08:00
Raja Subramanian 65d30d9e43 Ignore unknown mime in dynacast manager. (#3419)
Actually, was caused by down track not initialising mime, but it is good
to ignore unknown mime.

Also, added ulpfec sa SDP has that and there was a conversion which was
returning unknown. Also, note that the mime types use audio for RED and
video for flexfec and ulpfec although they are not media type dependent.
Maybe, at point need to introduce `MimeTypeAudioRED` and
`MimeTypeVideoRED`.
2025-02-10 14:56:52 +05:30
Raja Subramanian 9551c52c85 Try 2 to consolidate mime type (#3407)
* Normalize mime type and add utilities.

An attempt to normalize mime type and avoid string compares remembering
to do case insensitive search.

Not the best solution. Open to ideas. But, define our own mime types
(just in case Pion changes things and Pion also does not have red mime
type defined which should be easy to add though) and tried to use it everywhere.
But, as we get a bunch of callbacks and info from Pion, needed conversion in
more places than I anticipated. And also makes it necessary to carry
that cognitive load of what comes from Pion and needing to process it
properly.

* more locations

* test

* Paul feedback

* MimeType type

* more consolidation

* Remove unused

* test

* test

* mime type as int

* use string method

* Pass error details and timeouts. (#3402)

* go mod tidy (#3408)

* Rename CHANGELOG to CHANGELOG.md (#3391)

Enables markdown features in this otherwise already markdown'ish formatted document

* Update config.go to properly process bool env vars (#3382)

Fixes issue https://github.com/livekit/livekit/issues/3381

* fix(deps): update go deps (#3341)

Generated by renovateBot

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Use a Twirp server hook to send API call details to telemetry. (#3401)

* Use a Twirp server hook to send API call details to telemetry.

* mage generate and clean up

* Add project_id

* deps

* - Redact requests
- Do not store responses
- Extract top level fields room_name, room_id, participant_identity,
  participant_id, track_id as appropriate
- Store status as int

* deps

* Update pkg/sfu/mime/mimetype.go

* Fix prefer codec test

* handle down track mime changes

---------

Co-authored-by: Denys Smirnov <dennwc@pm.me>
Co-authored-by: Philzen <Philzen@users.noreply.github.com>
Co-authored-by: Pablo Fuente Pérez <pablofuenteperez@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Paul Wells <paulwe@gmail.com>
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2025-02-10 10:44:15 +05:30
cnderrauber aeec75edeb H265 supoort and codec regression (#3358)
* H265 supoort and codec regression

Support H265 codec.
Add optional codec regression for subscribers don't
support advanced codecs like H265, AV1, VP9.

* restart forwarder on upstream codec change

* tests

* Reneogitate new codec if client doesn't support change

* Add option to disable codec regression

---------

Co-authored-by: boks1971 <raja.gobi@tutanota.com>
2025-02-06 11:56:49 +08:00
Raja Subramanian 7ff4082e4a Do not skip due to large RR interval. (#3398)
* Do not skip due to large RR interval.

With sequence number adjustment, it will report some packets missing
which is fine.

* do not seed if already initialized
2025-02-04 11:08:38 +05:30
Raja Subramanian f45e3613ac Correct reason for poor/lost score. (#3397)
No functional change, just logging reason was confusing.
Also, log no packets case. Seeing some instances in staging where there
are periods of no packets received. Trying to understand better.
2025-02-04 00:59:56 +05:30
Raja Subramanian 2f758d49ce Adjust receiver report sequence number to be within range of highest. (#3396) 2025-02-03 21:58:26 +05:30
Raja Subramanian 91728fa59b More defensive checks for mime. (#3394) 2025-02-03 12:07:12 +05:30
Raja Subramanian 92e3f2e3d0 Starting on padding for RTX stream is accepted. (#3390) 2025-02-02 20:26:30 +05:30