66 Commits
Author SHA1 Message Date
Raja SubramanianandGitHub 1bbd4702b6 Spelling fixes (#4698) 2026-07-26 22:26:41 +05:30
Raja SubramanianandGitHub c4fd71a5dd Fix sense check in DeltaInfo gathering (#4507) 2026-05-06 13:34:26 +05:30
Raja SubramanianandGitHub c1ad2b22e6 Misc optimisations. (#4490)
- prevent some escape to heap
- avoid copying by using a ring buffer for receiver reports (probably
  should remove this as this is for debugging only and data so far has
  shown clients sending bad data and nothing more.)
2026-04-28 20:51:04 +05:30
David ZhaoandGitHub 4b3856125c chore: pin GH commits and switch to golangci-lint (#4444)
* chore: pin GH commits

* switch to golangci-lint-action

* fix lint issues
2026-04-11 13:04:22 -07:00
Raja SubramanianandGitHub 9674ac48ab Cleaning up some logs and standardising log frequency. (#4420)
Removing some logs which have not been useful in terms of insights other
than saying that there are a bunch of packets missing. Going to start
looking at gaps in terms of time if the inter-packet gap is too high.

Also, using logging these events as first 20 and then every 200.
2026-04-01 21:17:43 +05:30
Raja SubramanianandGitHub 248d73948d Guard against timestamp inversion in RED -> Opus conversion. (#4414)
* Guard against timestamp inversion in RED -> Opus conversion.

Seeing timestamp inversion (sequence number is +1, but timestamp is
-960, i.e. 20ms) in the RED -> Opus conversion path. Not able to spot
any bugs in code. So, logging details upon detection and also dropping
the packet. If not dropped, downstream components like Egress treat it
as a big timestamp jump (because sequence number is moving forward) and
try to adjust pts which ends up causing drops.

* do not log time reversal at the start

* typo
2026-03-31 17:08:13 +05:30
Raja SubramanianandGitHub 34bd1e0851 do not log roll over for padding only packets (#4396)
* do not log roll over for padding only packets

* calculated expected earlier
2026-03-26 11:47:29 +05:30
Raja SubramanianandGitHub bab9186840 do not discount packets lost on duplicate packets (#4333) 2026-02-23 23:55:56 +05:30
Raja SubramanianandGitHub 35d7ef88c2 Avoid alloc in RTPStatsReceiver.Update (#4302)
Using a pointer to the logging context was doing allocations.
2026-02-09 11:53:17 +05:30
Raja SubramanianandGitHub bb744916fd More optimisation in RTPStats module. (#4298)
Was hoping for more hidden bits to optimise, but oh well.
2026-02-06 21:33:41 +05:30
Raja SubramanianandGitHub cefd5da940 Optimise some bits in rtpstats_receiver (#4297)
* Optimise some bits in rtpstats_receiver

RTPStatsReceiver.Update is one of the high CPU bits. Taking some
suggestions from Cursor. Makes the `Update` function verbose though :-(

* zap.Inline logging fields

* rename
2026-02-06 21:26:30 +05:30
Raja SubramanianandGitHub 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
Raja SubramanianandGitHub 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
Raja SubramanianandGitHub 3606ce542f Do not warn about track not bound if participant is not ready. (#4205)
Analysed half a dozen cases and all of them were due to participant is
not active yet.

Also, some misc logging changes.
2025-12-29 18:16:11 +05:30
Raja SubramanianandGitHub b8ddd0f98c Taking interface{} -> any modernize bits (#4204) 2025-12-28 05:22:12 +05:30
Raja SubramanianandGitHub 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 SubramanianandGitHub fb849edc6a Minor clean up (#4172) 2025-12-18 08:46:40 +05:30
Raja SubramanianandGitHub 47324abd0e Drop run away receiver reports. (#4170) 2025-12-17 21:58:47 +05:30
Paul WellsandGitHub 462ec324be prevent uint overflow setting packet not found count (#4169) 2025-12-17 06:54:23 -08:00
Paul WellsandGitHub 2f2d0a5735 skip lost sequence number ranges in getIntervalStats (#4166) 2025-12-17 00:02:51 -08:00
Raja SubramanianandGitHub 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 SubramanianandGitHub 97aba5e77b Consistently undo update to sequence number and timestamp when the (#4156)
incoming packet cannot be sequenced.
2025-12-13 15:46:04 +05:30
Raja SubramanianandGitHub 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
changgesiandGitHub 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
cnderrauberandGitHub fa0633aa3e move utils.WrapAround to mediatransportutil (#4124) 2025-12-04 17:45:11 +08:00
Raja SubramanianandGitHub 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 SubramanianandGitHub 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 SubramanianandGitHub 5a426d15e1 Use rtp converter from protocol/utils (#4019) 2025-10-22 14:09:33 +05:30
Raja SubramanianandGitHub 3bd20ddb28 Revert unintentional change to not handle transport fallback on (#3970)
publisher peer connection.

While cleaning up during single peer connection changes, unintentionally
removed handler.

Also, another small change to log first packet time adjustment after
increment.
2025-09-30 10:24:26 +05:30
Raja SubramanianandGitHub 735c663adc Update protocol for EventKey helper. (#3963) 2025-09-29 11:42:18 +05:30
Raja SubramanianandGitHub 00ff2ab941 Adjust for hold time when fowarding RTCP report. (#3956)
* Adjust for hold time when fowarding RTCP report.

When passing through RTCP sender report, holding it for some time before
sending means the remote receiver could see varying amount of
propagation delay if the remote uses something like local_clock -
ntp_sender_report_time and adapting to it.

Ideally, SFU should just forward RTCP Sender Report, but the current pull model to
group RTCP sender reports makes it a bigger change. So, adjust it by
hold time.

Also add a initial condition for one-way-delay estimator which can init
with a smaller value of latency if the first sample to measure
one-way-delay itself experienced higher delay than the prevailing
conditions.

* variable name

* log as duration
2025-09-26 18:57:21 +05:30
Raja SubramanianandGitHub c823320528 Add a key frame seeder in up track. (#3524) 2025-03-12 22:11:27 +05:30
Raja SubramanianandGitHub 05dfd30d5b Take RTT and jitter from receiver view while reporting track stats for (#3483)
* Take RTT and jitter from receiver view while reporting track stats for
down stream tracks.

* adjust jitter in aggregate
2025-03-03 18:48:37 +05:30
Raja SubramanianandGitHub 83a839811c Transfer metadata cache over flow counter. (#3472)
* Transfer metadata cache over flow coutner.

Without that, logging was not getting sampled.

* sender
2025-02-27 11:21:11 +05:30
Raja SubramanianandGitHub ca4526048c structured logging (#3461) 2025-02-24 11:47:35 +05:30
Raja SubramanianandGitHub b3da3ff2cb Give more cache for RTX. (#3438)
- With probing the packet rate can get high suddenly and remote may not
  have sent receiver report as it might be sending for the non-spikey
  rate. That causes metadata cache overflows. So, give RTX more cahe.
- Don't need a large cache for primary as either reports come in
  regularly (or they are missing for a long time and having a biger
  cache is not the solution for that, so reduce primary cache size)
- Check for receiver report falling exactly back by (1 << 16). Had done
  that change in the inside for loop, but missed the top level check :-(
2025-02-15 22:43:28 +05:30
Raja SubramanianandGitHub 9fd80c8919 Catch up if the diff is exactly (1 << 16) also. (#3433) 2025-02-14 12:50:52 +05:30
Raja SubramanianandGitHub f160f6200a Do not log no packets in delta. (#3427)
Can happen a lot with dynacast layer turn off.
2025-02-13 11:25:57 +05:30
Raja SubramanianandGitHub 7fef374b19 Split down stream snapshot into sender view and receiver view. (#3422)
Receiver view is used for connection quality.

Sender view is used for analytics. One thing that this introduces is
that sender view uses the packet loss information from receiver view as
true loss is available only in the RTCP Receiver Reports received from
the remote side. So, the time alignment is off, i. e. receiver report
happens periodically and it includes information till the time at which
it was sent from remote side, but sender could have sent more packets
after that time.

The split should ensure that analytics does not rely on remote side
sending proper receiver repoerts albeit at slight misalignment of loss
statistic for remotes that send RTCP RR (which should be majority of the
cases)
2025-02-11 16:05:00 +05:30
Raja SubramanianandGitHub 7ff4082e4a Do not skip due to large RR interval. (#3398)
* Do not skip due to large RR interval.

With sequence number adjustment, it will report some packets missing
which is fine.

* do not seed if already initialized
2025-02-04 11:08:38 +05:30
Raja SubramanianandGitHub f45e3613ac Correct reason for poor/lost score. (#3397)
No functional change, just logging reason was confusing.
Also, log no packets case. Seeing some instances in staging where there
are periods of no packets received. Trying to understand better.
2025-02-04 00:59:56 +05:30
Raja SubramanianandGitHub 2f758d49ce Adjust receiver report sequence number to be within range of highest. (#3396) 2025-02-03 21:58:26 +05:30
Raja SubramanianandGitHub 92e3f2e3d0 Starting on padding for RTX stream is accepted. (#3390) 2025-02-02 20:26:30 +05:30
Raja SubramanianandGitHub 20b400faef Use signed check on rollback. (#3389) 2025-02-01 14:16:53 +05:30
Raja SubramanianandGitHub adc2246353 Move sequence number adjustment to when out-of-order is detected (#3387)
initially.

Out-of-order reception is detected and dropped before this change. By
moving the adjustment to that point, potentially more reports can be
processed.
2025-01-31 11:56:48 +05:30
Raja SubramanianandGitHub 2b5ee12f9b Reduce chances of metadata cache overflow. (#3369) 2025-01-27 18:14:57 +05:30
Raja SubramanianandGitHub 043464828a Correct off-by-one lost count on a restart. (#3337)
* Correct off-by-one lost count on a restart.

* log sender snap shot ID

* metadata cache overflow count per snapshot
2025-01-16 23:41:41 +05:30
Raja SubramanianandGitHub 53d300ba71 Use nano time for easier (and hopefully) faster checks/calculations. (#3323) 2025-01-12 00:56:46 +05:30
Raja SubramanianandGitHub bfbc4fa81f Remove alloc in packet forwarding path. (#3305)
* Remove alloc in packet forwarding path.

Unlikely logger creation was doing allocs. Replace it with a function
like in rtpstats_receiver.go so that allocations do not happen
unnecessarily.

* variable rename

* one more place
2025-01-06 11:48:27 +05:30
Raja SubramanianandGitHub cfe3178542 Reconcile RTP stats with RTX data. (#3252)
* RTX RTPStats

* WIP

* RTCP RTX handler

* reconcile rtx

* cache size

* clean up

* test

* clean up
2024-12-15 14:33:02 +05:30