mgcp_stat: Don't print osmux stats if it is off

Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
diff --git a/src/libosmo-mgcp/mgcp_stat.c b/src/libosmo-mgcp/mgcp_stat.c
index 88a2d69..581130c 100644
--- a/src/libosmo-mgcp/mgcp_stat.c
+++ b/src/libosmo-mgcp/mgcp_stat.c
@@ -23,6 +23,7 @@
  */
 
 #include <osmocom/mgcp/mgcp_stat.h>
+#include <osmocom/mgcp/mgcp_endp.h>
 #include <limits.h>
 
 /* Helper function for mgcp_format_stats_rtp() to calculate packet loss */
@@ -83,21 +84,23 @@
 	str += nchars;
 	str_len -= nchars;
 
-	/* Error Counter */
-	nchars = snprintf(str, str_len,
-			  "\r\nX-Osmo-CP: EC TI=%u, TO=%u",
-			  conn->state.in_stream.err_ts_counter,
-			  conn->state.out_stream.err_ts_counter);
-	if (nchars < 0 || nchars >= str_len)
-		goto truncate;
+	if (conn->conn->endp->cfg->osmux != OSMUX_USAGE_OFF) {
+		/* Error Counter */
+		nchars = snprintf(str, str_len,
+				  "\r\nX-Osmo-CP: EC TI=%u, TO=%u",
+				  conn->state.in_stream.err_ts_counter,
+				  conn->state.out_stream.err_ts_counter);
+		if (nchars < 0 || nchars >= str_len)
+			goto truncate;
 
-	str += nchars;
-	str_len -= nchars;
+		str += nchars;
+		str_len -= nchars;
 
-	if (conn->osmux.state == OSMUX_STATE_ENABLED) {
-		snprintf(str, str_len,
-			 "\r\nX-Osmux-ST: CR=%u, BR=%u",
-			 conn->osmux.stats.chunks, conn->osmux.stats.octets);
+		if (conn->osmux.state == OSMUX_STATE_ENABLED) {
+			snprintf(str, str_len,
+				 "\r\nX-Osmux-ST: CR=%u, BR=%u",
+				 conn->osmux.stats.chunks, conn->osmux.stats.octets);
+		}
 	}
 
 truncate: