Files
livekit/pkg
Raja Subramanian 41fbcec2cd Fix header size calculation in stats. (#3171)
* Fix header size calculation in stats.

With pacer inserting some extensions, the header size used in stats
(and more impoetantly when probing for bandwidth estimation and
metering the bytes to control the probes) was incorrect. The size
was effectively was that of incoming extensions. It would have been
close enough though.

Anyhow, a bit of history
- initially was planning on packaging all the necessary fields into
  pacer packet and pacer would callback after sending, but that was not
  great for a couple of reasons
  - had to send in a bunch of useless data (as far as pacer is
    concerned) into pacer.
  - callback every packet (this is not bad, just a function call which
    happens in the foward path too, but had to lug around the above
    data).
- in the forward path, there is a very edge case issue when calling stats update
  after pacer.Enqueue() - details in https://github.com/livekit/livekit/pull/2085,
  but that is a rare case.

Because of those reasons, the update was placed in the forward path
before enqueue, but did not notice the header size issue till now.

As a compromise, `pacer.Enqueue` returns the headerSize and payloadSize.
It uses a dummy header to calculate size. Real extension will be added
just before sending packet on the wire. pion/rtp replaces extension if
one is already present. So, the dummy would be replaced by the real one
before sending on the wire.
a21194ecfb/packet.go (L398)

This does introduce back the second rare edge case, but that is very
rare and even if it happens, not catastrophic.

* cleanup

* add extensions and dummy as well in downtrack to make pacer cleaner
2024-11-12 10:53:57 +05:30
..
2024-11-04 11:26:41 +05:30
2024-09-18 22:47:33 -07:00