Skip to content

Commit 671749b

Browse files
committed
fixups
1 parent cacc7f4 commit 671749b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/decrypters/DrmEngine.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ bool DRM::CDRMEngine::ConfigureClearKey(std::vector<DRM::DRMInfo>& drmInfos)
433433

434434
const ADP::KODI_PROPS::DrmCfg& drmCfg = kodiProps.GetDrmConfig(KS_CLEARKEY);
435435

436-
// The ClearKey configuration will replace all DRMInfo when
436+
// The ClearKey configuration can add (or replace) CK DRMInfo when
437437
// it finds a custom license uri or keys
438438
if (drmCfg.license.serverUri.empty() && drmCfg.license.keys.empty())
439439
return false;
@@ -442,7 +442,17 @@ bool DRM::CDRMEngine::ConfigureClearKey(std::vector<DRM::DRMInfo>& drmInfos)
442442
const CryptoMode cryptoMode = drmInfos[0].cryptoMode;
443443
const std::string defaultKid = drmInfos[0].defaultKid;
444444

445-
drmInfos.clear();
445+
if (kodiProps.GetDrmConfigs().size() == 1) // Single config (CK)
446+
{
447+
// Delete all the DRMInfo, so you can force CK even if the manifest uses a different DRM
448+
drmInfos.clear();
449+
}
450+
else // More configs, behavior based on "priority" its needed to preserve DRMInfos
451+
{
452+
drmInfos.erase(std::remove_if(drmInfos.begin(), drmInfos.end(), [](const DRM::DRMInfo& info)
453+
{ return info.keySystem == KS_CLEARKEY; }),
454+
drmInfos.end());
455+
}
446456

447457
std::string licenseUri;
448458

@@ -488,7 +498,6 @@ bool DRM::CDRMEngine::ConfigureClearKey(std::vector<DRM::DRMInfo>& drmInfos)
488498
drmInfo.cryptoMode = cryptoMode;
489499
drmInfo.defaultKid = defaultKid;
490500
drmInfo.licenseServerUri = licenseUri;
491-
492501
drmInfos.emplace_back(drmInfo);
493502

494503
return true;

0 commit comments

Comments
 (0)