void CBouquetManager::parseBouquetsXml(const xmlNodePtr root, bool bUser) { 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"); while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { char * name = xmlGetAttribute(search, (char *) "name"); //CZapitBouquet* newBouquet = addBouquet(xmlGetAttribute(search, (char *) "name"), bUser); CZapitBouquet* newBouquet = addBouquet(name, bUser); char* hidden = xmlGetAttribute(search, (char *) "hidden"); char* locked = xmlGetAttribute(search, (char *) "locked"); newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; newBouquet->bFav = (strcmp(name, "favorites") == 0); channel_node = search->xmlChildrenNode; while ((channel_node = xmlGetNextOccurence(channel_node, "S")) != NULL) { std::string name = xmlGetAttribute(channel_node, (char *) "n"); GET_ATTR(channel_node, (char *) "i", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, (char *) "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, (char *) "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, (char *) "t", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); GET_ATTR(channel_node, (char *) "frq", SCANF_SATELLITE_POSITION_TYPE, freq); if(freq > 20000) freq = freq/1000; CZapitChannel* chan; chan = findChannelByChannelID(CREATE_CHANNEL_ID64); //printf("Bouquet Channel-ID freq %d pos %d id %llx\n", freq, satellitePosition, CREATE_CHANNEL_ID64); if (chan != NULL) { //printf("found\n"); DBG("%04x %04x %04x %s\n", transport_stream_id, original_network_id, service_id, xmlGetAttribute(channel_node, (char *) "n")); #if 0 if(bUser && (name.length() > 1)) chan->setName(name); #endif if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); chan->bAlwaysLocked = newBouquet->bLocked; newBouquet->addService(chan); } channel_node = channel_node->xmlNextNode; } if(!bUser) newBouquet->sortBouquet(); search = search->xmlNextNode; } INFO("found %d bouquets", Bouquets.size()); } }
void CBouquetManager::makeBouquetfromCurrentservices(const xmlNodePtr root) { xmlNodePtr provider = root->xmlChildrenNode; // TODO: use locales CBouquet* newBouquet = addBouquet("Neue Sender"); newBouquet->bHidden = false; newBouquet->bLocked = false; t_original_network_id original_network_id; t_service_id service_id; t_transport_stream_id transport_stream_id; t_satellite_position satellitePosition; while (provider) { xmlNodePtr transponder = provider->xmlChildrenNode; while (xmlGetNextOccurence(transponder, "transponder") != NULL) { xmlNodePtr channel_node = transponder->xmlChildrenNode; while (xmlGetNextOccurence(channel_node, "channel") != NULL) { if (strncmp(xmlGetAttribute(channel_node, "action"), "remove", 6)) { GET_ATTR(provider, "position", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(transponder, "onid", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(transponder, "id", SCANF_TRANSPORT_STREAM_ID_TYPE, transport_stream_id); GET_ATTR(channel_node, "service_id", SCANF_SERVICE_ID_TYPE, service_id); CZapitChannel* chan = findChannelByChannelID(CREATE_CHANNEL_ID); if (chan != NULL) newBouquet->addService(chan); } channel_node = channel_node->xmlNextNode; } transponder = transponder->xmlNextNode; } provider = provider->xmlNextNode; } }
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 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) { char * name = xmlGetAttribute(search, "name"); if(name == NULL) name = const_cast<char*>("Unknown"); CZapitBouquet* newBouquet = addBouquet(name, bUser); char* hidden = xmlGetAttribute(search, "hidden"); char* locked = xmlGetAttribute(search, "locked"); 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 = xmlGetAttribute(channel_node, "n"); 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); 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 0 if(bUser && (name2.length() > 1)) chan->setName(name2); #endif if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); newBouquet->addService(chan); } else if (bUser) { chan = new CZapitChannel(name2, chid, 1 /*service_type*/, satellitePosition, freq); CServiceManager::getInstance()->AddChannel(chan); chan->flags = CZapitChannel::NOT_FOUND; 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); }
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; }
// readxml file bool CWebTV::readChannellist(std::string filename) { dprintf(DEBUG_NORMAL, "CWebTV::readChannellist parsing %s\n", filename.c_str()); // clear channellist ClearChannels(); // check for extension int ext_pos = 0; ext_pos = filename.rfind('.'); bool iptv = false; bool webtv = false; bool playlist = false; if( ext_pos > 0) { std::string extension; extension = filename.substr(ext_pos + 1, filename.length() - ext_pos); if( strcasecmp("tv", extension.c_str()) == 0) iptv = true; else if( strcasecmp("m3u", extension.c_str()) == 0) playlist = true; if( strcasecmp("xml", extension.c_str()) == 0) webtv = true; } if(iptv) { FILE * f = fopen(filename.c_str(), "r"); std::string title; std::string URL; std::string url; std::string description; if(f != NULL) { while(1) { char line[1024]; if (!fgets(line, 1024, f)) break; size_t len = strlen(line); if (len < 2) // Lines with less than one char aren't meaningful continue; /* strip newline */ line[--len] = 0; // strip carriage return (when found) if (line[len - 1] == '\r') line[len - 1 ] = 0; if (strncmp(line, "#SERVICE 4097:0:1:0:0:0:0:0:0:0:", 32) == 0) url = line + 32; //else if ( (strncmp(line, "#DESCRIPTION: ", 14) == 0) || (strncmp(line, "#DESCRIPTION ", 13) == 0) ) else if (strncmp(line, "#DESCRIPTION", 12) == 0) { int offs = line[12] == ':' ? 14 : 13; title = line + offs; description = "stream"; addUrl2Playlist(urlDecode(url).c_str(), title.c_str(), description.c_str()); //urlDecode defined in edvbstring.h } } fclose(f); return true; } } else if(webtv) { parser = parseXmlFile(filename.c_str()); if (parser) { xmlNodePtr l0 = NULL; xmlNodePtr l1 = NULL; l0 = xmlDocGetRootElement(parser); l1 = l0->xmlChildrenNode; neutrino_msg_t msg; neutrino_msg_data_t data; CHintBox* hintBox = NULL; hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RELOAD_HINT)); g_RCInput->getMsg(&msg, &data, 0); if (l1) { while ( ((xmlGetNextOccurence(l1, "webtv")) || (xmlGetNextOccurence(l1, "station"))) && msg != CRCInput::RC_home) { char * title; char * url; char * description; // title if(xmlGetNextOccurence(l1, "webtv")) { title = xmlGetAttribute(l1, (char *)"title"); // url url = xmlGetAttribute(l1, (char *)"url"); description = xmlGetAttribute(l1, (char *)"description"); addUrl2Playlist(url, title, description); } else if (xmlGetNextOccurence(l1, "station")) { hintBox->paint(); title = xmlGetAttribute(l1, (char *)"name"); url = xmlGetAttribute(l1, (char *)"url"); description = "stream"; processPlaylistUrl(url, title, description) ; } l1 = l1->xmlNextNode; g_RCInput->getMsg(&msg, &data, 0); } } hintBox->hide(); delete hintBox; hintBox = NULL; return true; } xmlFreeDoc(parser); } else if(playlist) { std::ifstream infile; char cLine[1024]; char name[1024] = { 0 }; int duration; std::string description; infile.open(filename.c_str(), std::ifstream::in); while (infile.good()) { infile.getline(cLine, sizeof(cLine)); // remove CR if(cLine[strlen(cLine) - 1] == '\r') cLine[strlen(cLine) - 1] = 0; sscanf(cLine, "#EXTINF:%d,%[^\n]\n", &duration, name); if(strlen(cLine) > 0 && cLine[0] != '#') { char *url = NULL; if ((url = strstr(cLine, "http://")) || (url = strstr(cLine, "rtmp://")) || (url = strstr(cLine, "rtsp://")) || (url = strstr(cLine, "mmsh://")) ) { if (url != NULL) { description = "stream"; addUrl2Playlist(url, name, description.c_str()); } } } } infile.close(); } return false; }