]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
mpegts input: increase the buffering but add the time check for slow streams
authorJaroslav Kysela <perex@perex.cz>
Wed, 28 May 2014 13:32:33 +0000 (15:32 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 28 May 2014 13:32:33 +0000 (15:32 +0200)
It's better to handle packets in bigger chunks, but for slow streams,
add a quick timer check to deliver these data in time, too.

src/input/mpegts.h
src/input/mpegts/iptv/iptv_udp.c
src/input/mpegts/mpegts_input.c

index 3991dc494c1d81f8b9889dbe4fdf077c6c3d214b..0e3da17617755c12c6cbfba6cc0f886d1e7a53de 100644 (file)
@@ -483,6 +483,7 @@ struct mpegts_input
    */
 
   int mi_running;
+  time_t mi_last_dispatch;
 
   /* Data input */
   // Note: this section is protected by mi_input_lock
index c001204f58f6f804818fd03101f7a776c49599cb..8a72f5cc46a7e3db2fedee6177016b7b1810447a 100644 (file)
@@ -112,7 +112,6 @@ iptv_rtp_read ( iptv_mux_t *im, size_t *off )
   return len;
 
 ignore:
-  printf("ignore\n");
   im->mm_iptv_buffer.sb_ptr = ptr; // reset
   return len;
 }
index 10e093c656fa4f5d9c53e7e8ba42765283051228..456bdaab2f1067b0cb15e4cb6fede37529e6f2dd 100644 (file)
@@ -375,6 +375,9 @@ static void
 mpegts_input_started_mux
   ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )
 {
+  /* Deliver first TS packets as fast as possible */
+  mi->mi_last_dispatch = 0;
+
   /* Arm timer */
   if (LIST_FIRST(&mi->mi_mux_active) == NULL)
     gtimer_arm(&mi->mi_status_timer, mpegts_input_status_timer,
@@ -451,11 +454,15 @@ mpegts_input_recv_packets
   mpegts_packet_t *mp;
   uint8_t *tsb = sb->sb_data + off;
   int     len  = sb->sb_ptr  - off;
-#define MIN_TS_PKT 10
+#define MIN_TS_PKT 100
 #define MIN_TS_SYN 5
 
-  if (len < (MIN_TS_PKT * 188))
-    return;
+  if (len < (MIN_TS_PKT * 188)) {
+    /* For slow streams, check also against the clock */
+    if (dispatch_clock == mi->mi_last_dispatch)
+      return;
+  }
+  mi->mi_last_dispatch = dispatch_clock;
 
   /* Check for sync */
 // could be a bit more efficient