<p>Dustin Marquess has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17555">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_fax_spandsp: Add spandsp 3.0.0+ compatibility<br><br>Newer versions of spandsp did refactoring of code to add new features<br>like color FAXing. This refactoring broke backwards compatibility.<br>Add support for the new version while retaining support for 0.0.6.<br><br>ASTERISK-29729 #close<br><br>Change-Id: I3bd74550604ebcf0304528d647fa39abc62fbaa1<br>---<br>A doc/CHANGES-staging/res_fax_spandsp.txt<br>M res/res_fax_spandsp.c<br>2 files changed, 46 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/55/17555/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_fax_spandsp.txt b/doc/CHANGES-staging/res_fax_spandsp.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..4ad351f</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_fax_spandsp.txt</span><br><span>@@ -0,0 +1,3 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_fax_spandsp</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Adds support for spandsp 3.0.0.</span><br><span>diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c</span><br><span>index 030dfc0..24fcff5 100644</span><br><span>--- a/res/res_fax_spandsp.c</span><br><span>+++ b/res/res_fax_spandsp.c</span><br><span>@@ -167,10 +167,17 @@</span><br><span> static int spandsp_v21_new(struct spandsp_pvt *p);</span><br><span> static void session_destroy(struct spandsp_pvt *p);</span><br><span> static int t38_tx_packet_handler(t38_core_state_t *t38_core_state, void *data, const uint8_t *buf, int len, int count);</span><br><span style="color: hsl(0, 100%, 40%);">-static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code);</span><br><span style="color: hsl(0, 100%, 40%);">-static void spandsp_log(int level, const char *msg);</span><br><span> static int update_stats(struct spandsp_pvt *p, int completion_code);</span><br><span> static int spandsp_modems(struct ast_fax_session_details *details);</span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+/* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+static void t30_phase_e_handler(void *data, int completion_code);</span><br><span style="color: hsl(120, 100%, 40%);">+static void spandsp_log(void *user_data, int level, const char *msg);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+/* for spandsp release 0.0.6 */</span><br><span style="color: hsl(120, 100%, 40%);">+static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code);</span><br><span style="color: hsl(120, 100%, 40%);">+static void spandsp_log(int level, const char *msg);</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> static void set_logging(logging_state_t *state, struct ast_fax_session_details *details);</span><br><span> static void set_local_info(t30_state_t *t30_state, struct ast_fax_session_details *details);</span><br><span>@@ -375,13 +382,23 @@</span><br><span>  * This function pulls stats from the spandsp stack and stores them for res_fax</span><br><span>  * to use later.</span><br><span>  */</span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+/* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+static void t30_phase_e_handler(void *data, int completion_code)</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+/* for spandsp release 0.0.6 */</span><br><span> static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code)</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> {</span><br><span>   struct ast_fax_session *s = data;</span><br><span>    struct spandsp_pvt *p = s->tech_pvt;</span><br><span>      char headerinfo[T30_MAX_PAGE_HEADER_INFO + 1];</span><br><span>       const char *c;</span><br><span>       t30_stats_t stats;</span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+   /* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+   t30_state_t *t30_state = p->t30_state;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span>        ast_debug(5, "FAX session '%u' entering phase E\n", s->id);</span><br><span> </span><br><span>@@ -430,7 +447,13 @@</span><br><span>  *</span><br><span>  * \note This function is a callback function called by spandsp.</span><br><span>  */</span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+/* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+static void spandsp_log(void *user_data, int level, const char *msg)</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+/* for spandsp release 0.0.6 */</span><br><span> static void spandsp_log(int level, const char *msg)</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> {</span><br><span>         if (level == SPAN_LOG_ERROR) {</span><br><span>               ast_log(LOG_ERROR, "%s", msg);</span><br><span>@@ -449,7 +472,13 @@</span><br><span>              level = SPAN_LOG_DEBUG_3;</span><br><span>    }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+        /* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+   span_log_set_message_handler(state, spandsp_log, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+        /* for spandsp release 0.0.6 */</span><br><span>      span_log_set_message_handler(state, spandsp_log);</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>    span_log_set_level(state, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | level);</span><br><span> }</span><br><span> </span><br><span>@@ -479,7 +508,13 @@</span><br><span> static void set_ecm(t30_state_t *t30_state, struct ast_fax_session_details *details)</span><br><span> {</span><br><span>     t30_set_ecm_capability(t30_state, details->option.ecm);</span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+   /* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+   t30_set_supported_compressions(t30_state, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+    /* for spandsp release 0.0.6 */</span><br><span>      t30_set_supported_compressions(t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> }</span><br><span> </span><br><span> static int spandsp_v21_new(struct spandsp_pvt *p)</span><br><span>@@ -1256,7 +1291,13 @@</span><br><span>        }</span><br><span> </span><br><span>        /* prevent logging to stderr */</span><br><span style="color: hsl(120, 100%, 40%);">+#if SPANDSP_RELEASE_DATE >= 20120902</span><br><span style="color: hsl(120, 100%, 40%);">+      /* for spandsp shaphots 3.0.0 and higher */</span><br><span style="color: hsl(120, 100%, 40%);">+   span_set_message_handler(NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+  /* for spandsp release 0.0.6 */</span><br><span>      span_set_message_handler(NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span>  return AST_MODULE_LOAD_SUCCESS;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17555">change 17555</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/17555"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: I3bd74550604ebcf0304528d647fa39abc62fbaa1 </div>
<div style="display:none"> Gerrit-Change-Number: 17555 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Dustin Marquess <jailbird@fdf.net> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>