Commit Graph

42 Commits

Author SHA1 Message Date
David Zhao
98c81b92bb Helper function to remove address from ClientInfo (#2288) 2023-12-03 10:48:33 -08:00
David Zhao
3fe124c87f Log cleanup pass (#2285)
* Log cleanup pass

Demoted a bunch of logs to DEBUG, consolidated logs.

* use context logger and fix context var usage

* moved common error types, fixed tests
2023-12-02 15:07:31 -08:00
David Zhao
debd75fa15 Integrate logger components (#1933)
* Integrate logger components

Dividing into the following components
* pub - publisher
* pub.sfu
* sub - subscriber
* transport
* transport.pion
* transport.cc
* api
* webhook

* update go modules
2023-08-03 13:31:17 -07:00
David Zhao
981fb7cac7 Adding license notices (#1913)
* Adding license notices

* remove from config
2023-07-27 16:43:19 -07:00
shishirng
2e93d386fe send min/median connection score along with avg (#1720)
* send min/median connection score along with avg
* guard against divide by zero for avg score calculation
* update median calculation

Signed-off-by: shishir gowda <shishir@livekit.io>
2023-05-18 13:50:54 -04:00
Paul Wells
b35d64ae86 finish timed version migration (#1443)
* finish timed version migration

* update protocol dep
2023-02-18 12:08:08 -08:00
Raja Subramanian
9f94fc8347 Callback support for migrate state change. (#1435)
This can be used to detect changes in migrate state and signal
migration completion to remote nodes.
2023-02-17 13:13:01 +05:30
Paul Wells
24d8ad0da9 add compare function to timedversion (#1422)
* add compare function to timedversion

* cleanup
2023-02-14 21:05:55 -08:00
David Zhao
2fa46e2df4 Retry initial connection attempt should it fail (#1335)
Sometimes the initial selected node could fail. In that case, we'll give it a few more attempts to locate a media node for the session instead of failing it after the first try.
2023-01-25 22:59:57 -08:00
David Zhao
cd6b8b80b9 feat: SubscriptionManager to consolidate subscription handling (#1317)
Added a new manager to handle all subscription needs. Implemented using reconciler pattern. The goals are:

improve subscription resilience by separating desired state and current state
reduce complexity of synchronous processing
better detect failures with the ability to trigger full reconnect
2023-01-24 23:06:16 -08:00
David Zhao
732309a8c1 Added track success & muted events (#1308)
Related to livekit/protocol#273

This PR adds:
- ParticipantResumed - for when ICE restart or migration had occurred
- TrackPublishRequested - when we initiate a publication
- TrackSubscribeRequested - when we initiate a subscription
- TrackMuted - publisher muted track
- TrackUnmuted - publisher unmuted track
- TrackPublish/TrackSubcribe events will indicate when those actions have been successful, to differentiate.
2023-01-15 15:40:20 -08:00
David Zhao
17236799bb Fix handling of non-monotonic timestamps (#1304)
* Fix handling of non-monotonic timestamps

Timed version is inspired by Hybrid Clock. We used to have a mixed behavior
by using time.Time:
* during local comparisons, it does increment monotonically
* when deserializing remote timestamps, we lose that attribute

So it's possible for two requests to be sent in the same microsecond, and
for the latter one to be dropped.

To fix that behavior, I'm switching it to keeping timestamps to consolidate
that behavior, and accepting multiple updates in the same ms by incrementing ticks.

Also using @paulwe's idea of a version generator.
2023-01-12 11:57:26 -08:00
Raja Subramanian
d76f7811e9 An attempt to use consistent layer mapping (#986)
* WIP commit

* Consistent layers.

* slight re-arrangement of code

* log mime

* fix tests

* map -> array
2022-09-07 09:57:31 +05:30
Raja Subramanian
51073e8918 Use TimedVersion for subscription permission update (#839)
* Use a read version for subscription permission

* Use TimedVersion for subscription permission updates

* Minor clean up

* latest protocol
2022-07-21 08:52:37 +05:30
Raja Subramanian
9032db857c Connection quality clean up (#766)
* WIP commit

* WIP commit

* Remove debug

* Revert to reduce diff

* Fix tests

* Determine spatial layer from track info quality if non-simulcast

* Adjust for invalid layer on no rid, previously that function was returning 0 for no rid case

* Fall back to top level width/height if there are no layers

* Use duration from RTPDeltaInfo
2022-06-18 21:58:47 +05:30
shishirng
cb9f0d37c2 Use rtcscore-go to calculate audio/video score (#689)
* Use rtcscore-go to calculate audio/video score

Signed-off-by: shishir gowda <shishir@livekit.io>

* Get max expected layer and find max actual layer from stream

Signed-off-by: shishir gowda <shishir@livekit.io>

* Cleanup unused methods

Signed-off-by: shishir gowda <shishir@livekit.io>

* Cleanup code - address review comments

Signed-off-by: shishir gowda <shishir@livekit.io>

* get expected layer info instead of just quality

Signed-off-by: shishir gowda <shishir@livekit.io>

* Move SpatialLayerForQuality to utils/helpers

method is required in rtc,sfu and connectionstats pkg
Moved to utils/helpers.go to remove cyclic deps

Signed-off-by: shishir gowda <shishir@livekit.io>

* update tests

Signed-off-by: shishir gowda <shishir@livekit.io>

* Pick stream stats with max layer

Signed-off-by: shishir gowda <shishir@livekit.io>

* Update rtcscore-go pkg to make rtt/jitter optional

when passing 0, rtcscore-go was setting default values

Signed-off-by: shishir gowda <shishir@livekit.io>

* update score to rating

Signed-off-by: shishir gowda <shishir@livekit.io>

* Update rtcscore-go pkg to use simulcast layer info for score

Signed-off-by: shishir gowda <shishir@livekit.io>

* Update score ratings to reflect rtcscore range

Signed-off-by: shishir gowda <shishir@livekit.io>

* update test params for new rtcscore

Signed-off-by: shishir gowda <shishir@livekit.io>

* Delay sending scores to connections only till full data is available

first interval can have partial data leading to lower scores

Signed-off-by: shishir gowda <shishir@livekit.io>

* Check for inf values in quality params

Signed-off-by: shishir gowda <shishir@livekit.io>

* Clean up initial score calculation. Default to 5

Signed-off-by: shishir gowda <shishir@livekit.io>

Co-authored-by: David Zhao <dz@livekit.io>
2022-05-27 14:58:26 -04:00
Raja Subramanian
d38566850a Do not post close callback in ops queue if not started. (#649)
* Do not post close callback in ops queue if not started.

Ops queue is started in `Bind()`. If `Close()` is called
when bind did not happen (because the underlying peer connection
closed before bind), the close callback does not run.

Check if ops queue is running before posting close callback
into the queue.

Not pretty, but covers this case. Need to think about it more.

* correct check
2022-04-24 11:40:22 +05:30
Raja Subramanian
e138ef3f55 Use error level to get some back trace (#625) 2022-04-19 13:06:47 +05:30
Raja Subramanian
a98d955284 Delta stats throughout (#615)
* Use delta stats throughout and avoid calculating deltas in telemetry

* Fix a few things after testing

* Remove debug

* Fix tests

* delete instead of setting to nil

* Point to the latest protocol
2022-04-16 21:11:32 +05:30
Raja Subramanian
c743d2ab3a Warn on ops queue full (#481)
Pass logger so that we can log with proper context.
2022-03-02 19:08:07 +05:30
Raja Subramanian
2959eebca8 Introducing OpsQueue (#463)
* Introducing OpsQueue

Creating a PR to get feedback on standardizing on this concept.

Can be used for callbacks.
Already a couple of places use this construct. Wondering if we
should standardize on this across the board.
Just changing one place to use the new struct. Another place
that I know of which uses this pattern is the telemetry package.

* atomic flag -> bool
2022-02-25 11:56:26 +05:30
David Colburn
289ebd32ff Telemetry refactor (#172)
* telemetry refactor

* fix imports

* update protocol
2021-11-08 20:00:34 -06:00
David Zhao
aa9534b7fb Server-driven connection quality detection (#167) 2021-11-03 21:05:20 -07:00
Mathew Kamkar
84ab0f82af Prometheus counters for RTC connection steps (#143)
* signal ws connection, participant join, ice connection

* must register

* offer negotiation

* dz review: offer and offer_response

* dz review: answer
2021-10-12 15:22:17 -07:00
Mathew Kamkar
b212fb9a9e Prometheus counter for Signal/RTC messages (#139) 2021-10-08 12:02:08 -07:00
David Zhao
797d2607c4 Fix NACK handling in simulcast (fixed in ion-sfu) 2021-10-04 17:17:41 -07:00
Mathew Kamkar
4553695631 get system stats from /proc only on linux (#96) 2021-08-27 13:15:02 -07:00
David Colburn
8a44fad307 protocol 0.8 (#95)
* protocol 0.8

* merge new selector
2021-08-27 13:16:33 -05:00
Mathew Kamkar
f9590afe1a include packet and system info with node stats (#92)
* include packet and system info with node stats

* add more packet and system stats

* revert magefile, clean up system stats error handling

* update procol version

* dz review: error return
2021-08-25 12:04:28 -07:00
Mathew Kamkar
f5466c74e6 list-nodes command action (#87)
* list-nodes command action

* refactor stats into a package

* store existing stats in redis, more refactoring

* dz review: atomic load
2021-08-24 10:14:39 -07:00
David Zhao
7d02c01fd8 refactor - moved common code to livekit/protocol 2021-03-13 22:01:51 -08:00
David Zhao
b52354623c use hostname instead of MAC address to work with docker environments 2021-02-17 17:51:54 -08:00
David Zhao
090f8d0664 use dedicated PeerConnections for sending and receiving (#19)
* protobuf updates to support new protocol

* use dedicated publish & subscribe peerconnections

* update client to work with dedicated PCs

* fix Go client negotiation, reduced length of UUID
2021-02-12 22:30:31 -08:00
David Zhao
dd8a1a5055 use atomic.Load to ensure atomicity 2021-01-28 23:40:30 -08:00
David Zhao
ed0b9db655 avoid sending to closed channels 2021-01-26 21:45:00 -08:00
David Zhao
458241d1f1 config rework to handle distributed setup, fixed redis bugs 2021-01-17 17:06:50 -08:00
David Zhao
30e99e8c6b redis based router & roomstore 2021-01-17 00:12:05 -08:00
David Zhao
353f35443a API key generator, using YAML format instead of hand rolled parser 2020-12-27 00:01:19 -08:00
David Zhao
804b7cb332 JWT token based auth 2020-12-25 22:31:11 -08:00
David Zhao
0dcfffb9d8 remove all forwarders when source track is closed 2020-12-04 23:28:50 -08:00
David Zhao
bca8090b41 correctly send participant updates 2020-12-02 00:53:16 -08:00
David Zhao
bea1a87cb8 updated flow, room & participant id created by server 2020-11-28 00:18:34 -08:00