diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 392aa4dc1..36a4e9922 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -60,6 +60,7 @@ #include "eitd.h" #include "edvbstring.h" +#include "xmlutil.h" //#define ENABLE_SDT //FIXME @@ -106,13 +107,11 @@ static long secondsExtendedTextCache; static long oldEventsAre; static int scanning = 1; -std::string epg_filter_dir = "/var/tuxbox/config/zapit/epgfilter.xml"; -static bool epg_filter_is_whitelist = false; -static bool epg_filter_except_current_next = false; -static bool messaging_zap_detected = false; +extern bool epg_filter_is_whitelist; +extern bool epg_filter_except_current_next; -std::string dvbtime_filter_dir = "/var/tuxbox/config/zapit/dvbtimefilter.xml"; -static bool dvb_time_update = false; +static bool messaging_zap_detected = false; +/*static*/ bool dvb_time_update = false; //NTP-Config #define CONF_FILE "/var/tuxbox/config/neutrino.conf" @@ -264,122 +263,6 @@ static MySIeventUniqueKeysMetaOrderServiceUniqueKey mySIeventUniqueKeysMetaOrder static MySIservicesOrderUniqueKey mySIservicesOrderUniqueKey; static MySIservicesNVODorderUniqueKey mySIservicesNVODorderUniqueKey; -struct EPGFilter -{ - t_original_network_id onid; - t_transport_stream_id tsid; - t_service_id sid; - EPGFilter *next; -}; - -struct ChannelBlacklist -{ - t_channel_id chan; - t_channel_id mask; - ChannelBlacklist *next; -}; - -struct ChannelNoDVBTimelist -{ - t_channel_id chan; - t_channel_id mask; - ChannelNoDVBTimelist *next; -}; - -EPGFilter *CurrentEPGFilter = NULL; -ChannelBlacklist *CurrentBlacklist = NULL; -ChannelNoDVBTimelist *CurrentNoDVBTime = NULL; - -static bool checkEPGFilter(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) -{ - EPGFilter *filterptr = CurrentEPGFilter; - while (filterptr) - { - if (((filterptr->onid == onid) || (filterptr->onid == 0)) && - ((filterptr->tsid == tsid) || (filterptr->tsid == 0)) && - ((filterptr->sid == sid) || (filterptr->sid == 0))) - return true; - filterptr = filterptr->next; - } - return false; -} - -static bool checkBlacklist(t_channel_id channel_id) -{ - ChannelBlacklist *blptr = CurrentBlacklist; - while (blptr) - { - if (blptr->chan == (channel_id & blptr->mask)) - return true; - blptr = blptr->next; - } - return false; -} - -static bool checkNoDVBTimelist(t_channel_id channel_id) -{ - ChannelNoDVBTimelist *blptr = CurrentNoDVBTime; - while (blptr) - { - if (blptr->chan == (channel_id & blptr->mask)) - return true; - blptr = blptr->next; - } - return false; -} - -static void addEPGFilter(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) -{ - if (!checkEPGFilter(onid, tsid, sid)) - { - dprintf("Add EPGFilter for onid=\"%04x\" tsid=\"%04x\" service_id=\"%04x\"\n", onid, tsid, sid); - EPGFilter *node = new EPGFilter; - node->onid = onid; - node->tsid = tsid; - node->sid = sid; - node->next = CurrentEPGFilter; - CurrentEPGFilter = node; - } -} - -static void addBlacklist(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) -{ - t_channel_id channel_id = - CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID(sid, onid, tsid); - t_channel_id mask = - CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID( - (sid ? 0xFFFF : 0), (onid ? 0xFFFF : 0), (tsid ? 0xFFFF : 0) - ); - if (!checkBlacklist(channel_id)) - { - xprintf("Add Channel Blacklist for channel 0x%012llx, mask 0x%012llx\n", channel_id, mask); - ChannelBlacklist *node = new ChannelBlacklist; - node->chan = channel_id; - node->mask = mask; - node->next = CurrentBlacklist; - CurrentBlacklist = node; - } -} - -static void addNoDVBTimelist(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) -{ - t_channel_id channel_id = - CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID(sid, onid, tsid); - t_channel_id mask = - CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID( - (sid ? 0xFFFF : 0), (onid ? 0xFFFF : 0), (tsid ? 0xFFFF : 0) - ); - if (!checkNoDVBTimelist(channel_id)) - { - xprintf("Add channel 0x%012llx, mask 0x%012llx to NoDVBTimelist\n", channel_id, mask); - ChannelNoDVBTimelist *node = new ChannelNoDVBTimelist; - node->chan = channel_id; - node->mask = mask; - node->next = CurrentNoDVBTime; - CurrentNoDVBTime = node; - } -} - // Loescht ein Event aus allen Mengen static bool deleteEvent(const event_id_t uniqueKey) { @@ -3780,6 +3663,7 @@ static void *houseKeepingThread(void *) pthread_exit(NULL); } +#if 0 static void readEPGFilter(void) { xmlDocPtr filter_parser = parseXmlFile(epg_filter_dir.c_str()); @@ -3846,6 +3730,7 @@ static void readDVBTimeFilter(void) dvb_time_update = true; } } +#endif extern cDemux * dmxUTC; diff --git a/src/eitd/xmlutil.cpp b/src/eitd/xmlutil.cpp index 5ad5bd492..d3bb0a420 100644 --- a/src/eitd/xmlutil.cpp +++ b/src/eitd/xmlutil.cpp @@ -1,5 +1,4 @@ // -// sectionsd.cpp (network daemon for SI-sections) // (dbox-II-project) // // Copyright (C) 2001 by fnbrd @@ -24,48 +23,34 @@ // #include -#include -#include -#include + #include #include #include #include #include -#include -#include -#include -#include -#include -#include #include -#include - -#include -#include - -#include -#include #include #include -// Daher nehmen wir SmartPointers aus der Boost-Lib (www.boost.org) -#include - -#include -#include -#include #include +#include "xmlutil.h" #include "eitd.h" void addEvent(const SIevent &evt, const time_t zeit, bool cn = false); extern MySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey; extern bool reader_ready; extern pthread_rwlock_t eventsLock; +extern bool dvb_time_update; + +std::string epg_filter_dir = "/var/tuxbox/config/zapit/epgfilter.xml"; +std::string dvbtime_filter_dir = "/var/tuxbox/config/zapit/dvbtimefilter.xml"; +bool epg_filter_is_whitelist = false; +bool epg_filter_except_current_next = false; inline void readLockEvents(void) { @@ -76,6 +61,189 @@ inline void unlockEvents(void) pthread_rwlock_unlock(&eventsLock); } +struct EPGFilter +{ + t_original_network_id onid; + t_transport_stream_id tsid; + t_service_id sid; + EPGFilter *next; +}; + +struct ChannelBlacklist +{ + t_channel_id chan; + t_channel_id mask; + ChannelBlacklist *next; +}; + +struct ChannelNoDVBTimelist +{ + t_channel_id chan; + t_channel_id mask; + ChannelNoDVBTimelist *next; +}; + +static EPGFilter *CurrentEPGFilter = NULL; +static ChannelBlacklist *CurrentBlacklist = NULL; +static ChannelNoDVBTimelist *CurrentNoDVBTime = NULL; + +bool checkEPGFilter(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) +{ + EPGFilter *filterptr = CurrentEPGFilter; + while (filterptr) + { + if (((filterptr->onid == onid) || (filterptr->onid == 0)) && + ((filterptr->tsid == tsid) || (filterptr->tsid == 0)) && + ((filterptr->sid == sid) || (filterptr->sid == 0))) + return true; + filterptr = filterptr->next; + } + return false; +} + +bool checkBlacklist(t_channel_id channel_id) +{ + ChannelBlacklist *blptr = CurrentBlacklist; + while (blptr) + { + if (blptr->chan == (channel_id & blptr->mask)) + return true; + blptr = blptr->next; + } + return false; +} + +bool checkNoDVBTimelist(t_channel_id channel_id) +{ + ChannelNoDVBTimelist *blptr = CurrentNoDVBTime; + while (blptr) + { + if (blptr->chan == (channel_id & blptr->mask)) + return true; + blptr = blptr->next; + } + return false; +} + +static void addEPGFilter(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) +{ + if (!checkEPGFilter(onid, tsid, sid)) + { + dprintf("Add EPGFilter for onid=\"%04x\" tsid=\"%04x\" service_id=\"%04x\"\n", onid, tsid, sid); + EPGFilter *node = new EPGFilter; + node->onid = onid; + node->tsid = tsid; + node->sid = sid; + node->next = CurrentEPGFilter; + CurrentEPGFilter = node; + } +} + +static void addBlacklist(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) +{ + t_channel_id channel_id = + CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID(sid, onid, tsid); + t_channel_id mask = + CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID( + (sid ? 0xFFFF : 0), (onid ? 0xFFFF : 0), (tsid ? 0xFFFF : 0) + ); + if (!checkBlacklist(channel_id)) + { + xprintf("Add Channel Blacklist for channel 0x%012llx, mask 0x%012llx\n", channel_id, mask); + ChannelBlacklist *node = new ChannelBlacklist; + node->chan = channel_id; + node->mask = mask; + node->next = CurrentBlacklist; + CurrentBlacklist = node; + } +} + +static void addNoDVBTimelist(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid) +{ + t_channel_id channel_id = + CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID(sid, onid, tsid); + t_channel_id mask = + CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID( + (sid ? 0xFFFF : 0), (onid ? 0xFFFF : 0), (tsid ? 0xFFFF : 0) + ); + if (!checkNoDVBTimelist(channel_id)) + { + xprintf("Add channel 0x%012llx, mask 0x%012llx to NoDVBTimelist\n", channel_id, mask); + ChannelNoDVBTimelist *node = new ChannelNoDVBTimelist; + node->chan = channel_id; + node->mask = mask; + node->next = CurrentNoDVBTime; + CurrentNoDVBTime = node; + } +} + +void readEPGFilter(void) +{ + xmlDocPtr filter_parser = parseXmlFile(epg_filter_dir.c_str()); + + t_original_network_id onid = 0; + t_transport_stream_id tsid = 0; + t_service_id sid = 0; + + if (filter_parser != NULL) + { + dprintf("Reading EPGFilters\n"); + + xmlNodePtr filter = xmlDocGetRootElement(filter_parser); + if (xmlGetNumericAttribute(filter, "is_whitelist", 10) == 1) + epg_filter_is_whitelist = true; + if (xmlGetNumericAttribute(filter, "except_current_next", 10) == 1) + epg_filter_except_current_next = true; + filter = filter->xmlChildrenNode; + + while (filter) { + + onid = xmlGetNumericAttribute(filter, "onid", 16); + tsid = xmlGetNumericAttribute(filter, "tsid", 16); + sid = xmlGetNumericAttribute(filter, "serviceID", 16); + if (xmlGetNumericAttribute(filter, "blacklist", 10) == 1) + addBlacklist(onid, tsid, sid); + else + addEPGFilter(onid, tsid, sid); + + filter = filter->xmlNextNode; + } + } + xmlFreeDoc(filter_parser); +} + +void readDVBTimeFilter(void) +{ + xmlDocPtr filter_parser = parseXmlFile(dvbtime_filter_dir.c_str()); + + t_original_network_id onid = 0; + t_transport_stream_id tsid = 0; + t_service_id sid = 0; + + if (filter_parser != NULL) + { + dprintf("Reading DVBTimeFilters\n"); + + xmlNodePtr filter = xmlDocGetRootElement(filter_parser); + filter = filter->xmlChildrenNode; + + while (filter) { + + onid = xmlGetNumericAttribute(filter, "onid", 16); + tsid = xmlGetNumericAttribute(filter, "tsid", 16); + sid = xmlGetNumericAttribute(filter, "serviceID", 16); + addNoDVBTimelist(onid, tsid, sid); + + filter = filter->xmlNextNode; + } + xmlFreeDoc(filter_parser); + } + else + { + dvb_time_update = true; + } +} + void *insertEventsfromFile(void * data) { xmlDocPtr event_parser = NULL; diff --git a/src/eitd/xmlutil.h b/src/eitd/xmlutil.h new file mode 100644 index 000000000..83e383264 --- /dev/null +++ b/src/eitd/xmlutil.h @@ -0,0 +1,43 @@ +/* + * + * (C) 2003 by thegoodguy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef __eitd_xmlutil_h__ +#define __eitd_xmlutil_h__ + +#include +#include +#include +#include + +#include +#include +#include + +void *insertEventsfromFile(void * data); +void writeEventsToFile(char *epgdir); + +void readEPGFilter(void); +void readDVBTimeFilter(void); +bool checkEPGFilter(t_original_network_id onid, t_transport_stream_id tsid, t_service_id sid); +bool checkBlacklist(t_channel_id channel_id); +bool checkNoDVBTimelist(t_channel_id channel_id); + +#endif /* __sectionsd__debug_h__ */ +