Commit Graph

445 Commits

Author SHA1 Message Date
Raja Subramanian
5f76d1adcc Introduce DISCONNECTED connection quality. (#2265)
* Introduce `DISCONNECTED` connection quality.

Currently, this state happens when any up stream track does not
send any packets in an analysis window when it is expected to send
packets.

This can be used by participants to know the quality of a potentially
disconnected participant. Previously, it took 20 - 30 seconds for
the stale timeout to kick in and disconnect the limbo participant which
triggered a participant update through which other participants knew
about it.

Previously, `POOR` quality was also overloaded to denote that the
up stream is not sending any packets. With this change, that is a
separate indicator, i. e. `DISCONNECTED`.

* clean up

* Update deps

* spelling
2023-11-27 23:06:53 +05:30
Raja Subramanian
53542b09a0 Participant traffic load. (#2262)
* Participant traffic load.

Capturing information about participant traffic
- Upstream/Downstream
- Audio/Video/Data
- Packets/Bytes

This captures a notion of how much traffic load a participant is
generating.

Can be used to make allocation decisions.

* Clean up

* SIP patches

* reporter goroutine

* unlock

* move traffic stats from protocol

* check type
2023-11-26 23:05:00 +05:30
Raja Subramanian
56dd399684 Use a worker to report signal/data stats. (#2260)
* Use a worker to report signal/data stats.

Was checking if reporting is needed on every update.
The check is wasted work if volume of signal/data messages is high
as reporting happens only once in 10 seconds.

Changing to a worker based on a timer. And also aligning with
telemetry reporting interval which defaults to 30 seconds.

* Remove unused constant
2023-11-22 11:47:15 +05:30
David Colburn
57643a42ed Agents enabled check (#2227)
* agents enabled check

* participant -> publisher

* nil check client

* add NumConnections

* add lock around agent check

* do not launch agents against other agents

* regen

* don't need atomic anymore

* update protocol
2023-11-07 19:19:07 -08:00
cnderrauber
302facc60d Reject migration if codec mismatch with published tracks (#2225)
* Reject migrated/published track mismatch codec with track info

* Check potential codecs

* Issue full connect if mismatch

* fix codec finding
2023-11-06 21:11:39 +08:00
Paul Wells
43703538c6 clean up proto logging (#2221) 2023-11-04 10:32:03 -07:00
Paul Wells
2a941ba58d improve participant hidden (#2220) 2023-11-04 09:59:23 -07:00
Raja Subramanian
f165ae1fa0 Separate publish and subscribe enabled codecs for finer grained control. (#2217) 2023-11-03 10:14:11 +05:30
cnderrauber
9399fb2bfe Only select alternative codec for video (#2210)
* Only select alternative codec for video

* Filter out empty mime
2023-11-01 19:45:44 +08:00
cnderrauber
3633dfe39e Disable h264 for android firefox (#2190)
* Disable H.264 for android firefox

* Fix syntax error for rule

* lower case

* Remove disabled codec from AddTrackRequest

* Consistent handling of enabled codecs

Mainly cleaning up where we are doing codec filtering.

There's also behavior change of how we handle codec compatibility. If a client doesn't support the client's desired codec, we'll pick a backup automatically
instead of rejecting the client's request.

Requires an update on multi-codec simulcast handling.

* fix alternative codec selection

---------

Co-authored-by: David Zhao <dz@livekit.io>
2023-10-27 14:47:36 +08:00
cnderrauber
eca32792b8 Add configuration to limit MaxBufferedAmount for data channel (#2170)
* Add configuration to limit MaxBufferedAmount for data channel

* comment

* Fix generate flags

* fix test

* Don't disconnect slow subscriber
2023-10-23 15:03:58 +08:00
Paul Wells
325e5ca753 add psrpc room service (#2171)
* add psrpc room service

* update deps

* disable by default

* feedback

* config

* test
2023-10-22 22:49:38 -07:00
David Zhao
65934e6486 Fix ICE connection fallback (#2144)
* Fix ICE connection fallback

Short connection detection relied on iceFailedTimeout, which previously
had been misinterpreted. Since we've reduced iceFailedTimeout, it is
creating false negatives.

We'll instead use PingTimeout since clients are expected to keep the
signal connection active.

* reduce ping interval to align with total ice failure timeout
2023-10-15 14:36:12 -07:00
David Zhao
0931dc0300 Handle playoutDelay for Firefox (#2135)
We will need to disable playoutDelay for FF users if the developer is
assuming streams are synced.
2023-10-07 00:00:52 -07:00
David Zhao
f40a97fd3e Allow playout delay even when sync stream isn't used. (#2133)
The two options should function independently. Users could still improve
video jitter by using up to 100ms of playout delay.
2023-10-06 14:51:11 -07:00
cnderrauber
92a355e1f3 Add SyncStreams flag to Room (#2110)
* Add SyncStreams flag to Room

* Increase protocol version

* Revert version change

* Move flags to internal & solve comment
2023-09-28 15:41:44 +08:00
Raja Subramanian
281d2b674b Changing some log levels (#2094)
Logging expected WS close at Infow to understand reasons for closure.
Moving "read from ws" to Debugw as it happens when signalling closes.

Also filter out a data channel abort chunk log as it shows a bunch of
errors, but those are expected though.
2023-09-20 14:13:48 +05:30
Raja Subramanian
019ad88b08 Do not force reconnect on resume if there is a pending track (#2081)
* Do not force reconnect on resume if there is a pending track

* move GetPendingTrack -> LocalParticipant
2023-09-17 14:00:09 +05:30
David Zhao
340906267f Reduce ghost participant disconnect timeout (#2077)
It's been reported that "ghost" participants, those that did not terminate
cleanly, hang around the room for too long after they disappear.

Evaluating our timeouts a bit, it seems that we are really conservative
in waiting for participants to disconnect. This PR cuts down the disconnect
timeout from 50s to 20s, a 30s reduction.
2023-09-16 00:15:04 -07:00
Raja Subramanian
463c62b99a Update deps (#2061) 2023-09-11 22:16:02 +05:30
Raja Subramanian
be4ea44425 Log ClientInfo on participant close. (#2057)
Want to check client distribution for negotiation failed induced closes.
2023-09-11 10:29:09 +05:30
Raja Subramanian
b5f2f83278 Fix time stamp adjustment when starting with dummy packets. (#2053)
* Fix time stamp adjustment when starting with dmummy packets.

- Populated extended values in ExtPacket on dummy packet.
- Have to pass reference time stamp offset to first packet time
  adjustment.

* display participant version info
2023-09-09 17:33:26 +05:30
Trey Hakanson
b38b51dad8 Integrate updated TWCC responder (#2038)
Integrates the updated TWCC responder based on `pion/interceptor` from
https://github.com/livekit/mediatransportutil/pull/25
2023-09-06 08:37:52 +05:30
Raja Subramanian
6509bb0325 Add option to issue full reconnect on data channel error. (#2026)
* Add option to issue full reconnect on data channel error.

There are situations where send data packet fails because of "stream
closed". It is unclear when that happens. Seems to be after an
ICERestart after ICE failed and connection type switching to TURN
from ICE.

Once the failure happens, it is not recoverable. Potentially, it is
recoverable, but unclear where the problem lies. Attempts to reproduce
looking at the pattern of failures has been unsuccesful.

In the mean time, adding an option to issue full reconnect
when send data packet fails.

* typo
2023-09-01 17:59:25 +05:30
Raja Subramanian
c7683fd383 Check for sctp.ErrStreamClosed (#2023) 2023-08-31 21:44:19 +05:30
David Zhao
eed8e85008 Demote more logs to debug (#1998) 2023-08-27 19:17:38 -07:00
Pingos
9d467e07d8 fix bug: p.pendingTracksLock.Unlock() when mid is empty (#1994) 2023-08-25 14:44:31 +05:30
Raja Subramanian
8c99a9e307 Move GetAudioLevel interface. (#1992)
To allow use with RemoteParticipant/RemoteMediaTrack too.
2023-08-24 13:25:49 +05:30
David Zhao
75f5387ccd Allow data packet to be sent to participants by identity (#1982)
* Allow data packet to be sent to participants by identity

* update gomodules
2023-08-19 23:03:09 -07:00
David Zhao
0f9fb24678 A few more logging component changes (#1934) 2023-08-03 18:46:48 -07:00
David Zhao
debd75fa15 Integrate logger components (#1933)
* Integrate logger components

Dividing into the following components
* pub - publisher
* pub.sfu
* sub - subscriber
* transport
* transport.pion
* transport.cc
* api
* webhook

* update go modules
2023-08-03 13:31:17 -07:00
cnderrauber
f7a1776f4c Add control of playout delay (#1838)
* Add control of playout delay

Add config to enable playout delay. The delay will be limited by
[min,max] in the config option and calculated by upstream & downstream
RTT.

* check protocol version to enable playout delay

* Move config to room, limit playout-delay update interval, solve comments

* Remove adaptive playout-delay

* Remove unused config
2023-08-02 16:12:23 +08:00
Raja Subramanian
eecddbb65a Issue full reconnect if subscriber PC is closed on ICERestart (#1919)
Server could have closed subscriber PC to aid migration.
But, if a resumes lands back on that node, a resume of
the participant session is not possible as subscriber PC is already
closed. While theoretically possible to form a new subscriber
peer conenction, reducing complexity and issuing a full reconnect
as this should be a rare case.
2023-07-31 11:43:47 +05:30
David Zhao
981fb7cac7 Adding license notices (#1913)
* Adding license notices

* remove from config
2023-07-27 16:43:19 -07:00
Raja Subramanian
fc7d4bd01e E2EE trailer for server injected packets. (#1908)
* Ability to use trailer with server injected frames

A 32-byte trailer generated per room.
Trailer appended when track encryption is enabled.

* E2EE trailer for server injected packets.

- Generate a 32-byte per room trailer. Too reasons for longer length
  o Laziness: utils generates a 32 byte string.
  o Longer length random string reduces chances of colliding with real data.
- Trailer sent in JoinResponse
- Trailer added to server injected frames (not to padding only packets)

* generate

* add a length check

* pass trailer in as an argument
2023-07-27 16:50:18 +05:30
Raja Subramanian
9702d3b541 A couple of more opportunities in stream allocator. (#1906)
1. When re-allocating for a track in DEFICIENT state, try to use
   available headroom to accommodate change before trying to steal
   bits from other tracks.
2. If the changing track gives back bits (because of muting or
   moving to a lower layer subscription), use the returned bits
   to try and boost deficient track(s).
2023-07-26 15:35:07 +05:30
Paul Wells
3980d049c9 close disconnected participants when signal channel fails (#1895)
* close disconnected participants when signal channel fails

* fix typefake

* update reason
2023-07-20 19:23:35 -07:00
Raja Subramanian
469f1cd073 Minor changes to publisher bool. (#1880)
* Minor changes to publisher bool.

* address feedback
2023-07-15 12:43:05 +05:30
David Zhao
3e71ea3d77 Fixed hidden participant update (#1857) 2023-07-07 13:36:15 -07:00
David Zhao
919355c873 Log additional details when updating participant permissions (#1855)
To help track down sporadic updateParticipant failures
2023-07-06 23:38:01 -07:00
Raja Subramanian
eaf70d5549 Pacer in down stream path. (#1835)
* Pacer interface to send packets

* notify outside lock

* use select

* use pass through pacer

* add error to OnSent

* Remove log which could get noisy

* Starting TWCC work (#1727)

* add packet time

* WIP commit

* WIP commit

* WIP commit

* minor comments

* Some measurements (#1736)

* WIP commit

* some notes

* WIP commit

* variable name change and do not post to closed channel

* unlock

* clean up

* comment

* Hooking up some more bits for TWCC (#1752)

* wake under lock

* Pacer in down stream path.

Splitting out only the pacer from a feature branch to
introduce the concept of pacer.

Currently, there should be no difference in functionality
as a pass through pacer is used.

Another implementation exists which is just put it in a queue and send
it from one goroutine.

A potential implementation to try would be data paced by bandwidth
estimate. That could include priority queues and such.

But, the main goal here is to introduce notion of pacer in the down
stream path and prepare for more congestion control possibilities down
the line.

* Don't need peak detector

* remove throttling of write IO errors
2023-06-28 13:22:44 +05:30
Raja Subramanian
2896aeb126 Set potential codecs for tracks without simulcast codecs. (#1828)
When migrating muted track, need to set potential codecs.
For audio, there may not be `simulcast_codecs` in `AddTrack`.
Hence when migrating a muted track, the potential codecs are not set.
That results in no receivers in relay up track (because all this
could happen before the audio track is unmuted).

So, look at MimeType in TrackInfo (this will be set in OnTrack) and
use that as potential codec.
2023-06-27 04:34:41 +05:30
Raja Subramanian
352bb1d204 Add GetClientInfo interface, to be used to decide migration vs full-reconenct (#1827) 2023-06-26 23:15:53 +05:30
Raja Subramanian
95f360bbce Do not process events after participant close. (#1824)
* Do not process events after participant close.

Avoid processing transport events after participant/transport close.
It causes error logs which are not really errors, but distracting noise.

* correct comment
2023-06-25 09:26:14 +05:30
Raja Subramanian
00558dee5c Close participant on full reconnect. (#1818)
* Close participant on full reconnect.

A full reconnect == irrecoverable error. Participant cannot continue.
So, close the participant when issuing a full reconnect.
That should prevent subscription manager reconcile till the participant
is finally closed down when participant is stale.

* format
2023-06-22 10:09:10 +05:30
Raja Subramanian
2438058474 Drop error logs due to pipe close (#1813) 2023-06-21 14:11:17 +05:30
Paul Wells
a6d091a810 update protocol (#1803) 2023-06-18 18:13:34 -07:00
Raja Subramanian
cadf3bf649 Simulate muted audio track publish on migration. (#1799)
Till now only video was using simulated publish when migrating on mute.
But, with `pauseUpstream() + replaceTrack(null)`, it is possible that
client does not send any data when muted.

I do not think there is a problem to do this (even when cleint is
actually using mute which sends silence frames).
2023-06-16 22:00:38 +05:30
Raja Subramanian
908b7a9bb1 Promote some migration logs to Infow (#1798) 2023-06-16 19:00:17 +05:30
Raja Subramanian
12db469297 Better tracking of signalling connection. (#1794)
* Better tracking of signalling connection.

- Reason for closing signaling channel.
- ConnectionID attached to request source/response sink

* Tests
2023-06-15 12:53:34 +05:30