Commit Graph

1053 Commits

Author SHA1 Message Date
Raja Subramanian 1b2289137d Support video layer mode from client and make most of the code mime aware (#3843) 2025-08-09 21:26:11 +05:30
Raja Subramanian 40028dc33c Normalize known rids. (#3779)
Normalize the rids in SDP to known patterns.
Currently,
- LK protocol uses q;h;f
- Sean's OBS WHIP uses 0;1;2

As the ordering in SDP could be different, normalize to known order.

For RIDs not in the known set, just use it as is.
2025-07-06 13:32:21 +05:30
Raja Subramanian ddd923296b Return default layer for invalid rid + track info combination. (#3778) 2025-07-05 14:43:26 +05:30
Raja Subramanian c69f1aae87 Revert "Temporary change: use pre-defined rids" (#3769)
* Revert "Temporary change: use pre-defined rids (#3767)"

This reverts commit d11da5f5fa.

* clean up

* add test and simplify

* clean up
2025-06-30 07:34:58 +05:30
Raja Subramanian d11da5f5fa Temporary change: use pre-defined rids (#3767)
To address a compatibility issue across relay. Will revert this once the
compatibility is addressed.
2025-06-29 20:00:21 +05:30
Raja Subramanian ef6c38cee5 Log previous allocation to see changes. (#3759) 2025-06-24 12:51:42 -07:00
Raja Subramanian 01bf96855d SVC with RID -> spatial layer mapping (#3754)
* SVC with RID -> spatial layer mapping

There are cases where an SVC track comes in with a RID.
As there is no RID announced in SDP, it maps to invalid layer.
Seems to happen with older browsers.

* test
2025-06-23 12:45:13 -07:00
cnderrauber 8c2fc0bcd9 Fix svc encoding for chrome mobile on iOS (#3751)
The browser could send rtp packets of svc encoding without
DD extension while the sdp negotiates it, sfu detects extension
in rtp packet for this case.
2025-06-23 22:39:12 +08:00
cnderrauber 7542cf0723 remove unused code (#3740) 2025-06-18 10:09:30 +08:00
Raja Subramanian 0e03390744 Return highest available layer if requested quality is higher than (#3729)
highest available quality.
2025-06-13 08:44:45 -07:00
cnderrauber 1b95e818c9 Don't check bindState on downtrack.Bind (#3726)
receiver can be ready before bind
2025-06-13 16:13:15 +08:00
Raja Subramanian 670f927ff6 Set and use rid/spatial layer in TrackInfo. (#3724)
* Set and use rid/spatial layer in TrackInfo.

* test
2025-06-12 23:22:11 -07:00
Raja Subramanian ce07740e11 Add simulcast support for WHIP. (#3719)
* Add simulcast support for WHIP.

- General change to have rids be anything.
- One issue is rid ordering not matching quality ordering, will need
  some dynamic layer quality determination for that.

* clean up

* deps

* test
2025-06-11 19:40:38 -07:00
Raja Subramanian e0aea17a06 Flush stats on close (#3713) 2025-06-09 09:33:34 -07:00
Paul Wells 630aa7d970 implement observability for room metrics (#3712)
* implement observability for room metrics

* deps

* test

* test

* Raja feedback

* cleanup
2025-06-09 09:32:58 -07:00
Raja Subramanian 758e176250 Add a trend check before declaring joint queuing region. (#3701)
* Add a trend check before declaring joint queuing region.

Seeing cases where the propagated queuing delay drops from one group to
next. Both groups are above threhold. It also recovers majority of the
time. So, introducing a trend check before declaring that queuing delay
is in joint queuing region. It is set 0.8 by default which means the
queueing delay should be trending up strongly before being declared
joint queuing region.

* deps
2025-06-05 18:51:23 -07:00
Raja Subramanian 2df0551762 Revert unbound transceiver stop. (#3661)
This is causing duplicate a=msid in testing. Will chase condition that
caused the addition of code to stop transceiver later.
2025-05-13 16:33:09 +05:30
Raja Subramanian 5172af1526 ~Send initial participant update only after a participant becomes active.~ - General clean up (#3655)
* Send initial participant update only after a participant becomes active.

There are cases where apps send data to remote participant as soon as
client emits `ParticipantConnected`. But, that time point would not have
a fully established client (i. e. the media connection + data channel
establishment is still in progress).

This PR changes the initial participant update to be sent from server
side only when a participant becomes `ACTIVE`, i.e fully connected
(media channel established and data channels open).

It is supported for clients using protocol version > 15.

@cnderrauber bumping up the protocol version in this PR. Move support is
also conditioned on protocol version > 15, but that PR did not ump
protocol version. Please let me know if there are issues bumping
protocol version.

* check for joining states in broadcast

* have to check on other participant

* test

* make helper for sending participant updates

* test

* make utility of pushAndDeque

* test

* consolidate getting other participants

* remove extra cast

* debug

* debug

* typo

* stop transceiver that is not bound

* logs

* log

* check for ever bound

* clean up

* clean up
2025-05-13 14:46:35 +05:30
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