Skip to content

Commit 7b3da5b

Browse files
committed
RDKEMW-5197 : Fix set/get/reset CMS issues with JSOn implementation
1 parent 43e87b3 commit 7b3da5b

File tree

2 files changed

+65
-36
lines changed

2 files changed

+65
-36
lines changed

AVOutput/AVOutputTV.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5057,11 +5057,26 @@ namespace Plugin {
50575057
returnResponse(false);
50585058
}
50595059

5060+
// Get Color and Component enum values
5061+
tvDataComponentColor_t colorLevel;
5062+
if ( getCMSColorEnumFromString(color,colorLevel ) == -1 ) {
5063+
LOGERR("%s : GetColorEnumFromString Failed!!! ",__FUNCTION__);
5064+
returnResponse(false);
5065+
}
5066+
5067+
tvComponentType_t componentLevel;
5068+
if ( getCMSComponentEnumFromString(component,componentLevel ) == -1 ) {
5069+
LOGERR("%s : GetComponentEnumFromString Failed!!! ",__FUNCTION__);
5070+
returnResponse(false);
5071+
}
5072+
50605073
// Prepare paramIndex from context
50615074
paramIndex_t indexInfo = {
50625075
.sourceIndex = static_cast<uint8_t>(validContext.videoSrcType),
50635076
.pqmodeIndex = static_cast<uint8_t>(validContext.pq_mode),
5064-
.formatIndex = static_cast<uint8_t>(validContext.videoFormatType)
5077+
.formatIndex = static_cast<uint8_t>(validContext.videoFormatType),
5078+
.colorIndex = static_cast<uint8_t>(colorLevel),
5079+
.componentIndex = static_cast<uint8_t>(componentLevel)
50655080
};
50665081

50675082
int level = 0;

AVOutput/AVOutputTVHelper.cpp

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,12 @@ namespace Plugin {
984984
std::string key;
985985

986986
// Generate storage key based on parameter type
987-
if (forParam == "CMS")
988-
generateStorageIdentifierCMS(key, forParam, indexInfo);
989-
else if (forParam.compare("WhiteBalance") == 0) {
990-
generateStorageIdentifierWB(key, forParam, indexInfo);
987+
if (forParam.compare("WhiteBalance") == 0) {
988+
generateStorageIdentifierWB(key, forParam, indexInfo);
991989
}
992-
else
990+
else {
993991
generateStorageIdentifierV2(key, forParam, indexInfo);
992+
}
994993

995994
if (key.empty()) {
996995
LOGERR("%s generateStorageIdentifier failed\n", __FUNCTION__);
@@ -1763,11 +1762,11 @@ namespace Plugin {
17631762
string key;
17641763
TR181_ParamData_t param={0};
17651764

1766-
if (forParam.compare("CMS") == 0) {
1765+
if (forParam.compare("CMS") == 0 && m_cmsStatus == tvERROR_OPERATION_NOT_SUPPORTED) {
17671766
generateStorageIdentifierCMS(key, forParam, indexInfo);
17681767
}
17691768
else if (forParam.compare("WhiteBalance") == 0) {
1770-
generateStorageIdentifierWB(key, forParam, indexInfo);
1769+
generateStorageIdentifierWB(key, forParam, indexInfo);
17711770
}
17721771
else {
17731772
generateStorageIdentifierV2(key, forParam, indexInfo);
@@ -2875,8 +2874,12 @@ namespace Plugin {
28752874
key += AVOUTPUT_GENERIC_STRING_RFC_PARAM;
28762875
key += STRING_SOURCE + convertSourceIndexToStringV2(info.sourceIndex) + "." +
28772876
STRING_PICMODE + convertPictureIndexToStringV2(info.pqmodeIndex) + "." +
2878-
STRING_FORMAT + convertVideoFormatToStringV2(info.formatIndex) + "." +
2879-
forParam;
2877+
STRING_FORMAT + convertVideoFormatToStringV2(info.formatIndex) + ".";
2878+
if( forParam == "CMS")
2879+
key += STRING_COLOR+getCMSColorStringFromEnum((tvDataComponentColor_t)info.colorIndex)+std::string(".")+STRING_COMPONENT+getCMSComponentStringFromEnum((tvComponentType_t)info.componentIndex)+std::string(".");
2880+
2881+
key += forParam;
2882+
28802883
return tvERROR_NONE;
28812884
}
28822885

@@ -3351,23 +3354,17 @@ namespace Plugin {
33513354
const JsonObject& parameters,
33523355
tvPQParameterIndex_t pqParamIndex, int level)
33533356
{
3354-
#if DEBUG
3355-
LOGINFO("Entry %s: Action: %s, Param: %s, Level: %d", __FUNCTION__, action.c_str(), tr181ParamName.c_str(), level);
3356-
#endif
3357+
33573358
std::vector<tvConfigContext_t> validContexts = getValidContextsFromParameters(parameters, tr181ParamName);
33583359
if (validContexts.empty()) {
33593360
LOGWARN("%s: No valid contexts found for parameters", __FUNCTION__);
33603361
return (int)tvERROR_GENERAL;
33613362
}
33623363
if (validContexts.size() == 1){
3363-
#if DEBUG
3364-
LOGINFO("Processing immediately");
3365-
#endif
3364+
33663365
return updateAVoutputTVParamV2Implementation(action, tr181ParamName, parameters, pqParamIndex, level);
33673366
} else {
3368-
#if DEBUG
3369-
LOGINFO("Queuing for background processing - no current values involved");
3370-
#endif
3367+
33713368
// Capture parameters by value for thread safety
33723369
std::lock_guard<std::mutex> lock(queueMutex);
33733370
paramUpdateQueue.push([this, action, tr181ParamName, parameters, pqParamIndex, level]() {
@@ -3384,36 +3381,54 @@ namespace Plugin {
33843381
const JsonObject& parameters,
33853382
tvPQParameterIndex_t pqParamIndex,int level)
33863383
{
3387-
#if DEBUG
3384+
33883385
LOGINFO("Entry %s: Action: %s, Param: %s, Level: %d", __FUNCTION__, action.c_str(), tr181ParamName.c_str(), level);
3389-
#endif
3386+
33903387
int ret = 0;
33913388
const bool isSet = (action == "set");
33923389
const bool isReset = (action == "reset");
33933390
const bool isSync = (action == "sync");
33943391

33953392
std::vector<tvConfigContext_t> validContexts = getValidContextsFromParameters(parameters, tr181ParamName);
3396-
#if DEBUG
3393+
std::vector<std::string> colors, components;
3394+
33973395
LOGINFO("%s: Number of validContexts = %zu", __FUNCTION__, validContexts.size());
3398-
#endif
3396+
33993397
if (validContexts.empty()) {
34003398
LOGWARN("%s: No valid contexts found for parameters", __FUNCTION__);
34013399
return (int)tvERROR_GENERAL;
34023400
}
34033401
if (tr181ParamName == "CMS") {
3404-
JsonArray colorArray = getJsonArrayIfArray(parameters, "color");
3405-
JsonArray componentArray = getJsonArrayIfArray(parameters, "component");
3406-
3407-
std::vector<std::string> colors, components;
3402+
if ( isReset )
3403+
{
3404+
JsonArray colorArray = getJsonArrayIfArray(parameters, "color");
3405+
JsonArray componentArray = getJsonArrayIfArray(parameters, "component");
34083406

3409-
for (size_t i = 0; i < colorArray.Length(); ++i)
3410-
colors.emplace_back(colorArray[i].String());
3407+
for (size_t i = 0; i < colorArray.Length(); ++i)
3408+
colors.emplace_back(colorArray[i].String());
34113409

3412-
for (size_t i = 0; i < componentArray.Length(); ++i)
3413-
components.emplace_back(componentArray[i].String());
3410+
for (size_t i = 0; i < componentArray.Length(); ++i)
3411+
components.emplace_back(componentArray[i].String());
3412+
}
3413+
else if( isSet)
3414+
{
3415+
colors.emplace_back(parameters.HasLabel("color") ? parameters["color"].String() : "");
3416+
components.emplace_back(parameters.HasLabel("component") ? parameters["component"].String() : "");
3417+
}
3418+
else if(isSync)
3419+
{
3420+
colors = m_cmsColorList;
3421+
components = m_cmsComponentList;
3422+
}
34143423

3415-
if (colors.empty()) colors.push_back("Global");
3416-
if (components.empty()) components.push_back("Global");
3424+
if (colors.empty())
3425+
{
3426+
colors.push_back("Global");
3427+
}
3428+
if (components.empty())
3429+
{
3430+
components.push_back("Global");
3431+
}
34173432

34183433
if (colors.size() == 1 && colors[0] == "Global")
34193434
colors = m_cmsColorList;
@@ -3462,10 +3477,9 @@ namespace Plugin {
34623477
paramIndex.colorIndex = static_cast<uint8_t>(colorValue);
34633478
paramIndex.colorTempIndex = 0;
34643479
paramIndex.controlIndex = 0;
3465-
34663480
int value = 0;
34673481
if (isReset) {
3468-
ret |= updateAVoutputTVParamToHAL(tr181ParamName, paramIndex, 0, false);
3482+
ret |= updateAVoutputTVParamToHALV2(tr181ParamName, paramIndex, 0, false);
34693483
level = 0;
34703484
}
34713485

@@ -3486,7 +3500,7 @@ namespace Plugin {
34863500
level);
34873501

34883502
if (isSet) {
3489-
ret |= updateAVoutputTVParamToHAL(tr181ParamName, paramIndex, level, true);
3503+
ret |= updateAVoutputTVParamToHALV2(tr181ParamName, paramIndex, level, true);
34903504
}
34913505
}
34923506
}

0 commit comments

Comments
 (0)