]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP client: add 'Skip TS packets (0-200)' option, fixes #3137
authorJaroslav Kysela <perex@perex.cz>
Fri, 9 Oct 2015 18:53:53 +0000 (20:53 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 9 Oct 2015 18:54:19 +0000 (20:54 +0200)
src/input/mpegts/satip/satip.c
src/input/mpegts/satip/satip_frontend.c
src/input/mpegts/satip/satip_private.h

index 7c939f836e31e5a26da433198d01cc770f33c2ec..9bd32f431e4e850389160b4b5edf19c0fbcfacf0 100644 (file)
@@ -284,6 +284,13 @@ const idclass_t satip_device_class =
       .opts     = PO_ADVANCED,
       .off      = offsetof(satip_device_t, sd_bindaddr),
     },
+    {
+      .type     = PT_INT,
+      .id       = "skip_ts",
+      .name     = N_("Skip TS packets (0-200)"),
+      .opts     = PO_ADVANCED,
+      .off      = offsetof(satip_device_t, sd_skip_ts),
+    },
     {
       .type     = PT_BOOL,
       .id       = "disableworkarounds",
index b8696c946268627053e373e7ffe6f8e3dc9a5b9e..97e9ea714c002eccc1bee88c228d99aa8829aafb 100644 (file)
@@ -971,7 +971,7 @@ satip_frontend_close_rtsp
 static int
 satip_frontend_rtp_data_received( http_client_t *hc, void *buf, size_t len )
 {
-  int c, pos;
+  int c, pos, r;
   uint32_t nseq, unc;
   uint8_t *b = buf, *p;
   satip_frontend_t *lfe = hc->hc_aux;
@@ -998,7 +998,8 @@ satip_frontend_rtp_data_received( http_client_t *hc, void *buf, size_t len )
         return 0;
       pos += (((p[pos+2] << 8) | p[pos+3]) + 1) * 4;
     }
-    if (c <= pos || ((c - pos) % 188) != 0)
+    r = c - pos;
+    if (c <= pos || (r % 188) != 0)
       return 0;
     /* Use uncorrectable value to notify RTP delivery issues */
     nseq = (p[2] << 8) | p[3];
@@ -1012,8 +1013,19 @@ satip_frontend_rtp_data_received( http_client_t *hc, void *buf, size_t len )
     lfe->sf_seq = nseq;
 
     /* Process */
-    tsdebug_write((mpegts_mux_t *)lfe->sf_curmux, p + pos, c - pos);
-    sbuf_append(&lfe->sf_sbuf, p + pos, c - pos);
+    if (lfe->sf_skip_ts > 0) {
+      if (lfe->sf_skip_ts < r) {
+        pos += lfe->sf_skip_ts;
+        lfe->sf_skip_ts = 0;
+        goto wrdata;
+      } else {
+        lfe->sf_skip_ts -= r;
+      }
+    } else {
+wrdata:
+      tsdebug_write((mpegts_mux_t *)lfe->sf_curmux, p + pos, c - pos);
+      sbuf_append(&lfe->sf_sbuf, p + pos, c - pos);
+    }
 
     if (lfe->sf_sbuf.sb_ptr > 64 * 1024 ||
         lfe->sf_last_data_tstamp != dispatch_clock) {
@@ -1344,6 +1356,7 @@ new_tune:
 
   udp_multirecv_init(&um, RTP_PKTS, RTP_PKT_SIZE);
   sbuf_init_fixed(sb, RTP_PKTS * RTP_PKT_SIZE);
+  lfe->sf_skip_ts = MIN(200, MAX(0, lfe->sf_device->sd_skip_ts)) * 188;
   
   while ((reply || running) && !fatal) {
 
@@ -1539,7 +1552,8 @@ new_tune:
           continue;
         pos += (((p[pos+2] << 8) | p[pos+3]) + 1) * 4;
       }
-      if (c <= pos || ((c - pos) % 188) != 0)
+      r = c - pos;
+      if (c <= pos || (r % 188) != 0)
         continue;
       /* Use uncorrectable value to notify RTP delivery issues */
       nseq = (p[2] << 8) | p[3];
@@ -1551,8 +1565,19 @@ new_tune:
       }
       seq = nseq;
       /* Process */
-      tsdebug_write((mpegts_mux_t *)lm, p + pos, c - pos);
-      sbuf_append(sb, p + pos, c - pos);
+      if (lfe->sf_skip_ts > 0) {
+        if (lfe->sf_skip_ts < r) {
+          pos += lfe->sf_skip_ts;
+          lfe->sf_skip_ts = 0;
+          goto wrdata;
+        } else {
+          lfe->sf_skip_ts -= r;
+        }
+      } else {
+wrdata:
+        tsdebug_write((mpegts_mux_t *)lm, p + pos, c - pos);
+        sbuf_append(sb, p + pos, c - pos);
+      }
     }
     pthread_mutex_lock(&lfe->sf_dvr_lock);
     if (lfe->sf_req == lfe->sf_req_thread) {
index 097f5728b8e71c3341cb916a637262675a6abc9f..1dbb7189750331ed587af50dfa40887ce3e51125 100644 (file)
@@ -93,6 +93,7 @@ struct satip_device
   int                        sd_pilot_on;
   int                        sd_no_univ_lnb;
   int                        sd_dbus_allow;
+  int                        sd_skip_ts;
   int                        sd_disable_workarounds;
   pthread_mutex_t            sd_tune_mutex;
 };
@@ -145,6 +146,7 @@ struct satip_frontend
   satip_tune_req_t          *sf_req;
   satip_tune_req_t          *sf_req_thread;
   sbuf_t                     sf_sbuf;
+  int                        sf_skip_ts;
   const char *               sf_display_name;
   uint32_t                   sf_seq;
   dvb_mux_t                 *sf_curmux;