From 7d116966c83538124aee60780a3ccdd8af582aa7 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 21 Oct 2013 13:33:02 +0100 Subject: [PATCH] mpegts: fix processing errors when <188 bytes is received Also fix raw streaming where data is not %188, previously the code would have sent duplicate bytes which would have caused (unecessary) errors downstream. --- src/input/mpegts/mpegts_input.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 331ccdda..42738b72 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -339,22 +339,11 @@ mpegts_input_recv_packets name, tsb, (int)len, pcr, pcr_pid); /* Not enough data */ - if (len < 188) return 0; + if (len < 188) return len; /* Streaming - lock mutex */ pthread_mutex_lock(&mi->mi_delivery_mutex); - /* Raw stream */ - if (LIST_FIRST(&mmi->mmi_streaming_pad.sp_targets) != NULL) { - streaming_message_t sm; - pktbuf_t *pb = pktbuf_alloc(tsb, len); - memset(&sm, 0, sizeof(sm)); - sm.sm_type = SMT_MPEGTS; - sm.sm_data = pb; - streaming_pad_deliver(&mmi->mmi_streaming_pad, &sm); - pktbuf_ref_dec(pb); - } - /* Process */ while ( len >= 188 ) { @@ -410,6 +399,18 @@ mpegts_input_recv_packets } + /* Raw stream */ + // Note: this will include unsynced data if that's what is received + if (i > 0 && LIST_FIRST(&mmi->mmi_streaming_pad.sp_targets) != NULL) { + streaming_message_t sm; + pktbuf_t *pb = pktbuf_alloc(tsb, i); + memset(&sm, 0, sizeof(sm)); + sm.sm_type = SMT_MPEGTS; + sm.sm_data = pb; + streaming_pad_deliver(&mmi->mmi_streaming_pad, &sm); + pktbuf_ref_dec(pb); + } + /* Wake table */ if (table_wakeup) pthread_cond_signal(&mi->mi_table_feed_cond);