mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 01:11:06 +02:00
scan: add cable nid param, use CFEManager to select frontend
Origin commit data
------------------
Branch: ni/coolstream
Commit: 134a1c4f78
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-01-13 (Fri, 13 Jan 2012)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <zapit/frontend_c.h>
|
#include <zapit/femanager.h>
|
||||||
#include <zapit/getservices.h>
|
#include <zapit/getservices.h>
|
||||||
#include <zapit/fastscan.h>
|
#include <zapit/fastscan.h>
|
||||||
#include "bouquets.h"
|
#include "bouquets.h"
|
||||||
@@ -45,6 +45,7 @@ class CServiceScan : public OpenThreads::Thread
|
|||||||
uint32_t found_radio_chans;
|
uint32_t found_radio_chans;
|
||||||
uint32_t found_data_chans;
|
uint32_t found_data_chans;
|
||||||
uint32_t failed_transponders;
|
uint32_t failed_transponders;
|
||||||
|
unsigned short cable_nid;
|
||||||
|
|
||||||
short curr_sat;
|
short curr_sat;
|
||||||
|
|
||||||
@@ -78,6 +79,7 @@ class CServiceScan : public OpenThreads::Thread
|
|||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
CFrontend * frontend;
|
||||||
static CServiceScan * scan;
|
static CServiceScan * scan;
|
||||||
CServiceScan();
|
CServiceScan();
|
||||||
|
|
||||||
@@ -96,8 +98,12 @@ class CServiceScan : public OpenThreads::Thread
|
|||||||
void Abort() { abort_scan = 1; };
|
void Abort() { abort_scan = 1; };
|
||||||
bool Aborted() { return abort_scan; };
|
bool Aborted() { return abort_scan; };
|
||||||
|
|
||||||
|
bool SetFrontend(t_satellite_position satellitePosition);
|
||||||
|
CFrontend * GetFrontend() { return frontend; };
|
||||||
|
|
||||||
uint32_t & FoundTransponders() { return found_transponders; };
|
uint32_t & FoundTransponders() { return found_transponders; };
|
||||||
uint32_t & FoundChannels() { return found_channels; };
|
uint32_t & FoundChannels() { return found_channels; };
|
||||||
|
void SetCableNID(unsigned short nid) { cable_nid = nid; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __scan_h__ */
|
#endif /* __scan_h__ */
|
||||||
|
@@ -26,13 +26,11 @@
|
|||||||
|
|
||||||
#include <zapit/client/zapitclient.h>
|
#include <zapit/client/zapitclient.h>
|
||||||
#include <zapit/debug.h>
|
#include <zapit/debug.h>
|
||||||
#include <zapit/getservices.h>
|
|
||||||
#include <zapit/nit.h>
|
#include <zapit/nit.h>
|
||||||
#include <zapit/scan.h>
|
#include <zapit/scan.h>
|
||||||
#include <zapit/sdt.h>
|
#include <zapit/sdt.h>
|
||||||
#include <zapit/settings.h>
|
#include <zapit/settings.h>
|
||||||
#include <zapit/satconfig.h>
|
#include <zapit/satconfig.h>
|
||||||
#include <zapit/frontend_c.h>
|
|
||||||
#include <zapit/zapit.h>
|
#include <zapit/zapit.h>
|
||||||
#include <xmlinterface.h>
|
#include <xmlinterface.h>
|
||||||
|
|
||||||
@@ -63,6 +61,8 @@ CServiceScan::CServiceScan()
|
|||||||
started = false;
|
started = false;
|
||||||
scan_nit = false;
|
scan_nit = false;
|
||||||
running = false;
|
running = false;
|
||||||
|
cable_nid = 0;
|
||||||
|
frontend = CFEManager::getInstance()->getFE(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CServiceScan::~CServiceScan()
|
CServiceScan::~CServiceScan()
|
||||||
@@ -128,8 +128,8 @@ void CServiceScan::run()
|
|||||||
|
|
||||||
bool CServiceScan::tuneFrequency(FrontendParameters *feparams, uint8_t polarization, t_satellite_position satellitePosition)
|
bool CServiceScan::tuneFrequency(FrontendParameters *feparams, uint8_t polarization, t_satellite_position satellitePosition)
|
||||||
{
|
{
|
||||||
CFrontend::getInstance()->setInput(satellitePosition, feparams->frequency, polarization);
|
frontend->setInput(satellitePosition, feparams->frequency, polarization);
|
||||||
int ret = CFrontend::getInstance()->driveToSatellitePosition(satellitePosition, false); //true);
|
int ret = frontend->driveToSatellitePosition(satellitePosition, false); //true);
|
||||||
if(ret > 0) {
|
if(ret > 0) {
|
||||||
printf("[scan] waiting %d seconds for motor to turn satellite dish.\n", ret);
|
printf("[scan] waiting %d seconds for motor to turn satellite dish.\n", ret);
|
||||||
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_PROVIDER, (void *) "moving rotor", 13);
|
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_PROVIDER, (void *) "moving rotor", 13);
|
||||||
@@ -139,7 +139,7 @@ bool CServiceScan::tuneFrequency(FrontendParameters *feparams, uint8_t polarizat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CFrontend::getInstance()->tuneFrequency(feparams, polarization, false);
|
return frontend->tuneFrequency(feparams, polarization, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CServiceScan::AddTransponder(transponder_id_t TsidOnid, FrontendParameters *feparams, uint8_t polarity, bool fromnit)
|
bool CServiceScan::AddTransponder(transponder_id_t TsidOnid, FrontendParameters *feparams, uint8_t polarity, bool fromnit)
|
||||||
@@ -256,19 +256,21 @@ _repeat:
|
|||||||
if(abort_scan)
|
if(abort_scan)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef NIT_THREAD
|
|
||||||
pthread_t nthread;
|
|
||||||
if(scan_nit)
|
|
||||||
if(pthread_create(&nthread, 0, nit_thread, (void*)satellitePosition)) {
|
|
||||||
ERROR("pthread_create");
|
|
||||||
nthread = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
freq_id_t freq;
|
freq_id_t freq;
|
||||||
if(cable)
|
if(cable)
|
||||||
freq = tI->second.feparams.frequency/100;
|
freq = tI->second.feparams.frequency/100;
|
||||||
else
|
else
|
||||||
freq = tI->second.feparams.frequency/1000;
|
freq = tI->second.feparams.frequency/1000;
|
||||||
|
|
||||||
|
#ifdef NIT_THREAD
|
||||||
|
pthread_t nthread;
|
||||||
|
nit_thread_args_t threadArgs(satellitePosition, freq, cable_nid);
|
||||||
|
if(scan_nit)
|
||||||
|
if(pthread_create(&nthread, 0, nit_thread, (void*)&threadArgs)) {
|
||||||
|
ERROR("pthread_create");
|
||||||
|
nthread = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//INFO("parsing SDT (tsid:onid %04x:%04x)", tI->second.transport_stream_id, tI->second.original_network_id);
|
//INFO("parsing SDT (tsid:onid %04x:%04x)", tI->second.transport_stream_id, tI->second.original_network_id);
|
||||||
int status = parse_sdt(&tI->second.transport_stream_id, &tI->second.original_network_id, satellitePosition, freq /*tI->second.feparams.frequency/1000*/);
|
int status = parse_sdt(&tI->second.transport_stream_id, &tI->second.original_network_id, satellitePosition, freq /*tI->second.feparams.frequency/1000*/);
|
||||||
if(status < 0) {
|
if(status < 0) {
|
||||||
@@ -361,7 +363,7 @@ bool CServiceScan::AddTransponder(xmlNodePtr transponder, uint8_t diseqc_pos, t_
|
|||||||
feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(transponder, "modulation", 0);
|
feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(transponder, "modulation", 0);
|
||||||
diseqc_pos = 0;
|
diseqc_pos = 0;
|
||||||
}
|
}
|
||||||
else if (CFrontend::getInstance()->getInfo()->type == FE_QPSK) {
|
else if (frontend->getInfo()->type == FE_QPSK) {
|
||||||
feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(transponder, "symbol_rate", 0);
|
feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(transponder, "symbol_rate", 0);
|
||||||
polarization = xmlGetNumericAttribute(transponder, "polarization", 0);
|
polarization = xmlGetNumericAttribute(transponder, "polarization", 0);
|
||||||
system = xmlGetNumericAttribute(transponder, "system", 0);
|
system = xmlGetNumericAttribute(transponder, "system", 0);
|
||||||
@@ -411,14 +413,10 @@ bool CServiceScan::ScanProvider(xmlNodePtr search, t_satellite_position satellit
|
|||||||
processed_transponders = 0;
|
processed_transponders = 0;
|
||||||
|
|
||||||
TIMER_START();
|
TIMER_START();
|
||||||
sat_iterator_t sit = satellitePositions.find(satellitePosition);
|
std::string satname = CServiceManager::getInstance()->GetSatelliteName(satellitePosition);
|
||||||
if(sit == satellitePositions.end()) {
|
|
||||||
printf("[zapit] WARNING satellite position %d not found!\n", satellitePosition);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_REPORT_NUM_SCANNED_TRANSPONDERS, &processed_transponders, sizeof(processed_transponders));
|
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_REPORT_NUM_SCANNED_TRANSPONDERS, &processed_transponders, sizeof(processed_transponders));
|
||||||
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_SATELLITE, sit->second.name.c_str(), sit->second.name.size() + 1);
|
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_SATELLITE, satname.c_str(), satname.size() + 1);
|
||||||
tps = search->xmlChildrenNode;
|
tps = search->xmlChildrenNode;
|
||||||
/* TPs from current service list */
|
/* TPs from current service list */
|
||||||
for(tI = transponders.begin(); tI != transponders.end(); tI++) {
|
for(tI = transponders.begin(); tI != transponders.end(); tI++) {
|
||||||
@@ -470,6 +468,19 @@ void CServiceScan::Cleanup(const bool success)
|
|||||||
service_types.clear();
|
service_types.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CServiceScan::SetFrontend(t_satellite_position satellitePosition)
|
||||||
|
{
|
||||||
|
CFrontend * fe = CFEManager::getInstance()->getScanFrontend(satellitePosition);
|
||||||
|
if(fe == NULL) {
|
||||||
|
INFO("No frontend found for satellite %d\n", satellitePosition);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
frontend = fe;
|
||||||
|
CFEManager::getInstance()->setLiveFE(frontend);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CServiceScan::ScanProviders()
|
bool CServiceScan::ScanProviders()
|
||||||
{
|
{
|
||||||
scan_list_iterator_t spI;
|
scan_list_iterator_t spI;
|
||||||
@@ -482,7 +493,7 @@ bool CServiceScan::ScanProviders()
|
|||||||
|
|
||||||
curr_sat = 0;
|
curr_sat = 0;
|
||||||
|
|
||||||
cable = (CFrontend::getInstance()->getInfo()->type == FE_QAM);
|
cable = (frontend->getInfo()->type == FE_QAM);//FIXME
|
||||||
if (cable)
|
if (cable)
|
||||||
frontendType = "cable";
|
frontendType = "cable";
|
||||||
else
|
else
|
||||||
@@ -492,7 +503,7 @@ bool CServiceScan::ScanProviders()
|
|||||||
int scan_sat_mode = mode & 0xFF00; // single = 0, all = 1
|
int scan_sat_mode = mode & 0xFF00; // single = 0, all = 1
|
||||||
|
|
||||||
printf("[zapit] scan mode %s, satellites %s\n", scan_nit ? "NIT" : "fast", scan_sat_mode ? "all" : "single");
|
printf("[zapit] scan mode %s, satellites %s\n", scan_nit ? "NIT" : "fast", scan_sat_mode ? "all" : "single");
|
||||||
// CZapitClient myZapitClient;
|
CZapitClient myZapitClient;
|
||||||
|
|
||||||
/* get first child */
|
/* get first child */
|
||||||
//xmlNodePtr search = xmlDocGetRootElement(scanInputParser)->xmlChildrenNode;
|
//xmlNodePtr search = xmlDocGetRootElement(scanInputParser)->xmlChildrenNode;
|
||||||
@@ -518,6 +529,8 @@ bool CServiceScan::ScanProviders()
|
|||||||
|
|
||||||
/* provider is not wanted - jump to the next one */
|
/* provider is not wanted - jump to the next one */
|
||||||
if (spI != scanProviders.end()) {
|
if (spI != scanProviders.end()) {
|
||||||
|
if(!SetFrontend(position))
|
||||||
|
break;
|
||||||
/* get name of current satellite oder cable provider */
|
/* get name of current satellite oder cable provider */
|
||||||
strcpy(providerName, xmlGetAttribute(search, "name"));
|
strcpy(providerName, xmlGetAttribute(search, "name"));
|
||||||
|
|
||||||
@@ -562,24 +575,10 @@ bool CServiceScan::ScanProviders()
|
|||||||
g_bouquetManager->loadBouquets();
|
g_bouquetManager->loadBouquets();
|
||||||
printf("[scan] save bouquets done\n");
|
printf("[scan] save bouquets done\n");
|
||||||
Cleanup(true);
|
Cleanup(true);
|
||||||
#if 1
|
|
||||||
CZapitClient myZapitClient;
|
|
||||||
myZapitClient.reloadCurrentServices();
|
myZapitClient.reloadCurrentServices();
|
||||||
#else
|
|
||||||
/* this can hang as the thread handling the connections
|
|
||||||
* could already be in g_Zapit->stopScan(), waiting for
|
|
||||||
* *this* thread to join().
|
|
||||||
myZapitClient.reloadCurrentServices();
|
|
||||||
* so let's do another ugly, layer-violating hack...
|
|
||||||
*/
|
|
||||||
CFrontend::getInstance()->setTsidOnid(0);
|
|
||||||
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
|
||||||
CZapit::getInstance()->ZapIt(live_channel_id, false);
|
|
||||||
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SERVICES_CHANGED);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
Cleanup(false);
|
Cleanup(false);
|
||||||
CFrontend::getInstance()->setTsidOnid(0);
|
frontend->setTsidOnid(0);
|
||||||
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
||||||
CZapit::getInstance()->ZapIt(live_channel_id, false);
|
CZapit::getInstance()->ZapIt(live_channel_id, false);
|
||||||
}
|
}
|
||||||
@@ -593,13 +592,18 @@ bool CServiceScan::ScanTransponder()
|
|||||||
char providerName[32] = "";
|
char providerName[32] = "";
|
||||||
t_satellite_position satellitePosition = 0;
|
t_satellite_position satellitePosition = 0;
|
||||||
|
|
||||||
|
satellitePosition = scanProviders.begin()->first;
|
||||||
|
if(!SetFrontend(satellitePosition)) {
|
||||||
|
Cleanup(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
scanBouquetManager = new CBouquetManager();
|
scanBouquetManager = new CBouquetManager();
|
||||||
|
|
||||||
cable = (CFrontend::getInstance()->getInfo()->type == FE_QAM);
|
cable = (frontend->getInfo()->type == FE_QAM);//FIXME
|
||||||
|
|
||||||
strcpy(providerName, scanProviders.size() > 0 ? scanProviders.begin()->second.c_str() : "unknown provider");
|
strcpy(providerName, scanProviders.size() > 0 ? scanProviders.begin()->second.c_str() : "unknown provider");
|
||||||
|
|
||||||
satellitePosition = scanProviders.begin()->first;
|
|
||||||
printf("[scan_transponder] scanning sat %s position %d\n", providerName, satellitePosition);
|
printf("[scan_transponder] scanning sat %s position %d\n", providerName, satellitePosition);
|
||||||
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_SATELLITE, providerName, strlen(providerName) + 1);
|
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_SATELLITE, providerName, strlen(providerName) + 1);
|
||||||
|
|
||||||
@@ -628,7 +632,7 @@ bool CServiceScan::ScanTransponder()
|
|||||||
if(abort_scan)
|
if(abort_scan)
|
||||||
found_channels = 0;
|
found_channels = 0;
|
||||||
|
|
||||||
// CZapitClient myZapitClient;
|
CZapitClient myZapitClient;
|
||||||
//FIXME move to Cleanup() ?
|
//FIXME move to Cleanup() ?
|
||||||
if(found_channels) {
|
if(found_channels) {
|
||||||
CServiceManager::getInstance()->SaveServices(true);
|
CServiceManager::getInstance()->SaveServices(true);
|
||||||
@@ -639,21 +643,10 @@ bool CServiceScan::ScanTransponder()
|
|||||||
//g_bouquetManager->clearAll();
|
//g_bouquetManager->clearAll();
|
||||||
g_bouquetManager->loadBouquets();
|
g_bouquetManager->loadBouquets();
|
||||||
Cleanup(true);
|
Cleanup(true);
|
||||||
#if 1
|
|
||||||
CZapitClient myZapitClient;
|
|
||||||
myZapitClient.reloadCurrentServices();
|
myZapitClient.reloadCurrentServices();
|
||||||
#else
|
|
||||||
/* see the explanation in CServiceScan::ScanProviders() in why this is a bad idea
|
|
||||||
myZapitClient.reloadCurrentServices();
|
|
||||||
*/
|
|
||||||
CFrontend::getInstance()->setTsidOnid(0);
|
|
||||||
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
|
||||||
CZapit::getInstance()->ZapIt(live_channel_id, false);
|
|
||||||
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SERVICES_CHANGED);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
Cleanup(false);
|
Cleanup(false);
|
||||||
CFrontend::getInstance()->setTsidOnid(0);
|
frontend->setTsidOnid(0);
|
||||||
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
||||||
CZapit::getInstance()->ZapIt(live_channel_id, false);
|
CZapit::getInstance()->ZapIt(live_channel_id, false);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user