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

fix: Reject TS content on all platforms and transmux always #6382

Merged
merged 1 commit into from
Apr 3, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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