From fe01908428d9745e7d111a0902d3d090d0090f91 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 21 Sep 2015 10:52:52 +0200 Subject: ortp: Export statistics for the bts or similar We might want to know how many things arrived at the BTS and ortp is already counting for us. We don't intend to use RTCP so I am not sure what the last "sender report" is and how accurate the jitter is. --- include/osmocom/trau/osmo_ortp.h | 6 ++++++ src/trau/osmo_ortp.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/osmocom/trau/osmo_ortp.h b/include/osmocom/trau/osmo_ortp.h index 2d32b02..c02cca8 100644 --- a/include/osmocom/trau/osmo_ortp.h +++ b/include/osmocom/trau/osmo_ortp.h @@ -79,4 +79,10 @@ void osmo_rtp_socket_log_stats(struct osmo_rtp_socket *rs, int subsys, int level, const char *pfx); +void osmo_rtp_socket_stats(struct osmo_rtp_socket *rs, + uint32_t *sent_packets, uint32_t *sent_octets, + uint32_t *recv_packets, uint32_t *recv_octets, + uint32_t *recv_lost, uint32_t *last_jitter); + + #endif /* _OSMO_ORTP_H */ diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c index fedc977..7edcd03 100644 --- a/src/trau/osmo_ortp.c +++ b/src/trau/osmo_ortp.c @@ -546,3 +546,29 @@ void osmo_rtp_socket_log_stats(struct osmo_rtp_socket *rs, stats->packet_recv, stats->hw_recv, stats->outoftime, stats->cum_packet_loss, stats->discarded); } + +void osmo_rtp_socket_stats(struct osmo_rtp_socket *rs, + uint32_t *sent_packets, uint32_t *sent_octets, + uint32_t *recv_packets, uint32_t *recv_octets, + uint32_t *recv_lost, uint32_t *last_jitter) +{ + const rtp_stats_t *stats; + const jitter_stats_t *jitter; + + *sent_packets = *sent_octets = *recv_packets = *recv_octets = 0; + *recv_lost = *last_jitter = 0; + + stats = rtp_session_get_stats(rs->sess); + if (stats) { + /* truncate from 64bit to 32bit here */ + *sent_packets = stats->packet_sent; + *sent_octets = stats->sent; + *recv_packets = stats->packet_recv; + *recv_octets = stats->recv; + *recv_lost = stats->cum_packet_loss; + } + + jitter = rtp_session_get_jitter_stats(rs->sess); + if (jitter) + *last_jitter = jitter->jitter; +} -- cgit v1.2.3