pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-mgw/+/39217?usp=email )
Change subject: mgw: Move force_ptime logic outside of main CRCX func handler
......................................................................
mgw: Move force_ptime logic outside of main CRCX func handler
Apply the forced value automatically during init, and then only
override it based on received input from MGCP when it has not been
forced by VTY config.
Change-Id: I02a92a090887caa8e05917a44c8b2351fa7b9b50
---
M include/osmocom/mgcp/mgcp_rtp_end.h
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_protocol.c
M src/libosmo-mgcp/mgcp_rtp_end.c
M src/libosmo-mgcp/mgcp_sdp.c
5 files changed, 28 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/17/39217/1
diff --git a/include/osmocom/mgcp/mgcp_rtp_end.h b/include/osmocom/mgcp/mgcp_rtp_end.h
index c08f00d..02554cb 100644
--- a/include/osmocom/mgcp/mgcp_rtp_end.h
+++ b/include/osmocom/mgcp/mgcp_rtp_end.h
@@ -11,6 +11,7 @@
/* 'mgcp_rtp_end': basically a wrapper around the RTP+RTCP ports */
struct mgcp_rtp_end {
+ struct mgcp_conn_rtp *conn_rtp; /* backpointer */
/* remote IP address of the RTP socket */
struct osmo_sockaddr addr;
@@ -45,7 +46,8 @@
char local_addr[INET6_ADDRSTRLEN];
};
-void mgcp_rtp_end_init(struct mgcp_rtp_end *end);
+void mgcp_rtp_end_init(struct mgcp_rtp_end *end, struct mgcp_conn_rtp *conn_rtp);
void mgcp_rtp_end_cleanup(struct mgcp_rtp_end *end);
+void mgcp_rtp_end_set_packet_duration_ms(struct mgcp_rtp_end *end, uint32_t
packet_duration_ms);
bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end);
void mgcp_rtp_end_free_port(struct mgcp_rtp_end *end);
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 088d3e3..48a9f19 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -112,7 +112,7 @@
conn_rtp->state.in_stream.err_ts_ctr = rate_ctr_group_get_ctr(conn_rtp->ctrg,
IN_STREAM_ERR_TSTMP_CTR);
conn_rtp->state.out_stream.err_ts_ctr = rate_ctr_group_get_ctr(conn_rtp->ctrg,
OUT_STREAM_ERR_TSTMP_CTR);
- mgcp_rtp_end_init(&conn_rtp->end);
+ mgcp_rtp_end_init(&conn_rtp->end, conn_rtp);
return 0;
}
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 45f2c4f..48bb28b 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1089,11 +1089,6 @@
rc = mgcp_conn_iuup_init(conn_rtp);
}
- if (pdata->cfg->force_ptime) {
- conn_rtp->end.packet_duration_ms = pdata->cfg->force_ptime;
- conn_rtp->end.force_output_ptime = 1;
- }
-
mgcp_rtp_end_config(endp, 0, &conn_rtp->end);
/* Find a local address for conn based on policy and initial SDP remote
diff --git a/src/libosmo-mgcp/mgcp_rtp_end.c b/src/libosmo-mgcp/mgcp_rtp_end.c
index e48eaeb..c9dbc54 100644
--- a/src/libosmo-mgcp/mgcp_rtp_end.c
+++ b/src/libosmo-mgcp/mgcp_rtp_end.c
@@ -30,13 +30,19 @@
#include <osmocom/core/osmo_io.h>
#include <osmocom/mgcp/mgcp_rtp_end.h>
#include <osmocom/mgcp/mgcp_codec.h>
+#include <osmocom/mgcp/mgcp_conn.h>
+#include <osmocom/mgcp/mgcp_endp.h>
+#include <osmocom/mgcp/mgcp_trunk.h>
/***********************
* mgcp_rtp_end
**********************/
-void mgcp_rtp_end_init(struct mgcp_rtp_end *end)
+void mgcp_rtp_end_init(struct mgcp_rtp_end *end, struct mgcp_conn_rtp *conn_rtp)
{
+ struct mgcp_config *cfg = conn_rtp->conn->endp->trunk->cfg;
+
+ end->conn_rtp = conn_rtp;
end->rtp = NULL;
end->rtcp = NULL;
memset(&end->addr, 0, sizeof(end->addr));
@@ -44,10 +50,17 @@
/* Set default values */
end->frames_per_packet = 0; /* unknown */
- end->packet_duration_ms = DEFAULT_RTP_AUDIO_PACKET_DURATION_MS;
end->output_enabled = false;
end->maximum_packet_time = -1;
+
+ if (cfg->force_ptime) {
+ end->packet_duration_ms = cfg->force_ptime;
+ end->force_output_ptime = 1;
+ } else {
+ end->packet_duration_ms = DEFAULT_RTP_AUDIO_PACKET_DURATION_MS;
+ }
+
/* Make sure codec table is reset */
mgcp_codecset_reset(&end->cset);
}
@@ -58,6 +71,13 @@
mgcp_codecset_reset(&end->cset);
}
+void mgcp_rtp_end_set_packet_duration_ms(struct mgcp_rtp_end *end, uint32_t
packet_duration_ms)
+{
+ if (end->force_output_ptime)
+ return;
+ end->packet_duration_ms = packet_duration_ms;
+}
+
bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end)
{
return (osmo_sockaddr_port(&rtp_end->addr.u.sa) != 0) &&
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 4d13388..ffd0f18 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -361,9 +361,9 @@
if (sscanf(line, "a=ptime:%d-%d", &ptime, &ptime2) >= 1) {
if (ptime2 > 0 && ptime2 != ptime)
- rtp->packet_duration_ms = 0;
+ mgcp_rtp_end_set_packet_duration_ms(rtp, 0);
else
- rtp->packet_duration_ms = ptime;
+ mgcp_rtp_end_set_packet_duration_ms(rtp, ptime);
break;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-mgw/+/39217?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I02a92a090887caa8e05917a44c8b2351fa7b9b50
Gerrit-Change-Number: 39217
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>