Commit Graph

867 Commits

Author SHA1 Message Date
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
Raja Subramanian
1a32439d7e Ensure older session does not clobeer newer session. (#1974) 2023-08-18 02:00:43 +05:30
David Zhao
13b1b4808f Fix race condition causing new participants to have stale room metadata (#1969)
If room metadata is changed in between when a participant is joining and
when they've became active, that participant will not have the latest
room metadata.
2023-08-15 17:30:26 -07:00
David Zhao
387faf2718 Demote removing subscribers for MIME (#1954) 2023-08-10 18:50:19 -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
Raja Subramanian
dbbf2f886f Skip video layer update if sub muted (#1929)
Previous change to check for non-zero width caused test failures
as subscribed track settings can use the quality field and not
necessarily width/height.
2023-08-02 16:33:58 +05:30
Raja Subramanian
0dc92ef273 Remove parked layer feature. (#1927)
* Remove parked layer feature.

Not worth the added complexity.

Several reasons
- Not seeing black frames on pub mute always.
- If they are there, it can consume more than 30kbps if the parked layer
  is high res. That is wasted bandwidth downstream when pub is muted.
- On resume, client some time sends PLI and that triggers a key frame
  request.

But, leaving the separate `PubMuted` flag in forwarder in case we can
use it for better handling.

* need the request spatial
2023-08-02 14:02:29 +05:30
Raja Subramanian
f3a0e3e71c skip logging when stream closed (#1928) 2023-08-02 14:00:58 +05:30
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
0c34f12fa1 Demote some high frequency logs to Debugw (#1925) 2023-08-02 00:03:38 +05:30
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
Raja Subramanian
b6394d5aa6 De-dupe ICE candidates, makes logging cleaner. (#1916) 2023-07-29 18:26:57 +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
Raja Subramanian
4c02a6d717 Time stamp adjustments v2 (I think) (#1875)
* WIP commit

* WIP commit

* WIP commit

* Some clean up
- Removed a chatty debug log
- some spelling, punctuation correction in comments
- missed an `Abs` in check, add it.
2023-07-14 11:47:07 +05:30
David Zhao
557fe7c9d3 Mark room as dirty after track published changes (#1878)
Ensure that we are recomputing NumPublished when needed
2023-07-13 16:33:04 -07:00
Raja Subramanian
ed867fafe5 Log unexpected ICE connection states (#1870) 2023-07-12 10:28:36 +05:30
Raja Subramanian
1cb74b9e1b Check for desired before clean up. (#1865)
Fix a potential race between needsCleanup checking and a re-subscribe
setting desired back to true.
2023-07-10 13:20:57 +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
lukasIO
7e96c98dc3 Select highest layer of equal dimensions (#1841)
* Select highest layer of equal dimensions

* clean up test
2023-07-03 17:32:28 +02:00
Raja Subramanian
869f23a054 Close subscriptions promptly (#1845)
* Close subscriptions promptly

Two things:
-----------
1. Because the desired is not changed, the notifiers are not notified
that the subscription is not observing any more. So, that holds
a refernce to the subscription manager.

Address the above by setting `setDesired` to false on all subscriptions
when subscription manager closes. That will remove observer from the
notifiers.

2. When subscription manager is closed, the down track close
is invoked which flows back (with onClose callback of downtrack) to
subscription manager "handleSubscribedTrackClose". That callback
handler sets the subscribed track to nil for that subscription.

A couple of scenarios here
a. Without the above change, desired could have been true and it would
have looked that the track needs to try subscription again because
`needsSubscribe == true` (desired == true && subscribedTrack == nil)

b. Even with the change above, there is a new condition of
`desired == false && subscribedTrack == nil` and there was no handler
for that condition in the reconciler.

Address this by adding a `needsCleanup` function and delete subscription
from the map. Note that the reconciler may not be running to execute
this action as subscription manager would have closed the `closeCh`, but
doing the code in the interest of proper clean up.

* clean up
2023-07-01 12:31:51 +05:30
Raja Subramanian
06f9b574cb Delete down track from receiver in close always. (#1842)
* Delete down track from receiver in close always.

I think with the parallel close in goroutines, it so happens that
peer connection can get closed first and unbind the track.

The delete down track and RTCP reader close was inside if `bound` block.
So, they were not running leaving a dangling down track in the receiver.

* fix tests

* fix test
2023-06-30 20:44:57 +05:30
David Zhao
7be9e2258d Upgrade to Pion 3.0.11, disable active TCP (#1836) 2023-06-28 16:53:58 -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
81f41aca20 Full reconnect on publication mismatch on resume. (#1823)
* Full reconnect on publication mismatch on resume.

It is possible that publications mismatch on resume. An example sequence
- Client sends `AddTrack` for `trackA`
- Server never receives it due to signalling connection breakage.
- Client could do a resume (reconnect=1) noticing signalling connection
  breakage.
- Client's view thinks that `trackA` is known to server, but server does
  not know about it.
- A subsequence offer containing `trackA` triggers `trackInfo not
  available before track publish` and the track does not get published.

Detect the case of missing track and issue a full reconnect.

* UpdateSubscriptions from sync state a la cloud

* add missing shouldReconnect
2023-06-24 19:18:05 +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
Raja Subramanian
583648a1ed Avoid closure to reduce life span of objects. (#1809)
A subscription in subscription manager could live till the source
track goes away even though the participant with that subscription
is long gone due to closure on source track removal. Handle it by using
trackID to look up on source track removal.

Also, logging SDPs when a negotiation failure happens to check
if there are any mismatches.
2023-06-20 19:06:01 +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
David Zhao
f71544e27a Do not send ParticipantJoined webhook if connection was resumed (#1795)
* Do not send ParticipantJoined webhook if connection was resumed

* isResume -> isMigration
2023-06-15 15:39:04 -07:00
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
cnderrauber
c91889edfd Add dependency descriptor stream tracker for svc codecs (#1788)
* Add dependency descriptor stream tracker for svc codecs

* Solve comments
2023-06-12 15:07:47 +08:00
Raja Subramanian
7ed3af193a No proof that this helps (#1772) 2023-06-06 11:28:13 +05:30
David Zhao
b5c8fe5294 Perform unsubscribe in parallel to avoid blocking (#1760)
* Perform unsubscribe in parallel to avoid blocking

When unsubscribing from tracks, we flush a blank frame in order to prepare
the transceivers for re-use. This process is blocking for ~200ms. If
the unsubscribes are performed serially, it would prevent other subscribe
operation from continuing.

This PR parallelizes that operation, and ensures subsequent subscribe
operations could reuse the existing transceivers.

* also perform in parallel when uptrack close

* fix a few log fields
2023-06-02 00:13:18 -07:00
cnderrauber
c1842cb54f Avoid reconnect loop for unsupported downtrack (#1754)
* Avoid reconnect loop for unsupported downtrack

If the client subscribes to a track which codec is unsupported by the
client, sfu will trigger negotiation failed and issue a full reconnect
after received client answer. If the client try to subscribe that track
then it will got full reconnect again. That will cause a infinite
reconnect loop until the client don't subscribe that track. This PR
will unsubscribe the error track for the client and send a
SubscriptionResponse that contain the reason to indicates the track's
codec is not supported to avoid the reconnect loop.
2023-05-31 11:41:22 +08:00
Raja Subramanian
1c920812d3 Return max spatial layer from selectors. (#1743)
* Return max spatial layer from selectors.

With differing requirements of SVC and allowing overshoot in Simulcast,
selectors are best placed to indicate what is the max spatial layer when
they indicate a switch to max spatial layer.

* fix test

* prevent race
2023-05-26 12:49:31 +05:30
Raja Subramanian
0354626bfc Adjust sender report time stamp for slow publishers. (#1740)
It is possible that publisher paces the media.
So, RTCP sender report from publisher could be ahead of
what is being fowarded by a good amount (have seen up to 2 seconds
ahead). Using the forwarded time stamp for RTCP sender report
in the down stream leads to jumps back and forth in the down track
RTCP sender report.

So, look at the publisher's RTCP sender report to check for it being
ahead and use the publisher rate as a guide.
2023-05-25 21:55:54 +05:30
David Zhao
61d393e709 Disable active TCP by rolling back to ICE v2.3.3 (#1735)
* Revert "Disable active TCP (#1726)"

This reverts commit 5260907ffe.

* Disable active TCP by rolling back to ICE v2.3.3
2023-05-23 21:27:03 -07:00
Raja Subramanian
bbbe815260 Init min to max MOS (#1734)
* Init min to max MOS

Could have been contributing to low p50 score in prom stats.

* don't need to reset on no tracks as default is that
2023-05-23 12:55:24 +05:30
David Zhao
12c6f1e12c Added Xiaomi 2201117TI to devices that does not support H.264 (#1728) 2023-05-22 21:38:56 -07:00