mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
add experimental support to scan epg in background using different tuner,
when enabled in menu - activated by next channel switch, scanning epg for channels (transponders) in current bouquet (channels list)
This commit is contained in:
@@ -32,6 +32,7 @@ libneutrino_driver_a_SOURCES = \
|
|||||||
rcinput.cpp \
|
rcinput.cpp \
|
||||||
record.cpp \
|
record.cpp \
|
||||||
ringbuffer.c \
|
ringbuffer.c \
|
||||||
|
scanepg.cpp \
|
||||||
screen_max.cpp \
|
screen_max.cpp \
|
||||||
screenshot.cpp \
|
screenshot.cpp \
|
||||||
shutdown_count.cpp \
|
shutdown_count.cpp \
|
||||||
|
135
src/driver/scanepg.cpp
Normal file
135
src/driver/scanepg.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2013 CoolStream International Ltd
|
||||||
|
|
||||||
|
License: GPLv2
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation;
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <global.h>
|
||||||
|
#include <neutrino.h>
|
||||||
|
|
||||||
|
#include <system/helpers.h>
|
||||||
|
#include <system/setting_helpers.h>
|
||||||
|
#include <daemonc/remotecontrol.h>
|
||||||
|
|
||||||
|
#include <zapit/zapit.h>
|
||||||
|
#include <zapit/debug.h>
|
||||||
|
#include <eitd/sectionsd.h>
|
||||||
|
|
||||||
|
#include <gui/bouquetlist.h>
|
||||||
|
#include <gui/channellist.h>
|
||||||
|
|
||||||
|
#include <driver/scanepg.h>
|
||||||
|
|
||||||
|
extern CBouquetList * bouquetList;
|
||||||
|
|
||||||
|
CEpgScan::CEpgScan()
|
||||||
|
{
|
||||||
|
current_bnum = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CEpgScan::~CEpgScan()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CEpgScan * CEpgScan::getInstance()
|
||||||
|
{
|
||||||
|
static CEpgScan * inst;
|
||||||
|
if (inst == NULL)
|
||||||
|
inst = new CEpgScan();
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEpgScan::Clear()
|
||||||
|
{
|
||||||
|
scanmap.clear();
|
||||||
|
current_bnum = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
|
||||||
|
{
|
||||||
|
if (!g_settings.epg_scan || CFEManager::getInstance()->getEnabledCount() <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) {
|
||||||
|
if(bouquetList->Bouquets.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (current_bnum != bouquetList->getActiveBouquetNumber()) {
|
||||||
|
scanmap.clear();
|
||||||
|
current_bnum = bouquetList->getActiveBouquetNumber();
|
||||||
|
CChannelList * clist = bouquetList->Bouquets[current_bnum]->channelList;
|
||||||
|
int lsize = clist->Size();
|
||||||
|
for (int i = 0; i < lsize; i++) {
|
||||||
|
CZapitChannel * chan = clist->getChannelFromIndex(i);
|
||||||
|
/* TODO: add interval check to clear scanned ? */
|
||||||
|
if (scanned.find(chan->getTransponderId()) == scanned.end())
|
||||||
|
scanmap.insert(eit_scanmap_pair_t(chan->getTransponderId(), chan->getChannelID()));
|
||||||
|
}
|
||||||
|
INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) {
|
||||||
|
t_channel_id chid = *(t_channel_id *)data;
|
||||||
|
CZapitChannel * 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());
|
||||||
|
|
||||||
|
if (scanmap.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
||||||
|
|
||||||
|
CFrontend *live_fe = CZapit::getInstance()->GetLiveFrontend();
|
||||||
|
CFEManager::getInstance()->lockFrontend(live_fe);
|
||||||
|
#ifdef ENABLE_PIP
|
||||||
|
CFrontend *pip_fe = CZapit::getInstance()->GetPipFrontend();
|
||||||
|
if (pip_fe && pip_fe != live_fe)
|
||||||
|
CFEManager::getInstance()->lockFrontend(pip_fe);
|
||||||
|
#endif
|
||||||
|
for (eit_scanmap_iterator_t it = scanmap.begin(); it != scanmap.end(); /* ++it*/) {
|
||||||
|
CZapitChannel * newchan = CServiceManager::getInstance()->FindChannel(it->second);
|
||||||
|
if ((newchan == NULL) || SAME_TRANSPONDER(live_channel_id, newchan->getChannelID())) {
|
||||||
|
scanmap.erase(it++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (CFEManager::getInstance()->canTune(newchan)) {
|
||||||
|
INFO("try to scan [%s]", newchan->getName().c_str());
|
||||||
|
bool ret = g_Zapit->zapTo_record(newchan->getChannelID()) > 0;
|
||||||
|
if (ret) {
|
||||||
|
g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux());
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
scanmap.erase(it++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
INFO("skip [%s], cannot tune", newchan->getName().c_str());
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
CFEManager::getInstance()->unlockFrontend(live_fe);
|
||||||
|
#ifdef ENABLE_PIP
|
||||||
|
if (pip_fe && pip_fe != live_fe)
|
||||||
|
CFEManager::getInstance()->unlockFrontend(pip_fe);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
45
src/driver/scanepg.h
Normal file
45
src/driver/scanepg.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2013 CoolStream International Ltd
|
||||||
|
|
||||||
|
License: GPLv2
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation;
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SCAN_EPG__
|
||||||
|
#define __SCAN_EPG__
|
||||||
|
|
||||||
|
#include <zapit/zapit.h>
|
||||||
|
|
||||||
|
typedef std::map<transponder_id_t, t_channel_id> eit_scanmap_t;
|
||||||
|
typedef std::pair<transponder_id_t, t_channel_id> eit_scanmap_pair_t;
|
||||||
|
typedef eit_scanmap_t::iterator eit_scanmap_iterator_t;
|
||||||
|
|
||||||
|
class CEpgScan
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int current_bnum;
|
||||||
|
eit_scanmap_t scanmap;
|
||||||
|
std::set<transponder_id_t> scanned;
|
||||||
|
|
||||||
|
CEpgScan();
|
||||||
|
public:
|
||||||
|
~CEpgScan();
|
||||||
|
static CEpgScan * getInstance();
|
||||||
|
|
||||||
|
void handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data);
|
||||||
|
void Clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user