Skip to content

Commit

Permalink
fix Web-If / VLC (thx DboxOldie)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxWiesel committed Feb 24, 2016
1 parent c3a65ac commit 164d6ef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
23 changes: 16 additions & 7 deletions src/driver/streamts.cpp
Expand Up @@ -80,6 +80,7 @@ CStreamInstance::CStreamInstance(int clientfd, t_channel_id chid, stream_pids_t
running = false;
dmx = NULL;
buf = NULL;
frontend = NULL;
}

CStreamInstance::~CStreamInstance()
Expand Down Expand Up @@ -195,22 +196,26 @@ void CStreamInstance::run()
CCamManager::getInstance()->Start(channel_id, CCamManager::STREAM);

#if HAVE_DUCKBOX_HARDWARE || HAVE_SPARK_HARDWARE
CFrontend *fe = CFEManager::getInstance()->allocateFE(CServiceManager::getInstance()->FindChannel(channel_id), true);
CFEManager::getInstance()->lockFrontend(fe);
CZapit::getInstance()->SetRecordMode(true);
CFrontend *live_fe = CZapit::getInstance()->GetLiveFrontend();
if(live_fe)
CFEManager::getInstance()->unlockFrontend(live_fe);
if(frontend)
CFEManager::getInstance()->lockFrontend(frontend);
//CZapit::getInstance()->SetRecordMode(true);
#endif
while (running) {
ssize_t r = dmx->Read(buf, IN_SIZE, 100);
if (r > 0)
Send(r);
}

CCamManager::getInstance()->Stop(channel_id, CCamManager::STREAM);

#if HAVE_DUCKBOX_HARDWARE || HAVE_SPARK_HARDWARE
CFEManager::getInstance()->unlockFrontend(fe);
CZapit::getInstance()->SetRecordMode(false);
if(frontend)
CFEManager::getInstance()->unlockFrontend(frontend);
//CZapit::getInstance()->SetRecordMode(false);
#endif
CCamManager::getInstance()->Stop(channel_id, CCamManager::STREAM);

printf("CStreamInstance::run: exiting %" PRIx64 " (%d fds)\n", channel_id, (int)fds.size());

Close();
Expand Down Expand Up @@ -356,7 +361,11 @@ CFrontend * CStreamManager::FindFrontend(CZapitChannel * channel)
for (std::set<CFrontend*>::iterator ft = frontends.begin(); ft != frontends.end(); ++ft)
CFEManager::getInstance()->unlockFrontend(*ft);

#if HAVE_DUCKBOX_HARDWARE || HAVE_SPARK_HARDWARE
if (unlock && !frontend)
#else
if (unlock)
#endif
CFEManager::getInstance()->unlockFrontend(live_fe);

CFEManager::getInstance()->Unlock();
Expand Down
30 changes: 21 additions & 9 deletions src/zapit/src/capmt.cpp
Expand Up @@ -228,7 +228,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);

/* FIXME until proper demux management */
CFrontend *frontend = NULL;
CFrontend *frontend = CFEManager::getInstance()->getFrontend(channel);
switch(mode) {
case PLAY:
#if HAVE_COOL_HARDWARE
Expand All @@ -237,19 +237,19 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
#else
source = cDemux::GetSource(0);
demux = cDemux::GetSource(0);
frontend = CFEManager::getInstance()->getFrontend(channel);
INFO("PLAY: fe_num %d dmx_src %d", frontend ? frontend->getNumber() : -1, cDemux::GetSource(0));
#endif
break;
case STREAM:
case RECORD:
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
channel->setRecordDemux(CFEManager::getInstance()->allocateFE(channel)->getNumber());
#endif
frontend = CFEManager::getInstance()->getFrontend(channel);
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();
demux = channel->getRecordDemux();
#endif
break;
case PIP:
source = channel->getRecordDemux();
Expand All @@ -272,10 +272,17 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
//INFO("source %d old mask %d new mask %d force update %s", source, oldmask, newmask, force_update ? "yes" : "no");

/* stop decoding if record stops unless it's the live channel. TODO:PIP? */
if (mode == RECORD && start == false && source != cDemux::GetSource(0)) {
INFO("MODE!=record(%d) start=false, src %d getsrc %d", mode, source, cDemux::GetSource(0));
/* 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);
cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_ALL, channel->scrambled, channel->camap, mode, start);
/* 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);
}
}

if((oldmask != newmask) || force_update) {
Expand Down Expand Up @@ -313,7 +320,12 @@ bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start
/* FIXME: back to live channel from playback dont parse pmt and call setCaPmt
* (see CMD_SB_LOCK / UNLOCK PLAYBACK */
//channel->setRawPmt(NULL);//FIXME
StopCam(channel_id, cam);
//StopCam(channel_id, cam);
/* don't use StopCam() here: ci-cam needs the real mode stop */
cam->sendCaPmt(channel->getChannelID(), NULL, 0, CA_SLOT_TYPE_CI, channel->scrambled, channel->camap, mode, start);
cam->sendMessage(NULL, 0, false);
channel_map.erase(channel_id);
delete cam;
}

// CI
Expand Down

0 comments on commit 164d6ef

Please sign in to comment.