Commit Graph

1261 Commits

Author SHA1 Message Date
Raja Subramanian 20bddfea1e Clean up published track on participant removal. (#3527)
Clean up the tracks in the synchronous path and remove track from track
manager. This is not strictly required in a single node case. But,
multi-node needs this. So, doing this here for consistency.
2025-03-14 16:09:22 +05:30
Raja Subramanian 65d8aa2847 Handle subscribe race with track close better. (#3526)
There are two very very edge case scenarios this is triyng to address.

Scenario 1:
-----------
- both pA and pB migrating
- pA migrates first and subscribes to pB via remote track of pB
- while the above subscribe is happening, pB also migrates and
  closes the remote track
- by the time the subscribe set up completes, it realises that
  the remote track is not open any more and removes itself as
  subscriber
- but that removal is using the wrong `isExpectedToResume` as clearing
  all receivers has not run yet which is what caches the
  `isExpectedToResume`.
- That meant, the down track transceiver is not cached and hence not
  re-used when re-subscribing via pB's local track
- Fix it by caching the expected to resume when changing receiver state
  to `closing`.

Scenario 2:
-----------
- both pA and pB migrating
- pA migrates first and subscribes to pB via remote track of pB
- while the above subscribe is happening, pB also migrates and
  closes the remote track
- pB's local track is published before the remote track can be fully
  closed and all the subscribers removed. That local track gets added
  to track manager.
- While the remote track is cleaning, subscription manager triggers
  again to for pA to subscribe to pB's track. The track manager now
  resolves to the local track.
- Local track subscription progresses. As the remote track clean up is
  not finished, the transceiver is not cached. So, the local track based
  subscription creates a new transceiver and that ends up causing
  duplicate tracks in the SDP offer.
- Fix it by creating a FIFO in track manager and only resolve using the
  first one. So, in the above case, till the remote track is fully
  cleaned up, the track manager will resolve to that. Yes, the
  subscriptions itself will fail as the track is not in open state (i. e.
  it might be in `closing` state), but that is fine as subscription
  manager will eventually resolve to the local track and proper
  transceiver re-use can happen.
2025-03-14 14:37:37 +05:30
Raja Subramanian b3779a9086 WebHookConfig (#3517)
* default webhook config

* WebHookConfig

* fix test

* protocol with yaml tags
2025-03-11 13:49:29 +05:30
cnderrauber 139d1b139c Add ForwardParticipant method to room service (#3507)
It returns unimplemented error now.
2025-03-10 14:08:38 +08:00
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
Raja Subramanian 3a35cbc401 Log migration complete only when coming from sync (#3496) 2025-03-07 19:02:39 +05:30
tiaoxizhan 01e51dbd7f fix: fix the wrong error return value (#3493)
Signed-off-by: tiaoxizhan <tiaoxizhan@outlook.com>
2025-03-06 15:53:36 +05:30
cnderrauber 04ed56835e Don't issue TrackPublished/Unpublished event on migrated track (#3482) 2025-03-03 15:32:17 +08:00
cnderrauber 900da73e6d Add ice candidates logs for failed peerconnection (#3473) 2025-02-27 14:47:28 +08:00
Paul Wells 43bd251575 simplify vls base access (#3465) 2025-02-26 09:34:59 +05:30
Raja Subramanian 83b94b31ac Do not revoke track subscription on permission update for exempt (#3458)
participants.
2025-02-21 11:25:29 +05:30
cnderrauber 363353d6e5 Fix codec regression failed after migration (#3455)
The backup codec could arrive before primary
in migration.
2025-02-20 15:54:11 +08:00
David Zhao 1c69a9eeed Dependent participants should not trigger count towards FirstJoinedAt (#3448)
* Dependent participants should not trigger count towards FirstJoinedAt

According to the API, empty timeout should be honored as long as no
independent participant joins the room. If we counted Agents and Egress
as part of FirstJoinedAt, it would have the side effect of using
departureTimeout instead of emptyTimeout for idle calculations.

* use Room logger
2025-02-20 00:57:40 -06:00
Paul Wells 3167266495 add datapacket stream metrics (#3450)
* add datapacket stream metrics

* normalize mime type
2025-02-19 22:28:10 -08:00
Raja Subramanian 69c8d0d165 Log migration complete (#3454) 2025-02-20 11:31:10 +05:30
Paul Wells f49103a003 add participant job type (#3443)
* add participant job type

* cleanup

* deps
2025-02-18 00:40:56 -08:00
Raja Subramanian 5589637152 Seed on receiving forwarder state. (#3435)
This is mostly to clean up forwarder state cache for already started
tracks.

A scenario like the following could apply the seed twice and end up with
an incorrect state resulting in a large jump
- Participant A let's say is the one showing the problem
- Participant A migrates first. So, it tries to restore its down track states by querying state from the previous node.
- But, its down tracks start before the response can be received. However, it remains in the cache.
- Participant B migrates from a different node to where Participant A. So, the down track of Participant A gets switched from relay up track publisher -> local up track publisher.
- I am guessing the seeding gets applied twice in this case and the cached value from step 3 above causes the huge jump.

In those cases, the cache needs to be cleaned up.

(NOTE: I think this seeding of down track on migration is not necessary
as the SSRC of down track changes and the remote side seems to be
treating it like a fresh start because of that. But, doing this step
first and will remove the related parts after observing for a bit more)

Also, moving fetching forwarder state to a goroutine as it involves a
network call to the previous node via Director.
2025-02-14 15:46:08 +05:30
cnderrauber 148a2af151 Log when dropping data packet by slow reader (#3429) 2025-02-13 15:26:22 +08:00
cnderrauber 7e4df818ee Fix timing issue between track republish (#3428) 2025-02-13 13:59:03 +08:00
Raja Subramanian 65d30d9e43 Ignore unknown mime in dynacast manager. (#3419)
Actually, was caused by down track not initialising mime, but it is good
to ignore unknown mime.

Also, added ulpfec sa SDP has that and there was a conversion which was
returning unknown. Also, note that the mime types use audio for RED and
video for flexfec and ulpfec although they are not media type dependent.
Maybe, at point need to introduce `MimeTypeAudioRED` and
`MimeTypeVideoRED`.
2025-02-10 14:56:52 +05:30
Raja Subramanian 3da7de76c7 Fix sense of codec match check while setting layer SSRC. (#3418) 2025-02-10 13:40:16 +05:30
Raja Subramanian 9551c52c85 Try 2 to consolidate mime type (#3407)
* Normalize mime type and add utilities.

An attempt to normalize mime type and avoid string compares remembering
to do case insensitive search.

Not the best solution. Open to ideas. But, define our own mime types
(just in case Pion changes things and Pion also does not have red mime
type defined which should be easy to add though) and tried to use it everywhere.
But, as we get a bunch of callbacks and info from Pion, needed conversion in
more places than I anticipated. And also makes it necessary to carry
that cognitive load of what comes from Pion and needing to process it
properly.

* more locations

* test

* Paul feedback

* MimeType type

* more consolidation

* Remove unused

* test

* test

* mime type as int

* use string method

* Pass error details and timeouts. (#3402)

* go mod tidy (#3408)

* Rename CHANGELOG to CHANGELOG.md (#3391)

Enables markdown features in this otherwise already markdown'ish formatted document

* Update config.go to properly process bool env vars (#3382)

Fixes issue https://github.com/livekit/livekit/issues/3381

* fix(deps): update go deps (#3341)

Generated by renovateBot

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Use a Twirp server hook to send API call details to telemetry. (#3401)

* Use a Twirp server hook to send API call details to telemetry.

* mage generate and clean up

* Add project_id

* deps

* - Redact requests
- Do not store responses
- Extract top level fields room_name, room_id, participant_identity,
  participant_id, track_id as appropriate
- Store status as int

* deps

* Update pkg/sfu/mime/mimetype.go

* Fix prefer codec test

* handle down track mime changes

---------

Co-authored-by: Denys Smirnov <dennwc@pm.me>
Co-authored-by: Philzen <Philzen@users.noreply.github.com>
Co-authored-by: Pablo Fuente Pérez <pablofuenteperez@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Paul Wells <paulwe@gmail.com>
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2025-02-10 10:44:15 +05:30
Paul Wells d8e325d3d4 copy track info when toggling mute (#3406)
* copy track info when toggling mute

* test
2025-02-05 20:12:11 -08:00
cnderrauber aeec75edeb H265 supoort and codec regression (#3358)
* H265 supoort and codec regression

Support H265 codec.
Add optional codec regression for subscribers don't
support advanced codecs like H265, AV1, VP9.

* restart forwarder on upstream codec change

* tests

* Reneogitate new codec if client doesn't support change

* Add option to disable codec regression

---------

Co-authored-by: boks1971 <raja.gobi@tutanota.com>
2025-02-06 11:56:49 +08:00
David Zhao 1825ea81f0 fire TrackSubscribed event only when subscriber is visible (#3378)
TrackSubscribed is meant to give publishers an indication when the subscriber
is ready to receive its audio. When there are hidden recorders in the room,
we do not want them to trigger this event.
2025-01-30 10:48:52 -06:00
Paul Wells 3970e965f6 move ConnectedAt to Participant interface (#3383) 2025-01-30 05:45:47 -08:00
Raja Subramanian c90473b749 ReconnectResponse getting mutated due to mutation of client conf. (#3379) 2025-01-30 11:23:23 +05:30
Raja Subramanian 5aa17adc91 Clone TrackInfo to TrackPublishRequested event. (#3377)
This is atleast one place where analytics objects are getting mutated.
2025-01-29 14:10:43 +05:30
Raja Subramanian db75092aa6 Use nonce in data messages to de-dupe SendData API. (#3366)
* Use nonce in data messages to de-dupe SendData API.

With API retries, it is possible that some data messages are sent
multiple times. Check the nonce (if present) to de-dupe data messages
before forwarding it to the clients.

* add nonce to UserPacket

* defer unlock

* 128-bit UUID as nonce

* - UUID nonce
- make a UserPacketDeduper module for easier re-use.

* deps

* feedback
2025-01-27 15:35:37 +05:30
Raja Subramanian 524441446f Room creation time with ms resolution (#3362) 2025-01-23 09:42:30 +05:30
Paul Wells f435c5cb62 reduce log level for channel closed error when writing signal message (#3361)
* reduce log level for channel closed error when writing signal message

* tidy
2025-01-22 04:33:47 -08:00
Raja Subramanian b4cf055c1c Resolve newer participant using higher precision join time. (#3360)
* Resolve newer participant using higher precision join time.

Also, keep it consistent based on participant SID if everything else is
the same.

* switch to compare semantics

* fix
2025-01-22 15:24:34 +05:30
Raja Subramanian 416dded86f Clone pending tracks to prevent concurrent update. (#3359) 2025-01-22 13:24:26 +05:30
Raja Subramanian 7f6bd614a0 Remove FF check for TWCC. (#3340)
Sending 0 ID dependency descriptor was the issue.
2025-01-17 02:14:26 +05:30
Raja Subramanian b82f77eb87 Check for Firefox in rtc config. (#3336) 2025-01-15 20:45:37 +05:30
Raja Subramanian ae8c8bc941 Turn off TWCC for Firefox (#3333)
* Debug FF TWCC

* - TURN off TWCC for Firefox. Seems to fail with VP9 send, i.e. there are
  no TWCC feedback packets when sending VP9.
- Relax thresholds for congestion as staging data is showing
  oscillations.
- Clean up some logging.

* debug log a few more signal messages

* revert config

* revert config

* clean up
2025-01-15 10:32:59 +05:30
lukasIO fc009fc707 Add support for datastream trailer (#3329) 2025-01-13 10:42:49 +01:00
cnderrauber 6a5d6a282b Log sdps when negotiate failed (#3325) 2025-01-13 13:38:32 +08:00
Raja Subramanian 28c39efa06 Exempt egress participant from track permissions. (#3322)
* Exempt egress participant from track permissions.

* test
2025-01-11 12:50:34 +05:30
cnderrauber f08fc581e0 disable sctp zero checksum for unknown sdk (#3321) 2025-01-10 11:55:28 +08:00
cnderrauber f846c7719b Disable SCTP zero checksum for old go client (#3319)
Old go-sdks with old pion/sctp version can't
process unknown parameters.
2025-01-09 13:22:23 +08:00
Raja Subramanian 3b0077f2fe Log connection quality changes. (#3311)
Also remove the connection quality drop prom as it is unused and also
adds state/complexity.
2025-01-07 10:58:31 +05:30
Raja Subramanian 61dbbf6c56 Start stream allocator after creating peer connection. (#3283)
* Start stream allocator after creating peer connection.

RTTGetter relies of peer connection being created/started.
Starting stream allocator before creating peer connection could race.

* set bwe interceptor
2024-12-22 23:05:55 +05:30
cnderrauber 8fa1127724 Disable data channel throttle by default (#3281)
* Disable data channel throttle by default

* data race

* err type
2024-12-21 12:08:54 +08:00
Raja Subramanian c8b644934f Update deque and friends. (#3276) 2024-12-20 07:16:14 +05:30
Raja Subramanian 36338bab5c Address another panic. (#3274)
* Address another panic.

If receiver is not resolved yet, prevent race of access dummy receiver.

* reset callback only if there is receiver

* missed return
2024-12-20 00:17:06 +05:30
Raja Subramanian 3251156bd3 Address a data race reported by CI (#3273)
in this run https://github.com/livekit/livekit/actions/runs/12396846876/job/34605820002
2024-12-19 23:16:48 +05:30
Raja Subramanian 1084866781 Update full subscriber config based on congestion control config. (#3272) 2024-12-19 18:43:37 +05:30
Raja Subramanian 02117a4d46 Panic fixes (#3270)
Also, do negotiated down track extensions after bind.
2024-12-19 11:52:43 +05:30