aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-09-08 14:42:58 +0200
committerHarald Welte <laforge@gnumonks.org>2011-09-08 14:42:58 +0200
commit65a50893d5f9577c17dc4485d585c12d349c8e30 (patch)
tree2d71278ca34b7b07b249705fb80f8f82fda3be1f
parentddfaca45feda2f07481fb4a7d70c303fe7b70e29 (diff)
add osmo_rtp_socket_set_param() and osmo_rtp_socket_log_stats()
-rw-r--r--include/osmocom/trau/osmo_ortp.h11
-rw-r--r--src/trau/osmo_ortp.c42
2 files changed, 53 insertions, 0 deletions
diff --git a/include/osmocom/trau/osmo_ortp.h b/include/osmocom/trau/osmo_ortp.h
index 5b350ce2..2d32b02f 100644
--- a/include/osmocom/trau/osmo_ortp.h
+++ b/include/osmocom/trau/osmo_ortp.h
@@ -21,6 +21,11 @@ struct _RtpSession;
/*! \brief Osmocom pseudo-static paylaod type for Adaptive Multi Rate (AMR) */
#define RTP_PT_AMR 98
+/*! \brief Parameter to osmo_rtp_socket_param_set() */
+enum osmo_rtp_param {
+ OSMO_RTP_P_JITBUF = 1,
+ OSMO_RTP_P_JIT_ADAP,
+};
/*! \brief Flag to indicate the socket is in polling-only mode */
#define OSMO_RTP_F_POLL 0x0001
@@ -67,5 +72,11 @@ int osmo_rtp_get_bound_ip_port(struct osmo_rtp_socket *rs,
uint32_t *ip, int *port);
int osmo_rtp_get_bound_addr(struct osmo_rtp_socket *rs,
const char **addr, int *port);
+int osmo_rtp_socket_set_param(struct osmo_rtp_socket *rs,
+ enum osmo_rtp_param param, int val);
+
+void osmo_rtp_socket_log_stats(struct osmo_rtp_socket *rs,
+ int subsys, int level,
+ const char *pfx);
#endif /* _OSMO_ORTP_H */
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index cac25089..be1d1c03 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -23,6 +23,7 @@
*/
#include <stdint.h>
+#include <inttypes.h>
#include <netdb.h>
#include <osmocom/core/logging.h>
@@ -32,6 +33,7 @@
#include <osmocom/trau/osmo_ortp.h>
#include <ortp/ortp.h>
+#include <ortp/rtp.h>
static PayloadType *payload_type_efr;
@@ -248,6 +250,27 @@ void osmo_rtp_init(void *ctx)
create_payload_types();
}
+int osmo_rtp_socket_set_param(struct osmo_rtp_socket *rs,
+ enum osmo_rtp_param param, int val)
+{
+ int rc = 0;
+
+ switch (param) {
+ case OSMO_RTP_P_JITBUF:
+ rtp_session_set_jitter_compensation(rs->sess, val);
+ break;
+#if 0
+ case OSMO_RTP_P_JIT_ADAP:
+ rc = jitter_control_enable_adaptive(rs->sess, val);
+ break;
+#endif
+ default:
+ return -EINVAL;
+ }
+
+ return rc;
+}
+
/*! \brief Create a new RTP socket
* \param[in] talloc_cxt talloc context for this allocation. NULL for
* dafault context
@@ -466,3 +489,22 @@ int osmo_rtp_get_bound_addr(struct osmo_rtp_socket *rs,
return 0;
}
+
+
+void osmo_rtp_socket_log_stats(struct osmo_rtp_socket *rs,
+ int subsys, int level,
+ const char *pfx)
+{
+ const rtp_stats_t *stats;
+
+ stats = rtp_session_get_stats(rs->sess);
+ if (!stats)
+ return;
+
+ LOGP(subsys, level, "%sRTP Tx(%"PRIu64" pkts, %"PRIu64" bytes) "
+ "Rx(%"PRIu64" pkts, %"PRIu64" bytes, %"PRIu64" late, "
+ "%"PRIu64" loss, %"PRIu64" qmax)\n",
+ pfx, stats->packet_sent, stats->sent,
+ stats->packet_recv, stats->hw_recv, stats->outoftime,
+ stats->cum_packet_loss, stats->discarded);
+}