add epg remaping

This commit is contained in:
Jacek Jendrzej
2016-05-10 14:00:37 +02:00
parent 7091383170
commit c416cf1c31
4 changed files with 79 additions and 1 deletions

19
data/epgmap.xml Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<zapit>
<filter channel_id="b85a1450013e0d49" new_epg_id="ac423070013e213f"/> --rai1
<filter channel_id="b12003ee00011072" new_epg_id="ac423070013e213f"/> --rai1
<filter channel_id="ac9630d4013e4530" new_epg_id="ac423070013e2140"/> --rai2
<filter channel_id="b12003ee00011073" new_epg_id="ac423070013e2140"/> --rai2
<filter channel_id="b12003ee00011074" new_epg_id="ac423070013e2141"/> --rai3
<filter channel_id="ac9630d4013e4531" new_epg_id="ac423070013e2141"/> --rai3
<filter channel_id="ac9630d4013e4534" new_epg_id="ac423070013e2142"/> --rai4
<filter channel_id="ac9630d4013e4533" new_epg_id="ac421518013e0ce9"/> --raisport1
<filter channel_id="b12003ee00011078" new_epg_id="ac423070013e2144"/> --rainews24
<filter channel_id="b4d6070800c80e26" new_epg_id="b45803fb0001283d"/> --Das Erste
</zapit>

View File

@@ -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<t_channel_id, t_channel_id> EpgIDMapping;
void readEPGMapping();
t_channel_id reMapEpgID(t_channel_id channelid);
public:
CBouquetManager() { remainChannels = NULL; };
~CBouquetManager();

View File

@@ -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 <const CZapitChannel * const, const CZapitChannel * const, bool>

View File

@@ -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<t_channel_id, t_channel_id>::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);
}