//------------------------------------------------------------------------- // TODO: clean up code // use templates? //------------------------------------------------------------------------- std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std::string para) { int BouquetNr = 0; std::string abnumber, tmp,yresult; ZapitChannelList channels; //int num; int mode = NeutrinoAPI->Zapit->getMode(); ySplitString(para," ",abnumber, tmp); if(abnumber != "") BouquetNr = atoi(abnumber.c_str()); if (BouquetNr > 0) { BouquetNr--; #if 0 channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[BouquetNr]->radioChannels : g_bouquetManager->Bouquets[BouquetNr]->tvChannels; num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr) : g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr)) ; #endif if (mode == CZapitClient::MODE_RADIO) g_bouquetManager->Bouquets[BouquetNr]->getRadioChannels(channels); else g_bouquetManager->Bouquets[BouquetNr]->getTvChannels(channels); } else { CBouquetManager::ChannelIterator cit = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin() : g_bouquetManager->tvChannelsBegin(); for (; !(cit.EndOfChannels()); cit++) channels.push_back(*cit); //num = 1; } NeutrinoAPI->GetChannelEvents(); int i = 1; char classname; t_channel_id current_channel = CZapit::getInstance()->GetCurrentChannelID(); int prozent = 100; CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo; std::string timestr; bool have_logos = false; if(hh->WebserverConfigList["Tuxbox.LogosURL"] != "") have_logos = true; for(int j = 0; j < (int) channels.size(); j++) { CZapitChannel * channel = channels[j]; CChannelEvent *event; event = NeutrinoAPI->ChannelListEvents[channel->channel_id]; classname = (i++ & 1) ? 'a' : 'b'; if (channel->channel_id == current_channel) classname = 'c'; std::string bouquetstr = (BouquetNr >= 0) ? ("&bouquet=" + itoa(BouquetNr)) : ""; yresult += "<tr>"; if(have_logos) yresult += string_printf("<td class=\"%c\" width=\"44\" rowspan=\"2\"><a href=\"javascript:do_zap('" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "')\"><img class=\"channel_logo\" src=\"%s\"/></a></td>", classname, channel->channel_id, (NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id)).c_str()); /* timer slider */ if(event && event->duration > 0) { prozent = 100 * (time(NULL) - event->startTime) / event->duration; yresult += string_printf("<td class=\"%c\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"3\"><tr><td>\n" "\t<table border=\"0\" rules=\"none\" class=\"cslider cslider_table\">" "<tr>" "<td class=\"cslider cslider_used\" width=\"%d\"></td>" "<td class=\"cslider cslider_free\" width=\"%d\"></td>" "</tr>" "</table>\n</td>\n" , classname , (prozent / 10) * 3 , (10 - (prozent / 10))*3 ); } else { yresult += string_printf("<td class=\"%c\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"3\"><tr><td>\n" "\t<table border=\"0\" rules=\"none\" class=\"cslider cslider_table\">" "<tr>" "<td class=\"cslider cslider_noepg\"></td>" "</tr>" "</table>\n</td>\n" , classname ); } /* channel name and buttons */ yresult += string_printf("<td>\n%s<a class=\"clist\" href=\"javascript:do_zap('" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "')\"> %d. %s%s</a> <a href=\"javascript:do_epg('" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "','" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "')\">%s</a>\n", ((channel->channel_id == current_channel) ? "<a name=\"akt\"></a>" : " "), channel->channel_id, channel->number /* num + j */, channel->getName().c_str(), (channel->getServiceType() == ST_NVOD_REFERENCE_SERVICE) ? " (NVOD)" : "", channel->channel_id, channel->channel_id & 0xFFFFFFFFFFFFULL, ((NeutrinoAPI->ChannelListEvents[channel->channel_id]) ? "<img src=\"/images/elist.gif\" alt=\"Program preview\" style=\"border: 0px\" />" : "")); if (channel->channel_id == current_channel) yresult += string_printf("\n <a href=\"javascript:do_streaminfo()\"><img src=\"/images/streaminfo.png\" alt=\"Streaminfo\" style=\"border: 0px\" /></a>"); yresult += string_printf("</td></tr></table>\n</td>\n</tr>\n"); if (channel->getServiceType() == ST_NVOD_REFERENCE_SERVICE) { CSectionsdClient::NVODTimesList nvod_list; if (CEitManager::getInstance()->getNVODTimesServiceKey(channel->channel_id, nvod_list)) { CZapitClient::subServiceList subServiceList; for (CSectionsdClient::NVODTimesList::iterator ni = nvod_list.begin(); ni != nvod_list.end(); ++ni) { CZapitClient::commandAddSubServices cmd; CEPGData epg; // Byte Sequence by ntohs cmd.original_network_id = ntohs(ni->original_network_id); cmd.service_id = ntohs(ni->service_id); cmd.transport_stream_id = ntohs(ni->transport_stream_id); t_channel_id channel_id = CREATE_CHANNEL_ID(cmd.service_id, cmd.original_network_id, cmd.transport_stream_id); timestr = timeString(ni->zeit.startzeit); // FIXME: time is wrong (at least on little endian)! CEitManager::getInstance()->getActualEPGServiceKey(channel_id, &epg); // FIXME: der scheissendreck geht nit!!! yresult += string_printf("<tr>\n<td align=\"left\" style=\"width: 31px\" class=\"%cepg\"> </td>", classname); yresult += string_printf("<td class=\"%cepg\">%s ", classname, timestr.c_str()); yresult += string_printf("%s<a href=\"javascript:do_zap('" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS ")'\">%04x:%04x:%04x %s</a>", // FIXME: get name (channel_id == current_channel) ? "<a name=\"akt\"></a>" : " ", channel_id, bouquetstr.c_str(), cmd.transport_stream_id, cmd.original_network_id, cmd.service_id, epg.title.c_str()); yresult += string_printf("</td>\n</tr>"); subServiceList.push_back(cmd); } if (!(subServiceList.empty())) NeutrinoAPI->Zapit->setSubServices(subServiceList); } } else if ((event = NeutrinoAPI->ChannelListEvents[channel->channel_id])) { bool has_current_next = true; CEitManager::getInstance()->getCurrentNextServiceKey(channel->channel_id, currentNextInfo); timestr = timeString(event->startTime); yresult += string_printf("<tr><td class=\"%cepg\">",classname); yresult += string_printf("%s %s " "<span style=\"font-size: 8pt; white-space: nowrap\">(%ld von %d min, %d%%)</span>" , timestr.c_str() , event->description.c_str() , (time(NULL) - event->startTime)/60 , event->duration / 60,prozent); if ((has_current_next) && (currentNextInfo.flags & CSectionsdClient::epgflags::has_next)) { timestr = timeString(currentNextInfo.next_zeit.startzeit); yresult += string_printf("<br />%s %s", timestr.c_str(), currentNextInfo.next_name.c_str()); } yresult += string_printf("</td></tr>\n"); } else yresult += string_printf("<tr style=\"height: 2px\"><td></td></tr>\n"); } return yresult; }
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; }