From b6b1b0b90e9ee3ed97238c64cfe46c98f2e47dfe Mon Sep 17 00:00:00 2001 From: Christian Spielberger Date: Fri, 29 Sep 2023 10:00:53 +0200 Subject: [PATCH] jbuf: add jbuf_frames() again --- include/re_jbuf.h | 1 + src/jbuf/jbuf.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/re_jbuf.h b/include/re_jbuf.h index 902924c18..77ad1961e 100644 --- a/include/re_jbuf.h +++ b/include/re_jbuf.h @@ -37,3 +37,4 @@ void jbuf_flush(struct jbuf *jb); int jbuf_stats(const struct jbuf *jb, struct jbuf_stat *jstat); int jbuf_debug(struct re_printf *pf, const struct jbuf *jb); uint32_t jbuf_packets(const struct jbuf *jb); +uint32_t jbuf_frames(const struct jbuf *jb); diff --git a/src/jbuf/jbuf.c b/src/jbuf/jbuf.c index 5d705c01b..6666d356d 100644 --- a/src/jbuf/jbuf.c +++ b/src/jbuf/jbuf.c @@ -732,6 +732,26 @@ uint32_t jbuf_packets(const struct jbuf *jb) } +/** + * Get number of current frames + * + * @param jb Jitter buffer + * + * @return number of frames + */ +uint32_t jbuf_frames(const struct jbuf *jb) +{ + if (!jb) + return 0; + + mtx_lock(jb->lock); + uint32_t n = jb->nf; + mtx_unlock(jb->lock); + + return n; +} + + /** * Get jitter buffer statistics *