1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00

octoscan parsable output, single tp scan (WIP)

This commit is contained in:
mvoelkel 2016-01-07 17:54:20 +01:00
parent 8768d462a2
commit 4680835d46

View File

@ -130,6 +130,7 @@ struct service {
unsigned int got_pmt : 1;
unsigned int got_sdt : 1;
unsigned int is_enc : 1;
uint16_t sid;
uint16_t tsid;
@ -166,6 +167,8 @@ struct tp_info {
uint32_t bw;
uint32_t fec;
uint32_t isi;
char* request;
};
struct scantp {
@ -628,6 +631,8 @@ int cmp_tp(struct tp_info *a, struct tp_info *b)
}
if (a->mod != b->mod )
return 0;
if (a->pol != b->pol )
return 0;
return 1;
}
@ -851,6 +856,7 @@ static int pmt_cb(struct sfilter *sf)
s->pcr = get_pid(buf + 8);
s->anum = 0;
s->pmt = p->pid;
s->is_enc = 0;
while (c < slen - 4) {
eslen = get12(buf + c + 3);
epid = get_pid(buf + c + 1);
@ -866,6 +872,8 @@ static int pmt_cb(struct sfilter *sf)
case 0xea: // VC1
case 0xd1: // DIRAC
s->vpid = epid;
if (hasdesc(0x09, buf + c + 5, eslen))
s->is_enc = 1;
break;
case 0x03: // MPEG1
case 0x04: // MPEG2
@ -877,6 +885,8 @@ static int pmt_cb(struct sfilter *sf)
if (s->anum < MAX_ANUM)
s->apid[s->anum++] = epid;
//fprintf(stderr, " APID %04x", epid);
if (hasdesc(0x09, buf + c + 5, eslen))
s->is_enc = 1;
break;
case 0x06:
if (hasdesc(0x56, buf + c + 5, eslen))
@ -887,6 +897,8 @@ static int pmt_cb(struct sfilter *sf)
if (s->anum < MAX_ANUM)
s->apid[s->anum++] = epid;
}
if (hasdesc(0x09, buf + c + 5, eslen))
s->is_enc = 1;
break;
case 0x05: // PRIVATE
break;
@ -937,6 +949,7 @@ static int nit_cb(struct sfilter *sf)
c += 6;
switch (buf[c]) {
case 0x43:
t.request = NULL;
t.freq = getbcd(buf + c + 2, 8) / 100;
t.pos = getbcd(buf + c + 6, 4);
t.sr = getbcd(buf + c + 9, 7) / 10;
@ -952,6 +965,7 @@ static int nit_cb(struct sfilter *sf)
add_tp(sip, &t);
break;
case 0x44:
t.request = NULL;
t.freq = getbcd(buf + c + 2, 8) / 10000;
t.mod = buf[c + 8]; // undef 16 32 64 128 256
t.msys = 1;
@ -1175,7 +1189,7 @@ static int proc_sec(struct pid_info *p)
break;
case 0x40:
case 0x41:
res = nit_cb(sf);
// res = nit_cb(sf);
break;
case 0x42:
case 0x46:
@ -1371,12 +1385,58 @@ void proc_tsps(struct ts_info *tsi, uint8_t *tsp, uint32_t len)
static void dump_tp(struct tp_info *tpi)
{
struct service *s;
int i;
list_for_each_entry(s, &tpi->services, link) {
if (!s->got_pmt)
printf("NO PMT: ");
printf("%s:%s sid=%04x pmt=%04x pcr=%04x vpid=%04x apid=%04x\n",
s->pname, s->name, s->sid, s->pmt, s->pcr, s->vpid, s->apid[0]);
if (s->got_pmt && (s->vpid != 0 || s->anum>0)) {
printf("BEGIN\n");
printf(" PNAME:%s\n",s->pname);
printf(" SNAME:%s\n",s->name);
printf(" SID:%d\n",s->sid);
printf(" PIDS:%d",s->pmt);
uint16_t pcr = s->pcr;
if (s->pmt == pcr) pcr = 0;
if (s->vpid != 0 ) {
printf(",%d",s->vpid);
if (s->vpid == pcr) pcr = 0;
}
for (i= 0; i < s->anum; i+=1) {
if (s->apid[i] != 0 ) {
printf(",%d",s->apid[i]);
if (s->apid[i] == pcr) pcr = 0;
}
}
if (s->sub != 0 ) {
printf(",%d",s->sub);
if (s->sub == pcr) pcr = 0;
}
if (s->ttx != 0 ) {
printf(",%d",s->ttx);
if (s->ttx == pcr) pcr = 0;
}
if (pcr != 0) {
printf(",%d",pcr);
}
printf("\n");
if (s->anum > 0 && s->apid[0] != 0) {
printf(" APIDS:%d",s->apid[0]);
for (i= 1; i < s->anum; i+=1) {
if (s->apid[i] != 0 ) {
printf(",%d",s->apid[i]);
}
}
}
printf("\n");
if ( s->vpid == 0 )
printf(" RADIO:1\n");
if ( s->is_enc )
printf(" ENC:1\n");
printf("END\n");
}
//~ if (!s->got_pmt)
//~ printf("NO PMT: ");
//~ printf("%s:%s sid=%04x pmt=%04x pcr=%04x vpid=%04x apid=%04x\n",
//~ s->pname, s->name, s->sid, s->pmt, s->pcr, s->vpid, s->apid[0]);
}
}
@ -1460,6 +1520,10 @@ void tpstring(struct tp_info *tpi, char *s, int slen)
{
int len;
if( tpi->request ) {
strncpy(s,tpi->request,slen);
}
else {
switch (tpi->msys) {
case 1:
len = snprintf(s, slen,
@ -1474,6 +1538,7 @@ void tpstring(struct tp_info *tpi, char *s, int slen)
msys2str[tpi->msys], tpi->sr);
break;
}
}
}
@ -1589,6 +1654,11 @@ int main(int argc, char **argv)
sigaction(SIGINT, &term, NULL);
scanip_init(&sip, argv[1]);
if( argc > 1 ) {
tpi.request = argv[2];
add_tp(&sip, &tpi);
}
else
add_tp(&sip, &tpi3);
//scan_cable(&sip);
scanip(&sip);