Commit Graph

175 Commits

Author SHA1 Message Date
Raja Subramanian
1a48cc6a8b Track subscription operations per source track. (#1248) 2022-12-23 12:23:26 +05:30
Raja Subramanian
f24c1b95c2 Initial commit of signal deduper. (#1243)
* Initial commit of signal deduper.

Idea is protect against signal storm from misbehaving clients.

Design:
- SignalDeduper interface with one method to handle a SignalRequest and
  return if dupe or not.
- Signal specific deduper. Could have made a single de-duper which could
  handle all signal message types, but making it per type so that the
  code is cleaner.
- Some module (like the router) can instantiate whatever signal types
  it wants to de-dupe. When a signal message is received, that module
  can run the signal message through the list of de-dupers and
  potentially drop the message if any of the de-dupers declare that the
  message is a dupe. Making it a list makes things a little bit
  inefficient, but keeps things cleaner. Hopefully, not many de-dupers
  will be needed so that the inefficiency is not pronounced.

* re-arrange comments

* helper function

* add ParticipantClosed
2022-12-21 09:29:56 +05:30
Raja Subramanian
50e39b9985 Check participant SID also while removing a participant. (#1237) 2022-12-19 22:53:11 +05:30
Raja Subramanian
241a7120f5 ICE config using protocol model (#1233)
* ICE config using protocol model

* use pointers consistently

* protocol pointer

* mage generate
2022-12-19 10:25:08 +05:30
David Zhao
33902a9f2a Do not send ParticipantLeft webhook event unless connected successfully. (#1234)
Fixes #1130
2022-12-18 17:37:55 -08:00
Haibo Chen
8a6c6de1db update name of participant (#1213) 2022-12-15 22:03:59 -08:00
Raja Subramanian
6bd5504bff Add option to issue full reconnect on a publication error. (#1214)
* Add option to issue full reconnect on a publication error.

Leaving the publication error timeout at 30 seconds as there
are some publications taking long. Also, there are cases
where the peer connection fails after 30 seconds. The peer
connection failure happens after publication error is detected.
But, 30 seconds is a good amount of time for publication to establish.

* prevent recursive lock
2022-12-06 14:46:59 +05:30
cnderrauber
3c907ed460 Add stats for data channel and signal (#1198)
* Add stats for data channel and signal

* Solve comment
2022-11-30 14:53:19 +08:00
cnderrauber
aaeb3c933c Fix rtcp lost for downtrack used incorrect buffer factory (#1195)
* Fix rtcp lost for downtrack used incorrect buffer factory

In buffer factory change(#1173), every pariticipant has its own
buffer factory, can't use publisher's bufferfactory to create
DownTrack

* clean code
2022-11-28 13:04:56 +08:00
Raja Subramanian
086009f05a Do not forward media till peer connection is connected. (#1194)
There were some failures with missing media. The only thing I could
see between working and non-working case is when media forwarding
starts. So, delay media forwarding till peer connection is connected.

Also, add a subscribe op only if a subscribe/unsubscribe queuing is
successful. There was a recent change to not queue a subscribe when
the participant is closed/disconnected. This got the subscribe op
counter out of whack.
2022-11-26 21:42:19 +05:30
cnderrauber
0310aa9250 Make sure client get participant info before track fired (#1147) 2022-11-07 14:50:45 +08:00
cnderrauber
5edb42a9fd experiment fallback to tcp when udp unstable (#1119)
* fallback to tcp when udp unstable
2022-10-31 09:40:20 +08:00
cnderrauber
7a7fc09372 Add fps calculator for VP8 and DependencyDescriptor (#1110)
* Add fps calculator for VP8 and DependencyDescriptor

* clean code

* unit test

* clean code

* solve comment
2022-10-26 09:28:28 +08:00
cnderrauber
8fd3e8fe2d Support track level stereo and red setting (#1086)
* Support track level stereo and red setting

* fix test client
2022-10-17 10:48:11 +08:00
Raja Subramanian
573850261a Cache RTPStats and seed on re-use (#1080)
* Cache RTPStats and seed on re-use

When a cached down track is re-used, RTPStats was not cached.
This caused sender reports getting out-of-sync with the remote side.
Cache RTPStats and seed it on re-use.

* staticcheck
2022-10-12 09:10:17 +05:30
Raja Subramanian
30e5037418 Minor clean up of media track & friends module (#1067) 2022-10-04 05:23:18 +05:30
Raja Subramanian
b3bd403316 Small clean up - remove unused pariticpant close reason (#1055) 2022-09-29 21:53:18 +05:30
Raja Subramanian
b3e148771a Tweaks to reduce supervisor error logs (#1039)
Seeing some supervisor error logs under two conditions
- Issuing a full reconnect - client should close this session and
form a new one. So, supervisor errors on the to be closed session
is not useful.
- Some times it takes a long time for publisher PC to establish.
If publish monitor timer stars when a pending track is added,
the time out fires before ICE/DTLS is established. So, include
a condition to start timer on publication monitor only after
peer connection is connected.
2022-09-27 08:20:06 +05:30
Raja Subramanian
dfc71d5bf8 Add a flag to signal need to close underlying media track. (#1038)
With migration in, once the local track is published, the
remote track should be closed. Add a flag to `RemovePublishedTrack`
to control the close behaviour. Invoke `Close` if specified.

Without, the remote track is not closed if it is waiting to resolve,
i. e. not yet attached. That remote track is left hanging.
2022-09-26 15:32:22 +05:30
Raja Subramanian
33f782a99b Use PostEvent to avoid casting to concrete type (#1006) 2022-09-15 12:22:13 +05:30
Raja Subramanian
07c43e0972 Supervisor beginnings (#1005)
* Remove VP9 from media engine set up.

* Remove vp9 from config sample

* Supervisor beginnings

Eventual goal is to have a reconciler which moves state from
actual -> desired. First step along the way is to observe/monitor.
The first step even in that is an initial implementation to get
feedback on the direction.

This PR is a start in that direction
- Concept of a supervisor at local participant level
- This supervisor will be responsible for periodically monitor
  actual vs desired (this is the one which will eventually trigger
  other things to reconcile, but for now it just logs on error)
- A new interface `OperationMonitor` which requires two methods
  o Check() returns an error based on actual vs desired state.
  o IsIdle() returns bool. Returns true if the monitor is idle.
- The supervisor maintains a list of monitors and does periodic check.

In the above framework, starting with list of
subscriptions/unsubscriptions. There is a new module
`SubscriptionMonitor` which checks subscription transitions.
A subscription transition is queued on subscribe/unsubscribe.
The transition can be satisfied when a subscribedTrack is added OR
removed. Error condition is when a transition is not satisfied for
10 seconds. Idle is when the transition queue is empty and
subscribedTrack is nil, i. e. the last transition would have been
unsubscribe and subscribed track removed (unsubscribe satisfied).

The idea is individual monitors can check on different things.
Some more things that I am thinking about are
- PublishedTrackMonitor - started when an add track happens,
  satisfied when OnTrack happens, error if `OnTrack` does not
  fire for a while and track is not muted, idle when there is
  nothing pending.
- PublishedTrackStreamingMonitor - to ensure that a published track
  is receiving media at the server (accounting for dynacast, mute, etc)
- SubscribedTrackStreamingMonitor - to ensure down track is sending
  data unless muted.

* Remove debug

* Protect against early casting errors

* Adding PublicationMonitor
2022-09-15 11:16:37 +05:30
cnderrauber
f1915feb1a keep mid unchange after migration for subscribed track (#995) 2022-09-09 17:39:09 +08:00
Raja Subramanian
d13c4be923 Close subscriber PC after a wait to aid in migration. (#979)
* Close subscriber PC after a wait to aid in migration.

* mage generate
2022-09-03 01:16:51 +05:30
David Zhao
69bf31944e Send connection type to telemetry (#964)
* Send connection type to telemetry

When connected, determine how the participant's primary connection is
connected and report it in ParticipantActive event.

* address feedback

* fixed case where prflx is reported instead of relay

* incorporate comments
2022-08-29 23:17:13 -07:00
Raja Subramanian
9b0539eb43 Need this for clean up during migration (#965) 2022-08-29 13:19:58 +05:30
David Zhao
747089a005 Additional closure reasons (#958) 2022-08-25 19:36:47 -07:00
cnderrauber
1350400c3a fallback to turn over tls when tcp short connection happen (#950)
* fallback to tls when tcp failed

* go mod

* magefile
2022-08-24 20:42:56 +08:00
Raja Subramanian
aaa3a5b46e Transport restructure (#944)
* WIP commit

* WIP commit

* fix copy pasta

* setting PC with previous answer has to happen synchronously

* static check

* WIP commit

* WIP commit

* fixing transport tests

* fix tests and clean up

* minor renaming

* FIx test race

* log event when channel is full
2022-08-24 14:31:45 +05:30
Raja Subramanian
70422c0267 Export CloseSignalConnection (#936)
* Export CloseSignalConnection

There are a few places where that close pattern is repeated.
Export it and use that function in other places directly.

* fix test
2022-08-21 11:33:35 +05:30
Raja Subramanian
0cd9c87dc9 Misc clean up (#931)
* Start RTCP workers after peer connection connects

* Move more things into transport module

* Start RTCP workers only on connected

* Test needs PeerConnection() method

* adjust comment
2022-08-19 11:49:12 +05:30
Raja Subramanian
f5627c3859 Prevent track subscriptions/adding receivers after close (#924)
* Prevent track subscriptions/adding receivers after close

With subscribe/unsubscribe queuing, a subscribe may be
attempted after a call to `RemoveAllSubscribers`.
So, renaming `RemoveAllSubscribers` to `InitiateClose`
and maintaining state that track is in the process of closing.

* Mime specific remove

* Remove unused error

* do not add receiver when closing
2022-08-17 13:07:59 +05:30
Raja Subramanian
641f8d4519 Transport refactor (#907)
* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* Clean up

* fix tests

* debug logs

* Remove comments

* Fix data channel creation on migration and clean up unused stuff

* log offer/answer send/receive
2022-08-12 11:20:54 +05:30
David Zhao
f09885825e Return ServerInfo to clients on join (#904)
* checkpoint

* Return ServerInfo in join response

* also include node information

* less verbose quality score

* update go modules
2022-08-10 17:04:17 -07:00
Raja Subramanian
4d7df612ec Refactor DynacastQuality & MediaLossProxy into separate modules (#894)
* WIP commit

* Refactor media loss proxy

* Use DynacastQuality and MediaLossProxy from MediaTrack

* fix test

* Remove unused param

* Remove unused interfaces

* Move interface methods to local

* Split out DynacastManager

* have to add codec to dynacast manager

* RUnlock

* fix restart

* Adding API to force quality and also maintain closed state

* Address PR comments
2022-08-09 11:47:06 +05:30
cnderrauber
1d2bca373b queue restart ice offer while publisher pc gathering ice (#895)
* queue restart ice offer while publisher pc gathering ice

* fix test case fail
2022-08-08 15:40:45 +08:00
Raja Subramanian
3f16018b62 Cache ICE config in room manager. (#872)
* Cache ICE config in room manager.

* mage generate

* Read ICE config within lock
2022-08-05 12:49:19 +05:30
Raja Subramanian
a393d64ccc Do not re-use transceiver when negotiation is pending. (#862) 2022-07-31 10:50:55 +05:30
Raja Subramanian
51073e8918 Use TimedVersion for subscription permission update (#839)
* Use a read version for subscription permission

* Use TimedVersion for subscription permission updates

* Minor clean up

* latest protocol
2022-07-21 08:52:37 +05:30
Raja Subramanian
fbb1f9fc80 Move subscribe/unsubscribe queue to participant. (#813)
* Move subscribe/unsubscribe queue to participant.

As subscribe/unsubscribe operation can come from both
local media track or remote media track, participant
needs to have it.

* Remove comment

* Stop reneg timer on close

* address comments
2022-07-06 17:27:32 +05:30
cnderrauber
937882c364 add negotiate failed to ToDisconnectReason (#809) 2022-07-05 11:24:32 +08:00
cnderrauber
f17ed9b925 refine negotiation process (#807)
* refine negotiation process

* not restart during ice gathering

* fix test case
2022-07-04 17:11:09 +08:00
David Zhao
f1f62ddda5 Sends disconnect reason when server sends Leave request (#801)
* Sends disconnect reason when server sends Leave request

* update go.mod
2022-07-02 21:22:26 -07:00
Raja Subramanian
41c57f737c More use of subscriber logger when appropriate and an interface to get (#800) 2022-07-02 20:51:38 +05:30
Raja Subramanian
46bce33fb8 Cache and restore forwarder state on resume (#786)
* WIP commit

* Clean up

* spelling mistake

* Run subscribed track onBind in a go routine

* Address comments and more safety net

* Cache and restore forwarder state on resume

* conflicts

* mage generate
2022-06-24 22:02:03 +05:30
Raja Subramanian
adf2d191b0 Re-use transceiver (via ReplaceTrack) if a down track is going to be resumed. (#785)
* WIP commit

* Clean up

* spelling mistake

* Run subscribed track onBind in a go routine

* Address comments and more safety net
2022-06-24 15:07:48 +05:30
Raja Subramanian
20512151c6 Prevent subscribe renegotiation if tracks will be resumed. (#781) 2022-06-24 00:06:37 +05:30
Raja Subramanian
120110fbbe A few more reasons a participant could be closed with (#778) 2022-06-22 11:56:03 +05:30
Raja Subramanian
47b89c155f Log reason for participant close (#776)
* Log reason for participant close

Please suggest better naming for different scenarios if something comes
to mind.

* group service requests

* incorporate feedback

* Change names in tests
2022-06-22 10:32:22 +05:30
David Zhao
301bd2771c Expose IsPublisher and IsSubscribedTo via LocalParticipant interface (#772) 2022-06-19 23:58:31 -07:00
cnderrauber
90ae3892b3 add simulate switch candidate (#754)
* add simulate switch candidate

* update go mod
2022-06-07 17:56:41 +08:00