mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-02 21:13:44 +00:00
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
This commit is contained in:
@@ -183,3 +183,5 @@ void rtpconn_rate_ctr_inc(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *
|
||||
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);
|
||||
|
||||
@@ -717,11 +717,18 @@ static int rfc5993_hr_convert(struct mgcp_endpoint *endp, struct msgb *msg)
|
||||
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
|
||||
|
||||
@@ -226,6 +226,12 @@ int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg)
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user