diff mgw/pstn2gsm.c @ 174:c985c33baeac

mgw: support EFR by way of libgsmefr
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 10 Jan 2023 17:56:22 -0800
parents f062c32a5116
children cf1ba5d65188
line wrap: on
line diff
--- a/mgw/pstn2gsm.c	Mon Nov 21 12:17:55 2022 -0800
+++ b/mgw/pstn2gsm.c	Tue Jan 10 17:56:22 2023 -0800
@@ -15,6 +15,7 @@
 #include <syslog.h>
 #include <unistd.h>
 #include <gsm.h>	/* libgsm dependency */
+#include <gsm_efr.h>
 #include "../include/tmgw_ctrl.h"
 #include "../include/tmgw_const.h"
 #include "struct.h"
@@ -128,6 +129,10 @@
 	case GSM_TCHF_FRAME:
 		gsm_encode(ep->gsm_encoder_state, pcm_samples, pkt.payload);
 		break;
+	case GSM_TCHF_FRAME_EFR:
+		EFR_encode_frame(ep->gsm_encoder_state, pcm_samples,
+				 pkt.payload, (int *) 0, (int *) 0);
+		break;
 	}
 	addrlen = sizeof(struct sockaddr_in);
 	sendto(ep->rtp_gsm.rtp_fd, &pkt, ep->gsm_rtp_pkt_size, 0,
@@ -145,6 +150,11 @@
 		if (!ep->gsm_encoder_state)
 			return TMGW_RESP_ERR_RSRC;
 		break;
+	case GSM_TCHF_FRAME_EFR:
+		ep->gsm_encoder_state = EFR_encoder_create(0);
+		if (!ep->gsm_encoder_state)
+			return TMGW_RESP_ERR_RSRC;
+		break;
 	}
 	select_handlers[ep->rtp_pstn.rtp_fd] = pstn2gsm_rtp_in;
 	return TMGW_RESP_OK;