dvb: remove orbital_dir, use negative orbital_pos value to distinguish East and West

This commit is contained in:
Jaroslav Kysela 2015-02-05 17:33:56 +01:00
parent 53f8b5068e
commit 36283c6598
8 changed files with 47 additions and 80 deletions

View file

@ -431,7 +431,6 @@ typedef enum dvb_polarisation {
typedef struct dvb_qpsk_config {
dvb_polarisation_t polarisation;
int orbital_pos;
char orbital_dir;
uint32_t symbol_rate;
dvb_fe_code_rate_t fec_inner;
} dvb_qpsk_config_t;
@ -517,8 +516,6 @@ void dvb_mux_conf_init ( dvb_mux_conf_t *dmc, dvb_fe_delivery_system_t delsys );
int dvb_mux_conf_str ( dvb_mux_conf_t *conf, char *buf, size_t bufsize );
int dvb_sat_position( const dvb_mux_conf_t *mc );
const char *dvb_sat_position_to_str( int position, char *buf, size_t buflen );
const int dvb_sat_position_from_str( const char *buf );

View file

@ -181,7 +181,8 @@ dvb_desc_sat_del
dmc.dmc_fe_freq = frequency;
dmc.u.dmc_fe_qpsk.orbital_pos = bcdtoint(ptr[4]) * 100 + bcdtoint(ptr[5]);
dmc.u.dmc_fe_qpsk.orbital_dir = (ptr[6] & 0x80) ? 'E' : 'W';
if ((ptr[6] & 0x80) == 0)
dmc.u.dmc_fe_qpsk.orbital_pos *= -1;
dmc.u.dmc_fe_qpsk.polarisation = (ptr[6] >> 5) & 0x03;
dmc.u.dmc_fe_qpsk.symbol_rate = symrate * 100;
@ -555,7 +556,7 @@ dvb_freesat_add_service
if (!fr->bouquet) {
strcpy(name, "???");
if (idnode_is_instance(&bi->mm->mm_id, &dvb_mux_dvbs_class))
dvb_sat_position_to_str(dvb_sat_position(&((dvb_mux_t *)bi->mm)->lm_tuning),
dvb_sat_position_to_str(((dvb_mux_t *)bi->mm)->lm_tuning.u.dmc_fe_qpsk.orbital_pos,
name, sizeof(name));
snprintf(src, sizeof(src), "dvb-%s://dvbs,%s,%04X,%u",
bi->freesat ? "freesat" : "bskyb", name, bi->nbid, fr->regionid);
@ -1230,9 +1231,9 @@ dvb_bat_completed
char src[64] = "";
if (idnode_is_instance(&mux->mm_id, &dvb_mux_dvbs_class)) {
dvb_mux_conf_t *mc = &((dvb_mux_t *)mux)->lm_tuning;
if (mc->u.dmc_fe_qpsk.orbital_dir) {
if (mc->u.dmc_fe_qpsk.orbital_pos != INT_MAX) {
char buf[16];
dvb_sat_position_to_str(dvb_sat_position(mc), buf, sizeof(buf));
dvb_sat_position_to_str(mc->u.dmc_fe_qpsk.orbital_pos, buf, sizeof(buf));
snprintf(src, sizeof(src), "dvb-bouquet://dvbs,%s,%04X,%04X", buf, tsid, bi->nbid);
}
} else if (idnode_is_instance(&mux->mm_id, &dvb_mux_dvbt_class)) {
@ -2553,7 +2554,7 @@ psi_tables_dvb ( mpegts_mux_t *mm )
if (idnode_is_instance(&mm->mm_id, &dvb_mux_dvbs_class)) {
dvb_mux_conf_t *mc = &((dvb_mux_t *)mm)->lm_tuning;
if (mc->dmc_fe_type == DVB_TYPE_S)
dvb_fastscan_each(mm, dvb_sat_position(mc),
dvb_fastscan_each(mm, mc->u.dmc_fe_qpsk.orbital_pos,
mc->dmc_fe_freq, psi_tables_dvb_fastscan);
}
#endif

View file

@ -816,14 +816,18 @@ static int
dvb_mux_conf_str_dvbs ( dvb_mux_conf_t *dmc, char *buf, size_t bufsize )
{
const char *pol = dvb_pol2str(dmc->u.dmc_fe_qpsk.polarisation);
const char dir = dmc->u.dmc_fe_qpsk.orbital_dir;
const int satpos = dmc->u.dmc_fe_qpsk.orbital_pos;
char satbuf[16];
if (satpos) {
snprintf(satbuf, sizeof(buf), "%d.%d%c ", abs(satpos) / 10, abs(satpos) % 10, satpos < 0 ? 'W' : 'E');
} else {
satbuf[0] = '\0';
}
return
snprintf(buf, bufsize,
"%s pos %d.%d%c freq %d %c sym %d fec %s mod %s roff %s is_id %d pls_mode %s pls_code %d",
"%s %sfreq %d %c sym %d fec %s mod %s roff %s is_id %d pls_mode %s pls_code %d",
dvb_delsys2str(dmc->dmc_fe_delsys),
dmc->u.dmc_fe_qpsk.orbital_pos / 10,
dmc->u.dmc_fe_qpsk.orbital_pos % 10,
dir >= ' ' && dir <= 'z' ? dir : '?',
satbuf,
dmc->dmc_fe_freq,
pol ? pol[0] : 'X',
dmc->u.dmc_fe_qpsk.symbol_rate,
@ -867,18 +871,6 @@ dvb_mux_conf_str ( dvb_mux_conf_t *dmc, char *buf, size_t bufsize )
}
}
int
dvb_sat_position(const dvb_mux_conf_t *mc)
{
int pos = mc->u.dmc_fe_qpsk.orbital_pos;
assert(mc->dmc_fe_type == DVB_TYPE_S);
if (!mc->u.dmc_fe_qpsk.orbital_dir)
return INT_MAX;
if (mc->u.dmc_fe_qpsk.orbital_dir == 'W')
return -pos;
return pos;
}
const char *
dvb_sat_position_to_str(int position, char *buf, size_t buflen)
{

View file

@ -34,6 +34,7 @@ typedef struct dvb_network
dvb_fe_type_t ln_type;
} dvb_network_t;
extern const idclass_t dvb_network_class;
extern const idclass_t dvb_network_dvbt_class;
extern const idclass_t dvb_network_dvbc_class;
extern const idclass_t dvb_network_dvbs_class;
@ -41,13 +42,13 @@ extern const idclass_t dvb_network_atsc_class;
void dvb_network_init ( void );
void dvb_network_done ( void );
dvb_network_t *dvb_network_find_by_uuid(const char *uuid);
static inline dvb_network_t *dvb_network_find_by_uuid(const char *uuid)
{ return idnode_find(uuid, &dvb_network_class, NULL); }
dvb_network_t *dvb_network_create0
( const char *uuid, const idclass_t *idc, htsmsg_t *conf );
int dvb_network_get_orbital_pos
( mpegts_network_t *mn, int *pos, char *dir );
int dvb_network_get_orbital_pos(mpegts_network_t *mn);
/*
*

View file

@ -450,39 +450,25 @@ dvb_mux_dvbs_class_delsys_enum (void *o)
static const void *
dvb_mux_dvbs_class_orbital_get ( void *o )
{
static char buf[256], *s = buf;
static char buf[16], *s = buf;
dvb_mux_t *lm = o;
snprintf(buf, sizeof(buf), "%0.1f%c",
lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos / 10.0,
lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir);
dvb_sat_position_to_str(lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos, buf, sizeof(buf));
return &s;
}
static int
dvb_mux_dvbs_class_orbital_set ( void *o, const void *s )
{
float posf;
char dir;
int pos, n, save = 0;
const char *tmp = s;
dvb_mux_t *lm = o;
int pos;
/* Note that 'E' is not passed to dir from sscanf (scientific float format) */
if ((n = sscanf(tmp, "%f%c", &posf, &dir)) < 1) return 0;
if (n != 2) {
dir = tmp[0] != '\0' ? tmp[strlen(tmp)-1] : 0;
if (dir != 'E' && dir != 'W')
dir = 0;
}
pos = (int)floorf(posf * 10.0);
pos = dvb_sat_position_from_str((const char *)s);
if (pos != lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos ||
dir != lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir) {
if (pos != lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos) {
lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos = pos;
lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir = dir;
save = 1;
return 1;
}
return save;
return 0;
}
const idclass_t dvb_mux_dvbs_class =
@ -745,5 +731,9 @@ dvb_mux_create0
htsmsg_destroy(c);
}
/* Update the satellite position for the network settings */
if (ln->mn_satpos == INT_MAX && lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos != INT_MAX)
ln->mn_satpos = lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos;
return lm;
}

View file

@ -320,11 +320,8 @@ dvb_network_check_symbol_rate( dvb_mux_t *lm, dvb_mux_conf_t *dmc, int deltar )
static int
dvb_network_check_orbital_pos ( dvb_mux_t *lm, dvb_mux_conf_t *dmc )
{
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir &&
dmc->u.dmc_fe_qpsk.orbital_dir) {
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir !=
dmc->u.dmc_fe_qpsk.orbital_dir)
return 1;
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos != INT_MAX &&
dmc->u.dmc_fe_qpsk.orbital_pos != INT_MAX) {
/* 1W and 0.8W */
if (abs(lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos -
dmc->u.dmc_fe_qpsk.orbital_pos) > 2)
@ -445,7 +442,7 @@ dvb_network_create_mux
dvb_mux_t *lm;
LIST_FOREACH(mm2, &ln->mn_muxes, mm_network_link) {
lm = (dvb_mux_t *)mm2;
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir)
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos != INT_MAX)
break;
}
/* do not allow to mix sattelite positions */
@ -500,10 +497,9 @@ dvb_network_create_mux
#endif
/* Always save the orbital position */
if (dmc->dmc_fe_type == DVB_TYPE_S) {
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir == 0 ||
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos == INT_MAX ||
dvb_network_check_orbital_pos(lm, dmc))
save |= COMPARE(u.dmc_fe_qpsk.orbital_pos);
save |= COMPARE(u.dmc_fe_qpsk.orbital_dir);
}
/* Do not change anything else without autodiscovery flag */
if (!ln->mn_autodiscovery)
@ -709,33 +705,24 @@ void dvb_network_done ( void )
* Search
* ***************************************************************************/
dvb_network_t*
dvb_network_find_by_uuid(const char *uuid)
{
return idnode_find(uuid, &dvb_network_class, NULL);
}
int dvb_network_get_orbital_pos
( mpegts_network_t *mn, int *pos, char *dir )
int dvb_network_get_orbital_pos(mpegts_network_t *mn)
{
dvb_network_t *ln = (dvb_network_t *)mn;
mpegts_mux_t *mm;
dvb_mux_t *lm = NULL;
if (!mn)
return -1;
if (!ln)
return INT_MAX;
if (ln->mn_satpos != INT_MAX)
return ln->mn_satpos;
LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link) {
lm = (dvb_mux_t *)mm;
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir)
if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos != INT_MAX)
break;
}
if (mm) {
*pos = lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos;
*dir = lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir;
return 0;
} else {
return -1;
}
if (mm)
return lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos;
return INT_MAX;
}
/******************************************************************************

View file

@ -289,7 +289,7 @@ mpegts_mux_bouquet_rescan ( const char *src, const char *extra )
LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link)
if (idnode_is_instance(&mm->mm_id, &dvb_mux_dvbs_class) &&
mm->mm_tsid == tsid &&
dvb_sat_position(&((dvb_mux_t *)mm)->lm_tuning) == satpos)
((dvb_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.orbital_pos == satpos)
mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND);
return;
}
@ -337,7 +337,7 @@ freq:
LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link)
if (idnode_is_instance(&mm->mm_id, &dvb_mux_dvbs_class) &&
abs(((dvb_mux_t *)mm)->lm_tuning.dmc_fe_freq - freq) < 2000 &&
dvb_sat_position(&((dvb_mux_t *)mm)->lm_tuning) == satpos)
((dvb_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.orbital_pos == satpos)
mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND);
return;
}

View file

@ -445,14 +445,13 @@ mpegts_service_channel_icon ( service_t *s )
int32_t hash = 0;
static char buf[128];
dvb_mux_t *mmd = (dvb_mux_t*)ms->s_dvb_mux;
char dir;
int pos;
switch ( mmd->lm_tuning.dmc_fe_type) {
case DVB_TYPE_S:
if (dvb_network_get_orbital_pos(mmd->mm_network, &pos, &dir) < 0)
if ((pos = dvb_network_get_orbital_pos(mmd->mm_network)) == INT_MAX)
return NULL;
hash = (dir == 'E' ? pos : 0xFFFF - pos) << 16;
hash = (pos >= 0 ? pos : 0xFFFF - abs(pos)) << 16;
break;
case DVB_TYPE_C:
hash = 0xFFFF0000;