759 Commits

Author SHA1 Message Date
Raja Subramanian
73399dd565 Encapsulate better. (#1466)
Only `logger` and `trackID` of `trackSubscription` is directly accessed
from outside. They are set at construction time. So, should be fine.
2023-02-24 09:34:03 +05:30
David Zhao
34fcf9e496 Additional case of subscribing to a closed track (#1465)
When the publisher stops publishing, the individual receivers would close
attached DownTracks first before notifying MediaTrackReceiver callbacks.

This means #1454 does not fix the issue entirely since there is still a window
when we can subscribe to a closing track.
2023-02-23 17:07:16 -08:00
cnderrauber
dbb2cdf2b6 switch to tls if tcp ice dose not work well (#1458)
* switch to tls if tcp ice don't work well

* ignore tcp quality too bad
2023-02-23 14:07:50 +08:00
Raja Subramanian
cd0359c898 Reset subscription start timer on permission grant. (#1457)
If not, bind timeout could be reported on permission grant
as it could be using some old timer.
2023-02-23 09:39:33 +05:30
David Zhao
e855620379 Prevent subscribing to track that's closing (#1454)
Due to the order of events in MediaTrackReceiver and friends, SubscribedTrack
will be closed before the track is removed from RoomTrackManager.

Because of this, when a track is unpublished, it's possible to be subscribed
to the track as it's closing.

By introducing a closing state, we'd prevent accidental subscription to
closing tracks.
2023-02-22 01:14:49 -08:00
cnderrauber
1b3d6fad54 update to utils parallel execute (#1450)
* log change

* remove identity field

* update to protocol parallel execute

* update protocol
2023-02-22 11:09:32 +08:00
Raja Subramanian
6b55742564 Use available layers in optimal allocation. (#1445)
Addressing edge case where a layer stopped before bitrate could be
measured. Purely bit rate based change deduction missed this as
the before and after did not have bit rates.

Use available layers to look for changes, especially currently
forwarding layer going away.

Also, simplifying bits. Only in the optimal allocation path,
these things are required. When congested, bitrate is always needed.
So, for optimal path, just look at available layer changes and adjust.

Don't need to look for bitrate based layer changes. Clean up that code.
2023-02-19 11:41:40 +05:30
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
bdc515774e Declare migration complete only after publish callback finishes. (#1442)
The following sequence caused early migration complete declaration
1. Audio track received
2. Audio track published callback in progress
3. Video track received, this clears the pending track
4. Audio track published callback finishes. This checks for pending
   tracks. As nothing is pending migration complete declared.
5. Due to the above, the remote video track is closed as not resuming.
   That causes an unsubscription.

Fix
- Wait till publish callback to finish to remove a track from pending
  fully.
- Introducing a new map as pending tracks is used in OnClose too. So,
  did not want to delay removing from it as a close could happen while
  publish callback is happening.

Also, moving the publish callback to a go routine (just like the recent
change for running those in a go routine for migrated muted tracks)
2023-02-18 12:08:43 +05:30
David Zhao
7a2d9b3d61 Ensure subscription logging is clear & without sampling (#1440) 2023-02-17 22:15:19 -08:00
Raja Subramanian
9f33ce0ecd Declare migration complete after track publish callback. (#1436) 2023-02-17 19:34:31 +05:30
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
cnderrauber
6d16f061de Suppress negotiation timout log if signal disconnect (#1433)
* Suppress negotiation timout log if signal disconnect

* solve comment
2023-02-17 15:40:35 +08:00
David Zhao
c16eb66925 Fix race condition with unsubscribing from a republished track (#1429) 2023-02-16 15:11:23 -08:00
Raja Subramanian
6cb46107c8 Delete signal de-duper. (#1427)
Not a good design. There is not an easy way to filter messages
before it hits media node. Without that, there is not a lot
of advantage.

And there are sequences that are not handled correctly in this
deleted implementation.

So, deleting code to prevent use.
2023-02-16 09:32:48 +05:30
David Colburn
10c53e0ebb Move psrpc to protocol (#1426)
* move psrpc to protocol

* update checks

* update protocol

* update protocol ref

* blank line
2023-02-15 16:47:38 -08:00
Dan McFaul
1848a21eda add configurable environment value (#1421)
* add configurable prometheus env label

* Update pkg/config/config.go

Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com>

* Update cmd/server/main.go

Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com>

* Update config-sample.yaml

Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com>

* set config.Environment value to dev when in dev mode

* be more precise for config-sample

---------

Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com>
2023-02-15 14:41:44 -07:00
cnderrauber
4367e93855 parallel writing for data packet broadcast (#1425) 2023-02-15 17:18:43 +08:00
David Zhao
4f6fda586c Do not unsubscribe from track if it's been republished (#1424)
thank you @boks1971 for the debugging
2023-02-14 23:12:08 -08:00
Raja Subramanian
3309c6fff0 Log feed SSRC (#1419) 2023-02-14 18:05:20 +05:30
Raja Subramanian
7857af4a66 Send unpublished callback unconditionally. (#1418)
Even if an add track has been queued and can be used immediately
when the previous incarnation unpublishes, send the unpublished
callback as the track was technically unpublished and republished.
The re-publish will pick the same track SID when the pending track
is queued as it will get the SID from an existing published track.
2023-02-14 13:17:54 +05:30
cnderrauber
e6eabb3a03 Prevent force tcp when client left between ice and dtls (#1414) 2023-02-13 13:57:50 +08:00
Raja Subramanian
481b4abbe5 Adding a debug log for track unpublish (#1412) 2023-02-11 09:38:58 +05:30
Trey Hakanson
ce07914e44 Allow for strict ACKs to be disabled or subscriber peer connections (#1410) 2023-02-10 22:51:03 +05:30
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