]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
iptv: do the bandwidth check per network properly
authorJaroslav Kysela <perex@perex.cz>
Wed, 13 Dec 2017 16:14:30 +0000 (17:14 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 13 Dec 2017 16:14:30 +0000 (17:14 +0100)
src/input/mpegts/iptv/iptv.c
src/input/mpegts/iptv/iptv_private.h

index 10227721eddfb8ecc4bea923d41dfeae05a2427b..9fda8f466604bc0220c0221878562a07ab6d0383 100644 (file)
@@ -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 */
index 2d187652c3d1582b1ca13a0445ca8f7e8fbc6587..42a37be1fc7a60bed2a38fd1b3a5177cabab6dd1 100644 (file)
@@ -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 */
 };