From: Lars Op den Kamp Date: Fri, 14 Oct 2011 13:59:27 +0000 (+0200) Subject: cec: add SetOSDString() to the interface (not supported by all tvs) X-Git-Tag: upstream/2.2.0~1^2~227 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=1969b1409b16be8b82f89e87d94daf527f9d5969 cec: add SetOSDString() to the interface (not supported by all tvs) --- diff --git a/include/cec.h b/include/cec.h index bf7a473..c23c35a 100644 --- a/include/cec.h +++ b/include/cec.h @@ -129,6 +129,11 @@ namespace CEC * @see cec_set_inactive_view */ virtual bool SetInactiveView(void) = 0; + + /*! + * @see cec_set_osd_string + */ + virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage) = 0; }; }; diff --git a/include/cecc.h b/include/cecc.h index 43e79d8..c319c19 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -202,6 +202,17 @@ extern DECLSPEC int cec_set_logical_address(cec_logical_address myAddress, cec_l */ extern DECLSPEC int cec_set_physical_address(uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS); +/*! + * @brief Display a message on the TV. + * @brief The message to display. + * @return True when the command was sent, false otherwise. + */ +#ifdef __cplusplus +extern DECLSPEC int cec_set_osd_string(CEC::cec_logical_address iLogicalAddress, CEC::cec_display_control duration, const char *strMessage); +#else +extern DECLSPEC int cec_set_osd_string(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); +#endif + #ifdef __cplusplus }; #endif diff --git a/include/cectypes.h b/include/cectypes.h index f18d928..004ea06 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -151,13 +151,13 @@ typedef enum CEC_DEVICE_TYPE_AUDIO_SYSTEM = 5 } ECecDeviceType; -typedef enum +typedef enum cec_display_control { CEC_DISPLAY_CONTROL_DISPLAY_FOR_DEFAULT_TIME = 0x00, CEC_DISPLAY_CONTROL_DISPLAY_UNTIL_CLEARED = 0x40, CEC_DISPLAY_CONTROL_CLEAR_PREVIOUS_MESSAGE = 0x80, CEC_DISPLAY_CONTROL_RESERVED_FOR_FUTURE_USE = 0xC0 -} ECecDisplayControl; +} cec_display_control; typedef enum { diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 0c55845..88541c0 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -221,6 +221,22 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) return SetActiveView(); } +bool CCECProcessor::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage) +{ + CStdString strLog; + strLog.Format("<< display message '%s'", strMessage); + m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str()); + + cec_command command; + cec_command::format(command, m_iLogicalAddress, iLogicalAddress, CEC_OPCODE_SET_OSD_STRING); + command.parameters.push_back((uint8_t)duration); + + for (unsigned int iPtr = 0; iPtr < strlen(strMessage); iPtr++) + command.parameters.push_back(strMessage[iPtr]); + + return Transmit(command); +} + bool CCECProcessor::TransmitFormatted(const cec_adapter_message &data, bool bWaitForAck /* = true */) { CLockObject lock(&m_mutex); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 43b7a30..dd0596e 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -59,6 +59,7 @@ namespace CEC virtual bool Transmit(const cec_command &data, bool bWaitForAck = true); virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress); + virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); static const char *CECVendorIdToString(const uint64_t iVendorId); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 78fca2d..a1f2650 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -193,6 +193,11 @@ bool CLibCEC::SetInactiveView(void) return m_cec ? m_cec->SetInactiveView() : false; } +bool CLibCEC::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage) +{ + return m_cec ? m_cec->SetOSDString(iLogicalAddress, duration, strMessage) : false; +} + void CLibCEC::AddLog(cec_log_level level, const string &strMessage) { if (m_cec) diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 2f80720..8ea0c98 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -71,6 +71,7 @@ namespace CEC virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST); virtual bool SetActiveView(void); virtual bool SetInactiveView(void); + virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); //@} virtual void AddLog(cec_log_level level, const std::string &strMessage); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index ccdd5b6..d062dff 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -173,4 +173,11 @@ int cec_set_inactive_view(void) return -1; } +int cec_set_osd_string(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage) +{ + if (cec_parser) + return cec_parser->SetOSDString(iLogicalAddress, duration, strMessage) ? 1 : 0; + return -1; +} + //@} diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index cd83f10..2939c60 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -183,6 +183,9 @@ void show_console_help(void) "pa {physical_address} change the physical address of the CEC adapter." << endl << "[pa 10 00] physical address 1.0.0.0" << endl << endl << + "osd {addr} {string} set OSD message on the specified device." << endl << + "[osd 0 Test Message] displays 'Test Message' on the TV" << endl << + endl << "[ping] send a ping command to the CEC adapter." << endl << "[bl] to let the adapter enter the bootloader, to upgrade" << endl << " the flash rom." << endl << @@ -339,6 +342,25 @@ int main (int argc, char *argv[]) parser->SetPhysicalAddress(iPhysicalAddress); } } + else if (command == "osd") + { + bool bFirstWord(false); + string strAddr, strMessage, strWord; + uint8_t iAddr; + if (GetWord(input, strAddr) && HexStrToInt(strAddr, iAddr) && iAddr < 0xF) + { + while (GetWord(input, strWord)) + { + if (bFirstWord) + { + bFirstWord = false; + strMessage.append(" "); + } + strMessage.append(strWord); + } + parser->SetOSDString((cec_logical_address) iAddr, CEC_DISPLAY_CONTROL_DISPLAY_FOR_DEFAULT_TIME, strMessage.c_str()); + } + } else if (command == "ping") { parser->PingAdapter();