diff options
-rw-r--r-- | src/core.h | 1 | ||||
-rw-r--r-- | src/metric.c | 13 | ||||
-rw-r--r-- | src/stream.c | 3 |
3 files changed, 16 insertions, 1 deletions
@@ -226,6 +226,7 @@ struct metric { uint32_t n_bytes_last; }; +void metric_init(struct metric *metric); void metric_reset(struct metric *metric); void metric_add_packet(struct metric *metric, size_t packetsize); uint32_t metric_avg_bitrate(const struct metric *metric); diff --git a/src/metric.c b/src/metric.c index f509805..f3e8d06 100644 --- a/src/metric.c +++ b/src/metric.c @@ -17,6 +17,9 @@ static void tmr_handler(void *arg) tmr_start(&metric->tmr, TMR_INTERVAL * 1000, tmr_handler, metric); + if (!metric->started) + return; + if (now <= metric->ts_last) return; @@ -38,12 +41,20 @@ static void metric_start(struct metric *metric) return; metric->ts_start = tmr_jiffies(); - tmr_start(&metric->tmr, 1, tmr_handler, metric); metric->started = true; } +void metric_init(struct metric *metric) +{ + if (!metric) + return; + + tmr_start(&metric->tmr, 100, tmr_handler, metric); +} + + void metric_reset(struct metric *metric) { if (!metric) diff --git a/src/stream.c b/src/stream.c index e9cf871..07f51bd 100644 --- a/src/stream.c +++ b/src/stream.c @@ -310,6 +310,9 @@ int stream_alloc(struct stream **sp, const struct config_avt *cfg, s->pt_enc = -1; + metric_init(&s->metric_tx); + metric_init(&s->metric_rx); + list_append(call_streaml(call), &s->le, s); out: |