summaryrefslogtreecommitdiffstats
path: root/net/freeswitch/patches/060-mod_spandsp-Fix-compilation-against-2023-06-02-spand.patch
blob: a5d08334087426e6528a4295e6dc0cc617c6eeed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From 76458fafc5a9cd0eebe94455ed39f41eac986c67 Mon Sep 17 00:00:00 2001
From: Patrice Fournier <patrice.fournier@t38fax.com>
Date: Tue, 4 Feb 2025 15:54:26 -0500
Subject: [PATCH] [mod_spandsp] Fix compilation against >=2023/06/02 spandsp

* [mod_spandsp] Fix compilation against >=2023/06/02 spandsp

spandsp, beginning with commit d9681c37 and coinciding with the
SPANDSP_RELEASE_DATE of 20230620, introduced the following changes to
its V.18 protocol API, which FreeSWITCH is not able to compile against:
- Certain V.18 constants were renamed.
- The v18_init function now requires passing a third function, handling
the V.18 modem's status changes.

This patch allows FreeSWITCH to build against current versions of
spandsp by:
- Using the new V.18 constant names.
- Implementing a simple status reporter callback function and passing it
as the third function to v18_init.

Additionally, it retains backward compatibility with prior versions of
spandp through #if conditions checking the value of
SPANDSP_RELEASE_DATE.

Signed-off-by: Patrice Fournier <patrice.fournier@t38fax.com>

* [mod_spandsp] Pass session to handle_v18_status.

---------

Signed-off-by: Patrice Fournier <patrice.fournier@t38fax.com>
Co-authored-by: Morgan Scarafiotti <morgan.scarafiotti@t38fax.com>
Co-authored-by: Andrey Volk <andywolk@gmail.com>
---
 .../applications/mod_spandsp/mod_spandsp.c    |  1 -
 .../applications/mod_spandsp/mod_spandsp.h    |  6 ++++
 .../mod_spandsp/mod_spandsp_dsp.c             | 32 ++++++++++++++++---
 3 files changed, 34 insertions(+), 5 deletions(-)

--- a/src/mod/applications/mod_spandsp/mod_spandsp.c
+++ b/src/mod/applications/mod_spandsp/mod_spandsp.c
@@ -37,7 +37,6 @@
 
 
 #include "mod_spandsp.h"
-#include <spandsp/version.h>
 #include "mod_spandsp_modem.h"
 
 /* **************************************************************************
--- a/src/mod/applications/mod_spandsp/mod_spandsp.h
+++ b/src/mod/applications/mod_spandsp/mod_spandsp.h
@@ -58,6 +58,12 @@ typedef int zap_socket_t;
 #define SPANDSP_EVENT_TXFAXNEGOCIATERESULT "spandsp::txfaxnegociateresult"
 #define SPANDSP_EVENT_RXFAXNEGOCIATERESULT "spandsp::rxfaxnegociateresult"
 
+#include <spandsp/version.h>
+
+#if SPANDSP_RELEASE_DATE < 20230620
+#define V18_MODE_WEITBRECHT_5BIT_4545 V18_MODE_5BIT_4545
+#define V18_MODE_WEITBRECHT_5BIT_50   V18_MODE_5BIT_50
+#endif
 
 
 /* The global stuff */
--- a/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c
+++ b/src/mod/applications/mod_spandsp/mod_spandsp_dsp.c
@@ -152,17 +152,27 @@ static void put_text_msg(void *user_data
 
 }
 
+#if SPANDSP_RELEASE_DATE >= 20230620
+static void handle_v18_status(void *user_data, int status)
+{
+	switch_core_session_t *session = (switch_core_session_t *) user_data;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+
+	switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s detected V.18 modem: %s\n", switch_channel_get_name(channel), v18_status_to_str(status));
+}
+#endif
+
 static int get_v18_mode(switch_core_session_t *session)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	const char *var;
-	int r = V18_MODE_5BIT_4545;
+	int r = V18_MODE_WEITBRECHT_5BIT_4545;
 
 	if ((var = switch_channel_get_variable(channel, "v18_mode"))) {
 		if (!strcasecmp(var, "5BIT_45") || !strcasecmp(var, "baudot")) {
-			r = V18_MODE_5BIT_4545;
+			r = V18_MODE_WEITBRECHT_5BIT_4545;
 		} else if (!strcasecmp(var, "5BIT_50")) {
-			r = V18_MODE_5BIT_50;
+			r = V18_MODE_WEITBRECHT_5BIT_50;
 		} else if (!strcasecmp(var, "DTMF")) {
 			r = V18_MODE_DTMF;
 		} else if (!strcasecmp(var, "EDT")) {
@@ -213,8 +223,11 @@ switch_status_t spandsp_tdd_send_session
 		return SWITCH_STATUS_FALSE;
 	}
 
+#if SPANDSP_RELEASE_DATE >= 20230620
+	tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL, handle_v18_status, session);
+#else
 	tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
-
+#endif
 
 	v18_put(tdd_state, text, -1);
 
@@ -260,7 +273,13 @@ switch_status_t spandsp_tdd_encode_sessi
 	}
 
 	pvt->session = session;
+
+#if SPANDSP_RELEASE_DATE >= 20230620
+	pvt->tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL, handle_v18_status, session);
+#else
 	pvt->tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
+#endif
+
 	pvt->head_lead = TDD_LEAD;
 
 	v18_put(pvt->tdd_state, text, -1);
@@ -338,7 +357,12 @@ switch_status_t spandsp_tdd_decode_sessi
 	}
 
 	pvt->session = session;
+
+#if SPANDSP_RELEASE_DATE >= 20230620
+	pvt->tdd_state = v18_init(NULL, FALSE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, pvt, handle_v18_status, session);
+#else
 	pvt->tdd_state = v18_init(NULL, FALSE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, pvt);
+#endif
 
 	if ((status = switch_core_media_bug_add(session, "spandsp_tdd_decode", NULL,
 						tdd_decode_callback, pvt, 0, SMBF_READ_REPLACE | SMBF_NO_PAUSE, &bug)) != SWITCH_STATUS_SUCCESS) {