Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
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 Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-CC: neels Gerrit-MessageType: merged
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, laforge, pespin, dexter. osmith has posted comments on 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 .. Patch Set 5: Code-Review+2 -- 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: 5 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-Attention: dexter Gerrit-Comment-Date: Wed, 26 Oct 2022 09:30:48 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, laforge, dexter. pespin has posted comments on 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 .. Patch Set 4: (1 comment) File src/libosmo-mgcp/mgcp_network.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/df93c82d_cd7dc1bd PS2, Line 723: * boundaries. This function is used to convert between the two modes */ > Ack. It should probably become a .a library that's linked and never installed. It should be merged into the same binary, moved into osmo-mgw directory. There's no benefit in having it separated, it creates problems with logging categories, etc. -- 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: 4 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: laforge Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: laforge Gerrit-Attention: dexter Gerrit-Comment-Date: Tue, 25 Oct 2022 16:21:20 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: neels Comment-In-Reply-To: laforge Comment-In-Reply-To: pespin Comment-In-Reply-To: dexter Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, pespin, dexter. laforge has posted comments on 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 .. Patch Set 4: Code-Review+1 -- 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: 4 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Reviewer: laforge Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: pespin Gerrit-Attention: dexter Gerrit-Comment-Date: Tue, 25 Oct 2022 15:39:50 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, pespin, dexter. laforge has posted comments on 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 .. Patch Set 4: (1 comment) File src/libosmo-mgcp/mgcp_network.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/834aab53_f5dc09d7 PS2, Line 723: * boundaries. This function is used to convert between the two modes */ > The libosmo-mgcp is actually internal to osmo-mgw, and IMHO should be dropped > completely and merged […] Ack. It should probably become a .a library that's linked and never installed. -- 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: 4 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-CC: laforge Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: pespin Gerrit-Attention: dexter Gerrit-Comment-Date: Tue, 25 Oct 2022 15:39:46 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: neels Comment-In-Reply-To: pespin Comment-In-Reply-To: dexter Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, dexter. Hello Jenkins Builder, dexter, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-mgw/+/29867 to look at the new patch set (#4). 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(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/67/29867/4 -- 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: 4 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: dexter Gerrit-MessageType: newpatchset
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, dexter. Jenkins Builder has posted comments on 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 .. Patch Set 3: (1 comment) File src/libosmo-mgcp/mgcp_network.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-421): https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/e8b33726_beb3086e PS3, Line 726: * For AMR RTP two framing modes are defined RFC3267. There is a bandwith 'bandwith' may be misspelled - perhaps 'bandwidth'? -- 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: 3 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: dexter Gerrit-Comment-Date: Tue, 25 Oct 2022 11:53:21 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, dexter. Hello Jenkins Builder, dexter, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-mgw/+/29867 to look at the new patch set (#3). 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(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/67/29867/3 -- 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: 3 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: dexter Gerrit-MessageType: newpatchset
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: neels, dexter. pespin has posted comments on 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 .. Patch Set 2: (2 comments) File src/libosmo-mgcp/mgcp_network.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/0696a7a6_be0a62ee PS2, Line 723: * boundaries. This function is used to convert between the two modes */ > ack, especially if this is now public libosmo-mgcp API The libosmo-mgcp is actually internal to osmo-mgw, and IMHO should be dropped completely and merged into osmo-mgw since it causes more trouble than benefits. File src/libosmo-mgcp/mgcp_osmux.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/11f64398_66bef826 PS2, Line 230: /* Osmux implementation works with AMR OA only, make sure we convert to it if needed: */ > i would prefer having two patches, 1) the API change to use msgb and 2) > adding the conversion to OA […] Ack -- 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: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-CC: neels Gerrit-Attention: neels Gerrit-Attention: dexter Gerrit-Comment-Date: Tue, 25 Oct 2022 11:22:58 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: neels Comment-In-Reply-To: dexter Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: pespin, dexter. neels has posted comments on 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 .. Patch Set 2: (2 comments) File src/libosmo-mgcp/mgcp_network.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/78ca37c0_3c2b3d8e PS2, Line 723: * boundaries. This function is used to convert between the two modes */ > Since this function was static before there was not doxygen apidoc added. […] ack, especially if this is now public libosmo-mgcp API File src/libosmo-mgcp/mgcp_osmux.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/4971680f_f3bf2a42 PS2, Line 230: /* Osmux implementation works with AMR OA only, make sure we convert to it if needed: */ i would prefer having two patches, 1) the API change to use msgb and 2) adding the conversion to OA The actual conversion to OA seems to be a very short bit that is orthogonal to the rest, reads cluttered -- 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: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-CC: neels Gerrit-Attention: pespin Gerrit-Attention: dexter Gerrit-Comment-Date: Mon, 24 Oct 2022 20:54:27 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: dexter Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: pespin. dexter has posted comments on 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 .. Patch Set 2: Code-Review+1 (2 comments) Patchset: PS2: I didn't try it out, but it looks technically ok to me. File src/libosmo-mgcp/mgcp_network.c: https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/0fd0ba11_bb9a7100 PS2, Line 723: * boundaries. This function is used to convert between the two modes */ Since this function was static before there was not doxygen apidoc added. Maybe you can add Apidoc now so that it is uniform. Maybe its also good to prefix the function with mgcp_ so that it is like the other functions in this file. -- 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: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter Gerrit-Attention: pespin Gerrit-Comment-Date: Mon, 24 Oct 2022 19:13:24 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-mgw/+/29867 to look at the new patch set (#2). 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 include/osmocom/mgcp/osmux.h M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_osmux.c 4 files changed, 18 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/67/29867/2 -- 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: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: pespin Gerrit-MessageType: newpatchset
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
Jenkins Builder has posted comments on 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 .. Patch Set 1: (1 comment) File src/libosmo-mgcp/mgcp_osmux.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-398): https://gerrit.osmocom.org/c/osmo-mgw/+/29867/comment/faa83a06_4cca9540 PS1, Line 229: memcpy(msg2->data, (char*)msgb_data(msg), msgb_length(msg)); "(foo*)" should be "(foo *)" -- 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: 1 Gerrit-Owner: pespin Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Mon, 24 Oct 2022 16:33:37 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in osmo-mgw[master]: osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
pespin has uploaded this change for review. ( 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 include/osmocom/mgcp/osmux.h M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_osmux.c 4 files changed, 20 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/67/29867/1 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/include/osmocom/mgcp/osmux.h b/include/osmocom/mgcp/osmux.h index 044a33f..4ea6da7 100644 --- a/include/osmocom/mgcp/osmux.h +++ b/include/osmocom/mgcp/osmux.h @@ -15,7 +15,7 @@ int conn_osmux_enable(struct mgcp_conn_rtp *conn); void conn_osmux_disable(struct mgcp_conn_rtp *conn); int conn_osmux_event_rx_crcx_mdcx(struct mgcp_conn_rtp *conn); -int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn); +int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg); int osmux_send_dummy(struct mgcp_conn_rtp *conn); void osmux_cid_pool_get(uint8_t osmux_cid); diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index 960b496..b4599f2 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -721,7 +721,7 @@ * 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, +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 @@ -1013,7 +1013,7 @@ LOGPENDP(endp, DRTP, LOGL_DEBUG, "endpoint type is MGCP_RTP_OSMUX, " "using osmux_xfrm_to_osmux() to forward data through OSMUX\n"); - return osmux_xfrm_to_osmux((char*)msgb_data(msg), msgb_length(msg), conn_dst); + return conn_osmux_send_rtp(conn_dst, msg); case MGCP_RTP_IUUP: if (proto == MGCP_PROTO_RTP) { LOGPENDP(endp, DRTP, LOGL_DEBUG, diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index 0fd1ba7..4e58452 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -205,10 +205,10 @@ * \param[in] buf_len length of rtp data * \param[in] conn associated RTP connection * \returns 0 on success, -1 on ERROR */ -int osmux_xfrm_to_osmux(char *buf, int buf_len, struct mgcp_conn_rtp *conn) +int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg) { int ret; - struct msgb *msg; + struct msgb *msg2; if (!conn->end.output_enabled) { rtpconn_osmux_rate_ctr_inc(conn, OSMUX_RTP_PACKETS_TX_DROPPED_CTR); @@ -222,14 +222,21 @@ return -1; } - msg = msgb_alloc(4096, "RTP"); - if (!msg) + /* msg is not owned by us and will be freed by the caller stack upon return: */ + msg2 = msgb_alloc(4096, "RTP"); + if (!msg2) return -1; + memcpy(msg2->data, (char*)msgb_data(msg), msgb_length(msg)); + msgb_put(msg2, msgb_length(msg)); - memcpy(msg->data, buf, buf_len); - msgb_put(msg, buf_len); + /* 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, msg, conn->osmux.remote_cid)) > 0) { + while ((ret = osmux_xfrm_input(conn->osmux.in, msg2, conn->osmux.remote_cid)) > 0) { /* batch full, build and deliver it */