changeset 214:10a4b0b0a239

sip-manual-out: parse SDP for all responses, not just 200
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 08 Jul 2023 13:32:32 -0800
parents 55ad0f4bb33c
children 67289fac8a44
files sip-manual-out/sdp_in.c sip-manual-out/uac.c
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sip-manual-out/sdp_in.c	Sun Jun 25 14:16:53 2023 -0800
+++ b/sip-manual-out/sdp_in.c	Sat Jul 08 13:32:32 2023 -0800
@@ -17,7 +17,7 @@
 extern char *extract_to_tag();
 
 struct sockaddr_in rtp_remote_addr;
-int pcma_selected, rtp_out_enable;
+int got_sdp_answer, pcma_selected, rtp_out_enable;
 
 static
 check_sdp_present(msg)
@@ -43,10 +43,8 @@
 	struct sdp_parse sdp_parse;
 	int rc;
 
-	if (!check_sdp_present(msg)) {
-		printf("INVITE response has no SDP!\n");
+	if (!check_sdp_present(msg))
 		return;
-	}
 	rc = parse_incoming_sdp(msg->msg_body, msg->msg_body_len, &sdp_parse);
 	if (rc < 0) {
 		printf("SDP parse error: %d\n", rc);
@@ -71,6 +69,16 @@
 	rtp_remote_addr.sin_family = AF_INET;
 	rtp_remote_addr.sin_addr = sdp_parse.ip_addr;
 	rtp_remote_addr.sin_port = htons(sdp_parse.audio_port);
+	got_sdp_answer = 1;
+}
+
+void
+invite_200_rtpout()
+{
+	if (!got_sdp_answer) {
+		printf("INVITE response has no SDP!\n");
+		return;
+	}
 	rtp_out_enable = 1;
 	assign_rtpout_ssrc();
 	init_pcm_fill_octet();
--- a/sip-manual-out/uac.c	Sun Jun 25 14:16:53 2023 -0800
+++ b/sip-manual-out/uac.c	Sat Jul 08 13:32:32 2023 -0800
@@ -103,11 +103,12 @@
 		else
 			printf("To tag exceeds length limit!\n");
 	}
+	extract_resp_sdp(msg);
 	if (msg->status_code >= 200) {
 		printf("Sending ACK\n");
 		send_ack(sin);
 		if (msg->status_code <= 299)
-			extract_resp_sdp(msg);
+			invite_200_rtpout();
 	}
 }