* @see cec_get_device_cec_version
*/
virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress) = 0;
+
+ /*!
+ * @see cec_get_device_menu_language
+ */
+ virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language) = 0;
};
};
extern DECLSPEC cec_version cec_get_device_cec_version(cec_logical_address iLogicalAddress);
#endif
+/*!
+ * @brief Get the menu language of the device with the given logical address
+ * @param iLogicalAddress The device to get the menu language for.
+ * @param language The requested menu language.
+ * @return True when fetched succesfully, false otherwise.
+ */
+#ifdef __cplusplus
+extern DECLSPEC int cec_get_device_menu_language(CEC::cec_logical_address iLogicalAddress, CEC::cec_menu_language *language);
+#else
+extern DECLSPEC cec_version cec_get_device_menu_language(cec_logical_address iLogicalAddress, cec_menu_language *language);
+#endif
#ifdef __cplusplus
};
#endif
CEC_LOG_ALL = 31
} cec_log_level;
+typedef struct cec_menu_language
+{
+ char language[4];
+ cec_logical_address device;
+} cec_menu_language;
+
typedef struct cec_log_message
{
char message[1024];
return m_busDevices[iAddress]->GetCecVersion();
}
+bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language)
+{
+ *language = m_busDevices[iAddress]->GetMenuLanguage();
+ return (strcmp(language->language, "???"));
+}
+
bool CCECProcessor::Transmit(const cec_command &data)
{
bool bReturn(false);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
virtual bool SwitchMonitoring(bool bEnable);
virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress);
+ virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; }
virtual uint16_t GetPhysicalAddress(void) const;
return CEC_VERSION_UNKNOWN;
}
+bool CLibCEC::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language)
+{
+ if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+ return m_cec->GetDeviceMenuLanguage(iAddress, language);
+ return false;
+}
+
void CLibCEC::AddLog(cec_log_level level, const string &strMessage)
{
if (m_cec)
virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage);
virtual bool SwitchMonitoring(bool bEnable);
virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress);
+ virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
//@}
virtual void AddLog(cec_log_level level, const std::string &strMessage);
return CEC_VERSION_UNKNOWN;
}
+int cec_get_device_menu_language(cec_logical_address iLogicalAddress, cec_menu_language *language)
+{
+ if (cec_parser)
+ return cec_parser->GetDeviceMenuLanguage(iLogicalAddress, language) ? 1 : 0;
+ return -1;
+}
+
//@}
m_cecVersion(CEC_VERSION_UNKNOWN)
{
m_handler = new CCECCommandHandler(this);
+ for (unsigned int iPtr = 0; iPtr < 4; iPtr++)
+ m_menuLanguage.language[iPtr] = '?';
+ m_menuLanguage.language[3] = 0;
+ m_menuLanguage.device = iLogicalAddress;
}
CCECBusDevice::~CCECBusDevice(void)
m_processor->AddLog(level, strMessage);
}
+void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
+{
+ if (language.device == m_iLogicalAddress)
+ {
+ CStdString strLog;
+ strLog.Format("device %d menu language set to '%s'", m_iLogicalAddress, language.language);
+ m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ m_menuLanguage = language;
+ }
+}
+
void CCECBusDevice::SetCecVersion(cec_version newVersion)
{
CStdString strLog;
return m_cecVersion;
}
+cec_menu_language &CCECBusDevice::GetMenuLanguage(void)
+{
+ if (!strcmp(m_menuLanguage.language, "???"))
+ {
+ AddLog(CEC_LOG_NOTICE, "<< requesting menu language");
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE);
+ CLockObject lock(&m_mutex);
+ if (m_processor->Transmit(command))
+ m_condition.Wait(&m_mutex, 1000);
+ }
+
+ return m_menuLanguage;
+}
+
const char *CCECBusDevice::CECVendorIdToString(const uint64_t iVendorId)
{
switch (iVendorId)
virtual uint16_t GetMyPhysicalAddress(void) const;
virtual void SetCecVersion(cec_version newVersion);
+ virtual void SetMenuLanguage(const cec_menu_language &menuLanguage);
virtual void SetVendorId(const cec_datapacket &data);
virtual void SetVendorId(uint64_t iVendorId, uint8_t iVendorClass = 0);
virtual const char *GetVendorName(void) const { return CECVendorIdToString(m_iVendorId); }
virtual CCECCommandHandler *GetHandler(void) const { return m_handler; };
virtual cec_version GetCecVersion(void);
+ virtual cec_menu_language &GetMenuLanguage(void);
virtual void PollVendorId(void);
virtual bool PowerOn(void);
virtual bool Standby(void);
protected:
uint16_t m_iPhysicalAddress;
cec_logical_address m_iLogicalAddress;
+ cec_menu_language m_menuLanguage;
CCECProcessor *m_processor;
CCECCommandHandler *m_handler;
uint64_t m_iVendorId;
case CEC_OPCODE_CEC_VERSION:
HandleDeviceCecVersion(command);
break;
+ case CEC_OPCODE_SET_MENU_LANGUAGE:
+ HandleSetMenuLanguage(command);
+ break;
case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
HandleGivePhysicalAddress(command);
break;
CStdString strLog;
switch (command.opcode)
{
+ case CEC_OPCODE_SET_MENU_LANGUAGE:
+ HandleSetMenuLanguage(command);
+ break;
case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
HandleRequestActiveSource(command);
break;
return true;
}
+bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command)
+{
+ if (command.parameters.size == 3)
+ {
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ {
+ cec_menu_language language;
+ language.device = command.initiator;
+ for (unsigned int iPtr = 0; iPtr < 4; iPtr++)
+ language.language[iPtr] = command.parameters[iPtr];
+ language.language[3] = 0;
+ device->SetMenuLanguage(language);
+ }
+ }
+ return true;
+}
+
+
bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
{
if (command.parameters.size >= 2)
bool HandleMenuRequest(const cec_command &command);
bool HandleRequestActiveSource(const cec_command &command);
bool HandleRoutingChange(const cec_command &command);
+ bool HandleSetMenuLanguage(const cec_command &command);
bool HandleSetStreamPath(const cec_command &command);
bool HandleUserControlPressed(const cec_command &command);
bool HandleUserControlRelease(const cec_command &command);
"ver {addr} get the CEC version of the specified device." << endl <<
"[ver 0] get the CEC version of the TV" << endl <<
endl <<
+ "lang {addr get the menu language of the specified device." << endl <<
+ "[lang 0] get the menu language of the TV" << endl <<
+ endl <<
"[mon] {1|0} enable or disable CEC bus monitoring." << endl <<
"[log] {1 - 31} change the log level. see cectypes.h for values." << endl <<
"[ping] send a ping command to the CEC adapter." << endl <<
{
parser->StartBootloader();
}
+ else if (command == "lang")
+ {
+ CStdString strDev;
+ if (GetWord(input, strDev))
+ {
+ int iDev = atoi(strDev);
+ if (iDev >= 0 && iDev < 15)
+ {
+ CStdString strLog;
+ cec_menu_language language;
+ if (parser->GetDeviceMenuLanguage((cec_logical_address) iDev, &language))
+ strLog.Format("menu language '%s'", language.language);
+ else
+ strLog = "failed!";
+ cout << strLog.c_str() << endl;
+ }
+ }
+ }
else if (command == "ver")
{
CStdString strDev;