dexter has uploaded this change for review. ( https://gerrit.osmocom.org/9234


Change subject: sdp: remove unused alt_codec field from struct mgcp_rtp_end
......................................................................

sdp: remove unused alt_codec field from struct mgcp_rtp_end

The alt_codec field is not used anywhere in the code

- remove unused alt_codec field

Change-Id: I5ff2899e3e61f33eb86f284b50ad8a94a949ed16
Related: OS#3114
---
M include/osmocom/mgcp/mgcp_internal.h
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_sdp.c
M tests/mgcp/mgcp_test.c
4 files changed, 20 insertions(+), 20 deletions(-)



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

diff --git a/include/osmocom/mgcp/mgcp_internal.h 
b/include/osmocom/mgcp/mgcp_internal.h
index ff02768..7a00c98 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -116,7 +116,6 @@

        /* audio codec information */
        struct mgcp_rtp_codec codec;
-       struct mgcp_rtp_codec alt_codec; /* TODO/XXX: make it generic */

        /* per endpoint data */
        int  frames_per_packet;
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 280ee8b..a7cd6cf 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -132,7 +132,6 @@
        end->output_enabled = 0;

        mgcp_rtp_codec_init(&end->codec);
-       mgcp_rtp_codec_init(&end->alt_codec);

        conn_rtp->rate_ctr_group = rate_ctr_group_alloc(conn, 
&rate_ctr_group_desc, rate_ctr_index);
        conn_rtp->state.in_stream.err_ts_ctr = 
&conn_rtp->rate_ctr_group->ctr[IN_STREAM_ERR_TSTMP_CTR];
diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index 5acb1ce..5cc34ea 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -205,10 +205,10 @@
  *  \param[in] endp trunk endpoint.
  *  \param[out] conn associated rtp connection.
  *  \param[out] caller provided memory to store the parsing results.
- *  \returns 1 when codecs are assigned, 0 when no codecs are assigned
+ *  \returns 1 when a codec is assigned, 0 when no codec is assigned
  *
  *  Note: In conn (conn->end) the function returns the packet duration,
- *  rtp port, rtcp port and the assigned codecs (codec and alt_codec). */
+ *  rtp port, rtcp port and the assigned codec. */
 int mgcp_parse_sdp_data(const struct mgcp_endpoint *endp,
                        struct mgcp_conn_rtp *conn,
                        struct mgcp_parse_data *p)
@@ -218,7 +218,7 @@
        char *line;
        int maxptime = -1;
        int i;
-       int codecs_assigned = 0;
+       bool codec_assigned = false;
        void *tmp_ctx = talloc_new(NULL);
        struct mgcp_rtp_end *rtp;

@@ -277,6 +277,10 @@
                                rtp->rtp_port = htons(port);
                                rtp->rtcp_port = htons(port + 1);
                                codecs_used = rc - 1;
+
+                               /* So far we have only set the payload type in
+                                * the codec struct. Now we fill up the
+                                * remaining fields of the codec description */
                                codecs_initialize(tmp_ctx, codecs, codecs_used);
                        }
                        break;
@@ -300,11 +304,11 @@
                }
        }

-       /* Now select the primary and alt_codec */
-       for (i = 0; i < codecs_used && codecs_assigned < 2; ++i) {
-               struct mgcp_rtp_codec *codec = codecs_assigned == 0 ?
-                   &rtp->codec : &rtp->alt_codec;
+       /* Now select a suitable codec */
+       for (i = 0; i < codecs_used; i++) {

+               /* When no transcoding is available, avoid codecs that would
+                * require transcoding. */
                if (endp->tcfg->no_audio_transcoding &&
                    !is_codec_compatible(endp, &codecs[i])) {
                        LOGP(DLMGCP, LOGL_NOTICE, "Skipping codec %s\n",
@@ -312,12 +316,14 @@
                        continue;
                }

-               mgcp_set_audio_info(p->cfg, codec,
+               mgcp_set_audio_info(p->cfg, &rtp->codec,
                                    codecs[i].payload_type, codecs[i].map_line);
-               codecs_assigned += 1;
+
+               codec_assigned = true;
+               break;
        }

-       if (codecs_assigned > 0) {
+       if (codec_assigned) {
                /* TODO/XXX: Store this per codec and derive it on use */
                if (maxptime >= 0 && maxptime * rtp->codec.frame_duration_den >
                    rtp->codec.frame_duration_num * 1500) {
@@ -335,7 +341,10 @@
        }

        talloc_free(tmp_ctx);
-       return codecs_assigned > 0;
+
+       if (codec_assigned)
+               return 1;
+       return 0;
 }

 /*! Generate SDP response string.
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 67c5f66..4dce64c 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -1244,7 +1244,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == 18);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == 97);

        /* Allocate 2@mgw with three codecs, last one ignored */
        last_endpoint = -1;
@@ -1260,7 +1259,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == 18);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == 97);

        /* Allocate 3@mgw with no codecs, check for PT == -1 */
        last_endpoint = -1;
@@ -1276,7 +1274,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == -1);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == -1);

        /* Allocate 4@mgw with a single codec */
        last_endpoint = -1;
@@ -1292,7 +1289,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == 18);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == -1);

        /* Allocate 5@mgw at select GSM.. */
        last_endpoint = -1;
@@ -1311,7 +1307,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == 3);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == -1);

        inp = create_msg(MDCX_NAT_DUMMY, conn_id);
        last_endpoint = -1;
@@ -1323,7 +1318,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == 3);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == -1);
        OSMO_ASSERT(conn->end.rtp_port == htons(16434));
        memset(&addr, 0, sizeof(addr));
        inet_aton("8.8.8.8", &addr);
@@ -1354,7 +1348,6 @@
        conn = mgcp_conn_get_rtp(endp, conn_id);
        OSMO_ASSERT(conn);
        OSMO_ASSERT(conn->end.codec.payload_type == 255);
-       OSMO_ASSERT(conn->end.alt_codec.payload_type == 0);

        talloc_free(cfg);
 }

--
To view, visit https://gerrit.osmocom.org/9234
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ff2899e3e61f33eb86f284b50ad8a94a949ed16
Gerrit-Change-Number: 9234
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>

Reply via email to