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.
This commit is contained in:
Jaroslav Kysela 2014-05-28 15:32:33 +02:00
parent 2a3210d0c5
commit f7422b6689
3 changed files with 11 additions and 4 deletions

View 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

View 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;
}

View 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