port CI handling (thx FlatTV!)

Origin commit data
------------------
Branch: ni/coolstream
Commit: d41235ac34
Author: gixxpunk <thomas.harfmann@gmail.com>
Date: 2017-11-09 (Thu, 09 Nov 2017)

Origin message was:
------------------
- port CI handling (thx FlatTV!)

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
gixxpunk
2017-11-09 11:27:07 +01:00
parent dc00052ca6
commit 42f9b4a572
2 changed files with 127 additions and 80 deletions

View File

@@ -100,7 +100,6 @@ class CFEManager
bool getSatelliteConfig(CFrontend * fe, sat_config_t &satconfig); bool getSatelliteConfig(CFrontend * fe, sat_config_t &satconfig);
bool loopCanTune(CFrontend * fe, CZapitChannel * channel); bool loopCanTune(CFrontend * fe, CZapitChannel * channel);
CFrontend * getFrontend(CZapitChannel * channel);
void copySettings(CFrontend * from, CFrontend * to); void copySettings(CFrontend * from, CFrontend * to);
static CFEManager * manager; static CFEManager * manager;
@@ -118,6 +117,7 @@ class CFEManager
void setLiveFE(CFrontend * fe); void setLiveFE(CFrontend * fe);
CFrontend * allocateFE(CZapitChannel * channel, bool forrecord = false); CFrontend * allocateFE(CZapitChannel * channel, bool forrecord = false);
CFrontend * getFrontend(CZapitChannel * channel);
fe_mode_t getMode() { return mode; }; fe_mode_t getMode() { return mode; };

View File

@@ -243,12 +243,7 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
//INFO("channel %llx [%s] mode %d %s update %d", channel_id, channel->getName().c_str(), mode, start ? "START" : "STOP", force_update); //INFO("channel %llx [%s] mode %d %s update %d", channel_id, channel->getName().c_str(), mode, start ? "START" : "STOP", force_update);
/* FIXME until proper demux management */ /* FIXME until proper demux management */
#if ! HAVE_COOL_HARDWARE CFrontend *frontend = CFEManager::getInstance()->getFrontend(channel);
CFrontend *dfe = CFEManager::getInstance()->allocateFE(channel);
int fenum = -1;
if (dfe)
fenum = dfe->getNumber();
#endif
switch(mode) { switch(mode) {
case PLAY: case PLAY:
#if HAVE_COOL_HARDWARE #if HAVE_COOL_HARDWARE
@@ -257,18 +252,18 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
#else #else
source = cDemux::GetSource(0); source = cDemux::GetSource(0);
demux = cDemux::GetSource(0); demux = cDemux::GetSource(0);
INFO("PLAY: fe_num %d dmx_src %d", fenum, cDemux::GetSource(0)); INFO("PLAY: fe_num %d dmx_src %d", frontend ? frontend->getNumber() : -1, cDemux::GetSource(0));
#endif #endif
break; break;
case STREAM: case STREAM:
case RECORD: case RECORD:
#if HAVE_COOL_HARDWARE #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || HAVE_ARM_HARDWARE
INFO("RECORD/STREAM(%d): fe_num %d rec_dmx %d", mode, frontend ? frontend->getNumber() : -1, channel->getRecordDemux());
source = frontend->getNumber();
demux = source;
#else
source = channel->getRecordDemux(); source = channel->getRecordDemux();
demux = channel->getRecordDemux(); demux = channel->getRecordDemux();
#else
source = cDemux::GetSource(channel->getRecordDemux());
demux = source;
INFO("RECORD/STREAM(%d): fe_num %d rec_dmx %d dmx_src %d", mode, fenum, channel->getRecordDemux(), demux);
#endif #endif
break; break;
case PIP: case PIP:
@@ -290,34 +285,80 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
mode, start ? "START" : "STOP", source, oldmask, newmask, force_update, rmode); 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"); //INFO("source %d old mask %d new mask %d force update %s", source, oldmask, newmask, force_update ? "yes" : "no");
#if ! HAVE_COOL_HARDWARE
/* stop decoding if record stops unless it's the live channel. TODO:PIP? */ /* stop decoding if record stops unless it's the live channel. TODO:PIP? */
#if ! HAVE_COOL_HARDWARE
/* all the modes: RECORD, STREAM, PIP except PLAY now stopping here !! */
if (mode && start == false && source != cDemux::GetSource(0)) {
INFO("MODE not PLAY:(%d) start=false, src %d getsrc %d", mode, source, cDemux::GetSource(0));
cam->sendMessage(NULL, 0, false);
/* clean up channel_map with stopped record/stream/pip services NOT live-tv */
it = channel_map.find(channel_id);
if(it != channel_map.end() && newmask != 0)
{
delete it->second;
channel_map.erase(channel_id);
}
}
#else
if (mode == RECORD && start == false && source != cDemux::GetSource(0)) { if (mode == RECORD && start == false && source != cDemux::GetSource(0)) {
INFO("MODE!=record(%d) start=false, src %d getsrc %d", mode, source, cDemux::GetSource(0)); INFO("MODE!=record(%d) start=false, src %d getsrc %d", mode, source, cDemux::GetSource(0));
cam->sendMessage(NULL, 0, false); cam->sendMessage(NULL, 0, false);
cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_ALL); cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_ALL);
} }
#endif #endif
if((oldmask != newmask) || force_update) { if((oldmask != newmask) || force_update) {
//INFO(" ##NI: (oldmask != newmask) || force_update)");
cam->setCaMask(newmask); cam->setCaMask(newmask);
cam->setSource(source); cam->setSource(source);
if(newmask != 0 && (!filter_channels || !channel->bUseCI)) { if(newmask != 0 && (!filter_channels || !channel->bUseCI)) {
cam->makeCaPmt(channel, true); cam->makeCaPmt(channel, true);
cam->setCaPmt(true); cam->setCaPmt(true);
#if ! HAVE_COOL_HARDWARE
// CI
CaIdVector caids;
cCA::GetInstance()->GetCAIDS(caids);
uint8_t list = CCam::CAPMT_ONLY;
cam->makeCaPmt(channel, false, list, caids);
int len;
unsigned char * buffer = channel->getRawPmt(len);
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, mode, start);
#endif
} }
} }
#if ! HAVE_COOL_HARDWARE
// CI
if(oldmask == newmask) {
if (mode) {
if(start) {
CaIdVector caids;
cCA::GetInstance()->GetCAIDS(caids);
uint8_t list = CCam::CAPMT_ONLY;
cam->makeCaPmt(channel, false, list, caids);
int len;
unsigned char * buffer = channel->getRawPmt(len);
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, mode, start);
} else {
cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, mode, start);
}
}
else if (!start) {
/* condition: STREAM or RECORD and LIVE-TV are running on the same channel
* now when zap to another channel, tell the CI here that former LIVE-TV has stopped */
cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, mode, start);
}
}
#endif
if(newmask == 0) { if(newmask == 0) {
//INFO(" ##NI: (newmask == 0)");
/* FIXME: back to live channel from playback dont parse pmt and call setCaPmt /* FIXME: back to live channel from playback dont parse pmt and call setCaPmt
* (see CMD_SB_LOCK / UNLOCK PLAYBACK */ * (see CMD_SB_LOCK / UNLOCK PLAYBACK */
//channel->setRawPmt(NULL);//FIXME //channel->setRawPmt(NULL);//FIXME
#if HAVE_COOL_HARDWARE
StopCam(channel_id, cam); StopCam(channel_id, cam);
#ifdef BOXMODEL_CS_HD2 #ifdef BOXMODEL_CS_HD2
//NI - this is a hack for rezaping to the recording channel
CZapitChannel * chan = CServiceManager::getInstance()->GetCurrentChannel(); CZapitChannel * chan = CServiceManager::getInstance()->GetCurrentChannel();
//NI - this is a hack for rezaping to the recording channe
//if commig from movieplayer, disable hack //if commig from movieplayer, disable hack
if(!mp && ( (!mode || (mode && !chan->scrambled)) && (!start && rmode)) ){ if(!mp && ( (!mode || (mode && !chan->scrambled)) && (!start && rmode)) ){
INFO(" ##NI: HACK: disabling TS"); INFO(" ##NI: HACK: disabling TS");
@@ -325,83 +366,89 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
} }
mp = false; mp = false;
#endif #endif
} #else
/* don't use StopCam() here: ci-cam needs the real mode stop */
//NI cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, mode, start);
#ifdef BOXMODEL_CS_HD2 cam->sendMessage(NULL, 0, false);
// disable if option "usable CI channel while recording" set to "all channels" channel_map.erase(channel_id);
if(mode && g_settings.ci_mode != 0 /*all channels*/) { delete cam;
if(start) {
if ((tunerno >= 0 && tunerno == cDemux::GetSource(cam->getSource())) || (filter_channels && channel->bUseCI)) {
rmode = true;
//INFO(" ##NI: rmode");
}
} else
rmode = false;
}
#endif #endif
}
CaIdVector caids; #if ! HAVE_COOL_HARDWARE
cCA::GetInstance()->GetCAIDS(caids); // CI
//uint8_t list = CCam::CAPMT_FIRST; if (mode && !start) {
uint8_t list = CCam::CAPMT_ONLY; #endif
if (channel_map.size() > 1) CaIdVector caids;
list = CCam::CAPMT_ADD; 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_CS_HD2 #ifdef BOXMODEL_CS_HD2
//INFO(" ##NI: channel_map.size() %d",channel_map.size()); int ci_use_count = 0;
int ci_use_count = 0; for (it = channel_map.begin(); it != channel_map.end(); ++it)
for (it = channel_map.begin(); it != channel_map.end(); ++it) {
{ cam = it->second;
cam = it->second; channel = CServiceManager::getInstance()->FindChannel(it->first);
channel = CServiceManager::getInstance()->FindChannel(it->first);
if (tunerno >= 0 && tunerno == cDemux::GetSource(cam->getSource())) { if (tunerno >= 0 && tunerno == cDemux::GetSource(cam->getSource())) {
cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)tunerno); cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)tunerno);
ci_use_count++;
break;
} else if (filter_channels) {
if (channel && channel->bUseCI)
ci_use_count++; ci_use_count++;
} else break;
ci_use_count++; } else if (filter_channels) {
} if (channel && channel->bUseCI)
if (ci_use_count == 0) { ci_use_count++;
INFO("CI: not used for [%s], disabling TS",channel->getName().c_str()); } else
cCA::GetInstance()->SetTS(CA_DVBCI_TS_INPUT_DISABLED); ci_use_count++;
} }
if (ci_use_count == 0) {
INFO("CI: not used, disabling TS\n");
cCA::GetInstance()->SetTS(CA_DVBCI_TS_INPUT_DISABLED);
}
#endif #endif
for (it = channel_map.begin(); it != channel_map.end(); /*++it*/) for (it = channel_map.begin(); it != channel_map.end(); /*++it*/)
{ {
cam = it->second; cam = it->second;
channel = CServiceManager::getInstance()->FindChannel(it->first); channel = CServiceManager::getInstance()->FindChannel(it->first);
++it; ++it;
if(!channel) if(!channel)
continue; continue;
if(!channel->scrambled)
continue;
#if 0 #if 0
if (it == channel_map.end()) if (it == channel_map.end())
list |= CCam::CAPMT_LAST; // FIRST->ONLY or MORE->LAST list |= CCam::CAPMT_LAST; // FIRST->ONLY or MORE->LAST
#endif #endif
cam->makeCaPmt(channel, false, list, caids); cam->makeCaPmt(channel, false, list, caids);
int len; int len;
unsigned char * buffer = channel->getRawPmt(len); unsigned char * buffer = channel->getRawPmt(len);
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_SMARTCARD); #if ! HAVE_COOL_HARDWARE
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, 0, true);
#else
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_SMARTCARD);
#endif
if (tunerno >= 0 && tunerno != cDemux::GetSource(cam->getSource())) { #if HAVE_COOL_HARDWARE
INFO("CI: configured tuner %d do not match %d, skip [%s]", tunerno, cam->getSource(), channel->getName().c_str()); if (tunerno >= 0 && tunerno != cDemux::GetSource(cam->getSource())) {
} else if (filter_channels && !channel->bUseCI) { INFO("CI: configured tuner %d do not match %d, skip [%s]", tunerno, cam->getSource(), channel->getName().c_str());
INFO("CI: filter enabled, CI not used for [%s]", channel->getName().c_str()); } else if (filter_channels && !channel->bUseCI) {
} else { INFO("CI: filter enabled, CI not used for [%s]", channel->getName().c_str());
useCI = true; //NI } else {
INFO("CI: use CI for [%s]", channel->getName().c_str()); useCI = true; //NI
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI); INFO("CI: use CI for [%s]", channel->getName().c_str());
cam->sendCaPmt(channel->getChannelID(), buffer, len, CA_SLOT_TYPE_CI);
}
//list = CCam::CAPMT_MORE;
#endif
} }
//list = CCam::CAPMT_MORE; #if ! HAVE_COOL_HARDWARE
} }
#endif
return true; return true;
} }