auto create mux

This commit is contained in:
Glenn-1990 2015-03-03 15:20:43 +01:00 committed by Jaroslav Kysela
parent e91074c812
commit 6acd4b60a3
5 changed files with 136 additions and 23 deletions

View file

@ -3,84 +3,126 @@
"name": "Canal Digitaal Astra1",
"position": 192,
"frequency": 12515000,
"symbolrate" : 22000000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 900
},
{
"name": "TV Vlaanderen Astra1",
"position": 192,
"frequency": 12515000,
"symbolrate" : 22000000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 910
},
{
"name": "TéléSAT Astra1",
"position": 192,
"frequency": 12515000,
"symbolrate" : 22000000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 920
},
{
"name": "Mobistar NL Astra1",
"position": 192,
"frequency": 12515000,
"symbolrate" : 22000000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 930
},
{
"name": "Mobistar FR Astra1",
"position": 192,
"frequency": 12515000,
"symbolrate" : 22000000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 940
},
{
"name": "AustriaSat Astra1",
"position": 192,
"frequency": 12515000,
"symbolrate" : 22000000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 950
},
{
"name": "Canal Digitaal Astra3",
"position": 235,
"frequency": 12187000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs2",
"pid": 900
},
{
"name": "TV Vlaanderen Astra3",
"position": 235,
"frequency": 12187000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs2",
"pid": 910
},
{
"name": "TéléSAT Astra3",
"position": 235,
"frequency": 12187000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs2",
"pid": 920
},
{
"name": "Mobistar NL Astra3",
"position": 235,
"frequency": 12187000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs2",
"pid": 930
},
{
"name": "Mobistar FR Astra3",
"position": 235,
"frequency": 12187000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs2",
"pid": 940
},
{
"name": "AustriaSat Astra3",
"position": 235,
"frequency": 12187000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs2",
"pid": 950
},
{
"name": "Skylink: Czech Republic",
"position": 235,
"frequency": 12070000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 30
},
{
"name": "Skylink: Slovak Republic",
"position": 235,
"frequency": 12070000,
"symbolrate" : 27500000,
"polarisation" : "H",
"delsys" : "dvbs",
"pid": 31
}
]

View file

@ -2623,7 +2623,7 @@ psi_tables_dvb ( mpegts_mux_t *mm )
dvb_mux_conf_t *mc = &((dvb_mux_t *)mm)->lm_tuning;
if (mc->dmc_fe_type == DVB_TYPE_S)
dvb_fastscan_each(mm, mc->u.dmc_fe_qpsk.orbital_pos,
mc->dmc_fe_freq, psi_tables_dvb_fastscan);
mc->dmc_fe_freq, mc->u.dmc_fe_qpsk.polarisation, psi_tables_dvb_fastscan);
}
#endif
}

View file

@ -37,8 +37,11 @@ typedef struct dvb_fastscan {
LIST_HEAD(,dvb_fastscan_item) items;
int position;
uint32_t frequency;
int position;
dvb_fe_delivery_system_t delsys;
dvb_polarisation_t polarisation;
uint32_t frequency;
uint32_t symbolRate;
} dvb_fastscan_t;
static RB_HEAD(,dvb_fastscan) fastscan_rb;
@ -51,13 +54,13 @@ _fs_cmp(const void *a, const void *b)
if (r == 0) {
r = ((dvb_fastscan_t *)a)->frequency - ((dvb_fastscan_t *)b)->frequency;
if (abs(r) < 2000)
return 0;
return (((dvb_fastscan_t *)a)->polarisation - ((dvb_fastscan_t *)b)->polarisation);
}
return r;
}
void
dvb_fastscan_each(void *aux, int position, uint32_t frequency,
dvb_fastscan_each(void *aux, int position, uint32_t frequency, dvb_polarisation_t polarisation,
void (*job)(void *aux, bouquet_t *bq,
const char *name, int pid))
{
@ -69,13 +72,14 @@ dvb_fastscan_each(void *aux, int position, uint32_t frequency,
SKEL_ALLOC(fastscan_rb_skel);
fastscan_rb_skel->position = position;
fastscan_rb_skel->frequency = frequency;
fastscan_rb_skel->polarisation = polarisation;
fs = RB_FIND(&fastscan_rb, fastscan_rb_skel, link, _fs_cmp);
if (!fs)
return;
LIST_FOREACH(fsi, &fs->items, ilink) {
dvb_sat_position_to_str(fs->position, buf, sizeof(buf));
snprintf(url, sizeof(url), "dvb-fastscan://dvbs,%s,%u,%d",
buf, fs->frequency, fsi->pid);
snprintf(url, sizeof(url), "dvb-fastscan://%s,%s,%u,%s,%u,%d", dvb_delsys2str(fastscan_rb_skel->delsys),
buf, fs->frequency, dvb_pol2str(fs->polarisation), fs->symbolRate, fsi->pid);
bq = bouquet_find_by_source(NULL, url, 0);
if (bq == NULL || !bq->bq_enabled)
continue;
@ -90,7 +94,7 @@ dvb_fastscan_create(htsmsg_t *e)
dvb_fastscan_t *fs;
dvb_fastscan_item_t *fsi;
bouquet_t *bq;
const char *name;
const char *name, *polarisation, *delsys;
int pid;
char url[64], buf[16];
@ -103,10 +107,18 @@ dvb_fastscan_create(htsmsg_t *e)
goto fail;
if ((name = htsmsg_get_str(e, "name")) == NULL)
goto fail;
if (htsmsg_get_u32(e, "symbolrate", &fastscan_rb_skel->symbolRate))
goto fail;
if ((delsys = htsmsg_get_str(e, "delsys")) == NULL)
goto fail;
if ((polarisation = htsmsg_get_str(e, "polarisation")) == NULL)
goto fail;
fastscan_rb_skel->polarisation = dvb_str2pol(polarisation);
fastscan_rb_skel->delsys = dvb_str2delsys(delsys);
dvb_sat_position_to_str(fastscan_rb_skel->position, buf, sizeof(buf));
snprintf(url, sizeof(url), "dvb-fastscan://dvbs,%s,%u,%d",
buf, fastscan_rb_skel->frequency, pid);
snprintf(url, sizeof(url), "dvb-fastscan://%s,%s,%u,%s,%u,%d", dvb_delsys2str(fastscan_rb_skel->delsys),
buf, fastscan_rb_skel->frequency, dvb_pol2str(fastscan_rb_skel->polarisation), fastscan_rb_skel->symbolRate, pid);
bq = bouquet_find_by_source(name, url, 1);
if (bq == NULL)
goto fail;

View file

@ -24,7 +24,7 @@
struct bouquet;
void
dvb_fastscan_each(void *aux, int position, uint32_t frequency,
dvb_fastscan_each(void *aux, int position, uint32_t frequency, dvb_polarisation_t polarisation,
void (*job)(void *aux, struct bouquet *,
const char *name, int pid));

View file

@ -321,18 +321,7 @@ tsid_lookup:
if (!extra)
return;
freq = strtod(extra, NULL) * 1000;
goto freq;
}
if ((l = startswith(src, "dvb-fastscan://dvbs,")) > 0) {
uint32_t pid;
src += l;
if ((satpos = dvb_sat_position_from_str(src)) == INT_MAX)
return;
while (*src && *src != ',')
src++;
if (sscanf(src, ",%u,%u", &freq, &pid) != 2)
return;
freq:
LIST_FOREACH(mn, &mpegts_network_all, mn_global_link)
LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link)
if (idnode_is_instance(&mm->mm_id, &dvb_mux_dvbs_class) &&
@ -341,6 +330,76 @@ freq:
mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND);
return;
}
if ((l = startswith(src, "dvb-fastscan://")) > 0) {
uint32_t pid, symbol, dvbs2;
char pol[2];
pol[1] = '\0';
src += l;
if ((l = startswith(src, "DVBS2,")) > 0)
dvbs2 = 1;
else if ((l = startswith(src, "DVBS,")) > 0)
dvbs2 = 0;
else
return;
src += l;
if ((satpos = dvb_sat_position_from_str(src)) == INT_MAX)
return;
while (*src && *src != ',')
src++;
if (sscanf(src, ",%u,%c,%u,%u", &freq, &pol[0], &symbol, &pid) != 4)
return;
// search for fastscan mux
LIST_FOREACH(mn, &mpegts_network_all, mn_global_link)
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_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.polarisation == dvb_str2pol(pol) &&
((dvb_mux_t *)mm)->lm_tuning.u.dmc_fe_qpsk.orbital_pos == satpos)
{
char buf[256];
mpegts_mux_nice_name(mm, buf, sizeof(buf));
tvhinfo("mpegts", "fastscan mux found '%s', set scan state 'PENDING'", buf);
mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND);
return;
}
tvhinfo("mpegts", "fastscan mux not found, position:%i, frequency:%i, polarisation:%c", satpos, freq, pol[0]);
// fastscan mux not found, try to add it automatically
LIST_FOREACH(mn, &mpegts_network_all, mn_global_link)
if (mn->mn_satpos != INT_MAX && mn->mn_satpos == satpos)
{
dvb_mux_conf_t *mux;
mpegts_mux_t *mm = NULL;
mux = malloc(sizeof(dvb_mux_conf_t));
dvb_mux_conf_init(mux, dvbs2 ? DVB_SYS_DVBS2 : DVB_SYS_DVBS);
mux->dmc_fe_freq = freq;
mux->u.dmc_fe_qpsk.symbol_rate = symbol;
mux->u.dmc_fe_qpsk.polarisation = dvb_str2pol(pol);
mux->u.dmc_fe_qpsk.orbital_pos = satpos;
mux->u.dmc_fe_qpsk.fec_inner = DVB_FEC_AUTO;
mux->dmc_fe_modulation = DVB_MOD_AUTO;
mux->dmc_fe_rolloff = DVB_ROLLOFF_AUTO;
mux->dmc_fe_pls_code = 1;
mm = (mpegts_mux_t*)dvb_mux_create0((dvb_network_t*)mn,
MPEGTS_ONID_NONE,
MPEGTS_TSID_NONE,
mux, NULL, NULL);
if (mm)
{
mm->mm_config_save(mm);
char buf[256];
mn->mn_display_name(mn, buf, sizeof(buf));
tvhinfo("mpegts", "fastscan mux add to network '%s'", buf);
}
free(mux);
}
return;
}
#endif
}