Commit Graph

1012 Commits

Author SHA1 Message Date
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
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
6519c7596a Demote some logs. (#2523)
When a fallback is not applied, it is due to signal interruption.
ICE connection failing happens. And every time there is error, it is due
to "no selected pair".

Move all of it to `Debugw`. `setting ICE config` is the definitive log
which says if a different ICE config was applied.
2024-02-28 12:11:40 +05:30
cnderrauber
20ac7fb416 Confirm migrated tracks info before declare migration completed (#2522)
* Confirm migrated tracks info before declare migration completed

* log expected mid
2024-02-28 12:16:34 +08:00
Denys Smirnov
f5eb6c8a95 Update usage of core.Fuse. (#2519) 2024-02-28 03:48:58 +02:00
Raja Subramanian
8442b2b37c Maintain subscription count. (#2515)
* Maintain subscription count.

Does not affect function as it is not decremented only if limits are
configured. But, good to maintain proper count anyway.

* wire
2024-02-27 12:11:24 +05:30
Raja Subramanian
22474e0f5d Remove unused interface method (#2513)
* Remove unused interface method

* cleanup
2024-02-26 20:55:41 +05:30
Raja Subramanian
ef4bc0b46d Support no dynacast pause. (#2512) 2024-02-26 15:15:04 +05:30
Raja Subramanian
6696c1e63d Close published track always. (#2508)
Simplify and close published track always. Avoid the round about path of
unbind to close.
2024-02-25 13:46:55 +05:30
Raja Subramanian
eed457d8be Do not need pending migration tracks. (#2507)
Simplify a bit. Pending migratiion tracks need not be maintained as when
a migrated track is added, it is added to up track manager and treated
as a published track. When up track manager closes, published tracks
will close. So, no need to maintain a separate list.
2024-02-25 01:31:04 +05:30
Paul Wells
e5b8e25064 use shared psrpc utils (#2506)
* use shared psrpc utils

* fix

* deps
2024-02-24 00:38:49 -08:00
Denys Smirnov
013c933636 Properly persist participant kind. (#2505) 2024-02-23 18:56:11 +02:00
Raja Subramanian
132d1ad31a Null out on slice compaction. (#2503)
Go 1.22 does this automatically with `slices` - https://go.dev/blog/generic-slice-functions
2024-02-23 08:20:03 +05:30
Raja Subramanian
f3e02d5132 Prevent multiple debounce of quality downgrade. (#2499) 2024-02-22 02:04:13 +05:30
Raja Subramanian
6895eff496 Buffer size config for video and audio. (#2498)
* Buffer size config for video and audio.

There was only one buffer size in config.
In upstream, config value was used for video.
Audio used a hard coded value of 200 packets.

But, in the down stream sequencer, the config value was used for both
video and audio. So, if video was set up for high bit rate (deep
buffers), audio sequencer ended up using a lot of memory too in
sequencer.

Split config to be able to control that and also not hard code audio.

Another optimisation here would be to not instantiate sequencer unkess
NACK is negotiated.

* deprecate packet_buffer_size
2024-02-21 22:58:56 +05:30
Raja Subramanian
bd7950f56c Cleaning up logs added for debugging (#2497) 2024-02-21 20:21:59 +05:30
cnderrauber
628b7c7024 Fix nil bufferfactory in test (#2495) 2024-02-20 17:06:34 +08:00
Raja Subramanian
e4acf02853 Include pending migrate tracks in ParticipantInfo. (#2493)
It is possible that participant state and migration state updates are
racing. And a participant update could end up with no tracks when
migration is being processed.
2024-02-19 13:30:54 +05:30
Raja Subramanian
1e2da70122 Filter out context canceled errors from logging (#2492)
* Filter out context canceled errors from logging

* move a few more warns to debug
2024-02-19 10:19:55 +05:30
Raja Subramanian
262b160464 Simplify migrate complete a bit more. (#2491)
Moving handling of migrated tracks to when the migration state moves to
completed. Pending data channel were already happening only on complete.
Move tracks also to that point.

Handling it earlier meant that track published callback happened and
ownership of track moved to new node before the new node could finish
peer connection. So, in cases where migration did not go through, this
caused confusion of track ownership.
2024-02-19 09:02:01 +05:30
David Zhao
8371848747 Version 1.5.3 (#2489)
* Version 1.5.3

* add missing copyright notices

* update protocol for redis.tls YAML keys
2024-02-17 12:37:15 -08:00
akarl10
7658e1b60d make 64bit atomics also align on 32bit (#2386)
do this by simply putting them at the front of each struct
see https://pkg.go.dev/sync/atomic#pkg-note-BUG

fixes #2383

Co-authored-by: akarl10 <mike@mwys.mine.bz>
2024-02-17 11:44:55 -08:00
Raja Subramanian
e7dd03181c Use smaller default deque size. (#2488) 2024-02-17 21:30:19 +05:30
Raja Subramanian
5ac5bd236a Let track events go through after participant close. (#2487)
* Let track events go through after participant close.

Also, reducing lock scope in telemetry service.

* use shadow
2024-02-17 13:40:07 +05:30
Raja Subramanian
d216f94ac1 Remove some logs. (#2484)
* Remove some logs.

Also, changing Errorw -> Warnw in a bunch of places.
Going to move towards using `Errorw` for cases where a functionally
unexpected condition happens, i.e by design a condition should not
happen yet it triggered kind of scenarios.

* log error
2024-02-15 18:05:50 +05:30
Raja Subramanian
e4c112929c Declare migration complete on publisher PC connected. (#2481)
Unless there are no published tracks, declare connected on primary PC
connected.

Streamlining this a bit. A bit of history
- With original migration, migration complete was declared on all tracks
  published.
- When muted tracks has to be migrated, a publish is synthesised for
  muted tracks, but migration complete did not wait till publisher peer
  connection connected.
- A few weeks back, those paths were merged and all cases were changed
  to use synthesised publish.
- Previously the completion point was different between muted and
  unmuted tracks. And with the change to treat everything like a muted
  track, completion point changed.

Change it so that if publisher PC is expected to be active, wait for it
to be connected before declaring migration complete.
2024-02-13 22:56:28 +05:30
Raja Subramanian
89a312d259 Ignore duplicate RID. (#2471)
Firefox on Windows 10 seems to be producing simulcast tracks with
duplicate RID. That causes a leak as only one buffer is processed.

Ignore duplicate rid.

NOTE: This is not perfect as the actual layer -> rid is indeterminable
at addition time. It would require looking at packets to determine the
video dimensions and match to rid/layer to figure out which one is
correct and which one is duplicate.

To simplify though, taking the first one and dropping later ones.
This could mean the correct resolution is not streamed, but that should
be okay. The leak is far more destructive.
2024-02-12 11:49:14 +05:30
Théo Monnom
927d8fc0ef UserPacket sid should be empty for hidden participants (#2469) 2024-02-11 03:30:51 +01:00
Raja Subramanian
d20811d1c2 Ignore disabled when adpative stream is enabled. (#2463)
* Ignore `disabled` when adpative stream is enabled.

Due to interplay of adaptive stream/visibility/dynacast, when adaptive
stream is enabled, subscribed track forces visibility and starts
streaming at low quality. This would trigger a render on client and
trigger a visibility update.

So, even if a migration disables a track, upon migration complete and
subscription bind, ignore disable and stream.

* don't hold lock during callback

* don't need to store pubMuted

* don't need to hold settings lock for pub muted
2024-02-08 18:58:48 +05:30
Raja Subramanian
f95194c833 Fixes to sync state disabled tracks. (#2459)
* Fixes to sync state disabled tracks.

* test
2024-02-07 13:52:57 +05:30
Raja Subramanian
e1fb69b634 Synthesize a track setting on sync state. (#2455)
* Synthesize a track setting on sync state.

* Add setting before subscription

* clean up

* Skip tracks that are not subscribed

* protocol deps
2024-02-07 09:32:56 +05:30
Raja Subramanian
5a310f961c Log receiver close. (#2456)
* Log receiver close.

This is going to increase log volume, but want to check if peer
connection close trickles back into receiver close.

* log final close
2024-02-06 23:33:58 +05:30
cnderrauber
be87a1b6f0 Support rtx for publisher (#2452)
* Support rtx for publisher

* remote log

* solve comment
2024-02-06 21:30:37 +08:00
Raja Subramanian
716844c383 Log unpublish for debug. (#2451)
Also, call unpublish callback irrespective of state and let callback
handle do the needed checks.
2024-02-06 10:39:57 +05:30
Raja Subramanian
b7147efb87 Close published tracks on participant close (#2446) 2024-02-05 13:41:41 +05:30
Raja Subramanian
c8b7d486b9 Do not synthesise DISCONNECT on session change. (#2412)
* Do not synthesise DISCONNECT on session change.

v12 clients can handle session change based on identity.

* change for testf

* Squelch participant update if close reason is DUPLICATE_IDENTITY.

* fix test

* comment

* Clean up participant close reason a bit

* fix test

* test
2024-01-31 11:36:50 +05:30
Raja Subramanian
a68500d4a1 Selective send of LeaveRequest. (#2429)
Cannot send old style leave request during migration and other scenarios
when client is expected to resume. The old style can only do a full
reconnect or disconnect. If `CanReconnect: false` which will be the case
for resume, client will disconnect.

Add a parameter to selectively send leave request to older clients.
2024-01-29 14:49:53 +05:30
Raja Subramanian
d53f167b31 LeaveRequest changes. (#2426)
Reworking this a bit
1. Send leave whenever the signal channel is closed to induce a resume.
2. Use a getter to get regions rather than setting.
2024-01-29 13:04:18 +05:30
Raja Subramanian
2a3de84351 Reverting participant worker. (#2428)
* Reverting participant worker.

Reverts https://github.com/livekit/livekit/pull/2420 partially.

This did not revert clean. So, reverting manually. Also, keeping the
drive-by clean up bits.

* fix test
2024-01-29 13:03:32 +05:30
Raja Subramanian
ad072f0836 Revert "Plug worker leaks" (#2427) 2024-01-29 12:40:55 +05:30
Raja Subramanian
846121e781 Revert "Cache data synchronously for processing in worker." (#2425) 2024-01-29 12:36:27 +05:30
Paul Wells
0be241eed8 refactor transport callbacks as interface (#2423)
* refactor transport callbacks as interface

* test
2024-01-28 21:35:25 -08:00
Raja Subramanian
efbc985c82 Cache data synchronously for processing in worker. (#2424)
It is possible that state of underlying object has changed between
event posting and event processing. So, cache data synchronously
and use it during event processing.

This is still not perfect as things like `hidden` and `IsClosed` is
accessed in worker. Ideally, it can be a snapshot of current state of
all required values that can be posted to the worker and the worker just
operates with data.
2024-01-29 10:57:41 +05:30
Raja Subramanian
ea2fa30cf8 Plug worker leaks (#2422)
Thank you @paulwe
2024-01-28 23:12:33 +05:30
Raja Subramanian
bcf9fe3f0f Use a participant worker queue in room. (#2420)
* Use a participant worker queue in room.

Removes selectively needing to call things in goroutine from
participant.

Also, a bit of drive-by clean up.

* spelling

* prevent race

* don't need to remove in goroutine as it is already running in the worker

* worker will get cleaned up in state change callback

* create participant worker only if not created already

* ref count participant worker

* maintain participant list

* clean up oldState
2024-01-28 22:10:35 +05:30
Raja Subramanian
38352b6125 Change transport queue. (#2419)
From a channel to OpsQueue. Have seen extreme cases (with a ton of
candidates) overflowing the channel.
2024-01-28 14:28:29 +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
d3da94c45e Augment LeaveRequest with alternate regions to connect. (#2408)
* Augment LeaveRequest with alternate regions to connect.

* update protocol and issue resume action on close if expected to resume

* use current protocol in tests

* address feedback
2024-01-25 22:22:46 +05:30