735 Commits

Author SHA1 Message Date
Dan McFaul ad7e075c18 exit after panic (#1392)
* let panics crash

* Revert "let panics crash"

This reverts commit 8027cccadd.

* catch and log panics then os.Exit

* Recover only recovers, caller can exit

* only exit on pacic, still need Recover calls in goroutines
2023-02-09 16:33:22 -07:00
cnderrauber a04e7ce647 Fix panic by CreateSenderReport before bind completed (#1397) 2023-02-08 17:02:19 +08:00
Raja Subramanian 4d8def2eb7 Ignore errors on closed connection. (#1396) 2023-02-08 13:41:04 +05:30
cnderrauber 5161dba873 Filter mdns candidate if not mdns not enabled (#1393)
* Filter mdns candidate if not mdns not enabled

* log target
2023-02-08 10:27:24 +08:00
Raja Subramanian 9d32c6065d Include track priority in de-duper checks (#1388) 2023-02-07 11:57:29 +05:30
David Zhao 2851a8ac98 Improved robustness of subscription stack (#1382)
UpdateSubscription had a shortcoming where when it couldn't find the
participant, it ignored the request.

This PR further removes the reliance of current publisher state from
subscribers.
- SubscribeToTrack only takes in a trackID
- Introduced RoomTrackManager to maintain all published tracks to a room
- Added TrackUnpublished event to clearly indicate when a track has been removed
- SubscribeRequested event no longer include information about the publisher
2023-02-06 18:08:26 -08:00
Raja Subramanian aaba402ada Log messages processed by signal de-duper. (#1384)
This will get noisy. Will revert once we have some data to analyse.
2023-02-06 10:55:42 +05:30
cnderrauber 8b6dab780c Add reconnect reason and signal rtt calculation (#1381)
* Add connect reason and signal rtt calculate

* Update protocol

* solve comment
2023-02-06 11:12:25 +08:00
Raja Subramanian d67cdb6141 Return early if already subscribed. (#1377)
* Return early if already subscribed.

When already subscribed, returned `subTrack` is nil.
Return early, but do not return an error.

* check for nil subTrack

* check for nil as well
2023-02-04 13:47:35 +05:30
David Zhao add9962655 Avoid triggering subscription failed handler unnecessarily. (#1379)
Certain errors are not at fault of the subscriber. For these errors
the reconciler should keep trying instead of giving up.
2023-02-03 01:06:04 -08:00
David Zhao be4764b93b Improve panic recovery to use participant logger. (#1375)
Also made IssueFullReconnect public
2023-02-02 14:55:50 -08:00
Raja Subramanian 501fb0860e correct test name, only latest version is used (#1373) 2023-02-03 03:50:45 +05:30
Raja Subramanian 037ae572d9 Ensure older participant session update does not go out after a newer (#1372)
* Ensure older participant session update does not go out after a newer
session has joined.

* fix tests

* change comment

* do not send older version
2023-02-03 00:30:11 +05:30
David Zhao 8c513a1fc5 Improve SubscriptionManagerTest resilience (#1370)
This check fails on GH Actions occasionally due to timing differences.
2023-02-01 22:55:57 -08:00
David Zhao 40120db993 Tweaks to subscription reconcile timeout (#1369) 2023-02-01 22:36:14 -08:00
David Zhao 8ba6418ab4 Server-side workaround for JS SDK's inability to handle ReconnectResponse (#1367)
See: https://github.com/livekit/client-sdk-js/pull/568
2023-02-01 15:37:18 -08:00
Raja Subramanian ffadb94e3a Simplifying forwarding logic a bit (#1349)
* Notes on wht to do

- Should targetLayers be altered while doing opportunistic locking
- Should targetLayers be altered in any other path than stream allocator path?
- Lock to layer as long as it is <= opportunistic layer
- When not congested, opportunistic can be highest
- When congested, opportunistic could be nil or lowest if paused is not allowed
- When muting, can we hold on to current layers (or keep it as previous) and
  restore on unmute.
- Store current/target in forwarder state and restore on seeding
- Watch for looking for targetLayers, etc. when looking to insert padding
  packets. There may be an assumption about restarting on key frame and hence
  okay to insert padding when target layers are invalid. This may not be true
  any more when doing opportunistic forwarding.
- Can we distinguish between publisher mute or dynacast (i. e. publisher side
  stopping) vs subscriber mute and do something useful? Publisher side mute
  could mean continuity in sequence numbers on a restart (might be able to
  catch it with opportunistic forwarding). But, there is the challenge of
  unmute from publisher via signalling channel vs media. If media is arriving,
  should subscribers do opportunistic forwarding before publisher mute state
  update happens?
- Maybe introduce a mode where forwarding continues to a frame end (of course
  with a time limit just in case the end of frame packet is lost) and then
  insert silence/padding packets?
- Ensure that audio blank frame insertion does not suffer from frame boundary
  issues.

* pub/sub mute separate + more notes on things to check

* WIP commit, more notes

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* clean up

* slightly better comments

* Do not stop on unmute

* do not inject blank frames when pub muted

* do not forward on audio publisher mute
2023-02-01 21:57:53 +05:30
cnderrauber 7e5ba6a3b0 Improve connectivity check (#1366)
* Add Timer to detect dtls failure quickly

* Fix pc state check in timeout after ice

* More strict conditions to switch candidate type

* log for signal interuppt

* typo
2023-02-01 20:00:34 +08:00
Raja Subramanian 1c321bfccc Ignore inactive media. (#1365)
* Ignore inactive media.

Seeing some errors of
"track info not published prior to track".
Happens when trying to configure publisher answer for audio
for DTX and stereo and trying to find a pending track.
There are cases where there are inactive m-lines in SDP
that is hitting this.

* fix sense
2023-02-01 12:41:07 +05:30
David Zhao 2048cfbfc7 Increase subscription manager notFound timeout (#1358)
Giving it more time before triggering the nuclear option of unsubscribing
from the track.
2023-01-31 00:52:12 -08:00
Benjamin Pracht c6e8887ab8 Allow requesting a specific Egress Cluster Id (#1342) 2023-01-30 17:04:26 -08:00
David Zhao b023c531c2 Fix incorrect unsubscribed track telemetry (#1350)
- only log unsubscribe on close if Track was actually bound
- update subscribed counters even if a failure had been logged before
2023-01-30 10:16:21 -08:00
David Zhao a24eb62b83 Set IsPublisher to true for data-only publishers (#1348) 2023-01-29 23:10:26 -08:00
David Zhao 21f816d23c Slight tweaks to subscription manager logging (#1345) 2023-01-29 11:45:47 -08:00
cnderrauber 3a4a294a92 Enable upstream nack for opus only audio track (#1343) 2023-01-28 16:02:38 +08:00
David Zhao 5e9221dbd8 Enable video at low res by default when adaptive stream is enabled. (#1341)
When AdaptiveStream is enabled, default the subscriber to LOW quality stream
we would want LOW instead of OFF for a couple of reasons
1. when a subscriber unsubscribes from a track, we would forget their previously defined settings
   depending on client implementation, subscription on/off is kept separately from adaptive stream
   So when there are no changes to desired resolution, but the user re-subscribes, we may leave stream at OFF
2. when interacting with dynacast *and* adaptive stream. If the publisher was not publishing at the
   time of subscription, we might not be able to trigger adaptive stream updates on the client side
   (since there aren't any video frames coming through). this will leave the stream "stuck" on off, without
   a trigger to re-enable it
2023-01-27 20:41:26 -08:00
David Zhao db40272657 Persist participant before firing webhook (#1340)
Fixes #1339
2023-01-27 19:29:38 -08:00
Paul Wells d83f9fe68b add lock tracker to participant (#1338)
* add lock tracker to participant

* update protocol dep
2023-01-27 13:44:22 -08:00
David Zhao c146398f32 Improved subscription manager logging to help with debugging (#1337) 2023-01-26 23:31:03 -08:00
David Zhao 2d6c896bba Fix incorrect accounting for track published/subscribed stats. (#1336)
It was not getting decremented in certain cases.
2023-01-26 16:07:04 -08:00
David Zhao 154f04afa6 Log ice candidates upon failure (#1325) 2023-01-25 00:02:48 -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
Raja Subramanian c696626fe8 Use local time base for NTP in RTCP Sender Report for downtracks. (#1321)
* Use local time base for NTP in RTCP Sender Report for downtracks.

More details in comments in code.

* Remove debug

* RTCPSenderReportInfo -> RTCPSenderReportDataExt

* Get rid of sender report data pointer checks
2023-01-25 11:00:15 +05:30
Paul Wells 1ef7c46fd7 publish stream stats to prometheus (#1313)
* add prometheus stats for rtt/jitter/packet loss

* add track source to metrics

* better packet loss bins

* add track type to metrics

* remove source from AnalyticsStat

* regenerate telemetry service fake

* compute loss from per stream packet count
2023-01-19 19:37:15 -08:00
Raja Subramanian 6a8e86c3a3 Support disable dynacast. (#1314)
Added a flag to throttle dynacast messages to the publisher.

Added a helper method to check if a client supports setting `active`
field in RTP sender encoding. This can be used to disable dynacast based
on some other feature flag/config settings.
2023-01-20 08:09:31 +05:30
cnderrauber bccf7a6842 Add ice mdns config (#1311)
* Add use_mdns config

* Update config-sample.yaml

Co-authored-by: David Zhao <dz@livekit.io>

Co-authored-by: David Zhao <dz@livekit.io>
2023-01-18 16:51:49 +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
cnderrauber 55962e300c enable track level audo nack config (#1306) 2023-01-13 17:07:06 +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
cnderrauber 81fb1c5ef0 Add idle check for participant (#1303) 2023-01-12 17:26:53 +08:00
Dan McFaul 4d6f0cd0f7 Stats collect v2 (#1291)
* initial commit

* add correct label

* clean up

* more cleanup on adding stats

* cleanup

* move things to pub and sub monitors, ensure stats are correctly updated

* fix merge conflict

* Fix panic on MacOS (#1296)

* fixing last feedback

Co-authored-by: Raja Subramanian <raja.gobi@tutanota.com>
2023-01-11 14:49:50 -07:00
cnderrauber 25debc6d35 add reconnect response to update configuration while reconnecting (#1300)
* add reconnect response to update configuration while reconnecting

* fix test
2023-01-11 17:40:12 +08:00
Raja Subramanian 878887b624 Reset state if requested even if config is same (#1287) 2023-01-06 21:39:45 +05:30
Raja Subramanian 2b89c821ab An attempt to use publisher side RTCP sender report while forwarding (#1286)
* WIP commit

* comment

* clean up

* remove unused stuff

* cleaner comment

* remove unused stuff

* remove unused stuff

* more comments

* TrackSender method to handle RTCP sender report data

* fix test

* push rtcp sender report data to down tracks

* Need payload type for codec id mapping in relay protocol

* rename variable a  bit
2023-01-06 14:07:18 +05:30
Raja Subramanian 56424985df Do not get tripped by default values. (#1284)
* Do not get tripped by default values.

The following scenario declared the second message a dupe incorrectly
- UpdateSubscription{subscribe: true}: This message initialized quality
  to default which is livekit.VideoQuality_LOW
- UpdateTrackSettings{quality: livekit.VideoQuality_LOW} - this one got
  tripped as duplicate because the previous message initialized quality
  to LOW.

Fix it by recording whether track settings have been seen.

no auto subscribe + quality setting to LOW test failed before this
change and passes with this change.

* patch all track setting fields
2023-01-04 23:06:50 +05:30
cnderrauber fe4da84ee9 send padding packets of muted uptrack for go sdk (#1283) 2023-01-04 16:01:04 +08:00
David Colburn 24664b1284 egress participants don't count towards max (#1279) 2023-01-03 09:38:58 +08:00
Raja Subramanian 4ba7e57683 Make an IsDisconnected interface and use it (#1278) 2022-12-31 12:53:02 +05:30
Raja Subramanian 9b8311ffcb No JoinResponse during migration (#1277)
* No JoinResponse during migration

* Change  to take migration into account
2022-12-31 11:43:48 +05:30
Raja Subramanian 5532dfa75c A couple of logging tweaks (#1276) 2022-12-30 19:47:25 +05:30