提交 38abcf7e authored 作者: Steve Underwood's avatar Steve Underwood

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

the callbacks.
上级 9db6d5ba
...@@ -153,43 +153,38 @@ typedef struct t30_state_s t30_state_t; ...@@ -153,43 +153,38 @@ typedef struct t30_state_s t30_state_t;
can access whatever additional information might have been received, using can access whatever additional information might have been received, using
t30_get_received_info(). t30_get_received_info().
\brief T.30 phase B callback handler. \brief T.30 phase B callback handler.
\param s The T.30 context.
\param user_data An opaque pointer. \param user_data An opaque pointer.
\param result The phase B event code. \param result The phase B event code.
\return The new status. Normally, T30_ERR_OK is returned. \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. T.30 phase D callback handler.
\brief 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 user_data An opaque pointer.
\param result The phase D event code. \param result The phase D event code.
\return The new status. Normally, T30_ERR_OK is returned. \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. T.30 phase E callback handler.
\brief 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 user_data An opaque pointer.
\param completion_code The phase E completion code. \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. T.30 real time frame handler.
\brief 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 user_data An opaque pointer.
\param incoming True for incoming, false for outgoing. \param incoming True for incoming, false for outgoing.
\param msg The HDLC message. \param msg The HDLC message.
\param len The length of the message. \param len The length of the message.
*/ */
typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s, typedef void (*t30_real_time_frame_handler_t)(void *user_data,
void *user_data,
bool direction, bool direction,
const uint8_t msg[], const uint8_t msg[],
int len); int len);
...@@ -197,11 +192,10 @@ typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s, ...@@ -197,11 +192,10 @@ typedef void (*t30_real_time_frame_handler_t)(t30_state_t *s,
/*! /*!
T.30 document handler. T.30 document handler.
\brief T.30 document handler. \brief T.30 document handler.
\param s The T.30 context.
\param user_data An opaque pointer. \param user_data An opaque pointer.
\param result The document event code. \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. T.30 set a receive or transmit type handler.
......
差异被折叠。
...@@ -98,7 +98,13 @@ enum ...@@ -98,7 +98,13 @@ enum
{ {
AUDIO_FAX, AUDIO_FAX,
T38_TERMINAL_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}; int mode[2] = {AUDIO_FAX, AUDIO_FAX};
...@@ -127,17 +133,19 @@ bool succeeded[2] = {false, false}; ...@@ -127,17 +133,19 @@ bool succeeded[2] = {false, false};
bool t38_simulate_incrementing_repeats = 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 i;
int ch; int ch;
int status; int status;
int len; int len;
t30_state_t *s;
char tag[20]; char tag[20];
const char *u; const char *u;
const uint8_t *v; const uint8_t *v;
i = (int) (intptr_t) user_data; i = (int) (intptr_t) user_data;
s = t30_state[i];
ch = i + 'A'; ch = i + 'A';
snprintf(tag, sizeof(tag), "%c: Phase B", ch); snprintf(tag, sizeof(tag), "%c: Phase B", ch);
printf("%c: Phase B handler - (0x%X) %s\n", ch, result, t30_frametype(result)); 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) ...@@ -296,14 +304,18 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result)
} }
/*- End of function --------------------------------------------------------*/ /*- 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 i;
int ch;
t30_state_t *s;
char tag[20]; char tag[20];
i = (int) (intptr_t) user_data; i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i + 'A'); s = t30_state[i];
printf("%c: Phase D handler - (0x%X) %s\n", i + 'A', result, t30_frametype(result)); 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_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_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) ...@@ -313,9 +325,9 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
if (test_local_interrupt) 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); t30_local_interrupt_request(s, true);
} }
else else
...@@ -326,7 +338,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) ...@@ -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_MPS:
case T30_PRI_EOM: case T30_PRI_EOM:
case T30_PRI_EOP: case T30_PRI_EOP:
printf("%c: Accepting interrupt request\n", i); printf("%c: Accepting interrupt request\n", ch);
t30_local_interrupt_request(s, true); t30_local_interrupt_request(s, true);
break; break;
case T30_PIN: case T30_PIN:
...@@ -338,15 +350,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result) ...@@ -338,15 +350,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
} }
/*- End of function --------------------------------------------------------*/ /*- 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 i;
int ch;
t30_stats_t t; t30_stats_t t;
t30_state_t *s;
char tag[20]; char tag[20];
i = (int) (intptr_t) user_data; i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i + 'A'); s = t30_state[i];
printf("%c: Phase E handler - (%d) %s\n", i + 'A', result, t30_completion_code_to_str(result)); 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_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_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) ...@@ -356,29 +372,32 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
static void real_time_frame_handler(t30_state_t *s, static void real_time_frame_handler(void *user_data,
void *user_data,
bool incoming, bool incoming,
const uint8_t *msg, const uint8_t *msg,
int len) int len)
{ {
int i; int i;
int ch;
i = (intptr_t) user_data; i = (intptr_t) user_data;
ch = i + 'A';
printf("%c: Real time frame handler - %s, %s, length = %d\n", printf("%c: Real time frame handler - %s, %s, length = %d\n",
i + 'A', ch,
(incoming) ? "line->T.30" : "T.30->line", (incoming) ? "line->T.30" : "T.30->line",
t30_frametype(msg[2]), t30_frametype(msg[2]),
len); len);
} }
/*- End of function --------------------------------------------------------*/ /*- 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 i;
int ch;
i = (intptr_t) user_data; 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; return false;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
......
...@@ -91,27 +91,31 @@ int test_seq_ptr = 0; ...@@ -91,27 +91,31 @@ int test_seq_ptr = 0;
t31_state_t *t31_state; 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]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase B", i); s = (t30_state_t *) user_data;
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); 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); fax_log_rx_parameters(s, tag);
return T30_ERR_OK; return T30_ERR_OK;
} }
/*- End of function --------------------------------------------------------*/ /*- 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]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase D", i); s = (t30_state_t *) user_data;
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); 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_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_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) ...@@ -119,18 +123,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
} }
/*- End of function --------------------------------------------------------*/ /*- 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]; char tag[20];
i = (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase E", i); s = (t30_state_t *) user_data;
printf("Phase E handler on channel %c\n", i); 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_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag); fax_log_rx_parameters(s, tag);
//exit(0);
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
...@@ -502,9 +507,9 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int ...@@ -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_tx_ident(t30, "11111111");
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); 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_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_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) 'A'); t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) 'A'); t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
if (t38_mode) if (t38_mode)
logging = t38_terminal_get_logging_state(t38_state); logging = t38_terminal_get_logging_state(t38_state);
......
...@@ -280,27 +280,31 @@ int test_seq_ptr = 0; ...@@ -280,27 +280,31 @@ int test_seq_ptr = 0;
t31_state_t *t31_state; 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]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase B", i); s = (t30_state_t *) user_data;
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); 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); fax_log_rx_parameters(s, tag);
return T30_ERR_OK; return T30_ERR_OK;
} }
/*- End of function --------------------------------------------------------*/ /*- 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]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase D", i); s = (t30_state_t *) user_data;
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); 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_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_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) ...@@ -308,18 +312,19 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
} }
/*- End of function --------------------------------------------------------*/ /*- 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]; char tag[20];
i = (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase E", i); s = (t30_state_t *) user_data;
printf("Phase E handler on channel %c\n", i); 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_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag); fax_log_rx_parameters(s, tag);
//exit(0);
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
...@@ -600,9 +605,9 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending, ...@@ -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_tx_ident(t30, "11111111");
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); 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_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_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) 'A'); t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) 'A'); t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
if (t38_mode) if (t38_mode)
logging = t38_terminal_get_logging_state(t38_state); logging = t38_terminal_get_logging_state(t38_state);
......
...@@ -70,27 +70,31 @@ static int done = false; ...@@ -70,27 +70,31 @@ static int done = false;
static int started = false; static int started = false;
static int64_t current = 0; 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]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase B", i); s = (t30_state_t *) user_data;
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); 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); fax_log_rx_parameters(s, tag);
return T30_ERR_OK; return T30_ERR_OK;
} }
/*- End of function --------------------------------------------------------*/ /*- 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]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase D", i); s = (t30_state_t *) user_data;
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result)); 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_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_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) ...@@ -98,15 +102,17 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
} }
/*- End of function --------------------------------------------------------*/ /*- 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_stats_t t;
t30_state_t *s;
char tag[20]; char tag[20];
i = (int) (intptr_t) user_data; ch = 'A';
snprintf(tag, sizeof(tag), "%c: Phase E", i); s = (t30_state_t *) user_data;
printf("%c: Phase E handler on channel %c - (%d) %s\n", i, i, result, t30_completion_code_to_str(result)); 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_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag); fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag); fax_log_rx_parameters(s, tag);
...@@ -319,6 +325,7 @@ int main(int argc, char *argv[]) ...@@ -319,6 +325,7 @@ int main(int argc, char *argv[])
t30_state_t *t30; t30_state_t *t30;
logging_state_t *logging; logging_state_t *logging;
const char *input_file_name; const char *input_file_name;
const char *input_tiff_file_name;
int t38_version; int t38_version;
int caller; int caller;
int use_ecm; int use_ecm;
...@@ -338,6 +345,7 @@ int main(int argc, char *argv[]) ...@@ -338,6 +345,7 @@ int main(int argc, char *argv[])
t38_version = 0; t38_version = 0;
options = 0; options = 0;
input_file_name = INPUT_FILE_NAME; input_file_name = INPUT_FILE_NAME;
input_tiff_file_name = INPUT_TIFF_FILE_NAME;
fill_removal = false; fill_removal = false;
use_tep = false; use_tep = false;
use_transmit_on_idle = true; use_transmit_on_idle = true;
...@@ -348,7 +356,7 @@ int main(int argc, char *argv[]) ...@@ -348,7 +356,7 @@ int main(int argc, char *argv[])
src_port = 0; src_port = 0;
dest_addr = 0; dest_addr = 0;
dest_port = 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) switch (opt)
{ {
...@@ -388,6 +396,9 @@ int main(int argc, char *argv[]) ...@@ -388,6 +396,9 @@ int main(int argc, char *argv[])
case 's': case 's':
src_port = atoi(optarg); src_port = atoi(optarg);
break; break;
case 'T':
input_tiff_file_name = optarg;
break;
case 't': case 't':
use_tep = true; use_tep = true;
break; break;
...@@ -433,12 +444,12 @@ int main(int argc, char *argv[]) ...@@ -433,12 +444,12 @@ int main(int argc, char *argv[])
t30_set_tx_ident(t30, "11111111"); t30_set_tx_ident(t30, "11111111");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12); t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
if (caller) 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 else
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1); 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_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A'); t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A'); t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
t30_set_ecm_capability(t30, use_ecm); t30_set_ecm_capability(t30, use_ecm);
t30_set_supported_compressions(t30, t30_set_supported_compressions(t30,
T4_COMPRESSION_T4_1D T4_COMPRESSION_T4_1D
...@@ -519,12 +530,12 @@ int main(int argc, char *argv[]) ...@@ -519,12 +530,12 @@ int main(int argc, char *argv[])
t30_set_tx_ident(t30, "22222222"); t30_set_tx_ident(t30, "22222222");
t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12); t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
if (caller) 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 else
t30_set_rx_file(t30, OUTPUT_TIFF_FILE_NAME, -1); 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_b_handler(t30, phase_b_handler, (void *) t30);
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'B'); t30_set_phase_d_handler(t30, phase_d_handler, (void *) t30);
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'B'); t30_set_phase_e_handler(t30, phase_e_handler, (void *) t30);
t30_set_ecm_capability(t30, use_ecm); t30_set_ecm_capability(t30, use_ecm);
t30_set_supported_compressions(t30, t30_set_supported_compressions(t30,
T4_COMPRESSION_T4_1D T4_COMPRESSION_T4_1D
......
...@@ -75,6 +75,7 @@ struct pvt_s { ...@@ -75,6 +75,7 @@ struct pvt_s {
mod_spandsp_fax_application_mode_t app_mode; mod_spandsp_fax_application_mode_t app_mode;
t30_state_t *t30;
fax_state_t *fax_state; fax_state_t *fax_state;
t38_terminal_state_t *t38_state; t38_terminal_state_t *t38_state;
t38_gateway_state_t *t38_gateway_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) ...@@ -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; t30_stats_t t30_stats;
switch_core_session_t *session; switch_core_session_t *session;
...@@ -312,10 +313,10 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) ...@@ -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); channel = switch_core_session_get_channel(session);
switch_assert(channel); 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)); local_ident = switch_str_nil(t30_get_tx_ident(pvt->t30));
far_ident = switch_str_nil(t30_get_rx_ident(s)); far_ident = switch_str_nil(t30_get_rx_ident(pvt->t30));
fax_transfer_rate = switch_core_session_sprintf(session, "%i", t30_stats.bit_rate); fax_transfer_rate = switch_core_session_sprintf(session, "%i", t30_stats.bit_rate);
if (fax_transfer_rate) { if (fax_transfer_rate) {
...@@ -324,9 +325,9 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) ...@@ -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_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_local_station_id", local_ident);
switch_channel_set_variable(channel, "fax_remote_station_id", far_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_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(s))); 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(s))); 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"); 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) ...@@ -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, "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, "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 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(s))); 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(s))); 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"); 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) ...@@ -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-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-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-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-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(s))); 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(s))); 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); switch_event_fire(&event);
} }
return T30_ERR_OK; 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; t30_stats_t t30_stats;
char *fax_file_image_resolution = NULL; char *fax_file_image_resolution = NULL;
...@@ -388,7 +389,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg) ...@@ -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); channel = switch_core_session_get_channel(session);
switch_assert(channel); switch_assert(channel);
t30_get_transfer_statistics(s, &t30_stats); t30_get_transfer_statistics(pvt->t30, &t30_stats);
/* Set Channel Variable */ /* Set Channel Variable */
...@@ -476,7 +477,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg) ...@@ -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 * 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; t30_stats_t t;
const char *local_ident; const char *local_ident;
...@@ -504,9 +505,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result) ...@@ -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); channel = switch_core_session_get_channel(session);
switch_assert(channel); switch_assert(channel);
t30_get_transfer_statistics(s, &t); t30_get_transfer_statistics(pvt->t30, &t);
local_ident = switch_str_nil(t30_get_tx_ident(s)); local_ident = switch_str_nil(t30_get_tx_ident(pvt->t30));
far_ident = switch_str_nil(t30_get_rx_ident(s)); far_ident = switch_str_nil(t30_get_rx_ident(pvt->t30));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n"); 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) ...@@ -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_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax successfully managed. How ?\n");
} }
switch_channel_set_variable(channel, "fax_success", "1"); switch_channel_set_variable(channel, "fax_success", "1");
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fax processing not successful - result (%d) %s.\n", result, 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)); t30_completion_code_to_str(result));
...@@ -535,9 +535,9 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int 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, "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, "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 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(s))); 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(s))); 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"); 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 ...@@ -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) static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
{ {
switch_core_session_t *session; switch_core_session_t *session;
switch_channel_t *channel; switch_channel_t *channel;
fax_state_t *fax; fax_state_t *fax;
...@@ -699,7 +698,6 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) ...@@ -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 fec_span = DEFAULT_FEC_SPAN;
int compressions; int compressions;
session = (switch_core_session_t *) pvt->session; session = (switch_core_session_t *) pvt->session;
switch_assert(session); switch_assert(session);
...@@ -724,7 +722,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) ...@@ -724,7 +722,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
} }
fax = pvt->fax_state; 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)); memset(fax, 0, sizeof(fax_state_t));
if (fax_init(fax, pvt->caller) == NULL) { 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) ...@@ -762,7 +761,8 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
} }
t38 = pvt->t38_state; 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)); 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) ...@@ -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); t38_gateway_set_ecm_capability(pvt->t38_gateway_state, 1);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
default: default:
assert(0); /* What? */ assert(0); /* What? */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
...@@ -975,7 +974,6 @@ static switch_status_t spanfax_destroy(pvt_t *pvt) ...@@ -975,7 +974,6 @@ static switch_status_t spanfax_destroy(pvt_t *pvt)
} }
t30 = t38_terminal_get_t30_state(pvt->t38_state); t30 = t38_terminal_get_t30_state(pvt->t38_state);
if (terminate && t30) { if (terminate && t30) {
t30_terminate(t30); t30_terminate(t30);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论