Skip to content

Commit

Permalink
fix(MCap): Fix the default DRM session type w/ MCap
Browse files Browse the repository at this point in the history
When there is no session type specified by a manifest parser or the
app's DRM config, we select a session type based on context (offline
or streaming).

In the EME branches of DrmEngine, we select the ultimate session type
in the engine's DrmInfo based on the configuration that was sent to
EME.  This, in turn, influences what kinds of sessions we create
later.

However, in the MediaCapabilities branch of DrmEngine, we were
defaulting to 'temporary' sessions in the engine's DrmInfo, without
regard to the input config or the load context.

This fixes the default so that it mirrors the input config to MCap.
That MCap config is not accessible at that time, so we just re-derive
the same value based on a boolean stored in DrmEngine.

In cases where there is a session type from the manifest parser (rare)
or the app's DRM config (more common), that will be preferred
regardless of context.

Change-Id: I1f408c04eff9a3006d2eddfaf748f7ab2c93cf9b
  • Loading branch information
joeyparrish committed Apr 28, 2021
1 parent aeee66d commit 6047fad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/media/drm_engine.js
Expand Up @@ -907,7 +907,7 @@ shaka.media.DrmEngine = class {
'We should get at least one supported MIME type');

if (useMediaCapabilities) {
this.currentDrmInfo_ = shaka.media.DrmEngine.createDrmInfoByInfos_(
this.currentDrmInfo_ = this.createDrmInfoByInfos_(
mediaKeySystemAccess.keySystem,
drmInfosByKeySystem.get(mediaKeySystemAccess.keySystem));
} else {
Expand Down Expand Up @@ -1993,7 +1993,7 @@ shaka.media.DrmEngine = class {
*
* @private
*/
static createDrmInfoByInfos_(keySystem, drmInfos) {
createDrmInfoByInfos_(keySystem, drmInfos) {
/** @type {!Array.<string>} */
const licenseServers = [];

Expand All @@ -2019,13 +2019,16 @@ shaka.media.DrmEngine = class {
'Only the first will be used.');
}

const defaultSessionType =
this.usePersistentLicenses_ ? 'persistent-license' : 'temporary';

/** @type {shaka.extern.DrmInfo} */
const res = {
keySystem,
licenseServerUri: licenseServers[0],
distinctiveIdentifierRequired: drmInfos[0].distinctiveIdentifierRequired,
persistentStateRequired: drmInfos[0].persistentStateRequired,
sessionType: drmInfos[0].sessionType || 'temporary',
sessionType: drmInfos[0].sessionType || defaultSessionType,
audioRobustness: drmInfos[0].audioRobustness || '',
videoRobustness: drmInfos[0].videoRobustness || '',
serverCertificate: serverCerts[0],
Expand Down

0 comments on commit 6047fad

Please sign in to comment.