]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
parsers: add PCR / PTS check (comparison) before the packet is pushed to next chain
authorJaroslav Kysela <perex@perex.cz>
Thu, 27 Apr 2017 16:32:49 +0000 (18:32 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 27 Apr 2017 16:33:13 +0000 (18:33 +0200)
- the goal is to improve the parsed data stability
- drop the invalid packets to avoid troubles in the packet processors

src/parsers/parsers.c
src/service.c
src/service.h

index 966b36be1c6cb4e39580e90ac6eab7bd4cdb4a5f..b386777b94c8ac0d1b0889bdcc7992f04fe00754 100644 (file)
@@ -1830,6 +1830,14 @@ parser_deliver(service_t *t, elementary_stream_t *st, th_pkt_t *pkt)
 {
   assert(pkt->pkt_type == st->es_type);
 
+  if (tvhlog_limit(&st->es_pcr_log, 2)) {
+    if (pts_diff(pkt->pkt_pcr, pkt->pkt_pts) > 2*90000) {
+      tvhwarn(LS_PARSER, "%s: PTS and PCR diff is very large (%"PRId64")",
+              service_component_nicename(st), pts_diff(pkt->pkt_pcr, pkt->pkt_pts));
+      goto end;
+    }
+  }
+
   pkt->pkt_componentindex = st->es_index;
 
   pkt_trace(LS_PARSER, pkt, "deliver");
@@ -1850,6 +1858,7 @@ parser_deliver(service_t *t, elementary_stream_t *st, th_pkt_t *pkt)
   /* Forward packet */
   streaming_pad_deliver(&t->s_streaming_pad, streaming_msg_create_pkt(pkt));
 
+end:
   /* Decrease our own reference to the packet */
   pkt_ref_dec(pkt);
 
index 220b4ad398c865faa34249ddd8052120e17f2d7c..978736e632e500c691658ff6e5353b6014f2f3c3 100644 (file)
@@ -310,6 +310,7 @@ stream_clean(elementary_stream_t *st)
 
   tvhlog_limit_reset(&st->es_cc_log);
   tvhlog_limit_reset(&st->es_pes_log);
+  tvhlog_limit_reset(&st->es_pcr_log);
 }
 
 /**
index 68a492293560619ebfcc0bcf84e2fb524d759a31..9290e570c40587a1feef79d56b76fc7dc8ac1df9 100644 (file)
@@ -127,6 +127,7 @@ typedef struct elementary_stream {
 
   tvhlog_limit_t es_cc_log;
   tvhlog_limit_t es_pes_log;
+  tvhlog_limit_t es_pcr_log;
   
   char *es_nicename;