Commit Graph

66 Commits

Author SHA1 Message Date
Raja Subramanian
1dcc62b569 SubscribedQualityUpdate message (#270)
* WIP commit

* SubscribedQualityUpdate message to send list of currently subscribed
qualities for a simulcast video publisher

* Correct subscriberID

* goimports

* Do quality update on add/remove of subscribed track

* do not update quality when admin mute is active

* update quality on admin unmute

* Update protocol version

* Simplify max subscribed quality loop per David's suggestion
2021-12-19 12:41:40 +05:30
Raja Subramanian
e504b6678c Deficient state handling when a track needs a change (#261)
* WIP commit

* deficient handling

* Add missing ProvisionalAllocatePrepare

* adjust state on track removal

* Increase test timeout

* - Add comments about cooperative routines
- Take down transition if available in cooperative scheme
- Use layer comparison when taking down transition. Because of when the
  bitrate is measured, it is not always guaranteed bandwidthDelta is -ve
  when moving down.
- Do not add track to stream allocator till bind.

* make comment better

* a bit more clear comments

* Use OnBind on subscribed track
2021-12-16 10:58:34 +05:30
Raja Subramanian
e54ce4f674 Stream Allocator Try 3 (#257)
* Stream Allocator Try 3

Making an intermediate PR to do
- Special treatment for screen share tracks
- When allocating all tracks,
  o try to stream all tracks by starting with the lowest layer
  o multi-pass across tracks to get a more even distribution

Not yet done:
-------------
In deficient state,
o Allocate a specific track on a change
o Steal from other tracks

* Correct sense of managed track

* have to range to copy

* generate

* fix VideoLayers compare

* Use t.simulcasted
2021-12-14 12:48:09 +05:30
David Zhao
d342335d09 Split out SignalHandler to simplify testing (#250) 2021-12-10 13:12:45 -08:00
David Zhao
2d93ccd668 Updated protocol from protocol/proto -> protocol/livekit (#242)
* Updated protocol from protocol/proto -> protocol/livekit

* separate MediaTrack from PublishedTrack
2021-12-08 13:58:38 -08:00
David Zhao
318bee4f1e Improve video quality selection by using publisher feedback (#238) 2021-12-06 12:12:08 -08:00
David Colburn
c41384cd09 ActiveRecording (#234)
* ActiveRecording

* regenerate

* update to 0.10.3

* 1.17
2021-12-03 21:40:53 -08:00
cnderrauber
6510692f23 export structures for cloud (#220)
* export structures for cloud


Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2021-12-02 13:57:22 +08:00
David Zhao
6dcb29c559 Use publisher PC as default with publish-only connections (#198) 2021-11-20 22:28:36 -08:00
David Colburn
95e29d3766 Interface updates (#194)
* update interfaces, a bit of cleaning

* regenerate

* return interface for RoomService

* export packetBufferSize

* update router interface

* move participant key into router

* change locks back

* read only room store

* fix server rm locks

* update SendJoinResponse

* clean up imports

* update room messaging

* regenerate
2021-11-15 15:25:50 -06:00
cnderrauber
1e1aaeb86b Separate from ion-sfu (#171)
* Separate from ion-sfu

changes:
1. extract pkg/buffer, twcc, sfu, relay, stats, logger

2. to solve cycle import, move ion-sfu/pkg/logger to pkg/sfu/logger

3. replace pion/ion-sfu => ./
reason: will change import pion/ion-sfu/pkg/* to livekit-server/pkg/*
after this pr merged. Just not change any code in this pr, because it
will confused with the separate code from ion-sfu in review.

* Move code from ion-sfu to pkg/sfu

* fix build error for resovle conflict

Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2021-11-09 12:03:16 +08:00
David Zhao
6a80beedfc Only send connection quality updates for protocol 5+ 2021-11-03 23:09:25 -07:00
David Zhao
aa9534b7fb Server-driven connection quality detection (#167) 2021-11-03 21:05:20 -07:00
David Zhao
7442551ae5 Fix missing participant updates race (#163)
* Fix faulty participant update buffering.

* Fix bug with broadcasting out of order

* dedicated participant update worker, without locks

* use tracker to drop duplicate/out of date messages

* additional lock around filter logic
2021-10-31 15:20:46 -07:00
David Zhao
0898c17e8a Select video quality using provided dimensions (#158) 2021-10-28 21:01:05 -07:00
Raja Subramanian
e0e46e079d Prevent missing entry in pending tracks (#152)
* Prevent missing entry in pending tracks

Problem:
--------
A track received via signalling request `AddTrack` is stored
in `pendingTracks` of participant. A MediaTrack is created
when `onTrack` fires after `SetRemoteDescription`. At that
time, pending tracks are searched to find a matching track
and look up an already published MediaTrack.

This is because `onTrack` fires once for every layer of
Simulcast and MediaTrack abstraction is for a media track and
not one for every layer of Simulcast track.

To accomplish that, pending tracks are cleaned up 5 seconds
after the MediaTrack is created. The theory there is that
`onTrack` will fire on all layers within 5 seconds. But, have
observed several instances on my slow machine of that firing
after 5 seconds which results in the search failing and we end
up creating a new MediaTrack.

The above is probably the reason (I am guessing though) for
subscriber PC having an extra m-line some times.

Considered fix:
---------------
One possible option is to increase that 5 seconds timeout to a
very large value. But, it has another issue.

`getPendingTrack` is given the track id which comes in the SDP.

Entries are added to the pending tracks using track id received
via the `AddTrack` signalling message.

And those two need not be the same. Especially Firefox has different ids
every time. Not sure if that is something we do on client side which
causes that, but it does look like a real possibility.

To handle that case, `getPendingTrack` looks up tracks by media kind
(audio/video) if the look up by SDP client id fails.

Here, it is possible that there are two pending tracks of type video
(think camera and screen sharing as an example) and looking up by kind
might end up picking the wrong one.

Fix:
----
Store the signalled client id and SDP client id in the MediaTrack and
look up the published tracks by SDP client id for a track match.

If there is no match, create a new MediaTrack and add it to publishedTracks
and delete the corresponding pending track all within the lock (yeah not
great to have a lot of code within the lock, but this is probably worth
it to have the correctness).

This does solve the issue of deferred pending track removal causing issues.

However, note that kind based look up may do some switching. In a scenario
where there are two pending tracks of kind video and the look up has to
rely on kind, it is possible that signalCid and sdpCid get cross matched
(i. e. client might have sent a signalCid for a Simulcast track, but during
kind based look up it gets assigned to a non-simulcast track). I think
that is okay as there is no strong correlation between the two.

Testing:
--------
- Connect from Chrome, Firefox (both orders, Chrome joining first, Firefox joining first) and ensure that media subscriptions and publishing are correct
- Ensure that DTX munging works properly too.

* Fix tests

Add back adding track to publishedTracks for testing purposes.

* Add a test to check case of `AddTrack` rejecting already published track

* Remove debug.

* Address PR comments - do not need to return SDP cid from `getPendingTracks`.
2021-10-21 12:50:07 +05:30
Raja Subramanian
d08646f17e Reuse transceivers (#145)
* WIP - Re-use transceiver

* Support both old and new methods for adding transceiver
2021-10-14 11:57:59 +05:30
Théo Monnom
939ed10ca6 Room Metadata Implementation (#126) 2021-10-02 22:08:29 -07:00
David Zhao
ff47301820 Implements protocol 3 speaker updates (#120)
* Disallow AddTrack from participants that don't have the permission

* Support protocol 3 speaker updates, client info

* update protocol

* Disallow AddTrack from participants that don't have the permission

* increase wait time for GH to pass
2021-09-17 11:47:13 -07:00
David Zhao
614ede2edc Supports client protocol 3 - subscriber as primary (#110)
* use subscriber connection as primary whenever possible

* backwards compat for data messages

* bump protocol version
2021-09-09 00:53:15 -07:00
David Zhao
e82d50d717 Send explicit message to clients for mute/unmute. (#107)
* Send explicit message to clients for mute/unmute.

* documentation in config
2021-09-01 21:50:02 -07:00
David Colburn
8a44fad307 protocol 0.8 (#95)
* protocol 0.8

* merge new selector
2021-08-27 13:16:33 -05:00
David Zhao
bcf6e15e07 SendData API & publishData permission (#88)
* SendData Server API

* SendData Server-API adjustments based on suggestions

* Update proto version

* enforce publishData permission

* go mod tidy

* fix go.mod

* go mod tidy

Co-authored-by: ChesterMing <89124853+ChesterMing@users.noreply.github.com>
2021-08-19 18:11:48 -07:00
David Zhao
29edf4e8d9 Improve dynamic simulcast, properly cleanup after pendingTracks (#84) 2021-08-13 15:49:25 -07:00
David Colburn
4bab395ac9 Hidden participants (#65)
Enables hidden recording and/or forwarding participants
2021-07-19 18:33:28 -05:00
David Zhao
53b52a67ca use protobuf for clients with protocol > 1 (#52) 2021-07-13 22:28:34 -07:00
David Zhao
850fecf931 Allow publishers to set layer availability (#51)
* support client message to update active layers

* update to match new protocol
2021-07-13 21:35:08 -07:00
David Colburn
5fdb6361cd Dev debug info (#50) 2021-07-13 14:05:25 -05:00
hn8
dcfe7eaf4f Enhancement: audio speakers (#44)
* refactor: active speakers

1. Observe the loudest adjusted with active ratio instead of linear average of decibel values
2. Follow RFC6465 to convert audio level from decibel to linear value.
3. Quantize audio level for stable slice comparison
4. Switch moving average algorithm from MMA to EMA to have the same center of mass with SMA
5. Minor: remove seenSids map allocation
6. Minor: minimize division arithmetic

* Update pkg/rtc/audiolevel.go

Co-authored-by: David Zhao <david@davidzhao.com>
2021-07-09 09:46:24 -07:00
David Zhao
3b2b3a4929 debounce track settings API to match client usage pattern 2021-06-22 14:13:24 -07:00
David Zhao
69290c535b Send full update after joining when there are missed updates 2021-06-19 00:14:40 -07:00
David Zhao
38c81e5645 Support for video dimensions in publications (#36)
* send back video dimensions

* Store video dimensions in MediaTrack and forward in TrackInfo

* use committed protocol
2021-06-18 21:05:56 -07:00
David Zhao
0900054c24 ability to disable auto subscribe per participant 2021-05-22 22:54:47 -07:00
David Zhao
c76cdf11c2 add tests to ensure subscriber cleanup 2021-05-12 23:52:41 -07:00
David Zhao
6b63cd5b31 Revamp data channels (#32)
* support for built-in data channels. active speaker updates via data channel

* fixed tests

* update to Pion 3.0.27
2021-04-27 22:02:59 -07:00
David Zhao
3b236f0d72 handle client reconnect with ICE restarts 2021-04-19 16:51:20 -07:00
David Zhao
93d10b2640 Manual negotiation and plan-b support 2021-04-16 00:56:25 -07:00
David Zhao
e4238890ff Refactor/cleanup of negotiation path 2021-04-15 17:03:22 -07:00
David Zhao
b90f851be5 return participant connected timestamps 2021-03-28 21:05:20 -07:00
David Zhao
537edda4c3 handle new UpdateParticipant API, enable permission updates 2021-03-20 22:27:47 -07:00
David Zhao
f7ed2cee60 RoomService.updateParticipantMetadata, participant permissions 2021-03-16 01:22:21 -07:00
David Zhao
7d02c01fd8 refactor - moved common code to livekit/protocol 2021-03-13 22:01:51 -08:00
David Zhao
e20c831c14 automatic configuration of TURN, with per-room credentials. version 0.6.0 2021-03-07 23:30:21 -08:00
David Zhao
e402d0d0af subscriber control of tracks (unsubscribe/mute/quality), support simulcast (#23)
* subscription control & simulcast RTC APIs

* don't remove tracks for simulcast
2021-02-16 13:52:50 -08:00
David Zhao
a96069969d support audio level extension & active speaker detection (#20)
* send active speaker updates with audio level

* add test on loudness sorting

* use a float to represent audio level
2021-02-14 14:30:23 -08:00
David Zhao
090f8d0664 use dedicated PeerConnections for sending and receiving (#19)
* protobuf updates to support new protocol

* use dedicated publish & subscribe peerconnections

* update client to work with dedicated PCs

* fix Go client negotiation, reduced length of UUID
2021-02-12 22:30:31 -08:00
David Zhao
538461d5dc pass client defined metadata from JWT to participant (#17) 2021-02-10 23:13:36 -08:00
David Zhao
f1f5b8dafe use proper fix for using shared bufferFactory, remove resync hack 2021-02-07 23:06:16 -08:00
David Zhao
fa9d2af495 use ion-sfu commit 2021-02-06 23:18:21 -08:00
David Zhao
290e100d0d fix generation 2021-02-06 23:15:30 -08:00