mgcp_codec: fix oa/bwe comparison in mgcp_codec_pt_translate()

The function mgcp_codec_pt_translate is very strict when comparing the
codecs to each other to find a matching payload type number to be used
on the egress side.

This poses a problem when one side uses AMR in bandwith-efficient, while
the other side uses AMR in octet-aligned payload type format. To the pt
translate function the difference in the payload format will appear as
if the codec were different and eventually the payload type number
cannot be translated.

since osmo-mgw offers conversion between the payload type format it
would be no problem to ignore the payload type format when making the
translation decision. The only exception here would be if one side would
announce AMR two times, the first time with octet-aligned and the second
time with bandwith-efficient format. Then we would have to use the
payload type number from the exact match. (and skip any formatconversion)

To archive such an optimized decision we will first go through the codec
lists and perform an exact match. If we don't get a match we go through
the codec lists a second time, but this time we ignore the payload
format.

Change-Id: Ifbd201a2749009a4644a29bd77e1d0fc0c124a9d
Related: OS#5461
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 444e07a..8f081a9 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -1851,6 +1851,7 @@
 			{ .payload_type_map = {96, 97}, },
 			{ .payload_type_map = {97, 96}, },
 			{ .payload_type_map = {0, 0}, },
+			{ .payload_type_map = {123, -EINVAL} },
 			{ .end = true },
 		},
 	},
@@ -1907,31 +1908,63 @@
 		.expect = {
 			{ .payload_type_map = {111, 121}, },
 			{ .payload_type_map = {112, 122} },
+			{ .payload_type_map = {123, -EINVAL} },
 			{ .end = true },
 		},
 	},
 	{
-		.descr = "test AMR with missing octet-aligned settings (defaults to 0)",
+		.descr = "test AMR with missing octet-aligned settings (oa <-> unset)",
 		.codecs = {
 			{
 				{ 111, "AMR/8000", &amr_param_octet_aligned_true, },
-				{ 112, "AMR/8000", &amr_param_octet_aligned_false, },
 			},
 			{
 				{ 122, "AMR/8000", &amr_param_octet_aligned_unset, },
 			},
 		},
 		.expect = {
-			{ .payload_type_map = {111, -EINVAL}, },
-			{ .payload_type_map = {112, 122} },
+			{ .payload_type_map = {111, 122}, },
+			{ .payload_type_map = {55, -EINVAL}, },
 			{ .end = true },
 		},
 	},
 	{
-		.descr = "test AMR with NULL param (defaults to 0)",
+		.descr = "test AMR with missing octet-aligned settings (bwe <-> unset)",
 		.codecs = {
 			{
-				{ 111, "AMR/8000", &amr_param_octet_aligned_true, },
+				{ 111, "AMR/8000", &amr_param_octet_aligned_false, },
+			},
+			{
+				{ 122, "AMR/8000", &amr_param_octet_aligned_unset, },
+			},
+		},
+		.expect = {
+			{ .payload_type_map = {111, 122}, },
+			{ .payload_type_map = {55, -EINVAL}, },
+			{ .end = true },
+		},
+	},
+	{
+		.descr = "test AMR with NULL param (oa <-> null)",
+		.codecs = {
+			{
+				{ 112, "AMR/8000", &amr_param_octet_aligned_true, },
+			},
+			{
+				{ 122, "AMR/8000", NULL, },
+			},
+		},
+		.expect = {
+			/* Note: Both 111, anbd 112 will translate to 122. The translation from 112 */
+			{ .payload_type_map = {112, 122} },
+			{ .payload_type_map = {55, -EINVAL}, },
+			{ .end = true },
+		},
+	},
+	{
+		.descr = "test AMR with NULL param (bwe <-> null)",
+		.codecs = {
+			{
 				{ 112, "AMR/8000", &amr_param_octet_aligned_false, },
 			},
 			{
@@ -1939,8 +1972,9 @@
 			},
 		},
 		.expect = {
-			{ .payload_type_map = {111, -EINVAL}, },
+			/* Note: Both 111, anbd 112 will translate to 122. The translation from 112 */
 			{ .payload_type_map = {112, 122} },
+			{ .payload_type_map = {55, -EINVAL}, },
 			{ .end = true },
 		},
 	},