From 9dd80ca1f8fd96041bba712e3778affb5d995b2b Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 27 Mar 2023 15:45:36 +0200 Subject: [PATCH] mgcp_codec: refactor payload type converstion in mgcp_codec.c we have a function mgcp_codec_pt_translate that is used to find the equivalent payload type number on an opposite connection. This is quite specific and the resulting payload type number may still belong to a codec that might require some form of conversion. Lets refactor this so that the function just finds a convertible codec for a given connection. This also opens up other usecases. The payload type conversion like we did it before can then be done with a few lines in mgcp_network.c Related: OS#5461 Change-Id: I085260a2ca8cfecdb58656b7a046c536189e238d --- include/osmocom/mgcp/mgcp_codec.h | 3 +- src/libosmo-mgcp/mgcp_codec.c | 74 ++++++------- src/libosmo-mgcp/mgcp_network.c | 22 ++-- tests/mgcp/mgcp_test.c | 59 ++++++---- tests/mgcp/mgcp_test.ok | 173 +++++++++++++++++++----------- 5 files changed, 203 insertions(+), 128 deletions(-) diff --git a/include/osmocom/mgcp/mgcp_codec.h b/include/osmocom/mgcp/mgcp_codec.h index 994d77054..1f29b0888 100644 --- a/include/osmocom/mgcp/mgcp_codec.h +++ b/include/osmocom/mgcp/mgcp_codec.h @@ -14,8 +14,9 @@ void mgcp_codec_summary(struct mgcp_conn_rtp *conn); void mgcp_codec_reset_all(struct mgcp_conn_rtp *conn); int mgcp_codec_add(struct mgcp_conn_rtp *conn, int payload_type, const char *audio_name, const struct mgcp_codec_param *param); int mgcp_codec_decide(struct mgcp_conn_rtp *conn); -int mgcp_codec_pt_translate(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, int payload_type); +struct mgcp_rtp_codec *mgcp_codec_find_convertible(struct mgcp_conn_rtp *conn, struct mgcp_rtp_codec *codec); const struct mgcp_rtp_codec *mgcp_codec_pt_find_by_subtype_name(struct mgcp_conn_rtp *conn, const char *subtype_name, unsigned int match_nr); bool mgcp_codec_amr_align_mode_is_indicated(const struct mgcp_rtp_codec *codec); bool mgcp_codec_amr_is_octet_aligned(const struct mgcp_rtp_codec *codec); +struct mgcp_rtp_codec *mgcp_codec_from_pt(struct mgcp_conn_rtp *conn, int payload_type); diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c index ccb5d7714..908604725 100644 --- a/src/libosmo-mgcp/mgcp_codec.c +++ b/src/libosmo-mgcp/mgcp_codec.c @@ -425,63 +425,42 @@ static bool codecs_convertible(struct mgcp_rtp_codec *codec_a, struct mgcp_rtp_c return true; } -/*! Translate a given payload type number that belongs to the packet of a - * source connection to the equivalent payload type number that matches the - * configuration of a destination connection. - * \param[in] conn_src related source rtp-connection. - * \param[in] conn_dst related destination rtp-connection. - * \param[in] payload_type number from the source packet or source connection. - * \returns translated payload type number on success, -EINVAL on failure. */ -int mgcp_codec_pt_translate(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, int payload_type) +/*! For a given codec, find a convertible codec in the given connection. + * \param[in] conn connection to search for a convertible codec + * \param[in] codec for which a convertible codec shall be found. + * \returns codec on success, -NULL on failure. */ +struct mgcp_rtp_codec *mgcp_codec_find_convertible(struct mgcp_conn_rtp *conn, struct mgcp_rtp_codec *codec) { - struct mgcp_rtp_end *rtp_src; - struct mgcp_rtp_end *rtp_dst; - struct mgcp_rtp_codec *codec_src = NULL; - struct mgcp_rtp_codec *codec_dst = NULL; + struct mgcp_rtp_end *rtp_end; unsigned int i; unsigned int codecs_assigned; + struct mgcp_rtp_codec *codec_convertible = NULL; - rtp_src = &conn_src->end; - rtp_dst = &conn_dst->end; - - /* Find the codec information that is used on the source side */ - codecs_assigned = rtp_src->codecs_assigned; - OSMO_ASSERT(codecs_assigned <= MGCP_MAX_CODECS); - for (i = 0; i < codecs_assigned; i++) { - if (payload_type == rtp_src->codecs[i].payload_type) { - codec_src = &rtp_src->codecs[i]; - break; - } - } - if (!codec_src) - return -EINVAL; + rtp_end = &conn->end; /* Use the codec information from the source and try to find the equivalent of it on the destination side. In * the first run we will look for an exact match. */ - codecs_assigned = rtp_dst->codecs_assigned; + codecs_assigned = rtp_end->codecs_assigned; OSMO_ASSERT(codecs_assigned <= MGCP_MAX_CODECS); for (i = 0; i < codecs_assigned; i++) { - if (codecs_same(codec_src, &rtp_dst->codecs[i])) { - codec_dst = &rtp_dst->codecs[i]; + if (codecs_same(codec, &rtp_end->codecs[i])) { + codec_convertible = &rtp_end->codecs[i]; break; } } /* In case we weren't able to find an exact match, we will try to find a match that is the same codec, but the * payload format may be different. This alternative will require a frame format conversion (i.e. AMR bwe->oe) */ - if (!codec_dst) { + if (!codec_convertible) { for (i = 0; i < codecs_assigned; i++) { - if (codecs_convertible(codec_src, &rtp_dst->codecs[i])) { - codec_dst = &rtp_dst->codecs[i]; + if (codecs_convertible(codec, &rtp_end->codecs[i])) { + codec_convertible = &rtp_end->codecs[i]; break; } } } - if (!codec_dst) - return -EINVAL; - - return codec_dst->payload_type; + return codec_convertible; } /* Find the payload type number configured for a specific codec by SDP. @@ -508,3 +487,26 @@ const struct mgcp_rtp_codec *mgcp_codec_pt_find_by_subtype_name(struct mgcp_conn } return NULL; } + +/*! Lookup a codec that is assigned to a connection by its payload type number. + * \param[in] conn related rtp-connection. + * \param[in] payload_type number of the codec to look up. + * \returns pointer to codec struct on success, NULL on failure. */ +struct mgcp_rtp_codec *mgcp_codec_from_pt(struct mgcp_conn_rtp *conn, int payload_type) +{ + struct mgcp_rtp_end *rtp_end = &conn->end; + unsigned int codecs_assigned = rtp_end->codecs_assigned; + struct mgcp_rtp_codec *codec = NULL; + size_t i; + + OSMO_ASSERT(codecs_assigned <= MGCP_MAX_CODECS); + + for (i = 0; i < codecs_assigned; i++) { + if (payload_type == rtp_end->codecs[i].payload_type) { + codec = &rtp_end->codecs[i]; + break; + } + } + + return codec; +} diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index af9ae9990..ce08dd49e 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -493,27 +493,31 @@ void mgcp_rtp_annex_count(const struct mgcp_endpoint *endp, /* There may be different payload type numbers negotiated for two connections. * Patch the payload type of an RTP packet so that it uses the payload type * that is valid for the destination connection (conn_dst) */ -static int mgcp_patch_pt(struct mgcp_conn_rtp *conn_src, - struct mgcp_conn_rtp *conn_dst, struct msgb *msg) +static int mgcp_patch_pt(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, struct msgb *msg) { struct rtp_hdr *rtp_hdr; - uint8_t pt_in; - int pt_out; + struct mgcp_rtp_codec *codec_src; + struct mgcp_rtp_codec *codec_dst; if (msgb_length(msg) < sizeof(struct rtp_hdr)) { LOG_CONN_RTP(conn_src, LOGL_ERROR, "RTP packet too short (%u < %zu)\n", msgb_length(msg), sizeof(struct rtp_hdr)); return -EINVAL; } - rtp_hdr = (struct rtp_hdr *)msgb_data(msg); - pt_in = rtp_hdr->payload_type; - pt_out = mgcp_codec_pt_translate(conn_src, conn_dst, pt_in); - if (pt_out < 0) + /* Find the codec information that is used on the source side */ + codec_src = mgcp_codec_from_pt(conn_src, rtp_hdr->payload_type); + if (!codec_src) return -EINVAL; - rtp_hdr->payload_type = (uint8_t) pt_out; + /* Lookup a suitable codec in the destination connection. (The codec must be of the same type or at least + * convertible) */ + codec_dst = mgcp_codec_find_convertible(conn_dst, codec_src); + if (!codec_dst) + return -EINVAL; + + rtp_hdr->payload_type = (uint8_t) codec_dst->payload_type; return 0; } diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index 8f081a9ce..bc2dae0e5 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -1769,26 +1769,26 @@ static const struct mgcp_codec_param amr_param_octet_aligned_unset = { .amr_octet_aligned_present = false, }; -struct testcase_mgcp_codec_pt_translate_codec { +struct testcase_mgcp_codec_find_convertible_codec { int payload_type; const char *audio_name; const struct mgcp_codec_param *param; int expect_rc; }; -struct testcase_mgcp_codec_pt_translate_expect { +struct testcase_mgcp_codec_find_convertible_expect { bool end; int payload_type_map[2]; }; -struct testcase_mgcp_codec_pt_translate { +struct testcase_mgcp_codec_find_convertible { const char *descr; /* two conns on an endpoint, each with N configured codecs */ - struct testcase_mgcp_codec_pt_translate_codec codecs[2][10]; - struct testcase_mgcp_codec_pt_translate_expect expect[32]; + struct testcase_mgcp_codec_find_convertible_codec codecs[2][10]; + struct testcase_mgcp_codec_find_convertible_expect expect[32]; }; -static const struct testcase_mgcp_codec_pt_translate test_mgcp_codec_pt_translate_cases[] = { +static const struct testcase_mgcp_codec_find_convertible test_mgcp_codec_find_convertible_cases[] = { { .descr = "same order, but differing payload type numbers", .codecs = { @@ -2044,14 +2044,39 @@ static const struct testcase_mgcp_codec_pt_translate test_mgcp_codec_pt_translat }, }; -static void test_mgcp_codec_pt_translate(void) +static int pt_translate(struct mgcp_conn_rtp *conn, unsigned int index_src, unsigned int index_dst, int payload_type) +{ + struct mgcp_rtp_codec *codec_src = NULL; + struct mgcp_rtp_codec *codec_dst = NULL; + struct mgcp_conn_rtp *conn_src = &conn[index_src]; + struct mgcp_conn_rtp *conn_dst = &conn[index_dst]; + + /* Find the codec information that is used on the source side */ + codec_src = mgcp_codec_from_pt(conn_src, payload_type); + if (!codec_src) { + printf(" - mgcp_codec_from_pt(conn%u, %d) -> NO RESULT\n", index_src, payload_type); + return -EINVAL; + } + printf(" - mgcp_codec_from_pt(conn%u, %d) -> %s\n", index_src, payload_type, codec_src->subtype_name); + + codec_dst = mgcp_codec_find_convertible(conn_dst, codec_src); + if (!codec_dst) { + printf(" - mgcp_codec_find_convertible(conn%u, %s) -> NO RESULT\n", index_dst, codec_src->subtype_name); + return -EINVAL; + } + printf(" - mgcp_codec_find_convertible(conn%u, %s) -> %s -> %u\n", + index_dst, codec_src->subtype_name, codec_dst->subtype_name, codec_dst->payload_type); + return codec_dst->payload_type; +} + +static void test_mgcp_codec_find_convertible(void) { int i; bool ok = true; - printf("\nTesting mgcp_codec_pt_translate()\n"); + printf("\nTesting mgcp_codec_find_convertible()\n"); - for (i = 0; i < ARRAY_SIZE(test_mgcp_codec_pt_translate_cases); i++) { - const struct testcase_mgcp_codec_pt_translate *t = &test_mgcp_codec_pt_translate_cases[i]; + for (i = 0; i < ARRAY_SIZE(test_mgcp_codec_find_convertible_cases); i++) { + const struct testcase_mgcp_codec_find_convertible *t = &test_mgcp_codec_find_convertible_cases[i]; struct mgcp_conn_rtp conn[2] = {}; int rc; int conn_i; @@ -2062,7 +2087,7 @@ static void test_mgcp_codec_pt_translate(void) for (conn_i = 0; conn_i < 2; conn_i++) { printf(" - add codecs on conn%d:\n", conn_i); for (c = 0; c < ARRAY_SIZE(t->codecs[conn_i]); c++) { - const struct testcase_mgcp_codec_pt_translate_codec *codec = &t->codecs[conn_i][c]; + const struct testcase_mgcp_codec_find_convertible_codec *codec = &t->codecs[conn_i][c]; if (!codec->audio_name) break; @@ -2086,15 +2111,13 @@ static void test_mgcp_codec_pt_translate(void) } for (c = 0; c < ARRAY_SIZE(t->expect); c++) { - const struct testcase_mgcp_codec_pt_translate_expect *expect = &t->expect[c]; + const struct testcase_mgcp_codec_find_convertible_expect *expect = &t->expect[c]; int result; if (expect->end) break; - result = mgcp_codec_pt_translate(&conn[0], &conn[1], expect->payload_type_map[0]); - printf(" - mgcp_codec_pt_translate(conn0, conn1, %d) -> %d\n", - expect->payload_type_map[0], result); + result = pt_translate(conn, 0, 1, expect->payload_type_map[0]); if (result != expect->payload_type_map[1]) { printf(" ERROR: expected -> %d\n", expect->payload_type_map[1]); ok = false; @@ -2104,9 +2127,7 @@ static void test_mgcp_codec_pt_translate(void) if (expect->payload_type_map[1] < 0) continue; - result = mgcp_codec_pt_translate(&conn[1], &conn[0], expect->payload_type_map[1]); - printf(" - mgcp_codec_pt_translate(conn1, conn0, %d) -> %d\n", - expect->payload_type_map[1], result); + result = pt_translate(conn, 1, 0, expect->payload_type_map[1]); if (result != expect->payload_type_map[0]) { printf(" ERROR: expected -> %d\n", expect->payload_type_map[0]); ok = false; @@ -2274,7 +2295,7 @@ int main(int argc, char **argv) test_osmux_cid(); test_get_lco_identifier(); test_check_local_cx_options(ctx); - test_mgcp_codec_pt_translate(); + test_mgcp_codec_find_convertible(); test_conn_id_matching(); test_e1_trunk_nr_from_epname(); test_mgcp_is_rtp_dummy_payload(); diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok index 8b3b3d12a..4ea9a34ef 100644 --- a/tests/mgcp/mgcp_test.ok +++ b/tests/mgcp/mgcp_test.ok @@ -1276,7 +1276,7 @@ p:10, a:PCMU -> p:10, a:PCMU p10, aPCMU -> (null) '10,a :PCMU' -> '(null)' -Testing mgcp_codec_pt_translate() +Testing mgcp_codec_find_convertible() #0: same order, but differing payload type numbers - add codecs on conn0: 0: 112 AMR/8000/1 octet-aligned=1 -> rc=0 @@ -1286,13 +1286,19 @@ Testing mgcp_codec_pt_translate() 0: 96 AMR/8000/1 octet-aligned=1 -> rc=0 1: 0 PCMU/8000/1 -> rc=0 2: 97 GSM-HR-08/8000/1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 96 - - mgcp_codec_pt_translate(conn1, conn0, 96) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> 0 - - mgcp_codec_pt_translate(conn1, conn0, 0) -> 0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 97 - - mgcp_codec_pt_translate(conn1, conn0, 97) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 123) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 96 + - mgcp_codec_from_pt(conn1, 96) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 0) -> PCMU + - mgcp_codec_find_convertible(conn1, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn1, 0) -> PCMU + - mgcp_codec_find_convertible(conn0, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn0, 111) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> GSM-HR-08 -> 97 + - mgcp_codec_from_pt(conn1, 97) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn0, GSM-HR-08) -> GSM-HR-08 -> 111 + - mgcp_codec_from_pt(conn0, 123) -> NO RESULT #1: different order and different payload type numbers - add codecs on conn0: 0: 0 PCMU/8000/1 -> rc=0 @@ -1302,13 +1308,19 @@ Testing mgcp_codec_pt_translate() 0: 97 GSM-HR-08/8000/1 -> rc=0 1: 0 PCMU/8000/1 -> rc=0 2: 96 AMR/8000/1 octet-aligned=1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 96 - - mgcp_codec_pt_translate(conn1, conn0, 96) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> 0 - - mgcp_codec_pt_translate(conn1, conn0, 0) -> 0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 97 - - mgcp_codec_pt_translate(conn1, conn0, 97) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 123) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 96 + - mgcp_codec_from_pt(conn1, 96) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 0) -> PCMU + - mgcp_codec_find_convertible(conn1, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn1, 0) -> PCMU + - mgcp_codec_find_convertible(conn0, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn0, 111) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> GSM-HR-08 -> 97 + - mgcp_codec_from_pt(conn1, 97) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn0, GSM-HR-08) -> GSM-HR-08 -> 111 + - mgcp_codec_from_pt(conn0, 123) -> NO RESULT #2: both sides have the same payload_type numbers assigned to differing codecs - add codecs on conn0: 0: 0 PCMU/8000/1 -> rc=0 @@ -1318,13 +1330,19 @@ Testing mgcp_codec_pt_translate() 0: 97 GSM-HR-08/8000/1 -> rc=0 1: 0 PCMU/8000/1 -> rc=0 2: 96 AMR/8000/1 octet-aligned=1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 96) -> 97 - - mgcp_codec_pt_translate(conn1, conn0, 97) -> 96 - - mgcp_codec_pt_translate(conn0, conn1, 97) -> 96 - - mgcp_codec_pt_translate(conn1, conn0, 96) -> 97 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> 0 - - mgcp_codec_pt_translate(conn1, conn0, 0) -> 0 - - mgcp_codec_pt_translate(conn0, conn1, 123) -> -22 + - mgcp_codec_from_pt(conn0, 96) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> GSM-HR-08 -> 97 + - mgcp_codec_from_pt(conn1, 97) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn0, GSM-HR-08) -> GSM-HR-08 -> 96 + - mgcp_codec_from_pt(conn0, 97) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 96 + - mgcp_codec_from_pt(conn1, 96) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 97 + - mgcp_codec_from_pt(conn0, 0) -> PCMU + - mgcp_codec_find_convertible(conn1, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn1, 0) -> PCMU + - mgcp_codec_find_convertible(conn0, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn0, 123) -> NO RESULT #3: conn0 has no codecs - add codecs on conn0: (none) @@ -1332,9 +1350,9 @@ Testing mgcp_codec_pt_translate() 0: 96 AMR/8000/1 octet-aligned=1 -> rc=0 1: 0 PCMU/8000/1 -> rc=0 2: 97 GSM-HR-08/8000/1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> -22 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> -22 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> NO RESULT + - mgcp_codec_from_pt(conn0, 0) -> NO RESULT + - mgcp_codec_from_pt(conn0, 111) -> NO RESULT #4: conn1 has no codecs - add codecs on conn0: 0: 112 AMR/8000/1 octet-aligned=1 -> rc=0 @@ -1342,9 +1360,12 @@ Testing mgcp_codec_pt_translate() 2: 111 GSM-HR-08/8000/1 -> rc=0 - add codecs on conn1: (none) - - mgcp_codec_pt_translate(conn0, conn1, 112) -> -22 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> -22 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> NO RESULT + - mgcp_codec_from_pt(conn0, 0) -> PCMU + - mgcp_codec_find_convertible(conn1, PCMU) -> NO RESULT + - mgcp_codec_from_pt(conn0, 111) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> NO RESULT #5: test AMR with differing octet-aligned settings - add codecs on conn0: 0: 111 AMR/8000 octet-aligned=1 -> rc=0 @@ -1352,43 +1373,55 @@ Testing mgcp_codec_pt_translate() - add codecs on conn1: 0: 122 AMR/8000 octet-aligned=0 -> rc=0 1: 121 AMR/8000 octet-aligned=1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 121 - - mgcp_codec_pt_translate(conn1, conn0, 121) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 122 - - mgcp_codec_pt_translate(conn1, conn0, 122) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 123) -> -22 + - mgcp_codec_from_pt(conn0, 111) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 121 + - mgcp_codec_from_pt(conn1, 121) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 111 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 122 + - mgcp_codec_from_pt(conn1, 122) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 123) -> NO RESULT #6: test AMR with missing octet-aligned settings (oa <-> unset) - add codecs on conn0: 0: 111 AMR/8000 octet-aligned=1 -> rc=0 - add codecs on conn1: 0: 122 AMR/8000 octet-aligned=unset -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 122 - - mgcp_codec_pt_translate(conn1, conn0, 122) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 55) -> -22 + - mgcp_codec_from_pt(conn0, 111) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 122 + - mgcp_codec_from_pt(conn1, 122) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 111 + - mgcp_codec_from_pt(conn0, 55) -> NO RESULT #7: test AMR with missing octet-aligned settings (bwe <-> unset) - add codecs on conn0: 0: 111 AMR/8000 octet-aligned=0 -> rc=0 - add codecs on conn1: 0: 122 AMR/8000 octet-aligned=unset -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 122 - - mgcp_codec_pt_translate(conn1, conn0, 122) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 55) -> -22 + - mgcp_codec_from_pt(conn0, 111) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 122 + - mgcp_codec_from_pt(conn1, 122) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 111 + - mgcp_codec_from_pt(conn0, 55) -> NO RESULT #8: test AMR with NULL param (oa <-> null) - add codecs on conn0: 0: 112 AMR/8000 octet-aligned=1 -> rc=0 - add codecs on conn1: 0: 122 AMR/8000 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 122 - - mgcp_codec_pt_translate(conn1, conn0, 122) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 55) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 122 + - mgcp_codec_from_pt(conn1, 122) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 55) -> NO RESULT #9: test AMR with NULL param (bwe <-> null) - add codecs on conn0: 0: 112 AMR/8000 octet-aligned=0 -> rc=0 - add codecs on conn1: 0: 122 AMR/8000 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 122 - - mgcp_codec_pt_translate(conn1, conn0, 122) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 55) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 122 + - mgcp_codec_from_pt(conn1, 122) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 55) -> NO RESULT #10: match FOO/8000/1 and FOO/8000 as identical, single channel is implicit - add codecs on conn0: 0: 0 PCMU/8000/1 -> rc=0 @@ -1398,13 +1431,19 @@ Testing mgcp_codec_pt_translate() 0: 97 GSM-HR-08/8000 -> rc=0 1: 0 PCMU/8000 -> rc=0 2: 96 AMR/8000 octet-aligned=1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 96 - - mgcp_codec_pt_translate(conn1, conn0, 96) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> 0 - - mgcp_codec_pt_translate(conn1, conn0, 0) -> 0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 97 - - mgcp_codec_pt_translate(conn1, conn0, 97) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 123) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 96 + - mgcp_codec_from_pt(conn1, 96) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 0) -> PCMU + - mgcp_codec_find_convertible(conn1, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn1, 0) -> PCMU + - mgcp_codec_find_convertible(conn0, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn0, 111) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> GSM-HR-08 -> 97 + - mgcp_codec_from_pt(conn1, 97) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn0, GSM-HR-08) -> GSM-HR-08 -> 111 + - mgcp_codec_from_pt(conn0, 123) -> NO RESULT #11: match FOO/8000/1 and FOO as identical, 8k and single channel are implicit - add codecs on conn0: 0: 0 PCMU/8000/1 -> rc=0 @@ -1414,13 +1453,19 @@ Testing mgcp_codec_pt_translate() 0: 97 GSM-HR-08 -> rc=0 1: 0 PCMU -> rc=0 2: 96 AMR octet-aligned=1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> 96 - - mgcp_codec_pt_translate(conn1, conn0, 96) -> 112 - - mgcp_codec_pt_translate(conn0, conn1, 0) -> 0 - - mgcp_codec_pt_translate(conn1, conn0, 0) -> 0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 97 - - mgcp_codec_pt_translate(conn1, conn0, 97) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 123) -> -22 + - mgcp_codec_from_pt(conn0, 112) -> AMR + - mgcp_codec_find_convertible(conn1, AMR) -> AMR -> 96 + - mgcp_codec_from_pt(conn1, 96) -> AMR + - mgcp_codec_find_convertible(conn0, AMR) -> AMR -> 112 + - mgcp_codec_from_pt(conn0, 0) -> PCMU + - mgcp_codec_find_convertible(conn1, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn1, 0) -> PCMU + - mgcp_codec_find_convertible(conn0, PCMU) -> PCMU -> 0 + - mgcp_codec_from_pt(conn0, 111) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> GSM-HR-08 -> 97 + - mgcp_codec_from_pt(conn1, 97) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn0, GSM-HR-08) -> GSM-HR-08 -> 111 + - mgcp_codec_from_pt(conn0, 123) -> NO RESULT #12: test whether channel number matching is waterproof - add codecs on conn0: 0: 111 GSM-HR-08/8000 -> rc=0 @@ -1429,10 +1474,12 @@ Testing mgcp_codec_pt_translate() - add codecs on conn1: 0: 122 GSM-HR-08/8000/2 -> rc=-22 1: 121 GSM-HR-08/8000/1 -> rc=0 - - mgcp_codec_pt_translate(conn0, conn1, 111) -> 121 - - mgcp_codec_pt_translate(conn1, conn0, 121) -> 111 - - mgcp_codec_pt_translate(conn0, conn1, 112) -> -22 - - mgcp_codec_pt_translate(conn0, conn1, 113) -> -22 + - mgcp_codec_from_pt(conn0, 111) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn1, GSM-HR-08) -> GSM-HR-08 -> 121 + - mgcp_codec_from_pt(conn1, 121) -> GSM-HR-08 + - mgcp_codec_find_convertible(conn0, GSM-HR-08) -> GSM-HR-08 -> 111 + - mgcp_codec_from_pt(conn0, 112) -> NO RESULT + - mgcp_codec_from_pt(conn0, 113) -> NO RESULT Testing test_conn_id_matching needle='23AB' found '000023AB'