w3c/webrtc-pc

Is it illegal to modify sdp between createOffer and setLocalDescription?

Closed this issue · 7 comments

y-i commented

I read "4.4.2 Interface Definition" and have a question about [[LastCreatedOffer]].

const offer = await pc.createOffer();
// modify sdp
await pc.setLocalDescription(offer);

Considering the behavior of the above code, according to step 5 of createOffer, the value will be set in [[LastCreatedOffer]] when createOffer is called.

If setLocalDescription is called after editing the SDP, it appears to be rejected with an InvalidModificationError because an sdp different from [[LastCreatedOffer]] is passed in step 4.2.
However, when I actually run it, all modern browsers (Chrome/Firefox/Safari) resolve it.

Am I misunderstanding something about this?
Or do all browsers violate the spec?

henbos commented

All browsers are violating the spec. Modifying SDP is not allowed.

henbos commented

Historically, features have been shipped via SDP modifications rather than APIs. The API side of things have been playing catch-up, e.g. setCodecPreferences() to allow modifying codecs that way instead of "SDP munging" or the recent API to modify header extensions to negotiating in the extension spec. So the list of reasons for SDP munging is quite small these days, but I'm not sure all holes have been plugged just yet.

henbos commented

@jan-ivar @alvestrand Should we make an official list of "holes that needs to be plugged"?

y-i commented

Thank you for explaining the detail.
In my case, I modified a SDP directly to use L16 to use Lyra codec over WebRTC.

We should add a test for this (that would fail)

Discussion how to enable codecs like L16 should now happen in #2925