Skip to content

Commit

Permalink
feat: use "audio/ogg; codecs=opus" as the MIME type for OPUS audio
Browse files Browse the repository at this point in the history
Fix #1473
  • Loading branch information
rdeltour committed Jan 11, 2023
1 parent 873d4f5 commit 0759a82
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
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

0 comments on commit 0759a82

Please sign in to comment.