int CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) { if (!g_settings.epg_scan || (!standby && (CFEManager::getInstance()->getEnabledCount() <= 1))) { if ((msg == NeutrinoMessages::EVT_EIT_COMPLETE) || (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE)) return messages_return::handled; return messages_return::unhandled; } CZapitChannel * newchan; if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { AddTransponders(); INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size()); return messages_return::handled; } else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) { t_channel_id chid = *(t_channel_id *)data; newchan = CServiceManager::getInstance()->FindChannel(chid); if (newchan) { scanned.insert(newchan->getTransponderId()); scanmap.erase(newchan->getTransponderId()); } INFO("EIT read complete [" PRINTF_CHANNEL_ID_TYPE "], scan map size: %d", chid, scanmap.size()); Next(); return messages_return::handled; } else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) { t_channel_id chid = *(t_channel_id *)data; INFO("EVT_BACK_ZAP_COMPLETE [" PRINTF_CHANNEL_ID_TYPE "]", chid); if (next_chid) { newchan = CServiceManager::getInstance()->FindChannel(next_chid); if (newchan) { if(chid) { if (!CRecordManager::getInstance()->RecordingStatus()) { INFO("try to scan [%s]", newchan->getName().c_str()); if (standby && !g_Sectionsd->getIsScanningActive()) g_Sectionsd->setPauseScanning(false); g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux()); } } else { INFO("tune failed [%s]", newchan->getName().c_str()); scanmap.erase(newchan->getTransponderId()); Next(); } } } return messages_return::handled; } return messages_return::unhandled; }
bool CBat::ParseLogicalChannels(LogicalChannelDescriptor * ld, BouquetAssociation * b) { t_transport_stream_id transport_stream_id = b->getTransportStreamId(); t_original_network_id original_network_id = b->getOriginalNetworkId(); const LogicalChannelList &clist = *ld->getChannelList(); LogicalChannelListConstIterator it; for (it = clist.begin(); it != clist.end(); ++it) { int lcn = (*it)->getLogicalChannelNumber(); if(lcn == 0) continue; t_service_id service_id = (*it)->getServiceId(); t_channel_id channel_id = CZapitChannel::makeChannelId(0, 0, transport_stream_id, original_network_id, service_id); /* (*it)->getVisibleServiceFlag(); */ logical_map[channel_id] = lcn; #ifdef DEBUG_LCN std::string name; CZapitChannel * chan = CServiceManager::getInstance()->FindChannel48(channel_id); if(chan) name = chan->getName(); printf("BAT: logical channel %05d: tsid %04x onid %04x %016" PRIx64 " [%s] visible %d\n", lcn, transport_stream_id, original_network_id, channel_id, name.c_str(), (*it)->getVisibleServiceFlag()); #endif } return true; }
int CSelectChannelWidget::InitZapitChannelHelper(CZapitClient::channelsMode mode) { std::vector<CMenuWidget *> toDelete; CMenuWidget mctv(LOCALE_TIMERLIST_BOUQUETSELECT, NEUTRINO_ICON_SETTINGS, width); mctv.addIntroItems(); for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++) { CMenuWidget* mwtv = new CMenuWidget(LOCALE_TIMERLIST_CHANNELSELECT, NEUTRINO_ICON_SETTINGS, width); toDelete.push_back(mwtv); mwtv->addIntroItems(); ZapitChannelList channels; if (mode == CZapitClient::MODE_RADIO) g_bouquetManager->Bouquets[i]->getRadioChannels(channels); else g_bouquetManager->Bouquets[i]->getTvChannels(channels); for(int j = 0; j < (int) channels.size(); j++) { CZapitChannel * channel = channels[j]; char cChannelId[60] = {0}; snprintf(cChannelId, sizeof(cChannelId), "ZC%c:%d|%" PRIx64 "#", (mode==CZapitClient::MODE_TV)?'T':'R', channel->number, channel->channel_id); CMenuForwarder * chan_item = new CMenuForwarder(channel->getName(), true, NULL, this, (std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL, channel->scrambled ? NEUTRINO_ICON_SCRAMBLED: (channel->getUrl().empty() ? NULL : NEUTRINO_ICON_STREAMING)); chan_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); mwtv->addItem(chan_item); } #if 1 // FIXME, probably unneeded by now --martii if (g_bouquetManager->Bouquets[i]->Name == "extra.zapit_bouquetname_others" || g_bouquetManager->Bouquets[i]->Name == "extra.zapit_bouquetname_newchannels") continue; #endif if(!channels.empty() && (!g_bouquetManager->Bouquets[i]->bHidden )) { mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name, true, NULL, mwtv)); } } int res = mctv.exec (NULL, ""); // delete dynamic created objects for(unsigned int count=0;count<toDelete.size();count++) { delete toDelete[count]; } toDelete.clear(); return res; }
//------------------------------------------------------------------------- // 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; }
//------------------------------------------------------------------------- // y-func : get_channel_dropdown [<bouquet_nr> [<channel_id>]] //------------------------------------------------------------------------- std::string CNeutrinoYParser::func_get_channels_as_dropdown(CyhookHandler *, std::string para) { std::string abouquet, achannel_id, yresult, sel; int bnumber = 1; int mode = NeutrinoAPI->Zapit->getMode(); ySplitString(para," ",abouquet, achannel_id); if(abouquet != "") bnumber = atoi(abouquet.c_str()); if(bnumber > 0) { bnumber--; ZapitChannelList channels; //channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[bnumber]->radioChannels : g_bouquetManager->Bouquets[bnumber]->tvChannels; if (mode == CZapitClient::MODE_RADIO) g_bouquetManager->Bouquets[bnumber]->getRadioChannels(channels); else g_bouquetManager->Bouquets[bnumber]->getTvChannels(channels); for(int j = 0; j < (int) channels.size(); j++) { CEPGData epg; CZapitChannel * channel = channels[j]; char buf[100],id[20]; sprintf(id,PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS,channel->channel_id); std::string _sid = std::string(id); sel = (_sid == achannel_id) ? "selected=\"selected\"" : ""; CEitManager::getInstance()->getActualEPGServiceKey(channel->channel_id, &epg); sprintf(buf,"<option value="PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS" %s>%.20s - %.30s</option>\n", channel->channel_id, sel.c_str(), channel->getName().c_str(),epg.title.c_str()); yresult += buf; } } return yresult; }
void CEpgScan::Next() { bool llocked = false; #ifdef ENABLE_PIP bool plocked = false; #endif next_chid = 0; if (!standby && CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby) return; if (CRecordManager::getInstance()->RecordingStatus() || CStreamManager::getInstance()->StreamStatus()) return; if (g_settings.epg_scan == SCAN_FAV && scanmap.empty()) AddFavorites(); if (g_settings.epg_scan == SCAN_SEL && scanmap.empty()) AddSelected(); if (!CheckMode() || scanmap.empty()) { EnterStandby(); return; } /* executed in neutrino thread - possible race with locks in zapit zap NOWAIT : send zapTo_NOWAIT -> EIT_COMPLETE from sectionsd -> zap and this at the same time */ CFEManager::getInstance()->Lock(); CFrontend *live_fe = NULL; #ifdef ENABLE_PIP CFrontend *pip_fe = NULL; #endif if (!standby) { bool webtv = IS_WEBTV(CZapit::getInstance()->GetCurrentChannelID()); if (!webtv) { llocked = true; live_fe = CZapit::getInstance()->GetLiveFrontend(); CFEManager::getInstance()->lockFrontend(live_fe); } #ifdef ENABLE_PIP pip_fe = CZapit::getInstance()->GetPipFrontend(); if (pip_fe /* && pip_fe != live_fe*/) { plocked = true; CFEManager::getInstance()->lockFrontend(pip_fe); } #endif } _repeat: for (eit_scanmap_iterator_t it = scanmap.begin(); it != scanmap.end(); /* ++it*/) { CZapitChannel * newchan = CServiceManager::getInstance()->FindChannel(it->second); if (newchan == NULL) { scanmap.erase(it++); continue; } if (CFEManager::getInstance()->canTune(newchan)) { INFO("try to tune [%s]", newchan->getName().c_str()); next_chid = newchan->getChannelID(); break; } else INFO("skip [%s], cannot tune", newchan->getName().c_str()); ++it; } if (!next_chid && ((g_settings.epg_scan == SCAN_FAV) && AddFavorites())) goto _repeat; if (!next_chid && ((g_settings.epg_scan == SCAN_SEL) && AddSelected())) goto _repeat; if (llocked) CFEManager::getInstance()->unlockFrontend(live_fe); #ifdef ENABLE_PIP if (plocked) CFEManager::getInstance()->unlockFrontend(pip_fe); #endif CFEManager::getInstance()->Unlock(); if (next_chid) g_Zapit->zapTo_epg(next_chid, standby); else EnterStandby(); }
int CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) { if ((msg == NeutrinoMessages::EVT_TIMER) && (data == rescan_timer)) { INFO("rescan timer in %s mode, scanning %d", standby ? "standby" : "live", scan_in_progress); scanned.clear(); Clear(); g_RCInput->killTimer(rescan_timer); if (CheckMode()) { if (standby) CNeutrinoApp::getInstance()->wakeupFromStandby(); Start(standby); } else { AddTimer(); } return messages_return::handled; } if (!CheckMode()) { int ret = messages_return::handled; if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) scan_in_progress = false; else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) scan_in_progress = true; else ret = messages_return::unhandled; return ret; } CZapitChannel * newchan; if (msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { /* live channel changed, block scan channel change by timer */ scan_in_progress = true; AddTransponders(); INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size()); #if 0 t_channel_id chid = *(t_channel_id *)data; if (IS_WEBTV(chid)) Next(); #endif return messages_return::handled; } else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) { scan_in_progress = false; t_channel_id chid = *(t_channel_id *)data; newchan = CServiceManager::getInstance()->FindChannel(chid); if (newchan) { scanned.insert(newchan->getTransponderId()); scanmap.erase(newchan->getTransponderId()); } INFO("EIT read complete [" PRINTF_CHANNEL_ID_TYPE "], scan map size: %d", chid, scanmap.size()); Next(); return messages_return::handled; } else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) { scan_in_progress = true; t_channel_id chid = *(t_channel_id *)data; INFO("EVT_BACK_ZAP_COMPLETE [" PRINTF_CHANNEL_ID_TYPE "]", chid); if (next_chid) { newchan = CServiceManager::getInstance()->FindChannel(next_chid); if (newchan) { if(chid) { if (!CRecordManager::getInstance()->RecordingStatus()) { INFO("try to scan [%s]", newchan->getName().c_str()); if (standby && !g_Sectionsd->getIsScanningActive()) g_Sectionsd->setPauseScanning(false); g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux()); } } else { INFO("tune failed [%s]", newchan->getName().c_str()); scanmap.erase(newchan->getTransponderId()); Next(); } } } return messages_return::handled; } return messages_return::unhandled; }
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 CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start, bool force_update) { CCam * cam; int oldmask, newmask; int demux = DEMUX_SOURCE_0; int source = DEMUX_SOURCE_0; CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id); if(channel == NULL) { printf("CCamManager: channel %" PRIx64 " not found\n", channel_id); return false; } //INFO("channel %llx [%s] mode %d %s update %d", channel_id, channel->getName().c_str(), mode, start ? "START" : "STOP", force_update); mutex.lock(); cammap_iterator_t it = channel_map.find(channel_id); if(it != channel_map.end()) { cam = it->second; } else if(start) { cam = new CCam(); channel_map.insert(std::pair<t_channel_id, CCam*>(channel_id, cam)); } else { mutex.unlock(); return false; } /* FIXME until proper demux management */ switch(mode) { case PLAY: source = DEMUX_SOURCE_0; demux = LIVE_DEMUX; break; case STREAM: case RECORD: source = channel->getRecordDemux(); demux = channel->getRecordDemux(); break; #if 0 case STREAM: source = DEMUX_SOURCE_0; demux = STREAM_DEMUX; break; #endif case PIP: source = channel->getRecordDemux(); demux = channel->getPipDemux(); break; } oldmask = cam->getCaMask(); if(force_update) newmask = oldmask; else newmask = cam->makeMask(demux, start); if(cam->getSource() > 0) source = cam->getSource(); INFO("channel %" PRIx64 " [%s] mode %d %s src %d mask %d -> %d update %d", channel_id, channel->getName().c_str(), mode, start ? "START" : "STOP", source, oldmask, newmask, force_update); //INFO("source %d old mask %d new mask %d force update %s", source, oldmask, newmask, force_update ? "yes" : "no"); if((oldmask != newmask) || force_update) { cam->setCaMask(newmask); cam->setSource(source); if(newmask == 0) { cam->sendMessage(NULL, 0, false); cam->sendCaPmt(channel->getChannelID(), NULL, 0); } else { cam->makeCaPmt(channel, true); cam->setCaPmt(true); } } if(newmask == 0) { /* FIXME: back to live channel from playback dont parse pmt and call setCaPmt * (see CMD_SB_LOCK / UNLOCK PLAYBACK */ //channel->setRawPmt(NULL);//FIXME channel_map.erase(channel_id); delete cam; } CaIdVector caids; cCA::GetInstance()->GetCAIDS(caids); //uint8_t list = CCam::CAPMT_FIRST; uint8_t list = CCam::CAPMT_ONLY; if (channel_map.size() > 1) list = CCam::CAPMT_ADD; for (it = channel_map.begin(); it != channel_map.end(); /*++it*/) { cam = it->second; channel = CServiceManager::getInstance()->FindChannel(it->first); ++it; if(!channel) continue; #if 0 if (it == channel_map.end()) list |= CCam::CAPMT_LAST; // FIRST->ONLY or MORE->LAST #endif cam->makeCaPmt(channel, false, list, caids); int len; unsigned char * buffer = channel->getRawPmt(len); cam->sendCaPmt(channel->getChannelID(), buffer, len); //list = CCam::CAPMT_MORE; } mutex.unlock(); return true; }
void CStreamInfo2::paint_techinfo(int xpos, int ypos) { char buf[100]; int xres = 0, yres = 0, aspectRatio = 0, framerate = -1; // paint labels int spaceoffset = 0,i = 0; int ypos1 = ypos; int box_width = width*2/3 - 10; yypos = ypos; if(box_h > 0) frameBuffer->paintBoxRel (0, ypos, box_width, box_h, COL_MENUHEAD_PLUS_0); CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); if(!channel) return; int array[6]={g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_RESOLUTION)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_ARATIO)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_BITRATE)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE)), g_Font[font_info]->getRenderWidth(g_Locale->getText (LOCALE_SCANTS_FREQDATA))}; for(i=0 ; i<6; i++) { if(spaceoffset < array[i]) spaceoffset = array[i]; } spaceoffset += g_Font[font_info]->getRenderWidth(" "); average_bitrate_offset = spaceoffset; if((channel->getVideoPid() || IS_WEBTV(channel->getChannelID())) && !(videoDecoder->getBlank())){ videoDecoder->getPictureInfo(xres, yres, framerate); if (yres == 1088) yres = 1080; aspectRatio = videoDecoder->getAspectRatio(); } //Video RESOLUTION ypos += iheight; sprintf (buf, "%s:",g_Locale->getText (LOCALE_STREAMINFO_RESOLUTION)); g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_INFOBAR_TEXT); sprintf (buf, "%dx%d", xres, yres); g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //audio rate ypos += iheight; sprintf (buf, "%s:",g_Locale->getText (LOCALE_STREAMINFO_ARATIO)); g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_INFOBAR_TEXT); switch (aspectRatio) { case 0: sprintf (buf, "N/A"); break; case 1: sprintf (buf, "4:3"); break; case 2: sprintf (buf, "14:9"); break; case 3: sprintf (buf, "16:9"); break; case 4: sprintf (buf, "20:9"); break; default: strncpy (buf, g_Locale->getText (LOCALE_STREAMINFO_ARATIO_UNKNOWN), sizeof (buf)-1); } g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //Video FRAMERATE ypos += iheight; sprintf (buf, "%s:", g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE)); g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_INFOBAR_TEXT); switch (framerate) { case 0: snprintf (buf,sizeof(buf), "23.976fps"); break; case 1: snprintf (buf,sizeof(buf), "24fps"); break; case 2: snprintf (buf,sizeof(buf), "25fps"); break; case 3: snprintf (buf,sizeof(buf), "29,976fps"); break; case 4: snprintf (buf,sizeof(buf), "30fps"); break; case 5: snprintf (buf,sizeof(buf), "50fps"); break; case 6: snprintf (buf,sizeof(buf), "50,94fps"); break; case 7: snprintf (buf,sizeof(buf), "60fps"); break; default: strncpy (buf, g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE_UNKNOWN), sizeof (buf)-1); break; } g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); // place for average bitrate average_bitrate_pos = ypos += iheight; //AUDIOTYPE ypos += iheight; int type, layer, freq, mode, lbitrate; audioDecoder->getAudioInfo(type, layer, freq, lbitrate, mode); sprintf (buf, "%s:", g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE)); g_Font[font_info]->RenderString (xpos, ypos, box_width, buf, COL_INFOBAR_TEXT); if(type == AUDIO_FMT_MPEG) { const int max_mode = 4; const char *mpegmodes[max_mode] = { "stereo", "joint_st", "dual_ch", "single_ch" }; sprintf (buf, "MPEG %s (%d)", (mode > max_mode) ?"unk":mpegmodes[mode], freq); } else if (type == AUDIO_FMT_DOLBY_DIGITAL || type == AUDIO_FMT_DD_PLUS) { const int max_mode = 8; const char *ddmodes[max_mode] = { "CH1/CH2", "C", "L/R", "L/C/R", "L/R/S", "L/C/R/S", "L/R/SL/SR", "L/C/R/SL/SR" }; sprintf (buf, "%s %s (%d)", (type == AUDIO_FMT_DOLBY_DIGITAL) ? "DD" : "DD+", (mode > max_mode) ?"unk": ddmodes[mode], freq); } else if (type == AUDIO_FMT_AAC || type == AUDIO_FMT_AAC_PLUS) { const int max_mode = 10; const char *aacmodes[max_mode] = { "N/S", "Mono", "L/R", "L/C/R", "L/C/R/SR/SL", "L/C/R/SR/SL/S", "L/R/RL/RR", "L/C/R/S", "L/R/SL/SR", "Dual-Mono" }; sprintf (buf, "%s %s (%d)", (type == AUDIO_FMT_AAC) ? "AAC" : "AAC+", (mode > max_mode) ?"unk":aacmodes[mode], freq); } else { sprintf (buf, "%s (%d)", g_Locale->getText(LOCALE_STREAMINFO_AUDIOTYPE_UNKNOWN), freq); } g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); if (mp) { //channel ypos += iheight; if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) { sprintf (buf, "%s:",g_Locale->getText (LOCALE_TIMERLIST_CHANNEL));//swiped locale g_Font[font_info]->RenderString(xpos, ypos, box_width, buf , COL_INFOBAR_TEXT); sprintf(buf, "%s", channel->getName().c_str()); g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); } else { sprintf (buf, "%s:",g_Locale->getText (LOCALE_MOVIEBROWSER_INFO_FILE));//swiped locale g_Font[font_info]->RenderString(xpos, ypos, box_width, buf , COL_INFOBAR_TEXT); sprintf(buf, "%s", mp->GetFile().c_str()); g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); } scaling = 27000; } else { transponder t; t = *frontend->getParameters(); //satellite ypos += iheight; if (CFrontend::isSat(t.feparams.delsys)) sprintf (buf, "%s:",g_Locale->getText (LOCALE_SATSETUP_SATELLITE));//swiped locale else if (CFrontend::isCable(t.feparams.delsys)) sprintf (buf, "%s:",g_Locale->getText (LOCALE_CHANNELLIST_PROVS)); else if (CFrontend::isTerr(t.feparams.delsys)) snprintf (buf, sizeof(buf), "%s:",g_Locale->getText (LOCALE_TERRESTRIALSETUP_AREA)); g_Font[font_info]->RenderString(xpos, ypos, box_width, buf, COL_INFOBAR_TEXT); sprintf (buf, "%s", IS_WEBTV(channel->getChannelID()) ? g_Locale->getText(LOCALE_WEBTV_HEAD) : CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()).c_str()); g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //channel ypos += iheight; sprintf (buf, "%s:",g_Locale->getText (LOCALE_TIMERLIST_CHANNEL));//swiped locale g_Font[font_info]->RenderString(xpos, ypos, box_width, buf , COL_INFOBAR_TEXT); sprintf(buf, "%s", channel->getName().c_str()); g_Font[font_info]->RenderString (xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //tsfrequenz ypos += iheight; scaling = 27000; if (CFrontend::isSat(t.feparams.delsys) && t.feparams.delsys == DVB_S) scaling = 15000; sprintf (buf, "%s",g_Locale->getText (LOCALE_SCANTS_FREQDATA)); g_Font[font_info]->RenderString(xpos, ypos, box_width, buf , COL_INFOBAR_TEXT); g_Font[font_info]->RenderString(xpos+spaceoffset, ypos, box_width, t.description().c_str(), COL_INFOBAR_TEXT); // paint labels int fontW = g_Font[font_small]->getWidth(); spaceoffset = 7 * fontW; //onid ypos+= sheight; sprintf(buf, "0x%04X (%i)", channel->getOriginalNetworkId(), channel->getOriginalNetworkId()); g_Font[font_small]->RenderString(xpos, ypos, box_width, "ONid:" , COL_INFOBAR_TEXT); g_Font[font_small]->RenderString(xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //sid ypos+= sheight; sprintf(buf, "0x%04X (%i)", channel->getServiceId(), channel->getServiceId()); g_Font[font_small]->RenderString(xpos, ypos, box_width, "Sid:" , COL_INFOBAR_TEXT); g_Font[font_small]->RenderString(xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //tsid ypos+= sheight; sprintf(buf, "0x%04X (%i)", channel->getTransportStreamId(), channel->getTransportStreamId()); g_Font[font_small]->RenderString(xpos, ypos, box_width, "TSid:" , COL_INFOBAR_TEXT); g_Font[font_small]->RenderString(xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //pmtpid ypos+= sheight; pmt_version = channel->getPmtVersion(); sprintf(buf, "0x%04X (%i) [0x%02X]", channel->getPmtPid(), channel->getPmtPid(), pmt_version); g_Font[font_small]->RenderString(xpos, ypos, box_width, "PMTpid:", COL_INFOBAR_TEXT); g_Font[font_small]->RenderString(xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //vpid ypos+= sheight; if ( g_RemoteControl->current_PIDs.PIDs.vpid > 0 ){ sprintf(buf, "0x%04X (%i)", g_RemoteControl->current_PIDs.PIDs.vpid, g_RemoteControl->current_PIDs.PIDs.vpid ); } else { sprintf(buf, "%s", g_Locale->getText(LOCALE_STREAMINFO_NOT_AVAILABLE)); } g_Font[font_small]->RenderString(xpos, ypos, box_width, "Vpid:" , COL_INFOBAR_TEXT); g_Font[font_small]->RenderString(xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); //apid ypos+= sheight; g_Font[font_small]->RenderString(xpos, ypos, box_width, "Apid(s):" , COL_INFOBAR_TEXT); if (g_RemoteControl->current_PIDs.APIDs.empty()){ sprintf(buf, "%s", g_Locale->getText(LOCALE_STREAMINFO_NOT_AVAILABLE)); } else { unsigned int sw=spaceoffset; for (unsigned int li= 0; (li<g_RemoteControl->current_PIDs.APIDs.size()) && (li<10); li++) { sprintf(buf, "0x%04X (%i)", g_RemoteControl->current_PIDs.APIDs[li].pid, g_RemoteControl->current_PIDs.APIDs[li].pid ); if (li == g_RemoteControl->current_PIDs.PIDs.selected_apid){ g_Font[font_small]->RenderString(xpos+sw, ypos, box_width, buf, COL_MENUHEAD_TEXT); } else{ g_Font[font_small]->RenderString(xpos+sw, ypos, box_width, buf, COL_INFOBAR_TEXT); } sw = g_Font[font_small]->getRenderWidth(buf)+sw+10; if (((li+1)%3 == 0) &&(g_RemoteControl->current_PIDs.APIDs.size()-1 > li)){ // if we have lots of apids, put "intermediate" line with pids ypos+= sheight; sw=spaceoffset; } } } //vtxtpid ypos += sheight; if ( g_RemoteControl->current_PIDs.PIDs.vtxtpid == 0 ) sprintf(buf, "%s", g_Locale->getText(LOCALE_STREAMINFO_NOT_AVAILABLE)); else sprintf(buf, "0x%04X (%i)", g_RemoteControl->current_PIDs.PIDs.vtxtpid, g_RemoteControl->current_PIDs.PIDs.vtxtpid ); g_Font[font_small]->RenderString(xpos, ypos, box_width, "VTXTpid:" , COL_INFOBAR_TEXT); g_Font[font_small]->RenderString(xpos+spaceoffset, ypos, box_width, buf, COL_INFOBAR_TEXT); if(box_h == 0) box_h = ypos - ypos1; yypos = ypos; paintCASystem(xpos,ypos); } }
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; }