From: Lars Op den Kamp Date: Mon, 6 Feb 2012 15:05:25 +0000 (+0100) Subject: cec: added GetLogicalAddresses()/cec_get_logical_addresses() to the interface, that... X-Git-Tag: upstream/2.2.0~1^2~35^2~143 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=80b72250dc1f336839ff2f13fd5247e7f273fb42;p=deb_libcec.git cec: added GetLogicalAddresses()/cec_get_logical_addresses() to the interface, that returns the list of addresses controlled by libCEC --- diff --git a/include/cec.h b/include/cec.h index 97e75a4..5916ffd 100644 --- a/include/cec.h +++ b/include/cec.h @@ -364,6 +364,11 @@ namespace CEC */ virtual bool SetStreamPath(uint16_t iPhysicalAddress) = 0; + /*! + * @return The list of addresses that libCEC is controlling + */ + virtual cec_logical_addresses GetLogicalAddresses(void) = 0; + virtual const char *ToString(const cec_menu_state state) = 0; virtual const char *ToString(const cec_version version) = 0; virtual const char *ToString(const cec_power_status status) = 0; diff --git a/include/cecc.h b/include/cecc.h index dc4b795..e1ef0e3 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -267,6 +267,12 @@ extern DECLSPEC int cec_set_stream_path_logical(cec_logical_address iAddress); extern DECLSPEC int cec_set_stream_path_physical(uint16_t iPhysicalAddress); +#ifdef __cplusplus +extern DECLSPEC CEC::cec_logical_addresses cec_get_logical_addresses(void); +#else +extern DECLSPEC cec_logical_addresses cec_get_logical_addresses(void); +#endif + #ifdef __cplusplus }; #endif diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 7022def..9c169cc 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -448,6 +448,12 @@ bool CLibCEC::SetStreamPath(uint16_t iPhysicalAddress) return m_cec->SetStreamPath(iPhysicalAddress); } +cec_logical_addresses CLibCEC::GetLogicalAddresses(void) +{ + cec_logical_addresses addr = m_cec->GetLogicalAddresses(); + return addr; +} + static CLibCEC *g_libCEC_instance(NULL); CLibCEC *CLibCEC::GetInstance(void) { diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 6cc2514..b5cf2bf 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -101,6 +101,7 @@ namespace CEC virtual bool IsActiveSource(cec_logical_address iAddress); virtual bool SetStreamPath(cec_logical_address iAddress); virtual bool SetStreamPath(uint16_t iPhysicalAddress); + virtual cec_logical_addresses GetLogicalAddresses(void); const char *ToString(const cec_menu_state state); const char *ToString(const cec_version version); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index 3711686..e2ae7f5 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -381,4 +381,13 @@ int cec_set_stream_path_physical(uint16_t iPhysicalAddress) return cec_parser ? (cec_parser->SetStreamPath(iPhysicalAddress) ? 1 : 0) : -1; } +cec_logical_addresses cec_get_logical_addresses(void) +{ + cec_logical_addresses addr; + addr.Clear(); + if (cec_parser) + addr = cec_parser->GetLogicalAddresses(); + return addr; +} + //@} diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index c8e6819..b987ff9 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -278,6 +278,7 @@ void ShowHelpConsole(void) "[volup] send a volume up command to the amp if present" << endl << "[voldown] send a volume down command to the amp if present" << endl << "[mute] send a mute/unmute command to the amp if present" << endl << + "[self] show the list of addresses controlled by libCEC" << endl << "[scan] scan the CEC bus and display device info" << endl << "[mon] {1|0} enable or disable CEC bus monitoring." << endl << "[log] {1 - 31} change the log level. see cectypes.h for values." << endl << @@ -291,6 +292,28 @@ void ShowHelpConsole(void) "================================================================================" << endl; } +bool ProcessCommandSELF(ICECAdapter *parser, const string &command, string & UNUSED(arguments)) +{ + if (command == "self") + { + cec_logical_addresses addr = parser->GetLogicalAddresses(); + CStdString strOut = "Addresses controlled by libCEC: "; + bool bFirst(true); + for (uint8_t iPtr = 0; iPtr <= 15; iPtr++) + { + if (addr[iPtr]) + { + strOut.AppendFormat((bFirst ? "%d%s" : ", %d%s"), iPtr, parser->IsActiveSource((cec_logical_address)iPtr) ? "*" : ""); + bFirst = false; + } + } + PrintToStdOut(strOut.c_str()); + return true; + } + + return false; +} + bool ProcessCommandSP(ICECAdapter *parser, const string &command, string &arguments) { if (command == "sp") @@ -868,7 +891,8 @@ bool ProcessConsoleCommand(ICECAdapter *parser, string &input) ProcessCommandLOG(parser, command, input) || ProcessCommandSCAN(parser, command, input) || ProcessCommandSP(parser, command, input) || - ProcessCommandSPL(parser, command, input); + ProcessCommandSPL(parser, command, input) || + ProcessCommandSELF(parser, command, input); } } return true;