Commit Graph

837 Commits

Author SHA1 Message Date
Raja Subramanian
9032db857c Connection quality clean up (#766)
* WIP commit

* WIP commit

* Remove debug

* Revert to reduce diff

* Fix tests

* Determine spatial layer from track info quality if non-simulcast

* Adjust for invalid layer on no rid, previously that function was returning 0 for no rid case

* Fall back to top level width/height if there are no layers

* Use duration from RTPDeltaInfo
2022-06-18 21:58:47 +05:30
cnderrauber
651d2aee4d fix datachannel to same postion as previous negotiate (#765) 2022-06-17 18:28:57 +08:00
Raja Subramanian
bbd5d3739f Use logger with context (#764) 2022-06-17 11:12:29 +05:30
Raja Subramanian
568d6c5432 Do not munge VP8 header in place. (#763)
As the buffer could be used to send to remote nodes, the publisher
side buffer should be treated as read-only.
2022-06-16 20:25:26 +05:30
cnderrauber
d15725c662 publish new codec when subscriber needed (#762)
* publish new codec as needed
2022-06-16 18:16:34 +08:00
Raja Subramanian
83b71fce50 Set SSRC for RTCP (#760)
- SenderSSRC was not set for NACK, RTCP_RR - so SRTP context
was using SSRC = 0 which is not bad, but let us set the SSRC properly.
- PLI was using a random SSRC on every PLI. So, that would have
created a new SRTP stream (not bad as that stream context is small)
on every PLI. It is wasteful. So, set the SenderSSRC to the mediaSSRC.
- Reduce re-start of higher layers to 10 seconds. That is long enough
to declare that a stream layer has restarted.
2022-06-16 12:07:21 +05:30
Alessio
558be854be Add turn relay start and end port configuration (#733) 2022-06-13 15:03:12 -07:00
David Colburn
4be096cf74 Update egress RPC handler (#759)
* egress rpc handler

* add egress statuses

* nil redis client

* update protocol
2022-06-13 12:18:17 -07:00
cnderrauber
15da445fd7 fix subscription update on codec change (#757) 2022-06-10 12:31:34 +08:00
Raja Subramanian
4701119885 Proto clone VideoLayer (#756)
Otherwise, there are warnings about copying locks.
2022-06-09 09:32:57 +05:30
cnderrauber
15e91344be add disabled_codecs to client conf, and disable it at server side (#755)
* add disabled_codecs to client conf, and disable it at server side

* update go mod
2022-06-08 15:55:48 +08:00
cnderrauber
90ae3892b3 add simulate switch candidate (#754)
* add simulate switch candidate

* update go mod
2022-06-07 17:56:41 +08:00
Raja Subramanian
e72fd80ca0 Move rtp stats log to info (#752) 2022-06-06 22:20:48 +05:30
David Zhao
c62def3fdf Use stable TrackID after unpublishing & republishing (#751)
Multiple parts of the system relies on a Track's ID (egress, telemetry, etc).
Track ID changes when a track was unpublished, then republished with the
exact same attributes. This PR would allow us to re-use a previously
unpublished Track ID
2022-06-05 23:31:51 -07:00
shishirng
2927521b8b Send publisher max layer change info to telemetry (#748)
Signed-off-by: shishir gowda <shishir@livekit.io>
2022-06-02 14:15:23 -04:00
cnderrauber
6ba034feae shorten the time cost for subscriber get media tracks (#747)
* set DownTrack's initial codec to first codec of potential codecs

* faststart on subscribe
2022-06-02 10:00:42 +08:00
shishirng
46301d7d6f Send layer dimensions when max subscribed layers change (#746)
Signed-off-by: shishir gowda <shishir@livekit.io>
2022-05-31 11:46:08 -04:00
Raja Subramanian
4ed9b5f90e Revert "Using shadow pattern for stats workers (#742)" (#744)
This reverts commit 2b561d2bad.
2022-05-31 11:06:44 +05:30
Raja Subramanian
f19815754c Do not re-compute average on real time metric change (#743) 2022-05-31 10:33:17 +05:30
Raja Subramanian
2b561d2bad Using shadow pattern for stats workers (#742) 2022-05-31 10:32:54 +05:30
Raja Subramanian
508aa471a9 Track participant join total + rate in node stats (#741)
* Track participant join total + rate in node stats

* update protocol
2022-05-30 15:58:30 +05:30
cnderrauber
62308b2ce0 set DownTrack's initial codec to first codec of potential codecs (#740) 2022-05-30 16:34:55 +08:00
Raja Subramanian
10b0c9b9ff Allow overshooting maximum when there are no bandwidth constraints. (#739)
* Allow overshooting maximum when there are no bandwidth constraints.

Some clients prioritize sending higher layer of video (for e.g.
Firefox). They may get into a state where congestion does not allow
sending lower layers.

That combined with adaptive streaming capping the max layer at a
certain level, it is possible to get into a state where video is
not streamed.

To make this experience better, allow overshoot beyond max layers
in case of optimal (i. e. no congestion) allocation.

NOTE: This means that the video could freeze when there is congestion
even if `AllowPause` is not disabled as in congested state, we do
not overshoot the max layer.

* log about allowing overshoot
2022-05-30 13:51:59 +05:30
David Zhao
73808a1623 Remove TrackSender.ParticipantIdentity since it's unused (#738)
Just introduced this in #736 and realized the interface change comes
with a bunch of unintended consequences, so reverting this addition.
2022-05-29 23:22:03 -07:00
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
3a45f93fdd disable AV1 and VP9 by default (#735) 2022-05-29 12:30:42 +08:00
Brint E. Kriebel
5a74c1695d Add support for Redis Sentinel (#707) 2022-05-28 10:26:58 -07:00
Raja Subramanian
80f8bc6c62 Re-introduce quantization of audio level to dampen small changes (#732) 2022-05-28 22:45:21 +05:30
David Zhao
1166d27a89 Fix duplicate subscriber connected (#729)
* Fix duplicate participant not being cleared out

* handle data race
2022-05-27 22:02:24 -07:00
David Colburn
f181b24b06 fix list-egress (#722) 2022-05-27 13:17:53 -07:00
David Zhao
a4882b9866 Improve thread safety with participant callbacks (#728) 2022-05-27 12:26:07 -07:00
shishirng
cb9f0d37c2 Use rtcscore-go to calculate audio/video score (#689)
* Use rtcscore-go to calculate audio/video score

Signed-off-by: shishir gowda <shishir@livekit.io>

* Get max expected layer and find max actual layer from stream

Signed-off-by: shishir gowda <shishir@livekit.io>

* Cleanup unused methods

Signed-off-by: shishir gowda <shishir@livekit.io>

* Cleanup code - address review comments

Signed-off-by: shishir gowda <shishir@livekit.io>

* get expected layer info instead of just quality

Signed-off-by: shishir gowda <shishir@livekit.io>

* Move SpatialLayerForQuality to utils/helpers

method is required in rtc,sfu and connectionstats pkg
Moved to utils/helpers.go to remove cyclic deps

Signed-off-by: shishir gowda <shishir@livekit.io>

* update tests

Signed-off-by: shishir gowda <shishir@livekit.io>

* Pick stream stats with max layer

Signed-off-by: shishir gowda <shishir@livekit.io>

* Update rtcscore-go pkg to make rtt/jitter optional

when passing 0, rtcscore-go was setting default values

Signed-off-by: shishir gowda <shishir@livekit.io>

* update score to rating

Signed-off-by: shishir gowda <shishir@livekit.io>

* Update rtcscore-go pkg to use simulcast layer info for score

Signed-off-by: shishir gowda <shishir@livekit.io>

* Update score ratings to reflect rtcscore range

Signed-off-by: shishir gowda <shishir@livekit.io>

* update test params for new rtcscore

Signed-off-by: shishir gowda <shishir@livekit.io>

* Delay sending scores to connections only till full data is available

first interval can have partial data leading to lower scores

Signed-off-by: shishir gowda <shishir@livekit.io>

* Check for inf values in quality params

Signed-off-by: shishir gowda <shishir@livekit.io>

* Clean up initial score calculation. Default to 5

Signed-off-by: shishir gowda <shishir@livekit.io>

Co-authored-by: David Zhao <dz@livekit.io>
2022-05-27 14:58:26 -04:00
shishirng
20681abcdc handle data race between updateState and OnStateChange (#727)
Signed-off-by: shishir gowda <shishir@livekit.io>
2022-05-27 12:54:19 -04:00
Raja Subramanian
a1c7332943 Use a shadow for receivers for safe range (#725)
* Use a shadow for receivers for safe range

* RLock layerSSRCs

* access max subscribed quality inside lock

* Fix go vet errors

* use defer
2022-05-27 22:11:34 +05:30
Dan McFaul
aa0df2813f deleting nonRtc rooms and fixing race when deleting rooms (#721) 2022-05-27 09:45:22 -06: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
3054f3eea3 Protect TrackInfo (#724)
* Protext TrackInfo

Also making a copy rather than changing params.

* prevent recursive lock

* Remove double lock

* Rework early return a little bit
2022-05-27 13:32:45 +05:30
cnderrauber
5f9cdfbd90 fix repeated AddSubscriber of MediaTrackSubscription (#723) 2022-05-27 15:42:17 +08:00
Raja Subramanian
d77a8ad916 Use proper type cast (#719) 2022-05-26 13:58:46 +05:30
Raja Subramanian
77b8e9eecb Fix a couple of more races (#717)
* Use grants clone

* Fix a couple of more races

Use a shadow copy of down tracks in DownTrackSpreader.
Read always uses the shadow.
On Add/Delete of down track, make a new copy.
Copying is done only on add/delete.
If somebody is holding reference to a shadow, it will be in tact as Add/Delete create a new slice.

With this, not seeing any more races in test. So, enabling CI tests with `-race`.

Also fixing another race reported in #603

There are a couple of more races in that bug report that needs to be
chased down.

* Use env suggested in https://lifesaver.codes/answer/runtime-race-detector-sigabrt-or-sigsegv-on-macos-monterey-49138

* staticcheck, did not fail locally, but reported by CI

* use API to get down tracks
2022-05-25 16:14:07 +05:30
Raja Subramanian
73db950ea4 Use grants clone (#716) 2022-05-25 15:29:23 +05:30
Raja Subramanian
08f047c157 Fix test race in grants (#715) 2022-05-25 12:31:31 +05:30
Raja Subramanian
11fb079a4f Catching a few more races reported by go test -race ./... (#713)
* Fix a few more races

* Make sure room store on leave has correct count

* Revert logger change to reduce diff
2022-05-25 07:32:25 +05:30
Dan McFaul
0589d757cd in some implementations of Store, particpant and their tracks may not yet have been persisted when a mute event is received, don't want to error in that case (#714) 2022-05-24 12:30:09 -06:00
Raja Subramanian
9d0e4375f2 Use blank frames at frame rate (#710)
* Inject silence opus frames on mute.

If not, under certain circumstances, residual noise
seems to trigger comfort noise generation at the decoder
which is not all that comfortable.

* inject silence only when muting

* Add comment

* augment comment

* Delete blank line

* Adjust TS offset on blank frames

* Remove debug

* Do not modify `lastTS` as it affects timestamp on next switch.

* Trying more stuff for DTX

* - Use a go routine to send blank frames
- Use duration instead of number of frames and calculate number of
  frames

* augment comment

* Remove debug

* Return a chan from writeBlankFrameRTP

* Use a long duration for mute

* add comment

* Incorporate suggestion from Jie
2022-05-24 13:25:19 +05:30
Raja Subramanian
33032f6c4b Fix some test races and other things found with go test -race (#711) 2022-05-24 10:16:36 +05:30
Raja Subramanian
a1e264bf34 Make a copy of available layers in forwarder. (#709)
Should be okay as that is usually only three elements max.

Stream tracker + manager send available layers. As stream trackers
run in different go routines, need to think some more about chances
of out-of-order operations. But, making a copy in forwarder so
that it is not referncing moving data.

Also, when setting up provisional allocation, make a copy
(that was the intention, i. e. a provisional allocation should have
stable data to work with).
2022-05-23 17:41:19 +05:30
David Zhao
a933f1513f Add pprof endpoint when running in dev mode (#708) 2022-05-23 00:34:16 -07:00
Raja Subramanian
96b095504b Fix some races reported by go -race (#706)
* Fix some races reported by go -race

* Avoid copy
2022-05-23 11:51:13 +05:30
David Zhao
cdf1724d80 Batch subscriber updates to reduce noise (#703)
Improve scalability by batching subscriber updates on an interval.
When lots of subscribers join, the server ends up spending 20% CPU
sending each state change to everyone. There's a non-trivial amount of
overhead with each send operation.

For publishers, updates are sent right away.
2022-05-20 22:54:02 -07:00