Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/mod/applications/mod_spandsp/mod_spandsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ switch_status_t load_configuration(switch_bool_t reload)
spandsp_globals.tonedebug = 0;
spandsp_globals.t38_tx_reinvite_packet_count = 100;
spandsp_globals.t38_rx_reinvite_packet_count = 50;
spandsp_globals.t38_retransmission_delay = 0;
spandsp_globals.t38_indicator_redundancy_count = 3;
spandsp_globals.t38_control_data_end_redundancy_count = 3;
spandsp_globals.t38_image_data_end_redundancy_count = 3;

if ((xml = switch_xml_open_cfg("spandsp.conf", &cfg, NULL)) || (xml = switch_xml_open_cfg("fax.conf", &cfg, NULL))) {
status = SWITCH_STATUS_SUCCESS;
Expand Down Expand Up @@ -673,6 +677,17 @@ switch_status_t load_configuration(switch_bool_t reload)
spandsp_globals.spool = switch_core_strdup(spandsp_globals.config_pool, value);
} else if (!strcmp(name, "file-prefix")) {
spandsp_globals.prepend_string = switch_core_strdup(spandsp_globals.config_pool, value);
} else if (!strcmp(name, "t38-retransmission-delay")) {
spandsp_globals.t38_retransmission_delay = atoi(value);
} else if (!strcmp(name, "t38-indicator-redundancy-count")) {
int count = atoi(value);
spandsp_globals.t38_indicator_redundancy_count = (count > 0 ? count : 1);
} else if (!strcmp(name, "t38-control-data-redundancy-count")) {
int count = atoi(value);
spandsp_globals.t38_control_data_end_redundancy_count = (count > 0 ? count : 1);
} else if (!strcmp(name, "t38-image-data-redundancy-count")) {
int count = atoi(value);
spandsp_globals.t38_image_data_end_redundancy_count = (count > 0 ? count : 1);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown parameter %s\n", name);
}
Expand Down
4 changes: 4 additions & 0 deletions src/mod/applications/mod_spandsp/mod_spandsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ struct spandsp_globals {
int tonedebug;
int t38_tx_reinvite_packet_count;
int t38_rx_reinvite_packet_count;
int t38_retransmission_delay;
int t38_indicator_redundancy_count;
int t38_control_data_end_redundancy_count;
int t38_image_data_end_redundancy_count;
};

extern struct spandsp_globals spandsp_globals;
Expand Down
42 changes: 42 additions & 0 deletions src/mod/applications/mod_spandsp/mod_spandsp_fax.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ struct pvt_s {

int tx_page_start;
int tx_page_end;
int t38_retransmission_delay;
int t38_indicator_redundancy_count;
int t38_control_data_end_redundancy_count;
int t38_image_data_end_redundancy_count;

int done;

Expand Down Expand Up @@ -774,6 +778,10 @@ static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uin
r = -1;
break;
}

if (count > 1 && pvt->t38_retransmission_delay > 0) {
switch_yield(pvt->t38_retransmission_delay * 1000);
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID PACKETLEN: %d PASSED: %d:%d\n", r, len, count);
Expand Down Expand Up @@ -967,6 +975,9 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
}

t38_set_t38_version(pvt->t38_core, 0);
t38_set_redundancy_control(pvt->t38_core, T38_PACKET_CATEGORY_INDICATOR, pvt->t38_indicator_redundancy_count);
t38_set_redundancy_control(pvt->t38_core, T38_PACKET_CATEGORY_CONTROL_DATA_END, pvt->t38_control_data_end_redundancy_count);
t38_set_redundancy_control(pvt->t38_core, T38_PACKET_CATEGORY_IMAGE_DATA_END, pvt->t38_image_data_end_redundancy_count);

return SWITCH_STATUS_SUCCESS;
default:
Expand Down Expand Up @@ -1355,6 +1366,10 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati

pvt->tx_page_start = -1;
pvt->tx_page_end = -1;
pvt->t38_retransmission_delay = 0;
pvt->t38_indicator_redundancy_count = 3;
pvt->t38_control_data_end_redundancy_count = 3;
pvt->t38_image_data_end_redundancy_count = 3;


switch(pvt->app_mode) {
Expand Down Expand Up @@ -1510,6 +1525,33 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati
}
}

if ((tmp = switch_channel_get_variable(channel, "fax_t38_retransmission_delay"))) {
pvt->t38_retransmission_delay = atoi(tmp);
} else {
pvt->t38_retransmission_delay = spandsp_globals.t38_retransmission_delay;
}

if ((tmp = switch_channel_get_variable(channel, "fax_t38_indicator_redundancy_count"))) {
int count = atoi(tmp);
pvt->t38_indicator_redundancy_count = (count > 0 ? count : 1);
} else {
pvt->t38_indicator_redundancy_count = spandsp_globals.t38_indicator_redundancy_count;
}

if ((tmp = switch_channel_get_variable(channel, "fax_t38_control_data_end_redundancy_count"))) {
int count = atoi(tmp);
pvt->t38_control_data_end_redundancy_count = (count > 0 ? count : 1);
} else {
pvt->t38_control_data_end_redundancy_count = spandsp_globals.t38_control_data_end_redundancy_count;
}

if ((tmp = switch_channel_get_variable(channel, "fax_t38_image_data_end_redundancy_count"))) {
int count = atoi(tmp);
pvt->t38_image_data_end_redundancy_count = (count > 0 ? count : 1);
} else {
pvt->t38_image_data_end_redundancy_count = spandsp_globals.t38_image_data_end_redundancy_count;
}

switch_mutex_init(&pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));

return pvt;
Expand Down