From 6047fad2c838ec538890f6cbfeae261775390cec Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 26 Apr 2021 12:09:36 -0700 Subject: [PATCH] fix(MCap): Fix the default DRM session type w/ MCap 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 --- lib/media/drm_engine.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index 0b351b7a15..e2cc2f32a2 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -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 { @@ -1993,7 +1993,7 @@ shaka.media.DrmEngine = class { * * @private */ - static createDrmInfoByInfos_(keySystem, drmInfos) { + createDrmInfoByInfos_(keySystem, drmInfos) { /** @type {!Array.} */ const licenseServers = []; @@ -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],