Commit Graph

246 Commits

Author SHA1 Message Date
David Zhao
aa9534b7fb Server-driven connection quality detection (#167) 2021-11-03 21:05:20 -07:00
Mathew Kamkar
05c4df4e23 Room logger with room name (#165)
* room with logger

* participant with room logger

* transport with room logger

* simplify room logger usage

* simplify logger

* update protocol

* more room logging, test fix
2021-11-02 14:02:45 -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
David Colburn
86d7fe8241 take iceServers out of room (#151) 2021-10-19 19:56:34 -05:00
David Zhao
833e497f37 Pass TrackInfo entirely to ensure fields aren't missing (#150) 2021-10-19 17:27:32 -07:00
Raja Subramanian
2d76c672e3 Use abs-send-time RTP header extension for video downstream (#149)
- Update ion-sfu to v1.20.14
- Enable `abs-send-time` for video tracks

Reference: ion-sfu PR - https://github.com/livekit/ion-sfu/pull/12

Testing:
--------
- Look at SDP offer in subscriber PC and ensure that abs-send-time is negotiated.
- Ensure that downstream packets have `abs-send-time` extension for video packets.

TODO:
-----
- Not yet setting this for audio tracks. Eventually we want to move
to TWCC. This is just a step along the way.
2021-10-19 23:46:04 +05:30
David Zhao
43079866a2 Update to Pion v3.1.5, fixed simulcast / non-simulcast mixing 2021-10-15 09:35:01 -07:00
David Zhao
81712f9502 revert to pion v3.1.0-beta.3
mixing of simulcast and non-simulcast tracks is broken
2021-10-15 00:31:57 -07:00
David Zhao
eba0c23375 Handle TrackInfo.Source attribute (#146)
* Support passing along Source attribute
2021-10-14 13:10:57 -07:00
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
Raja Subramanian
ac4db4575f LK-105 (Opus DTX) (#140)
* LK-105 (Opus DTX)

https://linear.app/livekit/issue/LK-105/allow-enabling-of-opus-dtx

Enable/Disable Opus DTX using SDP answer based on setting in
`AddTrack` request.

Testing:
--------
Chrome and Firefox work. Having audio problems with Safari
(maybe the Safari 15 issue as I am not getting media)

* Check that receiver has no tracks

* Skip non-audio transceivers

* A small clean up to not use pendin track outside lock and also append with spread

* Address comments from review by David

* Update pkg/rtc/participant.go

Co-authored-by: David Zhao <david@davidzhao.com>

* Pull in tagged version of webrtc and lk protocol

Co-authored-by: David Zhao <david@davidzhao.com>
2021-10-13 11:22:33 +05:30
Mathew Kamkar
84ab0f82af Prometheus counters for RTC connection steps (#143)
* signal ws connection, participant join, ice connection

* must register

* offer negotiation

* dz review: offer and offer_response

* dz review: answer
2021-10-12 15:22:17 -07:00
cnderrauber
8ff18e0326 forward fraction lost from subscriber to publisher (#142)
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2021-10-10 21:56:13 -07:00
David Zhao
52e10ea315 handle nil MessageChannel 2021-10-06 22:24:09 -07:00
David Zhao
797d2607c4 Fix NACK handling in simulcast (fixed in ion-sfu) 2021-10-04 17:17:41 -07:00
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
20d0c0ca43 Fix mute of simulcasted video tracks with < 3 encodings (#114) 2021-09-14 15:50:34 -07:00
David Zhao
1bcaf9d0ea update test client to use protocol 3 2021-09-10 20:58:33 -07:00
hn8
2d215f80b3 Restore SetLogger (#111)
- Fix buffer.NewBufferFactory: logger.GetLogger() has extra depth. Passing empty logger will use default logger set by serverlogger.SetLogger()
2021-09-10 13:34:46 -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 Colburn
2a3fb5f0e7 move logging to protocol (#109) 2021-09-09 00:45:42 -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
hn8
6a88bcc2d7 feat: support windows dev env (#101)
Works in Git Bash and PowerShell in Windows 10
2021-08-30 11:36:49 -07:00
David Colburn
8a44fad307 protocol 0.8 (#95)
* protocol 0.8

* merge new selector
2021-08-27 13:16:33 -05:00
Mathew Kamkar
f5466c74e6 list-nodes command action (#87)
* list-nodes command action

* refactor stats into a package

* store existing stats in redis, more refactoring

* dz review: atomic load
2021-08-24 10:14:39 -07: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 Zhao
5713731363 allow user to mute before track is fully published (#82)
fixes https://github.com/livekit/client-sdk-js/issues/28
2021-08-10 21:09:23 -07:00
David Zhao
b8e1cbe4f5 fix: avoid placing user in a layer that's not published 2021-07-30 21:29:19 -07:00
hn8
c682982af2 Update TLS port default as rfc5766 (#68) 2021-07-23 15:11:11 -07:00
David Colburn
8e872881c1 use receiver lb threshold option 2021-07-22 21:52:56 -07:00
David Colburn
4bab395ac9 Hidden participants (#65)
Enables hidden recording and/or forwarding participants
2021-07-19 18:33:28 -05:00
hn8
87dfb2b117 log: consistent log key (#60) 2021-07-19 10:28:51 -07:00
David Zhao
c493022f0f fix force_tcp flag: don't set UDPMux when enabled (#62) 2021-07-19 09:16:01 -07:00
hn8
99e9997d0a feat: support SetLogger & SetLoggerFactory (#57)
* upgrade logr to stable release v1.0.0

* feat: support SetLogger & SetLoggerFactory
2021-07-18 21:28:09 -07:00
David Zhao
55eb654a1b When adaptive-simulcast is used, allow subscribers to switch to the next available layer (#55) 2021-07-16 14:24:00 -07:00
David Zhao
4ce29799cf remove H.264 profile 42001f. Safari (14.1.1) does not playback tracks offered in this profile 2021-07-13 22:32:38 -07: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
David Zhao
a80e8cf69f Enable passing in local IP, refactored IP detection (#48)
* Enable passing in local IP, refactored IP detection

* update docker server instructions
2021-07-11 08:42:11 -07:00
David Colburn
50538db21f update log keys 2021-07-09 10:49:21 -07: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
4ec2959950 Use discreet ports by default due to write bottleneck (#40) 2021-07-06 15:08:46 -07:00
David Zhao
6751361187 Feature: codec restrictions.
In order to ensure clients are publishing with compatible codecs, the server can enforce codec restrictions.
2021-07-02 16:54:54 -07:00
David Zhao
343aec98a0 Remove STUN candidates, disconnect clients on ICE failed 2021-06-28 12:47:16 -07:00
David Colburn
815fd5066d remove unconnected participants after 1m 2021-06-26 18:38:44 -07:00