Commit Graph

91 Commits

Author SHA1 Message Date
cnderrauber
5b975af55f Refine dependency descriptor based selection forwarder (#1808)
* Don't update dependency info if unordered packet received

* Trace all active svc chains for downtrack

* Try to keep lower decode target decodable

* remove comments

* Test case

* clean code

* solve comments
2023-06-27 15:11:06 +08:00
Raja Subramanian
9809b8bc3a Use nack queue params. (#1789)
* Use nack queue params.

* fix test
2023-06-12 13:01:02 +05:30
cnderrauber
c91889edfd Add dependency descriptor stream tracker for svc codecs (#1788)
* Add dependency descriptor stream tracker for svc codecs

* Solve comments
2023-06-12 15:07:47 +08:00
Raja Subramanian
f518f5d743 Log head SN when packet cannot be fetched (#1780) 2023-06-09 12:13:06 +05:30
Raja Subramanian
0354626bfc Adjust sender report time stamp for slow publishers. (#1740)
It is possible that publisher paces the media.
So, RTCP sender report from publisher could be ahead of
what is being fowarded by a good amount (have seen up to 2 seconds
ahead). Using the forwarded time stamp for RTCP sender report
in the down stream leads to jumps back and forth in the down track
RTCP sender report.

So, look at the publisher's RTCP sender report to check for it being
ahead and use the publisher rate as a guide.
2023-05-25 21:55:54 +05:30
Raja Subramanian
25d6fd751f Cleaning up smoothed OWD calculation for sender report. (#1684)
* Keep track of expected RTP time stamp and control drift.

- Use monotonic clock in RTCP Sender Report and packet times
- Keep the time stamp close to expected time stamp on layer/SSRC
  switches

* clean up

* fix test compile

* more test compile failures

* anticipatory clean up

* further clean up

* add received sender report logging
2023-05-05 13:14:12 +05:30
Raja Subramanian
15078eb9f4 Keep track of expected RTP time stamp and control drift. (#1681)
* Keep track of expected RTP time stamp and control drift.

- Use monotonic clock in RTCP Sender Report and packet times
- Keep the time stamp close to expected time stamp on layer/SSRC
  switches

* clean up

* fix test compile

* more test compile failures
2023-05-04 13:00:57 +05:30
Raja Subramanian
69fb5e51a2 Fix stutter in forwarding path when using dependency descriptor (#1600)
* Decode chains

* clean up

* clean up

* decode targets only on publisher side

* comment out supported codecs

* fix test compile

* fix another test compile

* Adding TODO notes

* chainID -> chainIdx

* do not need to check for switch up point when using chains, as long as chain integrity is good, can switch

* more comments

* address comments
2023-04-12 17:30:54 +05:30
Raja Subramanian
c56e37f3fe Fix VP9 stutter in non-DD and some other misc changes (#1595)
* WIP commit

* WIP commit

* clean up

* remove todo

* fix test
2023-04-10 12:31:07 +05:30
Raja Subramanian
e32eaa451f Refactor video layer selector (#1588)
* WIP commit

* WIP commit

* fix test

* FPS for VP9

* WIP commit

* test changes

* WIP commit

* h264

* codec munger

* forwarder state

* clean up a bit

* dd interface

* WIP commit

* WIP commit

* WIP commit

* WIP commit

* more TODO notes

* overshoot interface

* clean up

* clean up isTemporalSupported

* wait for key frame to resume

* clean up VP8 payload descriptor stuff

* temporal layer selector

* comment out vp9 and av1

* space

* fix test compile

* append bytes

* fix tests

* fix test
2023-04-08 10:57:57 +05:30
cnderrauber
fb301e6e75 Add vp9 svc support by Dependency Descriptor (#1586)
* Add VP9 SVC support

* Fix preferred fps does not work

* Fix forwarder test
2023-04-06 21:51:33 +08:00
renovate[bot]
2fce780ce8 Update go deps (#1402)
* Update go deps

Generated by renovateBot

* use generics with Deque

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: David Zhao <dz@livekit.io>
2023-03-25 23:17:04 -07:00
David Colburn
191a9e8014 update core to 0.0.5 (#1540)
* update core

* sort imports

* fix typos

* redundant types
2023-03-22 16:53:23 -07:00
David Zhao
5ff72a99b9 Report publish & subscribe RTPStats as Telemetry events (#1506) 2023-03-10 10:28:54 -08:00
cnderrauber
3a4a294a92 Enable upstream nack for opus only audio track (#1343) 2023-01-28 16:02:38 +08:00
Raja Subramanian
c696626fe8 Use local time base for NTP in RTCP Sender Report for downtracks. (#1321)
* Use local time base for NTP in RTCP Sender Report for downtracks.

More details in comments in code.

* Remove debug

* RTCPSenderReportInfo -> RTCPSenderReportDataExt

* Get rid of sender report data pointer checks
2023-01-25 11:00:15 +05:30
Raja Subramanian
2b89c821ab An attempt to use publisher side RTCP sender report while forwarding (#1286)
* WIP commit

* comment

* clean up

* remove unused stuff

* cleaner comment

* remove unused stuff

* remove unused stuff

* more comments

* TrackSender method to handle RTCP sender report data

* fix test

* push rtcp sender report data to down tracks

* Need payload type for codec id mapping in relay protocol

* rename variable a  bit
2023-01-06 14:07:18 +05:30
Raja Subramanian
2b031a5112 Introducing frame based stream tracker. (#1267)
* Split stream tracker impl from base

* slight re-arrangement of code

* fps based stream tracker

* MinFPS config

* switch back to packet based tracker

* use video config by default to handle sources without type
2022-12-28 13:00:21 +05:30
David Zhao
7a1273151f Update to new logging library, using sampling participant logger (#1219) 2022-12-09 00:09:03 -08:00
Raja Subramanian
aba18accd9 Prevent rtx buffer and forwarding path colliding (#1174)
* Prevent rtx buffer and forwarding path colliding

Received packets are put into RTX buffer which is
a circular buffer and the packet (sequence number) is
queued for forwarding. If the RTX buffer fills up
and cycles before forwarding happens, forwarding
would pick the wrong packet (as it is holding a
reference to a byte slice in the RTX buffer) to forward.

Prevent it by moving reading from RTX buffer just
before forwarding. Adds an extra copy from RTX buffer
-> temp buffer for forwarding, but ensures that forwarding
buffer is not used by another go routine.

* Revert some changes from previous commit

Details:
- Do all forward processing as before.
- One difference is not load raw packet into ExtPacket.
- Load raw packet into provided buffer when module that reads
using ReadExtended calls that function. If the packet is
not there in the retransmission buffer, that packet will be
dropped. This is the case we are trying to fix, i. e. the RTX
buffer has cycled before ReadExtended could pull the packet.
This makes a copy into the provided buffer so that the data
does not change underneath.

* Remove debug comment

* Oops missed a function call
2022-11-19 13:19:49 +05:30
Raja Subramanian
379301c0bc A few more log tweaks (#1159) 2022-11-11 13:44:14 +05:30
cnderrauber
4783db34ef Remove DD extension when AV1 not preferred (#1129) 2022-10-27 15:51:50 +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
Raja Subramanian
794c74360b Do not log duplicate packet error. (#1116)
Also, use bucket.Err* as it has been moved to mediatransportutil
2022-10-23 09:39:50 +05:30
Raja Subramanian
792349cc56 Split out mediatransportutil (#1071) 2022-10-06 23:55:59 +05:30
cnderrauber
48588d7c3d code clean & fix h264 test fail (#1028) 2022-09-21 16:59:18 +08:00
Raja Subramanian
1e20786521 Store pure padding packets also in SnOffsets cache. (#1020) 2022-09-20 19:39:36 +05:30
Raja Subramanian
d76f7811e9 An attempt to use consistent layer mapping (#986)
* WIP commit

* Consistent layers.

* slight re-arrangement of code

* log mime

* fix tests

* map -> array
2022-09-07 09:57:31 +05:30
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