Skip to content

Commit

Permalink
Merge pull request rdkcentral#5086 from aishwariya15/46916_main
Browse files Browse the repository at this point in the history
RDK-46919: RDKServices Update to add setMixerLevels API
  • Loading branch information
ddevad authored Apr 2, 2024
2 parents 5fd17fb + 629fa39 commit d1ac9b9
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 16 deletions.
63 changes: 61 additions & 2 deletions AVInput/AVInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

#include "UtilsJsonRpc.h"
#include "UtilsIarm.h"
#include "host.hpp"

#include "exception.hpp"
#include <vector>
#include <algorithm>

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 5
#define API_VERSION_NUMBER_PATCH 2
#define API_VERSION_NUMBER_MINOR 6
#define API_VERSION_NUMBER_PATCH 0

#define HDMI 0
#define COMPOSITE 1
Expand All @@ -47,6 +48,7 @@
#define AVINPUT_METHOD_GET_EDID_VERSION "getEdidVersion"
#define AVINPUT_METHOD_SET_EDID_ALLM_SUPPORT "setEdid2AllmSupport"
#define AVINPUT_METHOD_GET_EDID_ALLM_SUPPORT "getEdid2AllmSupport"
#define AVINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels"
#define AVINPUT_METHOD_START_INPUT "startInput"
#define AVINPUT_METHOD_STOP_INPUT "stopInput"
#define AVINPUT_METHOD_SCALE_INPUT "setVideoRectangle"
Expand All @@ -62,6 +64,7 @@
#define AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED "gameFeatureStatusUpdate"
#define AVINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED "aviContentTypeUpdate"

static bool isAudioBalanceSet = false;
static int planeType = 0;

using namespace std;
Expand Down Expand Up @@ -217,13 +220,16 @@ void AVInput::RegisterAll()
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_READ_SPD), &AVInput::getSPDWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SET_EDID_VERSION), &AVInput::setEdidVersionWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GET_EDID_VERSION), &AVInput::getEdidVersionWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SET_MIXER_LEVELS), &AVInput::setMixerLevels, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SET_EDID_ALLM_SUPPORT), &AVInput::setEdid2AllmSupportWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GET_EDID_ALLM_SUPPORT), &AVInput::getEdid2AllmSupportWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_START_INPUT), &AVInput::startInput, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_STOP_INPUT), &AVInput::stopInput, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SCALE_INPUT), &AVInput::setVideoRectangleWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SUPPORTED_GAME_FEATURES), &AVInput::getSupportedGameFeatures, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GAME_FEATURE_STATUS), &AVInput::getGameFeatureStatusWrapper, this);
m_primVolume = DEFAULT_PRIM_VOL_LEVEL;
m_inputVolume = DEFAULT_INPUT_VOL_LEVEL;
}

void AVInput::UnregisterAll()
Expand Down Expand Up @@ -402,6 +408,11 @@ uint32_t AVInput::stopInput(const JsonObject& parameters, JsonObject& response)
try
{
planeType = -1;
if (isAudioBalanceSet){
device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,MAX_PRIM_VOL_LEVEL);
device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,DEFAULT_INPUT_VOL_LEVEL);
isAudioBalanceSet = false;
}
if (iType == HDMI) {
device::HdmiInput::getInstance().selectPort(-1);
}
Expand Down Expand Up @@ -1172,6 +1183,54 @@ std::string AVInput::getSPD(int iPort)
return spdbase64;
}

uint32_t AVInput::setMixerLevels(const JsonObject& parameters, JsonObject& response)
{
returnIfParamNotFound(parameters, "primaryVolume");
returnIfParamNotFound(parameters, "inputVolume");

int primVol = 0, inputVol = 0;
try {
primVol = parameters["primaryVolume"].Number();
inputVol = parameters["inputVolume"].Number() ;
} catch(...) {
LOGERR("Incompatible params passed !!!\n");
response["success"] = false;
returnResponse(false);
}

if( (primVol >=0) && (inputVol >=0) ) {
m_primVolume = primVol;
m_inputVolume = inputVol;
}
else {
LOGERR("Incompatible params passed !!!\n");
response["success"] = false;
returnResponse(false);
}
if(m_primVolume > MAX_PRIM_VOL_LEVEL) {
LOGWARN("Primary Volume greater than limit. Set to MAX_PRIM_VOL_LEVEL(100) !!!\n");
m_primVolume = MAX_PRIM_VOL_LEVEL;
}
if(m_inputVolume > DEFAULT_INPUT_VOL_LEVEL) {
LOGWARN("INPUT Volume greater than limit. Set to DEFAULT_INPUT_VOL_LEVEL(100) !!!\n");
m_inputVolume = DEFAULT_INPUT_VOL_LEVEL;
}

LOGINFO("GLOBAL primary Volume=%d input Volume=%d \n",m_primVolume , m_inputVolume );

try{

device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,primVol);
device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,inputVol);
}
catch(...){
LOGWARN("Not setting SoC volume !!!\n");
returnResponse(false);
}
isAudioBalanceSet = true;
returnResponse(true);
}

int setEdid2AllmSupport(int portId, bool allmSupport)
{
bool ret = true;
Expand Down
7 changes: 7 additions & 0 deletions AVInput/AVInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "libIBus.h"
#include "dsTypes.h"

#define DEFAULT_PRIM_VOL_LEVEL 25
#define MAX_PRIM_VOL_LEVEL 100
#define DEFAULT_INPUT_VOL_LEVEL 100

namespace WPEFramework {
namespace Plugin {

Expand All @@ -41,6 +45,8 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC
INTERFACE_ENTRY(PluginHost::IDispatcher)
END_INTERFACE_MAP

int m_primVolume;
int m_inputVolume; //Player Volume
public:
// IPlugin methods
// -------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -78,6 +84,7 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC
uint32_t setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response);
uint32_t getGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t setMixerLevels(const JsonObject& parameters, JsonObject& response);
//End methods

JsonArray getInputDevices(int iType);
Expand Down
33 changes: 26 additions & 7 deletions AVInput/AVInput.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@
]
},
"getEdid2AllmSupport":{
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/AVInputPlugin?id=getEdid2AllmSupport",
"summary": "Returns the EDID ALLM bit value.",
"params": {
"type":"object",
Expand Down Expand Up @@ -445,9 +443,32 @@
}
]
},
"setEdid2AllmSupport": {
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/AVInputPlugin?id=setedid2AllmSupport",
"setAudioMixerLevels": {
"summary": "Sets the audio mixer level for given audio input",
"params": {
"type":"object",
"properties": {
"primaryVolume":{
"summary": "Primary audio input volume",
"type": "integer",
"example": 100
},
"inputVolume":{
"summary": "System audio input volume",
"type": "integer",
"example": 75
}
},
"required": [
"primaryVolume",
"inputVolume"
]
},
"result": {
"$ref": "#/common/result"
}
},
"setEdid2AllmSupport": {
"summary": "Sets an HDMI ALLM bit in EDID.",
"params": {
"type":"object",
Expand Down Expand Up @@ -791,8 +812,6 @@
}
},
"hdmiContentTypeUpdate": {
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/AVInputPlugin?id=hdmiContentTypeUpdate",
"summary": "Triggered whenever AV Infoframe content type changes for an HDMI Input",
"params": {
"type": "object",
Expand Down
4 changes: 4 additions & 0 deletions AVInput/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

##[1.6.0] - 2024-04-02
###Changed
- Added support for Setting the Audio Mixer level for the given audio input

## [1.5.2] - 2024-03-29
### Security
- Resolved security vulnerabilities
Expand Down
4 changes: 4 additions & 0 deletions HdmiInput/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

##[1.3.0] - 2024-04-02
### Changed
- Added support for setting the audio mixer level for given audio input

## [1.2.2] - 2024-03-29
### Security
- Resolved security vulnerabilities
Expand Down
67 changes: 62 additions & 5 deletions HdmiInput/HdmiInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "dsUtl.h"
#include "dsError.h"
#include "dsMgr.h"
#include "host.hpp"

#include <vector>
#include <algorithm>
Expand All @@ -40,6 +41,7 @@
#define HDMIINPUT_METHOD_READ_HDMISPD "getHDMISPD"
#define HDMIINPUT_METHOD_SET_EDID_VERSION "setEdidVersion"
#define HDMIINPUT_METHOD_GET_EDID_VERSION "getEdidVersion"
#define HDMIINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels"
#define HDMIINPUT_METHOD_START_HDMI_INPUT "startHdmiInput"
#define HDMIINPUT_METHOD_STOP_HDMI_INPUT "stopHdmiInput"
#define HDMIINPUT_METHOD_SCALE_HDMI_INPUT "setVideoRectangle"
Expand All @@ -64,16 +66,16 @@
#define registerMethod(...) for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Register<JsonObject, JsonObject>(__VA_ARGS__)

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 2
#define API_VERSION_NUMBER_PATCH 2
#define API_VERSION_NUMBER_MINOR 3
#define API_VERSION_NUMBER_PATCH 0

static int audio_output_delay = 100;
static int video_latency = 20;
#define TVMGR_GAME_MODE_EVENT "gameModeEvent"
static bool lowLatencyMode = false;
#define SERVER_DETAILS "127.0.0.1:9998"
static int planeType = 0;

static bool isAudioBalanceSet = false;
using namespace std;

namespace WPEFramework
Expand Down Expand Up @@ -119,12 +121,14 @@ namespace WPEFramework
registerMethod(HDMIINPUT_METHOD_START_HDMI_INPUT, &HdmiInput::startHdmiInput, this);
registerMethod(HDMIINPUT_METHOD_STOP_HDMI_INPUT, &HdmiInput::stopHdmiInput, this);
registerMethod(HDMIINPUT_METHOD_SCALE_HDMI_INPUT, &HdmiInput::setVideoRectangleWrapper, this);

registerMethod(HDMIINPUT_METHOD_SET_MIXER_LEVELS, &HdmiInput::setMixerLevels, this);
registerMethod(HDMIINPUT_METHOD_SUPPORTED_GAME_FEATURES, &HdmiInput::getSupportedGameFeatures, this);
registerMethod(HDMIINPUT_METHOD_GAME_FEATURE_STATUS, &HdmiInput::getHdmiGameFeatureStatusWrapper, this);
registerMethod(HDMIINPUT_METHOD_GET_AV_LATENCY, &HdmiInput::getAVLatency, this);
registerMethod(HDMIINPUT_METHOD_GET_LOW_LATENCY_MODE, &HdmiInput::getTVLowLatencyMode, this);
}
m_primVolume = DEFAULT_PRIM_VOL_LEVEL;
m_inputVolume = DEFAULT_INPUT_VOL_LEVEL;
}

HdmiInput::~HdmiInput()
{
Expand Down Expand Up @@ -272,6 +276,12 @@ namespace WPEFramework
bool success = true;
try
{
// Restoring the Audio Mixer Levels when the Input is stopped.
if (isAudioBalanceSet){
device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,MAX_PRIM_VOL_LEVEL);
device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,DEFAULT_INPUT_VOL_LEVEL);
isAudioBalanceSet = false;
}
planeType = -1;// plane index when stopping hdmi input
device::HdmiInput::getInstance().selectPort(-1);
}
Expand All @@ -283,6 +293,53 @@ namespace WPEFramework
returnResponse(success);

}
uint32_t HdmiInput::setMixerLevels(const JsonObject& parameters, JsonObject& response)
{
returnIfParamNotFound(parameters, "primaryVolume");
returnIfParamNotFound(parameters, "inputVolume");

int primVol = 0, inputVol = 0;
try {
primVol = parameters["primaryVolume"].Number();
inputVol = parameters["inputVolume"].Number() ;
} catch(...) {
LOGERR("Incompatible params passed !!!\n");
response["success"] = false;
returnResponse(false);
}

if( (primVol >=0) && (inputVol >=0) ) {
m_primVolume = primVol;
m_inputVolume = inputVol;
}
else {
LOGERR("Incompatible params passed !!!\n");
response["success"] = false;
returnResponse(false);
}

if(m_primVolume > MAX_PRIM_VOL_LEVEL) {
LOGWARN("Primary Volume greater than limit. Set to MAX_PRIM_VOL_LEVEL(100) !!!\n");
m_primVolume = MAX_PRIM_VOL_LEVEL;
}
if(m_inputVolume > DEFAULT_INPUT_VOL_LEVEL) {
LOGWARN("Input Volume greater than limit. Set to DEFAULT_INPUT_VOL_LEVEL(100) !!!\n");
m_inputVolume = DEFAULT_INPUT_VOL_LEVEL;
}
LOGINFO("GLOBAL primary Volume=%d input Volume=%d \n",m_primVolume , m_inputVolume );

try{

device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_PRIMARY,primVol);
device::Host::getInstance().setAudioMixerLevels(dsAUDIO_INPUT_SYSTEM,inputVol);
}
catch(...){
LOGWARN("Not setting SoC volume !!!\n");
returnResponse(false);
}
isAudioBalanceSet = true;
returnResponse(true);
}

uint32_t HdmiInput::setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response)
{
Expand Down
8 changes: 7 additions & 1 deletion HdmiInput/HdmiInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "Module.h"
#include "dsTypes.h"

#define DEFAULT_PRIM_VOL_LEVEL 25
#define MAX_PRIM_VOL_LEVEL 100
#define DEFAULT_INPUT_VOL_LEVEL 100

namespace WPEFramework {

namespace Plugin {
Expand All @@ -49,6 +53,8 @@ namespace WPEFramework {

void InitializeIARM();
void DeinitializeIARM();
int m_primVolume;
int m_inputVolume; //Player Volume

//Begin methods
uint32_t getHDMIInputDevicesWrapper(const JsonObject& parameters, JsonObject& response);
Expand All @@ -60,7 +66,7 @@ namespace WPEFramework {
uint32_t getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t startHdmiInput(const JsonObject& parameters, JsonObject& response);
uint32_t stopHdmiInput(const JsonObject& parameters, JsonObject& response);

uint32_t setMixerLevels(const JsonObject& parameters, JsonObject& response);
uint32_t setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response);
uint32_t getHdmiGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response);
Expand Down
Loading

0 comments on commit d1ac9b9

Please sign in to comment.