summaryrefslogtreecommitdiff
path: root/p2pvr/daemon/si.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/daemon/si.cpp')
-rw-r--r--p2pvr/daemon/si.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp
new file mode 100644
index 0000000..557003c
--- /dev/null
+++ b/p2pvr/daemon/si.cpp
@@ -0,0 +1,127 @@
+#include <pch.hpp>
+#include "si.h"
+#include "resources.h"
+#include "dvbsiHelpers.h"
+#include "sqlContainerCreator.h"
+#include <linux/dvb/frontend.h>
+#include <logger.h>
+
+ResourceString(SI_serviceNextUsed, daemon_sql_SI_serviceNextUsed_sql);
+ResourceString(SI_servicesSelectAll, daemon_sql_SI_servicesSelectAll_sql);
+ResourceString(SI_servicesSelectById, daemon_sql_SI_servicesSelectById_sql);
+ResourceString(SI_eventById, daemon_sql_SI_eventById_sql);
+ResourceString(SI_eventsOnNow, daemon_sql_SI_eventsOnNow_sql);
+ResourceString(SI_eventsInRange, daemon_sql_SI_eventsInRange_sql);
+
+P2PVR::Deliveries
+SI::GetAllDeliveries(short type, const Ice::Current &)
+{
+ Logger()->messagebf(LOG_DEBUG, "%s(type %d)", __PRETTY_FUNCTION__, type);
+ P2PVR::Deliveries rtn;
+ SelectPtr sel;
+ switch (type) {
+ case FE_OFDM:
+ {
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cc(rtn);
+ cc.populate(Select("SELECT * FROM delivery_dvbt ORDER BY transportStreamId").second);
+ break;
+ }
+ case FE_QAM:
+ {
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> cc(rtn);
+ cc.populate(Select("SELECT * FROM delivery_dvbc ORDER BY transportStreamId").second);
+ break;
+ }
+ case FE_QPSK:
+ {
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> cc(rtn);
+ cc.populate(Select("SELECT * FROM delivery_dvbs ORDER BY transportStreamId").second);
+ break;
+ }
+ }
+ Logger()->messagebf(LOG_DEBUG, "%s: Found %d delivery methods", __PRETTY_FUNCTION__, rtn.size());
+ return rtn;
+}
+
+DVBSI::DeliveryPtr
+SI::GetDeliveryForTransport(int id, const Ice::Current&)
+{
+ P2PVR::Deliveries rtn;
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cct(rtn);
+ cct.populate(Select("SELECT * FROM delivery_dvbt WHERE transportStreamId = ?", id).second);
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> ccc(rtn);
+ ccc.populate(Select("SELECT * FROM delivery_dvbc WHERE transportStreamId = ?", id).second);
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> ccs(rtn);
+ ccs.populate(Select("SELECT * FROM delivery_dvbs WHERE transportStreamId = ?", id).second);
+ return rtn.front();
+}
+
+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;
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cct(rtn);
+ cct.populate(Select("SELECT d.* FROM services s, delivery_dvbt d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id).second);
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> ccc(rtn);
+ ccc.populate(Select("SELECT d.* FROM services s, delivery_dvbc d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id).second);
+ SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> ccs(rtn);
+ ccs.populate(Select("SELECT d.* FROM services s, delivery_dvbs d WHERE serviceid = ? AND s.transportstreamid = d.transportstreamid", id).second);
+ return rtn.front();
+}
+
+DVBSI::ServiceList
+SI::GetServices(const Ice::Current&)
+{
+ DVBSI::ServiceList rtn;
+ SqlContainerCreator<DVBSI::ServiceList, DVBSI::Service> cc(rtn);
+ cc.populate(Select(SI_servicesSelectAll).second);
+ return rtn;
+}
+
+DVBSI::ServicePtr
+SI::GetService(int id, const Ice::Current&)
+{
+ DVBSI::ServiceList rtn;
+ SqlContainerCreator<DVBSI::ServiceList, DVBSI::Service> cc(rtn);
+ cc.populate(Select(SI_servicesSelectById, id).second);
+ if (rtn.empty()) throw P2PVR::NotFound();
+ return rtn.front();
+}
+
+DVBSI::EventPtr
+SI::GetEvent(int serviceId, int eventId, const Ice::Current &)
+{
+ DVBSI::Events rtn;
+ SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn);
+ cc.populate(Select(SI_eventById, serviceId, eventId).second);
+ if (rtn.empty()) throw P2PVR::NotFound();
+ return rtn.front();
+}
+
+DVBSI::Events
+SI::EventsOnNow(const Ice::Current &)
+{
+ DVBSI::Events rtn;
+ SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn);
+ cc.populate(Select(SI_eventsOnNow).second);
+ return rtn;
+}
+
+DVBSI::Events
+SI::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, const Ice::Current &)
+{
+ DVBSI::Events rtn;
+ SqlContainerCreator<DVBSI::Events, DVBSI::Event> cc(rtn);
+ cc.populate(Select(SI_eventsInRange, from, to).second);
+ return rtn;
+}
+