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

Add a way to sniff for HLS playlist files (m3u8) #125

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

Conversation

padenot
Copy link
Collaborator

@padenot padenot commented Jul 29, 2020

This seems to be mostly mobile-only, because m3u8 are only played on mobile. Chrome, Firefox and Safari can play those files on mobile. Chrome and Safari don't require a particular Content-Type.

Firefox requires the right mime type to be sent because it didn't have a way to sniff for those files, but this is changing, and it's best to normalize how to sniff.

Safari can additionally play those files on desktop, regardless of the Content-Type sent by the server.

  • At least two implementers are interested (and none opposed):
    • Firefox plays it
    • Chrome plays it
    • Safari plays it
  • Tests are written and can be reviewed and commented upon at:
    • I didn't find a test infrastructure with test vectors, and I don't know of a way to check the content type sniffed by an HTMLMediaElement. I suppose we can try to load the resource with a web server that forces application/octet-stream or the like, but that requires a server-side component.
  • Implementation bugs are filed:

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

@domenic
Copy link
Member

domenic commented Jul 29, 2020

Awesome! Can you become a member of https://github.com/mozilla-standards/, or publicize your membership?

As for tests, historically we don't have many/any for the MIME sniffing algorithms, but I think it'd be worth adding some if it's not impossible. Web platform tests definitely supports the appropriate server infrastructure; you can set arbitrary headers.

@padenot
Copy link
Collaborator Author

padenot commented Jul 31, 2020

Awesome! Can you become a member of https://github.com/mozilla-standards/, or publicize your membership?

Yes, thanks, Anne had invited me but my membership was private.

As for tests, historically we don't have many/any for the MIME sniffing algorithms, but I think it'd be worth adding some if it's not impossible. Web platform tests definitely supports the appropriate server infrastructure; you can set arbitrary headers.

This is tracked by https://bugzilla.mozilla.org/show_bug.cgi?id=1656495. We have tests for most of this in Gecko, I need to see if it would be possible to convert to wpt (it's using internal gecko things to hook into the sniffers themselves, but the test vectors are nice).

Base automatically changed from master to main January 15, 2021 07:47
@GPHemsley
Copy link
Member

@padenot Are you sure that Chromium is sniffing this? I'm not seeing it in their sniffing code:
https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/mime_sniffer.cc
https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/mime_sniffer_unittest.cc

Though, as you well know, Firefox is:
https://hg.mozilla.org/mozilla-central/rev/0bed87941dc5
https://hg.mozilla.org/mozilla-central/file/default/toolkit/components/mediasniffer/nsMediaSniffer.cpp

(As I mentioned in #150, support for a format does not necessarily imply that sniffing is also being done.)

mimesniff.bs Outdated Show resolved Hide resolved
mimesniff.bs Outdated Show resolved Hide resolved
@padenot
Copy link
Collaborator Author

padenot commented Aug 31, 2021

Looks like Chrome and Safari (at least desktop) don't sniff it indeed [0], curiously. It's however mandatory to implement HTMLMediaElement (the Content-Type is to be ignored), so there should be steps to sniff here.

[0]: I tested serving a HLS playlist file with application/octet-stream and no extension as the src attribute of an HTMLMediaElement, and seeing what implementations do. Firefox plays it, Safari and Chrome don't.

@GPHemsley
Copy link
Member

It's however mandatory to implement HTMLMediaElement (the Content-Type is to be ignored), so there should be steps to sniff here.

I'm not seeing anything in Media elements that indicates that sniffing is mandatory, though I am seeing lots of conflicting and underspecified things. I'm guessing the connections between HTML and mimesniff need to be made more robust.

In the meantime, can you point to where you're interpreting as indicating sniffing is mandatory?

@annevk
Copy link
Member

annevk commented Sep 3, 2021

Yeah, I think Chrome and Safari do require a MIME type for this. See whatwg/html#6468 for the corresponding HTML issue.

I guess that means we should adjust Firefox and close this PR?

@GPHemsley
Copy link
Member

I have confirmed that Chrome identifies this as text/plain.

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.

4 participants