Commit Graph

662 Commits

Author SHA1 Message Date
boks1971 2f9d498ac3 Merge remote-tracking branch 'origin/master' into raja_1833 2023-10-18 22:05:17 +05:30
Raja Subramanian f97242c8ba Use 32-bit time stamp to get reference time stamp on a switch. (#2153)
* Use 32-bit time stamp to get reference time stamp on a switch.

With relay and dyncast and migration, it is possible that different
layers of a simulcast get out of sync in terms of extended type,
i. e. layer 0 could keep running and its timestamp could have
wrapped around and bumped the extended timestamp. But, another layer
could start and stop.

One possible solution is sending the extended timestamp across relay.

But, that breaks down during migration if publisher has started afresh.
Subscriber could still be using extended range.

So, use 32-bit timestamp to infer reference timestamp and patch it with
expected extended time stamp to derive the extended reference.

* use calculated value

* make it test friendly
2023-10-18 21:48:41 +05:30
Raja Subramanian 3e4cd3a161 Accept more range for first packet time adjustment. (#2150) 2023-10-17 23:52:14 +05:30
cnderrauber 53e757fd2c Fix panic on streamtracker_dd (#2147) 2023-10-17 10:37:11 +08:00
boks1971 131b9a1cba Merge remote-tracking branch 'origin/master' into raja_1833 2023-10-16 11:33:21 +05:30
Raja Subramanian 70b60101f4 do the proper large negative check (#2139) 2023-10-10 11:01:49 +05:30
Raja Subramanian 31b042ddce Log larga negative gap. (#2138)
Seeing a large positive gap which I am not able to explain.
Wondering if at some other time, a large negative is happening
and the large positive is just a correction.
2023-10-09 14:32:10 +05:30
Raja Subramanian ebe1470e46 Simplify (#2137) 2023-10-07 13:15:51 +05:30
Raja Subramanian 9fc276481a Increase accuracy of delay since last sender report. (#2136)
It is in 1 / 65536 seconds units. That is about 0.015 ms.
So, use microseconds to increase accuracy.
2023-10-07 12:25:47 +05:30
Raja Subramanian 2ff8fe3b78 Prevent old packets resolution. (#2134)
* Prevent old packets resolution.

With range map, we are just looking up ranges and not exactly
which packets were missing. This caused the case of old packets
being resolved after layer switch.

For example,
- Packet 10 is layer switch, range map gets reset
- Packet 11, 12, 13 are forwarded
- Packet 9 comes, it should ideally be dropped as pre-layer switch old
  packet. But, when looking up range map, it gets an offset and hence
  gets re-mapped to something before layer switch. This was probably
  okay as decoders would have had a key frame at the switch point and
  moved ahead, but incorrect technically.

Fix is to reset the start point in the range map to the switch point
and not 0. So, when packet 9 comes, range map will return "key too old"
error and that packet will be dropped as missing from cache.

* fix tests
2023-10-07 10:56:34 +05:30
Raja Subramanian 4ea284fae0 Log potential sequence number de-sync in receiver reports. (#2128)
* Log potential sequence number de-sync in receicer reports.

Seeing some cases of a roll over being missed. That ends up
as largish range to search in an interval and reports missing packets
in the packet metadata cache.

Logging some details.

* just log in one place
2023-10-05 13:10:13 +05:30
Raja Subramanian 5aa093f65d Log time when there are too many packets. (#2127)
Ideally, can remove the nil return when there are too many packets
as we have more information with extended sequence numbers, but
logging duration first to understand what is happening better.
2023-10-05 12:02:55 +05:30
Raja Subramanian 6c49d1a160 Logging a few bits at Infow (#2126)
Seeing sequencer errors with egress (related to dummy start).
So, logging a few bits at Infow to understand them better.
2023-10-05 11:16:31 +05:30
Raja Subramanian c710ab901e Log stream start at Infow (#2125)
Seeing some sequence number adjustment where timestamp is 0.
Want to check the stream start.
2023-10-05 00:12:41 +05:30
boks1971 4fea2433e2 Merge remote-tracking branch 'origin/master' into raja_1833 2023-10-03 23:04:48 +05:30
Raja Subramanian cb0a48c12d Handle RED extended sequence number. (#2123)
When converting from RED -> Opus, if there is a loss, SFU recovers
that loss if it can using a subsequent redundant packet. That path
was not setting the extended sequence number properly.

Also, ensuring use of monotonic clock for first packet time adjustment
also.
2023-10-03 19:38:55 +05:30
Raja Subramanian 96ccf696d3 Cap expected packets to padding diff. (#2122)
* Cap expected packets to padding diff.

On the receiver, no longer using packet metadata cache to calculate
interval stats. An optimisation to get rid of packet metadata cache
on receiver side.

Because of that, padding packets in an interval could be more than
expected packets. As padding packets is just a counter, out-of-order
padding packets will make the diff look larger than expected packets
in a window. Cap the expected to 0.

NOTE: This makes it so that the count is not accurate in a window,
but that is okay occasionally. It will affect reported stats and quality
calculations, but it should be rare. For example, if 30 packets were
received in a window and 60 out-of-order padding packets were received,
it would reported as 0 packets were received. One option is to not
increment padding packets when they are out-of-order, but that will mess
up overall stats. Will make that change if we see this happen a lot.

* log unexpected padding packets
2023-10-03 12:36:19 +05:30
Raja Subramanian e6e3e2a729 sligtly easier readability (#2121) 2023-10-02 22:47:40 +05:30
Raja Subramanian 989d621c97 A small change to move out of order check before RTT calc. (#2117) 2023-10-02 11:51:46 +05:30
Raja Subramanian 180ad541fc Mark packet not handled if restart is rejected (#2115)
* Mark packet not handled if restart is rejected

* log both sn and ts on restart/rollback
2023-09-30 10:24:13 +05:30
Raja Subramanian ee3a7c01bc Log resync at Infow. (#2114)
* Log resync at Infow.

Seeing potentially large sequence number jumps on a resync.
And it seems to happen on a lot of subscribe/unsubscribe.
Logging at Infow to understand better.

Probably need to find a way to avoid resync. But, logging for now to
check if I can catch one.

* Remove resync and log large sequence number jumps
2023-09-30 08:42:46 +05:30
Raja Subramanian 39d0af4381 Start key frame requester on start. (#2111)
Sending a single PLI on connected & bound meant that the upstream
throttler may not have sent it and down stream does not have a key frame
to lock onto. Caused some e2e test failures due to limited time of
track.
2023-09-28 18:44:48 +05:30
Pingos 4f9467040e Bind() function fails when mime == "audio/red" (#2104) 2023-09-26 13:36:54 +08:00
boks1971 ad3daf97e1 Merge remote-tracking branch 'origin' into raja_1833 2023-09-19 19:59:43 +05:30
Raja Subramanian d0bfb349aa Set packet time for padding packets (#2091) 2023-09-19 19:54:54 +05:30
boks1971 ae60d7456c Merge remote-tracking branch 'origin' into raja_1833 2023-09-19 15:37:32 +05:30
cnderrauber e46da0705a Add max playout delay config (#2089)
* Add max playout delay

* config sample
2023-09-19 11:30:38 +08:00
Raja Subramanian dd2427bf05 Stop writing packets in sysnthesize on track close. (#2086) 2023-09-18 22:25:48 +05:30
boks1971 a1d8b557fc Merge remote-tracking branch 'origin/master' into raja_1833 2023-09-18 18:46:48 +05:30
Raja Subramanian e0d98eebb6 Do stats update in line. (#2085) 2023-09-18 18:42:39 +05:30
boks1971 510af76c0d Merge remote-tracking branch 'origin/master' into raja_1833 2023-09-18 10:19:41 +05:30
Raja Subramanian ca2f8fedab Fix out-of-range access. (#2082)
Happens when converting quality in subscibed settings to layer.
Looks like it can happen only if the provided quality is OFF.
Don't know of any client that does that. Anyhow, prevent out-of-range
access which causea a panic.
2023-09-18 10:03:22 +05:30
boks1971 057908abbf Merge remote-tracking branch 'origin/master' into raja_1833 2023-09-18 09:36:05 +05:30
Raja Subramanian 97048a923c Reducing rtp stats memory consumption - part 2 (#2078)
* WIP commit

* move a struct to sender only

* Snapshot intervals

* make receiver history 4K too
2023-09-16 18:54:18 +05:30
Raja Subramanian f29887dcd0 Use bit map. (#2075)
* Use bit map.

Also, duplicate packet detection is impoetant for dropping padding
only packets at the publisher side itself. In the last PR, mentioned
that it is only for stats.

* clean up

* Update deps
2023-09-16 02:03:50 +05:30
Raja Subramanian 9c2ad54146 Clean up debug logs (#2076) 2023-09-16 01:57:34 +05:30
Raja Subramanian 044f6cec40 Reduce packet meta data cache - part 1 (#2073)
* Reduce packet meta data cache - part 1

Packet meta data cache takes a good amount of space.
That cache is 8K entries deep and each entry is 8 bytes.
So, that takes 64KB per RTP stream.

It is mostly needed for down stream to line up with receiver reports.

So, removing cache from up stream (RTPStatsReceiver) as part 1.
Will look at optimising the down stream in part 2.

* Remove caching from RTPStatsReceiver

* clean up a bit more

* maintain history and fix test
2023-09-15 21:39:03 +05:30
boks1971 dee6c161f8 Merge remote-tracking branch 'origin/master' into raja_1833 2023-09-15 13:14:56 +05:30
Raja Subramanian 7ac0abdf1b Decrement value when end is in open range. (#2072)
* Decrement value when end is in open range.

Not an error when end is in open range.

* change API call
2023-09-14 14:31:39 +05:30
Raja Subramanian 69177b8b6e Debug logs to check on sequencer missing offset. (#2071)
* Debug logs to check on sequencer missing offset.

* spelling

* close range on value decrement
2023-09-14 12:20:33 +05:30
boks1971 c5ba99f335 Merge remote-tracking branch 'origin/master' into raja_1833 2023-09-13 21:23:52 +05:30
Raja Subramanian 68aebb0106 Do not mute when stream is paused. (#2069) 2023-09-13 19:59:24 +05:30
Raja Subramanian a55c50f61d Throttle packet errors/warns a bit. (#2068)
* Throttle packet errors/warns a bit.

In very bad network conditions, it is possible that packets
arrive out-of-order, have choppy behaviour.

Use some counters and temper logs.

* slight change in comment
2023-09-13 15:52:10 +05:30
Raja Subramanian 3f9f3adf91 Fix init. (#2067)
Stupid me.
2023-09-13 12:53:16 +05:30
Raja Subramanian 2cf751d261 Use timer in scorer lock scope. (#2066)
Using time from outside make anachronous samples in expected
distance/bit rate measurement. So, have to let the time be
snap shotted in scorer lock scope.
2023-09-13 01:38:34 +05:30
Raja Subramanian 5f701ece34 Include top bits from start in highest sequence number from RR. (#2064)
Streaming could start after 16-bits has rolled over. So, have to add
that base back to what is received in receiver report.

Otherwise, it looks like there are not packets received in window
leading to poor quality.
2023-09-12 14:36:25 +05:30
Raja Subramanian 254a35543d Fix down stream stats. (#2063)
Need to pass in the correct time. Previously streaming start was
determined by another delta snap shot which as removed for efficiency.
Did not realise that we were passing in zero time for stats.

Also, revert of the change (the part which did not re-pause) from this
PR (https://github.com/livekit/livekit/pull/2037). That change affects
other paths. The edge it was trying to fix is more rare. Need to think
about a way which covers all cases.
2023-09-12 08:34:28 +05:30
Raja Subramanian f333ce05ed fix start (#2060) 2023-09-11 20:59:47 +05:30
boks1971 e8e444fd64 Merge remote-tracking branch 'origin/master' into raja_1833 2023-09-11 08:42:20 +05:30
Raja Subramanian 1b20b8f1ac Make interface for connection stats. (#2056)
* Make interface for connection stats.

Implement suggestion from @paulwe to clean that up a bit.

* fix test
2023-09-11 08:39:33 +05:30