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 = xmlChildrenNode(filter); while (filter) { onid = xmlGetNumericAttribute(filter, "onid", 16); tsid = xmlGetNumericAttribute(filter, "tsid", 16); sid = xmlGetNumericAttribute(filter, "serviceID", 16); addNoDVBTimelist(onid, tsid, sid); filter = xmlNextNode(filter); } xmlFreeDoc(filter_parser); } else { dvb_time_update = true; } }
bool 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 = xmlChildrenNode(filter); 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 = xmlNextNode(filter); } } xmlFreeDoc(filter_parser); return (CurrentEPGFilter != NULL); }
void ParseTransponders(xmlNodePtr node, t_satellite_position satellitePosition, uint8_t Source ) { t_transport_stream_id transport_stream_id; t_original_network_id original_network_id; FrontendParameters feparams; uint8_t polarization = 0; freq_id_t freq; tcnt = 0; memset(&feparams, 0, sizeof(FrontendParameters)); // read all transponders while ((node = xmlGetNextOccurence(node, "TS")) != NULL) { // common transport_stream_id = xmlGetNumericAttribute(node, "id", 16); original_network_id = xmlGetNumericAttribute(node, "on", 16); feparams.frequency = xmlGetNumericAttribute(node, "frq", 0); feparams.inversion = (fe_spectral_inversion) xmlGetNumericAttribute(node, "inv", 0); // DVB-C if(Source == DVB_C) { feparams.u.qam.symbol_rate = xmlGetNumericAttribute(node, "sr", 0); feparams.u.qam.fec_inner = (fe_code_rate_t) xmlGetNumericAttribute(node, "fec", 0); feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(node, "mod", 0); } // DVB-T else if(Source == DVB_T) { feparams.u.ofdm.bandwidth = (fe_bandwidth_t) xmlGetNumericAttribute(node, "band", 0); feparams.u.ofdm.code_rate_HP = (fe_code_rate_t) xmlGetNumericAttribute(node, "HP", 0); feparams.u.ofdm.code_rate_LP = (fe_code_rate_t) xmlGetNumericAttribute(node, "LP", 0); feparams.u.ofdm.constellation = (fe_modulation_t) xmlGetNumericAttribute(node, "const", 0); feparams.u.ofdm.transmission_mode = (fe_transmit_mode_t) xmlGetNumericAttribute(node, "trans", 0); feparams.u.ofdm.guard_interval = (fe_guard_interval_t) xmlGetNumericAttribute(node, "guard", 0); feparams.u.ofdm.hierarchy_information = (fe_hierarchy_t) xmlGetNumericAttribute(node, "hierarchy", 0); } // DVB-S else if(Source == DVB_S) { feparams.u.qpsk.fec_inner = (fe_code_rate_t) xmlGetNumericAttribute(node, "fec", 0); feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(node, "sr", 0); polarization = xmlGetNumericAttribute(node, "pol", 0); if(feparams.u.qpsk.symbol_rate < 50000) feparams.u.qpsk.symbol_rate = feparams.u.qpsk.symbol_rate * 1000; // ??? if(feparams.frequency < 20000) feparams.frequency = feparams.frequency*1000; } if(Source == DVB_C) freq = feparams.frequency/100; else if(Source == DVB_S) freq = feparams.frequency/1000; else if(Source == DVB_T) freq = feparams.frequency/1000000; // add current transponder to list transponder_id_t tid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, original_network_id, transport_stream_id); pair<map<transponder_id_t, transponder>::iterator, bool> ret; ret = transponders.insert (std::pair <transponder_id_t, transponder> ( tid, transponder(transport_stream_id, feparams, polarization, original_network_id))); if (ret.second == false) printf("[zapit] duplicate transponder id %llx freq %d\n", tid, feparams.frequency); // read channels that belong to the current transponder ParseChannels(node->xmlChildrenNode, transport_stream_id, original_network_id, satellitePosition, freq, polarization); // hop to next transponder node = node->xmlNextNode; } return; }
void ParseSatTransponders(fe_type_t frontendType, xmlNodePtr search, t_satellite_position satellitePosition) { uint8_t polarization = 0; uint8_t system = 0; uint8_t modulation = 1; int xml_fec; FrontendParameters feparams; fake_tid = fake_nid = 0; xmlNodePtr tps = search->xmlChildrenNode; while ((tps = xmlGetNextOccurence(tps, "transponder")) != NULL) { memset(&feparams, 0, sizeof(FrontendParameters)); freq_id_t freq; // frequency if (frontendType == FE_OFDM) feparams.frequency = xmlGetNumericAttribute(tps, "centre_frequency", 0); else feparams.frequency = xmlGetNumericAttribute(tps, "frequency", 0); // inversion feparams.inversion = INVERSION_AUTO; if (frontendType == FE_QAM) //DVB-C { feparams.u.qam.symbol_rate = xmlGetNumericAttribute(tps, "symbol_rate", 0); feparams.u.qam.fec_inner = (fe_code_rate_t) xmlGetNumericAttribute(tps, "fec_inner", 0); feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(tps, "modulation", 0); } else if (frontendType == FE_OFDM) //DVB-T { feparams.u.ofdm.bandwidth = (fe_bandwidth_t) xmlGetNumericAttribute(tps, "bandwidth", 0); feparams.u.ofdm.code_rate_HP = (fe_code_rate_t) xmlGetNumericAttribute(tps, "code_rate_hp", 0); feparams.u.ofdm.code_rate_LP = (fe_code_rate_t) xmlGetNumericAttribute(tps, "code_rate_lp", 0); feparams.u.ofdm.constellation = (fe_modulation_t) xmlGetNumericAttribute(tps, "constellation", 0); feparams.u.ofdm.transmission_mode = (fe_transmit_mode_t) xmlGetNumericAttribute(tps, "transmission_mode", 0); feparams.u.ofdm.guard_interval = (fe_guard_interval_t) xmlGetNumericAttribute(tps, "guard_interval", 0); feparams.u.ofdm.hierarchy_information = (fe_hierarchy_t) xmlGetNumericAttribute(tps, "hierarchy_information", 0); feparams.inversion = (fe_spectral_inversion_t)xmlGetNumericAttribute(tps, "inversion", 0); } else if (frontendType == FE_QPSK) //DVB-S { feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(tps, "symbol_rate", 0); polarization = xmlGetNumericAttribute(tps, "polarization", 0); system = xmlGetNumericAttribute(tps, "system", 0); modulation = xmlGetNumericAttribute(tps, "modulation", 0); xml_fec = xmlGetNumericAttribute(tps, "fec_inner", 0); xml_fec = CFrontend::getCodeRate(xml_fec, system); // DVB-S2 if(modulation == 2) xml_fec += 9; feparams.u.qpsk.fec_inner = (fe_code_rate_t)xml_fec; } if (frontendType == FE_QAM) freq = feparams.frequency/100; else if(frontendType == FE_QPSK) freq = feparams.frequency/1000; else if(frontendType == FE_OFDM) freq = feparams.frequency/1000000; transponder_id_t tid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, fake_nid, fake_tid); //polarization &= 1; polarization &= 7; // insert TPs list select_transponders.insert( std::pair <transponder_id_t, transponder> (tid, transponder(fake_tid, feparams, polarization, fake_nid))); fake_nid ++; fake_tid ++; tps = tps->xmlNextNode; } }
void ParseChannels(xmlNodePtr node, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq, uint8_t polarisation) { t_service_id service_id; std::string name; uint8_t service_type; unsigned short vpid, apid, pcrpid, pmtpid, txpid, vtype, scrambled; std::string desc = ""; desc += "Preset"; t_channel_id chid; int dummy; int * have_ptr = &dummy; sat_iterator_t sit = satellitePositions.find(satellitePosition); if(sit != satellitePositions.end()) have_ptr = &sit->second.have_channels; while ((node = xmlGetNextOccurence(node, "S")) != NULL) { *have_ptr = 1; service_id = xmlGetNumericAttribute(node, "i", 16); name = xmlGetAttribute(node, "n"); service_type = xmlGetNumericAttribute(node, "t", 16); vpid = xmlGetNumericAttribute(node, "v", 16); apid = xmlGetNumericAttribute(node, "a", 16); pcrpid = xmlGetNumericAttribute(node, "p", 16); pmtpid = xmlGetNumericAttribute(node, "pmt", 16); txpid = xmlGetNumericAttribute(node, "tx", 16); vtype = xmlGetNumericAttribute(node, "vt", 16); scrambled = xmlGetNumericAttribute(node, "s", 16); chid = CREATE_CHANNEL_ID; char *ptr = xmlGetAttribute(node, "action"); bool remove = ptr ? (!strcmp(ptr, "remove") || !strcmp(ptr, "replace")) : false; bool add = ptr ? (!strcmp(ptr, "add") || !strcmp(ptr, "replace")) : true; if (remove) { int result = allchans.erase(chid); dprintf(DEBUG_INFO, "%s '%s' (sid=0x%x): %s", add ? "replacing" : "removing", name.c_str(), service_id, result ? "succeded.\n" : "FAILED!\n"); } if(!add) { node = node->xmlNextNode; continue; } map<t_channel_id, audio_map_set_t>::iterator audio_map_it; audio_map_it = audio_map.find(chid); if((audio_map_it != audio_map.end()) && (audio_map_it->second.apid != 0)) { apid = audio_map_it->second.apid; } pair<map<t_channel_id, CZapitChannel>::iterator, bool> ret; ret = allchans.insert (std::pair <t_channel_id, CZapitChannel> (chid, CZapitChannel( name, service_id, transport_stream_id, original_network_id, service_type, satellitePosition, freq))); if(ret.second == false) { dprintf(DEBUG_DEBUG, "getSevices:ParseChannels: duplicate channel %s id %llx freq %d (old %s at %d)\n", name.c_str(), chid, freq, ret.first->second.getName().c_str(), ret.first->second.getFreqId()); } else { scnt++; tallchans_iterator cit1 = ret.first; cit1->second.scrambled = scrambled; service_type = cit1->second.getServiceType(); cit1->second.polarization = polarisation; if(pmtpid != 0 && (((service_type == ST_DIGITAL_RADIO_SOUND_SERVICE) && (apid > 0)) || ( (service_type == ST_DIGITAL_TELEVISION_SERVICE) && (vpid > 0) && (apid > 0))) ) { cit1->second.setVideoPid(vpid); cit1->second.setAudioPid(apid); cit1->second.setPcrPid(pcrpid); cit1->second.setPmtPid(pmtpid); cit1->second.setTeletextPid(txpid); cit1->second.setPidsFlag(); cit1->second.videoType = vtype; } } node = node->xmlNextNode; } return; }
void CBouquetManager::parseBouquetsXml(const xmlNodePtr root) { extern CConfigFile config; bool channel_names_from_bouquet = config.getBool("ChannelNamesFromBouquet", false); xmlNodePtr search=root->xmlChildrenNode; xmlNodePtr channel_node; if (search) { t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; t_satellite_position satellitePosition; INFO("reading bouquets"); while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { CBouquet *newBouquet; char *name = xmlGetAttribute(search, "name"); int bnum = existsBouquet(name); if (bnum != -1) newBouquet = Bouquets[bnum]; else { newBouquet = addBouquet(name); char* hidden = xmlGetAttribute(search, "hidden"); char* locked = xmlGetAttribute(search, "locked"); newBouquet->type = xmlGetNumericAttribute(search, "type", 16); newBouquet->bouquet_id = xmlGetNumericAttribute(search, "bouquet_id", 16); newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; bnum = Bouquets.size() - 1; } channel_node = search->xmlChildrenNode; while ((channel_node = xmlGetNextOccurence(channel_node, "channel")) != NULL) { GET_ATTR(channel_node, "serviceID", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, "onid", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, "sat", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, "tsid", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); CZapitChannel* chan = findChannelByChannelID(CREATE_CHANNEL_ID); if (chan != NULL) { if (channel_names_from_bouquet) chan->setName(xmlGetAttribute(channel_node, "name")); if (existsChannelInBouquet(bnum, CREATE_CHANNEL_ID)) { DBG("b %d '%s' ch %012llx sat %3d name '%s' exists, not added", bnum, name, CREATE_CHANNEL_ID, satellitePosition, chan->getName().c_str()); } else newBouquet->addService(chan); } channel_node = channel_node->xmlNextNode; } search = search->xmlNextNode; } INFO("found %d bouquets", Bouquets.size()); } }
bool readEventsFromFile(std::string &epgname, int &ev_count) { xmlDocPtr event_parser = NULL; xmlNodePtr service; xmlNodePtr event; t_original_network_id onid = 0; t_transport_stream_id tsid = 0; t_service_id sid = 0; if (!(event_parser = parseXmlFile(epgname.c_str()))) { dprintf("unable to open %s for reading\n", epgname.c_str()); return false; } service = xmlDocGetRootElement(event_parser); service = xmlChildrenNode(service); while (service) { onid = xmlGetNumericAttribute(service, "original_network_id", 16); tsid = xmlGetNumericAttribute(service, "transport_stream_id", 16); sid = xmlGetNumericAttribute(service, "service_id", 16); event = xmlChildrenNode(service); while (event) { SIevent e(onid,tsid,sid,xmlGetNumericAttribute(event, "id", 16)); uint8_t tid = xmlGetNumericAttribute(event, "tid", 16); std::string contentClassification, userClassification; if(tid) e.table_id = tid; e.table_id |= 0x80; /* make sure on-air data has a lower table_id */ xmlNodePtr node; node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "name"))) { const char *s = xmlGetAttribute(node, "string"); if (s) e.setName(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "text"))) { const char *s = xmlGetAttribute(node, "string"); if (s) e.setText(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "item"))) { #ifdef USE_ITEM_DESCRIPTION const char *s = xmlGetAttribute(node, "string"); if (s) e.item = s; #endif node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "item_description"))) { #ifdef USE_ITEM_DESCRIPTION const char *s = xmlGetAttribute(node, "string"); if (s) e.itemDescription = s; #endif node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "extended_text"))) { const char *l = xmlGetAttribute(node, "lang"); const char *s = xmlGetAttribute(node, "string"); if (l && s) e.appendExtendedText(ZapitTools::UTF8_to_Latin1(l), s); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "time"))) { e.times.insert(SItime(xmlGetNumericAttribute(node, "start_time", 10), xmlGetNumericAttribute(node, "duration", 10))); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "content"))) { const char cl = xmlGetNumericAttribute(node, "class", 16); contentClassification += cl; const char cl2 = xmlGetNumericAttribute(node, "user", 16); userClassification += cl2; node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "component"))) { SIcomponent c; c.streamContent = xmlGetNumericAttribute(node, "stream_content", 16); c.componentType = xmlGetNumericAttribute(node, "type", 16); c.componentTag = xmlGetNumericAttribute(node, "tag", 16); const char *s = xmlGetAttribute(node, "text"); if (s) c.setComponent(s); //e.components.insert(c); e.components.push_back(c); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "parental_rating"))) { const char *s = xmlGetAttribute(node, "country"); if (s) #if 0 e.ratings.insert(SIparentalRating(ZapitTools::UTF8_to_Latin1(s), (unsigned char) xmlGetNumericAttribute(node, "rating", 10))); #endif e.ratings.push_back(SIparentalRating(ZapitTools::UTF8_to_Latin1(s), (unsigned char) xmlGetNumericAttribute(node, "rating", 10))); node = xmlNextNode(node); } node = xmlChildrenNode(event); while ((node = xmlGetNextOccurence(node, "linkage"))) { SIlinkage l; l.linkageType = xmlGetNumericAttribute(node, "type", 16); l.transportStreamId = xmlGetNumericAttribute(node, "transport_stream_id", 16); l.originalNetworkId = xmlGetNumericAttribute(node, "original_network_id", 16); l.serviceId = xmlGetNumericAttribute(node, "service_id", 16); const char *s = xmlGetAttribute(node, "linkage_descriptor"); if (s) l.name = s; e.linkage_descs.insert(e.linkage_descs.end(), l); node = xmlNextNode(node); } if (!contentClassification.empty()) { #ifdef FULL_CONTENT_CLASSIFICATION ssize_t off = e.classifications.reserve(2 * contentClassification.size()); if (off > -1) for (unsigned i = 0; i < contentClassification.size(); i++) off = e.classifications.set(off, contentClassification.at(i), userClassification.at(i)); #else e.classifications.content = contentClassification.at(0); e.classifications.user = userClassification.at(0); #endif } addEvent(e, 0); ev_count++; event = xmlNextNode(event); } service = xmlNextNode(service); } xmlFreeDoc(event_parser); return true; }
void CServiceManager::ParseSatTransponders(fe_type_t frontendType, xmlNodePtr search, t_satellite_position satellitePosition) { uint8_t polarization = 0; uint8_t system = 0, modulation = 1; int xml_fec; FrontendParameters feparams; fake_tid = fake_nid = 0; xmlNodePtr tps = search->xmlChildrenNode; while ((tps = xmlGetNextOccurence(tps, "transponder")) != NULL) { memset(&feparams, 0x00, sizeof(FrontendParameters)); feparams.frequency = xmlGetNumericAttribute(tps, "frequency", 0); freq_id_t freq; if (frontendType == FE_QAM) { if (feparams.frequency > 1000*1000) feparams.frequency=feparams.frequency/1000; //transponderlist was read from tuxbox //feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000); freq = feparams.frequency/100; } else { feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000); freq = feparams.frequency/1000; } feparams.inversion = INVERSION_AUTO; if (frontendType == FE_QAM) { feparams.u.qam.symbol_rate = xmlGetNumericAttribute(tps, "symbol_rate", 0); feparams.u.qam.fec_inner = (fe_code_rate_t) xmlGetNumericAttribute(tps, "fec_inner", 0); feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(tps, "modulation", 0); } else if (frontendType == FE_QPSK) { feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(tps, "symbol_rate", 0); polarization = xmlGetNumericAttribute(tps, "polarization", 0); system = xmlGetNumericAttribute(tps, "system", 0); modulation = xmlGetNumericAttribute(tps, "modulation", 0); xml_fec = xmlGetNumericAttribute(tps, "fec_inner", 0); xml_fec = CFrontend::getCodeRate(xml_fec, system); if(modulation == 2) xml_fec += 9; feparams.u.qpsk.fec_inner = (fe_code_rate_t) xml_fec; } transponder_id_t tid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID( freq /*feparams.frequency/1000*/, satellitePosition, fake_nid, fake_tid); polarization &= 1; select_transponders.insert ( std::pair <transponder_id_t, transponder> (tid, transponder (fake_tid, feparams, polarization, fake_nid)) ); fake_nid ++; fake_tid ++; tps = tps->xmlNextNode; } }
void CServiceManager::ParseChannels(xmlNodePtr node, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq) { t_service_id service_id; std::string name; uint8_t service_type; unsigned short vpid, apid, pcrpid, pmtpid, txpid, vtype, scrambled; std::string desc = ""; desc += "Preset"; t_channel_id chid; int dummy; int * have_ptr = &dummy; sat_iterator_t sit = satellitePositions.find(satellitePosition); if(sit != satellitePositions.end()) have_ptr = &sit->second.have_channels; while ((node = xmlGetNextOccurence(node, "S")) != NULL) { *have_ptr = 1; service_id = xmlGetNumericAttribute(node, "i", 16); name = xmlGetAttribute(node, "n"); service_type = xmlGetNumericAttribute(node, "t", 16); vpid = xmlGetNumericAttribute(node, "v", 16); apid = xmlGetNumericAttribute(node, "a", 16); pcrpid = xmlGetNumericAttribute(node, "p", 16); pmtpid = xmlGetNumericAttribute(node, "pmt", 16); txpid = xmlGetNumericAttribute(node, "tx", 16); vtype = xmlGetNumericAttribute(node, "vt", 16); scrambled = xmlGetNumericAttribute(node, "s", 16); chid = CREATE_CHANNEL_ID64; char *ptr = xmlGetAttribute(node, "action"); bool remove = ptr ? (!strcmp(ptr, "remove") || !strcmp(ptr, "replace")) : false; bool add = ptr ? (!strcmp(ptr, "add") || !strcmp(ptr, "replace")) : true; if (remove) { int result = allchans.erase(chid); printf("[getservices]: %s '%s' (sid=0x%x): %s", add ? "replacing" : "removing", name.c_str(), service_id, result ? "succeded.\n" : "FAILED!\n"); } if(!add) { node = node->xmlNextNode; continue; } audio_map_set_t * pidmap = CZapit::getInstance()->GetSavedPids(chid); if(pidmap) apid = pidmap->apid; CZapitChannel * channel = new CZapitChannel ( name, service_id, transport_stream_id, original_network_id, service_type, satellitePosition, freq); bool ret = AddChannel(channel); //printf("INS CHANNEL %s %x\n", name.c_str(), (int) &ret.first->second); if(ret == false) { printf("[zapit] duplicate channel %s id %llx freq %d (old %s at %d)\n", name.c_str(), chid, freq, channel->getName().c_str(), channel->getFreqId()); } else { service_count++; channel->scrambled = scrambled; service_type = channel->getServiceType(); if(pmtpid != 0 && (((service_type == 2) && (apid > 0)) || ( (service_type == 1) && (vpid > 0) && (apid > 0))) ) { DBG("[getserv] preset chan %s vpid %X sid %X tpid %X onid %X\n", name.c_str(), vpid, service_id, transport_stream_id, transport_stream_id); channel->setVideoPid(vpid); channel->setAudioPid(apid); channel->setPcrPid(pcrpid); channel->setPmtPid(pmtpid); channel->setTeletextPid(txpid); channel->setPidsFlag(); channel->type = vtype; } } node = node->xmlNextNode; } return; }
void CServiceManager::ParseTransponders(xmlNodePtr node, t_satellite_position satellitePosition, bool cable) { t_transport_stream_id transport_stream_id; t_original_network_id original_network_id; FrontendParameters feparams; uint8_t polarization = 0; uint16_t freq; tp_count = 0; memset(&feparams, 0, sizeof(FrontendParameters)); /* read all transponders */ while ((node = xmlGetNextOccurence(node, "TS")) != NULL) { transport_stream_id = xmlGetNumericAttribute(node, "id", 16); original_network_id = xmlGetNumericAttribute(node, "on", 16); feparams.frequency = xmlGetNumericAttribute(node, "frq", 0); feparams.inversion = (fe_spectral_inversion) xmlGetNumericAttribute(node, "inv", 0); if(cable) { feparams.u.qam.symbol_rate = xmlGetNumericAttribute(node, "sr", 0); feparams.u.qam.fec_inner = (fe_code_rate_t) xmlGetNumericAttribute(node, "fec", 0); feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(node, "mod", 0); if (feparams.frequency > 1000*1000) feparams.frequency = feparams.frequency/1000; //transponderlist was read from tuxbox //feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000); } else { feparams.u.qpsk.fec_inner = (fe_code_rate_t) xmlGetNumericAttribute(node, "fec", 0); feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(node, "sr", 0); polarization = xmlGetNumericAttribute(node, "pol", 0); if(feparams.u.qpsk.symbol_rate < 50000) feparams.u.qpsk.symbol_rate = feparams.u.qpsk.symbol_rate * 1000; if(feparams.frequency < 20000) feparams.frequency = feparams.frequency*1000; else feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000); } if(cable) freq = feparams.frequency/100; else freq = feparams.frequency/1000; transponder_id_t tid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition,original_network_id,transport_stream_id); pair<map<transponder_id_t, transponder>::iterator,bool> ret; ret = transponders.insert ( std::pair <transponder_id_t, transponder> ( tid, transponder (transport_stream_id, feparams, polarization, original_network_id) ) ); if (ret.second == false) printf("[zapit] duplicate transponder id %llx freq %d\n", tid, feparams.frequency); /* read channels that belong to the current transponder */ ParseChannels(node->xmlChildrenNode, transport_stream_id, original_network_id, satellitePosition, freq); /* hop to next transponder */ node = node->xmlNextNode; } return; }
void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) { xmlDocPtr parser; parser = parseXmlFile(fname); if (parser == NULL) return; xmlNodePtr root = xmlDocGetRootElement(parser); xmlNodePtr search = root->xmlChildrenNode; xmlNodePtr channel_node; if (search) { t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; int16_t satellitePosition; freq_id_t freq = 0; INFO("reading bouquets from %s", fname); while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { const char * name = xmlGetAttribute(search, "name"); if(name == NULL) name = const_cast<char*>("Unknown"); CZapitBouquet* newBouquet = addBouquet(name, bUser); // per default in contructor: newBouquet->BqID = 0; //set to default, override if bqID exists GET_ATTR(search, "bqID", SCANF_BOUQUET_ID_TYPE, newBouquet->BqID); const char* hidden = xmlGetAttribute(search, "hidden"); const char* locked = xmlGetAttribute(search, "locked"); const char* scanepg = xmlGetAttribute(search, "epg"); newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; newBouquet->bFav = (strcmp(name, "favorites") == 0); newBouquet->bScanEpg = scanepg ? (strcmp(scanepg, "1") == 0) : false; channel_node = search->xmlChildrenNode; while ((channel_node = xmlGetNextOccurence(channel_node, "S")) != NULL) { std::string name2; name = xmlGetAttribute(channel_node, "n"); if (name) name2 = name; std::string uname; const char *uName = xmlGetAttribute(channel_node, "un"); if (uName) uname = uName; const char *url = xmlGetAttribute(channel_node, "u"); GET_ATTR(channel_node, "i", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, "t", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); GET_ATTR(channel_node, "frq", SCANF_SATELLITE_POSITION_TYPE, freq); bool clock = xmlGetNumericAttribute(channel_node, "l", 10); if(freq > 20000) freq = freq/1000; CZapitChannel* chan; t_channel_id chid = create_channel_id64(service_id, original_network_id, transport_stream_id, satellitePosition, freq, url); /* FIXME to load old cable settings with new cable "positions" started from 0xF00 */ if(!url && (bUser || CFEManager::getInstance()->cableOnly())) chan = CServiceManager::getInstance()->FindChannelFuzzy(chid, satellitePosition, freq); else chan = CServiceManager::getInstance()->FindChannel(chid); if (chan != NULL) { DBG("%04x %04x %04x %s\n", transport_stream_id, original_network_id, service_id, xmlGetAttribute(channel_node, "n")); if(bUser && !(uname.empty())) chan->setUserName(uname); if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); chan->bLocked = clock; newBouquet->addService(chan); } else if (bUser) { if (url) { chid = create_channel_id64(0, 0, 0, 0, 0, url); chan = new CZapitChannel(name2.c_str(), chid, url, NULL); } else chan = new CZapitChannel(name2, CREATE_CHANNEL_ID64, 1 /*service_type*/, satellitePosition, freq); CServiceManager::getInstance()->AddChannel(chan); chan->flags = CZapitChannel::NOT_FOUND; chan->bLocked = clock; if(!(uname.empty())) chan->setUserName(uname); newBouquet->addService(chan); CServiceManager::getInstance()->SetServicesChanged(false); } channel_node = channel_node->xmlNextNode; if(!bUser) { /* set satellite position for provider bouquets. reset position to 0, if position not match - means mixed bouquet */ if (newBouquet->satellitePosition == INVALID_SAT_POSITION) newBouquet->satellitePosition = satellitePosition; else if (newBouquet->satellitePosition != satellitePosition) newBouquet->satellitePosition = 0; } } if(!bUser) newBouquet->sortBouquet(); search = search->xmlNextNode; } INFO("total: %d bouquets", (int)Bouquets.size()); } xmlFreeDoc(parser); }