zapit/src/transponder.cpp: add transponder type, compare and dumpServiceXml members

Origin commit data
------------------
Commit: 8e87ec6264
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-04-15 (Sun, 15 Apr 2012)
This commit is contained in:
[CST] Focus
2012-04-15 15:25:55 +04:00
parent 8a24f69deb
commit c768d5d364
2 changed files with 52 additions and 7 deletions

View File

@@ -33,16 +33,19 @@ public:
t_original_network_id original_network_id;
transponder_id_t transponder_id;
t_satellite_position satellitePosition;
uint8_t type;
struct dvb_frontend_parameters feparams;
unsigned char polarization;
bool updated;
bool scanned;
transponder(const transponder_id_t t_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization = 0);
transponder(fe_type_t fType, const transponder_id_t t_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization = 0);
bool operator==(const transponder& t) const;
void dump(std::string label = "tp", bool cable = 0);
bool compare (const transponder& t) const;
void dump(std::string label = "tp");
void dumpServiceXml(FILE * fd);
};
typedef std::map <transponder_id_t, transponder> transponder_list_t;

View File

@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <zapit/transponder.h>
transponder::transponder(const transponder_id_t t_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization)
transponder::transponder(fe_type_t fType, const transponder_id_t t_id, const struct dvb_frontend_parameters p_feparams, const uint8_t p_polarization)
{
transponder_id = t_id;
transport_stream_id = GET_TRANSPORT_STREAM_ID_FROM_TRANSPONDER_ID(t_id);
@@ -35,6 +35,7 @@ transponder::transponder(const transponder_id_t t_id, const struct dvb_frontend_
satellitePosition = -(satellitePosition & 0xFFF);
else
satellitePosition = satellitePosition & 0xFFF;
type = fType;
}
bool transponder::operator==(const transponder& t) const
@@ -48,14 +49,55 @@ bool transponder::operator==(const transponder& t) const
);
}
void transponder::dump(std::string label, bool cable)
bool transponder::compare(const transponder& t) const
{
if(cable)
printf("%s: tp-id %016llx freq %d rate %d fec %d mod %d\n", label.c_str(),
bool ret = false;
if(type == FE_QAM) {
ret = (
(t == (*this)) &&
(feparams.u.qam.symbol_rate == t.feparams.u.qam.symbol_rate) &&
(feparams.u.qam.fec_inner == t.feparams.u.qam.fec_inner ||
feparams.u.qam.fec_inner == FEC_AUTO || t.feparams.u.qam.fec_inner == FEC_AUTO) &&
(feparams.u.qam.modulation == t.feparams.u.qam.modulation ||
feparams.u.qam.modulation == QAM_AUTO || t.feparams.u.qam.modulation == QAM_AUTO)
);
} else {
ret = (
(t == (*this)) &&
(feparams.u.qpsk.symbol_rate == t.feparams.u.qpsk.symbol_rate) &&
(feparams.u.qpsk.fec_inner == t.feparams.u.qpsk.fec_inner ||
feparams.u.qpsk.fec_inner == FEC_AUTO || t.feparams.u.qpsk.fec_inner == FEC_AUTO)
);
}
return ret;
}
void transponder::dumpServiceXml(FILE * fd)
{
if(type == FE_QAM) {
fprintf(fd, "\t\t<TS id=\"%04x\" on=\"%04x\" frq=\"%u\" inv=\"%hu\" sr=\"%u\" fec=\"%hu\" mod=\"%hu\">\n",
transport_stream_id, original_network_id,
feparams.frequency, feparams.inversion,
feparams.u.qam.symbol_rate, feparams.u.qam.fec_inner,
feparams.u.qam.modulation);
} else {
fprintf(fd, "\t\t<TS id=\"%04x\" on=\"%04x\" frq=\"%u\" inv=\"%hu\" sr=\"%u\" fec=\"%hu\" pol=\"%hu\">\n",
transport_stream_id, original_network_id,
feparams.frequency, feparams.inversion,
feparams.u.qpsk.symbol_rate, feparams.u.qpsk.fec_inner,
polarization);
}
}
void transponder::dump(std::string label)
{
if(type == FE_QAM)
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(),
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);
}