tab cleanup
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11168 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e5536a377c
commit
3a765ce940
|
@ -89,7 +89,7 @@ struct pvt_s {
|
||||||
|
|
||||||
/* UNUSED AT THE MOMENT
|
/* UNUSED AT THE MOMENT
|
||||||
int enable_t38_reinvite;
|
int enable_t38_reinvite;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ static void spanfax_log_message(int level, const char *msg)
|
||||||
|
|
||||||
if (!switch_strlen_zero(msg)) {
|
if (!switch_strlen_zero(msg)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, fs_log_level, "%s", msg);
|
switch_log_printf(SWITCH_CHANNEL_LOG, fs_log_level, "%s", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -166,11 +166,11 @@ static void phase_e_handler(t30_state_t * s, void *user_data, int result)
|
||||||
|
|
||||||
if (pvt->app_mode == FUNCTION_TX) {
|
if (pvt->app_mode == FUNCTION_TX) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax successfully sent.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax successfully sent.\n");
|
||||||
} else if (pvt->app_mode == FUNCTION_RX) {
|
} else if (pvt->app_mode == FUNCTION_RX) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax successfully received.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax successfully received.\n");
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax successfully managed. How ?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, 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_LOG, SWITCH_LOG_DEBUG, "Fax processing not successful - result (%d) %s.\n", result,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax processing not successful - result (%d) %s.\n", result,
|
||||||
|
@ -193,8 +193,8 @@ static void phase_e_handler(t30_state_t * s, void *user_data, int result)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set our channel variables
|
Set our channel variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmp = switch_mprintf("%i", result);
|
tmp = switch_mprintf("%i", result);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
|
@ -244,11 +244,11 @@ static void phase_e_handler(t30_state_t * s, void *user_data, int result)
|
||||||
switch_safe_free(tmp);
|
switch_safe_free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO Fire events
|
TODO Fire events
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -272,10 +272,10 @@ static switch_status_t spanfax_init(pvt_t * pvt, transport_mode_t trans_mode)
|
||||||
pvt->fax_state = (fax_state_t *) switch_core_session_alloc(pvt->session, sizeof(fax_state_t));
|
pvt->fax_state = (fax_state_t *) switch_core_session_alloc(pvt->session, sizeof(fax_state_t));
|
||||||
} else {
|
} else {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fax = pvt->fax_state;
|
fax = pvt->fax_state;
|
||||||
t30 = fax_get_t30_state(fax);
|
t30 = fax_get_t30_state(fax);
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -335,7 +335,7 @@ static switch_status_t spanfax_init(pvt_t * pvt, transport_mode_t trans_mode)
|
||||||
Here goes the T.38 SpanDSP initializing functions
|
Here goes the T.38 SpanDSP initializing functions
|
||||||
T.38 will require a big effort as it needs a different approach
|
T.38 will require a big effort as it needs a different approach
|
||||||
but the pieces are already in place
|
but the pieces are already in place
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
assert(0); /* Whaaat ? */
|
assert(0); /* Whaaat ? */
|
||||||
break;
|
break;
|
||||||
|
@ -352,14 +352,14 @@ static switch_status_t spanfax_destroy(pvt_t * pvt)
|
||||||
if (pvt->fax_state) {
|
if (pvt->fax_state) {
|
||||||
if (pvt->t38_state) {
|
if (pvt->t38_state) {
|
||||||
terminate = 0;
|
terminate = 0;
|
||||||
} else {
|
} else {
|
||||||
terminate = 1;
|
terminate = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
t30 = fax_get_t30_state(pvt->fax_state);
|
t30 = fax_get_t30_state(pvt->fax_state);
|
||||||
if (terminate && t30) {
|
if (terminate && t30) {
|
||||||
t30_terminate(t30);
|
t30_terminate(t30);
|
||||||
}
|
}
|
||||||
|
|
||||||
fax_release(pvt->fax_state);
|
fax_release(pvt->fax_state);
|
||||||
}
|
}
|
||||||
|
@ -367,14 +367,14 @@ static switch_status_t spanfax_destroy(pvt_t * pvt)
|
||||||
if (pvt->t38_state) {
|
if (pvt->t38_state) {
|
||||||
if (pvt->t38_state) {
|
if (pvt->t38_state) {
|
||||||
terminate = 1;
|
terminate = 1;
|
||||||
} else {
|
} else {
|
||||||
terminate = 0;
|
terminate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
t38_terminal_release(pvt->t38_state);
|
t38_terminal_release(pvt->t38_state);
|
||||||
}
|
}
|
||||||
|
@ -405,9 +405,9 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
|
|
||||||
if (!switch_channel_media_ready(channel)) {
|
if (!switch_channel_media_ready(channel)) {
|
||||||
switch_channel_answer(channel);
|
switch_channel_answer(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate our structs */
|
/* Allocate our structs */
|
||||||
pvt = switch_core_session_alloc(session, sizeof(pvt_t));
|
pvt = switch_core_session_alloc(session, sizeof(pvt_t));
|
||||||
|
@ -428,11 +428,11 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
|
|
||||||
if (pvt->app_mode == FUNCTION_TX) {
|
if (pvt->app_mode == FUNCTION_TX) {
|
||||||
pvt->caller = 1;
|
pvt->caller = 1;
|
||||||
} else if (pvt->app_mode == FUNCTION_RX) {
|
} else if (pvt->app_mode == FUNCTION_RX) {
|
||||||
pvt->caller = 0;
|
pvt->caller = 0;
|
||||||
} else {
|
} else {
|
||||||
assert(0); /* UH ? */
|
assert(0); /* UH ? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -542,12 +542,12 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*** Initialize the SpanDSP elements ***
|
*** Initialize the SpanDSP elements ***
|
||||||
|
|
||||||
Note: we could analyze if a fax was already detected in previous stages
|
Note: we could analyze if a fax was already detected in previous stages
|
||||||
and if so, when T.38 will be supported, send a reinvite in T38_MODE,
|
and if so, when T.38 will be supported, send a reinvite in T38_MODE,
|
||||||
bypassing AUDIO_MODE.
|
bypassing AUDIO_MODE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((spanfax_init(pvt, AUDIO_MODE) != SWITCH_STATUS_SUCCESS)) {
|
if ((spanfax_init(pvt, AUDIO_MODE) != SWITCH_STATUS_SUCCESS)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot initialize Fax engine\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot initialize Fax engine\n");
|
||||||
|
@ -557,14 +557,14 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
/*
|
/*
|
||||||
Note: Disable echocan on the channel, remember to call app "disable_ec" in the dialplan
|
Note: Disable echocan on the channel, remember to call app "disable_ec" in the dialplan
|
||||||
before invoking fax applications
|
before invoking fax applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Note: we are disabling the Jitterbuffer, here, before we answer.
|
Note: we are disabling the Jitterbuffer, here, before we answer.
|
||||||
If you have set it to something else and the channel is pre-answered,
|
If you have set it to something else and the channel is pre-answered,
|
||||||
it will have no effect. Make sure that if you want more reliable
|
it will have no effect. Make sure that if you want more reliable
|
||||||
faxes, it is disabled.
|
faxes, it is disabled.
|
||||||
*/
|
*/
|
||||||
switch_channel_set_variable(channel, "jitterbuffer_msec", "0");
|
switch_channel_set_variable(channel, "jitterbuffer_msec", "0");
|
||||||
|
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_ivr_sleep(session, 250, SWITCH_TRUE, NULL);
|
switch_ivr_sleep(session, 250, SWITCH_TRUE, NULL);
|
||||||
|
|
||||||
while (switch_channel_ready(channel)) {
|
while (switch_channel_ready(channel)) {
|
||||||
int tx = 0;
|
int tx = 0;
|
||||||
|
@ -623,7 +623,7 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
- call t38_terminal_send_timeout(), sleep for a while
|
- call t38_terminal_send_timeout(), sleep for a while
|
||||||
|
|
||||||
The T.38 stuff can be placed here (and the audio stuff can be skipped)
|
The T.38 stuff can be placed here (and the audio stuff can be skipped)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* read new audio frame from the channel */
|
/* read new audio frame from the channel */
|
||||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
|
@ -635,12 +635,12 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||||
|
|
||||||
/* Skip CNG frames (auto-generated by FreeSWITCH, usually) */
|
/* Skip CNG frames (auto-generated by FreeSWITCH, usually) */
|
||||||
if (!switch_test_flag(read_frame, SFF_CNG)) {
|
if (!switch_test_flag(read_frame, SFF_CNG)) {
|
||||||
/* pass the new incoming audio frame to the fax_rx function */
|
/* pass the new incoming audio frame to the fax_rx function */
|
||||||
if (fax_rx(pvt->fax_state, (int16_t *) read_frame->data, read_frame->samples)) {
|
if (fax_rx(pvt->fax_state, (int16_t *) read_frame->data, read_frame->samples)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fax_rx reported an error\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fax_rx reported an error\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tx = fax_tx(pvt->fax_state, buf, write_codec.implementation->samples_per_packet)) < 0) {
|
if ((tx = fax_tx(pvt->fax_state, buf, write_codec.implementation->samples_per_packet)) < 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fax_tx reported an error\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fax_tx reported an error\n");
|
||||||
|
|
Loading…
Reference in New Issue