bool CCECClient::SendSetActiveSource(const cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */) { // get the devices that are controlled by us CECDEVICEVEC devices; m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); // filter out the device that matches the given type if (type != CEC_DEVICE_TYPE_RESERVED) CCECDeviceMap::FilterType(type, devices); // no devices left, re-fetch the list of devices that are controlled by us if (devices.empty()) m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); if (!devices.empty()) { // get the first device from the list CCECBusDevice *device = *devices.begin(); // and activate it if (!m_processor->CECInitialised()) device->MarkAsActiveSource(); else if (device->HasValidPhysicalAddress()) return device->ActivateSource(); } return false; }
bool CCECProcessor::IsPresentDeviceType(cec_device_type type) { CECDEVICEVEC devices; m_busDevices->GetByType(type, devices); CCECDeviceMap::FilterActive(devices); return !devices.empty(); }
bool CCECClient::IsActiveDeviceType(const cec_device_type type) { CECDEVICEVEC activeDevices; if (m_processor) m_processor->GetDevices()->GetActive(activeDevices); CCECDeviceMap::FilterType(type, activeDevices); return !activeDevices.empty(); }
CCECPlaybackDevice *CCECClient::GetPlaybackDevice(void) { CCECPlaybackDevice *device(NULL); CECDEVICEVEC devices; // get the playback devices m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); CCECDeviceMap::FilterType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE, devices); // no matches, get the recording devices if (devices.empty()) { m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); CCECDeviceMap::FilterType(CEC_DEVICE_TYPE_RECORDING_DEVICE, devices); } // get the first device that matches, and cast it to CCECPlaybackDevice if (!devices.empty()) device = (*devices.begin())->AsPlaybackDevice(); return device; }
CCECBusDevice *CCECClient::GetDeviceByType(const cec_device_type type) const { // get all devices that match our logical addresses CECDEVICEVEC devices; m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); // filter the type we need CCECDeviceMap::FilterType(type, devices); return devices.empty() ? NULL : *devices.begin(); }
bool CCECClient::OnRegister(void) { // return false if already initialised if (IsInitialised()) return true; // get all device we control CECDEVICEVEC devices; m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses); // return false when no devices were found if (devices.empty()) { LIB_CEC->AddLog(CEC_LOG_WARNING, "cannot find the primary device (logical address %x)", GetPrimaryLogicalAdddress()); return false; } // mark as initialised SetInitialised(true); // configure all devices for (CECDEVICEVEC::iterator it = devices.begin(); it != devices.end(); it++) { // only set our OSD name for the primary device if ((*it)->GetLogicalAddress() == GetPrimaryLogicalAdddress()) (*it)->SetOSDName(m_configuration.strDeviceName); // set the default menu language for devices we control (*it)->SetMenuLanguage(m_configuration.strDeviceLanguage); } // set the physical address SetPhysicalAddress(m_configuration); // make the primary device the active source if the option is set if (m_configuration.bActivateSource == 1) GetPrimaryDevice()->ActivateSource(500); return true; }