diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index 5c35fdb0b4..f349a136c5 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -1863,7 +1863,7 @@ SPAN_DECLARE(int) t4_tx_set_tx_image_format(t4_tx_state_t *s, s->metadata.image_type = T4_IMAGE_TYPE_BILEVEL; } /* Squashing to a bi-level image is possible */ - span_log(&s->logging, SPAN_LOG_FLOW, "The image may be flattened to %d\n", s->metadata.image_type); + span_log(&s->logging, SPAN_LOG_FLOW, "The image will be flattened to %d\n", s->metadata.image_type); } } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 51e2505758..b6ff1771de 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -577,6 +577,26 @@ switch_status_t load_configuration(switch_bool_t reload) spandsp_globals.disable_v17 = 1; else spandsp_globals.disable_v17 = 0; + } else if (!strcmp(name, "enable-colour")) { + if (switch_true(value)) + spandsp_globals.enable_colour_fax = 1; + else + spandsp_globals.enable_colour_fax = 0; + } else if (!strcmp(name, "enable-image-resizing")) { + if (switch_true(value)) + spandsp_globals.enable_image_resizing = 1; + else + spandsp_globals.enable_image_resizing = 0; + } else if (!strcmp(name, "enable-colour-to-bilevel")) { + if (switch_true(value)) + spandsp_globals.enable_colour_to_bilevel = 1; + else + spandsp_globals.enable_colour_to_bilevel = 0; + } else if (!strcmp(name, "enable-grayscale-to-bilevel")) { + if (switch_true(value)) + spandsp_globals.enable_grayscale_to_bilevel = 1; + else + spandsp_globals.enable_grayscale_to_bilevel = 0; } else if (!strcmp(name, "enable-t38")) { if (switch_true(value)) { spandsp_globals.enable_t38= 1; diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index 323ff07a45..5f5a038c43 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp.h @@ -60,6 +60,10 @@ struct spandsp_globals { short int use_ecm; short int verbose; short int disable_v17; + short int enable_colour_fax; + short int enable_image_resizing; + short int enable_colour_to_bilevel; + short int enable_grayscale_to_bilevel; short int enable_t38; short int enable_t38_request; short int enable_t38_insist; diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 21a9cc51dc..993e44c0a5 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -89,6 +89,10 @@ struct pvt_s { int use_ecm; int disable_v17; + int enable_colour_fax; + int enable_image_resizing; + int enable_colour_to_bilevel; + int enable_grayscale_to_bilevel; int verbose; int caller; @@ -693,6 +697,7 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) const char *tz; int fec_entries = DEFAULT_FEC_ENTRIES; int fec_span = DEFAULT_FEC_SPAN; + int compressions; session = (switch_core_session_t *) pvt->session; @@ -872,8 +877,12 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) t30_set_phase_b_handler(t30, phase_b_handler, pvt); t30_set_supported_image_sizes(t30, - T4_SUPPORT_LENGTH_US_LETTER | T4_SUPPORT_LENGTH_US_LEGAL | T4_SUPPORT_LENGTH_UNLIMITED - | T4_SUPPORT_WIDTH_215MM | T4_SUPPORT_WIDTH_255MM | T4_SUPPORT_WIDTH_303MM); + T4_SUPPORT_LENGTH_US_LETTER + | T4_SUPPORT_LENGTH_US_LEGAL + | T4_SUPPORT_LENGTH_UNLIMITED + | T4_SUPPORT_WIDTH_215MM + | T4_SUPPORT_WIDTH_255MM + | T4_SUPPORT_WIDTH_303MM); t30_set_supported_bilevel_resolutions(t30, T4_RESOLUTION_R8_STANDARD | T4_RESOLUTION_R8_FINE @@ -883,7 +892,28 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) | T4_RESOLUTION_200_200 | T4_RESOLUTION_200_400 | T4_RESOLUTION_400_400); - t30_set_supported_colour_resolutions(t30, 0); + compressions = T4_COMPRESSION_T4_1D + | T4_COMPRESSION_T4_2D + | T4_COMPRESSION_T6 + | T4_COMPRESSION_T85 + | T4_COMPRESSION_T85_L0; + if (pvt->enable_colour_fax) { + t30_set_supported_colour_resolutions(t30, T4_RESOLUTION_100_100 + | T4_RESOLUTION_200_200 + | T4_RESOLUTION_300_300 + | T4_RESOLUTION_400_400); + compressions |= (T4_COMPRESSION_COLOUR | T4_COMPRESSION_T42_T81); + } else { + t30_set_supported_colour_resolutions(t30, 0); + } + if (pvt->enable_image_resizing) + compressions |= T4_COMPRESSION_RESCALING; + if (pvt->enable_colour_to_bilevel) + compressions |= T4_COMPRESSION_COLOUR_TO_BILEVEL; + if (pvt->enable_grayscale_to_bilevel) + compressions |= T4_COMPRESSION_GRAY_TO_BILEVEL; + + t30_set_supported_compressions(t30, compressions); if (pvt->disable_v17) { t30_set_supported_modems(t30, T30_SUPPORT_V29 | T30_SUPPORT_V27TER); @@ -894,11 +924,10 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) } if (pvt->use_ecm) { - t30_set_supported_compressions(t30, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6 | T4_COMPRESSION_T85 | T4_COMPRESSION_T85_L0); t30_set_ecm_capability(t30, TRUE); switch_channel_set_variable(channel, "fax_ecm_requested", "1"); } else { - t30_set_supported_compressions(t30, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D); + t30_set_ecm_capability(t30, FALSE); switch_channel_set_variable(channel, "fax_ecm_requested", "0"); } @@ -1217,6 +1246,30 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati pvt->disable_v17 = spandsp_globals.disable_v17; } + if ((tmp = switch_channel_get_variable(channel, "fax_enable_colour"))) { + pvt->enable_colour_fax = switch_true(tmp); + } else { + pvt->enable_colour_fax = spandsp_globals.enable_colour_fax; + } + + if ((tmp = switch_channel_get_variable(channel, "fax_enable_image_resizing"))) { + pvt->enable_image_resizing = switch_true(tmp); + } else { + pvt->enable_image_resizing = spandsp_globals.enable_image_resizing; + } + + if ((tmp = switch_channel_get_variable(channel, "fax_enable_colour_to_bilevel"))) { + pvt->enable_colour_to_bilevel = switch_true(tmp); + } else { + pvt->enable_colour_to_bilevel = spandsp_globals.enable_colour_to_bilevel; + } + + if ((tmp = switch_channel_get_variable(channel, "fax_enable_grayscale_to_bilevel"))) { + pvt->enable_grayscale_to_bilevel = switch_true(tmp); + } else { + pvt->enable_grayscale_to_bilevel = spandsp_globals.enable_grayscale_to_bilevel; + } + if ((tmp = switch_channel_get_variable(channel, "fax_verbose"))) { pvt->verbose = switch_true(tmp); } else {