Commit Graph

58 Commits

Author SHA1 Message Date
David Zhao
981fb7cac7 Adding license notices (#1913)
* Adding license notices

* remove from config
2023-07-27 16:43:19 -07:00
Paul Wells
745410bd69 only increment participant version after updates (#1646)
* only increment participant version after updates

* fix test util

* cleanup

* test uptrackmanager permission update version check
2023-04-22 17:48:10 -07:00
Raja Subramanian
65ad4b2c43 Doing a pass at demoting logs (#1531)
A few more candidates to think about demoting
- Publisher mute changes
- Forwarder -> layer lock/upgrade/downgrade/overshoot adjusting
- StreamAllocator
2023-03-20 12:22:08 +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
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
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
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
David Zhao
112d6fc18b Reduced log verbosity for pieces that are stable (#1274) 2022-12-29 23:47:36 -08:00
Raja Subramanian
086009f05a Do not forward media till peer connection is connected. (#1194)
There were some failures with missing media. The only thing I could
see between working and non-working case is when media forwarding
starts. So, delay media forwarding till peer connection is connected.

Also, add a subscribe op only if a subscribe/unsubscribe queuing is
successful. There was a recent change to not queue a subscribe when
the participant is closed/disconnected. This got the subscribe op
counter out of whack.
2022-11-26 21:42:19 +05:30
Raja Subramanian
3074cb862f Force 'allowed; even on subscription.' (#1187)
Also not holding lock while resolving by sid. Not pretty.
But, we should deprecate SID based permissions.

Also, wire changes, possibly due to redis cluster PR?
2022-11-23 14:13:20 +05:30
Raja Subramanian
fe0502c886 Demote some stable logs to Debugw (#1158)
* Demote some stable logs to Debugw

* Add 'discard message from' to ignore list
2022-11-11 10:17:47 +05:30
David Zhao
1019faa0e6 Cleanup pass through logging (#1073)
* added filtering for noisy pion logs
* demoted some logs to debug
* using consistent trackID / participant / publisher / subscriber terminology
* removed ice candidate log lines, deferring to combined log
2022-10-06 23:48:37 -07:00
Raja Subramanian
30e5037418 Minor clean up of media track & friends module (#1067) 2022-10-04 05:23:18 +05:30
Raja Subramanian
dfc71d5bf8 Add a flag to signal need to close underlying media track. (#1038)
With migration in, once the local track is published, the
remote track should be closed. Add a flag to `RemovePublishedTrack`
to control the close behaviour. Invoke `Close` if specified.

Without, the remote track is not closed if it is waiting to resolve,
i. e. not yet attached. That remote track is left hanging.
2022-09-26 15:32:22 +05:30
Raja Subramanian
34bab018dc Do not initialize subscription version until explicitly set. (#951)
Initializing with current time means some updates are ignored.
Do not initialize until explicitly set.
2022-08-24 20:50:23 +05:30
Raja Subramanian
f5627c3859 Prevent track subscriptions/adding receivers after close (#924)
* Prevent track subscriptions/adding receivers after close

With subscribe/unsubscribe queuing, a subscribe may be
attempted after a call to `RemoveAllSubscribers`.
So, renaming `RemoveAllSubscribers` to `InitiateClose`
and maintaining state that track is in the process of closing.

* Mime specific remove

* Remove unused error

* do not add receiver when closing
2022-08-17 13:07:59 +05:30
Raja Subramanian
d9fdcf8c2b Promoting a few logs to Info (#921)
* Promoting a few logs to Info

Also, adding a couple of more info logs which I will remove later
after some debugging.

* mime type

* Protect pause/max layer

* notify even if not bound
2022-08-16 13:03:14 +05:30
Raja Subramanian
4d7df612ec Refactor DynacastQuality & MediaLossProxy into separate modules (#894)
* WIP commit

* Refactor media loss proxy

* Use DynacastQuality and MediaLossProxy from MediaTrack

* fix test

* Remove unused param

* Remove unused interfaces

* Move interface methods to local

* Split out DynacastManager

* have to add codec to dynacast manager

* RUnlock

* fix restart

* Adding API to force quality and also maintain closed state

* Address PR comments
2022-08-09 11:47:06 +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
177061712c Do not hold lock while invoking resolver. (#816)
* Do not hold lock while invoking resolver.

Resolver is in room and it will grab its lock.
It is called from partcipant when checking permissions.
Permissions processing uses the participant lock.
So, not a good idea to call a room function with
participant lock held. Avoid that.

Also, use a full lock in the add/remove subscription
path. This is to ensure that permissions path and
subscription path (like subscribing to new participant's
tracks) do not race. As subscriptions are queued now
on the subscriber side, this should be fine.

* Revoke path resolution in ops queue goroutine

* fix test
2022-07-07 13:24:26 +05:30
Raja Subramanian
ef66404a1a Keep track of pending subscriber operations. (#814)
* Keep track of pending subscriber operations.

This is required to determine if a receiver does not have
any subscription.

* correct spelling of queuing

* lock around hasPermission
2022-07-06 23:48:28 +05:30
Raja Subramanian
7c35184944 Send permissions update on subscribe. (#805)
* Send permissions update on subscribe.

The permission `allowed` update was happening only when
processing pending subscriptions (which happens only on
subscription permissions update).

It is possible that subscription happens through other
paths (like subscribing new participant to tracks).
In that path, we were checking if the track has permissions
and adding to pending. But, we were not checking if
the track is in pending and if it is in there, removing
in on successful subscription and sending an update.
Fix that.

* log more fields in error
2022-07-03 12:17:22 +05:30
Raja Subramanian
1428ab3713 Add logs around permissions handling (#803) 2022-07-03 10:56:00 +05:30
Raja Subramanian
03b0a01aad Use a queue for add/remove subscribe operations. (#797)
* Use a queue for add/remove subscribe operations.

If subscribe/unsubscribe happens very quickly, the subscription
state gets mixed up as things are keyed off of subscriberID.

Use a queue of subscribe operations and process it serially.

* set up callback for down track added

* move the queue on unexpected type

* move the queue if removeSubscirber does not have a subscribed track
2022-07-02 10:52:55 +05:30
Raja Subramanian
856cc1798f RemoveSubscriber while revoking. (#796)
Else, a quick turn around of permissions tries to subscribe
again and the subscriber is already in the subscribed list.
2022-07-01 11:31:47 +05:30
Raja Subramanian
e5f53a0d21 Pass willBeResumed into RemovePublishedTrack (#789) 2022-06-26 11:39:27 +05:30
Raja Subramanian
20512151c6 Prevent subscribe renegotiation if tracks will be resumed. (#781) 2022-06-24 00:06:37 +05:30
David Zhao
7ad51f49f1 Fixed unclean DownTrack close when removed before bound. (#736)
* Fixed unclean DownTrack close when removed before bound.

When a DownTrack is closed before it had a chance to be bound to a
transceiver, we'd skip close and leave it hanging. This is unlikely in
normal operations. However, it can be seen with permissions and
subscription APIs.

* remove remaining peerID references
2022-05-29 22:09:02 -07:00
cnderrauber
f958fbcc1c simulcast codecs support (#720)
simulcast codecs support 

Co-authored-by: David Zhao <dz@livekit.io>
2022-05-27 19:55:50 +08:00
Raja Subramanian
fe8c355a32 Support participant identity in permissions (#663)
* Support participant identity in permissions

It is harder for clients to update permissions by SID as remote
reconnecting means a new SID for that participant. Using participant
identity is a better option.

For now, participant SID is also supported. Internally, it will
get mapped to identity. Server code uses identity throughout after
doing any necessary conversion from SID -> Identity.

* Address comments
2022-05-02 12:35:20 +05:30
Raja Subramanian
50bd08e551 ICE restart - dynacast settings were lost (#620)
* Prevent stats update if the deltas are empty

* increase force interval

* static check

* Change max delay to 30 seconds

* Restart the max subscribed quality timer on ICE restart.

Force an update after a restart to let clients apply dynacast settings.
Also, set the max expected layer to HIGH on restart so that stream
tracker starts up fast on a restart.

* fix test
2022-04-18 22:58:11 +05:30
David Zhao
8fbe00edb3 Avoid locking when flushing DownTrack (#594) 2022-04-05 23:45:51 -07:00
David Zhao
5920672802 feat: unpublish tracks after publish permissions are revoked. (#545)
* feat: unpublish tracks after publish permissions are revoked.

Uses protocol 7 to indicate client support, otherwise it attempts to
mute the tracks.

Also sends back permissions objects of all participants, and cleaned up
our handling of various permissions attributes.

* fix static check
2022-03-21 00:20:48 -07:00
Raja Subramanian
5b0f171bef Log actual track IDs during subscription, not just the number of tracks (#493)
* Log actual track IDs instead of just number of tracks

* Log track ids
2022-03-08 19:51:57 +05:30
David Zhao
d57f76fbef Use trackID consistently as log key (#491)
* Use trackID consistently as log key

* more useful logging for track published
2022-03-07 21:02:08 -08:00
David Zhao
130decbf1d CI step for static check (#467)
* CI step for static check

* fix staticcheck
2022-02-24 23:07:15 -08:00
Raja Subramanian
3f38172139 Types for ConnectionID, NodeID, ParticipantKey (#450)
* Types for ConnectionID, NodeID, ParticipantKey

* latest protocol version
2022-02-21 08:52:11 +05:30
Raja Subramanian
f962fef2c8 Apply subscribed track settsings on add (#379) 2022-01-28 08:34:13 +05:30
Raja Subramanian
d1848ab218 Rename UpdateSubscriptionPermissions -> SubscriptionPermission and other renaming (#363)
* Store subscription permission in DB

* Comment out subscription permission to DB

* WIP commit

* Clean up

* clean up

* Latest protocol
2022-01-22 12:16:15 +05:30
cnderrauber
2886ab1e39 RemoveSubscriber through pariticipant (#359) 2022-01-21 12:32:26 +08:00
Raja Subramanian
3d56b7c7f3 Adjustments to allow permissions migration. (#356)
* Adjustments to allow permissions migration.

* Fix tests
2022-01-21 09:43:59 +05:30
cnderrauber
0acb0a9d66 don't send black screen when Track be resumed (#352)
* don't send black screen when Track be resumed

* default flush
2022-01-19 18:14:38 +08:00
David Colburn
5bea9debb7 Code cleanup (#353) 2022-01-19 02:13:06 -08:00
Raja Subramanian
10714b3f6d Adjust interfaces to better work with cloud (#349)
* Adjust interfaces to better work with cloud

* force argument to quality update
2022-01-19 10:28:55 +05:30
Raja Subramanian
e67db84b3b Remove stubs (#331)
* WIP commit

* Use LocalParticipant interface

* Remove no-op local participant

* Remove localparticipant

* Remove no-op stubs

* Consolidate PublishedTrack into MediaTrack
2022-01-12 00:11:48 +05:30
Raja Subramanian
e82b8ea0a0 No op implementation to remove stubs in remote (#327)
* No op implementation to remove stubs in remote

* Place interface first
2022-01-10 19:17:58 +05:30
Raja Subramanian
1bc28240f8 Lock adding to pending subscription (#323) 2022-01-10 12:15:03 +05:30
Raja Subramanian
a9e0598210 uptrackmanager reuse (#318)
* WIP commit

* Remove the double lock

* Remove unused variable

* WIP commit

* Fix test

* WIP commit

* Split out MediaTrackReceiver

* Address comments from David
2022-01-09 10:45:49 +05:30
cnderrauber
8582ca4c9b Session migration (#319)
* migrate between nodes

* session migration

* bug fix

* use version instead of query parameter

* clean code

* clean

* merge master

* solve comments

* solve comment

* update go.mod

Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2022-01-08 18:54:23 +08:00
Raja Subramanian
ecf9590d56 More abstractions (#316) 2022-01-07 01:46:15 +05:30