29 #include "AampUtils.h"
64 {
"oper",AAMP_OPERATOR_SETTING},
65 {
"stream",AAMP_STREAM_SETTING},
66 {
"app",AAMP_APPLICATION_SETTING},
67 {
"tune",AAMP_TUNE_SETTING},
68 {
"cfg",AAMP_DEV_CFG_SETTING},
70 {
"unknown",AAMP_MAX_SETTING}
84 {
"fragmp4LicensePrefetch",eAAMPConfig_Fragmp4PrefetchLicense,
false,-1,-1},
215 {
"wifiCurlHeader",eAAMPConfig_WifiCurlHeader,
false,-1,-1},
227 {
"stallErrorCode",eAAMPConfig_StallErrorCode,
false,{.iMinValue=-1},{.iMaxValue=-1}},
228 {
"stallTimeout",eAAMPConfig_StallTimeoutMS,
false,{.iMinValue=-1},{.iMaxValue=-1}},
229 {
"initialBuffer",eAAMPConfig_InitialBuffer,
false,{.iMinValue=-1},{.iMaxValue=-1}},
230 {
"playbackBuffer",eAAMPConfig_PlaybackBuffer,
false,{.iMinValue=-1},{.iMaxValue=-1}},
231 {
"downloadDelay",eAAMPConfig_DownloadDelay,
false,{.iMinValue=0},{.iMaxValue=MAX_DOWNLOAD_DELAY_LIMIT_MS}},
272 {
"supportTLS",eAAMPConfig_TLSVersion,
true,{.lMinValue=CURL_SSLVERSION_DEFAULT},{.lMaxValue=CURL_SSLVERSION_TLSv1_3}},
279 {
"persistHighNetworkBandwidth",eAAMPConfig_PersistHighNetworkBandwidth,
false,-1,-1},
292 {
"ignoreAppLiveOffset", eAAMPConfig_IgnoreAppLiveOffset,
false, -1, -1},
305 AampConfig::AampConfig():mAampLookupTable(),mChannelOverrideMap(),logging(),mAampDevCmdTable(),vCustom(),vCustomIt(),customFound(false),mLogObj(NULL)
325 mChannelOverrideMap = rhs.mChannelOverrideMap;
326 mAampDevCmdTable = rhs.mAampDevCmdTable;
327 vCustom = rhs.vCustom;
328 customFound = rhs.customFound;
335 for(
int index=0;index < (eAAMPConfig_StringMaxValue-eAAMPConfig_StringStartValue) ; index++)
346 void AampConfig::Initialize()
364 #if defined(BRCM) || defined(RPI) || defined(AAMP_SIMULATOR_BUILD)
416 #if defined(REALTEKCE) || defined(AMLOGIC) || defined(FLEX2_RDK) // Temporary till westerossink disable is rollbacked
435 bAampCfgValue[eAAMPConfig_Fragmp4PrefetchLicense].value =
true;
447 #ifdef GST_SUBTEC_ENABLED
463 #ifdef CONTENT_4K_SUPPORTED
476 #ifdef USE_SECMANAGER
482 bAampCfgValue[eAAMPConfig_PersistHighNetworkBandwidth].value =
false;
533 iAampCfgValue[eAAMPConfig_DownloadDelay-eAAMPConfig_IntStartValue].value = 0;
563 lAampCfgValue[eAAMPConfig_TLSVersion-eAAMPConfig_LongStartValue].value = CURL_SSLVERSION_TLSv1_2;
611 #if defined(BRCM) || defined(RPI) || defined(AAMP_SIMULATOR_BUILD)
617 logprintf(
"AC4 not supported. DisableAC4 Audio");
628 logprintf(
"AC3 not supported. DisableAC3 Audio");
641 std::string AampConfig::GetUserAgentString()
667 if(cfg > eAAMPConfig_IntStartValue && cfg < eAAMPConfig_IntMaxValue)
688 else if(cfg > eAAMPConfig_IntStartValue && cfg < eAAMPConfig_IntMaxValue)
692 else if(cfg > eAAMPConfig_LongStartValue && cfg < eAAMPConfig_LongMaxValue)
696 else if(cfg > eAAMPConfig_DoubleStartValue && cfg < eAAMPConfig_DoubleMaxValue)
700 else if(cfg > eAAMPConfig_StringStartValue && cfg < eAAMPConfig_StringMaxValue)
706 AAMPLOG_ERR(
"Cfg Index Not in range : %d",cfg);
719 if(cfg > eAAMPConfig_LongStartValue && cfg < eAAMPConfig_LongMaxValue)
735 if(cfg > eAAMPConfig_DoubleStartValue && cfg < eAAMPConfig_DoubleMaxValue)
737 value =
dAampCfgValue[cfg-eAAMPConfig_DoubleStartValue].value;
751 if(cfg > eAAMPConfig_StringStartValue && cfg < eAAMPConfig_StringMaxValue)
753 value =
sAampCfgValue[cfg-eAAMPConfig_StringStartValue].value;
766 if(mChannelOverrideMap.size() && manifestUrl.size())
768 for (ChannelMapIter it = mChannelOverrideMap.begin(); it != mChannelOverrideMap.end(); ++it)
771 if (manifestUrl.find(pChannelInfo.name) != std::string::npos)
773 return pChannelInfo.uri.c_str();
787 if(mChannelOverrideMap.size() && manifestUrl.size())
789 for (ChannelMapIter it = mChannelOverrideMap.begin(); it != mChannelOverrideMap.end(); ++it)
792 if (manifestUrl.find(pChannelInfo.uri) != std::string::npos)
794 if(!pChannelInfo.licenseUri.empty())
796 return pChannelInfo.licenseUri.c_str();
836 else if(cfg > eAAMPConfig_IntStartValue && cfg < eAAMPConfig_IntMaxValue)
838 int valueInt = (int)value;
844 else if(cfg > eAAMPConfig_LongStartValue && cfg < eAAMPConfig_LongMaxValue)
846 long valueLong = (long)value;
852 else if(cfg > eAAMPConfig_DoubleStartValue && cfg < eAAMPConfig_DoubleMaxValue)
854 double valueDouble = (double)value;
862 AAMPLOG_ERR(
"Cfg Index Not in range : %d ",cfg);
874 if(cfg > eAAMPConfig_StringStartValue && cfg < eAAMPConfig_StringMaxValue)
880 AAMPLOG_ERR(
"Index Not in range : %d [%d-%d] ",cfg,eAAMPConfig_StringStartValue,eAAMPConfig_StringMaxValue);
894 cJSON *cfgdata = cJSON_Parse(jsonbuffer);
896 cJSON_Delete(cfgdata);
912 cJSON *custom = cJSON_GetObjectItem(cfgdata,
"Custom");
913 if((custom != NULL) && (owner == AAMP_DEV_CFG_SETTING))
919 for(cJSON *searchObj = cfgdata->child; NULL != searchObj; searchObj=searchObj->next)
921 auto it = mAampLookupTable.find(searchObj->string);
922 if ( it != mAampLookupTable.end())
926 std::string keyname = it->first;
930 if(cJSON_IsTrue(searchObj))
932 SetConfigValue<bool>(owner,cfgEnum,
true);
933 AAMPLOG_WARN(
"Parsed value for property %s - true",keyname.c_str());
937 SetConfigValue<bool>(owner,cfgEnum,
false);
938 AAMPLOG_WARN(
"Parsed value for property %s - false",keyname.c_str());
941 else if(cfgEnum > eAAMPConfig_IntStartValue && cfgEnum < eAAMPConfig_IntMaxValue && cJSON_IsNumber(searchObj))
944 int conv = (int)searchObj->valueint;
945 AAMPLOG_WARN(
"Parsed value for property %s - %d",keyname.c_str(),conv);
946 if(ValidateRange(keyname,conv))
948 SetConfigValue<int>(owner,cfgEnum,conv);
952 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
955 else if(cfgEnum > eAAMPConfig_LongStartValue && cfgEnum < eAAMPConfig_LongMaxValue && cJSON_IsNumber(searchObj))
958 long conv = (long)searchObj->valueint;
959 AAMPLOG_WARN(
"Parsed value for property %s - %ld",keyname.c_str(),conv);
960 if(ValidateRange(keyname,conv))
962 SetConfigValue<long>(owner,cfgEnum,conv);
966 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
969 else if(cfgEnum > eAAMPConfig_DoubleStartValue && cfgEnum < eAAMPConfig_DoubleMaxValue && cJSON_IsNumber(searchObj))
972 double conv= (double)searchObj->valuedouble;
973 AAMPLOG_WARN(
"Parsed value for property %s - %f",keyname.c_str(),conv);
974 if(ValidateRange(keyname,conv))
976 SetConfigValue<double>(owner,cfgEnum,conv);
980 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
983 else if(cfgEnum > eAAMPConfig_StringStartValue && cfgEnum < eAAMPConfig_StringMaxValue && cJSON_IsString(searchObj))
986 std::string conv = std::string(searchObj->valuestring);
987 AAMPLOG_WARN(
"Parsed value for property %s - %s",keyname.c_str(),conv.c_str());
988 SetConfigValue<std::string>(owner,cfgEnum,conv);
994 cJSON *chMap = cJSON_GetObjectItem(cfgdata,
"chmap");
997 if(cJSON_IsArray(chMap))
999 for (
int i = 0 ; i < cJSON_GetArraySize(chMap) ; i++)
1001 cJSON * subitem = cJSON_GetArrayItem(chMap, i);
1002 char *name = (
char *)cJSON_GetObjectItem(subitem,
"name")->valuestring;
1003 char *url = (
char *)cJSON_GetObjectItem(subitem,
"url")->valuestring;
1004 char *licenseUrl= (
char *)cJSON_GetObjectItem(subitem,
"licenseServerUrl")->valuestring;
1008 channelInfo.uri = url;
1009 channelInfo.name = name;
1010 channelInfo.licenseUri = licenseUrl;
1011 mChannelOverrideMap.push_back(channelInfo);
1017 AAMPLOG_ERR(
"JSON Channel Override format is wrong");
1020 cJSON *drmConfig = cJSON_GetObjectItem(cfgdata,
"drmConfig");
1023 AAMPLOG_WARN(
"Parsed value for property DrmConfig");
1024 cJSON *subitem = drmConfig->child;
1028 std::string conv = std::string(subitem->valuestring);
1029 if(strcasecmp(
"com.microsoft.playready",subitem->string)==0)
1031 AAMPLOG_WARN(
"Playready License Server URL config param received - %s", conv.c_str());
1035 if(strcasecmp(
"com.widevine.alpha",subitem->string)==0)
1037 AAMPLOG_WARN(
"Widevine License Server URL config param received - %s", conv.c_str());
1041 if(strcasecmp(
"org.w3.clearkey",subitem->string)==0)
1043 AAMPLOG_WARN(
"ClearKey License Server URL config param received - %s", conv.c_str());
1047 if(strcasecmp(
"preferredKeysystem",subitem->string)==0)
1049 AAMPLOG_WARN(
"Preferred key system received - %s", conv.c_str());
1052 if(strcasecmp(
"customData",subitem->string)==0)
1054 AAMPLOG_WARN(
"customData received - %s", conv.c_str());
1057 subitem = subitem->next;
1072 std::string keyname;
1074 cJSON *customVal=NULL;
1075 cJSON *searchVal=NULL;
1076 customOwner = owner;
1077 if(owner == AAMP_DEV_CFG_SETTING)
1082 int length = cJSON_GetArraySize(customArray);
1083 if(customArray != NULL)
1085 for(
int i = 0; i < length ; i++)
1087 customVal = cJSON_GetArrayItem(customArray,i);
1088 if((searchVal = cJSON_GetObjectItem(customVal,
"url")) != NULL)
1092 else if((searchVal = cJSON_GetObjectItem(customVal,
"playerId")) != NULL)
1094 keyname =
"playerId";
1096 else if((searchVal = cJSON_GetObjectItem(customVal,
"appName")) != NULL)
1098 keyname =
"appName";
1100 customValues.config = keyname;
1101 if(searchVal && searchVal->valuestring != NULL)
1103 customValues.configValue = searchVal->valuestring;
1104 vCustom.push_back(customValues);
1108 AAMPLOG_ERR(
"Invalid format for %s",keyname.c_str());
1111 for (
auto it = mAampLookupTable.begin(); it != mAampLookupTable.end(); ++it)
1113 keyname = it->first;
1114 searchVal = cJSON_GetObjectItem(customVal,keyname.c_str());
1117 customValues.config = keyname;
1118 if(searchVal->valuestring != NULL)
1120 customValues.configValue = searchVal->valuestring;
1121 vCustom.push_back(customValues);
1125 AAMPLOG_ERR(
"Invalid format for %s ",keyname.c_str());
1131 for(
int i = 0; i < vCustom.size(); i++)
1133 AAMPLOG_WARN(
"Custom Values listed %s %s",vCustom[i].config.c_str(),vCustom[i].configValue.c_str());
1144 if(customFound ==
false)
1149 AAMPLOG_INFO(
"url %s playerid %d appname %s ",url.c_str(),playerId,appname.c_str());
1150 std::string url_custom = url;
1151 std::string playerId_custom = std::to_string(playerId);
1152 std::string appName_custom = appname;
1153 std::string keyname;
1154 std::string urlName =
"url";
1155 std::string player =
"playerId";
1156 std::string appName =
"appName";
1160 auto it = std::find_if( vCustom.begin(), vCustom.end(),[](
const customJson & item) { return item.config ==
"url"; });
1161 if (it != vCustom.end())
1163 int distance = std::distance(vCustom.begin(),it);
1164 foundurl = url_custom.find(vCustom[distance].configValue);
1165 if( foundurl != std::string::npos)
1168 AAMPLOG_INFO(
"FOUND URL %s", vCustom[index].configValue.c_str());
1173 auto it1 = std::find_if( vCustom.begin(), vCustom.end(),[](
const customJson & item) { return item.config ==
"playerId"; });
1174 if (it1 != vCustom.end())
1176 int distance = std::distance(vCustom.begin(),it1);
1177 foundurl = playerId_custom.find(vCustom[distance].configValue);
1178 if( foundurl != std::string::npos)
1181 AAMPLOG_INFO(
"FOUND PLAYERID %s", vCustom[index].configValue.c_str());
1186 auto it2 = std::find_if( vCustom.begin(), vCustom.end(),[](
const customJson & item) { return item.config ==
"appName"; });
1187 if (it2 != vCustom.end())
1189 int distance = std::distance(vCustom.begin(),it2);
1190 foundurl = appName_custom.find(vCustom[distance].configValue);
1191 if( foundurl != std::string::npos)
1194 AAMPLOG_INFO(
"FOUND AAPNAME %s",vCustom[index].configValue.c_str());
1204 for(
int i = index+1; i < vCustom.size(); i++ )
1206 if(vCustom[i].config == urlName){
1208 else if(vCustom[i].config == player){
1210 else if(vCustom[i].config == appName){
1214 for (
auto it = mAampLookupTable.begin(); it != mAampLookupTable.end(); ++it)
1218 keyname = it->first;
1219 if(strcmp(vCustom[i].config.c_str(),keyname.c_str()) == 0)
1223 if(strcmp(vCustom[i].configValue.c_str(),
"true") == 0)
1225 SetConfigValue<bool>(customOwner,cfgEnum,
true);
1229 SetConfigValue<bool>(customOwner,cfgEnum,
false);
1232 else if(cfgEnum > eAAMPConfig_IntStartValue && cfgEnum < eAAMPConfig_IntMaxValue)
1234 int conv = atoi(vCustom[i].configValue.c_str());
1235 if(ValidateRange(keyname,conv))
1237 SetConfigValue<int>(customOwner,cfgEnum,conv);
1241 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
1244 else if(cfgEnum > eAAMPConfig_LongStartValue && cfgEnum < eAAMPConfig_LongMaxValue)
1246 long conv = atol(vCustom[i].configValue.c_str());
1247 if(ValidateRange(keyname,conv))
1249 SetConfigValue<long>(customOwner,cfgEnum,conv);
1253 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
1256 else if(cfgEnum > eAAMPConfig_DoubleStartValue && cfgEnum < eAAMPConfig_DoubleMaxValue)
1258 double conv= (double)atof(vCustom[i].configValue.c_str());
1259 if(ValidateRange(keyname,conv))
1261 SetConfigValue<double>(customOwner,cfgEnum,conv);
1265 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
1268 else if(cfgEnum > eAAMPConfig_StringStartValue && cfgEnum < eAAMPConfig_StringMaxValue)
1270 SetConfigValue<std::string>(customOwner,cfgEnum,std::string(vCustom[i].configValue.c_str()));
1298 for(
int i=eAAMPConfig_IntStartValue+1;i<eAAMPConfig_IntMaxValue;i++)
1304 for(
int i=eAAMPConfig_LongStartValue+1;i<eAAMPConfig_LongMaxValue;i++)
1310 for(
int i=eAAMPConfig_DoubleStartValue+1;i<eAAMPConfig_DoubleMaxValue;i++)
1316 for(
int i=eAAMPConfig_StringStartValue+1;i<eAAMPConfig_StringMaxValue;i++)
1332 bool retval =
false;
1333 DevCmdsIter iter = mAampDevCmdTable.find(key);
1334 if(iter != mAampDevCmdTable.end())
1336 value = iter->second;
1351 if (!cfg.empty() && cfg.at(0) !=
'#')
1359 std::size_t pos = cfg.find_first_of(
' ');
1360 if (pos != std::string::npos)
1365 std::stringstream iss(cfg.substr(1));
1367 while (getline(iss, token,
' '))
1369 if (token.compare(0,4,
"http") == 0)
1370 channelInfo.uri = token;
1371 else if ((token.compare(0,5,
"live:") == 0) || (token.compare(0,3,
"mr:") == 0) || (token.compare(0,5,
"tune:") == 0))
1373 AAMPLOG_INFO(
"Overriden OTA Url!!");
1374 channelInfo.uri = token;
1376 else if(token.compare(0,4,
"file") == 0)
1378 AAMPLOG_INFO(
"Overriden Progressive URL!!");
1379 channelInfo.uri = token;
1381 else if (token.compare(0,17,
"licenseServerUrl=") == 0)
1383 channelInfo.licenseUri = token.substr(17);
1386 channelInfo.name = token;
1388 mChannelOverrideMap.push_back(channelInfo);
1395 cfg.erase(std::find_if(cfg.rbegin(), cfg.rend(), [](
unsigned char ch) {return !std::isspace(ch);}).base(), cfg.end());
1397 bool toggle =
false;
1399 std::string key,value;
1400 std::size_t delimiterPos = cfg.find(
"=");
1401 if(delimiterPos != std::string::npos)
1403 key = cfg.substr(0, delimiterPos);
1404 key.erase(std::remove_if(key.begin(), key.end(), ::isspace), key.end());
1405 value = cfg.substr(delimiterPos + 1);
1406 position = value.find_first_not_of(
' ');
1407 value = value.substr(position);
1411 key = cfg.substr(0);
1415 LookUpIter iter = mAampLookupTable.find(key);
1416 if(iter != mAampLookupTable.end())
1420 AAMPLOG_WARN(
"Parsed value for dev cfg property %s - %s",key.c_str(),value.c_str());
1428 if(isdigit(value[0]))
1431 SetConfigValue<bool>(owner,cfgEnum,(
bool)(conv != 0));
1436 if(strcasecmp(value.c_str(),
"true")==0)
1437 SetConfigValue<bool>(owner,cfgEnum,(
bool)
true);
1438 else if(strcasecmp(value.c_str(),
"false")==0)
1439 SetConfigValue<bool>(owner,cfgEnum,(
bool)
false);
1441 AAMPLOG_ERR(
"Wrong input provided for Cfg:%s Value:%s",iter->first.c_str(),value.c_str());
1450 else if(cfgEnum > eAAMPConfig_IntStartValue && cfgEnum < eAAMPConfig_IntMaxValue)
1456 if(ValidateRange(key,conv))
1458 SetConfigValue<int>(owner,cfgEnum,(
int)conv);
1462 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
1466 else if(cfgEnum > eAAMPConfig_LongStartValue && cfgEnum < eAAMPConfig_LongMaxValue)
1472 if(ValidateRange(key,conv))
1474 SetConfigValue<long>(owner,cfgEnum,(
long)conv);
1478 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
1482 else if(cfgEnum > eAAMPConfig_DoubleStartValue && cfgEnum < eAAMPConfig_DoubleMaxValue)
1488 if(ValidateRange(key,conv))
1490 SetConfigValue<double>(owner,cfgEnum,(
double)conv);
1494 AAMPLOG_ERR(
"Set failed .Input beyond the configured range");
1498 else if(cfgEnum > eAAMPConfig_StringStartValue && cfgEnum < eAAMPConfig_StringMaxValue)
1502 SetConfigValue<std::string>(owner,cfgEnum,value);
1508 mAampDevCmdTable[key]=value;
1509 AAMPLOG_WARN(
"Unknown command(%s) added to DeveloperTable",key.c_str());
1526 #ifdef AAMP_SIMULATOR_BUILD
1527 std::string cfgPath(getenv(
"HOME"));
1529 std::string cfgPath =
"";
1532 #ifdef AAMP_SIMULATOR_BUILD
1533 cfgPath +=
"/aampcfg.json";
1536 #ifdef AAMP_CPC // Comcast builds
1538 const char *env_aamp_enable_opt = getenv(
"AAMP_ENABLE_OPT_OVERRIDE");
1540 const char *env_aamp_enable_opt =
"true";
1543 if(env_aamp_enable_opt)
1545 cfgPath = AAMP_JSON_PATH;
1549 if (!cfgPath.empty())
1551 std::ifstream f(cfgPath, std::ifstream::in | std::ifstream::binary);
1554 AAMPLOG_WARN(
"opened aampcfg.json");
1555 std::filebuf* pbuf = f.rdbuf();
1556 std::size_t size = pbuf->pubseekoff (0,f.end,f.in);
1557 pbuf->pubseekpos (0,f.in);
1558 char* jsonbuffer=
new char[size];
1559 pbuf->sgetn (jsonbuffer,size);
1562 SAFE_DELETE_ARRAY(jsonbuffer);
1576 bool retVal =
false;
1577 #ifdef AAMP_SIMULATOR_BUILD
1578 std::string cfgPath(getenv(
"HOME"));
1580 std::string cfgPath =
"";
1583 #ifdef AAMP_SIMULATOR_BUILD
1584 cfgPath +=
"/aamp.cfg";
1587 #ifdef AAMP_CPC // Comcast builds
1589 const char *env_aamp_enable_opt = getenv(
"AAMP_ENABLE_OPT_OVERRIDE");
1591 const char *env_aamp_enable_opt =
"true";
1594 if(env_aamp_enable_opt)
1596 cfgPath = AAMP_CFG_PATH;
1600 if (!cfgPath.empty())
1602 std::ifstream f(cfgPath, std::ifstream::in | std::ifstream::binary);
1605 AAMPLOG_WARN(
"opened aamp.cfg");
1609 std::getline(f, buf);
1624 void AampConfig::ReadBase64TR181Param()
1627 size_t iConfigLen = 0;
1628 char * cloudConf =
GetTR181AAMPConfig(
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AAMP_CFG.b64Config", iConfigLen);
1629 if(cloudConf && (iConfigLen > 0))
1631 bool bCharCompliant =
true;
1632 for (
int i = 0; i < iConfigLen; i++)
1634 if (!( cloudConf[i] == 0xD || cloudConf[i] == 0xA) &&
1635 ((cloudConf[i] < 0x20) || (cloudConf[i] > 0x7E)))
1637 bCharCompliant =
false;
1638 AAMPLOG_ERR(
"Non Compliant char[0x%X] found, Ignoring whole config ",cloudConf[i]);
1645 std::string strCfg(cloudConf,iConfigLen);
1649 std::istringstream iSteam(strCfg);
1651 while (std::getline(iSteam, line))
1653 if (line.length() > 0)
1655 AAMPLOG_INFO(
"aamp-cmd:[%s]\n", line.c_str());
1670 void AampConfig::ReadAllTR181Params()
1673 #ifdef AAMP_RFC_ENABLED
1676 long long begin = NOW_STEADY_TS_MS;
1679 const std::string strAAMPTr181BasePath =
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.aamp.";
1687 std::string value = RFCSettings::getRFCValue(strAAMPTr181BasePath+strParamName);
1688 if( !value.empty() )
1693 if(isdigit(value[0]))
1696 SetConfigValue<bool>(owner,cfgEnum,(
bool)(conv != 0));
1701 if(strcasecmp(value.c_str(),
"true")==0)
1703 SetConfigValue<bool>(owner,cfgEnum,(
bool)
true);
1705 else if(strcasecmp(value.c_str(),
"false")==0)
1707 SetConfigValue<bool>(owner,cfgEnum,(
bool)
false);
1711 AAMPLOG_ERR(
"ReadAllTR181Params: Wrong input provided for param:%s Value:%s",strParamName.c_str(),value.c_str());
1715 else if(cfgEnum > eAAMPConfig_IntStartValue && cfgEnum < eAAMPConfig_IntMaxValue)
1721 if(ValidateRange(strParamName,conv))
1723 SetConfigValue<int>(owner,cfgEnum,(
int)conv);
1727 AAMPLOG_ERR(
"ReadAllTR181Params: Out of range input provided for param:%s Value:%s",strParamName.c_str(),value.c_str());
1731 else if(cfgEnum > eAAMPConfig_LongStartValue && cfgEnum < eAAMPConfig_LongMaxValue)
1737 if(ValidateRange(strParamName,conv))
1739 SetConfigValue<long>(owner,cfgEnum,(
long)conv);
1743 AAMPLOG_ERR(
"ReadAllTR181Params: Out of range input provided for param:%s Value:%s",strParamName.c_str(),value.c_str());
1747 else if(cfgEnum > eAAMPConfig_DoubleStartValue && cfgEnum < eAAMPConfig_DoubleMaxValue)
1753 if(ValidateRange(strParamName,conv))
1755 SetConfigValue<double>(owner,cfgEnum,(
double)conv);
1759 AAMPLOG_ERR(
"ReadAllTR181Params: Out of range input provided for param:%s Value:%s",strParamName.c_str(),value.c_str());
1763 else if (cfgEnum > eAAMPConfig_StringStartValue && cfgEnum < eAAMPConfig_StringMaxValue)
1768 SetConfigValue<std::string>(owner,cfgEnum,value);
1774 AAMPLOG_TRACE(
"ReadAllTR181Params: Got empty value for param:%s",strParamName.c_str());
1779 AAMPLOG_WARN(
"ReadAllTR181Params took %lld ms to execute", (NOW_STEADY_TS_MS - begin));
1792 ReadBase64TR181Param();
1796 ReadAllTR181Params();
1799 const char *env_aamp_force_aac = getenv(
"AAMP_FORCE_AAC");
1800 if(env_aamp_force_aac)
1802 AAMPLOG_INFO(
"AAMP_FORCE_AAC present: Changing preference to AAC over ATMOS & DD+");
1811 const char *env_aamp_min_init_cache = getenv(
"AAMP_MIN_INIT_CACHE");
1812 if(env_aamp_min_init_cache)
1814 int minInitCache = 0;
1815 if(sscanf(env_aamp_min_init_cache,
"%d",&minInitCache) && minInitCache >= 0)
1817 AAMPLOG_INFO(
"AAMP_MIN_INIT_CACHE present: Changing min initial cache to %d seconds",minInitCache);
1818 SetConfigValue<int>(AAMP_OPERATOR_SETTING,eAAMPConfig_InitialBuffer,minInitCache);
1823 const char *env_enable_cdai = getenv(
"CLIENT_SIDE_DAI");
1826 AAMPLOG_INFO(
"CLIENT_SIDE_DAI present: Enabling CLIENT_SIDE_DAI.");
1830 const char *env_enable_westoros_sink = getenv(
"AAMP_ENABLE_WESTEROS_SINK");
1831 if(env_enable_westoros_sink)
1834 int iValue = atoi(env_enable_westoros_sink);
1835 bool bValue = (strcasecmp(env_enable_westoros_sink,
"true") == 0);
1837 AAMPLOG_INFO(
"AAMP_ENABLE_WESTEROS_SINK present, Value = %d", (bValue ? bValue : (iValue ? iValue : 0)));
1839 if(iValue || bValue)
1841 AAMPLOG_INFO(
"AAMP_ENABLE_WESTEROS_SINK present: Enabling westeros-sink.");
1847 const char *env_enable_lld = getenv(
"LOW_LATENCY_DASH");
1850 AAMPLOG_INFO(
"LOW_LATENCY_DASH present: Enabling LOW_LATENCY_DASH");
1861 std::string logString;
1887 else if(logString.compare(
"error") == 0)
1977 std::transform(keySystem.begin(), keySystem.end(), keySystem.begin(), ::tolower);
1978 if(keySystem.find(
"widevine") != std::string::npos)
1980 else if(keySystem.find(
"clearkey") != std::string::npos)
2029 std::string tempvalue;
2030 std::string sessionToken;
2044 double tempvalue,Appoffset;
2050 AAMPLOG_INFO(
"\n IgnoreAppLiveOffset Enabled,LiveOffset changed from %lf to %lf ",Appoffset,tempvalue);
2061 template<
class J,
class K>
2064 if(setting.owner <= newowner )
2068 if(setting.owner != newowner)
2070 setting.lastvalue = setting.value;
2071 setting.lastowner = setting.owner;
2073 setting.value = value;
2074 setting.owner = newowner;
2075 AAMPLOG_WARN(
"%s New Owner[%d]",cfgName.c_str(),newowner);
2079 AAMPLOG_WARN(
"%s Owner[%d] not allowed to Set ,current Owner[%d]",cfgName.c_str(),newowner,setting.owner);
2089 std::string keyname;
2090 for (
auto it = mAampLookupTable.begin(); it != mAampLookupTable.end(); ++it)
2096 keyname = it->first;
2104 template<
typename T>
2105 bool AampConfig::ValidateRange(std::string key, T& value)
2109 LookUpIter iter = mAampLookupTable.find(key);
2110 if(iter != mAampLookupTable.end())
2114 if (std::is_same<T, int>::value)
2116 if(item.Min.iMinValue != -1 && value < item.Min.iMinValue)
2118 if(item.Max.iMaxValue != -1 && value > item.Max.iMaxValue)
2121 else if (std::is_same<T, long>::value)
2123 if(item.Min.lMinValue != -1 && value < item.Min.lMinValue)
2125 if(item.Max.lMaxValue != -1 && value > item.Max.lMaxValue)
2128 else if (std::is_same<T, double>::value)
2130 if(item.Min.dMinValue != -1 && value < item.Min.dMinValue)
2132 if(item.Max.dMaxValue != -1 && value > item.Max.dMaxValue)
2163 for(
int i=eAAMPConfig_IntStartValue+1;i<eAAMPConfig_IntMaxValue;i++)
2177 for(
int i=eAAMPConfig_LongStartValue+1;i<eAAMPConfig_LongMaxValue;i++)
2190 for(
int i=eAAMPConfig_DoubleStartValue+1;i<eAAMPConfig_DoubleMaxValue;i++)
2204 for(
int i=eAAMPConfig_StringStartValue+1;i<eAAMPConfig_StringMaxValue;i++)
2230 if(
bAampCfgValue[i].owner == owner || owner == AAMP_MAX_SETTING)
2237 for(
int i=eAAMPConfig_IntStartValue+1;i<eAAMPConfig_IntMaxValue;i++)
2240 if(
iAampCfgValue[i-eAAMPConfig_IntStartValue].owner == owner || owner == AAMP_MAX_SETTING)
2247 for(
int i=eAAMPConfig_LongStartValue+1;i<eAAMPConfig_LongMaxValue;i++)
2250 if(
lAampCfgValue[i-eAAMPConfig_LongStartValue].owner == owner || owner == AAMP_MAX_SETTING)
2257 for(
int i=eAAMPConfig_DoubleStartValue+1;i<eAAMPConfig_DoubleMaxValue;i++)
2260 if(
dAampCfgValue[i-eAAMPConfig_DoubleStartValue].owner == owner || owner == AAMP_MAX_SETTING)
2269 for(
int i=eAAMPConfig_StringStartValue+1;i<eAAMPConfig_StringMaxValue;i++)
2272 if(
sAampCfgValue[i-eAAMPConfig_StringStartValue].owner == owner || owner == AAMP_MAX_SETTING)
2278 if(mChannelOverrideMap.size() && (owner == AAMP_DEV_CFG_SETTING || owner == AAMP_MAX_SETTING))
2280 ChannelMapIter iter;
2281 for (iter = mChannelOverrideMap.begin(); iter != mChannelOverrideMap.end(); ++iter)
2283 AAMPLOG_INFO(
"Cfg Channel[%s]-> [%s]",iter->name.c_str(),iter->uri.c_str());
2284 AAMPLOG_INFO(
"Cfg Channel[%s]-> License Uri: [%s]",iter->name.c_str(),iter->licenseUri.c_str());
2293 template<
typename T>
2300 if (std::is_same<T, int>::value)
2301 value = std::stoi(valStr);
2302 else if (std::is_same<T, long>::value)
2303 value = std::stol(valStr);
2304 else if (std::is_same<T, float>::value)
2305 value = std::stof(valStr);
2306 else if (std::is_same<T, double>::value)
2307 value = std::stod(valStr);
2310 AAMPLOG_ERR(
"ERROR Invalid Input ");
2327 char * strConfig = NULL;
2328 IARM_Result_t result;
2330 memset(¶m,0,
sizeof(param));
2331 snprintf(param.
paramName,TR69HOSTIFMGR_MAX_PARAM_LEN,
"%s",paramName);
2335 (
void *)¶m,
sizeof(param));
2336 if(result == IARM_RESULT_SUCCESS)
2338 if(fcNoFault == param.faultCode)
2340 if(param.paramtype == hostIf_StringType && param.paramLen > 0 )
2342 std::string strforLog(param.paramValue,param.paramLen);
2344 iConfigLen = param.paramLen;
2345 const char *src = (
const char*)(param.paramValue);
2348 AAMPLOG_INFO(
"GetTR181AAMPConfig: Got:%s En-Len:%d Dec-len:%d",strforLog.c_str(),param.paramLen,iConfigLen);
2352 AAMPLOG_ERR(
"GetTR181AAMPConfig: Not a string param type=%d or Invalid len:%d ",param.paramtype, param.paramLen);
2358 AAMPLOG_ERR(
"GetTR181AAMPConfig: Failed to retrieve value result=%d",result);
2364 #ifdef UNIT_TEST_ENABLED
2403 printf(
"Var1 LicenseServer Url:%s\n",test1.c_str());
2409 std::string ovrride;
2412 printf(
"Ch override for HBO: %s \n",ovrride.c_str());