codecs: for IuUP, use AMR for codec matching

For finding usable codecs / matching codecs with remote call leg, use
AMR in place of IUFP.

On Iu, to the MGW we need to set the codec VND.3GPP.IUFP on the RAN
facing side. On the CN facing side, we indicate AMR instead, so that the
MGW decapsulates the IuUP into plain AMR RTP.

Related: SYS#5092
Change-Id: I752505dd8e2360665417cdba6a93cfa1490e4b70
diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index d63e8bd..18233b0 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -1440,6 +1440,17 @@
 		rtp_stream_set_one_codec(rtps_to_ran, &m->sdp);
 
 		/* Update codecs filter with the codec chosen by Assignment */
+		if (*codec_if_known == CODEC_IUFP) {
+			/* For IuUP, the MGW decapsulates it to plain AMR RTP. So for the purpose of matching to the
+			 * other call leg / figuring out codecs, set to AMR instead. */
+			m = codec_mapping_by_mgcp_codec(CODEC_AMR_8000_1);
+			if (!m) {
+				/* this should never happen, CODEC_AMR_8000_1 is definitely present in codec_map[]. */
+				LOG_TRANS(cc_trans, LOGL_ERROR, "Error setting codec to AMR\n");
+				call_leg_release(msc_a->cc.call_leg);
+				return;
+			}
+		}
 		cc_trans->cc.codecs.assignment = m->sdp;
 	} else {
 		cc_trans->cc.codecs.assignment = (struct sdp_audio_codec){};