pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29867 )
Change subject: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode ...................................................................... osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode The Osmux implementation in libosmo-netif expects to work with RTP AMR in octet-aligned mode. Therefore, if the peer connection received RTP AMR in bandwidth-efficient mode, we need to convert it to octet-aligned before feeding the packets to the osmux layer. Related: SYS#6161 Change-Id: Ifeec44241079f7a31da12745c92bfdc4fb222f3a --- M include/osmocom/mgcp/mgcp_network.h M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_osmux.c 3 files changed, 18 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/include/osmocom/mgcp/mgcp_network.h b/include/osmocom/mgcp/mgcp_network.h index a3d57f0..e95907d 100644 --- a/include/osmocom/mgcp/mgcp_network.h +++ b/include/osmocom/mgcp/mgcp_network.h @@ -183,3 +183,5 @@ int id); void forward_data_tap(int fd, struct mgcp_rtp_tap *tap, struct msgb *msg); uint32_t mgcp_get_current_ts(unsigned codec_rate); + +int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg, bool target_is_oa); diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index 3248cbd..72d97fd 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -717,11 +717,18 @@ return 0; } -/* For AMR RTP two framing modes are defined RFC3267. There is a bandwith +/*! Convert msg to AMR RTP framing mode specified by target_is_oa. + * \param[in] endp MGCP Endpoint where this message belongs to (used for logging purposes) + * \param[in] msg Message containing an AMR RTP payload (in octet-aligned or bandwidth-efficient format). + * \param[in] target_is_oa the target framing mode that msg will contain after this function succeeds. + * \returns The size of the new RTP AMR content on success, negative on error. + * + * For AMR RTP two framing modes are defined RFC3267. There is a bandwidth * efficient encoding scheme where all fields are packed together one after * another and an octet aligned mode where all fields are aligned to octet - * boundaries. This function is used to convert between the two modes */ -static int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg, + * boundaries. This function is used to convert between the two modes. + */ +int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg, bool target_is_oa) { /* NOTE: the msgb has an allocated length of RTP_BUF_SIZE, so there is diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index e1380ec..5df5446 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -226,6 +226,12 @@ if (!msg2) return -1; + /* Osmux implementation works with AMR OA only, make sure we convert to it if needed: */ + if (amr_oa_bwe_convert(conn->conn->endp, msg2, true) < 0) { + LOGPCONN(conn->conn, DOSMUX, LOGL_ERROR, + "Error converting to AMR octet-aligned mode\n"); + return -1; + } while ((ret = osmux_xfrm_input(conn->osmux.in, msg2, conn->osmux.remote_cid)) > 0) { /* batch full, build and deliver it */ 5 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29867 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: Ifeec44241079f7a31da12745c92bfdc4fb222f3a Gerrit-Change-Number: 29867 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pma...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-CC: neels <nhofm...@sysmocom.de> Gerrit-MessageType: merged