From 982dc4d3667add9a047a65b422270cca2edb8cc6 Mon Sep 17 00:00:00 2001 From: none Date: Sat, 29 Aug 2020 14:38:09 +0200 Subject: [PATCH] fix tscheck and add option to not open dvr demux --- lib/ddzap.c | 58 ++++++++++++++++++++++++---------------------- lib/src/dddvb.c | 1 + lib/src/dddvb.h | 3 +++ lib/src/dvb.c | 7 +++--- lib/src/libdddvb.h | 3 +++ 5 files changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/ddzap.c b/lib/ddzap.c index d375854..519e8b8 100644 --- a/lib/ddzap.c +++ b/lib/ddzap.c @@ -27,33 +27,28 @@ void proc_ts(int i, uint8_t *buf) uint16_t pid=0x1fff&((buf[1]<<8)|buf[2]); uint8_t ccin = buf[3] & 0x1F; - if( buf[0] == 0x47 && (buf[1] & 0x80) == 0) - { - if( pid != 8191 ) - { - if( ccin != 0 ) - { - if( cc[pid] != 0 ) - { - // TODO: 1 repetition allowed - if( ( ccin & 0x10 ) != 0 && (((cc[pid] + 1) & 0x0F) != (ccin & 0x0F)) ) - cc_errors += 1; - } - cc[pid] = ccin; - } - payload_packets += 1; - } - } - else - packet_errors += 1; - - if( (packets & 0x3FFF ) == 0) - { - printf("%s Packets: %12u non null %12u, errors: %12u, CC errors: %12u%s", line_start, packets, payload_packets, packet_errors, cc_errors, line_end); - fflush(stdout); - } - - packets += 1; + if (buf[0] == 0x47 && (buf[1] & 0x80) == 0) { + if( pid != 8191 ) { + if (ccin & 0x10) { + if ( cc[pid]) { + // TODO: 1 repetition allowed + if( ( ccin & 0x10 ) != 0 && (((cc[pid] + 1) & 0x0F) != (ccin & 0x0F)) ) + cc_errors += 1; + } + cc[pid] = ccin; + } + payload_packets += 1; + } + } else + packet_errors += 1; + + if( (packets & 0x3FFF ) == 0) + { + printf("%s Packets: %12u non null %12u, errors: %12u, CC errors: %12u%s", line_start, packets, payload_packets, packet_errors, cc_errors, line_end); + fflush(stdout); + } + + packets += 1; } #define TSBUFSIZE (100*188) @@ -108,6 +103,7 @@ int main(int argc, char **argv) uint32_t id = DDDVB_UNDEF, ssi = DDDVB_UNDEF, num = DDDVB_UNDEF, source = 0; uint32_t mtype= DDDVB_UNDEF; uint32_t verbosity = 0; + uint32_t get_ts = 1; enum fe_code_rate fec = FEC_AUTO; enum fe_delivery_system delsys = ~0; char *config = "config/"; @@ -137,11 +133,12 @@ int main(int argc, char **argv) {"open_dvr", no_argument, 0, 'o'}, {"tscheck", no_argument, 0, 't'}, {"tscheck_l", required_argument, 0, 'a'}, + {"nodvr", no_argument , 0, 'q'}, {"help", no_argument , 0, 'h'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, - "c:i:f:s:d:p:hg:r:n:b:l:v:m:ota:", + "c:i:f:s:d:p:hg:r:n:b:l:v:m:ota:q", long_options, &option_index); if (c==-1) break; @@ -245,6 +242,9 @@ int main(int argc, char **argv) if (!strcmp(optarg, "v") || !strcmp(optarg, "V")) pol = 0; break; + case 'q': + get_ts = 0; + break; case 'h': fprintf(fout,"ddzap [-d delivery_system] [-p polarity] [-c config_dir] [-f frequency(Hz)]\n" " [-b bandwidth(Hz)] [-s symbol_rate(Hz)]\n" @@ -283,6 +283,7 @@ int main(int argc, char **argv) exit(-1); } fprintf(fout,"dvbnum = %u\n", dd->dvbfe_num); + dddvb_get_ts(dd, get_ts); if (num != DDDVB_UNDEF) fe = dddvb_fe_alloc_num(dd, delsys, num); @@ -303,6 +304,7 @@ int main(int argc, char **argv) dddvb_set_id(&p, id); dddvb_set_ssi(&p, ssi); dddvb_dvb_tune(fe, &p); + #if 0 { uint8_t ts[188]; diff --git a/lib/src/dddvb.c b/lib/src/dddvb.c index 17af839..aa85a8b 100644 --- a/lib/src/dddvb.c +++ b/lib/src/dddvb.c @@ -89,6 +89,7 @@ LIBDDDVB_EXPORTED struct dddvb *dddvb_init(char *config, uint32_t flags) dddvb_dvb_init(dd); global_dd = dd; + dd->get_ts = 1; fail: pthread_mutex_unlock(&dddvb_mutex); return dd; diff --git a/lib/src/dddvb.h b/lib/src/dddvb.h index 545e877..f9e76d8 100644 --- a/lib/src/dddvb.h +++ b/lib/src/dddvb.h @@ -150,6 +150,9 @@ struct dddvb { struct dddvb_fe dvbfe[DDDVB_MAX_DVB_FE]; struct dddvb_ca dvbca[DDDVB_MAX_DVB_CA]; + + + unsigned int get_ts:1; }; int dddvb_dvb_init(struct dddvb *dd); diff --git a/lib/src/dvb.c b/lib/src/dvb.c index 618eb03..81a1ef7 100644 --- a/lib/src/dvb.c +++ b/lib/src/dvb.c @@ -531,7 +531,7 @@ static int tune(struct dddvb_fe *fe) return ret; } -static int open_dmx(struct dddvb_fe *fe) +int open_dmx(struct dddvb_fe *fe) { char fname[80]; struct dmx_pes_filter_params pesFilterParams; @@ -623,10 +623,9 @@ void dddvb_fe_handle(struct dddvb_fe *fe) uint32_t newtune, count = 0, max, nolock = 0; int ret; - printf("fe_handle\n"); - open_dmx(fe); - printf("fe_handle 2\n"); + if (fe->dd->get_ts) + open_dmx(fe); while (fe->state == 1) { pthread_mutex_lock(&fe->mutex); newtune = fe->n_tune; diff --git a/lib/src/libdddvb.h b/lib/src/libdddvb.h index f4c802d..3b28f6a 100644 --- a/lib/src/libdddvb.h +++ b/lib/src/libdddvb.h @@ -64,6 +64,9 @@ LIBDDDVB_EXPORTED int dddvb_ca_write(struct dddvb *dd, uint32_t nr, uint8_t *buf LIBDDDVB_EXPORTED int dddvb_ca_read(struct dddvb *dd, uint32_t nr, uint8_t *buf, uint32_t len); LIBDDDVB_EXPORTED int dddvb_ca_set_pmts(struct dddvb *dd, uint32_t nr, uint8_t **pmts); +static inline void dddvb_get_ts(struct dddvb *dd, uint32_t val) { + dd->get_ts = val; +}; static inline void dddvb_set_frequency(struct dddvb_params *p, uint32_t freq) { p->param[PARAM_FREQ] = freq;