Skip to content

Commit

Permalink
fix: Reject TS content on all platforms and transmux always (#6382)
Browse files Browse the repository at this point in the history
Related to #6334
Related to
#6320 (comment)
Also reverts #6045
since now it is not necessary
  • Loading branch information
avelad committed Apr 3, 2024
1 parent 0d929ca commit 7e32636
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
17 changes: 6 additions & 11 deletions lib/media/media_source_engine.js
Expand Up @@ -467,10 +467,9 @@ 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, forceTransmux = false) {
initSourceBuffer_(contentType, stream, codecs) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

goog.asserts.assert(
Expand All @@ -482,7 +481,7 @@ shaka.media.MediaSourceEngine = class {
if (contentType == ContentType.TEXT) {
this.reinitText(mimeType, this.sequenceMode_, stream.external);
} else {
let needTransmux = this.config_.forceTransmux || forceTransmux;
let needTransmux = this.config_.forceTransmux;
if (!shaka.media.Capabilities.isTypeSupported(mimeType) ||
(!this.sequenceMode_ &&
shaka.util.MimeUtils.RAW_FORMATS.includes(mimeType))) {
Expand All @@ -499,10 +498,8 @@ shaka.media.MediaSourceEngine = class {
ContentType.VIDEO, (codecs || '').split(','));
if (audioCodec && videoCodec) {
this.needSplitMuxedContent_ = true;
this.initSourceBuffer_(
ContentType.AUDIO, stream, audioCodec, /* forceTransmux= */ true);
this.initSourceBuffer_(
ContentType.VIDEO, stream, videoCodec, /* forceTransmux= */ true);
this.initSourceBuffer_(ContentType.AUDIO, stream, audioCodec);
this.initSourceBuffer_(ContentType.VIDEO, stream, videoCodec);
return;
}
const transmuxerPlugin =
Expand Down Expand Up @@ -1875,8 +1872,7 @@ shaka.media.MediaSourceEngine = class {
let needTransmux = this.config_.forceTransmux;
if (!shaka.media.Capabilities.isTypeSupported(newMimeType) ||
(!this.sequenceMode_ &&
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType)) ||
codecs.includes(',')) {
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType))) {
needTransmux = true;
}
const TransmuxerEngine = shaka.transmuxer.TransmuxerEngine;
Expand Down Expand Up @@ -1957,8 +1953,7 @@ shaka.media.MediaSourceEngine = class {
let needTransmux = this.config_.forceTransmux;
if (!shaka.media.Capabilities.isTypeSupported(newMimeType) ||
(!this.sequenceMode_ &&
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType)) ||
stream.codecs.includes(',')) {
shaka.util.MimeUtils.RAW_FORMATS.includes(newMimeType))) {
needTransmux = true;
}
const newMimeTypeWithAllCodecs =
Expand Down
19 changes: 8 additions & 11 deletions lib/polyfill/mediasource.js
Expand Up @@ -32,12 +32,6 @@ shaka.polyfill.MediaSource = class {

if (!window.MediaSource && !window.ManagedMediaSource) {
shaka.log.info('No MSE implementation available.');
} else if (shaka.util.Platform.isChromecast()) {
shaka.log.info('Patching Chromecast MSE bugs.');
// Chromecast fails on some TS content, even though it is supposed to
// support it. Better to transmux.
// See https://github.com/shaka-project/shaka-player/issues/5278
shaka.polyfill.MediaSource.rejectContainer_('mp2t');
} else if (safariVersion) {
// NOTE: shaka.Player.isBrowserSupported() has its own restrictions on
// Safari version.
Expand Down Expand Up @@ -73,11 +67,6 @@ shaka.polyfill.MediaSource = class {
// Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
shaka.polyfill.MediaSource.stubAbort_();
}
} else if (shaka.util.Platform.isEdge()) {
shaka.log.info('Rejecting TS container.');
// TS content is broken on Edge in general.
// See https://github.com/shaka-project/shaka-player/issues/4955
shaka.polyfill.MediaSource.rejectContainer_('mp2t');
} else if (shaka.util.Platform.isTizen2() ||
shaka.util.Platform.isTizen3() ||
shaka.util.Platform.isTizen4()) {
Expand All @@ -90,6 +79,14 @@ shaka.polyfill.MediaSource = class {
shaka.log.info('Using native MSE as-is.');
}

if (window.MediaSource || window.ManagedMediaSource) {
// TS content is broken on all browsers in general.
// See https://github.com/shaka-project/shaka-player/issues/4955
// See https://github.com/shaka-project/shaka-player/issues/5278
// See https://github.com/shaka-project/shaka-player/issues/6334
shaka.polyfill.MediaSource.rejectContainer_('mp2t');
}

if (window.MediaSource &&
MediaSource.isTypeSupported('video/webm; codecs="vp9"') &&
!MediaSource.isTypeSupported('video/webm; codecs="vp09.00.10.08"')) {
Expand Down

0 comments on commit 7e32636

Please sign in to comment.