Commit Graph

2006 Commits

Author SHA1 Message Date
Raja Subramanian b1a4d00fa9 Replace receiver when there is an existing one. (#2611)
The receiver should not change, but code wise, the option of replacing
receiver object makes more sense, i.e. otherwise, it could look like we
are leaving the stale object in there without replacing with new
receiver of same type.
2024-04-01 16:14:30 +05:30
Raja Subramanian 278ae72f70 Avoid duplicate receivers on migration. (#2608)
* Avoid duplicate receivers on migration.

When migrating, post migration call to set up could add duplicate
receivers.

* don't need to check upgraded
2024-03-31 11:15:50 +05:30
Raja Subramanian 4c9e59dc25 Small tweaks to propagation delay adaptation. (#2607) 2024-03-30 21:53:18 +05:30
Raja Subramanian b5de646073 Remove redundant check. (#2605)
* Remove redundant check.

That check is already at the ouside check.

* print string

* space
2024-03-30 00:31:26 +05:30
Paul Wells f1c991c547 skip logging retry message when ws disconnections before signal finishes (#2604) 2024-03-29 06:30:12 -07:00
cnderrauber 0a35e59ebd Replace sleep with sync.Cond to reduce jitter (#2603) 2024-03-29 17:24:31 +08:00
cnderrauber 95df9737a6 Fix twcc has chance to miss for firefox simulcast rtx (#2601) 2024-03-29 09:05:53 +08:00
cnderrauber bc5fc17bdc Log high jitter case (#2602) 2024-03-28 15:59:03 +08:00
Raja Subramanian 45581433cc Add option to enable bitrate based scoring (#2600) 2024-03-27 18:45:53 +05:30
Raja Subramanian 0480f99a83 Tweak adaptation to increase in propagation delay. (#2598)
* Tweak adaptation to increase in propagation delay.

A couple of issues
- RTCP Sender Reports rate will vary based on underying track bitrate.
  (at least in theory, not all entities will do it though, for example
  SFU does standard rate of one per three seconds irrespective of track
  bit rate). So, adapt the long term estimate of propagation delay delta
  based on spacing of reports.
- Re-init of propagation delay to adapt to path change was taking the
  last value before the switch. But, that one value could have been an
  outlier and accepting it is not great. So, adapt spike time
  propagation delay in a smoother fashion to ensure that all values
  during spike contribute to the final value.

* clean up
2024-03-26 17:33:24 +05:30
Raja Subramanian 2dba3b2d2e Protect duplicate subscription (another try). (#2596)
Another case of duplciate tracks in SDP.
During migration (if both publisher and subscriber migrate), subscriber
could attach the remote track of the publisher. But, while that is
happening, publisher could migrate into the node and close the remote
media track. This was causing subscriber to switch from attaching to
remote media track -> attaching to local media track.

But, as remote media track was closed while add subscription was
happening, the subscriber is removed without subscription manager being
aware of it.

So, the subscription manager's reconcile and the remove subscriber is
racing and when subscription manager re-subscribes, caching has not run
yet and that creates a duplicate.

Delay removing subscribed track till after caching is done. That means,
even if the reconciler runs, it will get an `errAlreadySubscribed` error
and it will force it to reconcile again. By the time the subscribed
track is deleted from the subscriptions map, caching is done.
2024-03-25 15:07:29 +05:30
Raja Subramanian 95f5c94b4d Notify initial permissions (#2595)
* Notify initial permissions

NOTE: This does add an initial subscription permission notification
which should be fine, but something to watch for.

A stress test combining
- mute/unmute on publisher side.
- allowing/revoking permission for subscriber from publisher side.
- subscribing/unsubscribing from subscriber side.
results in a scenario where a subscription permission update of
`not_allowed` being sent and on a re-subscribe, an `allowed` update does
not happen.

It happens like so
- Subscription revoke cloes the down track of subscriber.
- The subscription is still desired.
- So, a subscription reconcile runs and sees `permission: false`. This
  sends subscription permission of `not_allowed`.
- Unsubscribe request comes in and sets `desired: false`.
- Reconsiler runs again and sees `desired: false` and `subscribedTrack:
  nil`. This cleans up the subscription.
- Publisher grants permission for the subscriber.
- Subscriber subscribes to the track again. A new subscription is
  created.
- Reconciler runs and sees `permission: true`, but there is no
  permission change as it is a new subscription object. So, `allowed`
  subscription permission update is not sent and the client is stuck at
  `not_allowed`.

Fix, maintain if permission has been initialized. Has the effect of
sending an initial update which should be fine.

* clean up comment

* no default
2024-03-22 23:22:20 +05:30
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
Paul Wells 0f597e7e46 update protocol (#2593)
* update protocol

* cleanup

* deps
2024-03-21 02:48:26 -07:00
Raja Subramanian 7945c01dbe Reset sharp increase if received delta is small. (#2592) 2024-03-21 10:25:45 +05:30
Denys Smirnov 8564329579 Pass DTMF when creating SIP participants. (#2590) 2024-03-20 18:59:25 +02:00
Raja Subramanian 03ada9ba76 Proper RTCP report past mute. (#2588)
- When audio is muted, server injects silence frames which moves the
  time stamp forward and adjusts offset. That cannot be used against
  publisher side sender report. Use a pinned version.
- Ignore small changes to propagation delay even while checking for
  sharp increase. That is spamming a lot for small changes, i.e.
  existing delta is 100 micro seconds or so and the new one is 300 micro
  seconds. Also rename to `longTerm` from `smoothed` as it is a slow
  varying long term estimate of propagation delay delta. And slow down
  that adaptation more.
2024-03-19 11:59:24 +05:30
Raja Subramanian e85922857a Use cloned grants. (#2586)
To ensure no pointer (i. e. mutable object) is held in returned proto.
2024-03-18 14:55:05 +05:30
Raja Subramanian 9e5f434cef Do not block as notification could make a network request. (#2581) 2024-03-15 10:59:37 +05:30
Denys Smirnov 1d920ae488 Support SIP DTMF data messages. (#2559) 2024-03-14 17:23:43 +02:00
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 4e96ad2e5b Missed clean up in the last PR (#2576)
* Missed clean up in the last PR

* Infow -> Debugw
2024-03-13 23:01:19 +05:30
Raja Subramanian 3e43f75143 Forward publisher sender report. (#2572)
* Forward publisher sender report.

Publisher side RTCP sernfer report is rebased to SFU time base
and used to send sender rerport to subscriber.

Will wait to merge till previous versions are out as this will require a
bunch of testing.

* - Add rebased report drift
- update protocol dep
- fix path change check, it has to check against delta of propagation
  delay and not propagation delay as the two side clocks could be way
  off.
2024-03-13 14:31:39 +05:30
Raja Subramanian 610d68a409 Clean up using publisher side clock rate. (#2568)
It is not used any more.
2024-03-11 12:25:07 +05:30
Raja Subramanian 50c48ff29d Ignore out-of-order receiver side sender reports. (#2567) 2024-03-11 11:30:01 +05:30
Raja Subramanian 93c7d1f4fb Adjust first packet time on down track resume. (#2566)
Allows subscriber sender report to line up better quicker.
2024-03-11 00:40:16 +05:30
Raja Subramanian bdbc9dcbc7 Use start time stamp to calculate down stream sender report. (#2564)
* Use start time stamp to calculate down stream sender report.

With first packet time adjustment, using the first time stamp is more
accurate.

This still suffers if the up stream clock rate changes (happens in cases
like noise suppression which is not well understood). Will be looking at
pass through of sender report from publisher to subscriber.

* similar log strings

* avoid early sender reports

* log messages

* Reduce first packet adjustment threshold to 15 seconds
2024-03-10 23:18:54 +05:30
Raja Subramanian a08b058abc Structured logging for sender report data. (#2563) 2024-03-10 01:29:37 +05:30
Raja Subramanian 666b912dd3 Fix test (#2557)
Have no idea how last PR was ready to merge without this.
2024-03-08 20:31:58 +05:30
Raja Subramanian 324c5f35cb handle nil resolver. (#2556) 2024-03-08 19:06:28 +05:30
Alexandr Rastopchin 7d39711084 fix issue 2539, do not kill the keepaliveWorker task when the ping timeout occurs (#2555) 2024-03-07 09:11:36 -08:00
Raja Subramanian 6c94185aa6 Bring back soft close. (#2553)
Remote media track needs it.
2024-03-07 12:52:48 +05:30
Paul Wells d87f8aa299 use departure timeout (#2549)
* use departure timeout

* deps

* default

* remove constants

* deps

* protoproxy cache

* add sample
2024-03-05 09:05:42 -08:00
Raja Subramanian 0618cb39df Logging time and rtp diff for easier debugging (#2548) 2024-03-05 20:31:44 +05:30
cnderrauber 95001dfe54 remove warning log of unexpected rtcp fb (#2546)
* remove warning log of unexpected rtcp fb

* Add log for high playout delay

* don't create delay controller for audio
2024-03-05 10:35:28 +08:00
Raja Subramanian 108594a0b9 Notify migration on migration out node. (#2543)
It is possible that migration could trigger without migrating out node
knowing about it. So, when a migration started notification comes in,
set up migration timer if not already set.
2024-03-04 19:43:54 +05:30
Raja Subramanian 46257c1d24 Skip large RR intervals. (#2544) 2024-03-04 19:12:53 +05:30
Raja Subramanian fdd76c8734 Post a PLI check request on connected. (#2542)
Otherwise, it gets delayed by timer and could wait upto to interval
(which could be 200 ms when there is no RTT information yet).
2024-03-04 14:41:35 +05:30
cnderrauber 8c5d8730b1 Check ssrc for rtcp packets (#2541)
* Check ssrc for rtcp packets

* Add warn log if rtcp fb has unknown ssrc
2024-03-04 16:36:57 +08:00
Raja Subramanian 56dcd0b025 Process matching sender report only. (#2540) 2024-03-04 13:11:57 +05:30
Paul Wells ad341d41f5 start telemetry participant worker to collect signal stats (#2538)
* start telemetry participant worker to collect signal stats

* format

* resolve room

* tidy
2024-03-03 02:47:51 -08:00
cnderrauber b58307f144 Support XR request/response for rtt calculation (#2536)
* Support XR request/response for rtt calculation

* Update pkg/sfu/downtrack.go

Co-authored-by: David Zhao <dz@livekit.io>

---------

Co-authored-by: David Zhao <dz@livekit.io>
2024-03-03 12:34:49 +08:00
Raja Subramanian dbe2af3886 Remove subscriber if track closed while adding subscriber. (#2537)
* Remove subscriber if track closed while adding subscriber.

It is possible that the track is closed when subscriber add is
processed. That subscriber would have been dangling off a closed track.

Check again after adding subscriber if track is closed.
If it is, remove the subscriber and return error so that subscription
manager re-resolves.

* oops, wrong unlock
2024-03-02 23:12:20 +05:30
Denys Smirnov 9a6d25674d Validate SIP trunks and rules when creating new ones. (#2535) 2024-03-01 19:29:32 +02:00
Raja Subramanian 6a0b72c357 Use SubscriberID() is calls to DeleteDownTrack. (#2533)
Thank you @cnderrauber for catching this.
2024-03-01 15:21:00 +05:30
Raja Subramanian 9e334c7510 Refactoring channel handling (#2532)
* Refactoring channel handling

* Add a version to SubscriberID()
2024-03-01 15:08:07 +05:30
Raja Subramanian 95011d64f8 Annotate max subscribe layer change with events. (#2531)
Using events to understand what is causing max subscribed layer changes.
Seeing an edge case where all layers are disabled incorrectly.
2024-03-01 11:27:26 +05:30
Raja Subramanian d40041d013 Use the correct snapshot id for PPS. (#2528)
* Use the correct snapshot id for PPS.

That caused connection quality to operate on small windows.

* remove debug
2024-02-29 22:48:36 +05:30
Raja Subramanian ea66eae9f5 Start moving things to structured logging (#2527) 2024-02-29 14:35:19 +05:30