Commit Graph

788 Commits

Author SHA1 Message Date
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
Raja Subramanian 8ef53037eb Lock stats worker maps (#704) 2022-05-21 10:36:49 +05:30
David Zhao 79296d0939 Fixed concurrent modification to map (#702)
Synchronizes access to stats worker maps. Previously it was accessed
from both OpsQueue goroutine and run() worker
2022-05-20 13:45:13 -07:00
Raja Subramanian 547ab908f5 Coalesce track events into stream allocator. (#701) 2022-05-21 00:40:02 +05:30
Raja Subramanian 8d0998ed1d Bump up stream allocator event queue size (#700)
This probably needs more work
- Maybe some events should not be queued
- Reduce number of events

Bump up the size any way so that the queue does not overflow
when subscribing to a lot of tracks.
2022-05-20 09:54:10 +05:30
Russ d'Sa 1d03843b3f Update README.md (#696)
* Update README.md

Community URL somehow expired, updating it here.

* fix static check

Co-authored-by: David Zhao <dz@livekit.io>
2022-05-18 21:01:21 -07:00
David Colburn a8ff70f63a Update egress info (#694) 2022-05-18 11:30:25 -07:00
Raja Subramanian 012337c96a Fix sense of tranmission label (#692) 2022-05-18 12:52:05 +05:30
Raja Subramanian d828e0fbd8 Inject silence opus frames on mute (#682)
* 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.

* use duration to calculate number of blank frames

* log errors in blank frames write path
2022-05-15 11:29:40 +05:30
cnderrauber fa53da18e7 update pion, export vp8munger header (#684)
* update pion, export vp8munger header

* fix test
2022-05-13 17:20:52 +08:00
Raja Subramanian 710e06b7da Tweak screen share stream tracker. (#683)
* Tweak screen share stream tracker.

Screen share uses extremely low frame rate when content is static.
This leads to stream tracker changes and layer switches.
Use a longer measurement interval for screen share tracks.
Setting it to 4 seconds. The screen share frame rate is
approx. 1 fps and with two temporal layers, it should get
a frame every 2 seconds or so in every layer. But, that
does not work. Even three second measurement window was
reporting 0 rate. So, it is getting clumped. 4 seconds works
fine.

Also modifying the bit rate availability change to trigger
on a temporal layer becoming available or going away.

With these changes, on a local test, not seeing any unnecessary
PLIs from client and hence no unnecessary key frames from publisher.

* Fix test
2022-05-13 10:18:18 +05:30
David Zhao a1caeeb8de Update WebRTC and DTLS with security fixes (#678)
* Update WebRTC and DTLS with security fixes.

* remove aggressive nomination settings (now default)

* fixed TURN issue
2022-05-10 18:27:16 -07:00
David Zhao 7eb3362d0a Keep track of retransmissions in NodeStats (#677) 2022-05-10 15:25:24 -07:00
Raja Subramanian 9f37239af3 Send active speaker update on subscription. (#676)
Newly joining participant does not get information about
currently active speaker till there is a speaker state change.
This addresses it by sending a speaker update on subscription
if the subscribed to participant is actively speaking.
2022-05-10 12:31:26 +05:30
David Zhao bd7e3beda4 Improve frequency of stats update (#673)
* Improve frequency of stats update

Prometheus stats are updated as the data becomes available, instead of
aggregated along with telemetry batches. Node availability decisions can
now react much faster to these stats.

* use the same intervals for connection quality updates
2022-05-09 08:55:06 -07:00
Raja Subramanian 16407ea180 Change state to JOINED before sending JoinResponse (#674)
* Send room metadata as long as participant is not disconnected

* Change state to JOINED before sending join response
2022-05-09 13:28:56 +05:30
Raja Subramanian 081b97142f Variable collision killed stats workers (#670) 2022-05-06 23:42:40 +05:30
cnderrauber 07b93e2e5b add support for av1 svc (#669)
* add support for av1 svc
2022-05-06 18:24:29 +08:00
cnderrauber 7f38164ef6 fix twcc panic on packet lost (#668) 2022-05-05 17:04:02 +08:00
Raja Subramanian 0d8848cfcd Do not count padding packets in stream tracker. (#667)
* Do not count padding packets in stream tracker.

There are cases where publisher uses padding only packets
in a layer to probe the channel. Treating those as valid
layer packets makes stream tracker declare that the layer
is active where in reality, it is not.

Also, removing check for out-of-order packets. Out-of-order
packets can happen and should be counted in bitrate calculation.

There is the extreme case of heavy loss which might skew it, but
that is an extreme case.

* Fix test
2022-05-05 13:09:59 +05:30
Raja Subramanian c6f895db15 Prevent concurrent access of stats worker map (#666) 2022-05-04 23:00:20 +05:30
Raja Subramanian 1665f51bd0 Stats of NACKs acked and number of repeated NACKs. (#664)
* Stats of NACKs acked and number of repeated NACKs.

Also making a change in delta stat to drop negative packet loss
counts to 0. Because of windowing it is a legitimate case.
The receiver could have seen a loss in window we are measuring
and in the subsequent window, the receiver could have gotten
a retransmission and reduced the packet loss count resulting
in a negative delta. When we report negative delta, it could
get dropped by analytics validator. That will be lost data.
Avoid that.

* Remove unused code

* Pick up latest protocol
2022-05-02 22:43:21 +05:30
Raja Subramanian fe8c355a32 Support participant identity in permissions (#663)
* Support participant identity in permissions

It is harder for clients to update permissions by SID as remote
reconnecting means a new SID for that participant. Using participant
identity is a better option.

For now, participant SID is also supported. Internally, it will
get mapped to identity. Server code uses identity throughout after
doing any necessary conversion from SID -> Identity.

* Address comments
2022-05-02 12:35:20 +05:30
Raja Subramanian d863b45dc1 Remove Head field from ExtPacket structure. (#662)
* Remove `Head` field from `ExtPacket` structure.

Although we do not intend to, but if packets get out-of-order
in the forwarding path (maybe reading in multiple goroutines
or using some worker pool to distribute packets), the `Head`
indicator could lead to wrong behaviour. It is possible that
at the receiver, the order is
- Seq Num N, Head = true
- N + 1, Head = true

If the forwarding path sees `N + 1` first, the Head flag
when it sees `N` packet is incorrect and will lead to incorrect
behaviour.

The alternative check is very simple. So, remove `Head` flag.

* Remove unused field
2022-05-02 10:16:17 +05:30
David Zhao 289d63ac53 Fix node ip parameter not being used (#661)
* Use node-ip if provided

* formatting
2022-04-29 15:26:37 -07:00
Raja Subramanian ea61b588a2 Simplifying SN info cache in RTPStats module (#660)
* Simplifying SN info cache in RTPStats module

* Remove unnecessary field
2022-04-28 18:48:59 +05:30
Raja Subramanian ca6ad7ec7a Use seq num offsets cache instead of missing seq num map. (#658)
* Use seq num offsets cache instead of missing seq num map.

Map operations can be costly. Use a fixed size array to store offsets.
4096 sequence numbers should be more than 16 seconds for 720p video
which should be plenty to look up offset of out-of-order packets.
Packets out-of-order more than that will probably be useless anyway.

* Move offset cache population to only when we are forwarding

* add some debug logs

* Remove debug
2022-04-28 15:16:42 +05:30
Raja Subramanian a83bd5c2f6 Split out load balancer into a separate module (#657) 2022-04-26 15:46:30 +05:30
Raja Subramanian 2f902a3edc Remove callbacks queue from sfu/DownTrack (#655)
* Remove callbacks queue from sfu/DownTrack

- Connection stats callback was happening in connection stats go routine
- RTT update launches a goroutine on the receive side as it affects the
  subscriber. So, no need to queue it.
- Changed two things
  o Move close handler to goroutine. It is better that way as it touches
the subscriber as well
  o Move max layer handling into a goroutine also so that the callback
does minimal work.

With this all the send side callback queues are removed.

* small clean up
2022-04-25 13:28:24 +05:30
Raja Subramanian f0f66a2d75 Remove ops queue from stream tracker. (#652)
It is not needed as the callback happens in a goroutine.
Also, had missed included bitrate availability change in the queue
which was inconsistent.
2022-04-25 12:51:29 +05:30
David Zhao 4e5863496c Set numCPUs correctly in non-linux environment (#653) 2022-04-24 23:25:33 -07:00
David Zhao b9ee0b5800 Skip loading of participant before writing messages to them. (#654)
In some implementations of the Store interface, it's possible that the
media node has not yet persisted the participant when we are trying to
send it messages. In which case we should not error on loading of the
participant.
2022-04-24 23:09:06 -07:00
Raja Subramanian 4d7950ec2f Do not send down track callbacks to streamallocator via queue (#651) 2022-04-24 21:41:58 +05:30
Raja Subramanian 0a802077dd Remove callbacks queue from sfu/buffer. (#650) 2022-04-24 21:39:28 +05:30
David Zhao 26700ea135 Add back region when hydrating ParticipantInit. (#648)
It was left out in the previous PR #646
2022-04-24 09:07:33 -07:00
Raja Subramanian d38566850a Do not post close callback in ops queue if not started. (#649)
* Do not post close callback in ops queue if not started.

Ops queue is started in `Bind()`. If `Close()` is called
when bind did not happen (because the underlying peer connection
closed before bind), the close callback does not run.

Check if ops queue is running before posting close callback
into the queue.

Not pretty, but covers this case. Need to think about it more.

* correct check
2022-04-24 11:40:22 +05:30
David Zhao b7d22c4f34 Fix MessageChannel leaks (#646) 2022-04-22 10:53:20 -07:00
Raja Subramanian 2e182afb61 Reduce memory used by RTPStats. (#645)
Keep track of last 2048 sequence numbers instead of full range
to reduce memory usage.
2022-04-22 17:17:37 +05:30
David Zhao 57e2321a18 Expose Participant.IsPublisher to differentiate pubs from subs (#643) 2022-04-21 22:15:01 -07:00
cnderrauber 8bb46637bb enable accept aggressive nomination by default (#644) 2022-04-22 12:41:43 +08:00
cnderrauber 124d628c0a add config to accept aggressive nomination (#642) 2022-04-21 18:32:18 +08:00
Raja Subramanian 2b6a304b27 Increase size of RTCP channel just to be safe. (#641)
Also, using select to log warnings when queue is full.
2022-04-21 12:21:21 +05:30
cnderrauber 3f9d6c11bc add log info for client closed websocket (#640) 2022-04-21 12:44:43 +08:00
David Zhao 3c53b843c5 Fixes bps and pps average computation. (#639)
Exclude NACK count from being a trigger to refresh stats.
Since NACKs are updated instantaneously without having to wait for
Telemetry updates that occurs every 10s, having even a single NACK
could cause us to compute averages prematurely.
2022-04-20 19:17:02 -07:00
David Zhao 59112b9200 Increase default message channel from 200 -> 10k (#638) 2022-04-20 16:34:00 -07:00
Raja Subramanian 43d0573693 Moving smoothing into the audio level module. (#636) 2022-04-20 23:59:51 +05:30
Raja Subramanian 6a53891f9f Process header extensions in line (#635)
* WIP commit

* Pass audio config

* Fix test compile
2022-04-20 18:20:28 +05:30
Raja Subramanian 1fe485ef0c Use cache for packet level processing. (#632)
* Use cache for packet level processing.

Do not overload ops queue for packet level operations.

* byte -> uint8
2022-04-20 13:19:10 +05:30
David Zhao 1cfc483d8f Do not pass STUN servers when using ICE Lite (#634) 2022-04-20 00:29:57 -07:00
David Zhao b821a0997d Use common logging init functions (#633)
* Use common logging init functions

* update protocol commit

* fix tests
2022-04-20 00:15:11 -07:00