Skip to content

Commit a77a66b

Browse files
committed
wip
1 parent 0ec0ab2 commit a77a66b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1944
-1691
lines changed

src/CompKodiProps.cpp

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <rapidjson/document.h>
2222

2323
using namespace UTILS;
24+
using namespace ADP::KODI_PROPS;
2425

2526
namespace
2627
{
@@ -280,11 +281,20 @@ void ADP::KODI_PROPS::CCompKodiProps::InitStage1(const std::map<std::string, std
280281
else
281282
{
282283
auto first = m_drmConfigs.begin();
283-
first->second.license.serverUrl = licenseUrl;
284+
first->second.license.serverUri = licenseUrl;
284285
}
285286
}
286287
}
287288

289+
const ADP::KODI_PROPS::DrmCfg ADP::KODI_PROPS::CCompKodiProps::GetDrmConfig(
290+
std::string_view keySystem) const
291+
{
292+
if (STRING::KeyExists(m_drmConfigs, keySystem))
293+
return m_drmConfigs.at(keySystem.data());
294+
295+
return {}; // default values
296+
}
297+
288298
void ADP::KODI_PROPS::CCompKodiProps::ParseConfig(const std::string& data)
289299
{
290300
/*
@@ -314,6 +324,38 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseConfig(const std::string& data)
314324
{
315325
m_config.internalCookies = jDictVal.GetBool();
316326
}
327+
else if (configName == "check_hdcp" && jDictVal.IsString())
328+
{
329+
std::string_view value = jDictVal.GetString();
330+
331+
if (value.empty() || value == "default")
332+
m_config.hdcpCheck = HdcpCheckType::DEFAULT;
333+
else if (value == "license")
334+
m_config.hdcpCheck = HdcpCheckType::LICENSE;
335+
else
336+
LOG::LogF(LOGERROR, "Value \"%s\" isnt supported on \"%s\" config of \"%s\" property",
337+
value.data(), configName.c_str(), PROP_MANIFEST_CONFIG.data());
338+
}
339+
else if (configName == "resolution_limit" && jDictVal.IsString())
340+
{
341+
std::string_view value = jDictVal.GetString();
342+
if (!value.empty())
343+
{
344+
auto pos = value.find('x');
345+
if (pos != std::string_view::npos)
346+
{
347+
const int width = STRING::ToInt32(value.substr(0, pos));
348+
const int height = STRING::ToInt32(value.substr(pos + 1));
349+
m_config.resolutionLimit = width * height;
350+
}
351+
else
352+
{
353+
LOG::LogF(LOGERROR,
354+
"Invalid resolution format \"%s\" on \"%s\" config of \"%s\" property",
355+
value.data(), configName.c_str(), PROP_MANIFEST_CONFIG.data());
356+
}
357+
}
358+
}
317359
else
318360
{
319361
LOG::LogF(LOGERROR, "Unsupported \"%s\" config or wrong data type on \"%s\" property",
@@ -379,9 +421,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
379421

380422
if (!STRING::KeyExists(props, PROP_LICENSE_TYPE))
381423
return;
382-
/*
383-
*! @todo: TO UNCOMMENT WHEN DRM AUTO-SELECTION WILL BE FULL IMPLEMENTED
384-
*
424+
385425
LOG::Log(LOGWARNING, "<<<<<<<<< DEPRECATION NOTICE >>>>>>>>>\n"
386426
"DEPRECATED PROPERTIES HAS BEEN USED TO SET THE DRM CONFIGURATION.\n"
387427
"THE FOLLOWING PROPERTIES WILL BE REMOVED FROM FUTURE KODI VERSIONS:\n"
@@ -392,11 +432,11 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
392432
"- inputstream.adaptive.server_certificate\n"
393433
"- inputstream.adaptive.pre_init_data\n"
394434
"YOU SHOULD CONSIDER MIGRATING TO THE NEW PROPERTIES:\n"
395-
"- inputstream.adaptive.drm\n"
396435
"- inputstream.adaptive.drm_legacy\n"
436+
"- inputstream.adaptive.drm\n"
397437
"FOR MORE INFO, PLEASE READ THE WIKI PAGE: "
398438
"https://github.com/xbmc/inputstream.adaptive/wiki/Integration-DRM");
399-
*/
439+
400440
std::string drmKeySystem{DRM::KS_NONE};
401441
if (STRING::KeyExists(props, PROP_LICENSE_TYPE))
402442
drmKeySystem = props.at(PROP_LICENSE_TYPE.data());
@@ -485,7 +525,7 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
485525
{
486526
// Field 1: License server url
487527
if (fieldCount >= 1)
488-
drmCfg.license.serverUrl = fields[0];
528+
drmCfg.license.serverUri = fields[0];
489529

490530
// Field 2: HTTP request headers
491531
if (fieldCount >= 2)
@@ -567,8 +607,8 @@ void ADP::KODI_PROPS::CCompKodiProps::ParseDrmOldProps(
567607
// Position 2: The dict Key name to get HDCP value (optional)
568608
if (jPaths.size() >= 2)
569609
{
570-
drmCfg.license.unwrapperParams["path_hdcp_traverse"] = "true";
571-
drmCfg.license.unwrapperParams["path_hdcp"] = jPaths[1];
610+
drmCfg.license.unwrapperParams["path_hdcp_res_traverse"] = "true";
611+
drmCfg.license.unwrapperParams["path_hdcp_res"] = jPaths[1];
572612
}
573613
}
574614
}
@@ -608,7 +648,7 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmConfig(const std::string& data)
608648
continue;
609649
}
610650

611-
DrmCfg& drmCfg = m_drmConfigs[keySystem];
651+
DrmCfg& drmCfg = m_drmConfigs[keySystem]; // create new configuration
612652
auto& jDictVal = jChildObj.value;
613653

614654
if (!jDictVal.IsObject())
@@ -663,7 +703,7 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmConfig(const std::string& data)
663703
drmCfg.license.serverCert = jDictLic["server_certificate"].GetString();
664704

665705
if (jDictLic.HasMember("server_url") && jDictLic["server_url"].IsString())
666-
drmCfg.license.serverUrl = jDictLic["server_url"].GetString();
706+
drmCfg.license.serverUri = jDictLic["server_url"].GetString();
667707

668708
if (jDictLic.HasMember("use_http_get_request") && jDictLic["use_http_get_request"].IsBool())
669709
drmCfg.license.isHttpGetRequest = jDictLic["use_http_get_request"].GetBool();
@@ -704,9 +744,6 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmConfig(const std::string& data)
704744
}
705745
}
706746
}
707-
708-
//! @todo: temporary support only one DRM config, must be reworked the CSession for DRM auto-selection
709-
break;
710747
}
711748

712749
return true;
@@ -752,9 +789,9 @@ bool ADP::KODI_PROPS::CCompKodiProps::ParseDrmLegacyConfig(const std::string& da
752789

753790
if (!licenseStr.empty())
754791
{
755-
if (URL::IsValidUrl(licenseStr)) // License server URL
792+
if (URL::IsValidUrl(licenseStr) || URL::IsValidUri(licenseStr)) // License server URI
756793
{
757-
drmCfg.license.serverUrl = licenseStr;
794+
drmCfg.license.serverUri = licenseStr;
758795
}
759796
else // Assume are keyid's for ClearKey DRM
760797
{

src/CompKodiProps.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ struct ChooserProps
3535
std::pair<int, int> m_resolutionSecureMax; // Res. limit for DRM protected videos (values 0 means auto)
3636
};
3737

38+
enum class HdcpCheckType
39+
{
40+
DEFAULT,
41+
LICENSE, // To check HDCP values from DRM license response
42+
};
43+
3844
// Generic add-on configuration
3945
struct Config
4046
{
@@ -43,6 +49,10 @@ struct Config
4349
bool curlSSLVerifyPeer{true};
4450
// Determines if cookies are internally handled by InputStream Adaptive add-on
4551
bool internalCookies{false};
52+
// Determines how HDCP should be checked
53+
HdcpCheckType hdcpCheck{HdcpCheckType::DEFAULT};
54+
// Force limit resolutions of manifest streams to the specified value included (value in px, height x width)
55+
int resolutionLimit{0};
4656
};
4757

4858
struct ManifestConfig
@@ -83,8 +93,8 @@ struct DrmCfg
8393
{
8494
// The license server certificate encoded as base64
8595
std::string serverCert;
86-
// The license server url
87-
std::string serverUrl;
96+
// The license server uri
97+
std::string serverUri;
8898
// To force an HTTP GET request, instead that POST request
8999
bool isHttpGetRequest{false};
90100
// HTTP request headers
@@ -152,20 +162,10 @@ class ATTR_DLL_LOCAL CCompKodiProps
152162
// \brief Specifies the manifest configuration
153163
const ManifestConfig& GetManifestConfig() const { return m_manifestConfig; }
154164

165+
// \brief Gets the DRM configuration for the specified keysystem. If not found, returns default values.
166+
const DrmCfg GetDrmConfig(std::string_view keySystem) const;
155167

156-
//! @todo: temporary method, for future rework
157-
const std::string GetDrmKeySystem()
158-
{
159-
return m_drmConfigs.empty() ? "" : m_drmConfigs.begin()->first;
160-
}
161-
//! @todo: temporary method, for future rework
162-
const DrmCfg& GetDrmConfig() { return m_drmConfigs[GetDrmKeySystem()]; }
163-
164-
165-
// \brief Get DRM configuration for specified keysystem, if not found will return default values
166-
const DrmCfg& GetDrmConfig(const std::string& keySystem) { return m_drmConfigs[keySystem]; }
167-
const DrmCfg& GetDrmConfig(std::string_view keySystem) { return m_drmConfigs[std::string(keySystem)]; }
168-
168+
// \brief Gets the DRM configurations (Key System, DRM config)
169169
const std::map<std::string, DrmCfg>& GetDrmConfigs() const { return m_drmConfigs; }
170170

171171
private:

src/Iaes_decrypter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IAESDecrypter
2626
size_t dstOffset,
2727
size_t& dataSize,
2828
bool lastChunk) = 0;
29-
virtual std::string convertIV(const std::string& input) = 0;
29+
virtual std::vector<uint8_t> convertIV(const std::string& input) = 0;
3030
virtual void ivFromSequence(uint8_t* buffer, uint64_t sid) = 0;
3131
// virtual const std::string& getLicenseKey() const = 0;
3232
// virtual bool RenewLicense(const std::string& pluginUrl) = 0;

0 commit comments

Comments
 (0)