Commit Graph

471 Commits

Author SHA1 Message Date
Raja Subramanian
370e0a4d52 Set up audio config in audio level module when config is updated. (#4290)
* Set up audio config in audio level module when config is updated.

It is possible to get audio config after bind (bind is where the audio
level module is created) for remote tracks. So, split out setting audio
level config in audio level module and invoke it when config is updated.

* coderabbit review

* prevent divide-by-0

* not active before config
2026-02-05 09:35:26 +05:30
Raja Subramanian
a9849340c3 Avoid logger data race. (#4284)
Also defer promise channel close.
2026-02-04 01:35:44 +05:30
Raja Subramanian
1e689e1a24 Reducing some info level logs. (#4274)
* Reducing some info level logs.

Also, relaxing the check for runaway RTCP receiver report to allow for
rollover to catch up if it is not too far away.

* set logger
2026-02-02 10:54:03 +05:30
Anunay Maheshwari
0c33b8c671 chore: move codecs/mime stuff to protocol (#4255) 2026-01-20 20:54:32 +05:30
Raja Subramanian
aea044c5cb Defer setting clock rate in RTPStats module till codec is bound. (#4250)
With audio simulcast codecs, it is possible that the clock rate of the
primary codec is different from the secondary codec. If a subscriber
binds to the secondary codec, the clock rate should be set correctly. Do
it at bind time.
2026-01-15 22:08:50 +05:30
Denys Smirnov
843d8c3ea1 Update Pion transport package. (#4237)
* Update Pion transport package.

* Update mediatransportutil package.
2026-01-13 19:56:41 +02:00
Raja Subramanian
7fae5ac9e6 Do not restart receiver on codec change mid-session. (#4225)
* Do not restart receiver on codec change mid-session.

This is not supported and was an erroneous change during the
receiver_base/buffer_base + RTP stream restart consolidation. Also make
the codec munger creation more resilient.

* fix test
2026-01-08 02:35:32 +05:30
Raja Subramanian
80ba93fa18 Do NACK updates as soon as flow state is processed. (#4221) 2026-01-06 11:59:21 +05:30
Raja Subramanian
46651c1978 Release v1.9.10 (#4214)
* Release v1.9.10

* move room exists service store op to Added section
2026-01-01 12:36:34 +05:30
Raja Subramanian
08ac4ecdc5 Support preserving external supplied time. (#4212)
In some paths, it is better to preserve pre-recorded time. So, make the
base implementations preserve the RTCP Sender Report receive time.

Also, add a method to enable forwarding packet arrival time. Could be
used across relay.
2025-12-31 14:41:59 +05:30
Raja Subramanian
1a4758ed9c Skip restart callback if external. (#4208)
* Skip restart callback if external.

Without out the external restart was bumping forwarder generation twice.

* fix sense
2025-12-30 22:14:06 +05:30
Raja Subramanian
dde4fb498e configurable dependency descriptor restart (#4207)
* configurable dependency descriptor restart

* KeyFrame -> IsKeyFrame

* use the params directly
2025-12-29 23:51:15 +05:30
Raja Subramanian
b91cd2e4ea Rework receiver restart. (#4202)
* Rework receiver restart.

- Protect against concurrent restarts
- Clean up and consolidate code around restarts
- Use `RestartStream` of buffer rather than creating new buffers.

* fix test
2025-12-27 17:17:16 +05:30
Raja Subramanian
25ece1e911 Minor refactor in buffer base and audio level (#4198)
* Minor refactor in buffer base and audio level

- Make a function for `restartStream`. Will be useful
  when external signal needs to restart a stream. Also restart all the
  bits (audio level, dd parser and frame rate calculator)
- make an audio level mode with RTP timestamp so that some state can be
  moved out of buffer base

* clean up

* log restart
2025-12-26 20:13:38 +05:30
Raja Subramanian
599002f890 ignore PLI requests for non-video (#4196)
* ignore PLI requests for non-video

* under lock
2025-12-26 12:26:22 +05:30
Raja Subramanian
2510b9462e Taking a bunch of go modernize suggestions. (#4194)
This is not all of it as it is not possible (or at least I do not know
of a way) to get all suggestions for a repo/project. Did this via loop
searching mainly and taking the modernize suggestions.
2025-12-25 16:55:58 +05:30
Raja Subramanian
ed8e6afcd7 Handle repair SSRC of simulcast tracks during migration. (#4193)
* Handle repair SSRC of simulcast tracks during migration.

* fix

* fix comment
2025-12-25 14:45:48 +05:30
Raja Subramanian
c6bf7a2786 Fix logging key and other clean up around stream restart. (#4192) 2025-12-24 22:48:25 +05:30
Raja Subramanian
381bce03ae Return extended sequence number only and not packet. (#4189)
* Return extended sequence number only and not packet.

Callers need only the extended sequence number.
Extended packet could get release if the forwarder processes it before
caller accesses it causing a data race.

* grow bucket in a go routine
2025-12-24 10:44:56 +05:30
Raja Subramanian
6bcbf54ea1 Always instantiate nacker when using out-of-band sequence numbers. (#4187) 2025-12-24 04:10:11 +05:30
Raja Subramanian
e71184dea0 Store buffer after creating it. (#4186)
* Refactor receiver and buffer into Base and higher layer.

To be able to share code/functionality with relay.

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* clean up

* deps

* fix test

* fix test

* Store buffer after creating it.

Also changing signature of creator function as it could call TrackInfo()
and get into a deadlock.

* fix double unlock

* add some more debug logging
2025-12-24 02:55:51 +05:30
Raja Subramanian
7c8ea11505 Refactor receiver and buffer into Base and higher layer. (#4185)
* Refactor receiver and buffer into Base and higher layer.

To be able to share code/functionality with relay.

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* clean up

* deps

* fix test

* fix test
2025-12-23 21:35:48 +05:30
Raja Subramanian
32cd0370c7 Flush the ext packets on restart/close and release packets. (#4179) 2025-12-19 20:25:22 +05:30
Raja Subramanian
a26c48304a Add support for RTP stream restart. (#4161)
* Add support for RTP stream restart.

When an unhandled packet is encountered, try a restart sequence.
Restart happens when 5 packets with contiguous sequence numbers and same
or increasing time stamps are received. Note that this does not work for
B-frame type of scenarios, but that is true for receive path handling
even before this. As WebRTC does not use B-frames, it is fine. But,
needs to be looked at again if B-frames are necessary.

It is controlled by a config that is disabled by default.

* clean up

* debug log
2025-12-16 13:21:39 +05:30
Raja Subramanian
ca4b56d2d5 Handle case of sequence number jump just after start. (#4150)
It is possible that the stream stops just after start and
restarts much later introducing a large gap in sequence number.
That could look like an unhandled case because the wrap back handler
does not have enough packets yet.

Let other checks based on time stamp gap take effect and only if that
also leaves the sequence number unhandled, drop the packet.
2025-12-12 00:29:15 +05:30
changgesi
d7db7cb389 chore: fix a large number of spelling issues (#4147)
Signed-off-by: changgesi <changgesi@outlook.com>
2025-12-11 09:34:13 +05:30
Raja Subramanian
498304cdd9 defensive nil check (#4144) 2025-12-10 13:33:08 +05:30
Raja Subramanian
20f6a49780 Store ddParser in atomic.Pointer (#4143)
* Store ddParser in atomic.Pointer

as release is handled outside lock

* log space

* make non-struct methods to release packets
2025-12-10 13:01:17 +05:30
Raja Subramanian
037cb9062f release ext packet if patching fails (#4142) 2025-12-10 12:09:49 +05:30
Raja Subramanian
dd598ef23f Release ExtPacket if dependency descriptor or other parsing fails (#4141) 2025-12-10 11:05:19 +05:30
Raja Subramanian
1c1a836c3c Mark RTCP buffer Write as noinline. (#4138)
Seeing a bunch of objects in ReadStreamSRTP.write which does not make
a lot of sense as the function does not allocate anything
(8fe528a0c4/stream_srtp.go (L68-L77))

RTP buffer was marked noinline in an easrlier PR.
Marking RTCP buffer write also as noinline to check if heap reporting
changes.
2025-12-08 22:30:30 +05:30
Raja Subramanian
64f3d1e972 switch participant callbacks to room to listener interface (#4136)
* switch participant callbacks to room to listener interface

* mage generate

* clean up

* clear listener

* clean up

* use interface in up data track manager

* tweaks

* Paul feedback - should reduce the diff as this keeps the room handlers as is except making methods for a couple of anonymous handlers

* clean up
2025-12-08 15:59:45 +05:30
Raja Subramanian
3eef869a68 Do not pause rid in SDP (#4129) 2025-12-05 15:57:31 +05:30
cnderrauber
fa0633aa3e move utils.WrapAround to mediatransportutil (#4124) 2025-12-04 17:45:11 +08:00
Raja Subramanian
7954748d7a Data tracks (#4089)
* WIP

* WIP

* Starting to add some signalling integration testing.

* Working tests.

* fix tests

* Forward data packets (#4096)

* WIP commit

* WIP

* WIP

* fix forwarding

* address PR comments

* move some methods from LocalParticipant to Participant interface

* handle subscription update

* add extensions and tests

* more packet tests

* add test for replace extension and fix a bug

* update protocol and add config
2025-12-04 10:44:34 +05:30
Raja Subramanian
7158d98366 log bucket growth (#4122) 2025-12-03 18:48:02 +05:30
Raja Subramanian
64c651431e Update mediatransportutil (#4115)
- New bucket API to pass in max packet size and sequence number offset
  and seequence number size generic type
- Move OWD estimator to mediatransportutil.
2025-11-28 21:51:53 +05:30
Raja Subramanian
c3964ba2eb Use sync.Pool for objects in packet path. (#4066)
* Use sync.Pool for objects in packet path.

Seeing cases of forwarding latency spikes that aling with GC.

This might be a bit overkill, but using sync.Pool for small +
short-lived objects in packet path.

Before this, all these were increasing in alloc_space heap profile
samples over time. With these, there is no increase (actually the lines
corresponding to geting from pool does not even show up in heap
accounting when doing `list` in `pprof`)

* merge

* Paul feedback
2025-11-14 16:13:23 +05:30
Raja Subramanian
1dc9b8fc5c Use buffered indicator to exclude from forwarding latency. (#4062)
* Debug high forwarding latency missing.

* log highest

* log condition

* update log

* log

* log

* change log

* Track start up delay.

Digging into forwarding latency, there are a few things
1. Seems to be caused due to forwarding packets queued before bind. They
   would be in the queue till bind. There are two ways it is showing up
   a. Bind itself is delayed and releasing queued packets causes the
      high forwarding latency.
   b. There is a significant gap between bind and first packet being
      pulled off the queue to be forwarded, in one example 100ms.

(a) is understandable if the signalling delays things. Can drop these
packets without forwarding or indicate in the packet that it is a queued
packet and drop it from forwarding latency calculation. Dropping is
probably better as down stream components like egress will see a burst
in these situations.

(b) looks like go scheduling latency? Unsure.

Logging more to understand this better.

* log start

* Use buffered indicator to exclude from forwarding latency.

Buffered packets live the queue for a while before Bind releases them.
They have high(ish) queuing latency and not true representation of
forwarding latency.
2025-11-07 21:46:14 +05:30
Raja Subramanian
f117ee511f Track start up delay. (#4061)
* Debug high forwarding latency missing.

* log highest

* log condition

* update log

* log

* log

* change log

* Track start up delay.

Digging into forwarding latency, there are a few things
1. Seems to be caused due to forwarding packets queued before bind. They
   would be in the queue till bind. There are two ways it is showing up
   a. Bind itself is delayed and releasing queued packets causes the
      high forwarding latency.
   b. There is a significant gap between bind and first packet being
      pulled off the queue to be forwarded, in one example 100ms.

(a) is understandable if the signalling delays things. Can drop these
packets without forwarding or indicate in the packet that it is a queued
packet and drop it from forwarding latency calculation. Dropping is
probably better as down stream components like egress will see a burst
in these situations.

(b) looks like go scheduling latency? Unsure.

Logging more to understand this better.

* log start
2025-11-07 16:55:18 +05:30
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
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
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
b07e7a3828 Use difference in key frame counter to stop seeder. (#3936)
The key frame seeder could be started multiple times.
Use difference to detect stop condition.
2025-09-19 15:15:26 +05:30
Raja Subramanian
56fb28858a Do DD restart only if DD structure is present. (#3935) 2025-09-19 02:39:08 +05:30
Raja Subramanian
86facce9f4 More debugging of DD jump (#3934) 2025-09-19 01:29:28 +05:30
Raja Subramanian
6058a3f622 Add debugging from DD frame number wrap around. (#3933)
* Add debugging from DD frame number wrap around.

On a DD parser restart, the extended highest sequence number oes not
seem to be updated. Adding some debug to understand it better.

* more logs

* log incoming sequence number and frame number
2025-09-19 00:17:45 +05:30
Raja Subramanian
6489237e33 Simulcast audio fixes (#3925)
* Simulcast audio fixes

* clean up
2025-09-14 09:41:40 +05:30
cnderrauber
5026de2bea handle frame number wrap back in svc (#3885)
* handle frame number wrap back in svc

* Add Slack Notifier

* check nil dd ext

* log format
2025-08-29 17:11:49 +08:00