diff --git a/daemon/mqtt.c b/daemon/mqtt.c index d9c548425..76512b3ce 100644 --- a/daemon/mqtt.c +++ b/daemon/mqtt.c @@ -249,8 +249,8 @@ static void mqtt_ssrc_stats(struct ssrc_ctx *ssrc, JsonBuilder *json, struct cal duplicates = sc->duplicates; // process per-second stats - uint64_t cur_ts = ssrc_timeval_to_ts(timeval_from_us(rtpe_now)); - uint64_t last_sample; + int64_t cur_ts = rtpe_now; + int64_t last_sample; int64_t sample_packets, sample_octets, sample_packets_lost, sample_duplicates; // sample values @@ -274,8 +274,8 @@ static void mqtt_ssrc_stats(struct ssrc_ctx *ssrc, JsonBuilder *json, struct cal if (last_sample && last_sample != cur_ts) { // calc sample rates with primitive math - struct timeval last_sample_ts = ssrc_ts_to_timeval(last_sample); // XXX - double usecs_diff = (double) timeval_diff(timeval_from_us(rtpe_now), last_sample_ts); // XXX + int64_t last_sample_ts = last_sample; + int64_t usecs_diff = rtpe_now - last_sample_ts; // adjust samples packets -= sample_packets; diff --git a/daemon/ssrc.c b/daemon/ssrc.c index 35f3c889a..7e101f9d6 100644 --- a/daemon/ssrc.c +++ b/daemon/ssrc.c @@ -32,7 +32,7 @@ static void init_ssrc_ctx(struct ssrc_ctx *c, struct ssrc_entry_call *parent) { while (!c->ssrc_map_out) c->ssrc_map_out = ssl_random(); c->seq_out = ssl_random(); - atomic64_set_na(&c->last_sample, ssrc_timeval_to_ts(timeval_from_us(rtpe_now))); + atomic64_set_na(&c->last_sample, rtpe_now); c->stats = bufferpool_alloc0(shm_bufferpool, sizeof(*c->stats)); } static void init_ssrc_entry(struct ssrc_entry *ent, uint32_t ssrc) { diff --git a/include/ssrc.h b/include/ssrc.h index 5c87e714b..4244b97ea 100644 --- a/include/ssrc.h +++ b/include/ssrc.h @@ -63,14 +63,6 @@ struct ssrc_ctx { int64_t next_rtcp; // for self-generated RTCP reports }; -INLINE uint64_t ssrc_timeval_to_ts(const struct timeval tv) { - return (tv.tv_sec << 20) | tv.tv_usec; -} -INLINE struct timeval ssrc_ts_to_timeval(uint64_t ts) { - return (struct timeval) { .tv_sec = ts >> 20, .tv_usec = ts & 0xfffff }; -} - - struct ssrc_stats_block { int64_t reported; uint64_t jitter; // ms diff --git a/lib/auxlib.h b/lib/auxlib.h index 39d3e0ca2..538110ccd 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -363,10 +363,6 @@ INLINE struct timeval timeval_from_us(int64_t ms) { return (struct timeval) { .tv_sec = ms/1000000LL, .tv_usec = ms%1000000LL }; } __attribute__((warn_unused_result)) -INLINE int64_t timeval_diff(const struct timeval a, const struct timeval b) { - return timeval_us(a) - timeval_us(b); -} -__attribute__((warn_unused_result)) INLINE int64_t timeval_lowest(const int64_t l, const int64_t n) { if (!n) return l;