diff mgw/gsm2pstn.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 a6eb2de277f6
children cf1ba5d65188
line wrap: on
line diff
--- a/mgw/gsm2pstn.c	Mon Nov 21 12:17:55 2022 -0800
+++ b/mgw/gsm2pstn.c	Tue Jan 10 17:56:22 2023 -0800
@@ -16,6 +16,7 @@
 #include <unistd.h>
 #include <gsm.h>	/* libgsm dependency */
 #include <gsm_fr_preproc.h>
+#include <gsm_efr.h>
 #include "../include/tmgw_ctrl.h"
 #include "../include/tmgw_const.h"
 #include "struct.h"
@@ -127,6 +128,14 @@
 						 pkt.payload);
 		gsm_decode(ep->gsm_decoder_state, pkt.payload, pcm_samples);
 		break;
+	case GSM_TCHF_FRAME_EFR:
+		if (bfi)
+			EFR_decode_bfi_nodata(ep->gsm_decoder_state, taf,
+					      pcm_samples);
+		else
+			EFR_decode_frame(ep->gsm_decoder_state, pkt.payload,
+					 0, 0, pcm_samples);
+		break;
 	}
 	if (ep->dtmf_sample_ptr) {
 		bcopy(ep->dtmf_sample_ptr, pcm_samples, SAMPLES_PER_FRAME*2);
@@ -162,6 +171,11 @@
 			return TMGW_RESP_ERR_RSRC;
 		}
 		break;
+	case GSM_TCHF_FRAME_EFR:
+		ep->gsm_decoder_state = EFR_decoder_create();
+		if (!ep->gsm_decoder_state)
+			return TMGW_RESP_ERR_RSRC;
+		break;
 	}
 	select_handlers[ep->rtp_gsm.rtp_fd] = gsm2pstn_rtp_in;
 	return TMGW_RESP_OK;