mgcp_codec: fix codec decision

Unfortunately OsmoMGW was never really tested with multiple different
codecs on either side of the connection. While OsmoMSC and OsmoBSC only
assign exactly one codec on each side this has never been a problem,
however it might become a problem when a call agent assigns multiple
codecs on one side. This has been observed in a setup where OsmoMGW had
one leg towards an external call agent. Also due to recent upgrades to
the TTCN3 tests we are now able to simulate different codecs on both
sides to pinpoint issues.

Testing has shown that OsmoMGW has difficulties with multiple codecs.
The reason for this is that the function that makes the codec decision
was not fully finished. So let's finish the codec decision function and
let's also use that decision when patching the payload type of outgoing
RTP packets.

Related: OS#5461
Change-Id: I6c3291f825488e5d8ce136aeb18450156794aeb5
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 5c19c14..784894c 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -120,8 +120,6 @@
 		trunk->audio_send_name ? "" : "no ", VTY_NEWLINE);
 	vty_out(vty, " number endpoints %u%s",
 		trunk->v.vty_number_endpoints, VTY_NEWLINE);
-	vty_out(vty, " %sallow-transcoding%s",
-		trunk->no_audio_transcoding ? "no " : "", VTY_NEWLINE);
 	if (strlen(g_cfg->call_agent_addr))
 		vty_out(vty, " call-agent ip %s%s", g_cfg->call_agent_addr,
 			VTY_NEWLINE);
@@ -701,25 +699,19 @@
 	return CMD_SUCCESS;
 }
 
-DEFUN_USRATTR(cfg_mgcp_allow_transcoding,
-	      cfg_mgcp_allow_transcoding_cmd,
-	      X(MGW_CMD_ATTR_NEWCONN),
-	      "allow-transcoding", "Allow transcoding\n")
+DEFUN_DEPRECATED(cfg_mgcp_allow_transcoding,
+		  cfg_mgcp_allow_transcoding_cmd,
+		  "allow-transcoding", "Allow transcoding\n")
 {
-	struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
-	OSMO_ASSERT(trunk);
-	trunk->no_audio_transcoding = 0;
+	vty_out(vty, "%% Deprecated 'allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
 	return CMD_SUCCESS;
 }
 
-DEFUN_USRATTR(cfg_mgcp_no_allow_transcoding,
-	      cfg_mgcp_no_allow_transcoding_cmd,
-	      X(MGW_CMD_ATTR_NEWCONN),
-	      "no allow-transcoding", NO_STR "Allow transcoding\n")
+DEFUN_DEPRECATED(cfg_mgcp_no_allow_transcoding,
+		 cfg_mgcp_no_allow_transcoding_cmd,
+		 "no allow-transcoding", NO_STR "Allow transcoding\n")
 {
-	struct mgcp_trunk *trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_VIRTUAL, MGCP_VIRT_TRUNK_ID);
-	OSMO_ASSERT(trunk);
-	trunk->no_audio_transcoding = 1;
+	vty_out(vty, "%% Deprecated 'no allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
 	return CMD_SUCCESS;
 }
 
@@ -1073,8 +1065,6 @@
 		if (trunk->audio_fmtp_extra)
 			vty_out(vty, "   sdp audio fmtp-extra %s%s",
 				trunk->audio_fmtp_extra, VTY_NEWLINE);
-		vty_out(vty, "  %sallow-transcoding%s",
-			trunk->no_audio_transcoding ? "no " : "", VTY_NEWLINE);
 	}
 
 	return CMD_SUCCESS;
@@ -1326,23 +1316,19 @@
 	return CMD_SUCCESS;
 }
 
-DEFUN_USRATTR(cfg_trunk_allow_transcoding,
-	      cfg_trunk_allow_transcoding_cmd,
-	      X(MGW_CMD_ATTR_NEWCONN),
-	      "allow-transcoding", "Allow transcoding\n")
+DEFUN_DEPRECATED(cfg_trunk_allow_transcoding,
+		 cfg_trunk_allow_transcoding_cmd,
+		 "allow-transcoding", "Allow transcoding\n")
 {
-	struct mgcp_trunk *trunk = vty->index;
-	trunk->no_audio_transcoding = 0;
+	vty_out(vty, "%% Deprecated 'allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
 	return CMD_SUCCESS;
 }
 
-DEFUN_USRATTR(cfg_trunk_no_allow_transcoding,
-	      cfg_trunk_no_allow_transcoding_cmd,
-	      X(MGW_CMD_ATTR_NEWCONN),
-	      "no allow-transcoding", NO_STR "Allow transcoding\n")
+DEFUN_DEPRECATED(cfg_trunk_no_allow_transcoding,
+		 cfg_trunk_no_allow_transcoding_cmd,
+		 "no allow-transcoding", NO_STR "Allow transcoding\n")
 {
-	struct mgcp_trunk *trunk = vty->index;
-	trunk->no_audio_transcoding = 1;
+	vty_out(vty, "%% Deprecated 'no allow-transcoding' config no longer has any effect%s", VTY_NEWLINE);
 	return CMD_SUCCESS;
 }