diff options
-rw-r--r-- | p2pvr/lib/maintenance.cpp | 44 | ||||
-rw-r--r-- | p2pvr/lib/si.cpp | 6 | ||||
-rw-r--r-- | p2pvr/lib/siParsers/network.cpp | 71 |
3 files changed, 93 insertions, 28 deletions
diff --git a/p2pvr/lib/maintenance.cpp b/p2pvr/lib/maintenance.cpp index 2bc026e..f2bf012 100644 --- a/p2pvr/lib/maintenance.cpp +++ b/p2pvr/lib/maintenance.cpp @@ -5,6 +5,7 @@ #include <Ice/Ice.h> #include "bindTimerTask.h" #include <linux/dvb/frontend.h> +#include <cxxabi.h> time_t Maintenance::periodUpdateNetwork; time_t Maintenance::periodUpdateServices; @@ -57,26 +58,33 @@ Maintenance::ScheduledUpdate() Logger()->messagebf(LOG_DEBUG, "%s: triggered", __PRETTY_FUNCTION__); if (!updateRunning) { std::thread update([this] { - ScopeObject notRunning([this]{ updateRunning = false; }); - updateRunning = true; - auto si = P2PVR::MaintenancePrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Maintenance"))); - time_t now = time(NULL); - if (lastUpdateNetwork < now - periodUpdateNetwork) { - Logger()->messagebf(LOG_INFO, "%s: updating network", __PRETTY_FUNCTION__); - si->UpdateNetwork(FE_OFDM); - time(&lastUpdateNetwork); + try { + ScopeObject notRunning([this]{ updateRunning = false; }); + updateRunning = true; + auto si = P2PVR::MaintenancePrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Maintenance"))); + time_t now = time(NULL); + if (lastUpdateNetwork < now - periodUpdateNetwork) { + Logger()->messagebf(LOG_INFO, "%s: updating network", __PRETTY_FUNCTION__); + si->UpdateNetwork(FE_OFDM); + time(&lastUpdateNetwork); + } + if (lastUpdateServices < now - periodUpdateServices) { + Logger()->messagebf(LOG_INFO, "%s: updating services", __PRETTY_FUNCTION__); + si->UpdateServices(FE_OFDM); + time(&lastUpdateServices); + } + if (lastUpdateEvents < now - periodUpdateEvents) { + Logger()->messagebf(LOG_INFO, "%s: updating events", __PRETTY_FUNCTION__); + si->UpdateEvents(FE_OFDM); + time(&lastUpdateEvents); + } + Logger()->messagebf(LOG_DEBUG, "%s: completed", __PRETTY_FUNCTION__); } - if (lastUpdateServices < now - periodUpdateServices) { - Logger()->messagebf(LOG_INFO, "%s: updating services", __PRETTY_FUNCTION__); - si->UpdateServices(FE_OFDM); - time(&lastUpdateServices); + catch (const std::exception & ex) { + char * buf = __cxxabiv1::__cxa_demangle(typeid(ex).name(), NULL, NULL, NULL); + Logger()->messagebf(LOG_ERR, "%s: failed %s: %s", __PRETTY_FUNCTION__, buf, ex.what()); + free(buf); } - if (lastUpdateEvents < now - periodUpdateEvents) { - Logger()->messagebf(LOG_INFO, "%s: updating events", __PRETTY_FUNCTION__); - si->UpdateEvents(FE_OFDM); - time(&lastUpdateEvents); - } - Logger()->messagebf(LOG_DEBUG, "%s: completed", __PRETTY_FUNCTION__); }); update.detach(); } diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp index 131cf69..3431b67 100644 --- a/p2pvr/lib/si.cpp +++ b/p2pvr/lib/si.cpp @@ -21,19 +21,19 @@ SI::GetAllDeliveries(short type, const Ice::Current &) case FE_OFDM: { SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cc(rtn); - cc.populate(Select("SELECT * FROM delivery_dvbt").second); + 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").second); + 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").second); + cc.populate(Select("SELECT * FROM delivery_dvbs ORDER BY transportStreamId").second); break; } } diff --git a/p2pvr/lib/siParsers/network.cpp b/p2pvr/lib/siParsers/network.cpp index b9a58ba..b91da1a 100644 --- a/p2pvr/lib/siParsers/network.cpp +++ b/p2pvr/lib/siParsers/network.cpp @@ -1,6 +1,9 @@ #include <pch.hpp> #include "network.h" #include <boost/bind.hpp> +#include <linux/dvb/frontend.h> +#include <safeMapFind.h> +#include <misc.h> struct NetworkStreamsHeader { #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ @@ -154,6 +157,60 @@ SiNetworkInformationParser::parseDescriptor_NetworkName(DVBSI::NetworkPtr n, con n->Name = *convert((const char *)p, len); } +#define SINOTSUPPORTED(What) \ +class What##NotSupported : public NotSupported { public: What##NotSupported(short id) : NotSupported(stringbf(#What" 0x%2x", id)) { } }; + +std::map<short, fe_bandwidth_t> tbandwidths { + {0, BANDWIDTH_8_MHZ}, + {1, BANDWIDTH_7_MHZ}, + {2, BANDWIDTH_6_MHZ}, + {3, BANDWIDTH_5_MHZ} +}; +SINOTSUPPORTED(Bandwidth); + +std::map<short, fe_modulation_t> tconstellations { + {0, QPSK}, + {1, QAM_16}, + {2, QAM_64} +}; +SINOTSUPPORTED(Constellation); + +std::map<short, fe_hierarchy_t> thierarchies { + {0, HIERARCHY_NONE}, + {1, HIERARCHY_1}, + {2, HIERARCHY_2}, + {3, HIERARCHY_4}, + {4, HIERARCHY_NONE}, + {5, HIERARCHY_1}, + {6, HIERARCHY_2}, + {7, HIERARCHY_4} +}; +SINOTSUPPORTED(Hierarchy); + +std::map<short, fe_code_rate_t> tcoderates { + {0, FEC_1_2}, + {1, FEC_2_3}, + {2, FEC_3_4}, + {3, FEC_5_6}, + {4, FEC_7_8} +}; +SINOTSUPPORTED(CodeRate); + +std::map<short, fe_guard_interval_t> tguardintervals { + {0, GUARD_INTERVAL_1_32}, + {1, GUARD_INTERVAL_1_16}, + {2, GUARD_INTERVAL_1_8}, + {3, GUARD_INTERVAL_1_4} +}; +SINOTSUPPORTED(GuardInterval); + +std::map<short, fe_transmit_mode_t> ttransmitmodes { + {0, TRANSMISSION_MODE_2K}, + {1, TRANSMISSION_MODE_8K}, + {2, TRANSMISSION_MODE_4K} +}; +SINOTSUPPORTED(TransmissionMode); + void SiNetworkInformationParser::parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTransportStreamPtr nts, const u_char * data, size_t len) { @@ -162,16 +219,16 @@ SiNetworkInformationParser::parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTr DVBSI::TerrestrialDeliveryPtr td = new DVBSI::TerrestrialDelivery; td->Frequency = ((uint64_t)ntohl(tdd->Frequency)) * 10; td->TransportStreamId = nts->TransportStreamId; - td->Bandwidth = tdd->Bandwidth; + td->Bandwidth = safeMapLookup<BandwidthNotSupported>(tbandwidths, tdd->Bandwidth); td->Priority = tdd->Priority; td->TimeSlicing = tdd->TimeSlicing; td->MpeFec = tdd->MpeFec; - td->Constellation = tdd->Constellation; - td->Hierarchy = tdd->Hierarchy; - td->CodeRateHP = tdd->CodeRateHP; - td->CodeRateLP = tdd->CodeRateLP; - td->GuardInterval = tdd->GuardInterval; - td->TransmissionMode = tdd->TransmissionMode; + td->Constellation = safeMapLookup<ConstellationNotSupported>(tconstellations, tdd->Constellation); + td->Hierarchy = safeMapLookup<HierarchyNotSupported>(thierarchies, tdd->Hierarchy); + td->CodeRateHP = safeMapLookup<CodeRateNotSupported>(tcoderates, tdd->CodeRateHP); + td->CodeRateLP = safeMapLookup<CodeRateNotSupported>(tcoderates, tdd->CodeRateLP); + td->GuardInterval = safeMapLookup<GuardIntervalNotSupported>(tguardintervals, tdd->GuardInterval); + td->TransmissionMode = safeMapLookup<TransmissionModeNotSupported>(ttransmitmodes, tdd->TransmissionMode); td->OtherFrequencyFlag = tdd->OtherFrequencyFlag; nts->Terrestrial = td; } |