changeset 104:ce3b1db7d1d7

sip-in: force-pcma-codec config option to use PCMA when both are offered
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 27 Sep 2022 21:52:07 -0800
parents 3b3f07b112f3
children 9213ec8b434b
files sip-in/invite.c sip-in/readconf.c
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sip-in/invite.c	Mon Sep 26 20:46:19 2022 -0800
+++ b/sip-in/invite.c	Tue Sep 27 21:52:07 2022 -0800
@@ -24,6 +24,7 @@
 extern struct in_addr sip_bind_ip;
 extern unsigned sip_bind_port;
 extern int cfg_use_100rel;
+extern int cfg_force_pcma;
 extern struct call *call_list;
 
 extern struct call *find_call_by_sip_id();
@@ -210,13 +211,15 @@
 	}
 	switch (sdp_parse.codec_mask) {
 	case SDP_CODEC_MASK_PCMU:
-	case SDP_CODEC_MASK_BOTH:
 		use_pcma = 0;
 		break;
 	case SDP_CODEC_MASK_PCMA:
 	case SDP_CODEC_MASK_BOTH | SDP_CODEC_MASK_PCMA_PREF:
 		use_pcma = 1;
 		break;
+	case SDP_CODEC_MASK_BOTH:
+		use_pcma = cfg_force_pcma;
+		break;
 	default:
 		start_response_out_msg(&resp,
 			"488 Unsupported codec selection");
--- a/sip-in/readconf.c	Mon Sep 26 20:46:19 2022 -0800
+++ b/sip-in/readconf.c	Tue Sep 27 21:52:07 2022 -0800
@@ -17,6 +17,7 @@
 struct in_addr sip_bind_ip;
 unsigned sip_bind_port;
 int cfg_use_100rel;
+int cfg_force_pcma;
 unsigned cfg_retrans_timeout = 500;
 unsigned cfg_retrans_count = 10;
 unsigned max_forwards = 70;
@@ -165,6 +166,10 @@
 		handler = handle_bool;
 		var = &cfg_use_100rel;
 		set_id = 0;
+	} else if (!strcmp(kw, "force-pcma-codec")) {
+		handler = handle_bool;
+		var = &cfg_force_pcma;
+		set_id = 0;
 	} else if (!strcmp(kw, "sip-udp-retrans")) {
 		handler = handle_retrans_conf;
 		var = (void *) 0;