Commit Graph

63 Commits

Author SHA1 Message Date
David Zhao
53f51c8cb0 Logging cleanup (#843)
* Logging cleanup

Changes log levels to better match significance

* fix lock
2022-07-21 00:39:49 -07:00
cnderrauber
fcdff4f97a enable nack for audio track (#829) 2022-07-13 16:05:57 +08:00
Raja Subramanian
9032db857c Connection quality clean up (#766)
* WIP commit

* WIP commit

* Remove debug

* Revert to reduce diff

* Fix tests

* Determine spatial layer from track info quality if non-simulcast

* Adjust for invalid layer on no rid, previously that function was returning 0 for no rid case

* Fall back to top level width/height if there are no layers

* Use duration from RTPDeltaInfo
2022-06-18 21:58:47 +05:30
Raja Subramanian
83b71fce50 Set SSRC for RTCP (#760)
- SenderSSRC was not set for NACK, RTCP_RR - so SRTP context
was using SSRC = 0 which is not bad, but let us set the SSRC properly.
- PLI was using a random SSRC on every PLI. So, that would have
created a new SRTP stream (not bad as that stream context is small)
on every PLI. It is wasteful. So, set the SenderSSRC to the mediaSSRC.
- Reduce re-start of higher layers to 10 seconds. That is long enough
to declare that a stream layer has restarted.
2022-06-16 12:07:21 +05:30
Raja Subramanian
e72fd80ca0 Move rtp stats log to info (#752) 2022-06-06 22:20:48 +05:30
cnderrauber
6ba034feae shorten the time cost for subscriber get media tracks (#747)
* set DownTrack's initial codec to first codec of potential codecs

* faststart on subscribe
2022-06-02 10:00:42 +08:00
cnderrauber
f958fbcc1c simulcast codecs support (#720)
simulcast codecs support 

Co-authored-by: David Zhao <dz@livekit.io>
2022-05-27 19:55:50 +08:00
Raja Subramanian
77b8e9eecb Fix a couple of more races (#717)
* Use grants clone

* Fix a couple of more races

Use a shadow copy of down tracks in DownTrackSpreader.
Read always uses the shadow.
On Add/Delete of down track, make a new copy.
Copying is done only on add/delete.
If somebody is holding reference to a shadow, it will be in tact as Add/Delete create a new slice.

With this, not seeing any more races in test. So, enabling CI tests with `-race`.

Also fixing another race reported in #603

There are a couple of more races in that bug report that needs to be
chased down.

* Use env suggested in https://lifesaver.codes/answer/runtime-race-detector-sigabrt-or-sigsegv-on-macos-monterey-49138

* staticcheck, did not fail locally, but reported by CI

* use API to get down tracks
2022-05-25 16:14:07 +05:30
cnderrauber
07b93e2e5b add support for av1 svc (#669)
* add support for av1 svc
2022-05-06 18:24:29 +08:00
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
0a802077dd Remove callbacks queue from sfu/buffer. (#650) 2022-04-24 21:39:28 +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
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
David Zhao
4475a028b6 Removed REMB references for publisher (#605) 2022-04-07 18:24:11 -07:00
Raja Subramanian
73ae58bb42 Reduce chatty logs (#592) 2022-04-06 06:30:26 +05:30
David Colburn
0b8a180554 Code inspection (#581)
* Code inspection

* fix [4]int64 conversiong
2022-03-30 13:49:53 -07:00
cnderrauber
3959251837 add support for vp9 and av1 (#574) 2022-03-28 22:22:48 +08:00
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
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
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
33f9726b79 Key frames (#522)
* Key frames

- Keep track of key frame stats
- Split out PLI from down track used for purpose of layer locking.
This will give us a good picture of down stream issues forcing a PLI.
- Use key frame requester whenever there is a layer lock required.
Not just the first key frame. With the synchronous thing, the counter
was just ridiculously high like 150 or something because of all
the initial padding packets. Also, use RTT in key frame requester.

* send first PLI before waiting

* Turn off key frame requester when disabled

* simplify
2022-03-16 19:55:12 +05:30
David Zhao
d498cccc05 Fixed panics with nil stats (#517) 2022-03-15 12:01:26 -07:00
Raja Subramanian
4d1cc82c89 Remove unused with move to RTPStats (#516) 2022-03-15 23:01:37 +05:30
Raja Subramanian
ae85e55fd4 Using RTPStats across the board (#515)
* WIP commit

* Clean up
2022-03-15 17:47:19 +05:30
Raja Subramanian
80bd45f061 Some clean up (#505)
* WIP commit

* Refactor NTP time

* Clean up

* Update lk protocol
2022-03-11 22:40:49 +05:30
cnderrauber
a5fa54853f fix potential nil rtcp packets cause rtcpSendWorker exit (#504) 2022-03-11 15:40:24 +08:00
Raja Subramanian
acbafa06f2 Log key frame and layer lock (#496) 2022-03-09 09:50:16 +05:30
cnderrauber
608da4ba4b stats for pli and bitrate (#487)
* stats for pli and bitrate

* solve comments

* return 0 if no pli sent
2022-03-07 14:59:01 +08:00
Raja Subramanian
c743d2ab3a Warn on ops queue full (#481)
Pass logger so that we can log with proper context.
2022-03-02 19:08:07 +05:30
Raja Subramanian
bfa350451e Start connection stats only after bind (#480) 2022-03-02 17:05:11 +05:30
Raja Subramanian
5a4181b581 Replacing hand rolled ion-sfu atomic with uber/atomic (#465)
* Replacing hand rolled ion-sfu atomic with uber/atomic

* Remove another hand rolled atomic
2022-02-25 11:57:09 +05:30
Raja Subramanian
2959eebca8 Introducing OpsQueue (#463)
* Introducing OpsQueue

Creating a PR to get feedback on standardizing on this concept.

Can be used for callbacks.
Already a couple of places use this construct. Wondering if we
should standardize on this across the board.
Just changing one place to use the new struct. Another place
that I know of which uses this pattern is the telemetry package.

* atomic flag -> bool
2022-02-25 11:56:26 +05:30
Raja Subramanian
0bbed7f0bd Use padding for probing (#434)
* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* Clean up

* Remove debug

* Remove unneeded change

* fix test

* Remove incorrect comment

* Reset probe after estimate trends down
2022-02-17 11:03:23 +05:30
Raja Subramanian
a6338992e8 Stop forwarding on congestion (#429)
* WIP commit

* comment out debug stuff
2022-02-11 09:17:53 +05:30
Raja Subramanian
f4f9df375f Ignore 0 RTT for nacker (#424)
- Propagate when a track is added
- Reduce scope of lock
2022-02-09 14:08:07 +05:30
Raja Subramanian
3117547d60 Consolidating PLI throttle (#419)
* Consolidating PLI throttle

Use the throttler in `sfu.WebRTCReceiver`.

Does change shape of config object.

* Move PLIThrottleConfig to sfu.WebRTCReceiver

* fix test compile

* Cleaning up unused stuff

* readability improvement
2022-02-08 22:50:43 +05:30
Raja Subramanian
fee3009853 Use buffer channel for all RTCP messages (#418)
RTCP messages are going through two channel hops now.
Maybe we don't need that anymore now that the original
problem is diagnosed. But, pushing all RTCP via
the callbackOps channel for now to make it consistent.
2022-02-08 17:19:59 +05:30
Raja Subramanian
e948ecb3a8 Duplicate packets should not update packet loss counter (#417) 2022-02-08 16:32:49 +05:30
cnderrauber
00b2a216c7 fix deadlock cause underlying buffer full (#413)
* fix deadlock cause underlying buffer full
2022-02-08 16:00:56 +08:00
Raja Subramanian
36289bbca7 FPS (#410)
* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* Clean up

* Clean up

* Store RTT in stats

* spelling mistake

* Make tests compile

* Fix test compilation error

* fix tests

* clone

* latest protocol
2022-02-08 12:53:14 +05:30
Raja Subramanian
4a9b844781 Process RTX packets for TWCC (#406)
The SRTP replay detection was disabled recently.
But, they were effectively getting dropped in `sfu.bucket`.

Doing two things with RTX packets in this PR
1. Update stats - add to packet count and bytes
2. Process header extension - to process TWCC
2022-02-05 23:25:53 +05:30
Raja Subramanian
4388a68b7e Breaking up calc for easier reading. (#402)
* WIP commit

* fix test

* More clean up

* cast to right size

* use local variable

* set a default RTT

* Do not log RTX, although need to figure out source of RTX

* fix test
2022-02-04 14:18:25 +05:30
Raja Subramanian
05c8a6b2fd Cleaning/simplifying some buffer bits (#398)
* Cleaning/simplifying some buffer bits

1. NACKs are always inserted in order. So, get rid of
bunch of out-of-order handling in there and simplify.
2. For now, removing triggering a key frame from NACKs.
Let subs drive it.
3. Move to 16-bit sequence numbers except for receiver
report handling. Simplify bits about unwrapping sequence
number on all packets.
4. Remove unused code.

* remove unused field
2022-02-04 08:43:32 +05:30
David Colburn
7bbd238188 clean up logs and imports (#400) 2022-02-03 14:20:19 -07:00
Raja Subramanian
0574803be8 Random clean up (#392) 2022-02-01 08:57:34 +05:30
Raja Subramanian
9db2bd22df LK logger with context in SFU (#391)
* LK logger with context in SFU

* Move buff.SetLogger into sfu.WebRTCReceiver
2022-02-01 08:57:09 +05:30