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

Fixup MIME usage #222

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open

Fixup MIME usage #222

wants to merge 31 commits into from

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented Jul 4, 2024

Closes #69

this is a draft... it doesn't actually address all the issues with MIME usage yet... just a start.


Preview | Diff

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@chrisn chrisn force-pushed the mime branch 2 times, most recently from 305ab3d to b7f3138 Compare July 18, 2024 11:01
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@chrisn
Copy link
Member

chrisn commented Aug 9, 2024

This PR replaces valid media MIME type with algorithmic steps. It could lead to similar changes to valid video configuration all the way up to valid MediaConfiguration. Please comment if you see any issues with the direction this is taking.

@aboba One specific question, as we develop this PR: section 2.1.4.2 RTP currently references RFC4855 and RFC6838, which define registration requirements. This PR proposes changing these to reference https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml instead. Is this OK?

@chrisn chrisn changed the title WIP: Fixup MIME usage Fixup MIME usage Aug 13, 2024
@chrisn
Copy link
Member

chrisn commented Aug 13, 2024

This is ready for review. PTAL @mfoltzgoogle, @aboba, @alastor0325, @marcoscaceres

The PR makes two main changes:

  • Replace "valid media MIME type"
  • Changes other algorithms to use the abstract-op dfn type

If needed we can tackle "valid video configuration" etc in follow-up PRs.

@markafoltz
Copy link
Contributor

LGTM with one side comment, nice PR @marcoscaceres

I just did a first read of the spec and wondered if a long term possibility is to decouple from mime types along the lines of the WebCodecs registry. However, the registry is missing a bunch of codecs though that may never be supported in WebCodecs, and container parsing support seems to be out of scope for WebCodecs as well.

@chrisn
Copy link
Member

chrisn commented Aug 20, 2024

There's a similar discussion in this EME issue: w3c/encrypted-media#559. I think a registry could help, but also recognise Joey's concerns in w3c/encrypted-media#559 (comment). This might be one to talk about at TPAC.

@chrisn chrisn added this to the V1 milestone Sep 13, 2024
@chrisn chrisn added the TPAC2024 Topic for discussion at TPAC 2024 label Sep 13, 2024
@markafoltz
Copy link
Contributor

@adoba, bumping the question above in #222 (comment):

One specific question, as we develop this PR: section 2.1.4.2 RTP currently references RFC4855 and RFC6838, which define registration requirements. This PR proposes changing these to reference https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml instead. Is this OK?

index.bs Outdated Show resolved Hide resolved
@markafoltz
Copy link
Contributor

@chrisn per https://www.w3.org/2024/09/26-mediawg-minutes.html#a01:

ACTION: cpn to update the Media Capabilities PR to refer to the main MIME type registry

After that is done, this should be ready to merge.

@chrisn
Copy link
Member

chrisn commented Oct 8, 2024

I've added the link to the IANA media type registry, as well as bringing back the references to the RTP specific RFCs.

@chrisn
Copy link
Member

chrisn commented Oct 8, 2024

@markafoltz I have removed the RFC4855 reference as we discussed in today's meeting (minutes). The PR is ready for your review. Many thanks.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated
and {{MediaEncodingType}} or {{MediaDecodingType}} |encodingOrDecodingType|.
</li>
<li>
If |result| is <code>failure</code> or <code>unsupported</code>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Two problems here?

  1. The Check MIME Type Support steps don't return unsupported, but see my proposed change below to fix the steps.

  2. If the result is unsupported, IIUC, we shouldn't reject the configuration as invalid. We should pass through the result to Create a MediaCapabilitiesDecodingInfo to set the supported property of the MediaCapabilitiesDecodingInfo return value.

Copy link
Member

Choose a reason for hiding this comment

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

You're right ... we should only reject if parsing the MIME type fails or the type something other than video or application. I can try to adjust the algorithms.

Copy link
Member

Choose a reason for hiding this comment

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

The difficulty I see is that we currently call Check MIME Type Support from valid video configuration and valid audio configuration (via valid MediaDecodingConfiguration and valid MediaConfiguration) but we need to use the result from Check MIME Type Support in Create a MediaCapabilitiesDecodingInfo.

What I'd like to propose is we write a complete set of algorithm steps for decodingInfo() and in doing so remove the valid MediaDecodingConfiguration, valid MediaConfiguration, valid audio configuration, valid video configuration, etc. concepts (and similar for encodingInfo()).

This would make this PR a much bigger rewrite, but I think it would takes us in the right direction. The alternative would be to keep valid video configuration etc but then we'd need to split Check MIME Type Support into two algorithms: one to check basic validity (does it parse, is its type audio, video or application, etc), the other to check for UA support.

Or am I missing an easier way to solve this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we take Check MIME Type Support out of the valid video configuration steps and instead call it in the Create a MediaCapabilitiesDecodingInfo algorithms? (Similar for audio, encoding, etc.)

It would be okay to reject early with a TypeError because the input is invalid (i.e. correct properties not set) and later also reject with a TypeError because the contentType could not be parsed.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the delay, I'm looking into this...

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I don't see any reason why it's not valid. Internal slots are intended to be part of the implementation and not visible to user scripts. I could call in a webidl expert if we need to.
  2. I will defer to @xhwang-chromium and EME experts to handle that :)
  3. I would need to talk to folks more directly involved with the implementation, but from what I can tell, Chrome checks the two values independently. If we really needed to we could amend the steps to be something like:

If audioMimeSupport is supported, videoMimeSupport is supported, and the user agent can decode the media represented by configuration, set supported to true and false otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also in "valid video configuration" I don't think we now have enough checks. To be consistent with the logic before this PR, it would have to check for video or application type and the parameters.

Yes, it looks like the checks in 2.1.4. MIME types got dropped.

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed a commit with most of my suggested changes, feel free to comment/amend as you like.

I wasn't able to resolve this issue though, because the steps in Check MIME Type Support need to be updated. They can't return failure because the steps that call it don't expect that result; with the current PR, failure would result in a supported return value.

And its not clear to me yet whether the checks in 2.1.4.1 and 2.1.4.2 (in the current spec) belong in Check MIME Type Support (and take the unsupported path) or check for valid {video,audio} configuration (and take the failure path). Might have to check the WPTs to see what implementations do.

Copy link
Contributor

Choose a reason for hiding this comment

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

The checks for audio, video, application etc. and a "single codec" all take the failure path in WPTs.

https://github.com/web-platform-tests/wpt/blob/f54cd920024da0857fdc5b036f16a7d1fd8792fd/media-capabilities/decodingInfo.any.js#L124

I found one WPT case that checks whether a valid mime type is also valid for WebRTC, and it takes the unsupported path:

https://github.com/web-platform-tests/wpt/blob/f54cd920024da0857fdc5b036f16a7d1fd8792fd/media-capabilities/decodingInfo-webrtc.any.js#L137

Copy link
Member

Choose a reason for hiding this comment

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

I'm doing some tests, and finding some inconsistencies with the "imply a codec" checks:

  • Chrome rejects if there are parameters other than codecs, Firefox resolves. The spec requires implementations to reject
  • Chrome resolves on audio/webm for audio contentType, Firefox rejects. A codecs parameter should be required
  • Chrome resolves on video/webm for video contentType, Firefox rejects. A codecs parameter should be required

I also found a difference in parsing behaviour:

  • Chrome rejects on audio/mpeg; (note the semicolon), Firefox resolves

index.bs Outdated Show resolved Hide resolved
chrisn and others added 3 commits October 9, 2024 19:59
This adds an internal slot to |AudioConfiguration|
and |VideoConfiguration| to store the parsed MIME type
Copy link
Contributor

@markafoltz markafoltz left a comment

Choose a reason for hiding this comment

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

This looks good, with a couple of spots I noted where steps could be simplified or the order changed to be more logical. Nothing that blocks merging IMO.

index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated
<code>false</code> and abort these steps.
</li>
<li>
Create an internal slot on |configuration|, \[[mimeType]], and set
Copy link
Member Author

@marcoscaceres marcoscaceres Nov 7, 2024

Choose a reason for hiding this comment

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

As above... at the same time, this duplicates the other algorithm... can we merge these two algorithms and switch on the media type?

Copy link
Contributor

Choose a reason for hiding this comment

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

The validation steps for audio and video configurations are slightly different so I don't see a way to merge them completely.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
</li>
<li>
If the combined <code>type</code> and <code>subtype</code> members
of |mimeType| imply a single media codec:
Copy link
Member

Choose a reason for hiding this comment

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

"imply a single media codec" is vague. Making it more precise would involve listing the specific MIME types where a codecs parameter isn't also needed. Related: #235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TPAC2024 Topic for discussion at TPAC 2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use mimesniff's "parse a MIME type" to parse the contentType member
6 participants