From 317e197b0b7093a18112d8e5c22b86092044bad9 Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Thu, 25 Jul 2019 17:44:15 +0000 Subject: [PATCH] FS-11959: add switch_jb_get_packets_per_frame() - gets the number of packets per video frame --- src/include/switch_jitterbuffer.h | 1 + src/switch_jitterbuffer.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/include/switch_jitterbuffer.h b/src/include/switch_jitterbuffer.h index d21b343c6b..bee0fa02f8 100644 --- a/src/include/switch_jitterbuffer.h +++ b/src/include/switch_jitterbuffer.h @@ -65,6 +65,7 @@ SWITCH_DECLARE(void) switch_jb_ts_mode(switch_jb_t *jb, uint32_t samples_per_fra SWITCH_DECLARE(void) switch_jb_set_flag(switch_jb_t *jb, switch_jb_flag_t flag); SWITCH_DECLARE(void) switch_jb_clear_flag(switch_jb_t *jb, switch_jb_flag_t flag); SWITCH_DECLARE(uint32_t) switch_jb_get_nack_success(switch_jb_t *jb); +SWITCH_DECLARE(uint32_t) switch_jb_get_packets_per_frame(switch_jb_t *jb); SWITCH_END_EXTERN_C #endif diff --git a/src/switch_jitterbuffer.c b/src/switch_jitterbuffer.c index 38e07b67f4..9d8e8c7e1c 100644 --- a/src/switch_jitterbuffer.c +++ b/src/switch_jitterbuffer.c @@ -986,6 +986,15 @@ SWITCH_DECLARE(uint32_t) switch_jb_get_nack_success(switch_jb_t *jb) return nack_recovered; } +SWITCH_DECLARE(uint32_t) switch_jb_get_packets_per_frame(switch_jb_t *jb) +{ + uint32_t ppf; + switch_mutex_lock(jb->mutex); + ppf = jb->packet_count; /* get current packets per frame */ + switch_mutex_unlock(jb->mutex); + return ppf; +} + SWITCH_DECLARE(switch_status_t) switch_jb_peek_frame(switch_jb_t *jb, uint32_t ts, uint16_t seq, int peek, switch_frame_t *frame) { switch_jb_node_t *node = NULL;