Commit Graph

1075 Commits

Author SHA1 Message Date
Raja Subramanian
f92e7e3db8 use pending lock, no need for participant lock (#2793) 2024-06-15 20:44:50 +05:30
David Colburn
29614cd4a1 clean up egress launcher (#2779) 2024-06-10 16:11:11 -07:00
Raja Subramanian
129ba62d61 Validate RTP packets. (#2778)
* Validate RTP packets.

Check version, payload type (if available) and SSRC (if available)
and drop bad packets. And let repair mechanisms take effect for those
packets.

* address data race reported by test

* fix an unlock and test packets
2024-06-10 15:43:59 +05:30
Raja Subramanian
73852d0a13 Reduce large sequence number jump threshold for logging. (#2770)
Seeing some unexplained large jumps on remotes across relay. Unclear if
there was a jump on origin side at some point. Reducing threshold for
large jump so that we can catch unexpected jumps more.
2024-06-07 12:36:02 +05:30
cnderrauber
908baeb942 initialize bucket size by publish bitrates (#2763) 2024-06-06 14:31:20 +08:00
Paul Wells
f1886ece42 update protocol (#2760)
* update protocol

* deps
2024-06-05 19:46:34 -07:00
Raja Subramanian
cfd3777f47 Use a safety net OnClose to remove track from peer connection. (#2758) 2024-06-05 21:54:22 +05:30
Raja Subramanian
49e1848d1d Move resync to TrackSender interface so that it can be called directly from up track (#2755) 2024-06-04 22:38:39 +05:30
Raja Subramanian
f9f761b223 Demote some less useful/noisy logs. (#2743) 2024-05-29 12:05:18 +05:30
Raja Subramanian
d9910ead61 Add back TrafficStats used by cloud. (#2736) 2024-05-27 13:43:20 +05:30
Raja Subramanian
991ad5a0ea Remove unused traffic load (#2734) 2024-05-27 10:53:23 +05:30
Raja Subramanian
721c36fbc0 Send telemetry events on track feature updates. (#2723)
* Send telemetry events on track feature updates.

* Do not process no change
2024-05-27 10:46:26 +05:30
Paul Wells
5e3b1e0f67 reduce participant lock scope (#2732) 2024-05-26 14:01:23 -07:00
cnderrauber
e6aa36fdd6 Add forward stats (#2725)
* Add forward metrics

* ignore packets was not forwarded

* rename
2024-05-24 17:43:28 +08:00
Raja Subramanian
80a4d021b9 Add simulate leave request close reason (#2713) 2024-05-10 20:02:25 +05:30
Antti Tapaninen
45ed030ce6 add missing strings.EqualFold for some mimeType comparisons (#2701) 2024-05-04 11:47:29 +05:30
Raja Subramanian
674550ea16 Option to disable traffic load tracking. (#2698) 2024-05-02 19:09:12 +05:30
cnderrauber
cfa82c6ad4 increase protocol version to support optional publisher datachannel (#2693) 2024-04-28 15:09:24 +08:00
cnderrauber
90de06ce02 Make datachannel optional for publisher (#2686) 2024-04-26 15:24:41 +08:00
David Zhao
37346774bb Forward transcription data packets to the room (#2687) 2024-04-26 00:00:30 -07:00
Raja Subramanian
79f6506553 Clean up UpdateVideoLayers (#2685) 2024-04-26 12:21:40 +05:30
Raja Subramanian
90b47424b5 Handle UpdateLocalAudioTrack and UpdateLocalVideoTrack. (#2684)
* Handle UpdateLocalAudioTrack and UpdateLocalVideoTrack.

- Update the TrackInfo
- NOTE: populating Stereo and DisableDtx fields although there are
  features now.
- The audio features in UpdateLocalAudioTrack is applied as is,
  i. e. the update has the latest set of features.
- Emits a track update which will broadcast a participant update.

TODO:
-----
- Telemetry event with track update?

* update deps
2024-04-26 12:06:35 +05:30
cnderrauber
b55038af03 Detach subscriber datachannel to save memory (#2680)
Sfu don't read message from subscriber datachannel, detach
it to bypass the readLoop can save 128KB memory and 2 goroutines per
participant.
2024-04-24 16:26:07 +08:00
Paul Wells
c4354575ec do not capture pointers in ops queue closures (#2675) 2024-04-22 11:33:28 -07:00
cnderrauber
0b3587b10d Disable dynamic playout delay for screenshare track (#2663)
Screenshare video has inaccuracy jitter due to its low frame rate and bursty traffic
2024-04-19 15:25:48 +08:00
Raja Subramanian
e96e8de725 Debug logging addition of ICE candidate (#2659) 2024-04-17 11:14:40 +05:30
Raja Subramanian
14b934a780 Log ICE candidates to debug TCP connection issues. (#2658) 2024-04-17 09:45:10 +05:30
Paul Wells
b77f0256c7 use typed ops queue in pctransport (#2656) 2024-04-16 03:23:08 -07:00
Raja Subramanian
1ab0879d28 ICE config cache module. (#2654)
* ICE config cache module.

* generic key type

* no ICEConfig in StartSession

* clean up
2024-04-16 15:49:45 +05:30
Paul Wells
7d5c991d8d add disconnected chan to participant (#2650) 2024-04-14 12:49:13 -07:00
David Colburn
990cf6877b backwards compatability for IsRecorder (#2647)
* backwards compatability for IsRecorder

* regenerate fakes
2024-04-11 11:14:15 -07:00
Raja Subramanian
ad1f508680 Add support for "abs-capture-time" extension. (#2640)
* Add support for "abs-capture-time" extension.

Currently, it is just passed through from publisher -> subscriber side.

TODO: Need to store in sequencer and restore for retransmission.

* abs-capture-time in retransmissions

* clean up

* fix test

* more test fixes

* more test fixes

* more test fixes

* log only when size is non-zero

* log on both sides for debugging

* add marshal/unmarshal

* normalize abs capture time to SFU clock

* comment out adding abs-capture-time from registered extensions
2024-04-11 15:25:10 +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
6b0f7403ef Log fix. (#2637)
Else, it was logging something like
`candidateError: json: unsupported type: func() interface {}`
2024-04-09 11:19:41 +05:30
Mathew Kamkar
10c8582a6b get cpu stats from cgroup, remove env (#2636)
* get cpu stats from cgroup, remove env

* undo rand seed removal

* tests
2024-04-08 21:15:17 -07:00
Raja Subramanian
8852d71a8a Disable audio loss proxying. (#2629)
* Disable audio loss proxying.

Added a config which is off by default.
With audio NACKs, that is the preferred repair mechanism.
With RED, repair is built in via packet redundancy to recover from
isolated losses.
So, proxying is not required. But, leaving it in there with a config
that is disabled by default.

* fix test
2024-04-06 11:28:04 +05:30
David Colburn
4603b5c053 make IsDependent backwards compatible (#2627) 2024-04-05 14:24:34 -07:00
David Colburn
fff937a89c participant kinds (#2626) 2024-04-05 12:59:06 -07:00
Raja Subramanian
5cfcbc0ca6 Move caching of publisher sender report to subscriber side. (#2622)
* Move caching of publisher sender report to subscriber side.

Please see inline for descriptive comments on why. Basically,
pause/unpause using replaceTrack(null)/replaceTrack(actualTrack) can
cause time stamp in sender report sent to subscribers jump ahead.
This prevents that.

With the caching on subscriber side, cleaning up the caching on
publisher side.

* fix compile, test still failing, need to debug

* skip reference TS for testing
2024-04-04 18:23:30 +05:30
Théo Monnom
dc67f505a5 agent service: new protocol & namespaces (#2545)
* initial worker impl

* fix test

* fix build

* TestAgentNamespaces

* log err

* nit cmt

* TestAgentMultiNode

* Update pkg/agent/worker.go

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

* retry on worker selection & fix review comments

* Update roommanager.go

* license

* use testutils.WIthTimeout

* abstract namespace/enabled logic into agent.Client, incrementally dispatch

* typos and dates

* lock

* timeout is now optional

* pass in topics instead of fixed

* handler handles connections

* onIdle, numConnections

* fix WithGrants

* update protocol

* check agent client

* broadcast after unlock

* fix data race

* remove ReadChan, fix dispatcher

---------

Co-authored-by: David Zhao <dz@livekit.io>
Co-authored-by: David Colburn <xero73@gmail.com>
2024-04-03 15:25:42 -07:00
Raja Subramanian
3c8980b443 Fix media track close check. (#2614)
With the change in https://github.com/livekit/livekit/pull/2611,
the dummy receiver was replaced with real receiver. But, the close check
was using the dummy receiver.

Doing two things
- Use the dummy receiver post upgrade also
  (NOTE: this is not needed, but just keeping old behaviour)
- Fix the close check to count number of open receivers.
2024-04-02 11:03:50 +05:30
Raja Subramanian
3ed0527ef5 Reduce chances of missing layer post migration. (#2612)
When migrating out, it is possible that a published layer is not
notified to the migrating in node. Reduce chances of that layer not
getting published to the new node by curbing RTCP during migration.
It could still happen if stars line up, but this should reduce the
window to a much smaller one.
2024-04-01 18:53:54 +05:30
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
cnderrauber
95df9737a6 Fix twcc has chance to miss for firefox simulcast rtx (#2601) 2024-03-29 09:05:53 +08:00
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
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