Commit Graph

717 Commits

Author SHA1 Message Date
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
cnderrauber c393a5f8dd Add interface and ipfilter to udpmux option (#1270)
* Add interface and ipfilter to udpmux option

* validate external ip is accessable by client

* add context

* use external ip only for firefox

* fix mapping error

* Update pion/ice and use external ip only for firefox

* Use single external ip for NAT1To1Ips if validate failed

* update pion/ice
2022-12-30 16:01:12 +08:00
David Zhao 112d6fc18b Reduced log verbosity for pieces that are stable (#1274) 2022-12-29 23:47:36 -08:00
David Zhao fe6234329d Improve robustness of JoinResponse and ParticipantUpdate race handling (#1272) 2022-12-29 21:52:55 -08:00
David Zhao 1cffa98311 Guard against ParticipantUpdate sent before JoinResponse (#1271)
* Guard against ParticipantUpdate sent before JoinResponse
2022-12-29 01:08:08 -08:00
lukasIO 12931f20fd Include encryption field in TrackInfo, update protocol (#1265)
* Include e2ee in TrackInfo

* update protocol, rename field
2022-12-28 13:48:49 +01:00
Raja Subramanian 41a906ce92 Using tracker type per source type which allows diffferent impl for different sources (#1269) 2022-12-28 14:07:53 +05:30
Raja Subramanian 2b031a5112 Introducing frame based stream tracker. (#1267)
* Split stream tracker impl from base

* slight re-arrangement of code

* fps based stream tracker

* MinFPS config

* switch back to packet based tracker

* use video config by default to handle sources without type
2022-12-28 13:00:21 +05:30
David Zhao 988858a98a Update dependencies to generic versions (#1259) 2022-12-26 22:29:13 -08:00
Raja Subramanian 94564f9f93 Introduce a safety note for dupe detection. (#1257)
If the last non-dupe was more than a while ago, just let one through
even if it is dupe.

Clean up code.
2022-12-24 12:53:18 +05:30
Raja Subramanian 1a48cc6a8b Track subscription operations per source track. (#1248) 2022-12-23 12:23:26 +05:30
cnderrauber 05132799a5 config for streamtracker (#1255) 2022-12-23 09:48:56 +08:00
Raja Subramanian 4fbb89e99c Check for not nil ICECandidatePair (#1253)
GetSelectedICECandidatePair can return nil for the candidate pair if not
available even if the error is not nil. Protect against the nil
de-reference panic.
2022-12-22 11:28:04 +05:30
Raja Subramanian d05d26cc04 Do not patch subscription setting when processing UpdateSubscription (#1247)
message.

There are is a sequence where a dupe could be detected due to patching
which could lead to issues.

The sequence is
- UpdataTrackSettings with some values
- UpdateSubscription with Subcribe: false - this will patch from above
  track settings
- UpdateSubscription with Subscribe: true - this will continue patching
- UpdateTrackSettings with the same settings as in the first step - this
  will be declared a dupe because the track is enabled and the patched
  settings will declare no change in settings.

This is okay in the current code as subscription settings are cached at
participant level and applied when somebody re-subscribes. But, that
down stream processing can change any time.

So, when processing `UpdateSubscription` message, just do not patch.
If a later `UpdateTrackSettings` comes along, let it pass even if it
is not changing anything.
2022-12-21 11:12:40 +05:30
Raja Subramanian f24c1b95c2 Initial commit of signal deduper. (#1243)
* Initial commit of signal deduper.

Idea is protect against signal storm from misbehaving clients.

Design:
- SignalDeduper interface with one method to handle a SignalRequest and
  return if dupe or not.
- Signal specific deduper. Could have made a single de-duper which could
  handle all signal message types, but making it per type so that the
  code is cleaner.
- Some module (like the router) can instantiate whatever signal types
  it wants to de-dupe. When a signal message is received, that module
  can run the signal message through the list of de-dupers and
  potentially drop the message if any of the de-dupers declare that the
  message is a dupe. Making it a list makes things a little bit
  inefficient, but keeps things cleaner. Hopefully, not many de-dupers
  will be needed so that the inefficiency is not pronounced.

* re-arrange comments

* helper function

* add ParticipantClosed
2022-12-21 09:29:56 +05:30
David Zhao c1d7dbd4fc Tweaks to prometheus participant counter (#1240)
* Tweaks to prometheus participant counter

Ensure that we don't miss adding a count in migration scenarios

* avoid nil ICEConfig
2022-12-19 14:30:14 -08:00
Raja Subramanian 50e39b9985 Check participant SID also while removing a participant. (#1237) 2022-12-19 22:53:11 +05:30
Raja Subramanian 241a7120f5 ICE config using protocol model (#1233)
* ICE config using protocol model

* use pointers consistently

* protocol pointer

* mage generate
2022-12-19 10:25:08 +05:30
David Zhao 33902a9f2a Do not send ParticipantLeft webhook event unless connected successfully. (#1234)
Fixes #1130
2022-12-18 17:37:55 -08:00