Commit Graph

779 Commits

Author SHA1 Message Date
Raja Subramanian
66a3a8e028 cond broadcast always. (#2699)
With Read and ReadExtended waiting (they are two different goroutines),
use Broadcast always. In theory, they both should not be waiting at the
same time, but just being safe.
2024-05-10 12:32:28 +05:30
Raja Subramanian
71b5ffed93 Less confusing variable name (#2706) 2024-05-08 16:10:49 +05:30
Paul Wells
9a5db132eb add room/participant name limit (#2704)
* add room/participant name limit

* defaults

* simplify

* omitempty

* handle 0 config

* fix race

* unlock

* tidy
2024-05-06 17:25:18 -07:00
Raja Subramanian
4d7586bda8 Simplify layer roll back. (#2702)
* Cache TS offset along with sender report.

* set offset after clearing

* simplify roll back
2024-05-04 15:00:19 +05:30
Raja Subramanian
26c2f7cd9a Do not use LastTS for dummy offset. (#2700)
* Do not use LastTS for dummy offset.

LastTS could be random when using dummy start. That should not be used
in calculating offsets.

Also, do not push padding into sequence before init. Could have heppened
with dummy start.

* apply dummy offset before comparing to last

* refresh ref TS

* initialize codec munger on catch up forwarding
2024-05-03 18:56:01 +05:30
Raja Subramanian
674550ea16 Option to disable traffic load tracking. (#2698) 2024-05-02 19:09:12 +05:30
Raja Subramanian
a2a8810734 log the correct new propagation delay (#2694) 2024-04-30 08:29:59 +05:30
Raja Subramanian
c8b289daa5 (Attempted) Simplify time stamp calculation on switches. (#2688)
* Simplify time stamp calculation on switches.

Trying to simplify time stamp calculation on restarts.
The additional checks take effect rarely and it not worth the extra
complication.

Also, doing the reference time stamp in extended range.
The challenge with that is when publisher migrates the extended
timestamp could change post migration (i. e. post migration would not
know about rollovers). To address that, maintain an offset that is
updated on resync.

* WIP

* Revert to resume threshold

* typo

* clean up
2024-04-28 12:13:52 +05:30
Paul Wells
18b3b7b421 use readCond in buffer read (#2691) 2024-04-27 04:04:01 -07:00
Paul Wells
c4354575ec do not capture pointers in ops queue closures (#2675) 2024-04-22 11:33:28 -07:00
Raja Subramanian
2ad0efc28f Handle large jumps in RTCP sender report timestamp. (#2674)
* Handle large jumps in RTCP sender report timestamp.

Seeing cases of RTCP Sender Report spaced apart by more than half the
RTP Timestamp range. Maybe a case of laptop going to sleep and waking
up. Handle it using time diff from last report and calculating expected
timestamp.

* try go 1.22
2024-04-22 23:04:56 +05:30
Raja Subramanian
af0b0c4734 Connection quality LOST only if RTCP is also not available. (#2670)
* Connection quality LOST only if RTCP is also not available.

It is possible that sender stops all layers of video due to some
constraint (CPU or bandwidth). Packet reception going dry due to
that should not trigger `LOST` quality.

Add last received RTCP time also to distinguish the case
of real `LOST` and sender stopping traffic.

Some bits to watch for
- With audio, RTCP reports could be more than 5 seconds apart (5 seconds
  is the default interval for connection quality scorer), but audio
  senders usually send silence packets even when there is no input.
  So audio completely stopping can be considered `LOST`.
- With video, have to observe if all clients continue to send RTCP even
  if all layers are stopped.
- RTCP bandwidth is not supposed to exceed the primary stream bandwidth.
  libwebrtc calculates that and spaces out RTCP reports accordingly.
  That is the reason why audio reports are that far apart. If a video
  stream is encoded at a very low bit rate, it could also be sending
  RTCP rarely. So, there is the case of LOST being indistinguishable
  from sender stopping all layers. But, this should be a rare case.

* typo
2024-04-21 23:35:24 +05:30
Paul Wells
680a07e896 update pion deps (#2667)
* update pion deps

* deps
2024-04-19 19:21:55 -07:00
Raja Subramanian
f4745b8437 Do codec munging when munging RTP header. (#2665)
* Do codec munging when munging RTP header.

It was possible for probe packets to get in between RTP munging and
codec munging and throw off sequence number while dropping packets.
Affected only VP8 as it does codec munging.

* do not pass in buffer as it is created anyway

* flip fields

* flip order

* fix test

* call translate for all tracks

* simplify
2024-04-19 22:32:13 +05:30
cnderrauber
8eb86f1077 Don't log dd invalid template index (#2664)
If the first packet of keyframe has template structure is lost then
subsequent packets rely on it will report invalid tempalte error which
is expected.
2024-04-19 16:48:36 +08:00
cnderrauber
0b3587b10d Disable dynamic playout delay for screenshare track (#2663)
Screenshare video has inaccuracy jitter due to its low frame rate and bursty traffic
2024-04-19 15:25:48 +08:00
Paul Wells
483aafcfc0 fix key frame timer (#2662) 2024-04-18 01:24:45 -07:00
Paul Wells
0974f3d961 replace keyframe ticker with timer (#2661) 2024-04-17 22:14:17 -07:00
Paul Wells
5c38d58987 add typed ops queue (#2655)
* add typed ops queue

* tidy
2024-04-16 02:51:49 -07:00
Raja Subramanian
04d193e0b2 Update mediatransportutil. (#2652)
Also, use adjusted time of sender report for drift logging.
2024-04-16 10:10:06 +05:30
Raja Subramanian
ec41d20f81 Reduce RED weight in half. (#2648) 2024-04-12 20:39:53 +05:30
Raja Subramanian
d55948f761 Add PropagationDelay API to sender report data (#2646) 2024-04-11 20:00:13 +05:30
Raja Subramanian
ad1f508680 Add support for "abs-capture-time" extension. (#2640)
* Add support for "abs-capture-time" extension.

Currently, it is just passed through from publisher -> subscriber side.

TODO: Need to store in sequencer and restore for retransmission.

* abs-capture-time in retransmissions

* clean up

* fix test

* more test fixes

* more test fixes

* more test fixes

* log only when size is non-zero

* log on both sides for debugging

* add marshal/unmarshal

* normalize abs capture time to SFU clock

* comment out adding abs-capture-time from registered extensions
2024-04-11 15:25:10 +05:30
Raja Subramanian
21fbda3470 Silence some noisy debug logs (#2643) 2024-04-11 10:58:19 +05:30
wanshuangcheng
e1b68012a1 chore: fix typos in comment (#2634)
Signed-off-by: wanshuangcheng <wanshuangcheng@outlook.com>
2024-04-10 09:27:48 -07:00
Raja Subramanian
c6ee34d083 Cleaning up stream allocator data. (#2639)
* Cleaning up stream allocator data.

Marking it with STREAM-ALLOCATOR-DATA for easier use later if needed.

* clean up a bit more

* wire_gen

* wire_gen
2024-04-10 13:31:25 +05:30
Paul Wells
4b7e5dc1cc reduce gc from stream allocator rate monitor (#2638)
* reduce gc from stream allocator rate monitor

* deps

* comment out rate monitor
2024-04-09 23:14:15 -07:00
cnderrauber
196fed605e Limit playout delay change for high jitter (#2635)
* Limit playout delay change for high jitter

* fix test
2024-04-08 21:50:50 +08:00
Raja Subramanian
ddece1fbb0 Use aarival time in cached packets. (#2633) 2024-04-08 11:29:55 +05:30
Raja Subramanian
8852d71a8a Disable audio loss proxying. (#2629)
* Disable audio loss proxying.

Added a config which is off by default.
With audio NACKs, that is the preferred repair mechanism.
With RED, repair is built in via packet redundancy to recover from
isolated losses.
So, proxying is not required. But, leaving it in there with a config
that is disabled by default.

* fix test
2024-04-06 11:28:04 +05:30
Raja Subramanian
e93611eafa Log sender reports. (#2625) 2024-04-05 18:21:38 +05:30
Raja Subramanian
d3f0436d25 Fix reference time stamp layer. (#2623)
- Had arguments reversed.
- Also, cannot take away reference layer from state as a new layer
  as reference could have a time stamp that is widely different from
  expected. So, put that back.
2024-04-04 21:09:11 +05:30
Raja Subramanian
5cfcbc0ca6 Move caching of publisher sender report to subscriber side. (#2622)
* Move caching of publisher sender report to subscriber side.

Please see inline for descriptive comments on why. Basically,
pause/unpause using replaceTrack(null)/replaceTrack(actualTrack) can
cause time stamp in sender report sent to subscribers jump ahead.
This prevents that.

With the caching on subscriber side, cleaning up the caching on
publisher side.

* fix compile, test still failing, need to debug

* skip reference TS for testing
2024-04-04 18:23:30 +05:30
Raja Subramanian
63b1fba082 Add start/end time to AnalyticsStream. (#2618)
* Add start/end time to AnalyticsStream.

* fix test
2024-04-03 12:23:18 +05:30
Raja Subramanian
860702e9dc Prevent large spikes in propagation delay (#2615)
* Prevent large spikes in propagation delay

A few tweaks
- Large spike in propagation delay due to congested channel results in
  long term estimate getting high value. Ignore outliers in long term
  estimate.
- Introduce a new field for adjusted arrival time as adjusting the
  arrival time in place meant it got applied again across the relay and
  that caused different propagation delay on remote nodes.
- Reset path change counters as long as there is any sample that is not
  higher than the multiple of long term. There was a case of
  o Sample with high value that triggered path change start.
  o Then some samples with high enough delta, but did not meet the
    criteria for increasing counter further.
  o Some time later, another sample met the threshold and that triggered
    a path change re-init.

* do not adapt to large delta
2024-04-02 14:21:20 +05:30
Raja Subramanian
4c9e59dc25 Small tweaks to propagation delay adaptation. (#2607) 2024-03-30 21:53:18 +05:30
Raja Subramanian
b5de646073 Remove redundant check. (#2605)
* Remove redundant check.

That check is already at the ouside check.

* print string

* space
2024-03-30 00:31:26 +05:30
cnderrauber
0a35e59ebd Replace sleep with sync.Cond to reduce jitter (#2603) 2024-03-29 17:24:31 +08:00
cnderrauber
bc5fc17bdc Log high jitter case (#2602) 2024-03-28 15:59:03 +08:00
Raja Subramanian
45581433cc Add option to enable bitrate based scoring (#2600) 2024-03-27 18:45:53 +05:30
Raja Subramanian
0480f99a83 Tweak adaptation to increase in propagation delay. (#2598)
* Tweak adaptation to increase in propagation delay.

A couple of issues
- RTCP Sender Reports rate will vary based on underying track bitrate.
  (at least in theory, not all entities will do it though, for example
  SFU does standard rate of one per three seconds irrespective of track
  bit rate). So, adapt the long term estimate of propagation delay delta
  based on spacing of reports.
- Re-init of propagation delay to adapt to path change was taking the
  last value before the switch. But, that one value could have been an
  outlier and accepting it is not great. So, adapt spike time
  propagation delay in a smoother fashion to ensure that all values
  during spike contribute to the final value.

* clean up
2024-03-26 17:33:24 +05:30
Raja Subramanian
ffb831aa8c Cache transceiver before closing subscribed track. (#2594)
On migration, when subscription moved from remote -> local,
transceiver caching was racing. Although a very small possibility,
it could happen like so

1. down track close
2. down track close callback fires go routine to close subscribed track
3. subscribed track close handler in subscription manager tries to
   reconcile
4. reconcile adds subscribed track again
5. cannot find cached transceiver as caching happens after down track
   close finishes in stap 1 above. Although there are a couple of
   gortouine jumps (step 2 fires a goroutine to close subscribed track
   and step 4 will reconcile in a goroutine too), it is theoretically
   possible that the step 1 has not finished and hence transceiver is
   not cached.

Fix is to move caching to before closing subscribed track.
2024-03-22 11:56:50 +05:30
Raja Subramanian
7945c01dbe Reset sharp increase if received delta is small. (#2592) 2024-03-21 10:25:45 +05:30
Raja Subramanian
03ada9ba76 Proper RTCP report past mute. (#2588)
- When audio is muted, server injects silence frames which moves the
  time stamp forward and adjusts offset. That cannot be used against
  publisher side sender report. Use a pinned version.
- Ignore small changes to propagation delay even while checking for
  sharp increase. That is spamming a lot for small changes, i.e.
  existing delta is 100 micro seconds or so and the new one is 300 micro
  seconds. Also rename to `longTerm` from `smoothed` as it is a slow
  varying long term estimate of propagation delay delta. And slow down
  that adaptation more.
2024-03-19 11:59:24 +05:30
Raja Subramanian
14321f21bf Make OpsQueueParams to make it easier to understand args. (#2578) 2024-03-14 10:27:24 +05:30
Raja Subramanian
e376625a13 Do not need to flush stream allocator events. (#2577) 2024-03-14 04:36:19 +05:30
Raja Subramanian
4e96ad2e5b Missed clean up in the last PR (#2576)
* Missed clean up in the last PR

* Infow -> Debugw
2024-03-13 23:01:19 +05:30
Raja Subramanian
3e43f75143 Forward publisher sender report. (#2572)
* Forward publisher sender report.

Publisher side RTCP sernfer report is rebased to SFU time base
and used to send sender rerport to subscriber.

Will wait to merge till previous versions are out as this will require a
bunch of testing.

* - Add rebased report drift
- update protocol dep
- fix path change check, it has to check against delta of propagation
  delay and not propagation delay as the two side clocks could be way
  off.
2024-03-13 14:31:39 +05:30
Raja Subramanian
610d68a409 Clean up using publisher side clock rate. (#2568)
It is not used any more.
2024-03-11 12:25:07 +05:30
Raja Subramanian
50c48ff29d Ignore out-of-order receiver side sender reports. (#2567) 2024-03-11 11:30:01 +05:30