diff --git a/data/epgmap.xml b/data/epgmap.xml new file mode 100644 index 000000000..49cead598 --- /dev/null +++ b/data/epgmap.xml @@ -0,0 +1,19 @@ + + + + --rai1 + --rai1 + + --rai2 + --rai2 + + --rai3 + --rai3 + + --rai4 + + --raisport1 + --rainews24 + + --Das Erste + diff --git a/src/zapit/include/zapit/bouquets.h b/src/zapit/include/zapit/bouquets.h index 007133a45..6c885a562 100644 --- a/src/zapit/include/zapit/bouquets.h +++ b/src/zapit/include/zapit/bouquets.h @@ -98,7 +98,10 @@ class CBouquetManager void writeBouquetChannels (FILE * bouq_fd, uint32_t i, bool bUser = false); void writeChannels(FILE * bouq_fd, ZapitChannelList &list, bool bUser); void writeBouquet(FILE * bouq_fd, uint32_t i, bool bUser); - + //remap epg_id + std::map EpgIDMapping; + void readEPGMapping(); + t_channel_id reMapEpgID(t_channel_id channelid); public: CBouquetManager() { remainChannels = NULL; }; ~CBouquetManager(); diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index de156827a..834873afa 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -290,6 +290,7 @@ class CZapitChannel }; bool Locked() { return (bLocked || !!bLockCount); } t_channel_id getEpgID(void) const { return epg_id; } + void setEPGid(t_channel_id pEPGid) { epg_id = pEPGid; } //remap epg_id }; struct CmpChannelBySat: public std::binary_function diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index 38b1d529b..271751cd0 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -387,6 +387,10 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) xmlNodePtr channel_node; if (search) { + if(!bUser){ + readEPGMapping(); + } + t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; @@ -448,6 +452,10 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) chan->pname = (char *) newBouquet->Name.c_str(); chan->bLocked = clock; chan->bUseCI = newBouquet->bUseCI; + //remapinng epg_id + t_channel_id new_epgid = reMapEpgID(chan->getChannelID()); + if(new_epgid) + chan->setEPGid(new_epgid); newBouquet->addService(chan); } else if (bUser) { @@ -483,6 +491,9 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) search = xmlNextNode(search); } INFO("total: %d bouquets", (int)Bouquets.size()); + if(!bUser && !EpgIDMapping.empty()){ + EpgIDMapping.clear(); + } } xmlFreeDoc(parser); } @@ -929,3 +940,47 @@ int CBouquetManager::ChannelIterator::getNrofFirstChannelofBouquet(const unsigne return i; } + +t_channel_id CBouquetManager::reMapEpgID(t_channel_id channelid) +{ + if(!EpgIDMapping.empty()){ + std::map::iterator it = EpgIDMapping.find(channelid); + if ( it != EpgIDMapping.end() ) + return it->second; + } + return 0; +} + +void CBouquetManager::readEPGMapping() +{ + if(!EpgIDMapping.empty()) + EpgIDMapping.clear(); + + const std::string epg_map_dir = CONFIGDIR "/zapit/epgmap.xml"; + xmlDocPtr epgmap_parser = parseXmlFile(epg_map_dir.c_str()); + + if (epgmap_parser != NULL) + { + + xmlNodePtr epgmap = xmlDocGetRootElement(epgmap_parser); + if(epgmap) + epgmap = xmlChildrenNode(epgmap); + + while (epgmap) { + const char *cannelid = xmlGetAttribute(epgmap, "channel_id"); + const char *epgid = xmlGetAttribute(epgmap, "new_epg_id"); + t_channel_id epg_id = 0; + t_channel_id chid = 0; + if (epgid) + epg_id = strtoull(epgid, NULL, 16); + if (cannelid) + chid = strtoull(cannelid, NULL, 16); + if(chid && epg_id){ + EpgIDMapping[chid]=epg_id; + } + + epgmap = xmlNextNode(epgmap); + } + } + xmlFreeDoc(epgmap_parser); +}