diff --git a/.github/workflows/L1-tests.yml b/.github/workflows/L1-tests.yml index f5dfb136..0b5cfccd 100755 --- a/.github/workflows/L1-tests.yml +++ b/.github/workflows/L1-tests.yml @@ -443,7 +443,6 @@ jobs: -DHAS_FRONT_PANEL=ON -DRDK_SERVICES_L1_TEST=ON -DPLUGIN_AVINPUT=ON - -DPLUGIN_HDMIINPUT=ON -DPLUGIN_HDCPPROFILE=ON -DPLUGIN_HDMICECSOURCE=ON -DPLUGIN_HDMICECSINK=ON @@ -521,7 +520,6 @@ jobs: -DCMAKE_BUILD_TYPE=Debug -DDS_FOUND=ON -DPLUGIN_AVINPUT=ON - -DPLUGIN_HDMIINPUT=ON -DPLUGIN_HDCPPROFILE=ON -DPLUGIN_HDMICECSOURCE=ON -DPLUGIN_HDMICECSINK=ON diff --git a/CMakeLists.txt b/CMakeLists.txt index df70686a..6a222334 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,10 +64,6 @@ if(PLUGIN_HDCPPROFILE) add_subdirectory(HdcpProfile) endif() -if(PLUGIN_HDMIINPUT) - add_subdirectory(HdmiInput) -endif() - if(WPEFRAMEWORK_CREATE_IPKG_TARGETS) set(CPACK_GENERATOR "DEB") diff --git a/HdmiInput/CHANGELOG.md b/HdmiInput/CHANGELOG.md deleted file mode 100644 index 3e73c318..00000000 --- a/HdmiInput/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Changelog - -All notable changes to this RDK Service will be documented in this file. - -* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. - -* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: - * **Added** for new features. - * **Changed** for changes in existing functionality. - * **Deprecated** for soon-to-be removed features. - * **Removed** for now removed features. - * **Fixed** for any bug fixes. - * **Security** in case of vulnerabilities. - -* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. - -## [1.4.0] - 2025-02-17 -### Added -- Added support for Getting the Maximum HDMI Compatibility version for the given port. - -## [1.0.0] - 2025-02-17 -### Added -- Add CHANGELOG - -### Change -- Reset API version to 1.0.0 -- Change README to inform how to update changelog and API version diff --git a/HdmiInput/CMakeLists.txt b/HdmiInput/CMakeLists.txt deleted file mode 100644 index b5d667a4..00000000 --- a/HdmiInput/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set(PLUGIN_NAME HdmiInput) -set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) - -set(PLUGIN_HDMIINPUT_STARTUPORDER "" CACHE STRING "To configure startup order of HdmiInput plugin") - -find_package(${NAMESPACE}Plugins REQUIRED) -if (USE_THUNDER_R4) - find_package(${NAMESPACE}COM REQUIRED) -else () - find_package(${NAMESPACE}Protocols REQUIRED) -endif (USE_THUNDER_R4) - -add_library(${MODULE_NAME} SHARED - HdmiInput.cpp - Module.cpp - ) - -set_target_properties(${MODULE_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED YES) - -target_compile_definitions(${MODULE_NAME} PRIVATE MODULE_NAME=Plugin_${PLUGIN_NAME}) - -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -if (USE_THUNDER_R4) -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}COM::${NAMESPACE}COM) -else () -target_link_libraries(${MODULE_NAME} PRIVATE ${NAMESPACE}Protocols::${NAMESPACE}Protocols) -endif (USE_THUNDER_R4) - - -find_package(DS) -find_package(IARMBus) - -target_include_directories(${MODULE_NAME} PRIVATE ${DS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS}) -target_include_directories(${MODULE_NAME} PRIVATE ../helpers) - -set_source_files_properties(HdmiInput.cpp PROPERTIES COMPILE_FLAGS "-fexceptions") - -target_link_libraries(${MODULE_NAME} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES} ) - -install(TARGETS ${MODULE_NAME} - DESTINATION lib/${STORAGE_DIRECTORY}/plugins) - -write_config(${PLUGIN_NAME}) diff --git a/HdmiInput/HdmiInput.conf.in b/HdmiInput/HdmiInput.conf.in deleted file mode 100644 index e16bde27..00000000 --- a/HdmiInput/HdmiInput.conf.in +++ /dev/null @@ -1,4 +0,0 @@ -precondition = ["Platform"] -callsign = "org.rdk.HdmiInput" -autostart = "false" -startuporder = "@PLUGIN_HDMIINPUT_STARTUPORDER@" diff --git a/HdmiInput/HdmiInput.config b/HdmiInput/HdmiInput.config deleted file mode 100644 index 2b918b14..00000000 --- a/HdmiInput/HdmiInput.config +++ /dev/null @@ -1,7 +0,0 @@ -set (autostart false) -set (preconditions Platform) -set (callsign "org.rdk.HdmiInput") - -if(PLUGIN_HDMIINPUT_STARTUPORDER) -set (startuporder ${PLUGIN_HDMIINPUT_STARTUPORDER}) -endif() diff --git a/HdmiInput/HdmiInput.cpp b/HdmiInput/HdmiInput.cpp deleted file mode 100644 index ef53a03a..00000000 --- a/HdmiInput/HdmiInput.cpp +++ /dev/null @@ -1,1454 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "HdmiInput.h" -#include "UtilsJsonRpc.h" -#include "UtilsIarm.h" - -#include "hdmiIn.hpp" -#include "exception.hpp" -#include "dsUtl.h" -#include "dsError.h" -#include "dsMgr.h" -#include "host.hpp" - -#include -#include - -#define HDMI_HOT_PLUG_EVENT_CONNECTED 0 -#define HDMI_HOT_PLUG_EVENT_DISCONNECTED 1 - -#define HDMIINPUT_METHOD_GET_HDMI_INPUT_DEVICES "getHDMIInputDevices" -#define HDMIINPUT_METHOD_WRITE_EDID "writeEDID" -#define HDMIINPUT_METHOD_READ_EDID "readEDID" -#define HDMIINPUT_METHOD_READ_RAWHDMISPD "getRawHDMISPD" -#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" -#define HDMIINPUT_METHOD_SUPPORTED_GAME_FEATURES "getSupportedGameFeatures" -#define HDMIINPUT_METHOD_GAME_FEATURE_STATUS "getHdmiGameFeatureStatus" - -#define HDMIINPUT_EVENT_ON_DEVICES_CHANGED "onDevicesChanged" -#define HDMIINPUT_EVENT_ON_SIGNAL_CHANGED "onSignalChanged" -#define HDMIINPUT_EVENT_ON_STATUS_CHANGED "onInputStatusChanged" -#define HDMIINPUT_EVENT_ON_VIDEO_MODE_UPDATED "videoStreamInfoUpdate" -#define HDMIINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED "hdmiGameFeatureStatusUpdate" -#define HDMIINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED "hdmiContentTypeUpdate" -#define HDMIINPUT_METHOD_GET_LOW_LATENCY_MODE "getTVLowLatencyMode" -#define HDMIINPUT_METHOD_GET_AV_LATENCY "getAVLatency" -#define HDMIINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion" - -#define HDMICECSINK_CALLSIGN "org.rdk.HdmiCecSink" -#define HDMICECSINK_CALLSIGN_VER HDMICECSINK_CALLSIGN".1" -#define TVSETTINGS_CALLSIGN "org.rdk.tv.ControlSettings" -#define TVSETTINGS_CALLSIGN_VER TVSETTINGS_CALLSIGN".2" - -// TODO: remove this -#define registerMethod(...) for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Register(__VA_ARGS__) - -#define API_VERSION_NUMBER_MAJOR 1 -#define API_VERSION_NUMBER_MINOR 4 -#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 -{ - namespace { - - static Plugin::Metadata metadata( - // Version (Major, Minor, Patch) - API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, - // Preconditions - {}, - // Terminations - {}, - // Controls - {} - ); - } - - namespace Plugin - { - SERVICE_REGISTRATION(HdmiInput, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); - - HdmiInput* HdmiInput::_instance = nullptr; - - HdmiInput::HdmiInput() - : PluginHost::JSONRPC() - { - HdmiInput::_instance = this; - - m_tv_client = nullptr; - m_client = nullptr; - //InitializeIARM(); - - CreateHandler({2}); - - registerMethod(HDMIINPUT_METHOD_GET_HDMI_INPUT_DEVICES, &HdmiInput::getHDMIInputDevicesWrapper, this); - registerMethod(HDMIINPUT_METHOD_WRITE_EDID, &HdmiInput::writeEDIDWrapper, this); - registerMethod(HDMIINPUT_METHOD_READ_EDID, &HdmiInput::readEDIDWrapper, this); - registerMethod(HDMIINPUT_METHOD_READ_RAWHDMISPD, &HdmiInput::getRawHDMISPDWrapper, this); - registerMethod(HDMIINPUT_METHOD_READ_HDMISPD, &HdmiInput::getHDMISPDWrapper, this); - registerMethod(HDMIINPUT_METHOD_SET_EDID_VERSION, &HdmiInput::setEdidVersionWrapper, this); - registerMethod(HDMIINPUT_METHOD_GET_EDID_VERSION, &HdmiInput::getEdidVersionWrapper, this); - 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); - registerMethod(HDMIINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION, &HdmiInput::getHdmiVersionWrapper, this); - m_primVolume = DEFAULT_PRIM_VOL_LEVEL; - m_inputVolume = DEFAULT_INPUT_VOL_LEVEL; - } - - HdmiInput::~HdmiInput() - { - } - - const string HdmiInput::Initialize(PluginHost::IShell * service ) - { - LOGINFO("Entering HdmiInput::Initialize"); - ASSERT(service != nullptr); - ASSERT(m_service == nullptr); - - m_service = service; - m_service->AddRef(); - - HdmiInput::_instance = this; - InitializeIARM(); - - subscribeForTvMgrEvent("gameModeEvent"); - LOGINFO("Exiting HdmiInput::Initialize"); - return (string()); - } - - uint32_t HdmiInput::subscribeForTvMgrEvent(const char* eventName) - { - uint32_t err = Core::ERROR_NONE; - LOGINFO("Attempting to subscribe for event: %s\n", eventName); - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS))); - if (nullptr == m_tv_client) { - getControlSettingsPlugin(); - if (nullptr == m_tv_client) { - LOGERR("JSONRPC: %s: client initialization failed", TVSETTINGS_CALLSIGN_VER); - err = Core::ERROR_UNAVAILABLE; - } - } - - if(err == Core::ERROR_NONE) { - /* Register handlers for Event reception. */ - if(strcmp(eventName, TVMGR_GAME_MODE_EVENT) == 0) { - err =m_tv_client->Subscribe(1000, eventName, &HdmiInput::onGameModeEventHandler, this); - } - else { - LOGERR("Failed to subscribe for %s with code %d", eventName, err); - } - } - return err; - } - - void setResponseArray(JsonObject& response, const char* key, const vector& items) - { - JsonArray arr; - for(auto& i : items) arr.Add(JsonValue(i)); - - response[key] = arr; - - string json; - response.ToString(json); - } - - void HdmiInput::Deinitialize(PluginHost::IShell* service ) - { - ASSERT(service == m_service); - m_service->Release(); - m_service = nullptr; - - HdmiInput::_instance = nullptr; - - DeinitializeIARM(); - } - - void HdmiInput::InitializeIARM() - { - if (Utils::IARM::init()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsHdmiEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, dsHdmiSignalStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsHdmiStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsHdmiVideoModeEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsHdmiGameFeatureStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, dsHdmiAviContentTypeEventHandler) ); - IARM_CHECK( IARM_Bus_RegisterEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY, dsHdmiAVLatencyEventHandler) ); - } - } - - void HdmiInput::DeinitializeIARM() - { - if (Utils::IARM::isConnected()) - { - IARM_Result_t res; - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, dsHdmiEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, dsHdmiSignalStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, dsHdmiStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, dsHdmiVideoModeEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsHdmiGameFeatureStatusEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE,dsHdmiAviContentTypeEventHandler) ); - IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY,dsHdmiAVLatencyEventHandler) ); - } - } - - uint32_t HdmiInput::startHdmiInput(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - - string sPortId = parameters["portId"].String(); - bool audioMix = parameters["requestAudioMix"].Boolean(); - int portId = 0; - bool topMostPlane = parameters["topMost"].Boolean(); - - //planeType = 0 - primary, 1 - secondary video plane type - planeType = 0; - try { - portId = stoi(sPortId); - if (parameters.HasLabel("plane")){ - string sPlaneType = parameters["plane"].String(); - planeType = stoi(sPlaneType); - if(!(planeType == 0 || planeType == 1))// planeType has to be primary(0) or secondary(1) - { - LOGWARN("planeType is invalid\n"); - returnResponse(false); - } - } - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - bool success = true; - try - { - device::HdmiInput::getInstance().selectPort(portId,audioMix,planeType,topMostPlane); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(sPortId); - success = false; - } - returnResponse(success); - - } - - uint32_t HdmiInput::stopHdmiInput(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - 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); - } - catch (const device::Exception& err) - { - LOGWARN("HdmiInputService::stopHdmiInput Failed"); - success = false; - } - 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) - { - LOGINFOMETHOD(); - - bool result = true; - if (!parameters.HasLabel("x") && !parameters.HasLabel("y")) - { - result = false; - response["message"] = "please specif coordinates (x,y)"; - } - - if (!parameters.HasLabel("w") && !parameters.HasLabel("h")) - { - result = false; - response["message"] = "please specify window width and height (w,h)"; - } - - if (result) - { - int x = 0; - int y = 0; - int w = 0; - int h = 0; - - try - { - if (parameters.HasLabel("x")) - { - x = std::stoi(parameters["x"].String()); - } - if (parameters.HasLabel("y")) - { - y = std::stoi(parameters["y"].String()); - } - if (parameters.HasLabel("w")) - { - w = std::stoi(parameters["w"].String()); - } - if (parameters.HasLabel("h")) - { - h = std::stoi(parameters["h"].String()); - } - } - catch (const std::exception& err) { - LOGWARN("Invalid paramater X: %s,Y: %s, W: %s, H:%s ", parameters["x"].String().c_str(),parameters["y"].String().c_str(),parameters["w"].String().c_str(),parameters["h"].String().c_str()); - returnResponse(false); - } - - result = setVideoRectangle(x, y, w, h); - if (false == result) { - LOGWARN("HdmiInputService::setVideoRectangle Failed"); - response["message"] = "failed to set scale"; - } - } - - returnResponse(result); - - } - - bool HdmiInput::setVideoRectangle(int x, int y, int width, int height) - { - bool ret = true; - - try - { - device::HdmiInput::getInstance().scaleVideo(x, y, width, height); - } - catch (const device::Exception& err) - { - ret = false; - } - - return ret; - } - - uint32_t HdmiInput::getHDMIInputDevicesWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - response["devices"] = getHDMIInputDevices(); - - returnResponse(true); - } - - uint32_t HdmiInput::writeEDIDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - int deviceId; - std::string message; - - if (parameters.HasLabel("deviceId") && parameters.HasLabel("message")) - { - getNumberParameter("deviceId", deviceId); - message = parameters["message"].String(); - } - else - { - LOGWARN("Required parameters are not passed"); - returnResponse(false); - } - - - writeEDID(deviceId, message); - returnResponse(true); - - } - - uint32_t HdmiInput::readEDIDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - - string sPortId = parameters.HasLabel("deviceId") ? parameters["deviceId"].String() : "0";; - int portId = 0; - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - string edid = readEDID (portId); - response["EDID"] = edid; - if (edid.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - JsonArray HdmiInput::getHDMIInputDevices() - { - JsonArray list; - try - { - int num = device::HdmiInput::getInstance().getNumberOfInputs(); - if (num > 0) { - int i = 0; - for (i = 0; i < num; i++) { - //Input ID is aleays 0-indexed, continuous number starting 0 - JsonObject hash; - hash["id"] = i; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << i; - hash["locator"] = locator.str(); - hash["connected"] = device::HdmiInput::getInstance().isPortConnected(i) ? "true" : "false"; - LOGWARN("HdmiInputService::getHDMIInputDevices id %d, locator=[%s], connected=[%s]", i, hash["locator"].String().c_str(), hash["connected"].String().c_str()); - list.Add(hash); - } - } - } - catch (const std::exception& e) { - LOGWARN("HdmiInputService::getHDMIInputDevices Failed"); - } - - return list; - } - - void HdmiInput::writeEDID(int deviceId, std::string message) - { - - } - - std::string HdmiInput::readEDID(int iPort) - { - vector edidVec({'u','n','k','n','o','w','n' }); - string edidbase64 = ""; - try - { - vector edidVec2; - device::HdmiInput::getInstance().getEDIDBytesInfo (iPort, edidVec2); - edidVec = edidVec2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(edidVec.size(), (size_t)numeric_limits::max()); - - LOGWARN("HdmiInput::readEDID size:%u edidVec.size:%d", size, (int)edidVec.size()); - - if(edidVec.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return edidbase64; - } - - Core::ToString((uint8_t*)&edidVec[0], size, true, edidbase64); - - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return edidbase64; - } - - /** - * @brief This function is used to translate HDMI input hotplug to - * deviceChanged event. - * - * @param[in] input Number of input port integer. - * @param[in] connection status of input port integer. - */ - void HdmiInput::hdmiInputHotplug( int input , int connect) - { - LOGWARN("hdmiInputHotplug [%d, %d]", input, connect); - - JsonObject params; - params["devices"] = getHDMIInputDevices(); - sendNotify(HDMIINPUT_EVENT_ON_DEVICES_CHANGED, params); - } - - /** - * @brief This function is used to translate HDMI input signal change to - * signalChanged event. - * - * @param[in] port HDMI In port id. - * @param[in] signalStatus signal status of HDMI In port. - */ - void HdmiInput::hdmiInputSignalChange( int port , int signalStatus) - { - LOGWARN("hdmiInputSignalStatus [%d, %d]", port, signalStatus); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << port; - params["locator"] = locator.str(); - - switch (signalStatus) { - case dsHDMI_IN_SIGNAL_STATUS_NOSIGNAL: - params["signalStatus"] = "noSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_UNSTABLE: - params["signalStatus"] = "unstableSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_NOTSUPPORTED: - params["signalStatus"] = "notSupportedSignal"; - break; - - case dsHDMI_IN_SIGNAL_STATUS_STABLE: - params["signalStatus"] = "stableSignal"; - break; - - default: - params["signalStatus"] = "none"; - break; - } - - sendNotify(HDMIINPUT_EVENT_ON_SIGNAL_CHANGED, params); - } - - /** - * @brief This function is used to translate HDMI input status change to - * inputStatusChanged event. - * - * @param[in] port HDMI In port id. - * @param[bool] isPresented HDMI In presentation started/stopped. - */ - void HdmiInput::hdmiInputStatusChange( int port , bool isPresented) - { - LOGWARN("hdmiInputStatus [%d, %d]", port, isPresented); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << port; - params["locator"] = locator.str(); - - if(isPresented) { - params["status"] = "started"; - } - else { - params["status"] = "stopped"; - } - params["plane"] = planeType; - sendNotify(HDMIINPUT_EVENT_ON_STATUS_CHANGED, params); - } - - /** - * @brief This function is used to translate HDMI input video mode change to - * videoStreamInfoUpdate event. - * - * @param[in] port HDMI In port id. - * @param[dsVideoPortResolution_t] video resolution data - */ - void HdmiInput::hdmiInputVideoModeUpdate( int port , dsVideoPortResolution_t resolution) - { - LOGWARN("hdmiInputVideoModeUpdate [%d]", port); - - JsonObject params; - params["id"] = port; - std::stringstream locator; - locator << "hdmiin://localhost/deviceid/" << port; - params["locator"] = locator.str(); - - switch(resolution.pixelResolution) { - case dsVIDEO_PIXELRES_720x480: - params["width"] = 720; - params["height"] = 480; - break; - - case dsVIDEO_PIXELRES_720x576: - params["width"] = 720; - params["height"] = 576; - break; - - case dsVIDEO_PIXELRES_1280x720: - params["width"] = 1280; - params["height"] = 720; - break; - - case dsVIDEO_PIXELRES_1920x1080: - params["width"] = 1920; - params["height"] = 1080; - break; - - case dsVIDEO_PIXELRES_3840x2160: - params["width"] = 3840; - params["height"] = 2160; - break; - - case dsVIDEO_PIXELRES_4096x2160: - params["width"] = 4096; - params["height"] = 2160; - break; - - default: - params["width"] = 1920; - params["height"] = 1080; - break; - } - - params["progressive"] = (!resolution.interlaced); - - switch(resolution.frameRate) { - case dsVIDEO_FRAMERATE_24: - params["frameRateN"] = 24000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_25: - params["frameRateN"] = 25000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_30: - params["frameRateN"] = 30000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_50: - params["frameRateN"] = 50000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_60: - params["frameRateN"] = 60000; - params["frameRateD"] = 1000; - break; - - case dsVIDEO_FRAMERATE_23dot98: - params["frameRateN"] = 24000; - params["frameRateD"] = 1001; - break; - - case dsVIDEO_FRAMERATE_29dot97: - params["frameRateN"] = 30000; - params["frameRateD"] = 1001; - break; - - case dsVIDEO_FRAMERATE_59dot94: - params["frameRateN"] = 60000; - params["frameRateD"] = 1001; - break; - case dsVIDEO_FRAMERATE_100: - params["frameRateN"] = 100000; - params["frameRateD"] = 1000; - break; - case dsVIDEO_FRAMERATE_119dot88: - params["frameRateN"] = 120000; - params["frameRateD"] = 1001; - break; - case dsVIDEO_FRAMERATE_120: - params["frameRateN"] = 120000; - params["frameRateD"] = 1000; - break; - case dsVIDEO_FRAMERATE_200: - params["frameRateN"] = 200000; - params["frameRateD"] = 1000; - break; - case dsVIDEO_FRAMERATE_239dot76: - params["frameRateN"] = 240000; - params["frameRateD"] = 1001; - break; - case dsVIDEO_FRAMERATE_240: - params["frameRateN"] = 240000; - params["frameRateD"] = 100; - break; - default: - params["frameRateN"] = 60000; - params["frameRateD"] = 1000; - break; - } - - sendNotify(HDMIINPUT_EVENT_ON_VIDEO_MODE_UPDATED, params); - } - - void HdmiInput::getHdmiCecSinkPlugin() - { - - if(m_client == nullptr) - { - LOGINFO("getting the hdmicecsink client\n"); - string token; - - // TODO: use interfaces and remove token - auto security = m_service->QueryInterfaceByCallsign("SecurityAgent"); - if (security != nullptr) { - string payload = "http://localhost"; - if (security->CreateToken( - static_cast(payload.length()), - reinterpret_cast(payload.c_str()), - token) - == Core::ERROR_NONE) { - LOGINFO("HdmiInput got security token\n"); - } - else { - LOGINFO("HdmiInput failed to get security token\n"); - } - security->Release(); - } - else { - LOGINFO("No security agent\n"); - } - - string query = "token=" + token; - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998"))); - m_client = new WPEFramework::JSONRPC::LinkType(_T(HDMICECSINK_CALLSIGN_VER), (_T(HDMICECSINK_CALLSIGN_VER)), false, query); - LOGINFO("HdmiInput getHdmiCecSinkPlugin init m_client\n"); - } - } - - void HdmiInput::reportLatencyInfoToHdmiCecSink() - { - - PluginHost::IShell::state state; - if ((getServiceState(m_service, HDMICECSINK_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED)) { - LOGINFO("%s is active", HDMICECSINK_CALLSIGN); - - getHdmiCecSinkPlugin(); - if (!m_client) { - LOGERR("HdmiCecSink Initialisation failed\n"); - } - else { - JsonObject hdmiCecSinkResult; - JsonObject param; - - param["audioOutputDelay"] = std::to_string(audio_output_delay); - param["videoLatency"] = std::to_string(video_latency); - param["lowLatencyMode"] = std::to_string(lowLatencyMode); - param["audioOutputCompensated"] ="3";//hard-coded for now - LOGINFO("latency - Info: %d : %d, %d\n",audio_output_delay,video_latency,lowLatencyMode); - m_client->Invoke(2000, "setLatencyInfo", param, hdmiCecSinkResult); - if (!hdmiCecSinkResult["success"].Boolean()) { - LOGERR("HdmiCecSink Plugin returned error\n"); - } - } - } - else { - LOGERR("HdmiCecSink plugin not ready\n"); - } - - - } - void HdmiInput::dsHdmiAVLatencyEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY == eventId) - { - LOGINFO("received the latency mode change event in dsHdmiAVLatencyEventHandler\n"); - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - audio_output_delay = eventData->data.hdmi_in_av_latency.audio_output_delay; - video_latency= eventData->data.hdmi_in_av_latency.video_latency; - - // HdmiInput::_instance->hdmiInAVLatencyChange(audio_output_delay,video_latency); - LOGINFO("Latency Info Change occurs: AV Latencies -- Report to HdmiCecSink\n"); - HdmiInput::_instance->reportLatencyInfoToHdmiCecSink(); - } - } - - void HdmiInput::onGameModeEventHandler(const JsonObject& parameters) - { - LOGINFO("Entered in onGameModeEventHandler\n"); - lowLatencyMode = parameters["lowLatencyMode"].Boolean(); - LOGINFO("Low Latency Mode : %d\n", lowLatencyMode); - HdmiInput::_instance->reportLatencyInfoToHdmiCecSink(); - } - - void HdmiInput::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmiin_hotplug_port = eventData->data.hdmi_in_connect.port; - int hdmiin_hotplug_conn = eventData->data.hdmi_in_connect.isPortConnected; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event data:%d", hdmiin_hotplug_port); - - HdmiInput::_instance->hdmiInputHotplug(hdmiin_hotplug_port, hdmiin_hotplug_conn ? HDMI_HOT_PLUG_EVENT_CONNECTED : HDMI_HOT_PLUG_EVENT_DISCONNECTED); - } - } - - void HdmiInput::dsHdmiSignalStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_sig_status.port; - int hdmi_in_signal_status = eventData->data.hdmi_in_sig_status.status; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS event port: %d, signal status: %d", hdmi_in_port,hdmi_in_signal_status); - - HdmiInput::_instance->hdmiInputSignalChange(hdmi_in_port, hdmi_in_signal_status); - - } - } - - void HdmiInput::dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_status.port; - bool hdmi_in_status = eventData->data.hdmi_in_status.isPresented; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS event port: %d, started: %d", hdmi_in_port,hdmi_in_status); - - HdmiInput::_instance->hdmiInputStatusChange(hdmi_in_port, hdmi_in_status); - - } - } - - void HdmiInput::dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_video_mode.port; - dsVideoPortResolution_t resolution = {}; - resolution.pixelResolution = eventData->data.hdmi_in_video_mode.resolution.pixelResolution; - resolution.interlaced = eventData->data.hdmi_in_video_mode.resolution.interlaced; - resolution.frameRate = eventData->data.hdmi_in_video_mode.resolution.frameRate; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n", hdmi_in_port,resolution.pixelResolution, resolution.interlaced, resolution.frameRate); - - HdmiInput::_instance->hdmiInputVideoModeUpdate(hdmi_in_port, resolution); - - } - } - - void HdmiInput::dsHdmiGameFeatureStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_allm_mode.port; - bool allm_mode = eventData->data.hdmi_in_allm_mode.allm_mode; - LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS event port: %d, ALLM Mode: %d", hdmi_in_port,allm_mode); - - HdmiInput::_instance->hdmiInputALLMChange(hdmi_in_port, allm_mode); - } - } - - void HdmiInput::hdmiInputALLMChange( int port , bool allm_mode) - { - JsonObject params; - params["id"] = port; - params["gameFeature"] = "ALLM"; - params["mode"] = allm_mode; - - sendNotify(HDMIINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params); - } - - void HdmiInput::dsHdmiAviContentTypeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) - { - if(!HdmiInput::_instance) - return; - - if (IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE == eventId) - { - IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; - int hdmi_in_port = eventData->data.hdmi_in_content_type.port; - int avi_content_type = eventData->data.hdmi_in_content_type.aviContentType; - LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE event port: %d, Content Type : %d", hdmi_in_port,avi_content_type); - HdmiInput::_instance->hdmiInputAviContentTypeChange(hdmi_in_port, avi_content_type); - } - } - - void HdmiInput::hdmiInputAviContentTypeChange( int port , int content_type) - { - JsonObject params; - params["id"] = port; - params["aviContentType"] = content_type; - sendNotify(HDMIINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED, params); - } - - uint32_t HdmiInput::getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - vector supportedFeatures; - try - { - device::HdmiInput::getInstance().getSupportedGameFeatures (supportedFeatures); - for (size_t i = 0; i < supportedFeatures.size(); i++) - { - LOGINFO("Supported Game Feature [%d]: %s\n",(int)i,supportedFeatures.at(i).c_str()); - } - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION0(); - } - - if (supportedFeatures.empty()) { - returnResponse(false); - } - else { - setResponseArray(response, "supportedGameFeatures", supportedFeatures); - returnResponse(true); - } - } - - uint32_t HdmiInput::getHdmiGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response) - { - string sPortId = parameters["portId"].String(); - string sGameFeature = parameters["gameFeature"].String(); - int portId = 0; - - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - returnIfParamNotFound(parameters, "gameFeature"); - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - if (strcmp (sGameFeature.c_str(), "ALLM") == 0) - { - bool allm = getHdmiALLMStatus(portId); - LOGWARN("HdmiInput::getHdmiGameFeatureStatusWrapper ALLM MODE:%d", allm); - response["mode"] = allm; - } - else - { - LOGWARN("HdmiInput::getHdmiGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM"); - response["message"] = "Mode is not supported. Supported mode: ALLM"; - returnResponse(false); - } - returnResponse(true); - } - - bool HdmiInput::getHdmiALLMStatus(int iPort) - { - bool allm = false; - - try - { - device::HdmiInput::getInstance().getHdmiALLMStatus (iPort, &allm); - LOGWARN("HdmiInput::getHdmiALLMStatus ALLM MODE: %d", allm); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return allm; - } - - uint32_t HdmiInput::getRawHDMISPDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - - string sPortId = parameters["portId"].String(); - int portId = 0; - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - string spdInfo = getRawHDMISPD (portId); - response["HDMISPD"] = spdInfo; - if (spdInfo.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - uint32_t HdmiInput::getHDMISPDWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - - string sPortId = parameters["portId"].String(); - int portId = 0; - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - string spdInfo = getHDMISPD (portId); - response["HDMISPD"] = spdInfo; - if (spdInfo.empty()) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - std::string HdmiInput::getRawHDMISPD(int iPort) - { - LOGINFO("HdmiInput::getHDMISPDInfo"); - vector spdVect({'u','n','k','n','o','w','n' }); - std::string spdbase64 = ""; - try - { - LOGWARN("HdmiInput::getHDMISPDInfo"); - vector spdVect2; - device::HdmiInput::getInstance().getHDMISPDInfo(iPort, spdVect2); - spdVect = spdVect2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(spdVect.size(), (size_t)numeric_limits::max()); - - LOGWARN("HdmiInput::getHDMISPD size:%u spdVec.size:%d", size, (int)spdVect.size()); - - if(spdVect.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return spdbase64; - } - - LOGINFO("------------getHDMISPD: "); - for (unsigned int itr =0; itr < spdVect.size(); itr++) { - LOGINFO("%02X ", spdVect[itr]); - } - Core::ToString((uint8_t*)&spdVect[0], size, false, spdbase64); - - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return spdbase64; - } - - std::string HdmiInput::getHDMISPD(int iPort) - { - LOGINFO("HdmiInput::getHDMISPDInfo"); - vector spdVect({'u','n','k','n','o','w','n' }); - std::string spdbase64 = ""; - try - { - LOGWARN("HdmiInput::getHDMISPDInfo"); - vector spdVect2; - device::HdmiInput::getInstance().getHDMISPDInfo(iPort, spdVect2); - spdVect = spdVect2;//edidVec must be "unknown" unless we successfully get to this line - - //convert to base64 - uint16_t size = min(spdVect.size(), (size_t)numeric_limits::max()); - - LOGWARN("HdmiInput::getHDMISPD size:%u spdVec.size:%d", size, (int)spdVect.size()); - - if(spdVect.size() > (size_t)numeric_limits::max()) { - LOGERR("Size too large to use ToString base64 wpe api"); - return spdbase64; - } - - LOGINFO("------------getHDMISPD: "); - for (unsigned int itr =0; itr < spdVect.size(); itr++) { - LOGINFO("%02X ", spdVect[itr]); - } - if (spdVect.size() > 0) { - struct dsSpd_infoframe_st pre; - memcpy(&pre,spdVect.data(),sizeof(struct dsSpd_infoframe_st)); - - char str[200] = {0}; - snprintf(str, sizeof(str), "Packet Type:%02X,Version:%u,Length:%u,vendor name:%s,product des:%s,source info:%02X" -,pre.pkttype,pre.version,pre.length,pre.vendor_name,pre.product_des,pre.source_info); - spdbase64 = str; - } - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return spdbase64; - } - - uint32_t HdmiInput::setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) - { - int portId = 0; - - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - returnIfParamNotFound(parameters, "edidVersion"); - string sPortId = parameters["portId"].String(); - string sVersion = parameters["edidVersion"].String(); - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - int edidVer = -1; - if (strcmp (sVersion.c_str(), "HDMI1.4") == 0) { - edidVer = HDMI_EDID_VER_14; - } - else if (strcmp (sVersion.c_str(), "HDMI2.0") == 0) { - edidVer = HDMI_EDID_VER_20; - } - - if (edidVer < 0) { - returnResponse(false); - } - bool result = setEdidVersion (portId, edidVer); - if (result == false) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - uint32_t HdmiInput::getAVLatency(const JsonObject& parameters, JsonObject& response) - { - int audio_output_delay = 0; - int video_latency = 0; - - LOGINFO("calling HdmiInput::getHdmiDAL_AudioVideoLatency \n"); - try - { - device::HdmiInput::getInstance().getAVLatency(&audio_output_delay,&video_latency); - LOGINFO("HdmiInput::getHdmiDAL_AudioVideoLatency Audio Latency: %d, Video Latency: %d\n", audio_output_delay,video_latency); - response["AudioLatency"] = audio_output_delay; - response["VideoLatency"] = video_latency; - returnResponse(true); - } - catch(const device::Exception& err) - { - std::string api = "getHdmiDAL_AudioVideoLatency"; - LOG_DEVICE_EXCEPTION1(std::string(api)); - response["message"] = "Invalid response from getHdmiDAL_AudioVideoLatency"; - LOGINFO("ERROR:HdmiInput::getHdmiDAL_AudioVideoLatency Audio Latency: %d, Video Latency: %d\n", audio_output_delay,video_latency); - returnResponse(false); - } - - } - uint32_t HdmiInput::getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response) - { - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - string sPortId = parameters["portId"].String(); - int portId = 0; - - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - dsHdmiMaxCapabilityVersion_t hdmiCapVersion = HDMI_COMPATIBILITY_VERSION_14; - - try { - device::HdmiInput::getInstance().getHdmiVersion(portId, &(hdmiCapVersion)); - LOGWARN("HdmiInput::getHdmiVersion Hdmi Version:%d", hdmiCapVersion); - } - catch (const device::Exception& err) { - LOG_DEVICE_EXCEPTION1(std::to_string(portId)); - returnResponse(false); - } - - - switch ((int)hdmiCapVersion){ - case HDMI_COMPATIBILITY_VERSION_14: - response["HdmiCapabilityVersion"] = "1.4"; - break; - case HDMI_COMPATIBILITY_VERSION_20: - response["HdmiCapabilityVersion"] = "2.0"; - break; - case HDMI_COMPATIBILITY_VERSION_21: - response["HdmiCapabilityVersion"] = "2.1"; - break; - } - - - if(hdmiCapVersion == HDMI_COMPATIBILITY_VERSION_MAX) - { - returnResponse(false); - }else{ - returnResponse(true); - } - } - - uint32_t HdmiInput::getServiceState(PluginHost::IShell* shell, const string& callsign, PluginHost::IShell::state& state) - { - LOGINFO("entering getServiceState\n"); - uint32_t result; - auto interface = shell->QueryInterfaceByCallsign(callsign); - LOGINFO("received interface:\n"); - - if (interface == nullptr) { - result = Core::ERROR_UNAVAILABLE; - LOGINFO("no IShell\n"); - } - else { - result = Core::ERROR_NONE; - state = interface->State(); - LOGINFO("IShell state\n"); - interface->Release(); - } - LOGINFO("at the end of getSErviceState\n"); - return result; - } - - void HdmiInput::getControlSettingsPlugin() - { - LOGINFO("entering getControlSettingsPlugin\n"); - if(m_tv_client == nullptr) - { - LOGINFO("in if case\n"); - string token; - - // TODO: use interfaces and remove token - auto security = m_service->QueryInterfaceByCallsign("SecurityAgent"); - LOGINFO("received security code\n"); - if (security != nullptr) { - string payload = "http://localhost"; - if (security->CreateToken( - static_cast(payload.length()), - reinterpret_cast(payload.c_str()), - token) - == Core::ERROR_NONE) - { - LOGINFO("ControlSettings got security token\n"); - } - else { - LOGINFO("ControlSettings failed to get security token\n"); - } - security->Release(); - } - else { - LOGINFO("No security agent\n"); - } - - string query = "token=" + token; - Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998"))); - m_tv_client = new WPEFramework::JSONRPC::LinkType(_T(TVSETTINGS_CALLSIGN_VER), (_T(TVSETTINGS_CALLSIGN_VER)), false, query); - LOGINFO("HdmiInput getControlSettingsPlugin init m_tv_client\n"); - } - } - - uint32_t HdmiInput::getTVLowLatencyMode(const JsonObject& parameters, JsonObject& response) - { - PluginHost::IShell::state state; - LOGINFOMETHOD(); - if ((getServiceState(m_service, TVSETTINGS_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED)) - { - LOGINFO("%s is active", TVSETTINGS_CALLSIGN); - - getControlSettingsPlugin(); - if(!m_tv_client) - { - LOGERR("TV Settings Initialisation failed\n"); - } - else{ - - JsonObject result; - JsonObject param; - - - int llmode = 0; - m_tv_client->Invoke(2000, "getLowLatencyState", param, result); - - if(result["success"].Boolean()) - { - string value = result.HasLabel("lowLatencyState") ? result["lowLatencyState"].String() : ""; - llmode = stoi(value); - - LOGINFO("value of the result: %d\n",llmode); - - if(llmode){ - response["lowLatencyMode"] = true; - LOGINFO("Low Latency Mode is enabled\n"); - returnResponse(true); - } - else{ - response["lowLatencyMode"] = false; - LOGINFO("Low Latency Mode is disabled\n"); - returnResponse(true); - } - } - else{ - - LOGERR("control settings Plugin returned error\n"); - returnResponse(false); - - } - } - } - else - { - LOGERR("control settings Plugin not ready\n"); - returnResponse(false); - } - - returnResponse(true); - } - - int HdmiInput::setEdidVersion(int iPort, int iEdidVer) - { - bool ret = true; - try - { - device::HdmiInput::getInstance().setEdidVersion (iPort, iEdidVer); - LOGWARN("HdmiInput::setEdidVersion EDID Version:%d", iEdidVer); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - ret = false; - } - return ret; - } - - uint32_t HdmiInput::getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response) - { - string sPortId = parameters["portId"].String(); - int portId = 0; - - LOGINFOMETHOD(); - returnIfParamNotFound(parameters, "portId"); - try { - portId = stoi(sPortId); - }catch (const std::exception& err) { - LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str()); - returnResponse(false); - } - - int edidVer = getEdidVersion (portId); - switch (edidVer) - { - case HDMI_EDID_VER_14: - response["edidVersion"] = "HDMI1.4"; - break; - case HDMI_EDID_VER_20: - response["edidVersion"] = "HDMI2.0"; - break; - } - - if (edidVer < 0) { - returnResponse(false); - } - else { - returnResponse(true); - } - } - - int HdmiInput::getEdidVersion(int iPort) - { - int edidVersion = -1; - - try - { - device::HdmiInput::getInstance().getEdidVersion (iPort, &edidVersion); - LOGWARN("HdmiInput::getEdidVersion EDID Version:%d", edidVersion); - } - catch (const device::Exception& err) - { - LOG_DEVICE_EXCEPTION1(std::to_string(iPort)); - } - return edidVersion; - } - - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdmiInput/HdmiInput.h b/HdmiInput/HdmiInput.h deleted file mode 100644 index ff93202e..00000000 --- a/HdmiInput/HdmiInput.h +++ /dev/null @@ -1,139 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once - -#include "libIBus.h" - -#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 { - - // This is a server for a JSONRPC communication channel. - // For a plugin to be capable to handle JSONRPC, inherit from PluginHost::JSONRPC. - // By inheriting from this class, the plugin realizes the interface PluginHost::IDispatcher. - // This realization of this interface implements, by default, the following methods on this plugin - // - exists - // - register - // - unregister - // Any other methood to be handled by this plugin can be added can be added by using the - // templated methods Register on the PluginHost::JSONRPC class. - // As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC, - // this class exposes a public method called, Notify(), using this methods, all subscribed clients - // will receive a JSONRPC message as a notification, in case this method is called. - class HdmiInput : public PluginHost::IPlugin, public PluginHost::JSONRPC { - private: - - // We do not allow this plugin to be copied !! - HdmiInput(const HdmiInput&) = delete; - HdmiInput& operator=(const HdmiInput&) = delete; - - void InitializeIARM(); - void DeinitializeIARM(); - int m_primVolume; - int m_inputVolume; //Player Volume - - //Begin methods - uint32_t getHDMIInputDevicesWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t writeEDIDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t readEDIDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getRawHDMISPDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t getHDMISPDWrapper(const JsonObject& parameters, JsonObject& response); - uint32_t setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response); - 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); - uint32_t getAVLatency(const JsonObject& parameters, JsonObject& response); - uint32_t getTVLowLatencyMode(const JsonObject& parameters, JsonObject& response); - uint32_t getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response); - //End methods - - JsonArray getHDMIInputDevices(); - void writeEDID(int deviceId, std::string message); - std::string readEDID(int iPort); - std::string getRawHDMISPD(int iPort); - std::string getHDMISPD(int iPort); - int setEdidVersion(int iPort, int iEdidVer); - int getEdidVersion(int iPort); - bool getHdmiALLMStatus(int iPort); - - bool setVideoRectangle(int x, int y, int width, int height); - - void getControlSettingsPlugin(); - void getHdmiCecSinkPlugin(void); - PluginHost::IShell* m_service = nullptr; - WPEFramework::JSONRPC::LinkType* m_client; - WPEFramework::JSONRPC::LinkType* m_tv_client; - std::vector m_clientRegisteredEventNames; - uint32_t getServiceState(PluginHost::IShell* shell, const string& callsign, PluginHost::IShell::state& state); - - void hdmiInputHotplug( int input , int connect); - static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputSignalChange( int port , int signalStatus); - static void dsHdmiSignalStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputStatusChange( int port , bool isPresented); - static void dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputVideoModeUpdate( int port , dsVideoPortResolution_t resolution); - static void dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputALLMChange( int port , bool allmMode); - static void dsHdmiGameFeatureStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInputAviContentTypeChange(int port, int content_type); - static void dsHdmiAviContentTypeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void hdmiInAVLatencyChange(int audio_output_delay,int video_latency); - static void dsHdmiAVLatencyEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); - - void reportLatencyInfoToHdmiCecSink(); - void onGameModeEventHandler(const JsonObject& parameters); - uint32_t subscribeForTvMgrEvent(const char* eventName); - public: - HdmiInput(); - virtual ~HdmiInput(); - virtual const string Initialize(PluginHost::IShell* shell) override; - virtual void Deinitialize(PluginHost::IShell* service) override; - virtual string Information() const override { return {}; } - - void terminate(); - - BEGIN_INTERFACE_MAP(HdmiInput) - INTERFACE_ENTRY(PluginHost::IPlugin) - INTERFACE_ENTRY(PluginHost::IDispatcher) - END_INTERFACE_MAP - - public: - static HdmiInput* _instance; - }; - } // namespace Plugin -} // namespace WPEFramework diff --git a/HdmiInput/Module.cpp b/HdmiInput/Module.cpp deleted file mode 100644 index ce759b61..00000000 --- a/HdmiInput/Module.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include "Module.h" - -MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/HdmiInput/Module.h b/HdmiInput/Module.h deleted file mode 100644 index 54e672c3..00000000 --- a/HdmiInput/Module.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2019 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#pragma once -#ifndef MODULE_NAME -#define MODULE_NAME Plugin_HdmiInput -#endif - -#include -#include - -#undef EXTERNAL -#define EXTERNAL diff --git a/HdmiInput/README.md b/HdmiInput/README.md deleted file mode 100644 index 998e3280..00000000 --- a/HdmiInput/README.md +++ /dev/null @@ -1,9 +0,0 @@ ------------------ -Build: - -bitbake wpeframework-service-plugins - ------------------ -Test: - -curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","id":"3","method": "HdmiInput.1."}' http://127.0.0.1:9998/jsonrpc diff --git a/HdmiInput/cmake/FindDS.cmake b/HdmiInput/cmake/FindDS.cmake deleted file mode 100644 index 926c02e0..00000000 --- a/HdmiInput/cmake/FindDS.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# - Try to find Display Settings library -# Once done this will define -# DS_FOUND - System has DS -# DS_INCLUDE_DIRS - The DS include directories -# DS_LIBRARIES - The libraries needed to use DS -# DS_FLAGS - The flags needed to use DS -# - -find_package(PkgConfig) - -find_library(DS_LIBRARIES NAMES ds) -find_path(DS_INCLUDE_DIRS NAMES hdmiIn.hpp PATH_SUFFIXES rdk/ds) - -set(DS_LIBRARIES ${DS_LIBRARIES}) -set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS}) -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - -find_library(DS_LIBRARIES NAMES ds) -#find_library(DSHAL_LIBRARIES NAMES dshalcli) -#find_path(DS_INCLUDE_DIRS NAMES manager.hpp PATH_SUFFIXES rdk/ds) -find_path(DSHAL_INCLUDE_DIRS NAMES dsTypes.h PATH_SUFFIXES rdk/halif/ds-hal) -find_path(DSRPC_INCLUDE_DIRS NAMES dsMgr.h PATH_SUFFIXES rdk/ds-rpc) - -#set(DS_LIBRARIES ${DS_LIBRARIES} ${DSHAL_LIBRARIES}) -#set(DS_LIBRARIES ${DS_LIBRARIES} CACHE PATH "Path to DS library") -set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} ${DSHAL_INCLUDE_DIRS} ${DSRPC_INCLUDE_DIRS}) -#set(DS_INCLUDE_DIRS ${DS_INCLUDE_DIRS} CACHE PATH "Path to DS include") - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DS DEFAULT_MSG DS_INCLUDE_DIRS DS_LIBRARIES) - -mark_as_advanced( - DS_FOUND - DS_INCLUDE_DIRS - DS_LIBRARIES - DS_LIBRARY_DIRS - DS_FLAGS) diff --git a/HdmiInput/cmake/FindIARMBus.cmake b/HdmiInput/cmake/FindIARMBus.cmake deleted file mode 100644 index bc716bcd..00000000 --- a/HdmiInput/cmake/FindIARMBus.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# If not stated otherwise in this file or this component's license file the -# following copyright and licenses apply: -# -# Copyright 2020 RDK Management -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# - Try to find IARMBus -# Once done this will define -# IARMBUS_FOUND - System has IARMBus -# IARMBUS_INCLUDE_DIRS - The IARMBus include directories -# IARMBUS_LIBRARIES - The libraries needed to use IARMBus -# IARMBUS_FLAGS - The flags needed to use IARMBus -# - -find_package(PkgConfig) - -find_library(IARMBUS_LIBRARIES NAMES IARMBus) -find_path(IARMIR_INCLUDE_DIRS NAMES sysMgr.h PATH_SUFFIXES rdk/iarmmgrs/sysmgr) - -set(IARMBUS_LIBRARIES ${IARMBUS_LIBRARIES} CACHE PATH "Path to IARMBus library") -set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${SYSMGR_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS../sysmgr} ) -set(IARMBUS_INCLUDE_DIRS ${IARMBUS_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS} ${SYSMGR_INCLUDE_DIRS} ${IARMIR_INCLUDE_DIRS../sysmgr} CACHE PATH "Path to IARMBus include") - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IARMBUS DEFAULT_MSG IARMBUS_INCLUDE_DIRS IARMBUS_LIBRARIES) - -mark_as_advanced( - IARMBUS_FOUND - IARMBUS_INCLUDE_DIRS - IARMBUS_LIBRARIES - IARMBUS_LIBRARY_DIRS - IARMBUS_FLAGS) diff --git a/Tests/L1Tests/CMakeLists.txt b/Tests/L1Tests/CMakeLists.txt index ead1b3c2..3d6639c9 100755 --- a/Tests/L1Tests/CMakeLists.txt +++ b/Tests/L1Tests/CMakeLists.txt @@ -106,9 +106,6 @@ set (HDCPPROFILE_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdcpProfile set (HDCPPROFILE_LIBS ${NAMESPACE}HdcpProfile ${NAMESPACE}HdcpProfileImplementation) add_plugin_test_ex(PLUGIN_HDCPPROFILE tests/test_HdcpProfile.cpp "${HDCPPROFILE_INC}" "${HDCPPROFILE_LIBS}") -# PLUGIN_HDMIINPUT -set (HDMIINPUT_INC ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/HdmiInput ${CMAKE_SOURCE_DIR}/../entservices-inputoutput/helpers) -add_plugin_test_ex(PLUGIN_HDMIINPUT tests/test_HdmiInput.cpp "${HDMIINPUT_INC}" "${NAMESPACE}HdmiInput") # PLUGIN_HDMICEC2 add_plugin_test_ex(PLUGIN_HDMICEC2 tests/test_HdmiCec2.cpp "../../HdmiCec_2" "${NAMESPACE}HdmiCec_2") diff --git a/Tests/L1Tests/tests/test_HdmiInput.cpp b/Tests/L1Tests/tests/test_HdmiInput.cpp deleted file mode 100644 index 9b0b1f66..00000000 --- a/Tests/L1Tests/tests/test_HdmiInput.cpp +++ /dev/null @@ -1,861 +0,0 @@ -/** -* If not stated otherwise in this file or this component's LICENSE -* file the following copyright and licenses apply: -* -* Copyright 2024 RDK Management -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -**/ - -#include - -#include "HdmiInput.h" - -#include "FactoriesImplementation.h" - -#include "HdmiInputMock.h" -#include "IarmBusMock.h" -#include "ServiceMock.h" - -#include "dsMgr.h" -#include "ThunderPortability.h" - -using namespace WPEFramework; - -using ::testing::NiceMock; - -class HdmiInputTest : public ::testing::Test { -protected: - Core::ProxyType plugin; - Core::JSONRPC::Handler& handler; - Core::JSONRPC::Handler& handlerV2; - DECL_CORE_JSONRPC_CONX connection; - string response; - - HdmiInputTest() - : plugin(Core::ProxyType::Create()) - , handler(*(plugin)) - , handlerV2(*(plugin->GetHandler(2))) - , INIT_CONX(1, 0) - { - } - virtual ~HdmiInputTest() = default; -}; - -class HdmiInputDsTest : public HdmiInputTest { -protected: - HdmiInputImplMock *p_hdmiInputImplMock = nullptr ; - - HdmiInputDsTest() - : HdmiInputTest() - { - p_hdmiInputImplMock = new NiceMock ; - device::HdmiInput::setImpl(p_hdmiInputImplMock); - } - virtual ~HdmiInputDsTest() override - { - device::HdmiInput::setImpl(nullptr); - if (p_hdmiInputImplMock != nullptr) - { - delete p_hdmiInputImplMock; - p_hdmiInputImplMock = nullptr; - } - } -}; - -class HdmiInputInitializedTest : public HdmiInputTest { -protected: - IarmBusImplMock *p_iarmBusImplMock = nullptr ; - IARM_EventHandler_t dsHdmiEventHandler; - IARM_EventHandler_t dsHdmiStatusEventHandler; - IARM_EventHandler_t dsHdmiSignalStatusEventHandler; - IARM_EventHandler_t dsHdmiVideoModeEventHandler; - IARM_EventHandler_t dsHdmiGameFeatureStatusEventHandler; - - // NiceMock service; - ServiceMock service; - - HdmiInputInitializedTest() - : HdmiInputTest() - { - p_iarmBusImplMock = new NiceMock ; - IarmBus::setImpl(p_iarmBusImplMock); - - EXPECT_CALL(service, QueryInterfaceByCallsign(::testing::_, ::testing::_)) - .Times(::testing::AnyNumber()) - .WillRepeatedly(::testing::Invoke( - [&](const uint32_t, const string& name) -> void* { - return nullptr; - })); - ON_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) - .WillByDefault(::testing::Invoke( - [&](const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) { - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiStatusEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiSignalStatusEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiVideoModeEventHandler = handler; - } - if ((string(IARM_BUS_DSMGR_NAME) == string(ownerName)) && (eventId == IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS)) { - EXPECT_TRUE(handler != nullptr); - dsHdmiGameFeatureStatusEventHandler = handler; - } - return IARM_RESULT_SUCCESS; - })); - - EXPECT_EQ(string(""), plugin->Initialize(&service)); - } - virtual ~HdmiInputInitializedTest() override - { - plugin->Deinitialize(&service); - - IarmBus::setImpl(nullptr); - if (p_iarmBusImplMock != nullptr) - { - delete p_iarmBusImplMock; - p_iarmBusImplMock = nullptr; - } - } -}; - - -class HdmiInputInitializedEventTest : public HdmiInputInitializedTest { -protected: - NiceMock service; - NiceMock factoriesImplementation; - PLUGINHOST_DISPATCHER* dispatcher; - Core::JSONRPC::Message message; - - HdmiInputInitializedEventTest() - : HdmiInputInitializedTest() - { - PluginHost::IFactories::Assign(&factoriesImplementation); - - dispatcher = static_cast( - plugin->QueryInterface(PLUGINHOST_DISPATCHER_ID)); - dispatcher->Activate(&service); - } - - virtual ~HdmiInputInitializedEventTest() override - { - dispatcher->Deactivate(); - dispatcher->Release(); - - PluginHost::IFactories::Assign(nullptr); - } -}; - -class HdmiInputInitializedEventDsTest : public HdmiInputInitializedEventTest { -protected: - HdmiInputImplMock *p_hdmiInputImplMock = nullptr ; - - HdmiInputInitializedEventDsTest() - : HdmiInputInitializedEventTest() - { - p_hdmiInputImplMock = new NiceMock ; - device::HdmiInput::setImpl(p_hdmiInputImplMock); - } - - virtual ~HdmiInputInitializedEventDsTest() override - { - device::HdmiInput::setImpl(nullptr); - if (p_hdmiInputImplMock != nullptr) - { - delete p_hdmiInputImplMock; - p_hdmiInputImplMock = nullptr; - } - } -}; - -TEST_F(HdmiInputTest, RegisteredMethods) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getHDMIInputDevices"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("writeEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("readEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getRawHDMISPD"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getHDMISPD"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("setEdidVersion"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getEdidVersion"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("startHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("stopHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("setVideoRectangle"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getSupportedGameFeatures"))); - EXPECT_EQ(Core::ERROR_NONE, handler.Exists(_T("getHdmiGameFeatureStatus"))); - - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getHDMIInputDevices"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("writeEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("readEDID"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("startHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("stopHdmiInput"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("setVideoRectangle"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getSupportedGameFeatures"))); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Exists(_T("getHdmiGameFeatureStatus"))); -} - -TEST_F(HdmiInputDsTest, getHDMIInputDevices) -{ - - ON_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) - .WillByDefault(::testing::Return(1)); - ON_CALL(*p_hdmiInputImplMock, isPortConnected(::testing::_)) - .WillByDefault(::testing::Return(true)); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHDMIInputDevices"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"devices\":[{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"connected\":\"true\"}],\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, writeEDIDEmpty) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("writeEDID"), _T("{\"message\": \"message\"}"), response)); - EXPECT_EQ(response, string("")); -} - - -TEST_F(HdmiInputDsTest, writeEDID) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("writeEDID"), _T("{\"deviceId\": 0, \"message\": \"message\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, writeEDIDInvalid) -{ - ON_CALL(*p_hdmiInputImplMock, getEDIDBytesInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector &edidVec2) { - edidVec2 = std::vector({ 't', 'e', 's', 't' }); - })); - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("readEDID"), _T("{\"deviceId\": \"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, readEDID) -{ - ON_CALL(*p_hdmiInputImplMock, getEDIDBytesInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector &edidVec2) { - edidVec2 = std::vector({ 't', 'e', 's', 't' }); - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("readEDID"), _T("{\"deviceId\": 0}"), response)); - EXPECT_EQ(response, string("{\"EDID\":\"dGVzdA==\",\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, getRawHDMISPD) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = { 't', 'e', 's', 't' }; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getRawHDMISPD"), _T("{\"portId\":0}"), response)); - EXPECT_EQ(response, string("{\"HDMISPD\":\"dGVzdA\",\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getRawHDMISPDInvalid) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = { 't', 'e', 's', 't' }; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("getRawHDMISPD"), _T("{\"portId\":\"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, getHDMISPD) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = {'0','1','2','n', 'p', '1','2','3','4','5','6','7',0,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',0,'q','r'}; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getHDMISPD"), _T("{\"portId\":0}"), response)); - EXPECT_EQ(response, string("{\"HDMISPD\":\"Packet Type:30,Version:49,Length:50,vendor name:1234567,product des:abcdefghijklmno,source info:71\",\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getHDMISPDInvalid) -{ - ON_CALL(*p_hdmiInputImplMock, getHDMISPDInfo(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, std::vector& edidVec2) { - edidVec2 = {'0','1','2','n', 'p', '0'}; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("getHDMISPD"), _T("{\"portId\":\"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - - -TEST_F(HdmiInputDsTest, setEdidVersionInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"b\", \"edidVersion\":\"HDMI1.4\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, setEdidVersion14) -{ - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"0\", \"edidVersion\":\"HDMI1.4\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, setEdidVersion20) -{ - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"0\", \"edidVersion\":\"HDMI2.0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} -TEST_F(HdmiInputDsTest, setEdidVersionEmpty) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("setEdidVersion"), _T("{\"portId\": \"0\", \"edidVersion\":\"\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, getEdidVersionInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handlerV2.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"b\", \"edidVersion\":\"HDMI1.4\"}"), response)); - EXPECT_EQ(response, string("")); -} -TEST_F(HdmiInputDsTest, getEdidVersionVer14) -{ - ON_CALL(*p_hdmiInputImplMock, getEdidVersion(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iPort, int *edidVersion) { - *edidVersion = 0; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"edidVersion\":\"HDMI1.4\",\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getEdidVersionVer20) -{ - ON_CALL(*p_hdmiInputImplMock, getEdidVersion(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iPort, int *edidVersion) { - *edidVersion = 1; - })); - EXPECT_EQ(Core::ERROR_NONE, handlerV2.Invoke(connection, _T("getEdidVersion"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"edidVersion\":\"HDMI2.0\",\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, startHdmiInputInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("startHdmiInput"), _T("{\"portId\": \"b\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, startHdmiInput) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startHdmiInput"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, stopHdmiInput) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopHdmiInput"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - -TEST_F(HdmiInputDsTest, setVideoRectangleInvalid) -{ - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\": \"b\",\"y\": 0,\"w\": 1920,\"h\": 1080}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, setVideoRectangle) -{ - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("setVideoRectangle"), _T("{\"x\": 0,\"y\": 0,\"w\": 1920,\"h\": 1080}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, getSupportedGameFeatures) -{ - ON_CALL(*p_hdmiInputImplMock, getSupportedGameFeatures(::testing::_)) - .WillByDefault(::testing::Invoke( - [&](std::vector &supportedFeatures) { - supportedFeatures = {"ALLM"}; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getSupportedGameFeatures"), _T("{\"supportedGameFeatures\": \"ALLM\"}"), response)); - EXPECT_EQ(response, string("{\"supportedGameFeatures\":[\"ALLM\"],\"success\":true}")); -} - - -TEST_F(HdmiInputDsTest, getHdmiGameFeatureStatusInvalidPort) -{ - ON_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, bool *allm) { - *allm = true; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getHdmiGameFeatureStatus"), _T("{\"portId\": \"b\",\"gameFeature\": \"ALLM\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputDsTest, getHdmiGameFeatureStatus) -{ - ON_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, bool *allm) { - *allm = true; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getHdmiGameFeatureStatus"), _T("{\"portId\": \"0\",\"gameFeature\": \"ALLM\"}"), response)); - EXPECT_EQ(response, string("{\"mode\":true,\"success\":true}")); -} -TEST_F(HdmiInputDsTest, getHdmiGameFeatureStatusInvalidFeature) -{ - ON_CALL(*p_hdmiInputImplMock, getHdmiALLMStatus(::testing::_,::testing::_)) - .WillByDefault(::testing::Invoke( - [&](int iport, bool *allm) { - *allm = true; - })); - EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("getHdmiGameFeatureStatus"), _T("{\"portId\": \"0\",\"gameFeature\": \"Invalid\"}"), response)); - EXPECT_EQ(response, string("")); -} - -TEST_F(HdmiInputInitializedEventDsTest, onDevicesChanged) -{ - ASSERT_TRUE(dsHdmiEventHandler != nullptr); - ON_CALL(*p_hdmiInputImplMock, getNumberOfInputs()) - .WillByDefault(::testing::Return(1)); - ON_CALL(*p_hdmiInputImplMock, isPortConnected(::testing::_)) - .WillByDefault(::testing::Return(true)); - - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onDevicesChanged.onDevicesChanged\",\"params\":{\"devices\":[{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"connected\":\"true\"}]}}"))); - - return Core::ERROR_NONE; - })); - - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_connect.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_connect.isPortConnected = true; - - EVENT_SUBSCRIBE(0, _T("onDevicesChanged"), _T("client.events.onDevicesChanged"), message); - - dsHdmiEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onDevicesChanged"), _T("client.events.onDevicesChanged"), message); -} - -TEST_F(HdmiInputInitializedEventDsTest, onInputStatusChangeOn) -{ - ASSERT_TRUE(dsHdmiStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onInputStatusChanged.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"started\",\"plane\":0}}"))); - return Core::ERROR_NONE; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("startHdmiInput"), _T("{\"portId\": \"0\"}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_status.isPresented = true; - - EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); - - dsHdmiStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onInputStatusChangeOff) -{ - ASSERT_TRUE(dsHdmiStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onInputStatusChanged.onInputStatusChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"status\":\"stopped\",\"plane\":-1}}"))); - return Core::ERROR_NONE; - })); - EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("stopHdmiInput"), _T("{}"), response)); - EXPECT_EQ(response, string("{\"success\":true}")); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_status.isPresented = false; - - EVENT_SUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); - - dsHdmiStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onInputStatusChanged"), _T("client.events.onInputStatusChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedStable) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"stableSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_STABLE; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedNoSignal) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"noSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_NOSIGNAL; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedUnstable) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"unstableSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_UNSTABLE; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedNotSupported) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"notSupportedSignal\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_NOTSUPPORTED; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - -} -TEST_F(HdmiInputInitializedEventDsTest, onSignalChangedDefault) -{ - ASSERT_TRUE(dsHdmiSignalStatusEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.onSignalChanged.onSignalChanged\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"signalStatus\":\"none\"}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_sig_status.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_sig_status.status = dsHDMI_IN_SIGNAL_STATUS_MAX; - - EVENT_SUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); - - dsHdmiSignalStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("onSignalChanged"), _T("client.events.onSignalChanged"), message); -} - -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate1) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":1920,\"height\":1080,\"progressive\":false,\"frameRateN\":60000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_1920x1080; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_59dot94; - - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate2) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":720,\"height\":480,\"progressive\":false,\"frameRateN\":24000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_720x480; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_24; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate3) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":720,\"height\":576,\"progressive\":false,\"frameRateN\":25000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_720x576; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_25; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate4) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":3840,\"height\":2160,\"progressive\":false,\"frameRateN\":30000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_3840x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_30; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate5) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":50000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_50; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate6) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":60000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_60; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate7) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":24000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_23dot98; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate8) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":4096,\"height\":2160,\"progressive\":false,\"frameRateN\":30000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_4096x2160; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_29dot97; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdate9) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":1280,\"height\":720,\"progressive\":false,\"frameRateN\":30000,\"frameRateD\":1001}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_1280x720; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate = dsVIDEO_FRAMERATE_29dot97; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, videoStreamInfoUpdateDefault) -{ - ASSERT_TRUE(dsHdmiVideoModeEventHandler != nullptr); - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.videoStreamInfoUpdate.videoStreamInfoUpdate\",\"params\":{\"id\":0,\"locator\":\"hdmiin:\\/\\/localhost\\/deviceid\\/0\",\"width\":1920,\"height\":1080,\"progressive\":false,\"frameRateN\":60000,\"frameRateD\":1000}}"))); - return Core::ERROR_NONE; - })); - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_video_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_video_mode.resolution.pixelResolution = dsVIDEO_PIXELRES_MAX; - eventData.data.hdmi_in_video_mode.resolution.interlaced = true; - eventData.data.hdmi_in_video_mode.resolution.frameRate= dsVIDEO_FRAMERATE_MAX; - EVENT_SUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); - dsHdmiVideoModeEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, &eventData , 0); - EVENT_UNSUBSCRIBE(0, _T("videoStreamInfoUpdate"), _T("client.events.videoStreamInfoUpdate"), message); -} -TEST_F(HdmiInputInitializedEventDsTest, hdmiGameFeatureStatusUpdate) -{ - ASSERT_TRUE(dsHdmiGameFeatureStatusEventHandler != nullptr); - - EXPECT_CALL(service, Submit(::testing::_, ::testing::_)) - .Times(1) - .WillOnce(::testing::Invoke( - [&](const uint32_t, const Core::ProxyType& json) { - string text; - EXPECT_TRUE(json->ToString(text)); - EXPECT_EQ(text, string(_T("{\"jsonrpc\":\"2.0\",\"method\":\"client.events.hdmiGameFeatureStatusUpdate.hdmiGameFeatureStatusUpdate\",\"params\":{\"id\":0,\"gameFeature\":\"ALLM\",\"mode\":true}}"))); - - return Core::ERROR_NONE; - })); - - - IARM_Bus_DSMgr_EventData_t eventData; - eventData.data.hdmi_in_allm_mode.port =dsHDMI_IN_PORT_0; - eventData.data.hdmi_in_allm_mode.allm_mode = true; - EVENT_SUBSCRIBE(0, _T("hdmiGameFeatureStatusUpdate"), _T("client.events.hdmiGameFeatureStatusUpdate"), message); - - dsHdmiGameFeatureStatusEventHandler(IARM_BUS_DSMGR_NAME, IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, &eventData , 0); - - EVENT_UNSUBSCRIBE(0, _T("hdmiGameFeatureStatusUpdate"), _T("client.events.hdmiGameFeatureStatusUpdate"), message); -}