* http://www.pulse-eight.net/
*/
+#include "env.h"
#include "LibCEC.h"
-#include "adapter/USBCECAdapterDetection.h"
-#include "adapter/USBCECAdapterCommunication.h"
+#include "adapter/AdapterFactory.h"
+#include "adapter/AdapterCommunication.h"
#include "CECProcessor.h"
#include "CECTypeUtils.h"
#include "devices/CECAudioSystem.h"
int8_t CLibCEC::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
{
- return CUSBCECAdapterDetection::FindAdapters(deviceList, iBufSize, strDevicePath);
+ return CAdapterFactory(this).FindAdapters(deviceList, iBufSize, strDevicePath);
}
bool CLibCEC::StartBootloader(void)
bool CLibCEC::Transmit(const cec_command &data)
{
- return m_client ? m_client->Transmit(data) : false;
+ return m_client ? m_client->Transmit(data, false) : false;
}
bool CLibCEC::SetLogicalAddress(cec_logical_address iLogicalAddress)
return addresses;
}
-bool CLibCEC::GetNextLogMessage(cec_log_message *message)
-{
- return m_client ? m_client->GetNextLogMessage(message) : false;
-}
-
-bool CLibCEC::GetNextKeypress(cec_keypress *key)
-{
- return m_client ? m_client->GetNextKeypress(key) : false;
-}
-
-bool CLibCEC::GetNextCommand(cec_command *command)
-{
- return m_client ? m_client->GetNextCommand(command) : false;
-}
-
cec_device_type CLibCEC::GetType(cec_logical_address address)
{
return CCECTypeUtils::GetType(address);
(*it)->AddLog(message);
}
-void CLibCEC::Alert(const libcec_alert type, const libcec_parameter ¶m)
+void CLibCEC::AddCommand(const cec_command &command)
{
- // send the alert to all clients
+ // send the command to all clients
for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
- (*it)->Alert(type, param);
-}
-
-bool CLibCEC::SetActiveView(void)
-{
- AddLog(CEC_LOG_WARNING, "deprecated method %s called", __FUNCTION__);
- return SetActiveSource();
+ (*it)->AddCommand(command);
}
-bool CLibCEC::EnablePhysicalAddressDetection(void)
+void CLibCEC::Alert(const libcec_alert type, const libcec_parameter ¶m)
{
- AddLog(CEC_LOG_WARNING, "deprecated method %s called", __FUNCTION__);
- return true;
+ // send the alert to all clients
+ for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
+ (*it)->Alert(type, param);
}
CCECClient *CLibCEC::RegisterClient(libcec_configuration &configuration)
return static_cast< void* > (lib);
}
-void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types, uint16_t iPhysicalAddress /* = 0 */)
+void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types)
{
- libcec_configuration configuration;
+ libcec_configuration configuration; configuration.Clear();
// client version < 1.5.0
snprintf(configuration.strDeviceName, 13, "%s", strDeviceName);
configuration.deviceTypes = types;
- configuration.iPhysicalAddress = iPhysicalAddress;
+ configuration.iPhysicalAddress = CEC_INVALID_PHYSICAL_ADDRESS;
if (configuration.deviceTypes.IsEmpty())
configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
{
bool bReturn(false);
cec_adapter deviceList[1];
- if (CUSBCECAdapterDetection::FindAdapters(deviceList, 1) > 0)
+ if (CAdapterFactory(NULL).FindAdapters(deviceList, 1, 0) > 0)
{
- CUSBCECAdapterCommunication comm(NULL, deviceList[0].comm);
- CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT);
- while (timeout.TimeLeft() > 0 && (bReturn = comm.Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false)
+ CAdapterFactory factory(NULL);
+ IAdapterCommunication *comm = factory.GetInstance(deviceList[0].comm);
+ if (comm)
{
- comm.Close();
- CEvent::Sleep(500);
+ CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT);
+ while (timeout.TimeLeft() > 0 &&
+ (bReturn = comm->Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false)
+ {
+ comm->Close();
+ CEvent::Sleep(500);
+ }
+ if (comm->IsOpen())
+ bReturn = comm->StartBootloader();
+
+ delete comm;
}
- if (comm.IsOpen())
- bReturn = comm.StartBootloader();
}
return bReturn;
return m_cec->GetDeviceInformation(strPort, config, iTimeoutMs);
}
-// no longer being used
-void CLibCEC::AddKey(const cec_keypress &UNUSED(key)) {}
-void CLibCEC::AddCommand(const cec_command &UNUSED(command)) {}
-void CLibCEC::ConfigurationChanged(const libcec_configuration &UNUSED(config)) {}
-void CLibCEC::SetCurrentButton(cec_user_control_code UNUSED(iButtonCode)) {}
-CLibCEC *CLibCEC::GetInstance(void) { return NULL; }
-void CLibCEC::SetInstance(CLibCEC *UNUSED(instance)) {}
+const char *CLibCEC::GetLibInfo(void)
+{
+#ifndef LIB_INFO
+#ifdef _WIN32
+#define FEATURES "'P8 USB' 'P8 USB detect'"
+#ifdef _WIN64
+#define HOST_TYPE "Windows (x64)"
+#else
+#define HOST_TYPE "Windows (x86)"
+#endif
+#else
+#define HOST_TYPE "unknown"
+#define FEATURES "unknown"
+#endif
+
+ return "host: " HOST_TYPE ", features: " FEATURES ", compiled: " __DATE__;
+#else
+ return LIB_INFO;
+#endif
+}
+
+const char *CLibCEC::ToString(const cec_user_control_code key)
+{
+ return CCECTypeUtils::ToString(key);
+}
+
+void CLibCEC::InitVideoStandalone(void)
+{
+ CAdapterFactory::InitVideoStandalone();
+}
+
+const char *CLibCEC::ToString(const cec_adapter_type type)
+{
+ return CCECTypeUtils::ToString(type);
+}