<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/10172">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">mgcp_network: translate payload type numbers in RTP packets<br><br>Since no transcoding is in place osmo-mgw forwards the incoming rtp<br>packets as they are (there may be minor modifications of the header) from<br>an ingress connection to an egress connection.<br><br>This works without problems as long as both connections use the same<br>payload type. For IANA defined fixed payload type numbers this is<br>usually the case, but for dynemic payload type numbers both ends may set<br>up the same codecs but with different payload type numbers.<br><br>When different payload type numbers are set up, and the packet is passed<br>through without modification, it will have the wrong payload type when<br>it is sent. The receiving end may then toss the packet since it expects<br>packets with the payload type it has configured.<br><br>The machanism, which is introduced with this patch looks up actual codec<br>inside the struct data of the ingress connection and then looks for the<br>matching codec in the struct data of the egress connection. When it<br>finds the codec there it looks up the payload type of this codec. The<br>header of the RTP packet is then patched with the correct payoad type.<br><br>- Add function mgcp_codec_pt_translate() to look up the payload type<br>- Add unit-test for function mgcp_codec_pt_translate()<br>- Add payload type translation to mgcp_network.c<br><br>Change-Id: I3a874e59fa07bcc2a67c376cafa197360036f539<br>Related: OS#2728<br>Related: OS#3384<br>---<br>M include/osmocom/mgcp/mgcp_codec.h<br>M src/libosmo-mgcp/mgcp_codec.c<br>M src/libosmo-mgcp/mgcp_network.c<br>M tests/mgcp/mgcp_test.c<br>4 files changed, 203 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/mgcp/mgcp_codec.h b/include/osmocom/mgcp/mgcp_codec.h</span><br><span>index f8d5e70..334913b 100644</span><br><span>--- a/include/osmocom/mgcp/mgcp_codec.h</span><br><span>+++ b/include/osmocom/mgcp/mgcp_codec.h</span><br><span>@@ -4,3 +4,4 @@</span><br><span> void mgcp_codec_reset_all(struct mgcp_conn_rtp *conn);</span><br><span> int mgcp_codec_add(struct mgcp_conn_rtp *conn, int payload_type, const char *audio_name);</span><br><span> int mgcp_codec_decide(struct mgcp_conn_rtp *conn);</span><br><span style="color: hsl(120, 100%, 40%);">+int mgcp_codec_pt_translate(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, int payload_type);</span><br><span>diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c</span><br><span>index 2ce90dd..55be554 100644</span><br><span>--- a/src/libosmo-mgcp/mgcp_codec.c</span><br><span>+++ b/src/libosmo-mgcp/mgcp_codec.c</span><br><span>@@ -341,3 +341,70 @@</span><br><span> </span><br><span>       return -EINVAL;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Compare two codecs, all parameters must match up, except for the payload type</span><br><span style="color: hsl(120, 100%, 40%);">+ * number. */</span><br><span style="color: hsl(120, 100%, 40%);">+static bool codecs_cmp(struct mgcp_rtp_codec *codec_a, struct mgcp_rtp_codec *codec_b)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    if (codec_a->rate != codec_b->rate)</span><br><span style="color: hsl(120, 100%, 40%);">+             return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (codec_a->channels != codec_b->channels)</span><br><span style="color: hsl(120, 100%, 40%);">+             return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (codec_a->frame_duration_num != codec_b->frame_duration_num)</span><br><span style="color: hsl(120, 100%, 40%);">+         return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (codec_a->frame_duration_den != codec_b->frame_duration_den)</span><br><span style="color: hsl(120, 100%, 40%);">+         return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strcmp(codec_a->audio_name, codec_b->audio_name))</span><br><span style="color: hsl(120, 100%, 40%);">+           return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strcmp(codec_a->subtype_name, codec_b->subtype_name))</span><br><span style="color: hsl(120, 100%, 40%);">+               return false;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       return true;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Translate a given payload type number that belongs to the packet of a</span><br><span style="color: hsl(120, 100%, 40%);">+ *  source connection to the equivalent payload type number that matches the</span><br><span style="color: hsl(120, 100%, 40%);">+ *  configuration of a destination connection.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] conn_src related source rtp-connection.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] conn_dst related destination rtp-connection.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] payload_type number from the source packet or source connection.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns translated payload type number on success, -EINVAL on failure. */</span><br><span style="color: hsl(120, 100%, 40%);">+int mgcp_codec_pt_translate(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, int payload_type)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct mgcp_rtp_end *rtp_src;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct mgcp_rtp_end *rtp_dst;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct mgcp_rtp_codec *codec_src = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+      struct mgcp_rtp_codec *codec_dst = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+      unsigned int i;</span><br><span style="color: hsl(120, 100%, 40%);">+       unsigned int codecs_assigned;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       rtp_src = &conn_src->end;</span><br><span style="color: hsl(120, 100%, 40%);">+      rtp_dst = &conn_dst->end;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Find the codec information that is used on the source side */</span><br><span style="color: hsl(120, 100%, 40%);">+      codecs_assigned = rtp_src->codecs_assigned;</span><br><span style="color: hsl(120, 100%, 40%);">+        OSMO_ASSERT(codecs_assigned <= MGCP_MAX_CODECS);</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = 0; i < codecs_assigned; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (payload_type == rtp_src->codecs[i].payload_type) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     codec_src = &rtp_src->codecs[i];</span><br><span style="color: hsl(120, 100%, 40%);">+                       break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!codec_src)</span><br><span style="color: hsl(120, 100%, 40%);">+               return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Use the codec infrmation from the source and try to find the</span><br><span style="color: hsl(120, 100%, 40%);">+        * equivalent of it on the destination side */</span><br><span style="color: hsl(120, 100%, 40%);">+        codecs_assigned = rtp_dst->codecs_assigned;</span><br><span style="color: hsl(120, 100%, 40%);">+        OSMO_ASSERT(codecs_assigned <= MGCP_MAX_CODECS);</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = 0; i < codecs_assigned; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (codecs_cmp(codec_src, &rtp_dst->codecs[i])) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      codec_dst = &rtp_dst->codecs[i];</span><br><span style="color: hsl(120, 100%, 40%);">+                       break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!codec_dst)</span><br><span style="color: hsl(120, 100%, 40%);">+               return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     return codec_dst->payload_type;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c</span><br><span>index 3ac93be..1b1867a 100644</span><br><span>--- a/src/libosmo-mgcp/mgcp_network.c</span><br><span>+++ b/src/libosmo-mgcp/mgcp_network.c</span><br><span>@@ -40,8 +40,10 @@</span><br><span> #include <osmocom/mgcp/osmux.h></span><br><span> #include <osmocom/mgcp/mgcp_conn.h></span><br><span> #include <osmocom/mgcp/mgcp_endp.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/mgcp/mgcp_codec.h></span><br><span> #include <osmocom/mgcp/debug.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #define RTP_SEQ_MOD                (1 << 16)</span><br><span> #define RTP_MAX_DROPOUT              3000</span><br><span> #define RTP_MAX_MISORDER        100</span><br><span>@@ -474,6 +476,28 @@</span><br><span>   state->stats.max_seq = seq;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* There may be different payload type numbers negotiated for two connections.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Patch the payload type of an RTP packet so that it uses the payload type</span><br><span style="color: hsl(120, 100%, 40%);">+ * that is valid for the destination connection (conn_dst) */</span><br><span style="color: hsl(120, 100%, 40%);">+static int mgcp_patch_pt(struct mgcp_conn_rtp *conn_src,</span><br><span style="color: hsl(120, 100%, 40%);">+                  struct mgcp_conn_rtp *conn_dst, char *data, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      struct rtp_hdr *rtp_hdr;</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t pt_in;</span><br><span style="color: hsl(120, 100%, 40%);">+        int pt_out;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(len >= sizeof(struct rtp_hdr));</span><br><span style="color: hsl(120, 100%, 40%);">+        rtp_hdr = (struct rtp_hdr *)data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   pt_in = rtp_hdr->payload_type;</span><br><span style="color: hsl(120, 100%, 40%);">+     pt_out = mgcp_codec_pt_translate(conn_src, conn_dst, pt_in);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (pt_out < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+            return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     rtp_hdr->payload_type = (uint8_t) pt_out;</span><br><span style="color: hsl(120, 100%, 40%);">+  return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* The RFC 3550 Appendix A assumes there are multiple sources but</span><br><span>  * some of the supported endpoints (e.g. the nanoBTS) can only handle</span><br><span>  * one source and this code will patch RTP header to appear as if there</span><br><span>@@ -665,6 +689,7 @@</span><br><span>        struct mgcp_rtp_end *rtp_end;</span><br><span>        struct mgcp_rtp_state *rtp_state;</span><br><span>    char *dest_name;</span><br><span style="color: hsl(120, 100%, 40%);">+      int rc;</span><br><span> </span><br><span>  OSMO_ASSERT(conn_src);</span><br><span>       OSMO_ASSERT(conn_dst);</span><br><span>@@ -684,6 +709,21 @@</span><br><span>             ENDPOINT_NUMBER(endp), tcfg->audio_loop, conn_src->conn->mode,</span><br><span>              conn_src->conn->mode == MGCP_CONN_LOOPBACK ? " (loopback)" : "");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  /* FIXME: It is legal that the payload type on the egress connection is</span><br><span style="color: hsl(120, 100%, 40%);">+        * different from the payload type that has been negotiated on the</span><br><span style="color: hsl(120, 100%, 40%);">+     * ingress connection. Essentially the codecs are the same so we can</span><br><span style="color: hsl(120, 100%, 40%);">+   * match them and patch the payload type. However, if we can not find</span><br><span style="color: hsl(120, 100%, 40%);">+  * the codec pendant (everything ist equal except the PT), we are of</span><br><span style="color: hsl(120, 100%, 40%);">+   * course unable to patch the payload type. A situation like this</span><br><span style="color: hsl(120, 100%, 40%);">+      * should not occur if transcoding is consequently avoided. Until</span><br><span style="color: hsl(120, 100%, 40%);">+      * we have transcoding support in osmo-mgw we can not resolve this. */</span><br><span style="color: hsl(120, 100%, 40%);">+        rc = mgcp_patch_pt(conn_src, conn_dst, buf, len);</span><br><span style="color: hsl(120, 100%, 40%);">+     if (rc < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGP(DRTP, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                     "endpoint:0x%x can not patch PT because no suitable egress codec was found.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                     ENDPOINT_NUMBER(endp));</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* Note: In case of loopback configuration, both, the source and the</span><br><span>          * destination will point to the same connection. */</span><br><span>         rtp_end = &conn_dst->end;</span><br><span>diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c</span><br><span>index 56d0cee..df6ea2f 100644</span><br><span>--- a/tests/mgcp/mgcp_test.c</span><br><span>+++ b/tests/mgcp/mgcp_test.c</span><br><span>@@ -1616,6 +1616,100 @@</span><br><span>      OSMO_ASSERT(check_local_cx_options(ctx, ",,,") == -1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void test_mgcp_codec_pt_translate_pars(struct mgcp_rtp_codec *c)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ c->rate = 8000;</span><br><span style="color: hsl(120, 100%, 40%);">+    c->channels = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+   c->frame_duration_num = 23;</span><br><span style="color: hsl(120, 100%, 40%);">+        c->frame_duration_den = 42;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void test_mgcp_codec_pt_translate(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct mgcp_conn_rtp conn_src;</span><br><span style="color: hsl(120, 100%, 40%);">+        struct mgcp_conn_rtp conn_dst;</span><br><span style="color: hsl(120, 100%, 40%);">+        int pt_dst;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Setup a realistic set of codec configurations on both</span><br><span style="color: hsl(120, 100%, 40%);">+       * ends. AMR and HR will use different payload types. PCMU</span><br><span style="color: hsl(120, 100%, 40%);">+     * must use 0 on both ends since this is not a dynamic payload</span><br><span style="color: hsl(120, 100%, 40%);">+         * type */</span><br><span style="color: hsl(120, 100%, 40%);">+    test_mgcp_codec_pt_translate_pars(&conn_src.end.codecs[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+       test_mgcp_codec_pt_translate_pars(&conn_dst.end.codecs[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+       test_mgcp_codec_pt_translate_pars(&conn_src.end.codecs[1]);</span><br><span style="color: hsl(120, 100%, 40%);">+       test_mgcp_codec_pt_translate_pars(&conn_dst.end.codecs[1]);</span><br><span style="color: hsl(120, 100%, 40%);">+       test_mgcp_codec_pt_translate_pars(&conn_src.end.codecs[2]);</span><br><span style="color: hsl(120, 100%, 40%);">+       test_mgcp_codec_pt_translate_pars(&conn_dst.end.codecs[2]);</span><br><span style="color: hsl(120, 100%, 40%);">+       conn_src.end.codecs[0].payload_type = 112;</span><br><span style="color: hsl(120, 100%, 40%);">+    conn_dst.end.codecs[0].payload_type = 96;</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_src.end.codecs[1].payload_type = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+      conn_dst.end.codecs[1].payload_type = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+      conn_src.end.codecs[2].payload_type = 111;</span><br><span style="color: hsl(120, 100%, 40%);">+    conn_dst.end.codecs[2].payload_type = 97;</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_src.end.codecs[0].audio_name = "AMR/8000/1";</span><br><span style="color: hsl(120, 100%, 40%);">+   conn_dst.end.codecs[0].audio_name = "AMR/8000/1";</span><br><span style="color: hsl(120, 100%, 40%);">+   conn_src.end.codecs[1].audio_name = "PCMU/8000/1";</span><br><span style="color: hsl(120, 100%, 40%);">+  conn_dst.end.codecs[1].audio_name = "PCMU/8000/1";</span><br><span style="color: hsl(120, 100%, 40%);">+  conn_src.end.codecs[2].audio_name = "GSM-HR-08/8000/1";</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_dst.end.codecs[2].audio_name = "GSM-HR-08/8000/1";</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_src.end.codecs[0].subtype_name = "AMR";</span><br><span style="color: hsl(120, 100%, 40%);">+        conn_dst.end.codecs[0].subtype_name = "AMR";</span><br><span style="color: hsl(120, 100%, 40%);">+        conn_src.end.codecs[1].subtype_name = "PCMU";</span><br><span style="color: hsl(120, 100%, 40%);">+       conn_dst.end.codecs[1].subtype_name = "PCMU";</span><br><span style="color: hsl(120, 100%, 40%);">+       conn_src.end.codecs[2].subtype_name = "GSM-HR-08";</span><br><span style="color: hsl(120, 100%, 40%);">+  conn_dst.end.codecs[2].subtype_name = "GSM-HR-08";</span><br><span style="color: hsl(120, 100%, 40%);">+  conn_src.end.codecs_assigned = 3;</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_dst.end.codecs_assigned = 3;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* We expect the function to find the PT we must use when we send the</span><br><span style="color: hsl(120, 100%, 40%);">+  * packet out to the destination. All we know is the context for both</span><br><span style="color: hsl(120, 100%, 40%);">+  * connections and the payload type from the source packet */</span><br><span style="color: hsl(120, 100%, 40%);">+ pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[0].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == conn_dst.end.codecs[0].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+   pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[1].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == conn_dst.end.codecs[1].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+   pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[2].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == conn_dst.end.codecs[2].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Try some constellations that must fail */</span><br><span style="color: hsl(120, 100%, 40%);">+  pt_dst = mgcp_codec_pt_translate(&conn_src, &conn_dst, 123);</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+       conn_src.end.codecs_assigned = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_dst.end.codecs_assigned = 3;</span><br><span style="color: hsl(120, 100%, 40%);">+     pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[0].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+       pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[1].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+       pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[2].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+       conn_src.end.codecs_assigned = 3;</span><br><span style="color: hsl(120, 100%, 40%);">+     conn_dst.end.codecs_assigned = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[0].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+       pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[1].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+       pt_dst =</span><br><span style="color: hsl(120, 100%, 40%);">+          mgcp_codec_pt_translate(&conn_src, &conn_dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 conn_src.end.codecs[2].payload_type);</span><br><span style="color: hsl(120, 100%, 40%);">+     OSMO_ASSERT(pt_dst == -EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> int main(int argc, char **argv)</span><br><span> {</span><br><span>         void *ctx = talloc_named_const(NULL, 0, "mgcp_test");</span><br><span>@@ -1639,6 +1733,7 @@</span><br><span>      test_osmux_cid();</span><br><span>    test_get_lco_identifier();</span><br><span>   test_check_local_cx_options(ctx);</span><br><span style="color: hsl(120, 100%, 40%);">+     test_mgcp_codec_pt_translate();</span><br><span> </span><br><span>  OSMO_ASSERT(talloc_total_size(msgb_ctx) == 0);</span><br><span>       OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10172">change 10172</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/10172"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-mgw </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I3a874e59fa07bcc2a67c376cafa197360036f539 </div>
<div style="display:none"> Gerrit-Change-Number: 10172 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>