diff --git a/CHANGELOG.md b/CHANGELOG.md index 87ff36e9..be49840d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.10.3](https://github.com/rdkcentral/entservices-inputoutput/compare/1.10.2...1.10.3) + +- RDKEMW-11398: Implement HdmiCecSink & UserSettings communication. [`#342`](https://github.com/rdkcentral/entservices-inputoutput/pull/342) +- Merge tag '1.10.2' into develop [`e22d4a8`](https://github.com/rdkcentral/entservices-inputoutput/commit/e22d4a8db483fc7f6dbfeb67a43e207830ff7905) + #### [1.10.2](https://github.com/rdkcentral/entservices-inputoutput/compare/1.10.1...1.10.2) +> 13 January 2026 + - RDKEMW-12459: ARC - SAD is not updating as expected. [`#358`](https://github.com/rdkcentral/entservices-inputoutput/pull/358) +- 1.10.2 release changelog updates [`67dca55`](https://github.com/rdkcentral/entservices-inputoutput/commit/67dca55a00bd3e9bc6f5b4be23723cc916166b3b) - Merge tag '1.10.1' into develop [`168ed58`](https://github.com/rdkcentral/entservices-inputoutput/commit/168ed5828d53b3a411026b65cc53b866575ca31a) #### [1.10.1](https://github.com/rdkcentral/entservices-inputoutput/compare/1.10.0...1.10.1) diff --git a/HdmiCecSink/HdmiCecSinkImplementation.cpp b/HdmiCecSink/HdmiCecSinkImplementation.cpp index 422faccc..42e76f92 100644 --- a/HdmiCecSink/HdmiCecSinkImplementation.cpp +++ b/HdmiCecSink/HdmiCecSinkImplementation.cpp @@ -92,7 +92,6 @@ static VendorID appVendorId = {defaultVendorId.at(0),defaultVendorId.at(1),defau static VendorID lgVendorId = {0x00,0xE0,0x91}; static PhysicalAddress physical_addr = {0x0F,0x0F,0x0F,0x0F}; static LogicalAddress logicalAddress = 0xF; -static Language defaultLanguage = "eng"; static OSDName osdName = "TV Box"; static int32_t powerState = DEVICE_POWER_STATE_OFF; static std::vector formatid = {0,0}; @@ -606,6 +605,8 @@ namespace WPEFramework , m_connectedDevices() , msgProcessor(nullptr) , msgFrameListener(nullptr) + , _userSettingsPlugin(nullptr) + , _userSettingsNotification(*this) , _powerManagerPlugin() , _pwrMgrNotification(*this) , _registeredEventHandlers(false) @@ -621,6 +622,13 @@ namespace WPEFramework _powerManagerPlugin.Reset(); } _registeredEventHandlers = false; + + if(_userSettingsPlugin) + { + _userSettingsPlugin->Unregister(&_userSettingsNotification); + _userSettingsPlugin->Release(); + _userSettingsPlugin = nullptr; + } CECDisable(); m_currentArcRoutingState = ARC_STATE_ARC_EXIT; @@ -779,6 +787,29 @@ namespace WPEFramework } } getCecVersion(); + + _userSettingsPlugin = service->QueryInterfaceByCallsign("org.rdk.UserSettings"); + if (nullptr == _userSettingsPlugin) { + LOGERR("Failed to get UserSettings interface"); + } + else + { + _userSettingsPlugin->Register(&_userSettingsNotification); + LOGINFO("Successfully registered for UserSettings notifications"); + + string presentationLanguage, isoLang; + uint32_t status = _userSettingsPlugin->GetPresentationLanguage(presentationLanguage); + if (status == Core::ERROR_NONE) { + isoLang = mapToIso639_2(presentationLanguage); + LOGINFO("Successfully retrieved the Presentation language from the userSettings plugin - BCP47: %s, ISO 639-2: %s", presentationLanguage.c_str(), isoLang.c_str()); + setCurrentLanguage(Language(isoLang.data())); + sendMenuLanguage(); + } + else { + LOGERR("Failed to get presentation language: %u", status); + } + } + LOGINFO(" HdmiCecSinkImplementation plugin Initialize completed \n"); return Core::ERROR_NONE; @@ -853,6 +884,17 @@ namespace WPEFramework HdmiCecSinkImplementation::_instance->onHdmiHotPlug((int) port, isConnected); } + void HdmiCecSinkImplementation::onPresentationLanguageChanged(const string& presentationLanguage) + { + if(!HdmiCecSinkImplementation::_instance) + return; + + string isoLang = mapToIso639_2(presentationLanguage); + LOGINFO("OnPresentationLanguageChanged - language BCP47: %s, ISO 639-2: %s", presentationLanguage.c_str(), isoLang.c_str()); + setCurrentLanguage(Language(isoLang.data())); + sendMenuLanguage(); + } + void HdmiCecSinkImplementation::onPowerModeChanged(const PowerState ¤tState, const PowerState &newState) { if(!HdmiCecSinkImplementation::_instance) @@ -1484,6 +1526,7 @@ namespace WPEFramework lang = language; setCurrentLanguage(Language(lang.data())); + sendMenuLanguage(); successResult.success = true; return Core::ERROR_NONE; @@ -1722,6 +1765,46 @@ namespace WPEFramework return cecSettingEnabled; } + std::string HdmiCecSinkImplementation::mapToIso639_2(const string& lang_BCP47) + { + if (lang_BCP47.empty()) + return "eng"; + + std::string lang = lang_BCP47.substr(0, lang_BCP47.find('-')); + std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower); + + if (lang.length() == 3) + return lang; + + static const std::unordered_map iso639_1_to_2 = { + {"en", "eng"}, + {"fr", "fra"}, + {"de", "deu"}, + {"es", "spa"}, + {"it", "ita"}, + {"pt", "por"}, + {"ru", "rus"}, + {"zh", "zho"}, + {"ja", "jpn"}, + {"ko", "kor"}, + {"ar", "ara"}, + {"hi", "hin"}, + {"nl", "nld"}, + {"sv", "swe"}, + {"fi", "fin"}, + {"no", "nor"}, + {"da", "dan"}, + {"pl", "pol"}, + {"tr", "tur"} + }; + + auto it = iso639_1_to_2.find(lang); + if (it != iso639_1_to_2.end()) + return it->second; + + return "eng"; + } + void HdmiCecSinkImplementation::setEnabled(bool enabled) { LOGINFO("Entered setEnabled: %d cecSettingEnabled :%d ",enabled, cecSettingEnabled); @@ -2637,7 +2720,6 @@ namespace WPEFramework _instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_1_4; _instance->deviceList[_instance->m_logicalAddressAllocated].m_vendorID = appVendorId; _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState); - _instance->deviceList[_instance->m_logicalAddressAllocated].m_currentLanguage = defaultLanguage; _instance->deviceList[_instance->m_logicalAddressAllocated].m_osdName = osdName.toString().c_str(); if(cecVersion == 2.0) { _instance->deviceList[_instance->m_logicalAddressAllocated].m_cecVersion = Version::V_2_0; @@ -3497,4 +3579,4 @@ namespace WPEFramework } } // namespace Plugin -} // namespace WPEFramework \ No newline at end of file +} // namespace WPEFramework diff --git a/HdmiCecSink/HdmiCecSinkImplementation.h b/HdmiCecSink/HdmiCecSinkImplementation.h index bc1f37bc..4869dadc 100644 --- a/HdmiCecSink/HdmiCecSinkImplementation.h +++ b/HdmiCecSink/HdmiCecSinkImplementation.h @@ -40,6 +40,7 @@ #include "UtilsLogging.h" #include +#include #include "PowerManagerInterface.h" #include #include "host.hpp" @@ -527,6 +528,7 @@ namespace WPEFramework { static HdmiCecSinkImplementation* _instance; CECDeviceParams deviceList[16]; std::vector hdmiInputs; + std::string mapToIso639_2(const string& lang_BCP47); int m_currentActiveSource; void updateInActiveSource(const int logical_address, const InActiveSource &source ); void updateActiveSource(const int logical_address, const ActiveSource &source ); @@ -570,6 +572,7 @@ namespace WPEFramework { void sendGiveAudioStatusMsg(); void onPowerModeChanged(const PowerState ¤tState, const PowerState &newState); void registerEventHandlers(); + void onPresentationLanguageChanged(const string& language); void getHdmiArcPortID(); int m_numberOfDevices; /* Number of connected devices othethan own device */ bool m_audioDevicePowerStatusRequested; @@ -612,6 +615,33 @@ namespace WPEFramework { HdmiCecSinkImplementation& _parent; }; + + class UserSettingsNotification : public Exchange::IUserSettings::INotification { + private: + UserSettingsNotification(const UserSettingsNotification&) = delete; + UserSettingsNotification& operator=(const UserSettingsNotification&) = delete; + + public: + explicit UserSettingsNotification(HdmiCecSinkImplementation& parent) + : _parent(parent) + { + } + ~UserSettingsNotification() override = default; + + public: + void OnPresentationLanguageChanged(const string& language) override + { + _parent.onPresentationLanguageChanged(language); + } + + BEGIN_INTERFACE_MAP(UserSettingsNotification) + INTERFACE_ENTRY(Exchange::IUserSettings::INotification) + END_INTERFACE_MAP + + private: + HdmiCecSinkImplementation& _parent; + }; + // We do not allow this plugin to be copied !! HdmiCecSinkImplementation(const HdmiCecSinkImplementation&) = delete; HdmiCecSinkImplementation& operator=(const HdmiCecSinkImplementation&) = delete; @@ -664,6 +694,8 @@ namespace WPEFramework { std::vector m_connectedDevices; HdmiCecSinkProcessor *msgProcessor; HdmiCecSinkFrameListener *msgFrameListener; + Exchange::IUserSettings *_userSettingsPlugin; + Core::Sink _userSettingsNotification; PowerManagerInterfaceRef _powerManagerPlugin; Core::Sink _pwrMgrNotification; bool _registeredEventHandlers;