]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
iptv: fix the time buffer limit configuration, fixes #3480
authorJaroslav Kysela <perex@perex.cz>
Mon, 11 Jan 2016 15:13:10 +0000 (16:13 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 11 Jan 2016 15:14:36 +0000 (16:14 +0100)
src/input/mpegts/iptv/iptv.c
src/input/mpegts/iptv/iptv_file.c
src/input/mpegts/iptv/iptv_http.c
src/input/mpegts/iptv/iptv_mux.c
src/input/mpegts/iptv/iptv_pipe.c
src/input/mpegts/iptv/iptv_private.h
src/input/mpegts/iptv/iptv_udp.c

index d4f577223ed876f2e4cff867bc0393744e8247e2..66fe4a593ce08dd123b7768553925feef0b4c95d 100644 (file)
@@ -410,18 +410,25 @@ iptv_input_display_name ( mpegts_input_t *mi, char *buf, size_t len )
 static inline int
 iptv_input_pause_check ( iptv_mux_t *im )
 {
-  int64_t s64;
+  int64_t s64, limit;
 
   if (im->im_pcr == PTS_UNSET)
     return 0;
+  limit = im->mm_iptv_buffer_limit;
+  if (!limit)
+    limit = im->im_handler->buffer_limit;
+  if (limit == UINT32_MAX)
+    return 0;
+  limit *= 1000;
   s64 = getmonoclock() - im->im_pcr_start;
   im->im_pcr_start += s64;
   im->im_pcr += (((s64 / 10LL) * 9LL) + 4LL) / 10LL;
   im->im_pcr &= PTS_MASK;
-  tvhtrace("iptv-pcr", "pcr: updated %"PRId64", time start %"PRId64, im->im_pcr, im->im_pcr_start);
+  tvhtrace("iptv-pcr", "pcr: updated %"PRId64", time start %"PRId64", limit %"PRId64,
+           im->im_pcr, im->im_pcr_start, limit);
 
   /* queued more than 3 seconds? trigger the pause */
-  return im->im_pcr_end - im->im_pcr_start >= 3000000LL;
+  return im->im_pcr_end - im->im_pcr_start >= limit;
 }
 
 void
index 6b7f627bb0c0d3ca6574ba55fd065c04f733f682..eaff540e9c16276a1e0525390325bfbd0eaed9eb 100644 (file)
@@ -137,6 +137,7 @@ iptv_file_init ( void )
   static iptv_handler_t ih[] = {
     {
       .scheme = "file",
+      .buffer_limit = 5000,
       .start  = iptv_file_start,
       .stop   = iptv_file_stop
     },
index 2102f008c4638d0890a25e48e32b5bdf82a3c658..07d0de3aea831dc5398e22dfc70de186245e81d9 100644 (file)
@@ -592,12 +592,14 @@ iptv_http_init ( void )
   static iptv_handler_t ih[] = {
     {
       .scheme = "http",
+      .buffer_limit = 5000,
       .start  = iptv_http_start,
       .stop   = iptv_http_stop,
       .pause  = iptv_http_pause
     },
     {
       .scheme  = "https",
+      .buffer_limit = 5000,
       .start  = iptv_http_start,
       .stop   = iptv_http_stop,
       .pause  = iptv_http_pause
index 6f12fb6df1e94f8f4cb3394e694409df1301dbb1..4398bec8fc66e60dd302b682c19cab11bec0788c 100644 (file)
@@ -246,6 +246,16 @@ const idclass_t iptv_mux_class =
       .off      = offsetof(iptv_mux_t, mm_iptv_satip_dvbt_freq),
       .opts     = PO_ADVANCED
     },
+    {
+      .type     = PT_U32,
+      .id       = "iptv_buffer_limit",
+      .name     = N_("Buffering limit (ms)"),
+      .desc     = N_("Specifies the incoming buffering limit in milliseconds (PCR based). "
+                     "If PCR time difference from the system clock is higher, the incoming "
+                     "stream is paused."),
+      .off      = offsetof(iptv_mux_t, mm_iptv_buffer_limit),
+      .opts     = PO_ADVANCED,
+    },
     {}
   }
 };
index 2b9aaac24ff1418d2894c521aedaa4f6cfddaf36..4902c5208c3cc0f03cbc402bca7cefdf767b8c19 100644 (file)
@@ -162,6 +162,7 @@ iptv_pipe_init ( void )
   static iptv_handler_t ih[] = {
     {
       .scheme = "pipe",
+      .buffer_limit = 5000,
       .start  = iptv_pipe_start,
       .stop   = iptv_pipe_stop,
       .read   = iptv_pipe_read,
index 1350be756a4707f20f5e90d89de535f1ebf14780..2188adbc20a1f451315387a866f30149087ee123 100644 (file)
@@ -49,6 +49,9 @@ typedef struct iptv_handler iptv_handler_t;
 struct iptv_handler
 {
   const char *scheme;
+
+  uint32_t buffer_limit;
+
   int     (*start) ( iptv_mux_t *im, const char *raw, const url_t *url );
   void    (*stop)  ( iptv_mux_t *im );
   ssize_t (*read)  ( iptv_mux_t *im );
@@ -141,6 +144,8 @@ struct iptv_mux
 
   sbuf_t                mm_iptv_buffer;
 
+  uint32_t              mm_iptv_buffer_limit;
+
   iptv_handler_t       *im_handler;
   gtimer_t              im_pause_timer;
 
index f701c210893119cac828b39ca0a03ece73bdfbfb..ab6636c9dfa9a715aff68ed93b53da68906b69be 100644 (file)
@@ -184,6 +184,7 @@ iptv_udp_init ( void )
   static iptv_handler_t ih[] = {
     {
       .scheme = "udp",
+      .buffer_limit = UINT32_MAX, /* unlimited */
       .start  = iptv_udp_start,
       .stop   = iptv_udp_stop,
       .read   = iptv_udp_read,
@@ -191,6 +192,7 @@ iptv_udp_init ( void )
     },
     {
       .scheme = "rtp",
+      .buffer_limit = UINT32_MAX, /* unlimited */
       .start  = iptv_udp_start,
       .stop   = iptv_udp_stop,
       .read   = iptv_udp_rtp_read,