Skip to content

Commit

Permalink
fix(Tizen): Work around misreported AC-3 support on Tizen
Browse files Browse the repository at this point in the history
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.

Closes #2989

Change-Id: I80f20ba796df29858728b19f8a9f6c1712c9556d
  • Loading branch information
joeyparrish committed Nov 14, 2020
1 parent 0bd4c69 commit ba4763a
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ba4763a

Please sign in to comment.