Skip to content

Commit a685c65

Browse files
committed
RDKEMW-5197 : zoomMode and resetBLackScreen issue
1 parent 9093339 commit a685c65

File tree

3 files changed

+191
-70
lines changed

3 files changed

+191
-70
lines changed

AVOutput/AVOutputTV.cpp

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ namespace Plugin {
523523
}
524524

525525
// Shared zoom mode mappings
526-
static const std::unordered_map<tvDisplayMode_t, std::string> zoomModeReverseMap = {
526+
static const std::unordered_map<int, std::string> zoomModeReverseMap = {
527527
{tvDisplayMode_16x9, "TV 16X9 STRETCH"},
528528
{tvDisplayMode_4x3, "TV 4X3 PILLARBOX"},
529529
{tvDisplayMode_NORMAL, "TV NORMAL"},
@@ -532,7 +532,7 @@ namespace Plugin {
532532
{tvDisplayMode_ZOOM, "TV ZOOM"},
533533
{tvDisplayMode_FULL, "TV FULL"}
534534
};
535-
static const std::unordered_map<std::string, tvDisplayMode_t> zoomModeMap = {
535+
static const std::unordered_map<std::string, int> zoomModeMap = {
536536
{"TV 16X9 STRETCH", tvDisplayMode_16x9},
537537
{"TV 4X3 PILLARBOX", tvDisplayMode_4x3},
538538
{"TV NORMAL", tvDisplayMode_NORMAL},
@@ -1355,37 +1355,15 @@ namespace Plugin {
13551355
}
13561356
else
13571357
{
1358-
std::string value = parameters.HasLabel("zoomMode") ? parameters["zoomMode"].String() : "";
1359-
returnIfParamNotFound(parameters, "zoomMode");
1360-
1361-
auto it = zoomModeMap.find(value);
1362-
if (it == zoomModeMap.end()) {
1363-
LOGERR("Invalid zoom mode: %s. Not in supported options.", value.c_str());
1364-
returnResponse(false);
1365-
}
1366-
tvDisplayMode_t mode = it->second;
1367-
tvError_t ret = setAspectRatioZoomSettings(mode);
1368-
if (ret != tvERROR_NONE) {
1369-
returnResponse(false);
1370-
}
1371-
else
1372-
{
1373-
// Save DisplayMode to local store and ssm_data
1374-
int retval = updateAVoutputTVParamV2("set", "AspectRatio", parameters, PQ_PARAM_ASPECT_RATIO, mode);
1375-
if (retval != 0) {
1376-
LOGERR("Failed to Save DisplayMode to ssm_data\n");
1377-
returnResponse(false);
1378-
}
1379-
tr181ErrorCode_t err = setLocalParam(rfc_caller_id, AVOUTPUT_ASPECTRATIO_RFC_PARAM, value.c_str());
1380-
if (err != tr181Success) {
1381-
LOGERR("setLocalParam for %s Failed : %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, getTR181ErrorString(err));
1382-
returnResponse(false);
1383-
} else {
1384-
LOGINFO("setLocalParam for %s Successful, Value: %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, value.c_str());
1385-
}
1386-
LOGINFO("Exit : SetAspectRatio() value : %s\n", value.c_str());
1387-
returnResponse(true);
1388-
}
1358+
return setContextPQParam(
1359+
parameters, response,
1360+
"zoomMode",
1361+
"ZoomMode",
1362+
tvDisplayMode_MAX - 1,
1363+
PQ_PARAM_ASPECT_RATIO,
1364+
[this](tvVideoSrcType_t /*src*/, tvPQModeIndex_t /*mode*/, tvVideoFormatType_t /*fmt*/, int val) {
1365+
return setAspectRatioZoomSettings(static_cast<tvDisplayMode_t>(val));}
1366+
);
13891367
}
13901368
}
13911369

@@ -1443,33 +1421,48 @@ namespace Plugin {
14431421
uint32_t AVOutputTV::resetZoomMode(const JsonObject& parameters, JsonObject& response)
14441422
{
14451423
LOGINFO("Entry\n");
1446-
capDetails_t inputInfo;
1447-
tvError_t ret = tvERROR_NONE;
1424+
if(m_aspectRatioStatus == tvERROR_OPERATION_NOT_SUPPORTED)
1425+
{
1426+
capDetails_t inputInfo;
1427+
tvError_t ret = tvERROR_NONE;
14481428

1449-
if (parsingSetInputArgument(parameters, "AspectRatio",inputInfo) != 0) {
1450-
LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__);
1451-
returnResponse(false);
1452-
}
1429+
if (parsingSetInputArgument(parameters, "AspectRatio",inputInfo) != 0) {
1430+
LOGERR("%s: Failed to parse the input arguments \n", __FUNCTION__);
1431+
returnResponse(false);
1432+
}
14531433

1454-
if( !isCapablityCheckPassed( "AspectRatio",inputInfo )) {
1455-
LOGERR("%s: CapablityCheck failed for AspectRatio\n", __FUNCTION__);
1456-
returnResponse(false);
1457-
}
1434+
if( !isCapablityCheckPassed( "AspectRatio",inputInfo )) {
1435+
LOGERR("%s: CapablityCheck failed for AspectRatio\n", __FUNCTION__);
1436+
returnResponse(false);
1437+
}
14581438

1459-
tr181ErrorCode_t err = clearLocalParam(rfc_caller_id,AVOUTPUT_ASPECTRATIO_RFC_PARAM);
1460-
if ( err != tr181Success ) {
1461-
LOGERR("clearLocalParam for %s Failed : %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, getTR181ErrorString(err));
1462-
ret = tvERROR_GENERAL;
1463-
}
1464-
else {
1465-
ret = setDefaultAspectRatio(inputInfo.pqmode,inputInfo.source,inputInfo.format);
1466-
}
1467-
if(ret != tvERROR_NONE) {
1468-
returnResponse(false);
1439+
tr181ErrorCode_t err = clearLocalParam(rfc_caller_id,AVOUTPUT_ASPECTRATIO_RFC_PARAM);
1440+
if ( err != tr181Success ) {
1441+
LOGERR("clearLocalParam for %s Failed : %s\n", AVOUTPUT_ASPECTRATIO_RFC_PARAM, getTR181ErrorString(err));
1442+
ret = tvERROR_GENERAL;
1443+
}
1444+
else {
1445+
ret = setDefaultAspectRatio(inputInfo.pqmode,inputInfo.source,inputInfo.format);
1446+
}
1447+
if(ret != tvERROR_NONE) {
1448+
returnResponse(false);
1449+
}
1450+
else {
1451+
LOGINFO("Exit : resetDefaultAspectRatio()\n");
1452+
returnResponse(true);
1453+
}
14691454
}
1470-
else {
1471-
LOGINFO("Exit : resetDefaultAspectRatio()\n");
1472-
returnResponse(true);
1455+
else
1456+
{
1457+
bool success = resetEnumPQParamToDefault(
1458+
parameters,
1459+
"ZoomMode",
1460+
PQ_PARAM_ASPECT_RATIO,
1461+
zoomModeReverseMap,
1462+
[this](int intVal, const std::unordered_map<int, std::string>& valueMap) -> tvError_t {
1463+
return setAspectRatioZoomSettings(static_cast<tvDisplayMode_t>(intVal));
1464+
});
1465+
returnResponse(success);
14731466
}
14741467
}
14751468

@@ -1673,6 +1666,14 @@ namespace Plugin {
16731666
}
16741667
enumValue = it->second;
16751668
}
1669+
else if (pqParamType == PQ_PARAM_ASPECT_RATIO) {
1670+
auto it = zoomModeMap.find(valueStr);
1671+
if (it == zoomModeMap.end()) {
1672+
LOGERR("Invalid ZoomMode value: %s", valueStr.c_str());
1673+
returnResponse(false);
1674+
}
1675+
enumValue = it->second;
1676+
}
16761677
else {
16771678
// default: numeric parsing
16781679
try {
@@ -1947,7 +1948,7 @@ namespace Plugin {
19471948
inputInfo.source = "Current";
19481949
inputInfo.format = "Current";
19491950

1950-
if (getParamIndex(paramName, inputInfo, indexInfo) == 0 &&
1951+
if (getParamIndexV2(paramName, inputInfo, indexInfo) == 0 &&
19511952
getLocalparam(paramName, indexInfo, intVal, pqIndex) == 0)
19521953
{
19531954
LOGINFO("%s: getLocalparam success for %s [format=%d, source=%d, mode=%d] → value=%d\n",
@@ -2003,7 +2004,7 @@ namespace Plugin {
20032004
inputInfo.source = "Current";
20042005
inputInfo.format = "Current";
20052006

2006-
if (getParamIndex(paramName, inputInfo, indexInfo) == 0 &&
2007+
if (getParamIndexV2(paramName, inputInfo, indexInfo) == 0 &&
20072008
getLocalparam(paramName, indexInfo, level, pqIndex) == 0)
20082009
{
20092010
LOGINFO("%s: getLocalparam success for %s: format=%d, source=%d, mode=%d, value=%d\n",
@@ -2060,7 +2061,7 @@ namespace Plugin {
20602061
inputInfo.source = "Current";
20612062
inputInfo.format = "Current";
20622063

2063-
if (getParamIndex(paramName, inputInfo, indexInfo) == 0 &&
2064+
if (getParamIndexV2(paramName, inputInfo, indexInfo) == 0 &&
20642065
getLocalparam(paramName, indexInfo, level, pqIndex) == 0)
20652066
{
20662067
LOGINFO("%s: getLocalparam success for %s: format=%d, source=%d, mode=%d, value=%d\n",

AVOutput/AVOutputTV.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class AVOutputTV : public AVOutputBase {
328328
int getDolbyModeIndex(const char * dolbyMode);
329329
int getHDRModeIndex(const std::string HDRMode, const std::string format,tvDolbyMode_t &value);
330330
tvDimmingMode_t getDimmingModeIndex(string mode);
331+
int getParamIndexV2(std::string param, capDetails_t& paramInfo, paramIndex_t& indexInfo);
331332

332333
bool isIncluded(const std::set<string> set1,const std::set<string> set2);
333334
bool isSetRequired(std::string pqmode,std::string source,std::string format);
@@ -428,14 +429,14 @@ class AVOutputTV : public AVOutputBase {
428429
tvError_t setAspectRatioZoomSettings(tvDisplayMode_t mode);
429430
tvError_t setDefaultAspectRatio(std::string pqmode="none",std::string format="none",std::string source="none");
430431
template <typename T>
431-
static int getEnumFromString(const std::map<std::string, int>& reverseMap, const std::string& key, T defaultVal) {
432+
static int getEnumFromString(const std::unordered_map<std::string, int>& reverseMap, const std::string& key, T defaultVal) {
432433
auto it = reverseMap.find(key);
433434
return (it != reverseMap.end()) ? it->second : defaultVal;
434435
}
435436

436-
static const std::map<int, std::string> pqModeMap;
437-
static const std::map<int, std::string> videoFormatMap;
438-
static const std::map<int, std::string> videoSrcMap;
437+
static const std::unordered_map<int, std::string> pqModeMap;
438+
static const std::unordered_map<int, std::string> videoFormatMap;
439+
static const std::unordered_map<int, std::string> videoSrcMap;
439440
static const std::unordered_map<int, std::string> backlightModeMap;
440441

441442
static std::unordered_map<std::string, tvPQModeIndex_t> pqModeReverseMap;

0 commit comments

Comments
 (0)