Skip to content

Commit

Permalink
fix(HLS): Fix playback of muxed TS content in Safari (#6045)
Browse files Browse the repository at this point in the history
Fixes #6032
  • Loading branch information
avelad committed Jan 9, 2024
1 parent a8bbbce commit 1b675cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/hls/hls_parser.js
Expand Up @@ -2237,7 +2237,7 @@ shaka.hls.HlsParser = class {
stream.keyIds = realStream.keyIds;
stream.mimeType = realStream.mimeType;
stream.bandwidth = realStream.bandwidth;
stream.codecs = realStream.codecs || stream.codecs;
stream.codecs = stream.codecs || realStream.codecs;

// Since we lazy-loaded this content, the player may need to create new
// sessions for the DRM info in this stream.
Expand Down
17 changes: 11 additions & 6 deletions lib/media/media_source_engine.js
Expand Up @@ -460,9 +460,10 @@ shaka.media.MediaSourceEngine = class {
* @param {shaka.util.ManifestParserUtils.ContentType} contentType
* @param {shaka.extern.Stream} stream
* @param {string} codecs
* @param {boolean=} forceTransmux
* @private
*/
initSourceBuffer_(contentType, stream, codecs) {
initSourceBuffer_(contentType, stream, codecs, forceTransmux = false) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

goog.asserts.assert(
Expand All @@ -474,7 +475,7 @@ shaka.media.MediaSourceEngine = class {
if (contentType == ContentType.TEXT) {
this.reinitText(mimeType, this.sequenceMode_, stream.external);
} else {
let needTransmux = this.config_.forceTransmux;
let needTransmux = this.config_.forceTransmux || forceTransmux;
if (!shaka.media.Capabilities.isTypeSupported(mimeType) ||
(!this.sequenceMode_ &&
shaka.util.MimeUtils.RAW_FORMATS.includes(mimeType))) {
Expand All @@ -491,8 +492,10 @@ shaka.media.MediaSourceEngine = class {
ContentType.VIDEO, (codecs || '').split(','));
if (audioCodec && videoCodec) {
this.needSplitMuxedContent_ = true;
this.initSourceBuffer_(ContentType.AUDIO, stream, audioCodec);
this.initSourceBuffer_(ContentType.VIDEO, stream, videoCodec);
this.initSourceBuffer_(
ContentType.AUDIO, stream, audioCodec, /* forceTransmux= */ true);
this.initSourceBuffer_(
ContentType.VIDEO, stream, videoCodec, /* forceTransmux= */ true);
return;
}
const transmuxerPlugin =
Expand Down Expand Up @@ -1854,7 +1857,8 @@ shaka.media.MediaSourceEngine = class {
let needTransmux = this.config_.forceTransmux;
if (!shaka.media.Capabilities.isTypeSupported(newMimeType) ||
(!this.sequenceMode_ &&
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType))) {
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType)) ||
codecs.includes(',')) {
needTransmux = true;
}
const TransmuxerEngine = shaka.transmuxer.TransmuxerEngine;
Expand Down Expand Up @@ -1935,7 +1939,8 @@ shaka.media.MediaSourceEngine = class {
let needTransmux = this.config_.forceTransmux;
if (!shaka.media.Capabilities.isTypeSupported(newMimeType) ||
(!this.sequenceMode_ &&
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType))) {
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType)) ||
stream.codecs.includes(',')) {
needTransmux = true;
}
const newMimeTypeWithAllCodecs =
Expand Down

0 comments on commit 1b675cb

Please sign in to comment.