w3c / webrtc-pc

WebRTC 1.0 API
https://w3c.github.io/webrtc-pc/
Other
433 stars 115 forks source link

Comparison rules for RTCRtpCodec needs clarification on how mimeType is compared #2971

Closed docfaraday closed 1 month ago

docfaraday commented 2 months ago

Recently I've found multiple wpt that are doing case-sensitive comparisons on the mimeType field. Mime-types are case insensitive (see https://datatracker.ietf.org/doc/html/rfc2045#section-5.1); this should be called out in https://w3c.github.io/webrtc-pc/#dfn-codec-dictionary-match

jan-ivar commented 1 month ago

This is a side-effect of not using interfaces to represent platform codecs https://github.com/w3c/webrtc-pc/issues/2845#issuecomment-1484992256

Following that decision, it seems we need to support JS constructing the inputs to setCodecPreferences out of whole cloth, and we'd need to support case-insensitive mimeType matching here as RFC 2045 says.

jan-ivar commented 1 month ago

WPTs that conjure up inputs to test browser tolerance need to use case-insensitive match.

WPTs that solely operate on codecs emitted by the browser itself are probably fine checking that case matches IMHO.

alvestrand commented 1 month ago

A WPT should never depend on anything that is not written in the specs. The fact that all implementations today are consistent about the case of their self-generated media types doesn't mean that a WPT can depend on that being so forever.

jan-ivar commented 1 month ago

I didn't mean WPTs relying on all browsers being consistent, only that they're self-consistent.

But sure, if @docfaraday can provide a list of the WPTs in question we can fix them to be case-insensitive.

Just seems a pity to allow some browser to return vIdEo/Vp8. I'm curious how other specs deal with this, if at all.

alvestrand commented 1 month ago

The SDP specs say that if a browser gets vIdEo/Vp8, it has to behave exactly as if it got ViDeO/vP8. It is good if we test this.

Orphis commented 1 month ago

I did notice that and added some proper comparison in a few newer tests like in https://github.com/web-platform-tests/wpt/blob/master/webrtc-extensions/RTCRtpParameters-codec.html#L28

It would be interesting to clarify which method should be used in JS. Can the mimeType also contain UTF-8 characters?

jan-ivar commented 1 month ago

RTCRtpCodec's mimeType must be:

jan-ivar commented 1 month ago

Sorry my bad we need to update the codec dictionary match. I'll do a PR.

jan-ivar commented 1 month ago

It would be interesting to clarify which method should be used in JS. Can the mimeType also contain UTF-8 characters?

This is a good question. Since we take DOMString as an input, we need to lower-case JS input in order to compare it. While we could UTF-8 encode it to bytes and use byte-lowercasing, we can probably just use ascii-lowercase.

alvestrand commented 1 month ago

note - quote from 6886 is missing two lines:

 restricted-name-chars =/ "." ; Characters before first dot always
                              ; specify a facet name
 restricted-name-chars =/ "+" ; Characters after last plus always
                              ; specify a structured syntax suffix