Commit Graph

79 Commits

Author SHA1 Message Date
shishirng 26eea78b54 Telemetry connection scores (#377)
* octets - total bytes needs to be uint64

uint32 wraps at 4GB

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

* Cleanup stats handler to use connectionQuality stats

remove per packet rtcp handlers, buffer stats

* cleanup connection stats

* Update mediatrack to store rtcp stats in connection stats

* Update downstream handling of connection stats and telemetry

* Update telemetry tests

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

* Misc fixes

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

* Minor fix to avoid accessing buffer before its allocated

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

* start updateStats worker in AddReciever()

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

* Use previous score to calculate avg scores

* Restructure connectionStats

Signed-off-by: shishir gowda <shishir@livekit.io>
2022-01-27 11:24:54 -05:00
Raja Subramanian 44afa8bae1 Delete down track on close (#374)
Note that it is called from Unbind also (previous behaviour). It should
be fine as long as there is no new down track for the same peer added
between close calling it and unbind calling it.
2022-01-26 13:22:39 +05:30
Raja Subramanian 6a46958870 Some receiver clean up (#364) 2022-01-23 08:22:39 +05:30
Raja Subramanian 0178a004dd Compile in send-side bandwidth estimation. (#351)
Still not using it. But, now that Pion has merged the initial
version of GCC (Google Congestion Control) for send side bandwidth
estimation, we can integrate it.

We will enable once we have tested and feel comfortable.
2022-01-19 22:36:41 +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
David Zhao f2f776931f Integrated logging with Pion (#341)
* Integrated logging with Pion

* handle nil logger
2022-01-14 17:44:28 -08:00
Raja Subramanian 017ed13338 Prevent multiple resume notifications on track (#334)
* Prevent multiple resume notifications on track

When returning previous allocation as is, reset change to none.
Ideally, would like to have change as a separate return and not in last
allocation. But, also prefer to have last allocation state. For now,
resetting change.

* log bandwidth estimate only on decrease
2022-01-12 23:19:56 +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
boks1971 973420faf5 Revert "Refactor media track subscriptions"
This reverts commit 9ca85454ed.
2022-01-04 16:57:49 +05:30
boks1971 9ca85454ed Refactor media track subscriptions
- To enable re-use of common bits
- Add max quality from other nodes
2022-01-04 16:40:47 +05:30
Raja Subramanian 995c1e8676 type aliases -> type definitions (#312)
* type alias -> type definition

* participantSid -> participantID in a comment

* Update protocol
2022-01-03 12:43:58 +05:30
Raja Subramanian 66a1ffe414 Allow cooperative allocation (#309) 2022-01-01 13:43:34 +05:30
Raja Subramanian 8d0fb179a0 Layer 0 and non-simulacst tracks also can be fully unsubscribed. (#308) 2021-12-31 14:04:22 +05:30
Raja Subramanian fc95757c7d Do not pause if pause is not allowed (#307) 2021-12-31 09:58:13 +05:30
Raja Subramanian 98586c2490 A simple configuration for congestion control. (#305) 2021-12-31 00:26:29 +05:30
Raja Subramanian 107e7bbb39 Configurable bandwidth estimation side (#298)
* Fix tests

Add back adding track to publishedTracks for testing purposes.

* WIP branch

* Don't know why merge from `master` did not catch this change.

* WIP commit

* Hook up all the bits for TWCC to work

* Fix typo

* WIP commit

* Catch up to latest API

* Move RTP/RTCP info config

* Instantiate GCC/TWCC interceptor only when in use

* comment SSBWE parts

* RTCP feedback in publisher config
2021-12-30 20:09:03 +05:30
Raja Subramanian 03000f88cb Adaptive publishing improvements (#295)
* Adaptive publishing improvements

* fix tests

* proper comment sentence

* Address comments from David

* proper locking

* fix crash

* Do not start quality timer if not video
2021-12-30 09:50:53 +05:30
Artur Shellunts 828d490755 Imlement analytics per track statistics (#281)
New tests for telemetry + implementation of per track statistics
2021-12-29 19:29:24 +01:00
David Zhao 554baa54f6 Avoid locking while waiting for receiver read (#288)
A deadlock was observed in this section, when Read was waiting for data.
2021-12-27 13:35:30 -08:00
Raja Subramanian ee99a323d2 Publisher controlled flex permissions (#284)
* WIP commit

* Add some tests

* allowedSubscribers uses participant sid

* correct variable name

* correct another variable name

* Add ParticipantSid to SubscriptionPermissionUpdate message

* protocol v0.11.2

* WIP commit

* WIP commit

* fix tests

* Remove unused code

* Close uptrack manager

* Remove duplicate close

* move comment to the correct line where the loop could be long

* Fix disallowed list revocation, thank you Jie

* Remove unneeded interface method

* RemoveSubscriber in Participant

* Clean up disallowed subscriptions and handle permissions on new track addition

* add test for track addition after permission set

* Remove unnecessary check
2021-12-24 14:14:40 +05:30
shishirng e6543f3b9e Convert jitter from MicroSecs to MilliSecs (#282)
Signed-off-by: shishir gowda <shishir@livekit.io>
2021-12-22 12:37:45 -05:00
shishirng 0f728b0b72 Connection quality v1 (#260)
* audio connection quality mos for publisher stats

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

* Update tests

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

* Change ratings range, increase default rtt to 80

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

* Use stats worker to get total packets to find %lost in window

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

* Update go dep

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

* Increase interval of score cal to 5 seconds

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

* use lastSequenceNumber in reports to find total packets

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

* Account for delay while calculating scores

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

* Fix minor typo

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

* Add connection stats/score to subscribed audio tracks

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

* Cleanup

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

* Ignore duplicate LastSequenceNumbers in rtcp reports

Ignore if sequence number is less than what was recieved

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

* Move video track score calc to media/downtracks

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

* Deprecate SubscribeLossPercentage() as score calc is now handled downstream

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

* Initialize connection  score to excellent

score is calc at 5sec interval. Client fetches score before first
score is computed

* Update test cases for connection quality

Signed-off-by: shishir gowda <shishir@livekit.io>
2021-12-20 07:54:14 -05:00
Artur Shellunts b0454b00a2 Count padding bytes in telemetry (#264)
Count padding bytes in telemetry outgoing total bytes
2021-12-20 12:04:50 +01:00
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
David Colburn 0b71a46239 missed some typos 2021-12-17 13:25:41 -08:00
David Colburn faa870de3d Move callbacks out of messageRouter (#269)
* move callbacks out of messageRouter

* OCD

* more OCD

* fix forwarder test

* even more OCD

* maximum OCD

* package name collision, copy lock by value
2021-12-17 13:19:23 -08:00
cnderrauber a06edd885e fix panic in forwarder (#268)
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2021-12-17 23:51:06 +08:00
Raja Subramanian 502c57d787 Fix forwarding status deduction (#267)
* Fix forwarding status deduction

- When muted OR when there are no available layers, declare optimal
- When target layer is the maximum it can achieve taking available
  layers into account even if they are not the maximum subscribed layer,
  it is still optimal as there is nothing better available.

* Fix and add more tests for forwarding status
2021-12-17 15:45:04 +05:30
Raja Subramanian a8fe06e083 Delete unused method (#266) 2021-12-17 13:16:55 +05:30
Raja Subramanian 62feed3983 Clean up down track type as it is not used (#265) 2021-12-17 13:00:44 +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
Raja Subramanian 1be3a3986d Recover VP8 MBit properly when unpacking from packetMeta (#255)
* Recover VP8 MBit properly when unpacking from packetMeta

* one liner for itob
2021-12-11 10:06:04 -08:00
David Zhao 8abd734d16 Use participant and room specific loggers (#252) 2021-12-10 15:51:05 -08:00
Raja Subramanian 8c774f144e Tightening up stats and also counting primary/rtx/padding separately (#247)
* Tightening up stats and also counting primary/rtx/padding separately

* Fix tests

* annotate type stored in atomic.Value
2021-12-10 19:30:27 +05:30
Raja Subramanian 7948fabce0 StreamAllocator tweaks (#240)
* WIP commit

* test padding only with a gap scenario

* Debug

* Fix video corruption, need buffer to include payload and translated header size

* Revert incorrect change

* Fix VP8 translation to return buffer with proper length

* Restore 7-bit mode

* WIP commit

* Clean up

* More clean up and tests compiling again

* Fix tests
2021-12-08 21:56:07 +05:30
Raja Subramanian 5dc0a43b29 Unit tests for sfu.Forwarder (#239) 2021-12-07 02:51:08 +05:30
David Zhao 318bee4f1e Improve video quality selection by using publisher feedback (#238) 2021-12-06 12:12:08 -08:00
Raja Subramanian ff390820e1 Make VP8 packet translation thread-safe. (#237)
* Make VP8 packet translation thread-safe.

Was using one packet from pool for all VP8 translation which was not thread safe.
Grab packets from the pool when needed for VP8 translation and return to pool after done.
Do not grab packet from pool if the header size between incoming and translated matches.
That also saves copying the packet payload.

* Keep Get/Put in the same function.
2021-12-05 10:01:35 +05:30
Raja Subramanian 45690bc301 Use StreamStateChange with a single list (#235)
* Use StreamStateChange with a single list

Use enum for state change indication on associated track.

* update protocol version
2021-12-04 11:57:23 +05:30
Raja Subramanian edafb0a118 VP8Munger tests (#229)
A bit of clean up of unused bits.
2021-12-03 21:57:49 +05:30
Raja Subramanian 6141567aef Unit tests for VP8 pack/unpack in packetMeta. (#228)
Deleting unused code.
2021-12-03 15:37:49 +05:30
Raja Subramanian ac650cd21d RTPMunger unit tests (#227) 2021-12-03 14:47:00 +05:30
Raja Subramanian 5eb58bcb41 Fixing a couple of bugs in StreamAllocator (#225)
* Debug

* More debug

* break -> return

* comment

* Clean up

* spelling fixed
2021-12-02 14:43:56 +05:30
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
Raja Subramanian 96a3f3e9a7 Minor clean up (#221) 2021-12-01 19:15:06 +05:30
Raja Subramanian 57ee033d67 Split Forwarder into its own file to make sfu.DownTrack smaller. (#217) 2021-12-01 01:26:55 +05:30
Raja Subramanian 5e7f93c954 Stream allocator - v0.2 (#216)
* Use protocol friendly StreamedTracksUpdate

* WIP commit

* Stream allocator update

* subtract the requested bandwidth as delta from Allocate could be adding to bandwidth

* Calculate delta correctly

* correct comment

* Simplify eventCh per David's suggestion
2021-12-01 01:05:19 +05:30