mirror of
https://github.com/DigitalDevices/octonet.git
synced 2023-10-10 13:36:52 +02:00
simplify parameter handling (like nodvbt) and add support for changing the announcement order of supported delivery systems
This commit is contained in:
parent
27f864b577
commit
24bd27a087
@ -194,7 +194,6 @@ static int set_fe_input(struct dvbfe *fe, uint32_t fr,
|
||||
int fd = fe->fd;
|
||||
|
||||
dbgprintf(DEBUG_DVB, "ds = %u, input = %u\n", ds, input);
|
||||
|
||||
if (fe->set & (1UL << PARAM_FEC))
|
||||
p[5].u.data = fe->param[PARAM_FEC] - 1;
|
||||
|
||||
@ -1113,7 +1112,7 @@ int dvb_tune(struct dvbfe *fe, struct dvb_params *p)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int init_fe(struct octoserve *os, int a, int f, int fd, int nodvbt, int msmode)
|
||||
static int init_fe(struct octoserve *os, int a, int f, int fd)
|
||||
{
|
||||
struct dtv_properties dps;
|
||||
struct dtv_property dp[10];
|
||||
@ -1134,8 +1133,10 @@ static int init_fe(struct octoserve *os, int a, int f, int fd, int nodvbt, int m
|
||||
dbgprintf(DEBUG_DVB, "delivery system %d\n", ds);
|
||||
fe->type |= (1UL << ds);
|
||||
}
|
||||
if (nodvbt)
|
||||
if (os->nodvbt)
|
||||
fe->type &= ~((1UL << SYS_DVBT2) | (1UL << SYS_DVBT));
|
||||
if (os->delsys_mask)
|
||||
fe->type &= os->delsys_mask;
|
||||
|
||||
if (!fe->type)
|
||||
return -1;
|
||||
@ -1156,8 +1157,9 @@ static int init_fe(struct octoserve *os, int a, int f, int fd, int nodvbt, int m
|
||||
dbgprintf(DEBUG_DVB, "input prop %u = %u\n", i, fe->input[i]);
|
||||
}
|
||||
if (fe->input[3]) {
|
||||
dbgprintf(DEBUG_DVB, "has_feswitch\n");
|
||||
os->has_feswitch = 1;
|
||||
if (!os->scif_type && !msmode) {
|
||||
if (!os->scif_type && !os->msmode) {
|
||||
if (fe->input[2] >= fe->input[1]) {
|
||||
fe->type = 0;
|
||||
return -1;
|
||||
@ -1181,7 +1183,7 @@ static int init_fe(struct octoserve *os, int a, int f, int fd, int nodvbt, int m
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int scan_dvbfe(struct octoserve *os, int nodvbt, int msmode)
|
||||
static int scan_dvbfe(struct octoserve *os)
|
||||
{
|
||||
int a, f, fd;
|
||||
char fname[80];
|
||||
@ -1191,7 +1193,7 @@ static int scan_dvbfe(struct octoserve *os, int nodvbt, int msmode)
|
||||
sprintf(fname, "/dev/dvb/adapter%d/frontend%d", a, f);
|
||||
fd = open(fname, O_RDWR);
|
||||
if (fd >= 0) {
|
||||
init_fe(os, a, f, fd, nodvbt, msmode);
|
||||
init_fe(os, a, f, fd);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
@ -1782,7 +1784,7 @@ void lnb_config(struct octoserve *os, char *name, char *val)
|
||||
}
|
||||
}
|
||||
|
||||
int init_dvb(struct octoserve *os, int nodvbt, int msmode)
|
||||
int init_dvb(struct octoserve *os)
|
||||
{
|
||||
int i, j;
|
||||
uint32_t fmode;
|
||||
@ -1792,13 +1794,16 @@ int init_dvb(struct octoserve *os, int nodvbt, int msmode)
|
||||
os->scif_type = 0;
|
||||
parse_config(os, "scif", &scif_config);
|
||||
|
||||
scan_dvbfe(os, nodvbt, msmode);
|
||||
scan_dvbfe(os);
|
||||
scan_dvbca(os);
|
||||
|
||||
if (os->scif_type)
|
||||
fmode = 0;
|
||||
else
|
||||
fmode = msmode;
|
||||
fmode = os->msmode;
|
||||
dbgprintf(DEBUG_DVB, "fmode = %u, msmode = %u hasfeswitch = %u\n",
|
||||
fmode, os->msmode, os->has_feswitch);
|
||||
|
||||
if (os->has_feswitch)
|
||||
set_fmode(fmode);
|
||||
|
||||
|
@ -162,19 +162,34 @@ void send_xml(struct os_ssdp *ss)
|
||||
uint8_t *mac = &os->mac[0];
|
||||
int serial = (mac[5] | (mac[4] << 8) | (mac[3] << 16)) / 2;
|
||||
char boxname[80];
|
||||
int i;
|
||||
|
||||
read_boxname(boxname);
|
||||
len = 0;
|
||||
if (os->dvbs2num)
|
||||
len += sprintf(cap + len, ",DVBS2-%u", os->dvbs2num);
|
||||
if (os->dvbtnum)
|
||||
len += sprintf(cap + len, ",DVBT-%u", os->dvbtnum);
|
||||
if (os->dvbt2num)
|
||||
len += sprintf(cap + len, ",DVBT2-%u", os->dvbt2num);
|
||||
if (os->dvbcnum)
|
||||
len += sprintf(cap + len, ",DVBC-%u", os->dvbcnum);
|
||||
if (os->dvbc2num)
|
||||
len += sprintf(cap + len, ",DVBC2-%u", os->dvbc2num);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
switch ((i + os->first_ds) % 5) {
|
||||
case 0:
|
||||
if (os->dvbs2num)
|
||||
len += sprintf(cap + len, ",DVBS2-%u", os->dvbs2num);
|
||||
break;
|
||||
case 1:
|
||||
if (os->dvbtnum)
|
||||
len += sprintf(cap + len, ",DVBT-%u", os->dvbtnum);
|
||||
break;
|
||||
case 2:
|
||||
if (os->dvbt2num)
|
||||
len += sprintf(cap + len, ",DVBT2-%u", os->dvbt2num);
|
||||
break;
|
||||
case 3:
|
||||
if (os->dvbcnum)
|
||||
len += sprintf(cap + len, ",DVBC-%u", os->dvbcnum);
|
||||
break;
|
||||
case 4:
|
||||
if (os->dvbc2num)
|
||||
len += sprintf(cap + len, ",DVBC2-%u", os->dvbc2num);
|
||||
break;
|
||||
}
|
||||
len = snprintf(buf, sizeof(buf), xmldesc,
|
||||
ss->configid, boxname,
|
||||
serial, ss->uuid_str, cap + 1);
|
||||
|
@ -2692,7 +2692,82 @@ static void os_serve(struct octoserve *os)
|
||||
killall_sessions(os);
|
||||
}
|
||||
|
||||
static struct octoserve *os_init(char *ifname, int nossdp, int nodms, int nodvbt, int msmode)
|
||||
static int fexists(char *fn)
|
||||
{
|
||||
struct stat b;
|
||||
|
||||
return (!stat(fn, &b));
|
||||
}
|
||||
|
||||
static int read_num(char *fn, int *num)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen(fn, "r");
|
||||
if (!f)
|
||||
return -1;
|
||||
fscanf(f, "%i", num);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void read_first_ds(struct octoserve *os)
|
||||
{
|
||||
int num;
|
||||
int res = read_num("/config/first_ds", &num);
|
||||
|
||||
if (res < 0)
|
||||
os->first_ds = 0;
|
||||
else
|
||||
os->first_ds = num;
|
||||
|
||||
printf("first_ds = %u\n", os->first_ds);
|
||||
}
|
||||
|
||||
static void read_delsys_mask(struct octoserve *os)
|
||||
{
|
||||
int fd, len;
|
||||
char mask[80];
|
||||
|
||||
os->delsys_mask = 0;
|
||||
fd = open("/config/delsys_mask", O_RDONLY);
|
||||
if (fd < 0)
|
||||
return;
|
||||
len = read(fd, mask, 79);
|
||||
if (len < 0)
|
||||
return;
|
||||
close (fd);
|
||||
if (len)
|
||||
os->delsys_mask = strtol(mask, NULL, 0);
|
||||
printf("delsys_mask = %08x\n", os->delsys_mask);
|
||||
}
|
||||
|
||||
static int read_msmode(char *fn)
|
||||
{
|
||||
int fd, len;
|
||||
char mode[80];
|
||||
|
||||
fd = open(fn, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
if (fexists("/config/noswitch.enabled"))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
len = read(fd, mode, 7);
|
||||
if (len < 0)
|
||||
return 0;
|
||||
close (fd);
|
||||
if (len == 4 && !strncasecmp(mode, "none", 4))
|
||||
return 0;
|
||||
if (len == 4 && !strncasecmp(mode, "quad", 4))
|
||||
return 1;
|
||||
if (len == 7 && !strncasecmp(mode, "quattro", 7))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct octoserve *os_init(char *ifname, int nossdp, int nodms)
|
||||
{
|
||||
struct octoserve *os;
|
||||
struct os_ssdp *ss;
|
||||
@ -2706,13 +2781,17 @@ static struct octoserve *os_init(char *ifname, int nossdp, int nodms, int nodvbt
|
||||
dbgprintf(DEBUG_SYS, "allocated octoserve struct, %d bytes\n", sizeof(*os));
|
||||
memset(os, 0, sizeof(struct octoserve));
|
||||
|
||||
if (fexists("/config/nodvbt.enabled"))
|
||||
os->nodvbt = 1;
|
||||
os->msmode = read_msmode("/config/msmode");
|
||||
read_first_ds(os);
|
||||
read_delsys_mask(os);
|
||||
pthread_mutexattr_init(&mta);
|
||||
pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&os->lock, &mta);
|
||||
|
||||
os->ifname = ifname;
|
||||
os->sessionid = random();
|
||||
|
||||
if (get_ifa(ifname, AF_INET, (struct sockaddr *) &os->ssdp.sadr) < 0) {
|
||||
perror("no such interface:");
|
||||
free(os);
|
||||
@ -2734,7 +2813,7 @@ static struct octoserve *os_init(char *ifname, int nossdp, int nodms, int nodvbt
|
||||
if (os->has_switch)
|
||||
switch_get_port(os->mac);
|
||||
|
||||
init_dvb(os, nodvbt, msmode);
|
||||
init_dvb(os);
|
||||
|
||||
ss = &os->ssdp;
|
||||
if (init_ssdp(os, &os->ssdp, debug, nossdp, nodms) < 0) {
|
||||
@ -2777,38 +2856,6 @@ static int set_termaction(void)
|
||||
sigaction(SIGTERM, &term, NULL);
|
||||
}
|
||||
|
||||
static int fexists(char *fn)
|
||||
{
|
||||
struct stat b;
|
||||
|
||||
return (!stat(fn, &b));
|
||||
}
|
||||
|
||||
static int read_msmode(char *fn)
|
||||
{
|
||||
int fd, len;
|
||||
char mode[80];
|
||||
|
||||
fd = open(fn, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
if (fexists("/config/noswitch.enabled"))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
len = read(fd, mode, 7);
|
||||
if (len < 0)
|
||||
return 0;
|
||||
close (fd);
|
||||
if (len == 4 && !strncasecmp(mode, "none", 4))
|
||||
return 0;
|
||||
if (len == 4 && !strncasecmp(mode, "quad", 4))
|
||||
return 1;
|
||||
if (len == 7 && !strncasecmp(mode, "quattro", 7))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void awrite(char *fn, char *txt)
|
||||
{
|
||||
FILE *f = fopen(fn, "w");
|
||||
@ -2820,7 +2867,7 @@ static void awrite(char *fn, char *txt)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int nodms = 0, nossdp = 0, nodvbt = 0, vlan = 0, msmode = 1;
|
||||
int nodms = 0, nossdp = 0, vlan = 0;
|
||||
|
||||
printf("Octoserve " OCTOSERVE_VERSION
|
||||
", Copyright (C) 2012-15 Digital Devices GmbH\n");
|
||||
@ -2834,13 +2881,12 @@ int main(int argc, char **argv)
|
||||
{"flags", required_argument, 0, 'f'},
|
||||
{"nossdp", no_argument, 0, 'n'},
|
||||
{"nodms", no_argument, 0, 'm'},
|
||||
{"nodvbt", no_argument, 0, 't'},
|
||||
{"conform", no_argument, 0, 'c'},
|
||||
{"help", no_argument , 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
c = getopt_long(argc, argv,
|
||||
"d:f:nmtsch",
|
||||
"d:f:nmch",
|
||||
long_options, &option_index);
|
||||
if (c==-1)
|
||||
break;
|
||||
@ -2858,9 +2904,6 @@ int main(int argc, char **argv)
|
||||
case 'm':
|
||||
nodms = 1;
|
||||
break;
|
||||
case 't':
|
||||
nodvbt = 1;
|
||||
break;
|
||||
case 'c':
|
||||
conform = 1;
|
||||
break;
|
||||
@ -2875,17 +2918,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if (fexists("/config/nodms.enabled"))
|
||||
nodms = 1;
|
||||
msmode = read_msmode("/config/msmode");
|
||||
if (fexists("/config/nodvbt.enabled"))
|
||||
nodvbt = 1;
|
||||
if (fexists("/config/vlan.enabled")) {
|
||||
awrite("/sys/class/ddbridge/ddbridge0/vlan", "1");
|
||||
vlan = 1;
|
||||
} else
|
||||
awrite("/sys/class/ddbridge/ddbridge0/vlan", "0");
|
||||
printf("nodms = %d, nodvbt = %d, vlan = %d\n", nodms, nodvbt, vlan);
|
||||
printf("nodms = %d, vlan = %d\n", nodms, vlan);
|
||||
|
||||
os = os_init("eth0", nossdp, nodms, nodvbt, msmode);
|
||||
os = os_init("eth0", nossdp, nodms);
|
||||
if (!os)
|
||||
return -1;
|
||||
set_termaction();
|
||||
|
@ -501,6 +501,10 @@ struct octoserve {
|
||||
int mld_sock;
|
||||
int has_switch;
|
||||
int strict;
|
||||
uint32_t delsys_mask;
|
||||
int msmode;
|
||||
int nodvbt;
|
||||
uint32_t first_ds;
|
||||
};
|
||||
|
||||
int streamsock(const char *port, int family, struct sockaddr *sadr);
|
||||
@ -508,7 +512,7 @@ void sockname(struct sockaddr *sadr, char *name);
|
||||
int get_ifa(const char *ifname, int iffam, struct sockaddr *sadr);
|
||||
int init_ssdp(struct octoserve *os, struct os_ssdp *ss, uint32_t d, int nossdp, int nodms);
|
||||
int dvb_tune(struct dvbfe *fe, struct dvb_params *p);
|
||||
int init_dvb(struct octoserve *os, int nodvbt, int noswitch);
|
||||
int init_dvb(struct octoserve *os);
|
||||
int release_dvb(struct octoserve *os);
|
||||
void parse_config(struct octoserve *os, char *sec,
|
||||
void (*cb)(struct octoserve *, char *, char *));
|
||||
|
Loading…
Reference in New Issue
Block a user