stats: use libosmocore rate counter for in/out_stream.err_ts_counter
The two counters: in_stream.err_ts_counter and out_stream.err_ts_counter
are still handcoded. To make them better accessible they should
be replaced with libosmocore rate counters.
- replace state.in_stream.err_ts_counter with libosmocore rate counter
- replace state.out_stream.err_ts_counter with libosmocore rate counter
Change-Id: I67aa7a8602f60366ef3ba2c5b1319b1b85719f64
Related: OS#2517
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 998dbc5..0055049 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -26,8 +26,28 @@
#include <osmocom/mgcp/mgcp_common.h>
#include <osmocom/mgcp/mgcp_endp.h>
#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/core/rate_ctr.h>
#include <ctype.h>
+const static struct rate_ctr_desc rate_ctr_desc[] = {
+ {
+ .name = "in_stream_err_ts_ctr",
+ .description = "inbound rtp-stream timestamp errors",
+ },{
+ .name = "out_stream_err_ts_ctr",
+ .description = "outbound rtp-stream timestamp errors",
+ }
+};
+
+const static struct rate_ctr_group_desc rate_ctr_group_desc = {
+ .group_name_prefix = "conn_rtp",
+ .group_description = "rtp connection statistics",
+ .class_id = 1,
+ .num_ctr = 2,
+ .ctr_desc = rate_ctr_desc
+};
+
+
/* Allocate a new connection identifier. According to RFC3435, they must
* be unique only within the scope of the endpoint. (Caller must provide
* memory for id) */
@@ -87,6 +107,10 @@
static void mgcp_rtp_conn_init(struct mgcp_conn_rtp *conn_rtp, struct mgcp_conn *conn)
{
struct mgcp_rtp_end *end = &conn_rtp->end;
+ /* FIXME: Each new rate counter group requires an unique index. At the
+ * moment we generate this index using this counter, but perhaps there
+ * is a more concious way to assign the indexes. */
+ static unsigned int rate_ctr_index = 0;
conn_rtp->type = MGCP_RTP_DEFAULT;
conn_rtp->osmux.allocated_cid = -1;
@@ -108,6 +132,15 @@
mgcp_rtp_codec_init(&end->codec);
mgcp_rtp_codec_init(&end->alt_codec);
+
+ conn_rtp->rate_ctr_group =
+ rate_ctr_group_alloc(conn, &rate_ctr_group_desc,
+ rate_ctr_index);
+ conn_rtp->state.in_stream.err_ts_ctr =
+ &conn_rtp->rate_ctr_group->ctr[0];
+ conn_rtp->state.out_stream.err_ts_ctr =
+ &conn_rtp->rate_ctr_group->ctr[1];
+ rate_ctr_index++;
}
/* Cleanup rtp connection struct */
@@ -116,6 +149,7 @@
osmux_disable_conn(conn_rtp);
osmux_release_cid(conn_rtp);
mgcp_free_rtp_port(&conn_rtp->end);
+ rate_ctr_group_free(conn_rtp->rate_ctr_group);
}
/*! allocate a new connection list entry.