--- opal-3.16.2/plugins/fax/fax_spandsp/spandsp_fax.cpp 2016-05-12 12:03:01.000000000 +0200 +++ opal-3.18.8/plugins/fax/fax_spandsp/spandsp_fax.cpp 2022-03-27 16:06:21.000000000 +0200 @@ -49,7 +46,8 @@ #endif extern "C" { -#include "spandsp.h" + #include "spandsp.h" + #include "spandsp/version.h" }; @@ -78,11 +76,15 @@ #define PTRACE(level, args) \ if (LogFunction != NULL && LogFunction(level, NULL, 0, NULL, NULL)) { \ - std::ostringstream strm; strm << args; \ - LogFunction(level, __FILE__, __LINE__, "FaxCodec", strm.str().c_str()); \ + std::ostringstream ptrace_strm; ptrace_strm << args; \ + LogFunction(level, __FILE__, __LINE__, "FaxCodec", ptrace_strm.str().c_str()); \ } else (void)0 +#if SPANDSP_RELEASE_DATE > 20110122 +static void SpanDSP_Message(void *, int level, const char *text) +#else static void SpanDSP_Message(int level, const char *text) +#endif { if (*text != '\0' && LogFunction != NULL) { // Close mapping between spandsp levels and OPAL ones, kust one tweak @@ -92,7 +94,7 @@ if (!LogFunction(level, NULL, 0, NULL, NULL)) return; - int last = strlen(text)-1; + size_t last = strlen(text)-1; if (text[last] == '\n') ((char *)text)[last] = '\0'; LogFunction(level, __FILE__, __LINE__, "SpanDSP", text); @@ -101,7 +103,11 @@ static void InitLogging(logging_state_t * logging, const std::string & tag) { +#if SPANDSP_RELEASE_DATE > 20110122 + span_log_set_message_handler(logging, SpanDSP_Message, NULL); +#else span_log_set_message_handler(logging, SpanDSP_Message); +#endif int level = SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_DEBUG; @@ -675,7 +681,7 @@ if (toLen < size) return false; - toLen = size; + toLen = (unsigned)size; memcpy(PluginCodec_RTP_GetPayloadPtr(toPtr), &packet[0], packet.size()); @@ -794,7 +800,11 @@ strm << "-1 (In progress)"; strm << "\n" "Bit Rate=" << stats.bit_rate << "\n" +#if SPANDSP_RELEASE_DATE > 20110122 + "Encoding=" << stats.type << ' ' << CompressionNames[stats.type&3] << "\n" +#else "Encoding=" << stats.encoding << ' ' << CompressionNames[stats.encoding&3] << "\n" +#endif "Error Correction=" << stats.error_correcting_mode << "\n" "Tx Pages=" << (stats.m_receiving ? -1 : stats.pages_tx) << "\n" "Rx Pages=" << (stats.m_receiving ? stats.pages_rx : -1) << "\n" @@ -824,28 +834,17 @@ int m_supported_resolutions; int m_supported_compressions; char m_phase; + t30_state_t * m_t30state; protected: FaxTIFF() : m_receiving(false) , m_stationIdentifer("-") - , m_supported_image_sizes(T30_SUPPORT_US_LETTER_LENGTH | - T30_SUPPORT_US_LEGAL_LENGTH | - T30_SUPPORT_UNLIMITED_LENGTH | - T30_SUPPORT_A4_LENGTH | - T30_SUPPORT_B4_LENGTH | - T30_SUPPORT_215MM_WIDTH | - T30_SUPPORT_255MM_WIDTH | - T30_SUPPORT_303MM_WIDTH) - , m_supported_resolutions(T30_SUPPORT_STANDARD_RESOLUTION | - T30_SUPPORT_FINE_RESOLUTION | - T30_SUPPORT_SUPERFINE_RESOLUTION | - T30_SUPPORT_R8_RESOLUTION | - T30_SUPPORT_R16_RESOLUTION) - , m_supported_compressions(T30_SUPPORT_T4_1D_COMPRESSION | - T30_SUPPORT_T4_2D_COMPRESSION | - T30_SUPPORT_T6_COMPRESSION) + , m_supported_image_sizes(INT_MAX) + , m_supported_resolutions(INT_MAX) + , m_supported_compressions(INT_MAX) , m_phase('A') + , m_t30state(NULL) { } @@ -887,6 +886,8 @@ bool Open(t30_state_t * t30state) { + m_t30state = t30state; + InitLogging(t30_get_logging_state(t30state), m_tag); if (m_tiffFileName.empty()) { @@ -936,7 +937,11 @@ t30_set_supported_modems(t30state, m_supported_modems); t30_set_supported_image_sizes(t30state, m_supported_image_sizes); +#if SPANDSP_RELEASE_DATE > 20110122 + t30_set_supported_bilevel_resolutions(t30state, m_supported_resolutions); +#else t30_set_supported_resolutions(t30state, m_supported_resolutions); +#endif t30_set_supported_compressions(t30state, m_supported_compressions); t30_set_ecm_capability(t30state, m_useECM); @@ -971,50 +976,62 @@ bool IsReceiving() const { return m_receiving; } +#if SPANDSP_RELEASE_DATE > 20110122 + static int PhaseB(void * user_data, int result) +#else static int PhaseB(t30_state_t * t30state, void * user_data, int result) +#endif { if (user_data != NULL) - ((FaxTIFF *)user_data)->PhaseB(t30state, result); + ((FaxTIFF *)user_data)->PhaseB(result); return T30_ERR_OK; } +#if SPANDSP_RELEASE_DATE > 20110122 + static int PhaseD(void * user_data, int result) +#else static int PhaseD(t30_state_t * t30state, void * user_data, int result) +#endif { if (user_data != NULL) - ((FaxTIFF *)user_data)->PhaseD(t30state, result); + ((FaxTIFF *)user_data)->PhaseD(result); return T30_ERR_OK; } +#if SPANDSP_RELEASE_DATE > 20110122 + static void PhaseE(void * user_data, int result) +#else static void PhaseE(t30_state_t * t30state, void * user_data, int result) +#endif { if (user_data != NULL) - ((FaxTIFF *)user_data)->PhaseE(t30state, result); + ((FaxTIFF *)user_data)->PhaseE(result); } private: - void PhaseB(t30_state_t * t30state, int) + void PhaseB(int) { m_phase = 'B'; PTRACE(3, m_tag << " SpanDSP entered Phase B:\n" - << MyStats(t30state, m_completed, m_receiving, m_phase)); + << MyStats(m_t30state, m_completed, m_receiving, m_phase)); } - void PhaseD(t30_state_t * t30state, int) + void PhaseD(int) { m_phase = 'D'; PTRACE(3, m_tag << " SpanDSP entered Phase D:\n" - << MyStats(t30state, m_completed, m_receiving, m_phase)); + << MyStats(m_t30state, m_completed, m_receiving, m_phase)); } - void PhaseE(t30_state_t * t30state, int result) + void PhaseE(int result) { if (result >= 0) m_completed = true; // Finished, exit codec loops m_phase = 'E'; PTRACE(3, m_tag << " SpanDSP entered Phase E:\n" - << MyStats(t30state, m_completed, m_receiving, m_phase)); + << MyStats(m_t30state, m_completed, m_receiving, m_phase)); } };