Commit Graph

400 Commits

Author SHA1 Message Date
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
David Zhao
a799069392 Add note about node-ip being public IP 2021-11-30 08:57:44 -08:00
cnderrauber
c47ad5e323 export structure & functions for relay (#214)
* export structure & functions for relay

Co-authored-by: jie.zeng <zengjie9004@gmail.com>
2021-11-30 14:08:32 +08:00
David Colburn
6cf662cbe9 send roomID with all events 2021-11-29 16:41:55 -08:00
David Colburn
27a80aa801 fix stats worker 2021-11-29 16:24:29 -08:00
Raja Subramanian
e996c185ce Simplifying (hopefully) sfu.DownTrack (#213)
* Simplifying (hopefully) sfu.DownTrack

* Remove unnecessary check as pdding only packets are dropped before that check

* Temporal filtering max layer

* - Split out forwarder bits into a separate structure
- Address comments from Jie and David

* Remove debug and unneeded stuff

* Fix test

* Remove unneeded default initialization
2021-11-28 09:15:36 +05:30
Raja Subramanian
092789a08f Stream allocator fixes (#212)
* Stream allocator fixes

- Treat simple track like simulcast track with one layer to make
it stream allocator friendly.

* Address David's comments
2021-11-27 09:22:39 +05:30
cnderrauber
dc60e27413 create TrackSender & TrackReceiver (#211)
* create TrackSender & TrackReceiver

change WebRtcReceiver & DownTrack to use corresponding interface
2021-11-26 15:40:10 +08:00
Raja Subramanian
98695cdd22 downstream allocator (#155)
* WIP branch to hash out down stream allocator.

* Plug more bits of stream allocator

* update protocol

* remove SignalRequest_Simulcast (#154)

* Plug more bits of stream allocator

* Handle simulcast track available layers change

* WIP branch to hash out down stream allocator.

* Plug more bits of stream allocator

* Handle simulcast track available layers change

* Adopt signature of call to AdjustAllocation

* Move StreamAllocator to PCTransport and allocate only for subscriber.

* Move streamallocator to ion-sfu

* Start/Stop of streamallocator

* Use StreamAllocator for subscriber bandwidth management.

* Do not allocate in ADD_TRACK

* Set payload in constructor

* - Add some logging
- Protocol message to notify clients of paused/resumed streams

* named return

* oops correct sense of isPausing

* Update pkg/sfu/streamallocator.go

Committing David's suggestion.

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

* - Log estimate changes/commits.
- Catch more than epsilon change oscillating for long time.

Co-authored-by: David Colburn <xero73@gmail.com>
Co-authored-by: David Zhao <david@davidzhao.com>
2021-11-26 09:11:04 +05:30
David Colburn
9aff9af690 back to MessageRouter interface 2021-11-24 18:43:26 -08:00
David Colburn
991c334d2d telemetry interfaces (#210)
* telemetry interfaces

* move AddUptrack under stats

* regenerate

* a space

* consistency

* fix test
2021-11-24 17:58:04 -08:00
Mathew Kamkar
e3c91de594 Configurable limit for number of tracks (#197)
* configurable node track limit

* sample config

* todos

* end of file new line

* default max num tracks

* bandwidth limit

* client message for limit exceeded node

* 10 Gbps default network limit
2021-11-23 15:48:07 -08:00
shishirng
5cdb1c4848 Send room name along in stat message (#205)
Signed-off-by: shishir gowda <shishir@livekit.io>
2021-11-23 15:51:16 -05:00
Raja Subramanian
a554da26dc Let down track do the layer filtering (#203) 2021-11-22 23:45:38 +05:30
Raja Subramanian
2f35128ac2 Prioritize down tracks based on max layer(s) (#202)
Use max layer subscription of down tracks to
prioritize bandwidth allocation. The ordering is
- Highest spatial layer
- Highest temporal layer, if spatial layer matches
- Down track id if both layers match (this is to
  prevent unnecessary re-ordering)

Testing:
--------
(Really need to make a DownTrack interface so that
we can mock it and use it in tests)
For now, just a sanity check.
2021-11-22 23:21:26 +05:30
Raja Subramanian
391e2f8b31 Separate out max layer setting (#201)
Small step on the way to making StreamAllocator prioritization of tracks.
With the new callback into StreamAllocator, the idea is to use the
max layer information to do track prioritization.

Testing:
--------
Sanity check that sample app works
2021-11-22 14:01:25 +05:30
lukasIO
d9219a2a67 track numParticipants in room (#199)
* track numParticipants in room

* only track participant if not a hidden participant

* adjust coding style to use ++

* fix typo

* fix missing nil check

* update roomstore with new numParticipants on participantChanged

* only update roomstore if participant is not hidden

* call StoreRoom directly after StoreParticipant when joining/leaving
2021-11-21 14:15:22 -06:00
David Colburn
a0b623914a store participant before webhook (#200)
* store participant before webhook

* delete participant before participant left event
2021-11-21 13:41:16 -06:00
David Zhao
6dcb29c559 Use publisher PC as default with publish-only connections (#198) 2021-11-20 22:28:36 -08:00
David Zhao
79cfc0d76a update protocol & pion versions 2021-11-19 21:25:08 -10:00
cnderrauber
b7f32dfffd Handle multiple codecs in renegotiation (#191)
* Handle multiple codecs in renegotiation

update pion to v3.1.9 for answer same order of codec as publisher.
register enable codecs in subscriber peerconnectin created.

add codec parameter to buffer.bind
buffer should use the codec of TrackRemote as it's codec mime.

sent h264blankframe when DownTrack closing
2021-11-17 21:18:43 +08:00
cnderrauber
c4c93eaad6 Fix issue #159 (#195)
* Fix issue #159

use timestamp for AudeioLevel observer
change smoothinterval default to 2 for more sensitive
2021-11-16 21:59:15 +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
David Zhao
ffb2c50a70 Fixed room API breakage (#190) 2021-11-14 11:18:01 -08:00
David Zhao
ceae58ac20 Fixed deadlocks occurring in Receiver writeRTP (#189)
When we RLock during write cycles, the mutex spends the majority of its time
staying locked. As new participants join, they have to acquire the WLock
before downtracks could be add it.

In load test scenarios (25 participants joining together), it's common to see
goroutine dump showing MediaTrack.AddSubscriber -> DownTrack.storeDownTrack trying to acquire mutex, and never able to acquire it.
2021-11-13 22:59:53 -08:00
David Colburn
4e16e4275c move NewStatsInterceptorFactory 2021-11-12 20:21:54 -08:00
David Colburn
92838d75a8 Analytics events + stats (#187)
* events

* bump

* update incoming stats

* publisher stats

* outgoing rtcp

* stats

* remove unnecessary struct

* merge mediaTrack

* put comment back
2021-11-12 16:36:10 -06:00
David Zhao
6500ce262d Fix publisher loss reporting (#186) 2021-11-11 23:29:54 -08:00
David Zhao
5a057f3d19 Handle nil when buffer pair doesn't exist 2021-11-11 23:16:21 -08:00
Raja Subramanian
0a20acdf68 Do not parse padding only retransmit packets as VP8 payload. (#185) 2021-11-12 10:09:25 +05:30
David Zhao
90f3c43dc5 Fixed deadlock in pion with SRTP and DataChannel 2021-11-11 13:25:08 -08:00
Raja Subramanian
2ec5f2bd3d Fixing edge cases in picture id munging. (#180)
* Fixing edge cases in picture id munging.

Changes

1. Check the RTP sequence number order before VP8 temporal layer
   filtering and use that ordering result while doing temporal
   layer filtering.

    In a sequence like below
       o Packet 10 -> Picture ID 10
       o Packet 11 -> missing
       o Packet 12 -> Picture ID 11
     it is not known if packet 11 will belong to Picture ID 10 or
     Picture ID 11. The problem becomes a lot more tricky if there
     is a burst loss and there is a larger hole in the picture id
     space also as a result.

     So, in the event of a packet loss, forward even if the current
     packet belongs to a layer that can be dropped. More comments
     in code.

2. Use result of sequence number ordering check while doing VP8 picture id munging.

3. When adding to missing picture id cache, have to include picture ids including
   both ends. As a picture can span multiple packets and it is not known which
   picture the packet belongs to, have to include both ends also in missing
   picture id cache in the event of a gap.

4. As a picture can span multiple packets, it is not possible to have a simple
   map of missing picture ids as an entry cannot be deleted if an out-of-order
   picture id is received. There may be more missing packets belonging to that
   picture id that is yet to be received.

   So, have to use an ordered map and truncate the map if it grows too large.

   Picked this for ordered map - https://github.com/elliotchance/orderedmap.
   Has a simple API, had the highest number of stars of all the ones I checked.
   And there are benchmarks.
   The author also wrote a medium post at https://medium.com/swlh/an-ordered-map-in-go-436634692381

   Another one which I looked at is - https://github.com/wk8/go-ordered-map.
   The author of that wrote at https://morioh.com/p/990229f32171 and has a
   bunch of other options at the end of that post (but does not include the
   one I picked above). None of those have that many stars.

Testing:
--------
- Set max temporal layers to 0 so that temporal filtering happens and run for
an hour on sample app.

* do not let padding packets through VP8

* Correct comment

* fix comment

* Review comments from Jie

* golang naming convention
2021-11-11 19:03:33 +05:30
Raja Subramanian
fc52b18776 Try sending small key frames to clear decoded buffer (#179)
* Try sending small key frames to clear decoded buffer

Problem:
--------
With transceiver re-use, client disables/enables tracks.
With video, this retains the last picture and when a new track
starts, there is a brief moment when the old stream is displayed
till there is data from new stream to decode and display.

Fix:
---
Send small key frames before closing DownTrack to try and clear
the decoder display buffer.

Testing:
--------
Tried with Chrome/Safari/Firefox and they worked. But, very rarely,
the last frames do not seem to show up. In fact, 6 frames are sent
and webrtc internals (in Firefox) reports anywhere from 1 - 6 frames
at the small resolution. Unclear as to why it does not get all the
frames or why it reports less than 6. A not so small percentage of
times (maybe 1 in 15 - 20), have seen no small frame reported at all.

TODO:
----
- Have to support more video codecs
- Would this be an issue for audio also? Should we send something to handle that?
  Probably not necessary as video is more jarring.

* Make VP8 Key Frame a const

* Need a packet factory buffer for simple tracks too
as we are using the VP8 munger for simple tracks too because
of the need to send blank frames at the end.

Also, making the writeBlankFrameRTP a private function.
And adding a check to not send blank frames if nothing has been sent
on that DownTrack.
2021-11-11 14:38:38 +05:30
Raja Subramanian
3ff3e91165 Update pion/rtp and pion/webrtc to the latest (#182)
* Update pion/rtp and pion/webrtc to the latest

* introduce additional delay to fix test reliability

Co-authored-by: David Zhao <david@davidzhao.com>
2021-11-10 14:12:14 -08:00
Mathew Kamkar
9336a0dab5 health check depends on updated stats (#183) 2021-11-10 14:11:44 -08:00
Mathew Kamkar
94aec3b98d Node updates stats with KeepAlive message to self (#177)
* node sends KeepAlive message to self

* use WriteRTCNodeMessage instead of participants[0]
2021-11-09 17:19:46 -08:00
David Colburn
01cf22f2c4 remove error message 2021-11-09 09:33:21 -08:00
cnderrauber
8b7a776af6 Remove unused files (#174)
* remove unsed files from ion-sfu

* remove comment code

* go mod tidy
2021-11-09 17:15:14 +08:00
David Colburn
bf46e998b2 Sfu/buffer stats for telemetry (#173)
* more buffer stats for analytics

* update names

* fix jitter and lost rate

* don't return on participantLeft if they never published
2021-11-09 02:06:07 -06:00
David Zhao
c5830f9060 add ion-sfu NOTICE 2021-11-08 20:56:53 -08:00
David Zhao
749446274f Use time.Unix instead of UnixMilli (for Go 1.15 compat) 2021-11-08 20:47:41 -08: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 Colburn
289ebd32ff Telemetry refactor (#172)
* telemetry refactor

* fix imports

* update protocol
2021-11-08 20:00:34 -06:00
David Zhao
8344466629 Delete unused code 2021-11-07 21:10:40 -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 Colburn
862a212b93 idOrName -> name (#169) 2021-11-03 15:11:44 -05:00
Mathew Kamkar
45aeafd3af more room logging 2021-11-02 14:05:52 -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