MGCP_Test: add new testcases for oa/bwe conversion

The octet aligned to bandwith efficient conversion is currently only
tested in scenarios where only one codec is assigned on both sides.
However, there may be call agents that will assign bandwith efficient
and octet aligned on one side for compatibility reasons. If this is the
case, then OsmoMGW should always chose the format that requires no
conversion.

Related: OS#5461
Change-Id: I2b2d7ef7fb4fe31111aa8665c4d4295425502451
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index 909ad25..28b7103 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -2351,7 +2351,9 @@
 	/* create two local RTP emulations; create two connections on MGW EP, see if
 	 * exchanged data is converted between AMR octet-aligned and bandwidth
 	 * efficient-mode */
-	function f_TC_amr_x_x_rtp_conversion(octetstring pl0, octetstring pl1, charstring fmtp0, charstring fmtp1) runs on dummy_CT {
+	function f_TC_amr_x_x_rtp_conversion(charstring fmtp0, octetstring pl0,
+					     charstring fmtp1a, octetstring pl1a,
+					     charstring fmtp1b, octetstring pl1b) runs on dummy_CT {
 		var RtpFlowData flow[2];
 		var RtpemStats stats[2];
 		var MgcpResponse resp;
@@ -2372,13 +2374,25 @@
 		f_flow_create(RTPEM[0], ep, call_id, "sendrecv", flow[0]);
 
 		/* Connection #1 (Bidirectional) */
-		flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 112, "AMR/8000", fmtp1));
+		flow[1] := valueof(t_RtpFlow(mp_local_ipv4, mp_remote_ipv4, 112, "AMR/8000", fmtp1a));
 		flow[1].em.portnr := 20000;
 		flow[1].rtp_cfg	:= c_RtpemDefaultCfg;
-		flow[1].rtp_cfg.rx_payloads[0].payload_type := flow[1].codec_descr[0].pt;
-		flow[1].rtp_cfg.tx_payloads[0].payload_type := flow[1].codec_descr[0].pt;
-		flow[1].rtp_cfg.rx_payloads[0].fixed_payload := pl1;
-		flow[1].rtp_cfg.tx_payloads[0].fixed_payload := pl1;
+		flow[1].rtp_cfg.rx_payloads := {};
+		flow[1].rtp_cfg.tx_payloads := {};
+		if (pl1a != ''O) {
+			flow[1].rtp_cfg.rx_payloads := flow[1].rtp_cfg.rx_payloads & {{112, pl1a}};
+			flow[1].rtp_cfg.tx_payloads := flow[1].rtp_cfg.tx_payloads & {{112, pl1a}};
+		}
+
+		/* The second fmtp parameter is to simulate a call agent that offers the transmission both modes. */
+		if (fmtp1b != "") {
+			flow[1].codec_descr := flow[1].codec_descr & {{113, "AMR/8000", fmtp1b}};
+			if (pl1b != ''O) {
+				flow[1].rtp_cfg.rx_payloads := flow[1].rtp_cfg.rx_payloads & {{113, pl1b}};
+				flow[1].rtp_cfg.tx_payloads := flow[1].rtp_cfg.tx_payloads & {{113, pl1b}};
+			}
+		}
+
 		f_flow_create(RTPEM[1], ep, call_id, "sendrecv", flow[1]);
 
 		/* Send RTP packets to connection #0, receive on connection #1 */
@@ -2421,16 +2435,41 @@
 	const octetstring rtp_amr_5_15k_oa := '100c4e9ba850e30d5d53d04de41e7c'O;
 	const octetstring rtp_amr_5_15k_bwe := '10d3a6ea1438c35754f41379079f'O;
 
+	/* Only one codec on each side */
 	testcase TC_amr_oa_bwe_rtp_conversion() runs on dummy_CT {
-		f_TC_amr_x_x_rtp_conversion(rtp_amr_5_90k_oa, rtp_amr_5_90k_bwe, "octet-align=1", "octet-align=0");
+		f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_90k_oa, "octet-align=0", rtp_amr_5_90k_bwe, "", ''O);
 	}
-
 	testcase TC_amr_oa_oa_rtp_conversion() runs on dummy_CT {
-		 f_TC_amr_x_x_rtp_conversion(rtp_amr_5_15k_oa, rtp_amr_5_15k_oa, "octet-align=1", "octet-align=1");
+		f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_15k_oa, "octet-align=1", rtp_amr_5_15k_oa, "", ''O);
+	}
+	testcase TC_amr_bwe_bwe_rtp_conversion() runs on dummy_CT {
+		f_TC_amr_x_x_rtp_conversion("octet-align=0", rtp_amr_5_15k_bwe, "octet-align=0", rtp_amr_5_15k_bwe, "", ''O);
 	}
 
-	testcase TC_amr_bwe_bwe_rtp_conversion() runs on dummy_CT {
-		 f_TC_amr_x_x_rtp_conversion(rtp_amr_5_15k_bwe, rtp_amr_5_15k_bwe, "octet-align=0", "octet-align=0");
+	/* Only one codec on one side, two codecs (compatibility) on other side. The payloads are the same on both
+	 * sides, so the expectation is that conversion must not be performed. Each test is done with both formats in
+	 * two different configurations.*/
+	testcase TC_amr_oa_oa_no_bwe_rtp_conversion() runs on dummy_CT {
+		f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_15k_oa,
+					    "octet-align=1", rtp_amr_5_15k_oa,
+					    "octet-align=0", ''O); /* We expect to see NO bandwidth efficient packets! */
+	}
+	testcase TC_amr_oa_no_bwe_oa_rtp_conversion() runs on dummy_CT {
+		/* (Same as above but flipped on the opposite side) */
+		f_TC_amr_x_x_rtp_conversion("octet-align=1", rtp_amr_5_15k_oa,
+					    "octet-align=0", ''O, /* We expect to see NO bandwidth efficient packets! */
+					    "octet-align=1", rtp_amr_5_15k_oa);
+	}
+	testcase TC_amr_bwe_bwe_no_oa_rtp_conversion() runs on dummy_CT {
+		f_TC_amr_x_x_rtp_conversion("octet-align=0", rtp_amr_5_15k_bwe,
+					    "octet-align=0", rtp_amr_5_15k_bwe,
+					    "octet-align=1", ''O); /* We expect to see NO octet aligned packets! */
+	}
+	testcase TC_amr_bwe_no_oa_bwe_rtp_conversion() runs on dummy_CT {
+		/* (Same as above but flipped on the opposite side) */
+		f_TC_amr_x_x_rtp_conversion("octet-align=0", rtp_amr_5_15k_bwe,
+					    "octet-align=1", ''O, /* We expect to see NO octet aligned packets! */
+					    "octet-align=0", rtp_amr_5_15k_bwe);
 	}
 
 	/* TODO: Double-DLCX (no retransmission) */
@@ -3028,6 +3067,10 @@
 		execute(TC_amr_oa_bwe_rtp_conversion());
 		execute(TC_amr_oa_oa_rtp_conversion());
 		execute(TC_amr_bwe_bwe_rtp_conversion());
+		execute(TC_amr_oa_oa_no_bwe_rtp_conversion());
+		execute(TC_amr_oa_no_bwe_oa_rtp_conversion());
+		execute(TC_amr_bwe_bwe_no_oa_rtp_conversion());
+		execute(TC_amr_bwe_no_oa_bwe_rtp_conversion());
 
 		execute(TC_conn_timeout());