diff options
-rw-r--r-- | p2pvr/ice/p2pvr.ice | 1 | ||||
-rw-r--r-- | p2pvr/lib/maintenance/events.cpp | 6 | ||||
-rw-r--r-- | p2pvr/lib/maintenance/network.cpp | 5 | ||||
-rw-r--r-- | p2pvr/lib/maintenance/services.cpp | 6 | ||||
-rw-r--r-- | p2pvr/lib/si.cpp | 10 | ||||
-rw-r--r-- | p2pvr/lib/si.h | 1 | ||||
-rw-r--r-- | p2pvr/lib/sql/SI_serviceNextUsed.sql | 12 |
7 files changed, 32 insertions, 9 deletions
diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 7b5f2fb..984f18a 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -84,6 +84,7 @@ module P2PVR { idempotent Deliveries GetAllDeliveries(short type); idempotent DVBSI::Delivery GetDeliveryForService(int id); idempotent DVBSI::Delivery GetDeliveryForTransport(int id); + idempotent DVBSI::Delivery GetDeliveryForSi(); // Get services idempotent DVBSI::ServiceList GetServices(); idempotent DVBSI::Service GetService(int id); diff --git a/p2pvr/lib/maintenance/events.cpp b/p2pvr/lib/maintenance/events.cpp index 94bb7ef..baa2bbf 100644 --- a/p2pvr/lib/maintenance/events.cpp +++ b/p2pvr/lib/maintenance/events.cpp @@ -49,13 +49,13 @@ class SiEventsMerger : public IHaveSubTasks { TemporarayIceAdapterObject<P2PVR::RawDataClient> parser(ice.adapter, new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec))); - const auto deliveries = si->GetAllDeliveries(type); - if (deliveries.empty()) { + auto delivery = si->GetDeliveryForSi(); + if (!delivery) { throw std::runtime_error("no delivery methods"); } Logger()->messagebf(LOG_DEBUG, "%s: Getting a tuner", __PRETTY_FUNCTION__); - auto tuner = devs->GetTunerAny(type, deliveries.front()); + auto tuner = devs->GetTunerAny(type, delivery); Logger()->messagebf(LOG_DEBUG, "%s: Fetching events", __PRETTY_FUNCTION__); tuner->SendEventInformation(parser); devs->ReleaseTuner(tuner); diff --git a/p2pvr/lib/maintenance/network.cpp b/p2pvr/lib/maintenance/network.cpp index c472899..c66a2dd 100644 --- a/p2pvr/lib/maintenance/network.cpp +++ b/p2pvr/lib/maintenance/network.cpp @@ -75,9 +75,8 @@ Maintenance::UpdateNetwork(short type, const Ice::Current & ice) if (!devs) { throw std::runtime_error("bad proxy(s)"); } - const auto transports = si->GetAllDeliveries(type); - if (!transports.empty()) { - const auto & transport = transports.front(); + auto transport = si->GetDeliveryForSi(); + if (transport) { P2PVR::TunerPrx tuner; try { tuner = devs->GetTunerAny(type, transport); diff --git a/p2pvr/lib/maintenance/services.cpp b/p2pvr/lib/maintenance/services.cpp index d63ca2a..2f97161 100644 --- a/p2pvr/lib/maintenance/services.cpp +++ b/p2pvr/lib/maintenance/services.cpp @@ -53,13 +53,13 @@ Maintenance::UpdateServices(short type, const Ice::Current & ice) auto siparser = new SiServicesMerger(this); TemporarayIceAdapterObject<P2PVR::RawDataClient> parser(ice.adapter, siparser); - const auto deliveries = si->GetAllDeliveries(type); - if (deliveries.empty()) { + auto delivery = si->GetDeliveryForSi(); + if (!delivery) { throw std::runtime_error("no delivery methods"); } Logger()->messagebf(LOG_DEBUG, "%s: Getting a tuner", __PRETTY_FUNCTION__); - auto tuner = devs->GetTunerAny(type, deliveries.front()); + auto tuner = devs->GetTunerAny(type, delivery); Logger()->messagebf(LOG_DEBUG, "%s: Fetching service list", __PRETTY_FUNCTION__); tuner->SendServiceDescriptions(parser); Logger()->messagebf(LOG_INFO, "%s: Updated service list", __PRETTY_FUNCTION__); diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp index a61566b..5640fe8 100644 --- a/p2pvr/lib/si.cpp +++ b/p2pvr/lib/si.cpp @@ -6,6 +6,7 @@ #include <linux/dvb/frontend.h> #include <logger.h> +ResourceString(SI_serviceNextUsed, lib_sql_SI_serviceNextUsed_sql); ResourceString(SI_servicesSelectAll, lib_sql_SI_servicesSelectAll_sql); ResourceString(SI_servicesSelectById, lib_sql_SI_servicesSelectById_sql); ResourceString(SI_eventById, lib_sql_SI_eventById_sql); @@ -56,6 +57,15 @@ SI::GetDeliveryForTransport(int id, const Ice::Current&) } DVBSI::DeliveryPtr +SI::GetDeliveryForSi(const Ice::Current&) +{ + P2PVR::Deliveries rtn; + SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cct(rtn); + cct.populate(Select(SI_serviceNextUsed).second); + return rtn.front(); +} + +DVBSI::DeliveryPtr SI::GetDeliveryForService(int id, const Ice::Current&) { P2PVR::Deliveries rtn; diff --git a/p2pvr/lib/si.h b/p2pvr/lib/si.h index 6e41d06..6b720dc 100644 --- a/p2pvr/lib/si.h +++ b/p2pvr/lib/si.h @@ -9,6 +9,7 @@ class SI : public P2PVR::SI, public DatabaseClient { P2PVR::Deliveries GetAllDeliveries(short type, const Ice::Current &); DVBSI::DeliveryPtr GetDeliveryForService(int id, const Ice::Current &); DVBSI::DeliveryPtr GetDeliveryForTransport(int id, const Ice::Current &); + DVBSI::DeliveryPtr GetDeliveryForSi(const Ice::Current &); DVBSI::ServiceList GetServices(const Ice::Current &); DVBSI::ServicePtr GetService(int id, const Ice::Current &); diff --git a/p2pvr/lib/sql/SI_serviceNextUsed.sql b/p2pvr/lib/sql/SI_serviceNextUsed.sql new file mode 100644 index 0000000..8e906ad --- /dev/null +++ b/p2pvr/lib/sql/SI_serviceNextUsed.sql @@ -0,0 +1,12 @@ +SELECT dd.* +FROM delivery_dvbt dd, services s + LEFT OUTER JOIN record r + ON r.serviceid = s.serviceid + AND r.recordstatus = 0 + LEFT OUTER JOIN events e + ON r.eventid = e.eventid + AND r.serviceid = e.serviceid + AND e.starttime > NOW() +WHERE dd.transportstreamid = s.transportstreamid +ORDER BY e.starttime, s.serviceid +LIMIT 1 |