Commit Graph

169 Commits

Author SHA1 Message Date
Raja Subramanian
9551c52c85 Try 2 to consolidate mime type (#3407)
* Normalize mime type and add utilities.

An attempt to normalize mime type and avoid string compares remembering
to do case insensitive search.

Not the best solution. Open to ideas. But, define our own mime types
(just in case Pion changes things and Pion also does not have red mime
type defined which should be easy to add though) and tried to use it everywhere.
But, as we get a bunch of callbacks and info from Pion, needed conversion in
more places than I anticipated. And also makes it necessary to carry
that cognitive load of what comes from Pion and needing to process it
properly.

* more locations

* test

* Paul feedback

* MimeType type

* more consolidation

* Remove unused

* test

* test

* mime type as int

* use string method

* Pass error details and timeouts. (#3402)

* go mod tidy (#3408)

* Rename CHANGELOG to CHANGELOG.md (#3391)

Enables markdown features in this otherwise already markdown'ish formatted document

* Update config.go to properly process bool env vars (#3382)

Fixes issue https://github.com/livekit/livekit/issues/3381

* fix(deps): update go deps (#3341)

Generated by renovateBot

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Use a Twirp server hook to send API call details to telemetry. (#3401)

* Use a Twirp server hook to send API call details to telemetry.

* mage generate and clean up

* Add project_id

* deps

* - Redact requests
- Do not store responses
- Extract top level fields room_name, room_id, participant_identity,
  participant_id, track_id as appropriate
- Store status as int

* deps

* Update pkg/sfu/mime/mimetype.go

* Fix prefer codec test

* handle down track mime changes

---------

Co-authored-by: Denys Smirnov <dennwc@pm.me>
Co-authored-by: Philzen <Philzen@users.noreply.github.com>
Co-authored-by: Pablo Fuente Pérez <pablofuenteperez@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Paul Wells <paulwe@gmail.com>
Co-authored-by: cnderrauber <zengjie9004@gmail.com>
2025-02-10 10:44:15 +05:30
cnderrauber
aeec75edeb H265 supoort and codec regression (#3358)
* H265 supoort and codec regression

Support H265 codec.
Add optional codec regression for subscribers don't
support advanced codecs like H265, AV1, VP9.

* restart forwarder on upstream codec change

* tests

* Reneogitate new codec if client doesn't support change

* Add option to disable codec regression

---------

Co-authored-by: boks1971 <raja.gobi@tutanota.com>
2025-02-06 11:56:49 +08:00
Raja Subramanian
7c58fdf329 move unrolled mime type check for broader use (#3326)
* move unrolled mime type check for broader use

* Use in IsSvcCodec and make MimeType exported

* test

* tidy branches

* tidy

---------

Co-authored-by: Paul Wells <paulwe@gmail.com>
2025-01-13 10:24:03 +05:30
cnderrauber
384e21abc0 vp8 temporal layer selection with dependency descriptor (#3302)
* vp8 with dd

* make temporal layer selection work with DD

* fix test

---------

Co-authored-by: boks1971 <raja.gobi@tutanota.com>
2025-01-03 21:26:03 +08:00
Raja Subramanian
c8b644934f Update deque and friends. (#3276) 2024-12-20 07:16:14 +05:30
cnderrauber
54f9f7de51 upgrade to pion/webrtc v4 (#3213) 2024-11-28 16:05:38 +08:00
Raja Subramanian
ceb8a70696 Use same components when logger is updated (#3166)
Logger in buffer can get updated when the layer is known. Use the same
components used in destructor.
2024-11-11 11:38:48 +05:30
cnderrauber
ca77df8212 warn for multiple dd ext (#3135)
* warn for multiple dd ext

* unused
2024-10-24 16:59:24 +08:00
Raja Subramanian
40b10af960 Use monotonic time util. (#3112)
Thank you @paulwe for doing this. I was promising to do this for a
while, but just like other times, empty promises :-(
2024-10-17 10:49:24 +05:30
Raja Subramanian
2491ee7c7c Make lite version of RTPStatsReceiver called RTPStatsReceiverLite. (#3065)
* Make lite version of RTPStatsReceiver called RTPStatsReceiverLite.

Refactor around that.

Will probably make some more flavors to have lighter versions still.

* update deps

* use MarshalLogArray

* use util
2024-10-05 10:50:25 +05:30
Raja Subramanian
8ac33a868c Splitting out rtp stats stuff into its own package. (#3060)
* Splitting out rtp stats stuff into its own package.

Going to be making some lighter versions of these.
Will be cleaner to have all of these grouped together.
So, as a first step, just making a package for it.

* tests
2024-10-03 15:51:24 +05:30
Raja Subramanian
b678ccdd66 Cache RTCP sender report in forwarder state. (#2994)
* Cache RTCP sender report in forwarder state.

To be used in migration.

TODO: need to check more places to operate pure in unix nano rather than
converting.

* match name
2024-09-10 20:50:50 +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
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
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
d68dd3033d Use extended sequence number in bucket (#2895) 2024-07-30 14:21:37 +05:30
cnderrauber
f6f6cca133 don't push 0 ssrc probing packets to pending queue (#2888) 2024-07-23 17:58:04 +08:00
cnderrauber
0c5b5537b2 Don't create DDParser for non-svc codec (#2883) 2024-07-19 10:52:27 +08:00
Raja Subramanian
95f4b304ef Prevent data race. (#2881)
* Prevent data race.

CI is reporting some data race warnings. Prevent that.

* prevent recursive lock

* prevent more recursive locks

* more lock dance
2024-07-18 19:53:41 +05:30
Raja Subramanian
91782b68be Recalc gap of sequence number after forcing rollover. (#2880) 2024-07-18 18:58:10 +05:30
Raja Subramanian
f3d3ec1ce7 Record packet/octet count in sender report. (#2864)
Seeing cases of huge jumps in sender erport rtp time stamp
(of the order of minutes) a few hundred ms after start of track.
Only less than 20 packets have been published at that time as seen by
server. Adding these to sender report to check if client thinks it has
sent much more.
2024-07-16 07:59:27 +05:30
Raja Subramanian
acbd4ea104 Handle cases of long mute/rollover of time stamp. (#2842)
* Handle cases of long mute/rollover of time stamp.

There are cases where the track is muted for long enough for timestamp
roll over to happen. There are no packets in that window (typically
there should be black frames (for video) or silence (for audio)). But,
maybe the pause based implementation of mute is causing this.

Anyhow, use time since last packet to gauge how much roll over should
have happened and use that to update time stamp. There will be really
edge cases where this could also fail (for e. g. packet time is affected
by propagation delay, so it could theoretically happen that mute/unmute
+ packet reception could happen exactly around that rollover point and
  miscalculate, but should be rare).

As this happen per packet on receive side, changing time to `UnixNano()`
to make it more efficient to check this.

* spelling

* tests

* test util

* tests
2024-07-08 11:07:20 +05:30
Raja Subramanian
39c59d913d Do not warn on padding (#2839) 2024-07-07 12:30:54 +05:30
Raja Subramanian
bfb7db2d91 RTP packet validity check. (#2833)
Adding some checks before packet is forwarded to check for anomalies.
Will remove after a round of debug.
2024-07-04 12:42:25 +05:30
Raja Subramanian
d4e50b633f Do not log warns on duplicate. (#2807)
With RTX, some clients use very old packets for probing. Check for
duplicate before logging warning about old packet/negative sequence
number jump.

Also, double the history so that duplicate tracking is better. Adds
about 1/2 KB per RTP stream.
2024-06-20 10:52:12 +05:30
Raja Subramanian
ea60368100 Do not error out on invalid packet. (#2789)
Remove the return when encountering invalid packet.
Also, log more sparesely.
Proper error returns from util so that we can selectively drop packets
based on error type, for example SSRC mismatches are okay type of thing.
2024-06-14 11:10:57 +05:30
Raja Subramanian
129ba62d61 Validate RTP packets. (#2778)
* Validate RTP packets.

Check version, payload type (if available) and SSRC (if available)
and drop bad packets. And let repair mechanisms take effect for those
packets.

* address data race reported by test

* fix an unlock and test packets
2024-06-10 15:43:59 +05:30
Raja Subramanian
38d213ed10 Do not compare payload type before bind (#2775) 2024-06-09 01:03:38 +05:30
Raja Subramanian
b58db82254 Log invalid RTP packet (#2774) 2024-06-08 10:36:05 +05:30
cnderrauber
908baeb942 initialize bucket size by publish bitrates (#2763) 2024-06-06 14:31:20 +08:00
Raja Subramanian
03bb468472 Log range map for debugging. (#2754)
* Log range map for debugging.

* log details on errors

* log details
2024-06-04 08:00:26 +05:30
Raja Subramanian
9781d30611 Do not propagate RTCP if report is not processed. (#2739) 2024-05-28 19:29:54 +05:30
Raja Subramanian
8be2005e0f More detailed logging to understand old packets. (#2730) 2024-05-25 18:34:55 +05:30
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
Paul Wells
18b3b7b421 use readCond in buffer read (#2691) 2024-04-27 04:04:01 -07:00
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
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
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
63b1fba082 Add start/end time to AnalyticsStream. (#2618)
* Add start/end time to AnalyticsStream.

* fix test
2024-04-03 12:23:18 +05:30
cnderrauber
0a35e59ebd Replace sleep with sync.Cond to reduce jitter (#2603) 2024-03-29 17:24:31 +08:00
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
d40041d013 Use the correct snapshot id for PPS. (#2528)
* Use the correct snapshot id for PPS.

That caused connection quality to operate on small windows.

* remove debug
2024-02-29 22:48:36 +05:30
cnderrauber
a435368278 use dynamic bucket size (#2524) 2024-02-28 16:24:23 +08:00
David Colburn
098b12981f fix pli throttle locking (#2521)
* fix pli throttle locking

* UpdatePliAndTime still used in cloud
2024-02-27 20:22:38 -08:00
Raja Subramanian
f7b6e915cb Fix return on dropping a padding packet. (#2479)
Had deleted an extra line while cleaning up.
2024-02-13 14:24:31 +05:30
Raja Subramanian
0bcd9a2f8b Remove some noisy logs (#2477) 2024-02-13 12:01:20 +05:30
Raja Subramanian
89a312d259 Ignore duplicate RID. (#2471)
Firefox on Windows 10 seems to be producing simulcast tracks with
duplicate RID. That causes a leak as only one buffer is processed.

Ignore duplicate rid.

NOTE: This is not perfect as the actual layer -> rid is indeterminable
at addition time. It would require looking at packets to determine the
video dimensions and match to rid/layer to figure out which one is
correct and which one is duplicate.

To simplify though, taking the first one and dropping later ones.
This could mean the correct resolution is not streamed, but that should
be okay. The leak is far more destructive.
2024-02-12 11:49:14 +05:30
cnderrauber
af0a8fbbbc add log for extpacket accumulated (#2454) 2024-02-06 21:38:36 +08:00
cnderrauber
be87a1b6f0 Support rtx for publisher (#2452)
* Support rtx for publisher

* remote log

* solve comment
2024-02-06 21:30:37 +08:00