Commit Graph

2229 Commits

Author SHA1 Message Date
cnderrauber
4792e7e134 Revert "Add tracksubscribed event on downtrack added (#2934)" (#2975)
This reverts commit 8b47218270.
2024-09-04 10:42:18 +08:00
cnderrauber
d6ce2338e2 Use correct subscriber id in dynacast notify (#2972) 2024-09-03 11:35:52 +08:00
Raja Subramanian
6de871d4e8 Allow start streaming on an out-of-order packet. (#2971)
But, do not record first packet time on an out-of-order packet.
It so happens that packets get out-of-order a lot more across relay.
And it turns out with some H.264 stream, the first few packets of a key
frame are very small (may be SPS/PPS, haven't checked), they get
out-of-oder quite a lot, so much so a down track never starts even it
has 20 - 25 key frames have passed through.
2024-09-02 21:36:46 +05:30
cnderrauber
efa85221b3 Negotiate downttrack for subscriber before receiver is ready (#2970)
* Negotiate downttrack for subscriber before receiver is ready

This change will save 1 round sdp negotiation time for
subscribing to simulcast-codec or remote node track

* solve comment

* Fix simulcast-codec case
2024-09-02 14:10:14 +08:00
Raja Subramanian
579f76cf7c Use 0 rollover when possible. (#2968) 2024-08-31 11:36:49 +05:30
Raja Subramanian
a4baa8b550 Skip ICE restart on unestablished peer connection. (#2967)
* Do not ICE restart on an idle/not yet started peer connection.

* Skip ICE restart on unestablished peer connection.

For publish only participants, the subscriber peer connection is not
negotiated. So, ICE restart was hitting an error while trying to restart
the SUBSCRIBER peer connection.

* use ICE gathering state as peer connection state may not have changed if first offer/answer was missed
2024-08-30 11:19:51 +05:30
cnderrauber
28417ef599 fix republish failed (#2966)
* fix republish failed

parallel negotiation would cause remote webrtc track consume
pending republished track then failed.

* comment
2024-08-29 15:41:32 +08:00
cnderrauber
16896e4d66 Add FastPublish in JoinResponse (#2964)
Set FastPublish in JoinResponse for participant can publish
and no ice fallback setting.
2024-08-28 12:00:28 +08:00
cnderrauber
bde702d9c9 Don't remove DD extesion for simucalst codecs (#2960) 2024-08-26 17:52:33 +08:00
David Zhao
91cb4369ef Standardize twirp hooks during server init (#2959) 2024-08-26 00:53:13 -07:00
Raja Subramanian
e9f26c21e7 Panic fix for nil candidate check. (#2957) 2024-08-25 10:12:32 +05:30
Raja Subramanian
56e67c9d25 Properly exclude mDNS when not trickling also. (#2956) 2024-08-24 23:23:23 +05:30
cnderrauber
947e8f5909 Speed up track publication (#2952)
* speed up track publication

Add metrics for track publication and subscription

Return EnabledCodecs in JoinResponse so client can
choose codec without server side codec fallback

Cache remote webrtc track without AddTrackRequest to
let client send publisher offer before AddTrackRequest response

* go mod

* clean code
2024-08-23 18:38:32 +08:00
Raja Subramanian
37c6f95fe4 Reduce threshold of out-of-order very old packet detection. (#2951)
There are cases where the very first packet on resume is an out-of-order
packet. In that case, the gap in both sequence number and time stamp is
a small(ish) negative number. With a high threshold to declare very old
packet, the condition does not trip and the packet gets through and
treated as a packet that has rolled over.

It should be fine to have smaller threshold (in fact, it is probably
okay to have something a little over 1.0 too) as the expected jump is
calculated based on elapsed time since last packet receive and new
packets should be coming in with a diff close to that. So, a factor of
just over 1.0 to prevent false triggers should be fine. Using 1.5 for
now.
2024-08-22 17:48:12 +05:30
David Colburn
0fdfe2f5a0 refactor sip create participant (#2949) 2024-08-21 17:13:26 -04:00
Raja Subramanian
d78fdbf2a8 Handle another old packet condition. (#2947)
* Handle another old packet condition.

With this detection, the sequence number can be rolled over even when TS
rollover is not possible. For example, a track at 300 pps can rollver
the sequence number space in minutes compared to 13h+ for video time
stamp to roll over.

* fix typo
2024-08-21 13:32:20 +05:30
Denys Smirnov
7ad6d97b1b Propagate SIP attributes from a Dispatch Rule. (#2943) 2024-08-19 18:09:37 +03:00
cnderrauber
15bf920f2c fix framenumber test (#2942) 2024-08-19 16:35:38 +08:00
Raja Subramanian
1fb8964814 Refactor propagation delay estimator. (#2941)
* Refactor propagation delay estimator.

NOTE: It is not possible to calculate OWD (one-way-delay) in a passive
fashion. So, this should not be used for anything requiring high
precision.

But, mainly factoring it out as a separate object just in case it can be
re-used.

TODO:
- probably has some edge case that is not handled well
- maybe path change detection can be improved
- will write UT later. This is just purely splitting it out from what
  was embedded in RTPStatsReceiver.

* fix labels

* precision -> accuracy
2024-08-19 12:03:45 +05:30
Raja Subramanian
08b8ef56de Use monotonic clock in packet path. (#2940)
Set up a base time when starting a receiver and use that clock as base
for other packet times to ensure that clock is monotonic.
2024-08-17 23:19:27 +05:30
Paul Wells
dabbb298c5 mark explicit create paths (#2935) 2024-08-13 22:00:39 -07:00
cnderrauber
8b47218270 Add tracksubscribed event on downtrack added (#2934)
will remove this once the remote node has tracksubscribed
event sent.
2024-08-14 10:19:01 +08:00
Paul Wells
c371929535 add roommanager service (#2931)
* add roommanager service

* cleanup

* deps

* timeout

* cleanup

* cleanup

* config

* cleanup
2024-08-13 11:00:41 -07:00
Raja Subramanian
edad813c61 Add DisconnectReason to ParticipantInfo. (#2930) 2024-08-13 17:24:09 +05:30
Raja Subramanian
9a6b4c6956 Send signal response for non-error cases also. (#2926)
* Send signal response for non-error cases also.

Gated by protocol version 15 or higher for sending OK response.

* explicit reason init
2024-08-12 22:25:34 +05:30
Raja Subramanian
1c265180f1 Fix ARM compile. (#2923)
(1 << 32) was outside range for 32-bit arch.
2024-08-11 11:14:40 +05:30
Raja Subramanian
d0ac19779e Reset DD tracker layers when muted. (#2920)
* Reset DD tracker layers when muted.

@cnderrauber, I think this is okay to do, but please let me know if
there are gotchas in there.

* copy

* more compact form
2024-08-10 15:42:14 +05:30
Benjamin Pracht
64057c3e4d Implement AgentDispatch service (#2919)
This allows listing, adding and deleting agent dispatches on an existing room. Requests go to a new AgentDispatchService, which sends them over RPC to the rtc.Room via the RoomManager. The rtc.Room then does agent job management using RPCs to the agent service.
2024-08-08 22:31:23 +02:00
Raja Subramanian
7018e485f2 Do not start forwarding on an out-of-order packet. (#2917)
It is possible that old packets arrive on receiver. If subscriber starts
on that, the first packet time would be incorrect. Do not start
forwarding on out-of-order packets.
2024-08-08 23:15:04 +05:30
Dan McFaul
489f73f0a4 distribute load to agents probabilistically, inversely proportionate to load (#2902)
* select the least loaded agent worker for job dispatch

* update to load balance using inverse load

* remove unused file

* adding unit tests for worker job distribution
2024-08-07 21:05:47 -06:00
cnderrauber
a8730b04b8 move TrackSubscribed trigger to MediaSubscription (#2916) 2024-08-07 22:30:52 +08:00
Paul Wells
2346c8a6b7 add example agent test (#2914) 2024-08-06 19:51:30 -07:00
Paul Wells
e9b6bf43c3 add mock agent for integration tests (#2913)
* add mock agent for integration tests

* cleanup
2024-08-06 19:46:52 -07:00
Paul Wells
de0c5bbd91 use structured logging for create room request (#2912) 2024-08-06 19:45:00 -07:00
Raja Subramanian
01100650f6 Clean up packet checks. (#2910)
Still leaving the utility `ValidateRTPPacket` in helpers as it could be
useful.
2024-08-06 14:30:08 +05:30
Raja Subramanian
13ee1aca28 Delay getting forwarder state till migration is complete. (#2909) 2024-08-06 12:45:46 +05:30
Raja Subramanian
8c323330b6 Store subscriber forwarder state (#2907)
* Forwarder state for migrating participant.

* clean up

* update protocol deps

* cleanup debug
2024-08-05 21:13:07 +05:30
cnderrauber
5e4c6d46fb rename log (#2906) 2024-08-05 13:46:56 +08:00
David Zhao
b1fbca066f Send the correct room closed reason to clients (#2901)
* Send the correct room closed reason to clients

* update go mod
2024-08-01 19:40:06 -07:00
Raja Subramanian
1993c87fd8 Do not force rollover if ts rollover is not active. (#2899)
There are cases of small negative sequence number jump and small
positive time stamp jump. Those should not force rollover. Maybe, they
should be dropped, but just logging for now till we learn more.
2024-08-01 22:08:53 +05:30
Raja Subramanian
18fd622802 Add API to get highest time stamp from RTPStatsReceiver. (#2898) 2024-08-01 13:26:25 +05:30
Raja Subramanian
c2c187202f Fix forced rollover of RTP time stamp. (#2896)
* Fix forced rollover of RTP time stamp.

Was erroneously forcing a rollover when the timestamp jump actually has
room to accommodate large jumps. For example, before pause ts = 10, then
eight hour pause, restart ts = 10  + (8 * 00 * 60 * 90000) = 2592000010
(at 90000 clock rate for video). In normal processing, it will look like
out-of-order as the difference 2592000000 is more than half the 32-bit
range. But, forcing a roll over is incorrect.

Fix by calculating excess over the full range and then account for wrap
around.

* log potential ts rollover

* clamp at min 0
2024-07-31 12:45:19 +05:30
Raja Subramanian
d68dd3033d Use extended sequence number in bucket (#2895) 2024-07-30 14:21:37 +05:30
Raja Subramanian
4e29e18129 Set gapSN when initing. (#2893) 2024-07-30 07:48:06 +05:30
Raja Subramanian
3e6e6e2732 Ignore really old packets. (#2891)
* Ignore really old packets.

There are cases where really old packets (time stamp is way back, but
sequence number looks like it is moving forward) which cause the
sequence number to update incorrectly. Drop those packets are they are
very old.

* test
2024-07-29 10:51:01 +05:30
Raja Subramanian
d27ecc0732 Switch order so that last calculated clock rate does not get (#2890)
divide-by-zero.
2024-07-26 10:50:51 +05:30
cnderrauber
f6f6cca133 don't push 0 ssrc probing packets to pending queue (#2888) 2024-07-23 17:58:04 +08:00
Benjamin Pracht
0fd09d73c1 Instantiate default agent dispatches in rtc for better backward compatibility (#2886) 2024-07-22 08:44:13 -07:00
Raja Subramanian
bd616d6074 Split ICE candidate queue. (#2885)
Shared ICE candidate queue meant only one of PUBLISHER/SUBSCRIBER pc got
final candidate notification. Split the queue.
2024-07-20 10:25:06 +05:30
Benjamin Pracht
73b3a91a5c Use RoomConfiguration message from protocol (#2882) 2024-07-19 13:54:33 -07:00