Commit Graph

3428 Commits

Author SHA1 Message Date
boks1971
3a44635f13 log seq and destination identities 2025-11-08 08:26:38 +05:30
boks1971
266c7cded2 log data streams 2025-11-06 15:06:26 +05:30
Raja Subramanian
4872f2051d Return write count from WriteRTP. (#4059)
* Log write count atomic.

* Return write count from WriteRTP.

Apologies for the frequent changes on this. With relays, the down track
could write to several targets. So, use count to have an accurate
indication of how may subscribers were written to.
2025-11-06 13:29:21 +05:30
Raja Subramanian
d0ba46b460 Log write count atomic. (#4057) 2025-11-06 13:00:08 +05:30
Raja Subramanian
ae5fb7e882 Add packet to forwarding stats only if packet is forwarded. (#4056)
Packets not being forwarded were getting included in forwarding stats
calculation and skewing the measurement towards a smaller number.

The latency measurement does not include the batch IO of packets on
send. With a 2ms batching, that will add an average latency of 1ms.
2025-11-06 12:31:49 +05:30
Raja Subramanian
f6909192bb Update PsRPC to get redis pipeliner implementation. (#4055)
* Update PsRPC to get redis pipeliner implementation.

* clean up
2025-11-05 22:42:21 +05:30
Raja Subramanian
ca3c507b3f Prevent invalid track access while peer connection is shutting down. (#4054) 2025-11-05 17:48:27 +05:30
Raja Subramanian
9ca6ee0077 Use replace so that x/tools does not get overridden (#4048) 2025-11-02 17:58:01 +05:30
Anunay Maheshwari
b9323eab39 chore(deps): downgrade x/tools for counterfeiter (#4047) v1.9.3 2025-11-02 17:16:06 +05:30
Raja Subramanian
2f1e6c363c Prep release v1.9.3 (#4046) 2025-11-02 16:01:41 +05:30
Raja Subramanian
9d5c351d36 Fix prom units for forwarding latency/jitter. (#4045) 2025-11-02 14:38:25 +05:30
Raja Subramanian
e183657cff Add prom histogram for forwarding latency and jitter. (#4044)
* Add prom histogram for forwarding latency and jitter.

Using short term stats for histogram.

An example setting is
1s - short term
1m - long term

Using the 1s (short term) data for histogram. In that 1 second, all
packet forwarding latencies are averaged for latency and std. dev. of
the collection is used as jitter.

* try different staticcheck
2025-11-01 23:25:03 +05:30
Trey Hakanson
1eefeb3089 Enable AbsCaptureTimeURI in RTC configuration (#4043)
Enable absolute capture time RTP extension. This logic was added a while back, but was disabled.
2025-10-31 09:42:36 +05:30
cnderrauber
075a7576ed Use simulcast codec as default policy for audio track (#4040) 2025-10-29 21:39:20 +08:00
cnderrauber
c264b504c4 Don't warn 0 payload type for PCMU (#4039) 2025-10-28 23:11:51 +08:00
Raja Subramanian
32fc35254e Broadcast cond var on RTX write. (#4038)
* Broadcast cond var on RTX write.

High forwarding latency logs all show high queuing delay so far. From
code inspection, RTX writes were not signaling the cond var. Not sure if
that is the reason, but adding a signal there for further tests.

* Remove return values from writeRTX as they are not used
2025-10-28 11:27:02 +05:30
Raja Subramanian
061eb8b4e8 AddDownTrack to regressed codec after restarting forwarder. (#4037)
Without that the new codec was skipping through with old selector and
not working correctly.
2025-10-27 20:14:33 +05:30
Artur Melanchyk
c87eb8ed11 fix: add missing Unlock() in AddReceiver (#4036)
Signed-off-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
Co-authored-by: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com>
2025-10-27 18:45:44 +05:30
Matthew Brown
704449247e if RingingTimeout is provided, deadline should be set to that timeout. (#4018)
* if RingingTimeout is provided, deadline should be set to that timeout.

This is because the SIP bridge will not return until RingingTimeout
which may be longer than the 30 second default deadline.

* handle Deadline being "before" timeout.
2025-10-27 15:03:03 +02:00
Raja Subramanian
ab906d710c Prevent leakage of previous codec after codec regression. (#4035)
* Prevent leakage of previous codec after codec regression.

In the window between forwarder restart and determining codec, the old
codec packet could leak through. Prevent tha by doing the restart and
codec determination atomically on a codec regression.

* tidy

* use locked function
2025-10-27 17:40:39 +05:30
Raja Subramanian
79b03f97a2 Log queueing latency when encountering high forwarding latency (#4034) 2025-10-27 15:27:03 +05:30
Raja Subramanian
29117b1422 set max layer in allocation (#4033) 2025-10-26 17:51:35 +05:30
Raja Subramanian
15b19ccd26 Remove ~ from rid which indicates disabled layer to get the actual rid (#4032) 2025-10-26 15:44:32 +05:30
Raja Subramanian
34e16a8709 Check more conditions for opportunistic alloc. (#4031) 2025-10-26 14:03:26 +05:30
Raja Subramanian
81fbd3551a Use the optimal allocation function for opportunistic allocation. (#4030)
* Use the optimal allocation function for opportunistic allocation.

Allocation functions set the `lastAllocation` state also.
This might have been causing an e2e failure with v1 client on migration.

* annotate args
2025-10-26 00:27:41 +05:30
Raja Subramanian
a2ce73e0d0 Do not bind buffer if codec is invalid. (#4028)
Seeing cases of codec with zero clock rate. Do not bind to those.
2025-10-25 14:30:30 +05:30
Raja Subramanian
cef6fdb7b6 Correct direction for request/response for prom counters. (#4027)
* Correct direction for request/response for prom counters.

I think I had it reversed.

* clean up

* clean up
2025-10-24 23:15:23 +05:30
Raja Subramanian
5042c06cb2 Use rtp converter from protocol/utils/rtputil (#4020)
* Use rtp converter from protocol/utils/rtputil

* lock x/tools as counterfeiter needs it
2025-10-22 15:15:46 +05:30
Raja Subramanian
5a426d15e1 Use rtp converter from protocol/utils (#4019) 2025-10-22 14:09:33 +05:30
Andrés
35fb887714 feat: use env var for GOARCH (#4012)
Signed-off-by: Andrés MANELLI <amanelli@forssea-robotics.fr>
2025-10-21 12:56:37 +05:30
Alexey Sokolov
c039769607 Issue #1 only: Fix spatial layer initialization in Forwarder (#4003)
When SetMaxSpatialLayer() is called with target/current layers in
InvalidLayerSpatial state, opportunistically initialize the target
layer to avoid dropped packets during async stream allocator
initialization.

Guards:
- Only sets target if not congestion-throttled (isDeficientLocked)
- Does not set current layer (deferred to keyframe-based forwarder start)
- Logs at Debug level to avoid log noise

This prevents undefined layer state during manual subscription
with immediate quality upgrades (WithAutoSubscribe(false) +
SetVideoQuality(HIGH)).
2025-10-21 12:54:05 +05:30
Raja Subramanian
2afbf0e8ca Some golang modernisation bits. (#4016)
Mainly doing this to check CI static check failures.
2025-10-21 12:53:18 +05:30
Raja Subramanian
484f784a43 Prepare release v1.9.2 (#4011) v1.9.2 2025-10-17 13:17:36 +05:30
Raja Subramanian
ad074ed2a5 counterfeiter needs an older version of x/tools (#4009) 2025-10-16 09:54:44 +05:30
Raja Subramanian
e63e8b6f2d Include mid -> trackID in both SDP offer and answer. (#4007)
This can be used by dual peer connection clients also.
2025-10-16 09:19:13 +05:30
Raja Subramanian
781dfede93 Do not call receiver methods under settings lock. (#4006)
* Do not call receiver methods under settings lock.

CI flagged a potential lock order reversal in https://github.com/livekit/livekit/actions/runs/18531658065/job/52815807499

* clean up
2025-10-15 21:06:28 +05:30
Raja Subramanian
69ff25a055 Use answer with mid -> trackID mapping when in single peer connection (#4005)
* Use answer with mid -> trackID mapping when in single peer connection
mode.

* mage generate

* staticcheck

* handle mapped answer in tests
2025-10-15 19:36:22 +05:30
Raja Subramanian
fe912acf37 Update pion/webrtc to prevent GetStats panic. (#4004)
Also, closing all data channels before closing peer connection.
2025-10-15 13:11:14 +05:30
Raja Subramanian
7930dcde25 Do not try to read stats from peer connection after close. (#4002)
Pion does not protect the stats getter and using it after close could
cause nil de-reference. Do a couple of things
1. Stop timer that access peer connection stats before closing peer
   connection.
2. Do not access stats if peer connection is already closed
2025-10-15 00:04:12 +05:30
Raja Subramanian
ca0d5ee972 Count request/response packets on both client and server side. (#4001)
Currently, the signal requests are counted on media side and signal
responses are counted on controller side. This does not provide the
granularity to check how many response messages each media node is
sending.

Seeing some cases where track subscriptions are slow under load. This
would be good to see if the media node is doing a lot of signal response
messages.
2025-10-14 16:58:36 +05:30
Raja Subramanian
dd62eb0072 Resort to full search for requested quality is not available. (#4000)
When doing code changes for dynamic rid, inadventently relied on
ordering of quality in track info layers to pick the highest layer if
the requested quality is higher than available qualities.
@cnderrauber addressed it in
https://github.com/livekit/livekit/pull/3998. Just adding some more
robustness behind that by doing a full search when requested quality is
not available.

Tested using JS SDK demo app and picking different qualities from
subscriber side with adaptive streaming turned off.
2025-10-14 10:05:33 +05:30
Raja Subramanian
f6ca82d177 Revert to using silence packets for audio dummy start. (#3999)
Effectively reverts https://github.com/livekit/livekit/pull/3984.
Using padding only packets for audio dummy start introduces dependencies
on other services and is not a necessary change. Would have been good to
use padding only for audio also from t=0. We can re-visit this for
better compatbility down the line.
2025-10-14 10:05:16 +05:30
cnderrauber
0e2c59c8e4 Sort codec layers when adding track (#3998) 2025-10-14 10:34:52 +08:00
Nishad
100bb46af3 Adding ProviderInfo to GetSIPTrunkAuthenticationResponse (#3993) 2025-10-12 15:40:32 +05:30
Alan Willard
a8d4df66f4 "Power of Two Random Choices" option for node selection (#3785)
* Added optional "Power of Two Random Choices" algorithm for the node selector sort_by feature. The current, default behavior of picking the lowest-valued node remains.
2025-10-08 15:31:01 -07:00
Raja Subramanian
a20bbe34fa Log RPC details. (#3991)
Seeing cases of `ConnectionTimeout` and `ResponseTimeout`.
So, logging destination identity in RPC request and also logging ACK and
response. Will pare back logs/log level of these messages after gettnig
some data.

Also a small change I noticed and had sitting in my local tree to set
the previous RTP marker on a padding packet.
2025-10-09 00:16:56 +05:30
Raja Subramanian
158496bca1 Increment RTP timestamp on padding when using dummy start. (#3989)
* Increment RTP timestamp on padding when using dummy start.

This allows things like egress to have proper sequence to start
the pipeline.

* test
2025-10-07 23:39:51 +05:30
Raja Subramanian
4f6ed65d61 Limit check to red + opus when looking for primary codec match. (#3988)
For codec regression, even if track is encrypted, should be able to fall
back to a backup codec and trigger a regression.
2025-10-07 23:28:26 +05:30
Denys Smirnov
a87f6c4bc8 Allow passing inline trunk for outbound calls. (#3987) 2025-10-07 17:30:14 +03:00
Raja Subramanian
bf06596fcb Support Opus mixed with RED when encrypted. (#3986)
Even when encrypted, can set up opus as the second codec to support the
case of RED interspersed with Opus packets when the RED packet is too
big to fit in one packet.

The change here is to not go through all up stream codecs when trying to
find a match in DownTrack.Bind when source is encrypted. When encrypted,
the down track codec should match the primary upstream codec, i. e. the
codec at index 0.
2025-10-07 16:23:28 +05:30