From 15cee94e2290d8ecbfb6b21191a30bbe8a628276 Mon Sep 17 00:00:00 2001 From: FlatTV Date: Sun, 4 Dec 2016 11:53:40 +0100 Subject: [PATCH] capmt.cpp: Codeing the NI CI-Record workaround closer to original Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/8191d85c4c14095d083a46624c62c95c27b2a131 Author: FlatTV Date: 2016-12-04 (Sun, 04 Dec 2016) --- src/zapit/src/capmt.cpp | 128 +++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 73 deletions(-) diff --git a/src/zapit/src/capmt.cpp b/src/zapit/src/capmt.cpp index a8bc4dcc4..3e1849386 100644 --- a/src/zapit/src/capmt.cpp +++ b/src/zapit/src/capmt.cpp @@ -262,16 +262,13 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start mode, start ? "START" : "STOP", source, oldmask, newmask, force_update, rmode); //INFO("source %d old mask %d new mask %d force update %s", source, oldmask, newmask, force_update ? "yes" : "no"); - if((oldmask != newmask) || force_update) { INFO(" ##NI: (oldmask != newmask) || force_update)\n"); - if(start) { - cam->setCaMask(newmask); - cam->setSource(source); - if(newmask != 0 && (!filter_channels || !channel->bUseCI)) { - cam->makeCaPmt(channel, true); - cam->setCaPmt(true); - } + cam->setCaMask(newmask); + cam->setSource(source); + if(newmask != 0 && (!filter_channels || !channel->bUseCI)) { + cam->makeCaPmt(channel, true); + cam->setCaPmt(true); } } @@ -283,7 +280,6 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start StopCam(channel_id, cam); #ifdef BOXMODEL_APOLLO CZapitChannel * chan = CServiceManager::getInstance()->GetCurrentChannel(); - INFO(" ##NI: GetCurrentChannel (%s)\n",chan->getName().c_str()); //NI - this is a hack for rezaping to the recording channe //if commig from movieplayer, disable hack @@ -303,87 +299,73 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start rmode = true; INFO(" ##NI: rmode\n"); } + } else rmode = false; } #endif - //NI - if(oldmask == newmask) { - INFO(" ##NI: (oldmask == newmask) do nothing yet\n"); - } - - if(start) { //NI - INFO(" ##NI: (start)\n"); - 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; + 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; #ifdef BOXMODEL_APOLLO - INFO(" ##NI: channel_map.size() %d\n",channel_map.size()); + INFO(" ##NI: channel_map.size() %d\n",channel_map.size()); + int ci_use_count = 0; + for (it = channel_map.begin(); it != channel_map.end(); ++it) + { + cam = it->second; + channel = CServiceManager::getInstance()->FindChannel(it->first); - int ci_use_count = 0; - bool ts_use = false; //NI - for (it = channel_map.begin(); it != channel_map.end(); ++it) - { - cam = it->second; - channel = CServiceManager::getInstance()->FindChannel(it->first); - - if(!channel || !channel->scrambled) {//NI - INFO("CI: skip, channel not scrambled [%s]\n",channel->getName().c_str()); - continue; - } - ts_use = true; //NI - - if (tunerno >= 0 && tunerno == cDemux::GetSource(cam->getSource())) { - cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)tunerno); + if (tunerno >= 0 && tunerno == cDemux::GetSource(cam->getSource())) { + cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)tunerno); + ci_use_count++; + break; + } else if (filter_channels) { + if (channel && channel->bUseCI) ci_use_count++; - break; - } else if (filter_channels) { - if (channel && channel->bUseCI) - ci_use_count++; - } else - ci_use_count++; - } - if (ci_use_count == 0 && ts_use) { //NI - don't disable TS if SetTS wouldn't call - INFO("CI: not used for [%s], disabling TS\n",channel->getName().c_str()); - cCA::GetInstance()->SetTS(CA_DVBCI_TS_INPUT_DISABLED); - } + } else + ci_use_count++; + } + if (ci_use_count == 0) { + INFO("CI: not used for [%s], disabling TS\n",channel->getName().c_str()); + cCA::GetInstance()->SetTS(CA_DVBCI_TS_INPUT_DISABLED); + } #endif - for (it = channel_map.begin(); it != channel_map.end(); /*++it*/) - { - cam = it->second; - channel = CServiceManager::getInstance()->FindChannel(it->first); - ++it; - if(!channel || !channel->scrambled) //NI - continue; + 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 + 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, CA_SLOT_TYPE_SMARTCARD); + cam->makeCaPmt(channel, false, list, caids); + int len; + unsigned char * buffer = channel->getRawPmt(len); + cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_SMARTCARD); - if (tunerno >= 0 && tunerno != cDemux::GetSource(cam->getSource())) { - INFO("CI: configured tuner %d do not match %d, skip [%s]\n", tunerno, cam->getSource(), channel->getName().c_str()); - } else if (filter_channels && !channel->bUseCI) { - INFO("CI: filter enabled, CI not used for [%s]\n", channel->getName().c_str()); - } else { - useCI = true; //NI - INFO("CI: use CI for [%s]\n", channel->getName().c_str()); - cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI); - } - //list = CCam::CAPMT_MORE; + if (tunerno >= 0 && tunerno != cDemux::GetSource(cam->getSource())) { + INFO("CI: configured tuner %d do not match %d, skip [%s]\n", tunerno, cam->getSource(), channel->getName().c_str()); + } else if (filter_channels && !channel->bUseCI) { + INFO("CI: filter enabled, CI not used for [%s]\n", channel->getName().c_str()); + } else { + useCI = true; //NI + INFO("CI: use CI for [%s]\n", channel->getName().c_str()); + cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI); } - } //NI + //list = CCam::CAPMT_MORE; + } + return true; }