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

feat: use "audio/ogg; codecs=opus" as the MIME type for OPUS audio #1474

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public static boolean isAudioType(String type)

public static boolean isBlessedAudioType(String type)
{
return type.equals("audio/mpeg") || type.equals("audio/mp4") || type.equals("audio/opus");
return type.equals("audio/mpeg") || type.equals("audio/mp4") || type.matches("audio/ogg\\s*;\\s*codecs=opus");
}

public static boolean isVideoType(String type)
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,14 @@ protected String checkMimetypeMatches(URL resource, String mimetype)
// remove any params from the given MIME type string
mimetype = MIMEType.removeParams(mimetype);

// hack: remove the codecs parameter in the resource type for OPUS audio
// so that the equality check works
// TODO remove this when we implement proper MIME type parsing
if (resourceMimetype != null && resourceMimetype.matches("audio/ogg\\s*;\\s*codecs=opus"))
{
resourceMimetype = "audio/ogg";
}

// report any MIME type mismatch as a warning
if (resourceMimetype != null && !resourceMimetype.equals(mimetype))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
<audio src="audio.opus" />
<audio>
<source src="audio.opus" type="audio/ogg; codecs=opus"/>
</audio>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="audio" href="audio.opus" media-type="audio/opus"/>
<item id="audio" href="audio.opus" media-type="audio/ogg ; codecs=opus"/>
</manifest>
<spine>
<itemref idref="content_001" />
Expand Down