laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-mgw/+/36356?usp=email )


Change subject: remove strange loop for non-existant transcoding support
......................................................................

remove strange loop for non-existant transcoding support

The existing support preparing the mgw for transcoding (which doesn't exist)
has some kind of method where the transcoding function might be called
multiple times in a row.  However, as it is not used, it is not entirely
clear how it was intended to work.  Let's remove this unused looping
feature which makes it hard to understand how upcoming osmo_io should
deal with it.

Change-Id: Ie1a629fd31c5ab806fc929d1e6b279c4be5b8246
---
M src/libosmo-mgcp/mgcp_network.c
1 file changed, 59 insertions(+), 49 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/56/36356/1

diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 111c5cf..31c02d2 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1168,70 +1168,64 @@
                         osmo_sockaddr_port(&rtp_end->addr.u.sa), 
ntohs(rtp_end->rtcp_port)
                    );
        } else if (is_rtp) {
-               int cont;
-               int nbytes = 0;
                int buflen = msgb_length(msg);

                /* Make sure we have a valid RTP header, in cases where no RTP
                 * header is present, we will generate one. */
                gen_rtp_header(msg, rtp_end, rtp_state);

-               do {
-                       /* Run transcoder */
-                       cont = endp->trunk->cfg->rtp_processing_cb(endp, 
rtp_end, (char *)msgb_data(msg), &buflen, RTP_BUF_SIZE);
-                       if (cont < 0)
-                               break;
+               /* Run transcoder */
+               rc = endp->trunk->cfg->rtp_processing_cb(endp, rtp_end, (char 
*)msgb_data(msg), &buflen, RTP_BUF_SIZE);
+               if (rc < 0) {
+                       LOGPENDP(endp, DRTP, LOGL_ERROR, "Error %d during 
transcoding\n", rc);
+                       return rc;
+               }

-                       if (addr)
-                               mgcp_patch_and_count(endp, rtp_state, rtp_end,
-                                                    addr, msg);
+               if (addr)
+                       mgcp_patch_and_count(endp, rtp_state, rtp_end, addr, 
msg);

-                       if (mgcp_conn_rtp_is_iuup(conn_dst) || 
mgcp_conn_rtp_is_iuup(conn_src)) {
-                               /* the iuup code will correctly transform to 
the correct AMR mode */
-                       } else if 
(mgcp_codec_amr_align_mode_is_indicated(conn_dst->end.codec)) {
-                               rc = amr_oa_bwe_convert(endp, msg,
-                                                       
conn_dst->end.codec->param.amr_octet_aligned);
-                               if (rc < 0) {
-                                       LOGPENDP(endp, DRTP, LOGL_ERROR,
-                                                "Error in AMR octet-aligned 
<-> bandwidth-efficient mode conversion (target=%s)\n",
-                                                
conn_dst->end.codec->param.amr_octet_aligned ? "octet-aligned" : 
"bandwidth-efficient");
-                                       break;
-                               }
-                       } else if (rtp_end->rfc5993_hr_convert &&
-                                  strcmp(conn_src->end.codec->subtype_name, 
"GSM-HR-08") == 0) {
-                               rc = rfc5993_hr_convert(endp, msg);
-                               if (rc < 0) {
-                                       LOGPENDP(endp, DRTP, LOGL_ERROR, "Error 
while converting to GSM-HR-08\n");
-                                       break;
-                               }
+               if (mgcp_conn_rtp_is_iuup(conn_dst) || 
mgcp_conn_rtp_is_iuup(conn_src)) {
+                       /* the iuup code will correctly transform to the 
correct AMR mode */
+               } else if 
(mgcp_codec_amr_align_mode_is_indicated(conn_dst->end.codec)) {
+                       rc = amr_oa_bwe_convert(endp, msg, 
conn_dst->end.codec->param.amr_octet_aligned);
+                       if (rc < 0) {
+                               LOGPENDP(endp, DRTP, LOGL_ERROR,
+                                        "Error in AMR octet-aligned <-> 
bandwidth-efficient mode conversion (target=%s)\n",
+                                        
conn_dst->end.codec->param.amr_octet_aligned ? "octet-aligned" : 
"bandwidth-efficient");
+                               return rc;
                        }
+               } else if (rtp_end->rfc5993_hr_convert &&
+                          strcmp(conn_src->end.codec->subtype_name, 
"GSM-HR-08") == 0) {
+                       rc = rfc5993_hr_convert(endp, msg);
+                       if (rc < 0) {
+                               LOGPENDP(endp, DRTP, LOGL_ERROR, "Error while 
converting to GSM-HR-08\n");
+                               return rc;
+                       }
+               }

-                       LOGPENDP(endp, DRTP, LOGL_DEBUG,
-                                "process/send to %s %s "
-                                "rtp_port:%u rtcp_port:%u\n",
-                                dest_name,
-                                osmo_sockaddr_ntop(&rtp_end->addr.u.sa, ipbuf),
-                                osmo_sockaddr_port(&rtp_end->addr.u.sa), 
ntohs(rtp_end->rtcp_port)
-                               );
+               LOGPENDP(endp, DRTP, LOGL_DEBUG,
+                        "process/send to %s %s "
+                        "rtp_port:%u rtcp_port:%u\n",
+                        dest_name,
+                        osmo_sockaddr_ntop(&rtp_end->addr.u.sa, ipbuf),
+                        osmo_sockaddr_port(&rtp_end->addr.u.sa), 
ntohs(rtp_end->rtcp_port)
+                       );

-                       /* Forward a copy of the RTP data to a debug ip/port */
-                       forward_data_tap(rtp_end->rtp.fd, &conn_src->tap_out,
-                                    msg);
+               /* Forward a copy of the RTP data to a debug ip/port */
+               forward_data_tap(rtp_end->rtp.fd, &conn_src->tap_out,
+                            msg);

-                       len = mgcp_udp_send(rtp_end->rtp.fd, &rtp_end->addr,
-                                           (char *)msgb_data(msg), 
msgb_length(msg));
+               len = mgcp_udp_send(rtp_end->rtp.fd, &rtp_end->addr,
+                                   (char *)msgb_data(msg), msgb_length(msg));

-                       if (len <= 0)
-                               return len;
+               if (len <= 0)
+                       return len;

-                       rtpconn_rate_ctr_inc(conn_dst, endp, 
RTP_PACKETS_TX_CTR);
-                       rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, 
len);
-                       rtp_state->alt_rtp_tx_sequence++;
+               rtpconn_rate_ctr_inc(conn_dst, endp, RTP_PACKETS_TX_CTR);
+               rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len);
+               rtp_state->alt_rtp_tx_sequence++;

-                       nbytes += len;
-                       buflen = cont;
-               } while (buflen > 0);
-               return nbytes;
+               return len;
        } else if (!trunk->omit_rtcp) {
                struct osmo_sockaddr rtcp_addr = rtp_end->addr;
                osmo_sockaddr_set_port(&rtcp_addr.u.sa, rtp_end->rtcp_port);

--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/36356?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ie1a629fd31c5ab806fc929d1e6b279c4be5b8246
Gerrit-Change-Number: 36356
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to