Commit Graph

189 Commits

Author SHA1 Message Date
Raja Subramanian d863b45dc1 Remove Head field from ExtPacket structure. (#662)
* Remove `Head` field from `ExtPacket` structure.

Although we do not intend to, but if packets get out-of-order
in the forwarding path (maybe reading in multiple goroutines
or using some worker pool to distribute packets), the `Head`
indicator could lead to wrong behaviour. It is possible that
at the receiver, the order is
- Seq Num N, Head = true
- N + 1, Head = true

If the forwarding path sees `N + 1` first, the Head flag
when it sees `N` packet is incorrect and will lead to incorrect
behaviour.

The alternative check is very simple. So, remove `Head` flag.

* Remove unused field
2022-05-02 10:16:17 +05:30
David Zhao 289d63ac53 Fix node ip parameter not being used (#661)
* Use node-ip if provided

* formatting
2022-04-29 15:26:37 -07:00
Raja Subramanian ea61b588a2 Simplifying SN info cache in RTPStats module (#660)
* Simplifying SN info cache in RTPStats module

* Remove unnecessary field
2022-04-28 18:48:59 +05:30
Raja Subramanian ca6ad7ec7a Use seq num offsets cache instead of missing seq num map. (#658)
* Use seq num offsets cache instead of missing seq num map.

Map operations can be costly. Use a fixed size array to store offsets.
4096 sequence numbers should be more than 16 seconds for 720p video
which should be plenty to look up offset of out-of-order packets.
Packets out-of-order more than that will probably be useless anyway.

* Move offset cache population to only when we are forwarding

* add some debug logs

* Remove debug
2022-04-28 15:16:42 +05:30
Raja Subramanian a83bd5c2f6 Split out load balancer into a separate module (#657) 2022-04-26 15:46:30 +05:30
Raja Subramanian 2f902a3edc Remove callbacks queue from sfu/DownTrack (#655)
* Remove callbacks queue from sfu/DownTrack

- Connection stats callback was happening in connection stats go routine
- RTT update launches a goroutine on the receive side as it affects the
  subscriber. So, no need to queue it.
- Changed two things
  o Move close handler to goroutine. It is better that way as it touches
the subscriber as well
  o Move max layer handling into a goroutine also so that the callback
does minimal work.

With this all the send side callback queues are removed.

* small clean up
2022-04-25 13:28:24 +05:30
Raja Subramanian f0f66a2d75 Remove ops queue from stream tracker. (#652)
It is not needed as the callback happens in a goroutine.
Also, had missed included bitrate availability change in the queue
which was inconsistent.
2022-04-25 12:51:29 +05:30
Raja Subramanian 4d7950ec2f Do not send down track callbacks to streamallocator via queue (#651) 2022-04-24 21:41:58 +05:30
Raja Subramanian 0a802077dd Remove callbacks queue from sfu/buffer. (#650) 2022-04-24 21:39:28 +05:30
Raja Subramanian d38566850a Do not post close callback in ops queue if not started. (#649)
* Do not post close callback in ops queue if not started.

Ops queue is started in `Bind()`. If `Close()` is called
when bind did not happen (because the underlying peer connection
closed before bind), the close callback does not run.

Check if ops queue is running before posting close callback
into the queue.

Not pretty, but covers this case. Need to think about it more.

* correct check
2022-04-24 11:40:22 +05:30
Raja Subramanian 2e182afb61 Reduce memory used by RTPStats. (#645)
Keep track of last 2048 sequence numbers instead of full range
to reduce memory usage.
2022-04-22 17:17:37 +05:30
Raja Subramanian 2b6a304b27 Increase size of RTCP channel just to be safe. (#641)
Also, using select to log warnings when queue is full.
2022-04-21 12:21:21 +05:30
Raja Subramanian 43d0573693 Moving smoothing into the audio level module. (#636) 2022-04-20 23:59:51 +05:30
Raja Subramanian 6a53891f9f Process header extensions in line (#635)
* WIP commit

* Pass audio config

* Fix test compile
2022-04-20 18:20:28 +05:30
Raja Subramanian 1fe485ef0c Use cache for packet level processing. (#632)
* Use cache for packet level processing.

Do not overload ops queue for packet level operations.

* byte -> uint8
2022-04-20 13:19:10 +05:30
David Zhao b821a0997d Use common logging init functions (#633)
* Use common logging init functions

* update protocol commit

* fix tests
2022-04-20 00:15:11 -07:00
Raja Subramanian 75ec31f237 Support starting off with not forwarding video (#623) 2022-04-19 12:37:53 +05:30
Raja Subramanian 2e9bccfeff Allow padding packets to stream tracker. (#618) 2022-04-18 10:20:52 +05:30
Raja Subramanian ed2a0011d9 Lock to receiver report for senders (#616) 2022-04-17 08:43:50 +05:30
Raja Subramanian a98d955284 Delta stats throughout (#615)
* Use delta stats throughout and avoid calculating deltas in telemetry

* Fix a few things after testing

* Remove debug

* Fix tests

* delete instead of setting to nil

* Point to the latest protocol
2022-04-16 21:11:32 +05:30
Raja Subramanian 587534d121 Count repeated NACK only on a hit (#611) 2022-04-13 18:01:59 +05:30
Raja Subramanian ee7bb0a1ad Log both estimate and nack ratio when congestion detected (#608) 2022-04-10 12:09:11 +05:30
David Zhao 4475a028b6 Removed REMB references for publisher (#605) 2022-04-07 18:24:11 -07:00
Raja Subramanian 93a2730128 Resync on mute to avoid sequence number jumps on unmute (#597) 2022-04-06 23:23:57 +05:30
David Zhao 8fbe00edb3 Avoid locking when flushing DownTrack (#594) 2022-04-05 23:45:51 -07:00
Raja Subramanian 2e71fba3da Prevent negative timestamp diff (#595)
Found another reason for potential stalling on layer switch up.

When switching up, it is possible that the key frame of the packet
at higher layer arrives very close to a packet in the currently
forwarded layer.

An inversion happens when higher layer packet arrives earlier
(as timestamped at receicver), but gets scheduled for forwarding
later (as seen by forwarder).

Because of the order of processing goroutines,
it is possible to have negative diff when trying to adjust
RTP timestamps for layer switch. A negative diff results in
large jump in RTP timestamp. Client stalls, sends PLI three seconds
later (3 seconds is a Chrome thing, not sure about others), waits
for another key frame and starts again. In the mean time, the
video is frozen.
2022-04-06 10:18:41 +05:30
Raja Subramanian 73ae58bb42 Reduce chatty logs (#592) 2022-04-06 06:30:26 +05:30
Raja Subramanian 92009b6428 Consistently stop tickers (#593) 2022-04-05 20:42:06 +05:30
David Colburn 0b8a180554 Code inspection (#581)
* Code inspection

* fix [4]int64 conversiong
2022-03-30 13:49:53 -07:00
Raja Subramanian f694dad105 Reset available layers when removing all trackers (#575) 2022-03-29 08:16:18 +05:30
cnderrauber 3959251837 add support for vp9 and av1 (#574) 2022-03-28 22:22:48 +08:00
Raja Subramanian f293de054d Fix large reported loss in RTPStats (#564)
Had to check for half the range to see if start needed to be moved back.
2022-03-24 12:17:36 +05:30
Raja Subramanian ab7c63a08a Remove padding double counting (#562) 2022-03-24 06:36:17 +05:30
Raja Subramanian ed9234f71b Removing unused functions and adding more logs (#560)
* Removing unused functions and adding more logs

* Do not include padding packets in Packets
2022-03-23 22:26:34 +05:30
Raja Subramanian 06ea1d2ad3 Log rtp stats for debugging large gaps or all packets getting reported lost (#559) 2022-03-23 15:12:45 +05:30
Raja Subramanian 757a59fbcd Use windowing for NACK monitoring (#557)
* Use windowing for NACK monitoring

* Fix test
2022-03-23 13:42:29 +05:30
Raja Subramanian 076eb1c8ae Dampen stream allocator (#551)
* WIP commit

* WIP commit

* WIP commit

* format

* NACK window

* Remove layer when it is expected to stop

* Remove debug
2022-03-22 22:23:22 +05:30
Raja Subramanian 0a88dee95e A minimum channel capacity config (#549) 2022-03-22 13:13:48 +05:30
Raja Subramanian 641858832a Address edge case stream allocation (#544)
* Handle an edge in layer lock.

A very edge case
- Available layer: [0, 1, 2], but bitrate is not yet available.
We set it to layer 2 awaiting measurement.
- Measurement for layers 0 and 1 come through.
- Still no key frame for layer 2.
- Finalize layers runs and sees that bitrate is available for 0 and 1.
It finalizes layer 1.
- Layer 1 key frame comes (because we asked key frame of layer 2,
publisher sends key frame for all layers). Locks to layer 1.
- No more events happen to switch to layer 2.

Changes
-------
- Move bit rate measurement to StreamTrackerManager. Allows re-use
in relay.
- Make bit rate availability (from zero -> non-zero) an event
and let it flow through the stream allocation flow so that we
always have an event when bit rate measurement becomes available.
This gets rid of finalization which I was unhappy with it anyway as
it was polling every second.
- Removing REMB stuff from buffer. We do not use it.
It is incorrect anyway. REMB should be ay peer connection level.

* Fix test

* fix test

* Simplify allocate

* Simplify/clean up
2022-03-21 14:53:31 +05:30
Raja Subramanian 82e1c391a4 Fix time stamp jump on layer switch (#543) 2022-03-20 13:36:29 +05:30
Raja Subramanian 1d03a5a3b6 Lock temporal layers to target for non-temporal layer codecs also (#542) 2022-03-20 11:11:49 +05:30
Raja Subramanian 8c9c1fe837 Always do stats update and header extension processing (#540)
Also, use Errorw for tracking large gap to get a back trace.
2022-03-19 21:29:10 +05:30
Raja Subramanian 5a9da8bee2 Do not double count NACK miss in sfu.DownTrack (#536) 2022-03-19 11:10:58 +05:30
Raja Subramanian ed00146937 Fix packets/packetRate mismatch (#534)
This still does not address root cause of large loss, but at least
does not display crazy thing like packets = 0, but packet rate is 45/s.

Also, RLock in ToString() as there are bits of structure used in
stringification.
2022-03-19 01:06:52 +05:30
Raja Subramanian 13083a143f More logs (#533) 2022-03-19 00:38:22 +05:30
Raja Subramanian d738424173 Catch a few edge cases in stream allocator. (#532)
* Catch a few edge cases in stream allocator.

- More useful logging

* fire probe cluster done callback only when there is an active cluster
2022-03-18 20:42:15 +05:30
Raja Subramanian 3ce4010e89 Fix bracket (#531) 2022-03-18 11:25:20 +05:30
Raja Subramanian a709cc0ad7 Exempt layers in stream tracker (#530)
For now, exempt layer 0 from stream tracker declaring it stopped.
2022-03-18 11:17:48 +05:30
Raja Subramanian 64f82a6a73 Fix off by one packets expected (#529) 2022-03-18 10:03:09 +05:30
cnderrauber c6a35d3ff1 fix keyFrameRequestGeneration not exit after close (#527)
* fix keyFrameRequestGeneration not exit after close

* change to bound check

* Refactor stop key frame requester into a function

* Remove redundant key frame requester stop

Co-authored-by: boks1971 <raja.gobi@tutanota.com>
2022-03-17 18:50:07 +08:00