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