From f7422b6689cbb7070bd99db884cdd4b0e090feb0 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 28 May 2014 15:32:33 +0200 Subject: [PATCH] mpegts input: increase the buffering but add the time check for slow streams 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 | 1 + src/input/mpegts/iptv/iptv_udp.c | 1 - src/input/mpegts/mpegts_input.c | 13 ++++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 3991dc49..0e3da176 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -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 diff --git a/src/input/mpegts/iptv/iptv_udp.c b/src/input/mpegts/iptv/iptv_udp.c index c001204f..8a72f5cc 100644 --- a/src/input/mpegts/iptv/iptv_udp.c +++ b/src/input/mpegts/iptv/iptv_udp.c @@ -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; } diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 10e093c6..456bdaab 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -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