Commit Graph

84 Commits

Author SHA1 Message Date
Raja Subramanian
bfba6feed4 Adjust stream allocator ping interval based on state. (#3951)
* Adjust stream allocator ping interval based on state.

In steady state, does a 15 second ping.
While deficient, to be able to react to probes faster, it pings at 100ms
interval.

* clean up

* log ops queue not able to wake up
2025-09-24 14:45:57 +05:30
Raja Subramanian
f7291fdaa8 Do not send both asb-send-time and twcc. (#3890)
* Do not send both asb-send-time and twcc.

In single peer connection mode, both extensions are set on the media
engine and both would be negotiated. Unfortunately, pion/webrtc does
not yet support RTPSender.SetParameters() which would allow setting
specific header extensions for the sender. So, check for TWCC enabled
and use it. If not, do abs-send-time if that is enabled.

* check BWE type

* comment
2025-08-30 19:22:14 +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
Raja Subramanian
0c966e6a7e Move a few logs to Debugw (#3437) 2025-02-15 22:16:17 +05:30
Raja Subramanian
0d9bad489c Remove duplicate SSRC get. (#3318)
The duplicate was not checking for `nil`. The SSRC is already loaded
with proper nil check before.
2025-01-08 22:50:34 +05:30
Raja Subramanian
0dde347615 Use contiguous groups to determine queuing region. (#3308) 2025-01-07 04:00:39 +05:30
Raja Subramanian
238333985b BWE reset for probing. (#3295) 2024-12-31 23:22:47 +05:30
Raja Subramanian
6e9964e80b TWCC tweaks (#3282)
* SSBWE experimentation

* dqr hysteresis

* fixes

* fmt

* more relaxed DQR

* pps proportional to duration

* clean up

* clean up

* don't need gratuitous up allocation
2024-12-21 23:08:38 +05:30
Raja Subramanian
b6e99e249b Better naming/logging for send side bwe (#3264)
* Better naming/logging for send side bwe

* Check BWE congestion state before doing optimal allocation.

It is possible that BWE declares congestion, but the estimated bandwidth
may still be enough to accommodate all tracks. So, stream allocator
would still not in DEFICIENT state. On a new track allocation, it will
get optimal allocation although BWE is in congested state.

Take BWE congestion state into consideration before doing any track
allocation.

* get congestion state from BWE rather than caching it in stream allocator

* get states from update

* log contributing groups only when they are small in number

* get oldest group always

* notify only when estimate is dropping

* require stronger CTR down trend

* maintain min/max group

* relax thresholds to declare congestion a bit
2024-12-18 21:38:13 +05:30
Raja Subramanian
b3efdfcfe5 Up allocate to available headroom. (#3259)
There are cases where the probe result has enough headroom to up
allocate all deficient tracks. Mainly happens after a loss scenario
where the estimate is actually still high.

After boosting once, there was a check for the track to hit the desired
layer before boosting again. But, that is not really necessary. Can
boost target and forwarder should resolve to the latest target.
Removing that check in the forwarder.

Also, adding a gratuitous boost check in stream allocator periodic ping
when deficient to look for opportunities to boost.
2024-12-17 10:49:14 +05:30
Raja Subramanian
192ecbfc88 Dampen oscillations in loss based congestion detection when using TWCC. (#3256)
* Rework congestion detection state machine

* WIP

* fmt

* clean up

* revert config
2024-12-16 15:26:23 +05:30
Raja Subramanian
699cd9c26c BWE minor tweaks (#3254)
- Clear probe id in downtracks when aborting probe
- a bit of clean up
2024-12-16 08:04:24 +05:30
Raja Subramanian
be65d24333 Add method to check for probe goal reached (#3253)
* Check for early probe end

* use old packets for probing

* fmt
2024-12-15 23:34:07 +05:30
Raja Subramanian
8cfea87ad0 Use RTX channel for bandwidth probing (#3250) 2024-12-14 11:51:58 +05:30
Raja Subramanian
4b16017d09 Send side BWE - fixes (#3244)
* WIP

* no worker

* fixes

* use congested packet groups

* oldest group

* markers

* WIP

* WIP

* WIP

* WIP

* WIP

* clean up

* fmt

* consolidate

* store last packet only for bwe extension cases
2024-12-11 21:31:26 +05:30
Raja Subramanian
c172ba13e6 Cleaning up unused stream allocator experiments. (#3237)
Not sure if we will ever use it. Can bring it back if needed.
2024-12-08 13:00:58 +05:30
Raja Subramanian
94488d434d TWCC probing (#3234)
* WIP

* WIP

* WIP

* make it compile

* typo

* clean up

* fmt

* fixes
2024-12-06 00:13:36 +05:30
Raja Subramanian
f9ee48f24b Tri-state probe signal. (#3229)
Need tri-state to indicate inconslusive, congeting and clearing.
Currently, no special treatment for inconclusive, but for future use.
2024-12-03 10:52:43 +05:30
Raja Subramanian
2dcb5c928a Freeze update on congested probe. (#3228)
Reverting back to pre-refactor behaviour. Was trying to avoid doing
special treatment when in probe, but REMB values are hard to predict
and the NACKs as well.

So, freeze updates when congesting in probe till the probe is done.
Otherwise, further changes while probe is finalising sometimes causes an
invalid signal and tracks are not up allocated.
2024-12-02 23:06:06 +05:30
Raja Subramanian
12b3da0a40 Bit more clean up around probe controller refactor (#3227)
* Bit more clean up around probe controller refactor

* consistent order
2024-12-02 13:36:27 +05:30
Raja Subramanian
ceefa8d150 Reset next probe time. (#3226) 2024-12-02 11:37:02 +05:30
Raja Subramanian
3c42ccbb64 Keep congestion state only in BWE. (#3224) 2024-12-02 09:42:51 +05:30
Raja Subramanian
8bb29c3a7b Fixes from probe controller refactor (#3222)
* Fixes from probe controller refactor

* fmt

* static check
2024-11-30 13:34:01 +05:30
Raja Subramanian
44d26f0cb4 Probe controller refactor (#3221)
* WIP

* WIP

* WIP
2024-11-30 01:38:25 +05:30
Raja Subramanian
427ed23478 Move probe observer to pacer (#3214)
* Probe ID pass

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* clean up

* typo

* populate desired bytes

* correct num probes calculation

* debug log

* remove unused constant

* log channel observer

* debug

* clear isInProbe flag on end

* clear probe flag on reset

* re-arrange
2024-11-29 09:19:48 +05:30
cnderrauber
54f9f7de51 upgrade to pion/webrtc v4 (#3213) 2024-11-28 16:05:38 +08:00
Raja Subramanian
cd718c84f6 Misc/minor clean up. (#3183)
Cosmetic. While thinking through how to structure probing better,
noticing small things here and there. Cleaning up and making some small
PRs along the way.
2024-11-17 12:14:46 +05:30
Raja Subramanian
6509cdb5ea StreamAllocator (congestion controller) refactor (#3180)
* refactor WIP

* WIP

* compiling

* runlock

* fixes

* fmt

* stringer and unlikely logger

* clean up
2024-11-16 03:06:37 +05:30
Raja Subramanian
adaf56a30d Move Prober to ccutils. (#3175)
* keep track of RTX bytes separately

* packet group

* Packet group of 50ms

* Minor refactoring

* rate calculator

* send bit rate

* WIP

* comment

* reduce packet infos size

* extended twcc seq num

* fix packet info

* WIP

* queuing delay

* refactor

* config

* callbacks

* fixes

* clean up

* remove debug file, fix rate calculation

* fmt

* fix probes

* format

* notes

* check loss

* tweak detection settings

* 24-bit wrap

* clean up a bit

* limit symbol list to number of packets

* fmt

* clean up

* lost

* fixes

* fmt

* rename

* fixes

* fmt

* use min/max

* hold on early warning of congestion

* make note about need for all optimal allocation on hold release

* estimate trend in congested state

* tweaks

* quantized

* fmt

* TrendDetector generics

* CTR trend

* tweaks

* config

* config

* comments

* clean up

* consistent naming

* pariticpant level setting

* log usage mode

* probing hacks

* WIP

* no lock

* packet group config

* ctr trend refactor

* cleanup and fixes

* format

* debug

* format

* move prober to ccutils

* clean up

* clean up
2024-11-15 00:05:59 +05:30
Raja Subramanian
a3f2ca56f9 TWCC based congestion control - v0 (#3165)
* file output

* wake under lock

* keep track of RTX bytes separately

* packet group

* Packet group of 50ms

* Minor refactoring

* rate calculator

* send bit rate

* WIP

* comment

* reduce packet infos size

* extended twcc seq num

* fix packet info

* WIP

* queuing delay

* refactor

* config

* callbacks

* fixes

* clean up

* remove debug file, fix rate calculation

* fmt

* fix probes

* format

* notes

* check loss

* tweak detection settings

* 24-bit wrap

* clean up a bit

* limit symbol list to number of packets

* fmt

* clean up

* lost

* fixes

* fmt

* rename

* fixes

* fmt

* use min/max

* hold on early warning of congestion

* make note about need for all optimal allocation on hold release

* estimate trend in congested state

* tweaks

* quantized

* fmt

* TrendDetector generics

* CTR trend

* tweaks

* config

* config

* comments

* clean up

* consistent naming

* pariticpant level setting

* log usage mode

* feedback
2024-11-11 10:24:47 +05:30
Raja Subramanian
86383b2271 De-centralize some configs to where they are used. (#3162)
* De-centralize some configs to where they are used.

And make default variables.

Renaming a bit, but these are all internal config and have not been
added to documented config.

* Keep documented config as is.

* test

* typo
2024-11-08 12:47:30 +05:30
Raja Subramanian
f3a13569ee Use int64 nanoseconds and reduce conversion in a few places (#3159) 2024-11-06 12:28:30 +05:30
Raja Subramanian
d0ac19779e Reset DD tracker layers when muted. (#2920)
* Reset DD tracker layers when muted.

@cnderrauber, I think this is okay to do, but please let me know if
there are gotchas in there.

* copy

* more compact form
2024-08-10 15:42:14 +05:30
Raja Subramanian
3ad0a69c86 Stop probe on probe controller reset (#2744) 2024-05-29 18:26:22 +05:30
Raja Subramanian
f9f761b223 Demote some less useful/noisy logs. (#2743) 2024-05-29 12:05:18 +05:30
Paul Wells
9a5db132eb add room/participant name limit (#2704)
* add room/participant name limit

* defaults

* simplify

* omitempty

* handle 0 config

* fix race

* unlock

* tidy
2024-05-06 17:25:18 -07:00
Paul Wells
c4354575ec do not capture pointers in ops queue closures (#2675) 2024-04-22 11:33:28 -07:00
Paul Wells
5c38d58987 add typed ops queue (#2655)
* add typed ops queue

* tidy
2024-04-16 02:51:49 -07:00
Raja Subramanian
c6ee34d083 Cleaning up stream allocator data. (#2639)
* Cleaning up stream allocator data.

Marking it with STREAM-ALLOCATOR-DATA for easier use later if needed.

* clean up a bit more

* wire_gen

* wire_gen
2024-04-10 13:31:25 +05:30
Paul Wells
4b7e5dc1cc reduce gc from stream allocator rate monitor (#2638)
* reduce gc from stream allocator rate monitor

* deps

* comment out rate monitor
2024-04-09 23:14:15 -07:00
Raja Subramanian
ffb831aa8c Cache transceiver before closing subscribed track. (#2594)
On migration, when subscription moved from remote -> local,
transceiver caching was racing. Although a very small possibility,
it could happen like so

1. down track close
2. down track close callback fires go routine to close subscribed track
3. subscribed track close handler in subscription manager tries to
   reconcile
4. reconcile adds subscribed track again
5. cannot find cached transceiver as caching happens after down track
   close finishes in stap 1 above. Although there are a couple of
   gortouine jumps (step 2 fires a goroutine to close subscribed track
   and step 4 will reconcile in a goroutine too), it is theoretically
   possible that the step 1 has not finished and hence transceiver is
   not cached.

Fix is to move caching to before closing subscribed track.
2024-03-22 11:56:50 +05:30
Raja Subramanian
14321f21bf Make OpsQueueParams to make it easier to understand args. (#2578) 2024-03-14 10:27:24 +05:30
Raja Subramanian
e376625a13 Do not need to flush stream allocator events. (#2577) 2024-03-14 04:36:19 +05:30
Raja Subramanian
b71d373f4a Use Deque in ops queue. (#2418)
* Use Seque in ops queue.

Standardizing some uses
- Change OpsQueue to use Deque so that it can grow/shrink as necessary and
  need not worry about channel getting full and dropping events.
- Change StreamAllocator and TelemetryService to use OpsQueue so that
  they also need not worry about channel size and overflows.

* Address feedback

* delete obvious comment

* clean up
2024-01-28 13:48:30 +05:30
Raja Subramanian
5ee307952e Reduce a couple of logs to Debugw. Small saving. (#2322) 2023-12-18 14:27:55 +05:30
David Zhao
3fe124c87f Log cleanup pass (#2285)
* Log cleanup pass

Demoted a bunch of logs to DEBUG, consolidated logs.

* use context logger and fix context var usage

* moved common error types, fixed tests
2023-12-02 15:07:31 -08:00
Raja Subramanian
d866b5110f Restrict scope of negotiation time out error logs (#2283)
* Restrict scope of negotiation time out error logs

1. Log "negotiation failed" only if signal channel was active
within half window of negotiation timeout. Negotiation timeout currently
is at 15 seconds. Signal pings are every 10 seconds.
2. In transport.go, do not report negotiation timed out and do not
callback negotiation failure if the peer connection state is not
connected. Goal of negotiation failure tracker is to take remedial
action when an in-session negotiation fails. Seeing a bunch of cases
of the case hitting even without ICE connection forming. Negotiation
timer is not intended for those cases.

* fix test
2023-12-02 12:44:37 +05:30
Raja Subramanian
68aebb0106 Do not mute when stream is paused. (#2069) 2023-09-13 19:59:24 +05:30
Raja Subramanian
83353d821c Make a config option to skip unmanaged tracks in bandwidth estimation (#2050)
* WIP commit

* Make a config option to skip unmanaged tracks in bandwidth estimation
2023-09-08 20:59:58 +05:30
Raja Subramanian
c122c20f49 Do not re-pause a paused track. (#2037) 2023-09-06 08:27:16 +05:30