aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/bsc/mgw_endpoint_fsm.h2
-rw-r--r--src/osmo-bsc/bsc_subscr_conn_fsm.c2
-rw-r--r--src/osmo-bsc/lchan_rtp_fsm.c4
-rw-r--r--src/osmo-bsc/mgw_endpoint_fsm.c32
-rw-r--r--src/osmo-bsc/osmo_bsc_lcls.c4
5 files changed, 37 insertions, 7 deletions
diff --git a/include/osmocom/bsc/mgw_endpoint_fsm.h b/include/osmocom/bsc/mgw_endpoint_fsm.h
index 34fdcb76a..e264a3c8b 100644
--- a/include/osmocom/bsc/mgw_endpoint_fsm.h
+++ b/include/osmocom/bsc/mgw_endpoint_fsm.h
@@ -56,4 +56,4 @@ const char *mgwep_ci_name(const struct mgwep_ci *ci);
const char *mgcp_conn_peer_name(const struct mgcp_conn_peer *info);
enum mgcp_codecs chan_mode_to_mgcp_codec(enum gsm48_chan_mode chan_mode, bool full_rate);
-void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan);
+void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side);
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index fd3c2931f..81fe9f6cc 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -491,7 +491,7 @@ bool gscon_connect_mgw_to_msc(struct gsm_subscriber_connection *conn,
.call_id = conn->sccp.conn_id,
.ptime = 20,
};
- mgcp_pick_codec(&mgw_info, for_lchan);
+ mgcp_pick_codec(&mgw_info, for_lchan, false);
rc = osmo_strlcpy(mgw_info.addr, addr, sizeof(mgw_info.addr));
if (rc <= 0 || rc >= sizeof(mgw_info.addr)) {
diff --git a/src/osmo-bsc/lchan_rtp_fsm.c b/src/osmo-bsc/lchan_rtp_fsm.c
index f7efc1ba8..2cc9a781c 100644
--- a/src/osmo-bsc/lchan_rtp_fsm.c
+++ b/src/osmo-bsc/lchan_rtp_fsm.c
@@ -157,7 +157,7 @@ static void lchan_rtp_fsm_wait_mgw_endpoint_available_onenter(struct osmo_fsm_in
if (lchan->conn)
crcx_info.call_id = lchan->conn->sccp.conn_id;
crcx_info.ptime = 20;
- mgcp_pick_codec(&crcx_info, lchan);
+ mgcp_pick_codec(&crcx_info, lchan, true);
mgw_endpoint_ci_request(lchan->mgw_endpoint_ci_bts, MGCP_VERB_CRCX, &crcx_info,
fi, LCHAN_RTP_EV_MGW_ENDPOINT_AVAILABLE, LCHAN_RTP_EV_MGW_ENDPOINT_ERROR,
@@ -406,7 +406,7 @@ static void connect_mgw_endpoint_to_lchan(struct osmo_fsm_inst *fi,
.port = to_lchan->abis_ip.bound_port,
.ptime = 20,
};
- mgcp_pick_codec(&mdcx_info, to_lchan);
+ mgcp_pick_codec(&mdcx_info, to_lchan, true);
addr.s_addr = ntohl(to_lchan->abis_ip.bound_ip);
addr_str = inet_ntoa(addr);
diff --git a/src/osmo-bsc/mgw_endpoint_fsm.c b/src/osmo-bsc/mgw_endpoint_fsm.c
index 18e9dcf5b..fc49886c3 100644
--- a/src/osmo-bsc/mgw_endpoint_fsm.c
+++ b/src/osmo-bsc/mgw_endpoint_fsm.c
@@ -26,6 +26,7 @@
#include <osmocom/core/fsm.h>
#include <osmocom/core/byteswap.h>
+#include <osmocom/netif/rtp.h>
#include <osmocom/bsc/debug.h>
#include <osmocom/bsc/gsm_timers.h>
@@ -730,10 +731,31 @@ enum mgcp_codecs chan_mode_to_mgcp_codec(enum gsm48_chan_mode chan_mode, bool fu
}
}
-void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan)
+int chan_mode_to_mgcp_bss_pt(enum mgcp_codecs codec)
+{
+ switch (codec) {
+ case CODEC_GSMHR_8000_1:
+ return RTP_PT_GSM_HALF;
+
+ case CODEC_GSMEFR_8000_1:
+ return RTP_PT_GSM_EFR;
+
+ case CODEC_AMR_8000_1:
+ return RTP_PT_AMR;
+
+ default:
+ /* Not an error, we just leave it to libosmo-mgcp-client to
+ * decide over the PT. */
+ return -1;
+ }
+}
+
+void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side)
{
enum mgcp_codecs codec = chan_mode_to_mgcp_codec(lchan->tch_mode,
lchan->type == GSM_LCHAN_TCH_H? false : true);
+ int custom_pt;
+
if (codec < 0) {
LOG_LCHAN(lchan, LOGL_ERROR,
"Unable to determine MGCP codec type for %s in chan-mode %s\n",
@@ -744,4 +766,12 @@ void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *l
verb_info->codecs[0] = codec;
verb_info->codecs_len = 1;
+
+ /* Setup custom payload types (only for BSS side and when required) */
+ custom_pt = chan_mode_to_mgcp_bss_pt(codec);
+ if (bss_side && custom_pt > 0) {
+ verb_info->ptmap[0].codec = codec;
+ verb_info->ptmap[0].pt = custom_pt;
+ verb_info->ptmap_len = 1;
+ }
}
diff --git a/src/osmo-bsc/osmo_bsc_lcls.c b/src/osmo-bsc/osmo_bsc_lcls.c
index 04826615b..4639c4e36 100644
--- a/src/osmo-bsc/osmo_bsc_lcls.c
+++ b/src/osmo-bsc/osmo_bsc_lcls.c
@@ -242,7 +242,7 @@ static void lcls_break_local_switching(struct gsm_subscriber_connection *conn)
.port = conn->user_plane.msc_assigned_rtp_port,
};
osmo_strlcpy(mdcx_info.addr, conn->user_plane.msc_assigned_rtp_addr, sizeof(mdcx_info.addr));
- mgcp_pick_codec(&mdcx_info, conn->lchan);
+ mgcp_pick_codec(&mdcx_info, conn->lchan, false);
mgw_endpoint_ci_request(conn->user_plane.mgw_endpoint_ci_msc,
MGCP_VERB_MDCX, &mdcx_info,
@@ -573,7 +573,7 @@ static void lcls_locally_switched_onenter(struct osmo_fsm_inst *fi, uint32_t pre
mdcx_info = *other_mgw_info;
/* Make sure the request doesn't want to use the other side's endpoint string. */
mdcx_info.endpoint[0] = 0;
- mgcp_pick_codec(&mdcx_info, conn->lchan);
+ mgcp_pick_codec(&mdcx_info, conn->lchan, false);
mgw_endpoint_ci_request(conn->user_plane.mgw_endpoint_ci_msc,
MGCP_VERB_MDCX, &mdcx_info,
NULL, 0, 0, NULL);