Commit Graph

1187 Commits

Author SHA1 Message Date
David Zhao
9a1f4ab18b Allow /rtc/validate to return room not found message (#1344)
It's not always possible for WebSocket clients to obtain status code or
error messages returned during WS Upgrade. Moving autocreation validation
to an explicit interface in the validation step so the /rtc/validate
would be able to return an appropriate message.
2023-01-29 21:41:44 -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
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
bd39a96eac Tweak call stack depth to show more helpful error lines (#1333) 2023-01-25 15:35:18 -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
Dan McFaul
9e3ca1e989 adding rtc_init stat (#1316)
* adding rtc_initiated stat

* clean up signal and rtc init/connected

* update naming and break out stats update funcs

* update protocol dependency
2023-01-23 12:49:15 -07:00
Raja Subramanian
56803a6b29 No need for using arrival time diff. (#1318)
From logs, can see when reference layer is out of order, it is
out of order by a small amount most of the time (saw a maximum
of 5 ms in a sampling of logs). When using arrival time in those
case, some times the offset comes out to 10 ms or so. In most
of the cases, the time based diff is a lot higher (by several ms).
Just use the default of +1 diff on switch layer in case of
out-of-order time stamp. That will allow playback to move
forward and keep the timing close to actual frame time.
2023-01-23 10:17:37 +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
Raja Subramanian
b7263b7625 Do not use local time stamp when sending RTCP Sender Report (#1315)
* some additional logging

* Do not use local time stamp when sending RTCP Sender Report

As local time does not take into account the transmission delay
of publisher side sender report, using local time to calculate
offset is not accurate.

Calculate NTP time stamp based on difference in RTP time.
Notes in code about some shortcomings of this, but should
get better RTT numbers. I think RTT numbers were bloated because of
using local time stamp.
2023-01-19 23:32:50 +05:30
David Colburn
e31b25300d update psrpc (#1312) 2023-01-18 13:52:03 -08:00
Benjamin Pracht
edc39da0b1 Add TwirpRequestStatusReporter twirp server hook to count requests (#1309) 2023-01-18 11:53:20 -08:00
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 Colburn
a87107a0f3 IOInfo service (#1305)
* IOInfo service

* only start if not nil

* use ctx in updateEgressInfo

* updates

* fix merge
2023-01-16 16:26:03 -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
Paul Wells
a052ebd644 Ingress psrpc (#1295)
* add ingress psrpc codegen

* use psrpc for ingress

* merge entity/info update psrpc services

* split update/delete ingress methods

* add race helper test

* add race context cancel test

* sync race result with mutex
2023-01-12 11:00:43 -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
Benjamin Pracht
0ca80a4fa7 Fix log statement in egress service (#1301) 2023-01-11 11:42:47 -08: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
7aad888e4e Normalize NTP time base when calculating RTT (#1297)
* Normalize NTP time base when calculating RTT

* seed last SR
2023-01-11 12:25:14 +05:30
Raja Subramanian
1db218a5b1 Fix panic on MacOS (#1296) 2023-01-11 10:08:56 +05:30
Mathew Kamkar
7c970da974 add memory used and total to node stats (#1293)
* add memory used and total to node stats

* raja review: consistency

* update protocol
2023-01-10 12:32:04 -08:00
Raja Subramanian
69d879706d Use getBuffer consistently. (#1290)
* Use `getBuffer` consistently.

With SVC, it is possible that layer <-> buffer mapping is not 1:1.
So, use `getBuffer` method.

* fix recursive lock
2023-01-07 16:16:17 +05:30
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
shishirng
dceb624b83 Send participant object in telemetry on Active event (#1282)
Signed-off-by: shishir gowda <shishir@livekit.io>
2023-01-04 08:55:49 -05:00
cnderrauber
fe4da84ee9 send padding packets of muted uptrack for go sdk (#1283) 2023-01-04 16:01:04 +08:00
Raja Subramanian
cbc7d43ba4 Minor tweaks to frame based stream tracker. (#1281) 2023-01-03 18:16:55 +05:30
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
a87574da31 FPS based stream tracker tweaks (#1275)
* FPS based stream tracker tweaks

- Cleaning up code
- Two tweaks
  o A layer is declared active on receiving first packet (when starting fresh).
    But, if there are no frames after that (no packets after girst packet or
    there is only one frame), layer would not have been declared stopped as
    the previous version waited for second frame. Now, if there are no more
    frames in eval interval, declare the layer stopped.
  o When frame rate goes to 0, reset FPS calculator. Otherwise, layer starting
    after a long time will have frames spaced apart too far which would result
    in very low frame rate. Reset the calculator and let it pick up after the
    the layer restarts
- Also changing from lowest FPS -> estimated FPS and update up slowly and down fast.
  There are cases where frames are to far apart result in really low FPS. Seems to
  happen with NLC kind of cases where bandwidth is changed rapidly and the estimator
  on browser probably gets a bit confused and starts/stops layers a bit erratically.
  So, update estimate periodically to ensure eval interval is tracking current rate.

* fix factor

* spelling fix
2022-12-30 19:49:16 +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
Benjamin Pracht
86bf5cb62e Ensure we create en Egress ID with PsRPC (#1273) 2022-12-30 13:46:45 +13:00
Benjamin Pracht
7778cdf2cd Do not use the egress version stored in redis to decide whether to enable PsRPC. Use a conf entry instead (#1262) 2022-12-30 09:32:55 +13:00