Commit Graph

1683 Commits

Author SHA1 Message Date
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
David Zhao 0b0431b765 Per-session TURN credentials (#2080)
Switching to using session specific TURN credentials instead of shared
credentials per Room. Also eliminates need to load Room from Redis
during TURN authentication
2023-09-17 10:08:35 -07:00
Raja Subramanian 019ad88b08 Do not force reconnect on resume if there is a pending track (#2081)
* Do not force reconnect on resume if there is a pending track

* move GetPendingTrack -> LocalParticipant
2023-09-17 14:00:09 +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
David Zhao 340906267f Reduce ghost participant disconnect timeout (#2077)
It's been reported that "ghost" participants, those that did not terminate
cleanly, hang around the room for too long after they disappear.

Evaluating our timeouts a bit, it seems that we are really conservative
in waiting for participants to disconnect. This PR cuts down the disconnect
timeout from 50s to 20s, a 30s reduction.
2023-09-16 00:15:04 -07:00
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
David Zhao 2113557842 Skip SendDataPacket logging on transport failure (#2074)
That's a sign of peer connection failure, we do not need to log these
2023-09-15 12:55:54 -07:00
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
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 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 463c62b99a Update deps (#2061) 2023-09-11 22:16:02 +05:30
Raja Subramanian f333ce05ed fix start (#2060) 2023-09-11 20:59:47 +05:30
cnderrauber 696798279e Check destination identites of data message if sid is empty (#2058) 2023-09-11 14:42:48 +08:00
Raja Subramanian be4ea44425 Log ClientInfo on participant close. (#2057)
Want to check client distribution for negotiation failed induced closes.
2023-09-11 10:29:09 +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
Raja Subramanian c09d8d0878 Split RTPStats into receiver and sender. (#2055)
* Split RTPStats into receiver and sender.

For receiver, short types are input and need to calculate extended type.

For sender (subscriber), it can operate only in extended type.
This makes the subscriber side a little simpler and should make it more
efficient as it can do simple comparisons in extended type space.

There was also an issue with subscriber using shorter type and
calculating extended type. When subscriber starts after the publisher
has already rolled over in sequence number OR timestamp, when
subsequent publisher side sender reports are used to adjust subscriber
time stamps, they were out of whack. Using extended type on subscriber
does not face that.

* fix test

* extended types from sequencer

* log
2023-09-11 07:33:39 +05:30
Raja Subramanian b5f2f83278 Fix time stamp adjustment when starting with dummy packets. (#2053)
* Fix time stamp adjustment when starting with dmummy packets.

- Populated extended values in ExtPacket on dummy packet.
- Have to pass reference time stamp offset to first packet time
  adjustment.

* display participant version info
2023-09-09 17:33:26 +05:30
Raja Subramanian d24f409354 Simplify SN cache a bit. (#2052) 2023-09-09 13:00:59 +05:30
David Zhao f351f9b2ed Allow RoomService.SendData to use participant identities (#2051)
* Allow RoomService.SendData to use participant identities

* update protocol

* update webrtc to 3.2.19
2023-09-08 16:22:56 -07:00
Raja Subramanian 492eb3bf18 Sequencer small optimisations (#2049)
* Sequencer small optimisations

1. Use range map to exclude padding only packets. Should take lesser
   space as we are not using slice to hold pointer to actual data.
2. Avoid `time.Now()` when adding each packet. Just use the arrival time
   as it should be close enough. `time.Now()` was showing up in
   profile.

* remove debug

* correct comment
2023-09-08 23:48:54 +05:30
Raja Subramanian 83353d821c Make a config option to skip unmanaged tracks in bandwidth estimation (#2050)
* WIP commit

* Make a config option to skip unmanaged tracks in bandwidth estimation
2023-09-08 20:59:58 +05:30
Raja Subramanian b95670f56b Removing one snapshot in down track. (#2047)
Profiling showed updating jitter going through the snapshot maps.
With the reduction of one, there should only be one snapshot
and hopefully that should gain some cycles back.
2023-09-07 22:22:00 +05:30
Raja Subramanian 3babb432c6 Missed an SN offset update in the previous round (#2044) 2023-09-07 15:58:42 +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 0fffaf3282 Some small optimisations (#2042)
* WIP commit

* WIP commit

* WIP commit

* Revert unintended delete
2023-09-07 13:25:09 +05:30
cnderrauber 75ffb25d77 Parse PortRange of UDPPort from cli flag (#2039) 2023-09-06 14:17:49 +08:00
Trey Hakanson b38b51dad8 Integrate updated TWCC responder (#2038)
Integrates the updated TWCC responder based on `pion/interceptor` from
https://github.com/livekit/mediatransportutil/pull/25
2023-09-06 08:37:52 +05:30
Raja Subramanian c122c20f49 Do not re-pause a paused track. (#2037) 2023-09-06 08:27:16 +05:30
cnderrauber 9b9298b927 Add batch i/o to improve throughput (#2033)
* Add batch i/o to improve throughput

* remove empty line

* Solve comments

* Change rtcconfig.UDPPort to PortRange

* Fix test
2023-09-06 10:18:20 +08:00
Raja Subramanian 1590b96686 Need to set reference layer when starting with dummy packets. (#2034)
Dummy packets are used at start to trigger Pion's OnTrack.
2023-09-05 12:00:00 +05:30
Raja Subramanian e922ae5f23 Filter out noisy error (#2032) 2023-09-04 22:01:07 +05:30
cnderrauber b85ff8f063 Support non-SVC AV1 track publishing (#2030) 2023-09-04 12:39:14 +08:00
David Zhao d6ebc081d5 Use random NodeID instead of MAC based (#2029)
Makes it possible to run multiple instances of livekit-server locally.

Also enables Signal Relay by default as default signal proxy.
2023-09-02 17:36:55 -07:00
Raja Subramanian 6509bb0325 Add option to issue full reconnect on data channel error. (#2026)
* Add option to issue full reconnect on data channel error.

There are situations where send data packet fails because of "stream
closed". It is unclear when that happens. Seems to be after an
ICERestart after ICE failed and connection type switching to TURN
from ICE.

Once the failure happens, it is not recoverable. Potentially, it is
recoverable, but unclear where the problem lies. Attempts to reproduce
looking at the pattern of failures has been unsuccesful.

In the mean time, adding an option to issue full reconnect
when send data packet fails.

* typo
2023-09-01 17:59:25 +05:30
Raja Subramanian b4efbe21a1 Log data channel close and errors. (#2025) 2023-08-31 23:44:11 +05:30
David Zhao d5808f96df Disconnect participant when signal proxy is closed (#2024)
When signal proxy is closed, we'd want to stop writing to it and sever
WS connection with the client. Client would go into a reconnect sequence
2023-08-31 09:39:45 -07:00
Raja Subramanian c7683fd383 Check for sctp.ErrStreamClosed (#2023) 2023-08-31 21:44:19 +05:30
Raja Subramanian bc5b4d68af Do NACKs and reports always. (#2022)
* Do NACKs and reports always.

With padding packet drops, it is possible that a lot of packets
go by without RTCP RR.

Do NACKs and RTCP RR always.

* remove local variable
2023-08-31 12:41:25 +05:30
Raja Subramanian 790954bbe9 Use RTCP SR to resync. (#2021)
Remove packet debug code that was added temporarily.
2023-08-31 11:45:42 +05:30
Raja Subramanian 6e3a20ebf4 Temporary packet debug (#2018) 2023-08-31 00:33:00 +05:30
Raja Subramanian da52167cd9 Adjust extended sequence number to account for dropped packets (#2017) 2023-08-30 23:08:53 +05:30
Raja Subramanian f9b613be41 Log resync data (#2016) 2023-08-30 22:18:27 +05:30
Raja Subramanian 9afb0873ae Do not process packets not processed by RTPStats. (#2015)
Seeing the case of a stream starting with padding packets
on migration. As publisher in that case is always sending packets.
it is possible that the new node gets padding packets at the start.
Processing them in buffer leads to trying to drop that padding packet
and adding an exclusion range. That fails because the extended
sequence number is not available for unprocessed packets.

It is okay to drop them as they will be dropped anyway.
But, they are useful for bandwidth estimation. So, headers are processed
even if the packet is RTPStats unprocessed.
2023-08-30 19:43:24 +05:30