diff options
Diffstat (limited to 'p2pvr/lib/globalDevices.cpp')
-rw-r--r-- | p2pvr/lib/globalDevices.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/p2pvr/lib/globalDevices.cpp b/p2pvr/lib/globalDevices.cpp new file mode 100644 index 0000000..8dfe77d --- /dev/null +++ b/p2pvr/lib/globalDevices.cpp @@ -0,0 +1,59 @@ +#include "globalDevices.h" +#include <Ice/Ice.h> + +std::vector<std::string> GlobalDevices::Devices; + +DECLARE_OPTIONS(GlobalDevices, "P2PVR Devices") +("p2pvr.globaldevices.carddaemon", + Options::functions( + [](const VariableType & df) { Devices.push_back(df); }, + []{ Devices.clear(); }), + "ICE address of remote device pools (<adapter>:<endpoint>)") +END_OPTIONS(GlobalDevices); + +P2PVR::TunerPrx +GlobalDevices::GetTunerSpecific(const DVBSI::DeliveryPtr & delivery, Ice::Long until, const Ice::Current & ice) +{ + auto ic = ice.adapter->getCommunicator(); + BOOST_FOREACH(const auto & pool, Devices) { + auto poolprx = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy(pool)); + auto tuner = poolprx->GetTunerSpecific(delivery, until); + if (tuner) return tuner; + } + return NULL; +} + +P2PVR::TunerPrx +GlobalDevices::GetTunerAny(short type, const DVBSI::DeliveryPtr & delivery, Ice::Long until, const Ice::Current & ice) +{ + auto ic = ice.adapter->getCommunicator(); + BOOST_FOREACH(const auto & pool, Devices) { + auto poolprx = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy(pool)); + auto tuner = poolprx->GetTunerAny(type, delivery, until); + if (tuner) return tuner; + } + return NULL; +} + +P2PVR::PrivateTunerPrx +GlobalDevices::GetPrivateTuner(short type, Ice::Long until, const Ice::Current & ice) +{ + auto ic = ice.adapter->getCommunicator(); + BOOST_FOREACH(const auto & pool, Devices) { + auto poolprx = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy(pool)); + auto tuner = poolprx->GetPrivateTuner(type, until); + if (tuner) return tuner; + } + return NULL; +} + +void +GlobalDevices::ReleaseTuner(const P2PVR::TunerPrx & tuner, const Ice::Current & ice) +{ + auto ic = ice.adapter->getCommunicator(); + BOOST_FOREACH(const auto & pool, Devices) { + auto poolprx = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy(pool)); + poolprx->ReleaseTuner(tuner); + } +} + |