Commit Graph

22 Commits

Author SHA1 Message Date
Raja Subramanian
acbd4ea104 Handle cases of long mute/rollover of time stamp. (#2842)
* Handle cases of long mute/rollover of time stamp.

There are cases where the track is muted for long enough for timestamp
roll over to happen. There are no packets in that window (typically
there should be black frames (for video) or silence (for audio)). But,
maybe the pause based implementation of mute is causing this.

Anyhow, use time since last packet to gauge how much roll over should
have happened and use that to update time stamp. There will be really
edge cases where this could also fail (for e. g. packet time is affected
by propagation delay, so it could theoretically happen that mute/unmute
+ packet reception could happen exactly around that rollover point and
  miscalculate, but should be rare).

As this happen per packet on receive side, changing time to `UnixNano()`
to make it more efficient to check this.

* spelling

* tests

* test util

* tests
2024-07-08 11:07:20 +05:30
Raja Subramanian
ea60368100 Do not error out on invalid packet. (#2789)
Remove the return when encountering invalid packet.
Also, log more sparesely.
Proper error returns from util so that we can selectively drop packets
based on error type, for example SSRC mismatches are okay type of thing.
2024-06-14 11:10:57 +05:30
Raja Subramanian
129ba62d61 Validate RTP packets. (#2778)
* Validate RTP packets.

Check version, payload type (if available) and SSRC (if available)
and drop bad packets. And let repair mechanisms take effect for those
packets.

* address data race reported by test

* fix an unlock and test packets
2024-06-10 15:43:59 +05:30
Raja Subramanian
03bb468472 Log range map for debugging. (#2754)
* Log range map for debugging.

* log details on errors

* log details
2024-06-04 08:00:26 +05:30
cnderrauber
be87a1b6f0 Support rtx for publisher (#2452)
* Support rtx for publisher

* remote log

* solve comment
2024-02-06 21:30:37 +08:00
Raja Subramanian
c62382c76e Clean up restart a bit. (#2247) 2023-11-17 00:40:00 +05:30
Raja Subramanian
33a629065d Fix pre-extended value on wrap back restart. (#2202)
When wrapping back on a restart, was not setting pre-extended
values properly. It was missing a cycle. That caused rare large
sequence number gap.
2023-10-31 01:10: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
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
Raja Subramanian
6c94719487 Cache extended highest. (#2043)
* Cache extended highest.

Prevents calculating extended highest on every update to populate
PreExtendedHighest in the result.

* remove incorrect comment
2023-09-07 14:59:22 +05:30
Raja Subramanian
126872047d Handle duplicate padding packet in the up stream. (#2012)
* Handle duplicate padding packet in the up stream.

The following sequence would have produce incorrect results
- Sequence number 39 - regular packet - offset = 0
- Sequence number 40 - padding only - drop - offset = 1
- Sequence number 40 - padding only duplicate - was not dropped (this is
  the bug) - apply offet - sequence number becomes 39 and clashes with
  previous packet
- Sequence number 41 - regular packet - apply offset - goes through as 40.
- Sequence number 40 again - does not get dropped - will pass through as 39.

* fix duplicate dropping

* fix tests

* accept repeat last value as padding injection could cause that

* use exclusion ranges

* more UT and more specific errors
2023-08-30 16:46:39 +05:30
Raja Subramanian
a48660fa77 Make extended sequence number 64-bit. (#2003) 2023-08-27 21:26:31 +05:30
Raja Subramanian
5a7d095a11 Change one of the tests to 16/64 bit combo (#2002) 2023-08-27 20:18:08 +05:30
Raja Subramanian
3b30f49ad5 Extended type for RTP timestamp. (#2001) 2023-08-27 17:28:44 +05:30
Raja Subramanian
55d5edcf73 Use range map in RTPMunger. (#2000)
* WIP commit

* Make lastSN 32-bit

* Remove unused TSCycles
2023-08-27 10:49:17 +05:30
Raja Subramanian
3c31ae5dc0 Use extended types for sequence number and time stamp in RTPStats. (#1999)
Reinstating this PR - https://github.com/livekit/livekit/pull/1548

Will use extended types in other places too over time.
2023-08-26 22:31:43 +05:30
Raja Subramanian
36dadbacb2 Drop padding only packets on publisher side. (#1990)
* Drop padding only packet on publisher side.

* add UT

* update deps

* remove debug

* add fast path short cut

* correct comment

* fix test

* fix for Linux
2023-08-24 09:09:42 +05:30
Raja Subramanian
480edff4ac Adjust TS and cycles when adjusting start. (#1971)
* Adjust TS and cycles when adjusting start.

Chasing some AddPacket errors across relay.
Noticed that in one case the start/end sequence was flipped.
There is a known issue of it happening with resync.
Unclear if this instance was due to resync or not.
The start was close to the edge (64513). So, thought maybe
adjust at start and noticed that it needs to maybe increase
cycle count if start is wrapping back. In this case, the
start is 1000 before wrap point. So, may not be a wrap back
issue, but addressing what I found anyway.

* fix test
2023-08-16 13:52:01 +05:30
David Zhao
981fb7cac7 Adding license notices (#1913)
* Adding license notices

* remove from config
2023-07-27 16:43:19 -07:00
Raja Subramanian
d9e682a0d2 Fix unwrap (#1729)
* Fix unwrap

An out-or-order packet wrapping back after a wrap around had already happened
 was not using proper cycle ounter to calculate unerapped value.

* update mediatransportutil
2023-05-22 18:46:56 +05:30
Raja Subramanian
69fb5e51a2 Fix stutter in forwarding path when using dependency descriptor (#1600)
* Decode chains

* clean up

* clean up

* decode targets only on publisher side

* comment out supported codecs

* fix test compile

* fix another test compile

* Adding TODO notes

* chainID -> chainIdx

* do not need to check for switch up point when using chains, as long as chain integrity is good, can switch

* more comments

* address comments
2023-04-12 17:30:54 +05:30