From: Jaroslav Kysela Date: Wed, 13 Dec 2017 16:14:30 +0000 (+0100) Subject: iptv: do the bandwidth check per network properly X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c2bf962a362d102523553b248ca8da7fa27ed496;p=thirdparty%2Ftvheadend.git iptv: do the bandwidth check per network properly --- diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 10227721e..9fda8f466 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -513,7 +513,6 @@ iptv_input_recv_flush ( iptv_mux_t *im ) int iptv_input_recv_packets ( iptv_mux_t *im, ssize_t len ) { - static time_t t1 = 0, t2; iptv_network_t *in = (iptv_network_t*)im->mm_network; mpegts_mux_instance_t *mmi; mpegts_pcr_t pcr; @@ -524,8 +523,8 @@ iptv_input_recv_packets ( iptv_mux_t *im, ssize_t len ) pcr.pcr_last = PTS_UNSET; pcr.pcr_pid = im->im_pcr_pid; in->in_bps += len * 8; - time(&t2); - if (t2 != t1) { + s64 = mclk(); + if (mono2sec(in->in_bandwidth_clock) != mono2sec(s64)) { if (in->in_max_bandwidth && in->in_bps > in->in_max_bandwidth * 1024) { if (!in->in_bw_limited) { @@ -535,7 +534,7 @@ iptv_input_recv_packets ( iptv_mux_t *im, ssize_t len ) } } in->in_bps = 0; - t1 = t2; + in->in_bandwidth_clock = s64; } /* Pass on, but with timing */ diff --git a/src/input/mpegts/iptv/iptv_private.h b/src/input/mpegts/iptv/iptv_private.h index 2d187652c..42a37be1f 100644 --- a/src/input/mpegts/iptv/iptv_private.h +++ b/src/input/mpegts/iptv/iptv_private.h @@ -95,6 +95,7 @@ struct iptv_network int in_ignore_path; int in_tsid_accept_zero_value; int in_libav; + int64_t in_bandwidth_clock; void *in_auto; /* private structure for auto-network */ };