MT#55283 obsolete timeval_diff

Change-Id: I83ea176acd77cdd9c371e4c8cde324bdfc3c2486
pull/1855/merge
Richard Fuchs 2 weeks ago
parent 283abdf465
commit 71f2234902

@ -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;

@ -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) {

@ -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

@ -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;

Loading…
Cancel
Save