The APIs for spandsp FAX have changes, removing one of the parameters passed in

the callbacks.
This commit is contained in:
Steve Underwood 2014-05-04 17:22:28 +08:00
parent 9db6d5ba9c
commit 38abcf7e2c
8 changed files with 242 additions and 202 deletions

View File

@ -153,43 +153,38 @@ typedef struct t30_state_s t30_state_t;
can access whatever additional information might have been received, using
t30_get_received_info().
\brief T.30 phase B callback handler.
\param s The T.30 context.
\param user_data An opaque pointer.
\param result The phase B event code.
\return The new status. Normally, T30_ERR_OK is returned.
*/
typedef int (*t30_phase_b_handler_t)(t30_state_t *s, void *user_data, int result);
typedef int (*t30_phase_b_handler_t)(void *user_data, int result);
/*!
T.30 phase D callback handler.
\brief T.30 phase D callback handler.
\param s The T.30 context.
\param user_data An opaque pointer.
\param result The phase D event code.
\return The new status. Normally, T30_ERR_OK is returned.
*/
typedef int (*t30_phase_d_handler_t)(t30_state_t *s, void *user_data, int result);
typedef int (*t30_phase_d_handler_t)(void *user_data, int result);
/*!
T.30 phase E callback handler.
\brief T.30 phase E callback handler.
\param s The T.30 context.
\param user_data An opaque pointer.
\param completion_code The phase E completion code.
*/
typedef void (*t30_phase_e_handler_t)(t30_state_t *s, void *user_data, int completion_code);
typedef void (*t30_phase_e_handler_t)(void *user_data, int completion_code);
/*!
T.30 real time frame handler.
\brief T.30 real time frame handler.
\param s The T.30 context.
\param user_data An opaque pointer.
\param incoming True for incoming, false for outgoing.
\param msg The HDLC message.
\param len The length of the message.
*/
typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s,
void *user_data,
typedef void (*t30_real_time_frame_handler_t)(void *user_data,
bool direction,
const uint8_t msg[],
int len);
@ -197,11 +192,10 @@ typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s,
/*!
T.30 document handler.
\brief T.30 document handler.
\param s The T.30 context.
\param user_data An opaque pointer.
\param result The document event code.
*/
typedef int (*t30_document_handler_t)(t30_state_t *s, void *user_data, int status);
typedef int (*t30_document_handler_t)(void *user_data, int status);
/*!
T.30 set a receive or transmit type handler.

View File

@ -769,7 +769,7 @@ static uint8_t check_next_tx_step(t30_state_t *s)
If so, we send an EOM, rather than an EOP. Then we will renegotiate, and the new
document will begin. */
if (s->document_handler)
more = s->document_handler(s, s->document_user_data, 0);
more = s->document_handler(s->document_user_data, 0);
else
more = false;
if (more)
@ -919,7 +919,7 @@ static void send_frame(t30_state_t *s, const uint8_t *msg, int len)
print_frame(s, "Tx: ", msg, len);
if (s->real_time_frame_handler)
s->real_time_frame_handler(s, s->real_time_frame_user_data, false, msg, len);
s->real_time_frame_handler(s->real_time_frame_user_data, false, msg, len);
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, msg, len);
}
@ -2683,7 +2683,7 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len)
}
if (s->phase_b_handler)
{
new_status = s->phase_b_handler(s, s->phase_b_user_data, msg[2]);
new_status = s->phase_b_handler(s->phase_b_user_data, msg[2]);
if (new_status != T30_ERR_OK)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Application rejected DIS/DTC - '%s'\n", t30_completion_code_to_str(new_status));
@ -2772,7 +2772,7 @@ static int process_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
if (s->phase_b_handler)
{
new_status = s->phase_b_handler(s, s->phase_b_user_data, msg[2]);
new_status = s->phase_b_handler(s->phase_b_user_data, msg[2]);
if (new_status != T30_ERR_OK)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Application rejected DCS - '%s'\n", t30_completion_code_to_str(new_status));
@ -3015,7 +3015,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len)
rx_end_page(s);
report_rx_ecm_page_result(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, s->last_pps_fcf2);
s->phase_d_handler(s->phase_d_user_data, s->last_pps_fcf2);
rx_start_page(s);
break;
}
@ -3590,7 +3590,7 @@ static void process_state_f_doc_non_ecm(t30_state_t *s, const uint8_t *msg, int
case T30_MPS:
/* Treat this as a bad quality page. */
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->next_rx_step = msg[2] & 0xFE;
queue_phase(s, T30_PHASE_D_TX);
set_state(s, T30_STATE_III_Q_RTN);
@ -3605,7 +3605,7 @@ static void process_state_f_doc_non_ecm(t30_state_t *s, const uint8_t *msg, int
case T30_EOS:
/* Treat this as a bad quality page. */
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->next_rx_step = msg[2] & 0xFE;
/* Return to phase B */
queue_phase(s, T30_PHASE_B_TX);
@ -3620,7 +3620,7 @@ static void process_state_f_doc_non_ecm(t30_state_t *s, const uint8_t *msg, int
case T30_EOP:
/* Treat this as a bad quality page. */
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->next_rx_step = msg[2] & 0xFE;
queue_phase(s, T30_PHASE_D_TX);
set_state(s, T30_STATE_III_Q_RTN);
@ -3667,7 +3667,7 @@ static void assess_copy_quality(t30_state_t *s, uint8_t fcf)
}
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (fcf == T30_EOP)
terminate_operation_in_progress(s);
else
@ -4042,7 +4042,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4054,7 +4054,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_MPS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
/* Transmit the next page */
if (tx_start_page(s))
{
@ -4069,7 +4069,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
report_tx_result(s, true);
return_to_phase_b(s, false);
@ -4078,7 +4078,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
send_dcn(s);
report_tx_result(s, true);
@ -4093,7 +4093,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_MPS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (tx_start_page(s))
{
/* TODO: recover */
@ -4115,7 +4115,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
t4_tx_release(&s->t4.tx);
/* TODO: should go back to T, and resend */
return_to_phase_b(s, true);
@ -4124,7 +4124,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
t4_tx_release(&s->t4.tx);
send_dcn(s);
break;
@ -4136,7 +4136,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4149,7 +4149,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_MPS:
s->retries = 0;
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (!s->retransmit_capable)
{
/* Send the next page, regardless of the problem with the current one. */
@ -4175,7 +4175,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOS:
s->retries = 0;
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (s->retransmit_capable)
{
/* Wait for DIS */
@ -4189,7 +4189,7 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOP:
s->retries = 0;
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (s->retransmit_capable)
{
/* Send fresh training, and then repeat the last page */
@ -4401,7 +4401,7 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le
case T30_MPS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (tx_start_page(s))
{
/* TODO: recover */
@ -4419,7 +4419,7 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le
case T30_EOS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
report_tx_result(s, true);
return_to_phase_b(s, false);
@ -4428,7 +4428,7 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
send_dcn(s);
report_tx_result(s, true);
@ -4478,7 +4478,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len)
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4505,7 +4505,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_MPS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (tx_start_page(s))
{
/* TODO: recover */
@ -4523,7 +4523,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
report_tx_result(s, true);
return_to_phase_b(s, false);
@ -4532,7 +4532,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len)
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
send_dcn(s);
report_tx_result(s, true);
@ -4566,7 +4566,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len)
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4593,7 +4593,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4620,7 +4620,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len
case T30_MPS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
if (tx_start_page(s))
{
/* TODO: recover */
@ -4638,7 +4638,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len
case T30_EOS:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
report_tx_result(s, true);
return_to_phase_b(s, false);
@ -4647,7 +4647,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len
case T30_EOP:
tx_end_page(s);
if (s->phase_d_handler)
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
terminate_operation_in_progress(s);
send_dcn(s);
report_tx_result(s, true);
@ -4678,7 +4678,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4753,7 +4753,7 @@ static void process_state_iv_eor(t30_state_t *s, const uint8_t *msg, int len)
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4802,7 +4802,7 @@ static void process_state_iv_eor_rnr(t30_state_t *s, const uint8_t *msg, int len
s->retries = 0;
if (s->phase_d_handler)
{
s->phase_d_handler(s, s->phase_d_user_data, fcf);
s->phase_d_handler(s->phase_d_user_data, fcf);
s->timer_t3 = ms_to_samples(DEFAULT_TIMER_T3);
}
}
@ -4827,7 +4827,7 @@ static void process_rx_control_msg(t30_state_t *s, const uint8_t *msg, int len)
/* We should only get good frames here. */
print_frame(s, "Rx: ", msg, len);
if (s->real_time_frame_handler)
s->real_time_frame_handler(s, s->real_time_frame_user_data, true, msg, len);
s->real_time_frame_handler(s->real_time_frame_user_data, true, msg, len);
if ((msg[1] & 0x10) == 0)
{
@ -6267,7 +6267,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
/* We have now allowed time for the last message to flush through
the system, so it is safe to report the end of the call. */
if (s->phase_e_handler)
s->phase_e_handler(s, s->phase_e_user_data, s->current_status);
s->phase_e_handler(s->phase_e_user_data, s->current_status);
set_state(s, T30_STATE_CALL_FINISHED);
set_phase(s, T30_PHASE_CALL_FINISHED);
release_resources(s);
@ -6527,7 +6527,7 @@ SPAN_DECLARE(void) t30_terminate(t30_state_t *s)
break;
}
if (s->phase_e_handler)
s->phase_e_handler(s, s->phase_e_user_data, s->current_status);
s->phase_e_handler(s->phase_e_user_data, s->current_status);
set_state(s, T30_STATE_CALL_FINISHED);
set_phase(s, T30_PHASE_CALL_FINISHED);
release_resources(s);

View File

@ -98,7 +98,13 @@ enum
{
AUDIO_FAX,
T38_TERMINAL_FAX,
T38_GATEWAY_FAX
T38_GATEWAY_FAX,
T31_AUDIO_FAX,
T31_T38_TERMINAL_FAX,
T31_T38_GATEWAY_FAX,
TSB85_AUDIO_FAX,
TSB85_T38_TERMINAL_FAX,
TSB85_T38_GATEWAY_FAX
};
int mode[2] = {AUDIO_FAX, AUDIO_FAX};
@ -127,17 +133,19 @@ bool succeeded[2] = {false, false};
bool t38_simulate_incrementing_repeats = false;
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
static int phase_b_handler(void *user_data, int result)
{
int i;
int ch;
int status;
int len;
t30_state_t *s;
char tag[20];
const char *u;
const uint8_t *v;
i = (int) (intptr_t) user_data;
s = t30_state[i];
ch = i + 'A';
snprintf(tag, sizeof(tag), "%c: Phase B", ch);
printf("%c: Phase B handler - (0x%X) %s\n", ch, result, t30_frametype(result));
@ -296,14 +304,18 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static int phase_d_handler(t30_state_t *s, void *user_data, int result)
static int phase_d_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i + 'A');
printf("%c: Phase D handler - (0x%X) %s\n", i + 'A', result, t30_frametype(result));
s = t30_state[i];
ch = i + 'A';
snprintf(tag, sizeof(tag), "%c: Phase D", ch);
printf("%c: Phase D handler - (0x%X) %s\n", ch, result, t30_frametype(result));
fax_log_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -313,9 +325,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
if (test_local_interrupt)
{
if (i == 'A')
if (i == 0)
{
printf("%c: Initiating interrupt request\n", i);
printf("%c: Initiating interrupt request\n", ch);
t30_local_interrupt_request(s, true);
}
else
@ -326,7 +338,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
case T30_PRI_MPS:
case T30_PRI_EOM:
case T30_PRI_EOP:
printf("%c: Accepting interrupt request\n", i);
printf("%c: Accepting interrupt request\n", ch);
t30_local_interrupt_request(s, true);
break;
case T30_PIN:
@ -338,15 +350,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static void phase_e_handler(void *user_data, int result)
{
int i;
int ch;
t30_stats_t t;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i + 'A');
printf("%c: Phase E handler - (%d) %s\n", i + 'A', result, t30_completion_code_to_str(result));
s = t30_state[i];
ch = i + 'A';
snprintf(tag, sizeof(tag), "%c: Phase E", ch);
printf("%c: Phase E handler - (%d) %s\n", ch, result, t30_completion_code_to_str(result));
fax_log_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -356,29 +372,32 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static void real_time_frame_handler(t30_state_t *s,
void *user_data,
static void real_time_frame_handler(void *user_data,
bool incoming,
const uint8_t *msg,
int len)
{
int i;
int ch;
i = (intptr_t) user_data;
ch = i + 'A';
printf("%c: Real time frame handler - %s, %s, length = %d\n",
i + 'A',
ch,
(incoming) ? "line->T.30" : "T.30->line",
t30_frametype(msg[2]),
len);
}
/*- End of function --------------------------------------------------------*/
static int document_handler(t30_state_t *s, void *user_data, int event)
static int document_handler(void *user_data, int event)
{
int i;
int ch;
i = (intptr_t) user_data;
printf("%c: Document handler - event %d\n", i + 'A', event);
ch = i + 'A';
printf("%c: Document handler - event %d\n", ch, event);
return false;
}
/*- End of function --------------------------------------------------------*/

View File

@ -91,27 +91,31 @@ int test_seq_ptr = 0;
t31_state_t *t31_state;
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
static int phase_b_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", ch);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
static int phase_d_handler(t30_state_t *s, void *user_data, int result)
static int phase_d_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", ch);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -119,18 +123,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static void phase_e_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("Phase E handler on channel %c\n", i);
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", ch);
printf("Phase E handler on channel %c\n", ch);
fax_log_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
//exit(0);
}
/*- End of function --------------------------------------------------------*/
@ -502,9 +507,9 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int
t30_set_tx_ident(t30, "11111111");
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
//t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) 'A');
t30_set_phase_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
if (t38_mode)
logging = t38_terminal_get_logging_state(t38_state);

View File

@ -280,27 +280,31 @@ int test_seq_ptr = 0;
t31_state_t *t31_state;
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
static int phase_b_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", ch);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
static int phase_d_handler(t30_state_t *s, void *user_data, int result)
static int phase_d_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", ch);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -308,18 +312,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static void phase_e_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("Phase E handler on channel %c\n", i);
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", ch);
printf("Phase E handler on channel %c\n", ch);
fax_log_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
//exit(0);
}
/*- End of function --------------------------------------------------------*/
@ -600,9 +605,9 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
t30_set_tx_ident(t30, "11111111");
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
//t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) 'A');
t30_set_phase_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
if (t38_mode)
logging = t38_terminal_get_logging_state(t38_state);

View File

@ -70,27 +70,31 @@ static int done = false;
static int started = false;
static int64_t current = 0;
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
static int phase_b_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", ch);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
static int phase_d_handler(t30_state_t *s, void *user_data, int result)
static int phase_d_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", ch);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -98,15 +102,17 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static void phase_e_handler(void *user_data, int result)
{
int i;
int ch;
t30_stats_t t;
t30_state_t *s;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", ch);
printf("%c: Phase E handler on channel %c - (%d) %s\n", ch, ch, result, t30_completion_code_to_str(result));
fax_log_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -319,6 +325,7 @@ int main(int argc, char *argv[])
t30_state_t *t30;
logging_state_t *logging;
const char *input_file_name;
const char *input_tiff_file_name;
int t38_version;
int caller;
int use_ecm;
@ -338,6 +345,7 @@ int main(int argc, char *argv[])
t38_version = 0;
options = 0;
input_file_name = INPUT_FILE_NAME;
input_tiff_file_name = INPUT_TIFF_FILE_NAME;
fill_removal = false;
use_tep = false;
use_transmit_on_idle = true;
@ -348,7 +356,7 @@ int main(int argc, char *argv[])
src_port = 0;
dest_addr = 0;
dest_port = 0;
while ((opt = getopt(argc, argv, "cD:d:eFGi:lm:oS:s:tv:")) != -1)
while ((opt = getopt(argc, argv, "cD:d:eFGi:lm:oS:s:T:tv:")) != -1)
{
switch (opt)
{
@ -388,6 +396,9 @@ int main(int argc, char *argv[])
case 's':
src_port = atoi(optarg);
break;
case 'T':
input_tiff_file_name = optarg;
break;
case 't':
use_tep = true;
break;
@ -433,12 +444,12 @@ int main(int argc, char *argv[])
t30_set_tx_ident(t30, "11111111");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
if (caller)
t30_set_tx_file(t30, INPUT_TIFF_FILE_NAME, -1, -1);
t30_set_tx_file(t30, input_tiff_file_name, -1, -1);
else
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
t30_set_phase_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
t30_set_ecm_capability(t30, use_ecm);
t30_set_supported_compressions(t30,
T4_COMPRESSION_T4_1D
@ -519,12 +530,12 @@ int main(int argc, char *argv[])
t30_set_tx_ident(t30, "22222222");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
if (caller)
t30_set_tx_file(t30, INPUT_TIFF_FILE_NAME, -1, -1);
t30_set_tx_file(t30, input_tiff_file_name, -1, -1);
else
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'B');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'B');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'B');
t30_set_phase_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
t30_set_ecm_capability(t30, use_ecm);
t30_set_supported_compressions(t30,
T4_COMPRESSION_T4_1D

View File

@ -94,20 +94,22 @@ char next_tx_file[1000];
static int next_step(faxtester_state_t *s);
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
static int phase_b_handler(void *user_data, int result)
{
int i;
int ch;
int status;
t30_state_t *s;
const char *u;
i = (intptr_t) user_data;
s = (t30_state_t *) user_data;
ch = 'A';
status = T30_ERR_OK;
if ((u = t30_get_rx_ident(s)))
{
printf("%c: Phase B: remote ident '%s'\n", i, u);
printf("%c: Phase B: remote ident '%s'\n", ch, u);
if (expected_rx_info.ident[0] && strcmp(expected_rx_info.ident, u))
{
printf("%c: Phase B: remote ident incorrect! - expected '%s'\n", i, expected_rx_info.ident);
printf("%c: Phase B: remote ident incorrect! - expected '%s'\n", ch, expected_rx_info.ident);
status = T30_ERR_IDENT_UNACCEPTABLE;
}
}
@ -115,16 +117,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
if (expected_rx_info.ident[0])
{
printf("%c: Phase B: remote ident missing!\n", i);
printf("%c: Phase B: remote ident missing!\n", ch);
status = T30_ERR_IDENT_UNACCEPTABLE;
}
}
if ((u = t30_get_rx_sub_address(s)))
{
printf("%c: Phase B: remote sub-address '%s'\n", i, u);
printf("%c: Phase B: remote sub-address '%s'\n", ch, u);
if (expected_rx_info.sub_address[0] && strcmp(expected_rx_info.sub_address, u))
{
printf("%c: Phase B: remote sub-address incorrect! - expected '%s'\n", i, expected_rx_info.sub_address);
printf("%c: Phase B: remote sub-address incorrect! - expected '%s'\n", ch, expected_rx_info.sub_address);
status = T30_ERR_SUB_UNACCEPTABLE;
}
}
@ -132,16 +134,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
if (expected_rx_info.sub_address[0])
{
printf("%c: Phase B: remote sub-address missing!\n", i);
printf("%c: Phase B: remote sub-address missing!\n", ch);
status = T30_ERR_SUB_UNACCEPTABLE;
}
}
if ((u = t30_get_rx_polled_sub_address(s)))
{
printf("%c: Phase B: remote polled sub-address '%s'\n", i, u);
printf("%c: Phase B: remote polled sub-address '%s'\n", ch, u);
if (expected_rx_info.polled_sub_address[0] && strcmp(expected_rx_info.polled_sub_address, u))
{
printf("%c: Phase B: remote polled sub-address incorrect! - expected '%s'\n", i, expected_rx_info.polled_sub_address);
printf("%c: Phase B: remote polled sub-address incorrect! - expected '%s'\n", ch, expected_rx_info.polled_sub_address);
status = T30_ERR_PSA_UNACCEPTABLE;
}
}
@ -149,16 +151,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
if (expected_rx_info.polled_sub_address[0])
{
printf("%c: Phase B: remote polled sub-address missing!\n", i);
printf("%c: Phase B: remote polled sub-address missing!\n", ch);
status = T30_ERR_PSA_UNACCEPTABLE;
}
}
if ((u = t30_get_rx_selective_polling_address(s)))
{
printf("%c: Phase B: remote selective polling address '%s'\n", i, u);
printf("%c: Phase B: remote selective polling address '%s'\n", ch, u);
if (expected_rx_info.selective_polling_address[0] && strcmp(expected_rx_info.selective_polling_address, u))
{
printf("%c: Phase B: remote selective polling address incorrect! - expected '%s'\n", i, expected_rx_info.selective_polling_address);
printf("%c: Phase B: remote selective polling address incorrect! - expected '%s'\n", ch, expected_rx_info.selective_polling_address);
status = T30_ERR_SEP_UNACCEPTABLE;
}
}
@ -166,16 +168,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
if (expected_rx_info.selective_polling_address[0])
{
printf("%c: Phase B: remote selective polling address missing!\n", i);
printf("%c: Phase B: remote selective polling address missing!\n", ch);
status = T30_ERR_SEP_UNACCEPTABLE;
}
}
if ((u = t30_get_rx_sender_ident(s)))
{
printf("%c: Phase B: remote sender ident '%s'\n", i, u);
printf("%c: Phase B: remote sender ident '%s'\n", ch, u);
if (expected_rx_info.sender_ident[0] && strcmp(expected_rx_info.sender_ident, u))
{
printf("%c: Phase B: remote sender ident incorrect! - expected '%s'\n", i, expected_rx_info.sender_ident);
printf("%c: Phase B: remote sender ident incorrect! - expected '%s'\n", ch, expected_rx_info.sender_ident);
status = T30_ERR_SID_UNACCEPTABLE;
}
}
@ -183,16 +185,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
if (expected_rx_info.sender_ident[0])
{
printf("%c: Phase B: remote sender ident missing!\n", i);
printf("%c: Phase B: remote sender ident missing!\n", ch);
status = T30_ERR_SID_UNACCEPTABLE;
}
}
if ((u = t30_get_rx_password(s)))
{
printf("%c: Phase B: remote password '%s'\n", i, u);
printf("%c: Phase B: remote password '%s'\n", ch, u);
if (expected_rx_info.password[0] && strcmp(expected_rx_info.password, u))
{
printf("%c: Phase B: remote password incorrect! - expected '%s'\n", i, expected_rx_info.password);
printf("%c: Phase B: remote password incorrect! - expected '%s'\n", ch, expected_rx_info.password);
status = T30_ERR_PWD_UNACCEPTABLE;
}
}
@ -200,24 +202,27 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
if (expected_rx_info.password[0])
{
printf("%c: Phase B: remote password missing!\n", i);
printf("%c: Phase B: remote password missing!\n", ch);
status = T30_ERR_PWD_UNACCEPTABLE;
}
}
printf("%c: Phase B handler on channel %d - (0x%X) %s\n", i, i, result, t30_frametype(result));
printf("%c: Phase B handler on channel %d - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
return status;
}
/*- End of function --------------------------------------------------------*/
static int phase_d_handler(t30_state_t *s, void *user_data, int result)
static int phase_d_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
i = 0;
s = (t30_state_t *) user_data;
ch = i + 'A';
snprintf(tag, sizeof(tag), "%c: Phase D", ch);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", ch, ch, result, t30_frametype(result));
fax_log_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
@ -227,9 +232,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
if (test_local_interrupt)
{
if (i == 'A')
if (i == 0)
{
printf("%c: Initiating interrupt request\n", i);
printf("%c: Initiating interrupt request\n", ch);
t30_local_interrupt_request(s, true);
}
else
@ -240,7 +245,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
case T30_PRI_MPS:
case T30_PRI_EOM:
case T30_PRI_EOP:
printf("%c: Accepting interrupt request\n", i);
printf("%c: Accepting interrupt request\n", ch);
t30_local_interrupt_request(s, true);
break;
case T30_PIN:
@ -252,22 +257,23 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
}
/*- End of function --------------------------------------------------------*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static void phase_e_handler(void *user_data, int result)
{
int i;
int ch;
t30_state_t *s;
char tag[20];
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result));
ch = 'A';
s = (t30_state_t *) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", ch);
printf("%c: Phase E handler on channel %c - (%d) %s\n", ch, ch, result, t30_completion_code_to_str(result));
fax_log_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
}
/*- End of function --------------------------------------------------------*/
static void t30_real_time_frame_handler(t30_state_t *s,
void *user_data,
static void t30_real_time_frame_handler(void *user_data,
bool incoming,
const uint8_t *msg,
int len)
@ -286,12 +292,14 @@ static void t30_real_time_frame_handler(t30_state_t *s,
}
/*- End of function --------------------------------------------------------*/
static int document_handler(t30_state_t *s, void *user_data, int event)
static int document_handler(void *user_data, int event)
{
int i;
int ch;
t30_state_t *s;
i = (intptr_t) user_data;
fprintf(stderr, "%d: Document handler on channel %d - event %d\n", i, i, event);
ch = 'A';
s = (t30_state_t *) user_data;
fprintf(stderr, "%d: Document handler on channel %d - event %d\n", ch, ch, event);
if (next_tx_file[0])
{
t30_set_tx_file(s, next_tx_file, -1, -1);
@ -411,11 +419,11 @@ static void fax_prepare(void)
t30_set_supported_colour_resolutions(t30, 0);
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
t30_set_supported_compressions(t30, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
t30_set_real_time_frame_handler(t30, t30_real_time_frame_handler, (void *) (intptr_t) 'A');
t30_set_document_handler(t30, document_handler, (void *) (intptr_t) 'A');
t30_set_phase_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
t30_set_real_time_frame_handler(t30, t30_real_time_frame_handler, (void *) t30);
t30_set_document_handler(t30, document_handler, (void *) t30);
logging = fax_get_logging_state(fax);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);

View File

@ -75,6 +75,7 @@ struct pvt_s {
mod_spandsp_fax_application_mode_t app_mode;
t30_state_t *t30;
fax_state_t *fax_state;
t38_terminal_state_t *t38_state;
t38_gateway_state_t *t38_gateway_state;
@ -292,7 +293,7 @@ void mod_spandsp_log_message(void *user_data, int level, const char *msg)
}
}
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
static int phase_b_handler(void *user_data, int result)
{
t30_stats_t t30_stats;
switch_core_session_t *session;
@ -312,10 +313,10 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
channel = switch_core_session_get_channel(session);
switch_assert(channel);
t30_get_transfer_statistics(s, &t30_stats);
t30_get_transfer_statistics(pvt->t30, &t30_stats);
local_ident = switch_str_nil(t30_get_tx_ident(s));
far_ident = switch_str_nil(t30_get_rx_ident(s));
local_ident = switch_str_nil(t30_get_tx_ident(pvt->t30));
far_ident = switch_str_nil(t30_get_rx_ident(pvt->t30));
fax_transfer_rate = switch_core_session_sprintf(session, "%i", t30_stats.bit_rate);
if (fax_transfer_rate) {
@ -324,9 +325,9 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
switch_channel_set_variable(channel, "fax_ecm_used", (t30_stats.error_correcting_mode) ? "on" : "off");
switch_channel_set_variable(channel, "fax_local_station_id", local_ident);
switch_channel_set_variable(channel, "fax_remote_station_id", far_ident);
switch_channel_set_variable(channel, "fax_remote_country", switch_str_nil(t30_get_rx_country(s)));
switch_channel_set_variable(channel, "fax_remote_vendor", switch_str_nil(t30_get_rx_vendor(s)));
switch_channel_set_variable(channel, "fax_remote_model", switch_str_nil(t30_get_rx_model(s)));
switch_channel_set_variable(channel, "fax_remote_country", switch_str_nil(t30_get_rx_country(pvt->t30)));
switch_channel_set_variable(channel, "fax_remote_vendor", switch_str_nil(t30_get_rx_vendor(pvt->t30)));
switch_channel_set_variable(channel, "fax_remote_model", switch_str_nil(t30_get_rx_model(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "=== Negotiation Result =======================================================\n");
@ -335,9 +336,9 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t30_stats.bit_rate);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ECM status %s\n", (t30_stats.error_correcting_mode) ? "on" : "off");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote country: %s\n", switch_str_nil(t30_get_rx_country(s)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(s)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(s)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote country: %s\n", switch_str_nil(t30_get_rx_country(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n");
@ -353,16 +354,16 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-ecm-used", (t30_stats.error_correcting_mode) ? "on" : "off");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-local-station-id", local_ident);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-station-id", far_ident);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-country", switch_str_nil(t30_get_rx_country(s)));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-vendor", switch_str_nil(t30_get_rx_vendor(s)));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-model", switch_str_nil(t30_get_rx_model(s)));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-country", switch_str_nil(t30_get_rx_country(pvt->t30)));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-vendor", switch_str_nil(t30_get_rx_vendor(pvt->t30)));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-model", switch_str_nil(t30_get_rx_model(pvt->t30)));
switch_event_fire(&event);
}
return T30_ERR_OK;
}
static int phase_d_handler(t30_state_t *s, void *user_data, int msg)
static int phase_d_handler(void *user_data, int msg)
{
t30_stats_t t30_stats;
char *fax_file_image_resolution = NULL;
@ -388,7 +389,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg)
channel = switch_core_session_get_channel(session);
switch_assert(channel);
t30_get_transfer_statistics(s, &t30_stats);
t30_get_transfer_statistics(pvt->t30, &t30_stats);
/* Set Channel Variable */
@ -476,7 +477,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg)
/*
* Called at the end of the document
*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static void phase_e_handler(void *user_data, int result)
{
t30_stats_t t;
const char *local_ident;
@ -504,9 +505,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
channel = switch_core_session_get_channel(session);
switch_assert(channel);
t30_get_transfer_statistics(s, &t);
local_ident = switch_str_nil(t30_get_tx_ident(s));
far_ident = switch_str_nil(t30_get_rx_ident(s));
t30_get_transfer_statistics(pvt->t30, &t);
local_ident = switch_str_nil(t30_get_tx_ident(pvt->t30));
far_ident = switch_str_nil(t30_get_rx_ident(pvt->t30));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n");
@ -519,7 +520,6 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax successfully managed. How ?\n");
}
switch_channel_set_variable(channel, "fax_success", "1");
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax processing not successful - result (%d) %s.\n", result,
t30_completion_code_to_str(result));
@ -535,9 +535,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "ECM status %s\n", (t.error_correcting_mode) ? "on" : "off");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote country: %s\n", switch_str_nil(t30_get_rx_country(s)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(s)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(s)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote country: %s\n", switch_str_nil(t30_get_rx_country(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(pvt->t30)));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n");
@ -687,7 +687,6 @@ static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uin
static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
{
switch_core_session_t *session;
switch_channel_t *channel;
fax_state_t *fax;
@ -699,7 +698,6 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
int fec_span = DEFAULT_FEC_SPAN;
int compressions;
session = (switch_core_session_t *) pvt->session;
switch_assert(session);
@ -724,7 +722,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
}
fax = pvt->fax_state;
t30 = fax_get_t30_state(fax);
pvt->t30 = fax_get_t30_state(fax);
t30 = pvt->t30;
memset(fax, 0, sizeof(fax_state_t));
if (fax_init(fax, pvt->caller) == NULL) {
@ -762,7 +761,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
}
t38 = pvt->t38_state;
t30 = t38_terminal_get_t30_state(t38);
pvt->t30 = t38_terminal_get_t30_state(t38);
t30 = pvt->t30;
memset(t38, 0, sizeof(t38_terminal_state_t));
@ -856,7 +856,6 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
t38_gateway_set_ecm_capability(pvt->t38_gateway_state, 1);
return SWITCH_STATUS_SUCCESS;
default:
assert(0); /* What? */
return SWITCH_STATUS_SUCCESS;
@ -975,7 +974,6 @@ static switch_status_t spanfax_destroy(pvt_t *pvt)
}
t30 = t38_terminal_get_t30_state(pvt->t38_state);
if (terminate && t30) {
t30_terminate(t30);
}