diff --git a/src/input.c b/src/input.c index ecd8cdcd..5f1f3310 100644 --- a/src/input.c +++ b/src/input.c @@ -84,6 +84,8 @@ tvh_input_stream_create_msg htsmsg_add_u32(m, "snr", st->stats.snr); htsmsg_add_u32(m, "unc", st->stats.unc); htsmsg_add_u32(m, "bps", st->stats.bps); + htsmsg_add_u32(m, "te", st->stats.te); + htsmsg_add_u32(m, "cc", st->stats.cc); return m; } diff --git a/src/input.h b/src/input.h index c4e162c3..2b28884d 100644 --- a/src/input.h +++ b/src/input.h @@ -44,6 +44,8 @@ struct tvh_input_stream_stats int unc; ///< Uncorrectable errors int snr; ///< Signal 2 Noise (dB) int bps; ///< Bandwidth (bps) + int cc; ///< Continuity errors + int te; ///< Transport errors }; struct tvh_input_stream { diff --git a/src/input/mpegts.h b/src/input/mpegts.h index d6d5e5eb..26d7cecb 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -120,6 +120,7 @@ typedef struct mpegts_pid { int mp_pid; int mp_fd; // linuxdvb demux fd + int8_t mp_cc; RB_HEAD(,mpegts_pid_sub) mp_subs; // subscribers to pid RB_ENTRY(mpegts_pid) mp_link; } mpegts_pid_t; diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 3129902f..46c0b619 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -516,12 +516,29 @@ mpegts_input_process mpegts_pid_sub_t *mps; service_t *s; int pid = ((tsb[i+1] & 0x1f) << 8) | tsb[i+2]; + int cc = (tsb[i+3] & 0x0f); + int pl = (tsb[i+3] & 0x10) ? 1 : 0; + int te = (tsb[i+1] & 0x80); /* Ignore NUL packets */ if (pid == 0x1FFF) goto done; + /* Transport error */ + if (te) + ++mmi->mmi_stats.te; + /* Find PID */ if ((mp = mpegts_mux_find_pid(mm, pid, 0))) { + + /* Low level CC check */ + if (pl) { + if (mp->mp_cc != -1 && mp->mp_cc != cc) { + tvhtrace("mpegts", "pid %04X cc err %2d != %2d", pid, cc, mp->mp_cc); + ++mmi->mmi_stats.cc; + } + mp->mp_cc = (cc + 1) & 0xF; + } + // Note: there is a minor danger this caching will get things // wrong for a brief period of time if the registrations on // the PID change diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index 72b86226..c3c7d018 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -919,6 +919,7 @@ mpegts_mux_find_pid_ ( mpegts_mux_t *mm, int pid, int create ) mp = mpegts_pid_skel; SKEL_USED(mpegts_pid_skel); mp->mp_fd = -1; + mp->mp_cc = -1; } } if (mp) {