diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index fdc56327b8..5b08c9279e 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -576,12 +576,25 @@ shaka.media.DrmEngine = class { // first MIME type even if the others are supported. To work around this, // we say that Edge supports everything. // - // See: https://bit.ly/2IcEgv0 and Issue #1495 + // See https://github.com/google/shaka-player/issues/1495 for details. if (shaka.util.Platform.isEdge()) { return true; } - return this.supportedTypes_.has(contentType.toLowerCase()); + contentType = contentType.toLowerCase(); + + if (shaka.util.Platform.isTizen() && + contentType.includes('codecs="ac-3"')) { + // Some Tizen devices seem to misreport AC-3 support. This works around + // the issue, by falling back to EC-3, which seems to be supported on the + // same devices and be correctly reported in all cases we have observed. + // See https://github.com/google/shaka-player/issues/2989 for details. + const fallback = contentType.replace('ac-3', 'ec-3'); + return this.supportedTypes_.has(contentType) || + this.supportedTypes_.has(fallback); + } + + return this.supportedTypes_.has(contentType); } /** @@ -715,6 +728,16 @@ shaka.media.DrmEngine = class { const mimeType = shaka.util.MimeUtils.getFullType( stream.mimeType, stream.codecs); + let fallbackMimeType = null; + + if (stream.codecs.toLowerCase() == 'ac-3' && + shaka.util.Platform.isTizen()) { + // Some Tizen devices seem to misreport AC-3 support, but correctly + // report EC-3 support. So query EC-3 as a fallback for AC-3. + // See https://github.com/google/shaka-player/issues/2989 for details. + fallbackMimeType = shaka.util.MimeUtils.getFullType( + stream.mimeType, 'ec-3'); + } for (const info of stream.drmInfos) { const config = configs.get(info.keySystem); @@ -747,6 +770,22 @@ shaka.media.DrmEngine = class { } else { config.videoCapabilities.push(capability); } + + // This is how we work around some misbehaving platforms by adding + // synthetic capability records using a fallback MIME type. + if (fallbackMimeType) { + /** @type {MediaKeySystemMediaCapability} */ + const fallbackCapability = { + robustness: robustness || '', + contentType: fallbackMimeType, + }; + + if (stream.type == ContentType.AUDIO) { + config.audioCapabilities.push(fallbackCapability); + } else { + config.videoCapabilities.push(fallbackCapability); + } + } } // for (const info of stream.drmInfos) } // for (const stream of [audio, video]) } // for (const variant of variants)