18 Commits

Author SHA1 Message Date
boks1971
2af60a491d Filter unattached RTX when getting codecs
Recently added filtering out unattached RTX in SetCodecPrefrences.
Turns out it is needed in `getCodecs()` also in the following
scenario
- AddTrack from answer side adds a tracks and has media engine codecs
- An offer is received and negotiated codecs get updated in
  media engine. And this does not have one of the codecs added
  AddTrack above (default media engine codecs)
- Generate answer will do `getCodecs` which will filter out
  the codec missing from the `offer`, but would have let the
  corresponding RTX pass through and get added to the answer.
2025-08-27 01:34:35 +05:30
boks1971
c82d96cb75 Remove RTX codec if no primary
While adding transceivers from SetRemoteDescription,
the filtered codecs could filter out the primart codec
and leave the RTX codec in. Generating an answer with
that fails `SetRemoteDescription` on remote peer due
to an unrecognisable codec. Fix it by filtering out
RTX is primary is not there.
2025-08-22 23:46:49 +05:30
Jingyang Kang
334692b122 Add findFECPayloadType (#3084)
#### Description

Before this, any interceptor that tries to read FEC payload type from
`info *interceptor.StreamInfo`, always gets 0. This PR implements the
logic to find FEC payload type.

Also, MimeType consts are moved from mediaengine.go to mimetype.go,
since mediaengine.go is not included in the WASM build.
2025-04-07 20:29:51 +08:00
Alessandro Ros
969ab684e3 Fix matching codecs with different rate or channels
Currently codecs are matched regardless of the clock
rate and the channel count, and this makes impossible to fully support
codecs that might have a clock rate or channel count different than the
default one, in particular LPCM, PCMU, PCMA and multiopus (the last one
is a custom Opus variant present in the Chrome source code to support
multichannel Opus).

For instance, let's suppose a peer (receiver) wants to receive an audio
track encoded with LPCM, 48khz sample rate and 2 channels. This receiver
doesn't know the audio codec yet, therefore it advertises all supported
sample rates in the SDP:

```
LPCM/44100
LPCM/48000
LPCM/44100/2
LPCM/48000/2
```

The other peer (sender) receives the SDP, but since the clock rate and
channel count are not taken into consideration when matching codecs, the
sender codec `LPCM/48000/2` is wrongly associated with the receiver
codec `LPCM/44100`. The result is that the audio track cannot be decoded
correctly from the receiver side.

This patch fixes the issue and has been running smoothly in MediaMTX for
almost a year.

Unfortunately, in lots of examples and tests, clock rate and/or channels
are not present (and in fact they are producing horrible SDPs that
contain `VP8/0` instead of `VP8/90000` and are incompatible with lots of
servers) therefore this new check causes troubles in existing code. In
order to maintain compatibility, default clock rates and channels are
provided for most codecs.

In the future, it might be better to update examples (i can do it in a
future patch) and remove the exception.
2025-02-15 21:16:47 -05:00
Joe Turki
feeeebf251 Upgrade golangci-lint, more linters
Introduces new linters, upgrade golangci-lint to version (v1.63.4)
2025-01-18 07:16:06 -06:00
Sean DuBois
cbe660b713 Use intersection of codecs to generate rtcp-fb
Update MediaEngine codec creation to take into account remote
and local rtcp-fb. Before we would incorrectly always take
the remote rtcp-fb and ignore local.

Resolves #2943
Resolves #2944
Resolves #1968
2024-12-14 19:32:20 -05:00
Sean DuBois
32f7063f1a Send FEC and RTX PayloadType into interceptor
New fields added to interceptor.StreamInfo
2024-10-04 21:33:10 -04:00
Sean DuBois
4541b73b1a Add Retransmission and FEC to TrackLocal
If the MediaEngine contains support for them a SSRC will be generated
appropriately

Co-authored-by: aggresss <aggresss@163.com>
Co-authored-by: Kevin Wang <kevmo314@gmail.com>

Resolves #1989
Resolves #1675
2024-10-03 20:44:49 -07:00
Woodrow Douglass
13450332a4 Remove the "Unknown" constant
This commit replaces the Unknown constant with
separate constants for each enumeration that
uses it.

Fixes #1293
2023-09-12 13:29:05 -04:00
cnderrauber
2225386c41 Generate answer to match group bundle in offer
Generate answer to match group bundle in offer
2023-09-08 09:30:52 -07:00
Sean DuBois
dc4b591c4d Start pion/webrtc/v4
60eea43 is a breaking change
2023-09-05 11:48:14 -04:00
Steffen Vogel
683fc837d0 Make repo REUSE compliant 2023-05-05 11:58:49 -04:00
Ryan Shumate
2d529be571 Improved h264 fmtp line parsing
Implements h264 fmtp parsing based on RFC 6184 Section 8.2.2
2021-07-30 13:23:07 -04:00
Atsushi Watanabe
07d7403cca Parse and compare FmtpLine on codec select
Exact match if fmtp parameters are not inconsistent.

e.g. default OPUS fmtp of the browsers are:
  Chrome:  minptime=10;useinbandfec=1
  Firefox: maxplaybackrate=48000;stereo=1;useinbandfec=1
They should be treated as matched.
2021-03-21 13:41:33 +09:00
David Zhao
e5c8c659ca Improve MediaEngine codec matching
Implement more sophisticated matching to prefer exact
matches over partial ones.
2021-03-04 09:08:59 -08:00
Sean DuBois
3d9a7ede1a Allow extensions to be configured with direction
RegisterHeaderExtension now allows users to enable headers depending on
the type of transceiver that was created.

Also expose GetParameters on RTPSender and RTPReceiver

Co-authored-by: OrlandoCo <luisorlando.co@gmail.com>

Resolves #1554
2020-12-04 11:52:48 -08:00
Adam Kiss
5bbc84e404 Implement Interceptors
Provide API so that handling around RTP can be easily defined by the
user. See the design doc here[0]

[0] https://github.com/pion/webrtc-v3-design/issues/34
2020-11-26 11:23:19 -08:00
Sean DuBois
7edfb701e0 New Track API
The Pion WebRTC API has been dramatically redesigned. The design docs
are located here [0]

You can also read the release notes [1] on how to migrate your
application.

[0] https://github.com/pion/webrtc-v3-design
[1] https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0
2020-11-15 09:20:47 -08:00