Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing RTX codec when using SetCodecPreferences #3051

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stephanrotolante
Copy link
Contributor

@stephanrotolante stephanrotolante commented Mar 4, 2025

Description

When you specify the codecs that you want to use, we need to add the RTX codec related to the specified codecs

Reference issue

Fixes #2996

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.60%. Comparing base (e4ff415) to head (2d892b5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3051      +/-   ##
==========================================
+ Coverage   78.38%   78.60%   +0.22%     
==========================================
  Files          91       91              
  Lines       11300    11313      +13     
==========================================
+ Hits         8857     8893      +36     
+ Misses       1950     1932      -18     
+ Partials      493      488       -5     
Flag Coverage Δ
go 80.50% <100.00%> (+0.24%) ⬆️
wasm 63.61% <0.00%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stephanrotolante
Copy link
Contributor Author

broken test cases.... I am looking into that

@stephanrotolante stephanrotolante force-pushed the fix/missing_rtx_codec branch 4 times, most recently from 5768cbd to f7cc6af Compare March 5, 2025 04:27
@stephanrotolante stephanrotolante force-pushed the fix/missing_rtx_codec branch 5 times, most recently from b4dfd98 to 9322dc1 Compare March 5, 2025 18:23
@JoeTurki JoeTurki added this to the V4.1.0 milestone Mar 5, 2025
rtpcodec.go Outdated
// Given a RTPCodecParameters check if it exists in a list of other RTPCodecParameters.
func doesCodecExistInList(codec RTPCodecParameters, codecList []RTPCodecParameters) bool {
for _, c := range codecList {
if codec.SDPFmtpLine == c.SDPFmtpLine && codec.MimeType == c.MimeType {
Copy link
Member

@JoeTurki JoeTurki Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We match codecs with different rate or channels now, I know RTX is never used for audio, but can we use the fmtp helpers that Alessandro's made in his PR instead, for the sake of behavioral consistency (Like we use strings.EqualFold there to match the MimeType), so one behavior and less code to test?

func (g *genericFMTP) Match(b FMTP) bool {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, let me see what I can do

Copy link
Contributor Author

@stephanrotolante stephanrotolante Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that I reviewed the code, I wonder if I should just use codecParametersFuzzySearch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if you can use codecParametersFuzzySearch that would be better!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@stephanrotolante stephanrotolante force-pushed the fix/missing_rtx_codec branch 2 times, most recently from f269ded to 1385481 Compare March 6, 2025 00:43
@itzmanish
Copy link
Contributor

Hi, Please correct me if my understanding of the issue is wrong.

This PR fixes the scenario where someone sets CodecPreferences with one codec, and it disables the RTX for that codec. Right?

According to MDN, the parameter for setCodecPreferences is a list of codecs. Pion's API is the same as well. So my question is, why should pion try to find the RTX codec from mediaengine instead of the user providing the list of codecs with the RTX codec in setCodecPreferences?

@stephanrotolante
Copy link
Contributor Author

@itzmanish that is a great question and I thought about that as well while making this PR

If we want the RTX codec when using setCodecPreferences, why not just specify it?

why should pion try to find the RTX codec from mediaengine instead of the user providing the list of codecs with the RTX codec > in setCodecPreferences?

I guess you could say this is a pion specific feature, that will handle this for you.....

Maybe I should ask the author of the issue why they cannot just pass in the RTX codec 🤔

@JoeTurki
Copy link
Member

JoeTurki commented Mar 6, 2025

@jech what is your thoughts on @itzmanish comment?

@jech
Copy link
Member

jech commented Mar 6, 2025

Sure, no problem. However, since that would be a divergence from the JavaScript API, it would need to be clearly documented.

If you choose to do that, please add a test to make sure that a codec with an associated RTX track can be specified, since I'm afraid that's code that might rot and since things will still sort of work if the RTX track is incorrect, we might not notice that it's broken.

@stephanrotolante
Copy link
Contributor Author

stephanrotolante commented Mar 7, 2025

@JoeTurki @itzmanish

What do you think? Should we stay aligned with the javascript api or do our own thing??

I am thinking we stay aligned

@jech
Copy link
Member

jech commented Mar 8, 2025

Should we stay aligned with the javascript api or do our own thing?

The JavaScript API is fairly high level. Pion is useful for low-level software, such as SFUs, so it might make sense to give more control to the programmer. But perhaps it's not worth the extra complexity in this particular case.

In other words, I have no clue.

@itzmanish
Copy link
Contributor

Pion is useful for low-level software, such as SFUs, so it might make sense to give more control to the programmer. But perhaps it's not worth the extra complexity in this particular case.

This ^

In my view, the reward for introducing extra complexity and logic is unfulfilling. The more pion/webrtc operates behind the scene logic, the more unpredictable the API will be, and it will be more challenging for users using the library.

@JoeTurki
Copy link
Member

JoeTurki commented Mar 8, 2025

I too think we should stay aligned!

@jech
Copy link
Member

jech commented Mar 8, 2025

It's a little bit more complicated than that.

When using SetCodecPreferences in Pion, we set the ptype, and in particular we can set a ptype that is not defined in the mediaengine. If we do that, there is no way for Pion to choose the right ptype for the RTX track.

This is not the case in the JavaScript case, where we do not set the ptype. See here: https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/setCodecPreferences

So the API is already not aligned with the JavaScript case, and not being explicit will cause the API to fail for mysterious reasons.

@stephanrotolante
Copy link
Contributor Author

@Sean-Der Do you have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Using SetCodecPrefences to constrain the track type disables negotiation of RTX
4 participants