-
Notifications
You must be signed in to change notification settings - Fork 115
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
RTCRtpParameters.codec matching is probably too strict #2987
Comments
I should note that semantic matching of sdpFmtpLine would not be sufficient to fix this problem; max-fr=60 and max-fr=30 are not semantically equivalent, but we probably still want the .codec setting to work here. If we want to be able to match these, we'd basically have to specify that the browser consider it a match if the same codec/channels/clockRate/fmtp in a remote description would be considered a successful negotiation of that codec. Alternately, we could punt and say that .codec is only ever matched against RTCRtpParameters.codecs (ie; negotiated codecs with parameters from a remote description), and that setting .codec based on getCapabilities, or before negotiation, is simply not allowed. |
Fundamentally, the problem we have here is that most fmtp values are not a distinguishing feature of a codec, but in rare cases they are (eg; profile-level-id for H264). Right now, the spec treats all fmtp as distinguishing features, to make sure the tiny minority of distinguishing ones are taken into account. |
The problem is an assumption that symmetry is required, when many fmtp parameters refer to a receiver capability that need not be the same for both peers. For example, in VP8 one peer can have |
.codec must be taken (literal match) from the remote because the remote specifies the parameters it wants to receive, no? |
It depends I suppose; if JS sets VP8 with 60 fps as its preferred codec, and the other end says it wants to do H264, or VP8 with 30fps, should we say "Oh well" and just do H264? If we're going to require that level of granularity for a match, then maybe semantic matching would be sufficient (lexical still won't work, because "max-fs=12288;max-fr=60" won't match "max-fr=60;max-fs=12288", which is clearly wrong). |
But you can only take the input to Didn't we discuss this in #2888 (without conclusion)? In particular this but it is more about sCP, not setParameters. Same problem though. |
Right now the spec allows (and wpt tests for) populating .codec from the return of getCapabilities. (If we disallow this, that would solve this problem, probably. You could still in theory run into unexpected behavior if the remote side changes its fmtp without changing the semantics, I guess.) |
I'm currently working in this area (coming in from PT assignment, but "are these equal" comes in a lot there). means that A can receive vp8 at 60 fps, and B can receive vp8 at 30 fps, and they just happen to use the same PT number. |
Note the codec dictionary match algorithm only exists because codecs aren't interfaces. See #2955 (comment). It exists to differentiate codecs — i.e. these two are not the same thing, vs these two are the same thing — it does NOT speak to what codecs UAs should select in any particular situation (except where explicitly called from algorithms). Had they been interfaces, it would clear up that the only allowed API inputs are local API outputs. E.g. constructing your own dictionary based on remote information is invalid if not found locally. That said, I don't have a strong opinion on how browsers should respond when a |
Sure, but .codec is explicitly about what we should send; it will be matched against whatever is in the remote SDP. If we set .codec based on a RTCRtpSender.getCapabilities call (which the spec explicitly allows for), and the fmtp in the capabilities differs even slightly from what the remote puts in its SDP, we won't try to honor that .codec setting because it doesn't match. That's the issue here. |
I don't believe the spec says what to do here. The codec dictionary algorithm is only used to validate JS inputs AFAICT. All it says about it seems inferred here: "Optional value selecting which codec is used for this encoding's RTP stream. If absent, the user agent can chose to use any negotiated codec." IOW, there's no RTP stream "selecting codec" algorithm. The purpose seems to be to choose between "negotiated codecs", i.e. |
Well, that's a separate (and easier) bug. Right now, the wpt expects setting .codec based on getCapabilities, and then negotiating, will cause that codec to be used if it matches the remote SDP. There's no explicit prose around doing this in the spec right now, but it definitely seems to be the intent. The wpt also expects .codec to be automatically unset if the remote SDP does not contain a match (there's definitely nothing in the spec about this). Also, there's the
This strongly suggests that it is "normal" to be setting .codec based on getCapabilities, which I suppose is why we see the wpt using this pattern. |
The wording is in: https://w3c.github.io/webrtc-pc/#set-the-session-description 4.6.13.2
We can update it if it's not clear enough. |
This issue was discussed in WebRTC August 27 2024 meeting – 27 August 2024 (RTCRtpParameters.codec matching is probably too strict) |
Let's say this is one of the codecs returned by getCapabilities, and JS sets a sender's RTCRtpParameters.codec to it before negotiation.
{ mimeType: 'video/vp8', clockRate: 90000, sdpFmtpLine: 'max-fs=12288;max-fr=60' }
Then, suppose the remote side's fmtp for vp8 looks like this, because it only wants to receive 30 frames per second (instead of the default of 60):
a=fmtp:120 max-fs=12288;max-fr=30
This results in the following entry in RTCRtpParameters.codecs:
{ mimeType: 'video/vp8', clockRate: 90000, sdpFmtpLine: 'max-fs=12288;max-fr=30', payloadType: 120 }
The codec dictionary match algorithm says these do not match, despite the fact that the negotiation worked just fine for vp8. Most fmtp parameters are negotiable in this way. I get the impression that a failure to match here is not the intent.
The text was updated successfully, but these errors were encountered: