changeset 100:1579ec0e9fb9

mgw internal code: set GSM side RTP packet size in one place and also set payload magic value for use by GSM->PSTN code
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2022 13:57:20 -0800
parents 738be11ac432
children ca21fbf9d2ea
files mgw/mdcx.c mgw/pstn2gsm.c mgw/struct.h
diffstat 3 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mgw/mdcx.c	Mon Sep 26 13:42:46 2022 -0800
+++ b/mgw/mdcx.c	Mon Sep 26 13:57:20 2022 -0800
@@ -14,9 +14,26 @@
 #include "../include/tmgw_ctrl.h"
 #include "../include/tmgw_const.h"
 #include "struct.h"
+#include "int_defs.h"
 
 extern struct endpoint *find_ep_by_id();
 
+static void
+gsm_vars_init(ep)
+	struct endpoint *ep;
+{
+	switch (ep->gsm_payload_msg_type) {
+	case GSM_TCHF_FRAME:
+		ep->gsm_rtp_pkt_size = RTP_PACKET_SIZE_GSM_FR;
+		ep->gsm_payload_magic = 0xD0;
+		return;
+	case GSM_TCHF_FRAME_EFR:
+		ep->gsm_rtp_pkt_size = RTP_PACKET_SIZE_GSM_EFR;
+		ep->gsm_payload_magic = 0xC0;
+		return;
+	}
+}
+
 mdcx_operation(ep, req)
 	struct endpoint *ep;
 	struct tmgw_ctrl_req *req;
@@ -47,6 +64,7 @@
 			sizeof(struct sockaddr_in));
 		ep->gsm_payload_type = req->gsm_payload_type;
 		ep->gsm_payload_msg_type = req->gsm_payload_msg_type;
+		gsm_vars_init(ep);
 	}
 	if (req->setup_mask & TMGW_CTRL_MASK_PSTN_CONN) {
 		if (ep->ep_type != TMGW_EP_TYPE_GATEWAY)
--- a/mgw/pstn2gsm.c	Mon Sep 26 13:42:46 2022 -0800
+++ b/mgw/pstn2gsm.c	Mon Sep 26 13:57:20 2022 -0800
@@ -126,11 +126,10 @@
 	switch (ep->gsm_payload_msg_type) {
 	case GSM_TCHF_FRAME:
 		gsm_encode(ep->gsm_encoder_state, pcm_samples, pkt.payload);
-		n = RTP_PACKET_SIZE_GSM_FR;
 		break;
 	}
 	addrlen = sizeof(struct sockaddr_in);
-	sendto(ep->rtp_gsm.rtp_fd, &pkt, n, 0,
+	sendto(ep->rtp_gsm.rtp_fd, &pkt, ep->gsm_rtp_pkt_size, 0,
 		(struct sockaddr *) &ep->rtp_gsm.remote_addr, addrlen);
 }
 
--- a/mgw/struct.h	Mon Sep 26 13:42:46 2022 -0800
+++ b/mgw/struct.h	Mon Sep 26 13:57:20 2022 -0800
@@ -23,6 +23,8 @@
 	struct rtp_one_end rtp_pstn;
 	unsigned	gsm_payload_type;
 	unsigned	gsm_payload_msg_type;
+	unsigned	gsm_rtp_pkt_size;
+	unsigned	gsm_payload_magic;
 	unsigned	pstn_payload_type;
 	unsigned	fwd_mode;
 	/* gateway functionality */