zapit/include/zapit/getservices.h:

extend transponder struct;
add map to store satellite transponders per satellite;
add GetSatelliteTransponders(), remove global select_transponders


Origin commit data
------------------
Branch: ni/coolstream
Commit: 778733fc75
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-04-13 (Fri, 13 Apr 2012)



------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2012-04-13 17:59:53 +04:00
parent c63dddcaf6
commit 2b4520157a
2 changed files with 52 additions and 31 deletions

View File

@@ -35,7 +35,6 @@
#include <map> #include <map>
#include <list> #include <list>
#define zapped_chan_is_nvod 0x80
struct transponder struct transponder
{ {
@@ -47,16 +46,8 @@ struct transponder
struct dvb_frontend_parameters feparams; struct dvb_frontend_parameters feparams;
unsigned char polarization; unsigned char polarization;
bool updated; bool updated;
#if 0 bool failed;
transponder(const t_transport_stream_id p_transport_stream_id, const t_original_network_id p_original_network_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization = 0)
{
transport_stream_id = p_transport_stream_id;
original_network_id = p_original_network_id;
feparams = p_feparams;
polarization = p_polarization;
updated = 0;
}
#endif
transponder(const transponder_id_t t_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization = 0) transponder(const transponder_id_t t_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization = 0)
{ {
transponder_id = t_id; transponder_id = t_id;
@@ -65,19 +56,43 @@ struct transponder
feparams = p_feparams; feparams = p_feparams;
polarization = p_polarization; polarization = p_polarization;
updated = 0; updated = 0;
failed = 0;
satellitePosition = GET_SATELLITEPOSITION_FROM_TRANSPONDER_ID(transponder_id); satellitePosition = GET_SATELLITEPOSITION_FROM_TRANSPONDER_ID(transponder_id);
if(satellitePosition & 0xF000) if(satellitePosition & 0xF000)
satellitePosition = -(satellitePosition & 0xFFF); satellitePosition = -(satellitePosition & 0xFFF);
else else
satellitePosition = satellitePosition & 0xFFF; satellitePosition = satellitePosition & 0xFFF;
}
bool operator==(const transponder& t) const {
return (
(satellitePosition == t.satellitePosition) &&
//(transport_stream_id == t.transport_stream_id) &&
//(original_network_id == t.original_network_id) &&
((polarization & 1) == (t.polarization & 1)) &&
(abs((int) feparams.frequency - (int)t.feparams.frequency) <= 3000)
);
}
void dump(std::string label = "tp", bool cable = 0) {
if(cable)
printf("%s: tp-id %016llx freq %d rate %d fec %d mod %d\n", label.c_str(),
transponder_id, feparams.frequency, feparams.u.qam.symbol_rate,
feparams.u.qam.fec_inner, feparams.u.qam.modulation);
else
printf("%s: tp-id %016llx freq %d rate %d fec %d pol %d\n", label.c_str(),
transponder_id, feparams.frequency, feparams.u.qpsk.symbol_rate,
feparams.u.qpsk.fec_inner, polarization);
} }
}; };
typedef std::map <transponder_id_t, transponder> transponder_list_t; typedef std::map <transponder_id_t, transponder> transponder_list_t;
typedef std::map <transponder_id_t, transponder>::iterator stiterator; typedef std::map <transponder_id_t, transponder>::iterator stiterator;
extern transponder_list_t scantransponders; typedef std::pair<transponder_id_t, transponder> transponder_pair_t;
extern transponder_list_t transponders; extern transponder_list_t transponders;
typedef std::map <t_satellite_position, transponder_list_t> sat_transponder_map_t;
typedef map<t_channel_id, CZapitChannel> channel_map_t; typedef map<t_channel_id, CZapitChannel> channel_map_t;
typedef channel_map_t::iterator channel_map_iterator_t; typedef channel_map_t::iterator channel_map_iterator_t;
typedef std::pair<t_channel_id, CZapitChannel> channel_pair_t; typedef std::pair<t_channel_id, CZapitChannel> channel_pair_t;
@@ -122,6 +137,7 @@ class CServiceManager
fe_type_t frontendType; fe_type_t frontendType;
satellite_map_t satellitePositions; satellite_map_t satellitePositions;
sat_transponder_map_t satelliteTransponders;
bool ParseScanXml(); bool ParseScanXml();
void ParseTransponders(xmlNodePtr node, t_satellite_position satellitePosition, bool cable); void ParseTransponders(xmlNodePtr node, t_satellite_position satellitePosition, bool cable);
@@ -169,8 +185,8 @@ class CServiceManager
std::string GetServiceName(t_channel_id channel_id); std::string GetServiceName(t_channel_id channel_id);
tallchans* GetAllChannels(){ return &allchans; }; tallchans* GetAllChannels(){ return &allchans; };
bool GetAllRadioChannels(ZapitChannelList &list); bool GetAllRadioChannels(ZapitChannelList &list, int flags = 0);
bool GetAllTvChannels(ZapitChannelList &list); bool GetAllTvChannels(ZapitChannelList &list, int flags = 0);
bool GetAllHDChannels(ZapitChannelList &list); bool GetAllHDChannels(ZapitChannelList &list);
bool GetAllSatelliteChannels(ZapitChannelList &list, t_satellite_position position); bool GetAllSatelliteChannels(ZapitChannelList &list, t_satellite_position position);
bool GetAllTransponderChannels(ZapitChannelList &list, transponder_id_t tpid); bool GetAllTransponderChannels(ZapitChannelList &list, transponder_id_t tpid);
@@ -201,5 +217,8 @@ class CServiceManager
void FreeNumber(int number, bool radio); void FreeNumber(int number, bool radio);
void UseNumber(int number, bool radio); void UseNumber(int number, bool radio);
void SetServicesChanged(bool changed) { services_changed = changed; } void SetServicesChanged(bool changed) { services_changed = changed; }
bool GetTransponder(struct transponder &t);
transponder_list_t & GetSatelliteTransponders(t_satellite_position position) { return satelliteTransponders[position]; }
}; };
#endif /* __getservices_h__ */ #endif /* __getservices_h__ */

View File

@@ -32,7 +32,6 @@
//#define SAVE_DEBUG //#define SAVE_DEBUG
extern transponder_list_t transponders; extern transponder_list_t transponders;
std::map<transponder_id_t, transponder> select_transponders;
CServiceManager * CServiceManager::manager = NULL; CServiceManager * CServiceManager::manager = NULL;
@@ -113,6 +112,7 @@ bool CServiceManager::AddNVODChannel(CZapitChannel * &channel)
t_transport_stream_id transport_stream_id = channel->getTransportStreamId(); t_transport_stream_id transport_stream_id = channel->getTransportStreamId();
t_satellite_position satellitePosition = channel->getSatellitePosition(); t_satellite_position satellitePosition = channel->getSatellitePosition();
//FIXME define CREATE_NVOD_CHANNEL_ID
t_channel_id sub_channel_id = t_channel_id sub_channel_id =
((uint64_t) ( satellitePosition >= 0 ? satellitePosition : (uint64_t)(0xF000+ abs(satellitePosition))) << 48) | ((uint64_t) ( satellitePosition >= 0 ? satellitePosition : (uint64_t)(0xF000+ abs(satellitePosition))) << 48) |
(uint64_t) CREATE_CHANNEL_ID(service_id, original_network_id, transport_stream_id); (uint64_t) CREATE_CHANNEL_ID(service_id, original_network_id, transport_stream_id);
@@ -458,6 +458,7 @@ void CServiceManager::ParseSatTransponders(fe_type_t fType, xmlNodePtr search, t
FrontendParameters feparams; FrontendParameters feparams;
fake_tid = fake_nid = 0; fake_tid = fake_nid = 0;
satelliteTransponders[satellitePosition].clear();
xmlNodePtr tps = search->xmlChildrenNode; xmlNodePtr tps = search->xmlChildrenNode;
@@ -465,9 +466,6 @@ void CServiceManager::ParseSatTransponders(fe_type_t fType, xmlNodePtr search, t
memset(&feparams, 0x00, sizeof(FrontendParameters)); memset(&feparams, 0x00, sizeof(FrontendParameters));
feparams.frequency = xmlGetNumericAttribute(tps, "frequency", 0); feparams.frequency = xmlGetNumericAttribute(tps, "frequency", 0);
freq_id_t freq = 0;
feparams.inversion = INVERSION_AUTO; feparams.inversion = INVERSION_AUTO;
if (fType == FE_QAM) { if (fType == FE_QAM) {
@@ -476,8 +474,6 @@ void CServiceManager::ParseSatTransponders(fe_type_t fType, xmlNodePtr search, t
feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(tps, "modulation", 0); feparams.u.qam.modulation = (fe_modulation_t) xmlGetNumericAttribute(tps, "modulation", 0);
if (feparams.frequency > 1000*1000) if (feparams.frequency > 1000*1000)
feparams.frequency=feparams.frequency/1000; //transponderlist was read from tuxbox feparams.frequency=feparams.frequency/1000; //transponderlist was read from tuxbox
//feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000);
freq = feparams.frequency/100;
} }
else if (fType == FE_QPSK) { else if (fType == FE_QPSK) {
feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(tps, "symbol_rate", 0); feparams.u.qpsk.symbol_rate = xmlGetNumericAttribute(tps, "symbol_rate", 0);
@@ -490,18 +486,14 @@ void CServiceManager::ParseSatTransponders(fe_type_t fType, xmlNodePtr search, t
xml_fec += 9; xml_fec += 9;
feparams.u.qpsk.fec_inner = (fe_code_rate_t) xml_fec; feparams.u.qpsk.fec_inner = (fe_code_rate_t) xml_fec;
feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000); feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000);
freq = feparams.frequency/1000;
} }
freq_id_t freq = CREATE_FREQ_ID(feparams.frequency, fType == FE_QAM);
transponder_id_t tid =
CREATE_TRANSPONDER_ID64(
freq /*feparams.frequency/1000*/, satellitePosition, fake_nid, fake_tid);
polarization &= 1; polarization &= 1;
select_transponders.insert (
std::pair <transponder_id_t, transponder> (tid, transponder_id_t tid = CREATE_TRANSPONDER_ID64(freq, satellitePosition, fake_nid, fake_tid);
transponder (tid, feparams, polarization)) transponder t(tid, feparams, polarization);
); satelliteTransponders[satellitePosition].insert(transponder_pair_t(tid, t));
fake_nid ++; fake_tid ++; fake_nid ++; fake_tid ++;
tps = tps->xmlNextNode; tps = tps->xmlNextNode;
@@ -606,7 +598,6 @@ bool CServiceManager::LoadServices(bool only_current)
TIMER_START(); TIMER_START();
allchans.clear(); allchans.clear();
transponders.clear(); transponders.clear();
select_transponders.clear();
tv_numbers.clear(); tv_numbers.clear();
radio_numbers.clear(); radio_numbers.clear();
have_numbers = false; have_numbers = false;
@@ -1091,3 +1082,14 @@ void CServiceManager::UseNumber(int number, bool radio)
service_number_map_t * channel_numbers = radio ? &radio_numbers : &tv_numbers; service_number_map_t * channel_numbers = radio ? &radio_numbers : &tv_numbers;
channel_numbers->insert(number); channel_numbers->insert(number);
} }
bool CServiceManager::GetTransponder(struct transponder &t)
{
for (transponder_list_t::iterator tI = transponders.begin(); tI != transponders.end(); tI++) {
if (t == tI->second) {
t = tI->second;
return true;
}
}
return false;
}