From eab8bbec206d23cb52ea860b8ea7aba15e140d3d Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Fri, 6 Nov 2015 17:20:48 +0300 Subject: [PATCH] neutrino: add option to limit CI usage to selected bouquets; if no bouquets selected, CI used for all channels --- data/locale/english.locale | 1 + src/gui/bouquetlist.cpp | 55 ++++++++++++++++++++++++--- src/system/locals.h | 1 + src/system/locals_intern.h | 1 + src/zapit/include/zapit/bouquets.h | 6 ++- src/zapit/include/zapit/capmt.h | 2 + src/zapit/include/zapit/channel.h | 1 + src/zapit/include/zapit/getservices.h | 1 + src/zapit/src/bouquets.cpp | 11 ++++-- src/zapit/src/capmt.cpp | 3 ++ src/zapit/src/channel.cpp | 1 + src/zapit/src/getservices.cpp | 13 +++++++ 12 files changed, 86 insertions(+), 10 deletions(-) diff --git a/data/locale/english.locale b/data/locale/english.locale index e8c2ebc40..62b4159bf 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -282,6 +282,7 @@ ci.save_pincode Save pincode ci.settings Conditional access ci.timeout Timeout waiting CI menu ready ci.tuner Use CI only with tuner: +ci.use Enable CI ci.waiting Waiting for CI answer clock_background Show background clock_seconds Show seconds diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 5acc9c610..c3185364b 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -223,7 +223,7 @@ int CBouquetList::exec( bool bShowChannelList) int CBouquetList::doMenu() { - int i = 0; + int i = 0, ret = 0; int select = -1; static int old_selected = 0; signed int bouquet_id; @@ -245,13 +245,16 @@ int CBouquetList::doMenu() CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); int old_epg = zapitBouquet ? zapitBouquet->bScanEpg : 0; + int old_ci = zapitBouquet ? zapitBouquet->bUseCI : 0; sprintf(cnt, "%d", i); /* FIXME menu centered different than bouquet list ??? */ /* provider bouquet */ if (zapitBouquet && !zapitBouquet->bUser) { menu->addItem(new CMenuForwarder(LOCALE_FAVORITES_COPY, true, NULL, selector, cnt, CRCInput::RC_blue), old_selected == i ++); - if (g_settings.epg_scan == CEpgScan::SCAN_SEL) + if (!zapitBouquet->bWebtv && g_settings.epg_scan == CEpgScan::SCAN_SEL) menu->addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SCAN, &zapitBouquet->bScanEpg, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); + if (!zapitBouquet->bWebtv) + menu->addItem(new CMenuOptionChooser(LOCALE_CI_USE, &zapitBouquet->bUseCI, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); menu->exec(NULL, ""); delete menu; delete selector; @@ -259,6 +262,21 @@ int CBouquetList::doMenu() if (old_epg != zapitBouquet->bScanEpg) { save_bouquets = true; CNeutrinoApp::getInstance()->MarkBouquetsChanged(); + ret = -1; + } + if (old_ci != zapitBouquet->bUseCI) { + channels = &zapitBouquet->tvChannels; + for(int li = 0; li < (int) channels->size(); li++) + (*channels)[li]->bUseCI = zapitBouquet->bUseCI; + + channels = &zapitBouquet->radioChannels; + for(int li = 0; li < (int) channels->size(); li++) + (*channels)[li]->bUseCI = zapitBouquet->bUseCI; + + CServiceManager::getInstance()->SetCIFilter(); + save_bouquets = true; + CNeutrinoApp::getInstance()->MarkBouquetsChanged(); + ret = -1; } if(select >= 0) { @@ -304,8 +322,10 @@ int CBouquetList::doMenu() } else { /* user or satellite bouquet */ menu->addItem(new CMenuForwarder(LOCALE_BOUQUETEDITOR_DELETE, true, NULL, selector, cnt, CRCInput::RC_red), old_selected == i ++); - if (zapitBouquet && (g_settings.epg_scan == CEpgScan::SCAN_SEL)) + if (zapitBouquet && !zapitBouquet->bWebtv && (g_settings.epg_scan == CEpgScan::SCAN_SEL)) menu->addItem(new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SCAN, &zapitBouquet->bScanEpg, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); + if (zapitBouquet && !zapitBouquet->bWebtv) + menu->addItem(new CMenuOptionChooser(LOCALE_CI_USE, &zapitBouquet->bUseCI, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); menu->exec(NULL, ""); delete menu; @@ -313,6 +333,21 @@ int CBouquetList::doMenu() if (zapitBouquet && (old_epg != zapitBouquet->bScanEpg)) { save_bouquets = true; CNeutrinoApp::getInstance()->MarkFavoritesChanged(); + ret = -1; + } + if (zapitBouquet && (old_ci != zapitBouquet->bUseCI)) { + channels = &zapitBouquet->tvChannels; + for(int li = 0; li < (int) channels->size(); li++) + (*channels)[li]->bUseCI = zapitBouquet->bUseCI; + + channels = &zapitBouquet->radioChannels; + for(int li = 0; li < (int) channels->size(); li++) + (*channels)[li]->bUseCI = zapitBouquet->bUseCI; + + CServiceManager::getInstance()->SetCIFilter(); + save_bouquets = true; + CNeutrinoApp::getInstance()->MarkFavoritesChanged(); + ret = -1; } printf("CBouquetList::doMenu: %d selected\n", select); @@ -342,7 +377,7 @@ int CBouquetList::doMenu() } } } - return 0; + return ret; } const struct button_label CBouquetListButtons[4] = @@ -638,9 +673,19 @@ void CBouquetList::paintItem(int pos) if (iw && ih) { int icon_x = (x+width-2) - RADIUS_LARGE/2 - iw; frameBuffer->paintIcon(NEUTRINO_ICON_EPG, icon_x - iw, ypos, fheight); - iw = iw + 12 + RADIUS_LARGE/2; + iw = iw + 4 + RADIUS_LARGE/2; } } + if (Bouquets[npos]->zapitBouquet && Bouquets[npos]->zapitBouquet->bUseCI) { + int iw2; + frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED2, &iw2, &ih); + if (iw2 && ih) { + int icon_x = (x+width-2) - RADIUS_LARGE/2 - iw - iw2 - 2; + frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED2, icon_x - iw2, ypos, fheight); + iw = iw + iw2 + 4 + RADIUS_LARGE/2; + } + } + int numpos = x+5+numwidth- g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos,ypos+fheight, numwidth+5, tmp, color, fheight); diff --git a/src/system/locals.h b/src/system/locals.h index 9138c0f8a..fdde7dc29 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -309,6 +309,7 @@ typedef enum LOCALE_CI_SETTINGS, LOCALE_CI_TIMEOUT, LOCALE_CI_TUNER, + LOCALE_CI_USE, LOCALE_CI_WAITING, LOCALE_CLOCK_BACKGROUND, LOCALE_CLOCK_SECONDS, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 2868f11ca..a498b74e9 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -309,6 +309,7 @@ const char * locale_real_names[] = "ci.settings", "ci.timeout", "ci.tuner", + "ci.use", "ci.waiting", "clock_background", "clock_seconds", diff --git a/src/zapit/include/zapit/bouquets.h b/src/zapit/include/zapit/bouquets.h index 0c169c289..007133a45 100644 --- a/src/zapit/include/zapit/bouquets.h +++ b/src/zapit/include/zapit/bouquets.h @@ -44,7 +44,8 @@ class CZapitBouquet bool bFav; bool bOther; int bScanEpg; - bool bVirtual; // dont save + bool bWebtv; // dont save + int bUseCI; t_satellite_position satellitePosition; ZapitChannelList radioChannels; @@ -59,7 +60,8 @@ class CZapitBouquet bUser = false; bOther = DEFAULT_BQ_OTHER; bScanEpg = DEFAULT_BQ_SCANEPG; - bVirtual = false; + bWebtv = false; + bUseCI = false; } void addService(CZapitChannel* newChannel); diff --git a/src/zapit/include/zapit/capmt.h b/src/zapit/include/zapit/capmt.h index 228be79cb..e85a3f458 100644 --- a/src/zapit/include/zapit/capmt.h +++ b/src/zapit/include/zapit/capmt.h @@ -90,6 +90,7 @@ class CCamManager cammap_t channel_map; OpenThreads::Mutex mutex; int tunerno; + bool filter_channels; static CCamManager * manager; bool SetMode(t_channel_id id, enum runmode mode, bool enable, bool force_update = false); void StopCam(t_channel_id id, CCam *cam); @@ -102,6 +103,7 @@ class CCamManager bool Stop(t_channel_id id, enum runmode mode) { return SetMode(id, mode, false); }; void SetCITuner(int tuner); int GetCITuner(void) { return tunerno; }; + void EnableChannelFilter(bool enable) { filter_channels = enable; }; }; #endif /* __capmt_h__ */ diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index fba6150dc..25702d659 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -191,6 +191,7 @@ class CZapitChannel unsigned int bLockCount; bool bLocked; + bool bUseCI; int number; CChannelEvent currentEvent,nextEvent; diff --git a/src/zapit/include/zapit/getservices.h b/src/zapit/include/zapit/getservices.h index 361cdc8e3..2aa4616c2 100644 --- a/src/zapit/include/zapit/getservices.h +++ b/src/zapit/include/zapit/getservices.h @@ -178,5 +178,6 @@ class CServiceManager transponder_list_t & GetTransponders() { return transponders; } transponder_list_t & GetSatelliteTransponders(t_satellite_position position) { return satelliteTransponders[position]; } void KeepNumbers(bool enable) { keep_numbers = enable; }; + void SetCIFilter(void); }; #endif /* __getservices_h__ */ diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index 6c438c4b5..c338db34e 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -230,6 +230,7 @@ void CBouquetManager::writeBouquetHeader(FILE * bouq_fd, uint32_t i, const char if (Bouquets[i]->bHidden!=DEFAULT_BQ_HIDDEN) fprintf(bouq_fd, " hidden=\"%d\"", Bouquets[i]->bHidden ? 1 : 0); if (Bouquets[i]->bLocked!=DEFAULT_BQ_LOCKED) fprintf(bouq_fd, " locked=\"%d\"", Bouquets[i]->bLocked ? 1 : 0); if (Bouquets[i]->bScanEpg!=DEFAULT_BQ_SCANEPG) fprintf(bouq_fd, " epg=\"%d\"", Bouquets[i]->bScanEpg ? 1 : 0); + if (Bouquets[i]->bUseCI) fprintf(bouq_fd, " ci=\"1\""); fprintf(bouq_fd, ">\n"); } @@ -272,7 +273,7 @@ void CBouquetManager::saveBouquets(void) for (unsigned int i = 0; i < Bouquets.size(); i++) { if (Bouquets[i] != remainChannels) { DBG("save Bouquets: name %s user: %d\n", Bouquets[i]->Name.c_str(), Bouquets[i]->bUser); - if(!Bouquets[i]->bUser && !Bouquets[i]->bVirtual) { + if(!Bouquets[i]->bUser && !Bouquets[i]->bWebtv) { writeBouquet(bouq_fd, i,false); } } @@ -405,10 +406,12 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) const char* hidden = xmlGetAttribute(search, "hidden"); const char* locked = xmlGetAttribute(search, "locked"); const char* scanepg = xmlGetAttribute(search, "epg"); + const char* useci = xmlGetAttribute(search, "ci"); 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; + newBouquet->bUseCI = useci ? (strcmp(useci, "1") == 0) : false; channel_node = xmlChildrenNode(search); while ((channel_node = xmlGetNextOccurence(channel_node, "S")) != NULL) { std::string name2; @@ -444,6 +447,7 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); chan->bLocked = clock; + chan->bUseCI = newBouquet->bUseCI; newBouquet->addService(chan); } else if (bUser) { @@ -495,6 +499,7 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile) loadWebtv(); parseBouquetsXml(UBOUQUETS_XML, true); renumServices(); + CServiceManager::getInstance()->SetCIFilter(); TIMER_STOP("[zapit] bouquet loading took"); } @@ -813,7 +818,7 @@ void CBouquetManager::loadWebtv() if (!prov) prov = "WebTV"; pbouquet = addBouquetIfNotExist(prov); - pbouquet->bVirtual = true; + pbouquet->bWebtv = true; while ((xmlGetNextOccurence(l1, "webtv"))) { const char *title = xmlGetAttribute(l1, "title"); @@ -829,7 +834,7 @@ void CBouquetManager::loadWebtv() if (genre) { std::string bname = prov ? std::string(std::string(prov) + " ") + genre : genre; gbouquet = addBouquetIfNotExist(bname); - gbouquet->bVirtual = true; + gbouquet->bWebtv = true; } if (title && url) { t_channel_id chid = create_channel_id64(0, 0, 0, 0, 0, url); diff --git a/src/zapit/src/capmt.cpp b/src/zapit/src/capmt.cpp index 99de9a2d1..894f20591 100644 --- a/src/zapit/src/capmt.cpp +++ b/src/zapit/src/capmt.cpp @@ -171,6 +171,7 @@ CCamManager::CCamManager() { channel_map.clear(); tunerno = -1; + filter_channels = false; } CCamManager::~CCamManager() @@ -298,6 +299,8 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start if (tunerno >= 0 && tunerno != cDemux::GetSource(cam->getSource())) INFO("CI: configured tuner %d do not match %d, skip...\n", tunerno, cam->getSource()); + else if (filter_channels && !channel->bUseCI) + INFO("CI: filter enabled, CI not used\n"); else cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI); //list = CCam::CAPMT_MORE; diff --git a/src/zapit/src/channel.cpp b/src/zapit/src/channel.cpp index 5a497a34d..45c98b476 100644 --- a/src/zapit/src/channel.cpp +++ b/src/zapit/src/channel.cpp @@ -99,6 +99,7 @@ void CZapitChannel::Init() delsys = DVB_S; bLockCount = 0; bLocked = DEFAULT_CH_LOCKED; + bUseCI = false; } CZapitChannel::~CZapitChannel(void) diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index 7f4bcd662..3918082a9 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1391,3 +1392,15 @@ bool CServiceManager::IsChannelTVChannel(const t_channel_id channel_id) ret = (channel->getServiceType() != ST_DIGITAL_RADIO_SOUND_SERVICE); return ret; } + +void CServiceManager::SetCIFilter() +{ + bool enable = false; + for (channel_map_iterator_t it = allchans.begin(); it != allchans.end(); ++it) { + if (it->second.bUseCI) { + enable = true; + break; + } + } + CCamManager::getInstance()->EnableChannelFilter(enable); +}