summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p2pvr/ice/p2pvr.ice2
-rw-r--r--p2pvr/lib/globalDevices.cpp17
-rw-r--r--p2pvr/lib/globalDevices.h1
-rw-r--r--p2pvr/lib/localDevices.cpp7
-rw-r--r--p2pvr/lib/localDevices.h1
5 files changed, 28 insertions, 0 deletions
diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice
index 8835511..1db9cf3 100644
--- a/p2pvr/ice/p2pvr.ice
+++ b/p2pvr/ice/p2pvr.ice
@@ -232,6 +232,8 @@ module P2PVR {
PrivateTuner * GetPrivateTuner(short type, long until);
// Release a tuner when no longer required.
idempotent void ReleaseTuner(Tuner * t);
+ // Count available tuners
+ idempotent int TunerCount();
};
interface LocalDevices extends Devices {
diff --git a/p2pvr/lib/globalDevices.cpp b/p2pvr/lib/globalDevices.cpp
index 8dfe77d..a21fe1f 100644
--- a/p2pvr/lib/globalDevices.cpp
+++ b/p2pvr/lib/globalDevices.cpp
@@ -57,3 +57,20 @@ GlobalDevices::ReleaseTuner(const P2PVR::TunerPrx & tuner, const Ice::Current &
}
}
+int
+GlobalDevices::TunerCount(const Ice::Current & ice)
+{
+ int total = 0;
+ auto ic = ice.adapter->getCommunicator();
+ BOOST_FOREACH(const auto & pool, Devices) {
+ try {
+ auto poolprx = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy(pool));
+ total += poolprx->TunerCount();
+ }
+ catch (...) {
+ // Not available, don't count 'em
+ }
+ }
+ return total;
+}
+
diff --git a/p2pvr/lib/globalDevices.h b/p2pvr/lib/globalDevices.h
index 0cf9636..8f2acd9 100644
--- a/p2pvr/lib/globalDevices.h
+++ b/p2pvr/lib/globalDevices.h
@@ -13,6 +13,7 @@ class GlobalDevices : public P2PVR::Devices {
P2PVR::TunerPrx GetTunerAny(short type, const DVBSI::DeliveryPtr &, Ice::Long until, const Ice::Current &);
P2PVR::PrivateTunerPrx GetPrivateTuner(short type, Ice::Long until, const Ice::Current &);
void ReleaseTuner(const P2PVR::TunerPrx &, const Ice::Current &);
+ int TunerCount(const Ice::Current &);
INITOPTIONS;
private:
diff --git a/p2pvr/lib/localDevices.cpp b/p2pvr/lib/localDevices.cpp
index 5bb2b61..51eed31 100644
--- a/p2pvr/lib/localDevices.cpp
+++ b/p2pvr/lib/localDevices.cpp
@@ -153,6 +153,13 @@ LocalDevices::ReleaseTuner(const P2PVR::TunerPrx & tuner, const Ice::Current & i
}
}
+int
+LocalDevices::TunerCount(const Ice::Current &)
+{
+ std::lock_guard<std::mutex> g(lock);
+ return devices.size();
+}
+
void
LocalDevices::Scan(const Ice::Current &)
{
diff --git a/p2pvr/lib/localDevices.h b/p2pvr/lib/localDevices.h
index 9e62525..7185dde 100644
--- a/p2pvr/lib/localDevices.h
+++ b/p2pvr/lib/localDevices.h
@@ -17,6 +17,7 @@ class LocalDevices : public P2PVR::LocalDevices {
P2PVR::TunerPrx GetTunerAny(short type, const DVBSI::DeliveryPtr &, Ice::Long until, const Ice::Current &);
P2PVR::PrivateTunerPrx GetPrivateTuner(short type, Ice::Long until, const Ice::Current &);
void ReleaseTuner(const P2PVR::TunerPrx &, const Ice::Current &);
+ int TunerCount(const Ice::Current &);
void Scan(const Ice::Current &);
void Add(const std::string & frontend, const Ice::Current &);