From 6eef7d3951dbf8aedf252238ed70386233f5454c Mon Sep 17 00:00:00 2001 From: benjaminqcox Date: Fri, 3 Oct 2025 12:49:59 +0100 Subject: [PATCH] RDKTV-38695: Adding missing AVOutput functions Reason for change: Adding in missing AVOutput apis from documentation Test Procedure: As in Jira Risks: None Priority: P1 --- AVOutput/AVOutputTV.cpp | 123 +++++++++++++++++++++++++++++++++- AVOutput/AVOutputTV.h | 5 ++ AVOutput/AVOutputTVHelper.cpp | 33 +++++++++ 3 files changed, 159 insertions(+), 2 deletions(-) diff --git a/AVOutput/AVOutputTV.cpp b/AVOutput/AVOutputTV.cpp index 68c945b55c..f98cdeaa2b 100644 --- a/AVOutput/AVOutputTV.cpp +++ b/AVOutput/AVOutputTV.cpp @@ -358,6 +358,11 @@ namespace Plugin { registerMethod("resetAutoBacklightMode", &AVOutputTV::resetAutoBacklightMode, this); registerMethod("getAutoBacklightModeCaps", &AVOutputTV::getAutoBacklightModeCaps, this); + registerMethod("getFadeDisplayCaps", &AVOutputTV::getFadeDisplayCaps, this); + registerMethod("fadeDisplay", &AVOutputTV::fadeDisplay, this); + registerMethod("getWBMode", &AVOutputTV::getWBMode, this); + registerMethod("setWBMode", &AVOutputTV::setWBMode, this); + LOGINFO("Exit\n"); } @@ -3890,7 +3895,7 @@ namespace Plugin { tvError_t ret = tvERROR_NONE; - if (isPlatformSupport("AutoBacklightMode") != 0) { + if (isPlatformSupport("AutoBacklightMode") != 0) { returnResponse(false); } @@ -3945,7 +3950,121 @@ namespace Plugin { { returnResponse(true); } - } + } + + uint32_t AVOutputTV::getFadeDisplayCaps(const JsonObject& parameters, JsonObject& response) + { + LOGINFO("Entry"); + capVectors_t info; + JsonObject rangeObj; + + tvError_t ret = getParamsCaps("BacklightFade",info); + if(ret != tvERROR_NONE) { + returnResponse(false); + } + + response["platformSupport"] = (info.isPlatformSupportVector[0].compare("true") == 0 ) ? true : false; + response["from"] = stoi(info.rangeVector[0]); + response["to"] = stoi(info.rangeVector[1]); + rangeObj["from"] = stoi(info.rangeVector[2]); + rangeObj["to"] = stoi(info.rangeVector[3]); + response["durationInfo"] = rangeObj; + LOGINFO("Exit\n"); + returnResponse(true); + } + + uint32_t AVOutputTV::fadeDisplay(const JsonObject& parameters, JsonObject& response) + { + LOGINFO("Entry\n"); + std::string from,to,duration; + int fromValue = 0,toValue = 0, durationValue = 0; + + if (isPlatformSupport("BacklightFade") != 0) { + LOGERR("Platform Support (%s) false", __FUNCTION__); + returnResponse(false); + } + from = parameters.HasLabel("from") ? parameters["from"].String() : ""; + if (from.empty() || validateFadeDisplayInputParameter("BacklightFade", "Range", std::stoi(from)) != 0) { + LOGERR("%s: Range validation failed for BacklightFade From\n", __FUNCTION__); + LOGWARN("%s: Using default value, from = 100\n", __FUNCTION__); + fromValue = 100; + } else + fromValue = std::stoi(from); + + to = parameters.HasLabel("to") ? parameters["to"].String() : ""; + if(to.empty() || validateFadeDisplayInputParameter("BacklightFade", "Range", std::stoi(to)) != 0) { + LOGERR("%s: Range validation failed for BacklightFade To\n", __FUNCTION__); + LOGWARN("%s: Using default value, to = 0\n", __FUNCTION__); + toValue = 0; + } else + toValue = std::stoi(to); + + duration = parameters.HasLabel("duration") ? parameters["duration"].String() : ""; + if(duration.empty() || validateFadeDisplayInputParameter("BacklightFade", "Duration", std::stoi(duration)) != 0) { + LOGERR("%s: Range validation failed for BacklightFade Duration\n", __FUNCTION__); + LOGWARN("%s: Using default value, duration = 0\n", __FUNCTION__); + durationValue = 0; + } else + durationValue = std::stoi(duration); + + LOGINFO("from = %d to = %d duration = %d\n" ,fromValue,toValue,durationValue); + tvError_t ret = SetBacklightFade(fromValue,toValue,durationValue); + if(ret != tvERROR_NONE) { + LOGERR("Failed to set BacklightFade \n"); + returnResponse(false); + } + else { + LOGINFO("Exit : backlightFade Success \n"); + returnResponse(true); + } + } + + uint32_t AVOutputTV::getWBMode(const JsonObject& parameters, JsonObject& response) + { + LOGINFO("Entry - Is stubbed api will return 0'\n"); + bool mode = 0; + tvError_t ret = GetCurrentWBCalibrationMode(&mode); + if(ret != tvERROR_NONE) { + LOGERR("Failed to get WBCalibrationMode \n"); + returnResponse(false); + } + else + { + response["wbMode"] = (mode); + returnResponse(true); + } + } + + uint32_t AVOutputTV::setWBMode(const JsonObject& parameters, JsonObject& response) + { + LOGINFO("Entry\n"); + std::string value; + tvError_t ret = tvERROR_NONE; + bool mode = 0; + if(parameters.HasLabel("mode")) { + value = parameters["mode"].String(); + if(value == "true") { + mode = 1; + } else if(value == "false") { + mode = 0; + } else { + LOGERR("Invalid WBMode param value\n"); + returnResponse(false); + } + ret = EnableWBCalibrationMode(mode); + if(ret != tvERROR_NONE) { + LOGERR("enableWBmode failed\n"); + returnResponse(false); + } + else{ + LOGINFO("setWBmode to %s\n", mode ? "true" : "false"); + returnResponse(true); + } + } else { + LOGERR("Invalid Param\n"); + returnResponse(false); + } + } uint32_t AVOutputTV::getVideoSource(const JsonObject& parameters,JsonObject& response) { diff --git a/AVOutput/AVOutputTV.h b/AVOutput/AVOutputTV.h index f442f91157..f04edc3c47 100644 --- a/AVOutput/AVOutputTV.h +++ b/AVOutput/AVOutputTV.h @@ -204,6 +204,7 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(getHDRMode) DECLARE_JSON_RPC_METHOD(get2PointWB) DECLARE_JSON_RPC_METHOD(getAutoBacklightMode) + DECLARE_JSON_RPC_METHOD(getWBMode) /*Get Capability API's*/ @@ -227,6 +228,7 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(get2PointWBCaps) DECLARE_JSON_RPC_METHOD(getHDRModeCaps) DECLARE_JSON_RPC_METHOD(getAutoBacklightModeCaps) + DECLARE_JSON_RPC_METHOD(getFadeDisplayCaps) /*Set API's*/ DECLARE_JSON_RPC_METHOD(setBacklight) @@ -247,6 +249,8 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(set2PointWB ) DECLARE_JSON_RPC_METHOD(signalFilmMakerMode) DECLARE_JSON_RPC_METHOD(setAutoBacklightMode) + DECLARE_JSON_RPC_METHOD(fadeDisplay) + DECLARE_JSON_RPC_METHOD(setWBMode) /*Reset API's*/ DECLARE_JSON_RPC_METHOD(resetBacklight) @@ -289,6 +293,7 @@ class AVOutputTV : public AVOutputBase { void spliltCapablities( capVectors_t& vectorInfo, capDetails_t stringInfo); void spliltStringsAndConvertToSet( std::string pqmodeInfo,std::string formatInfo,std::string sourceInfo,std::set &pqmode, std::set &format, std::set &source); int validateIntegerInputParameter(std::string param, int inputValue); + int validateFadeDisplayInputParameter(std::string param, std::string name, int inputValue); int fetchCapablities(string pqparam, capDetails_t& info); int validateInputParameter(std::string param, std::string inputValue); int validateWBParameter(std::string param,std::string control,int inputValue); diff --git a/AVOutput/AVOutputTVHelper.cpp b/AVOutput/AVOutputTVHelper.cpp index cf16d4ff38..e387729457 100644 --- a/AVOutput/AVOutputTVHelper.cpp +++ b/AVOutput/AVOutputTVHelper.cpp @@ -615,6 +615,30 @@ namespace Plugin { return 0; } + int AVOutputTV::validateFadeDisplayInputParameter(std::string param, std::string name, int inputValue) + { + capVectors_t info; + tvError_t ret = getParamsCaps(param, info); + + if (ret != tvERROR_NONE) { + LOGERR("Failed to fetch the range capability[%s] \n", param.c_str()); + return -1; + } + if ( (name == "Range")){ + if (inputValue < std::stoi(info.rangeVector[0]) || inputValue > std::stoi(info.rangeVector[1])){ + LOGERR("wrong Input Value[%d]", inputValue); + return -1; + } + } + if ( (name == "Duration")){ + if (inputValue > std::stoi(info.rangeVector[2]) || inputValue < std::stoi(info.rangeVector[3])){ + LOGERR("wrong Input Value[%d]", inputValue); + return -1; + } + } + return 0; + } + int AVOutputTV::fetchCapablities(string pqparam, capDetails_t& info) { capVectors_t vectorInfo; @@ -2349,6 +2373,15 @@ namespace Plugin { info.range += ","+inFile.Get(configString); configString = param + ".range_Offset_to"; info.range += ","+inFile.Get(configString); + } else if ( (param == "BacklightFade")) { + configString = param + ".range_from"; + info.range = inFile.Get(configString); + configString = param + ".range_to"; + info.range += ","+inFile.Get(configString); + configString = param + ".duration_from"; + info.range += ","+inFile.Get(configString); + configString = param + ".duration_to"; + info.range += ","+inFile.Get(configString); } else { configString = param + ".range_from"; info.range = inFile.Get(configString);