diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index fc26e7ebf0419cc31e6d6a56a860a935a733005a..eec904f57f56313f54ddc66a83fe9d0a4351efe0 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -12995,7 +12995,7 @@ static void add_codec_to_sdp(const struct sip_pvt *p,
 	/* Opus mandates 2 channels in rtpmap */
 	if (ast_format_cmp(format, ast_format_opus) == AST_FORMAT_CMP_EQUAL) {
 		ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u/2\r\n", rtp_code, mime, rate);
-	} else {
+	} else if ((35 <= rtp_code) || !(sip_cfg.compactheaders)) {
 		ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u\r\n", rtp_code, mime, rate);
 	}