Skip to content

Commit

Permalink
fix: Fix audio mime type in multiplexed HLS stream (shaka-project#4241)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyanmisaka authored May 23, 2022
1 parent 60af9ad commit 4e4e92e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/util/mime_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ goog.provide('shaka.util.MimeUtils');

goog.require('shaka.dependencies');
goog.require('shaka.media.Transmuxer');
goog.require('shaka.util.ManifestParserUtils');

/**
* @summary A set of utility functions for dealing with MIME types.
Expand All @@ -34,6 +35,8 @@ shaka.util.MimeUtils = class {
/**
* Takes a MIME type and a codecs string and produces the full MIME
* type. If it's a transport stream, convert its codecs to MP4 codecs.
* Otherwise for multiplexed content, convert the video MIME types to
* their audio equivalents if the content type is audio.
*
* @param {string} mimeType
* @param {string} codecs
Expand All @@ -42,13 +45,19 @@ shaka.util.MimeUtils = class {
*/
static getFullOrConvertedType(mimeType, codecs, contentType) {
const fullMimeType = shaka.util.MimeUtils.getFullType(mimeType, codecs);
const ContentType = shaka.util.ManifestParserUtils.ContentType;

if (!shaka.dependencies.muxjs() ||
!shaka.media.Transmuxer.isTsContainer(fullMimeType)) {
return fullMimeType;
if (shaka.media.Transmuxer.isTsContainer(fullMimeType)) {
if (shaka.dependencies.muxjs()) {
return shaka.media.Transmuxer.convertTsCodecs(
contentType, fullMimeType);
}
} else if (contentType == ContentType.AUDIO) {
// video/mp2t is the correct mime type for TS audio, so only replace the
// word "video" with "audio" for non-TS audio content.
return fullMimeType.replace('video', 'audio');
}

return shaka.media.Transmuxer.convertTsCodecs(contentType, fullMimeType);
return fullMimeType;
}


Expand Down

0 comments on commit 4e4e92e

Please sign in to comment.