mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-25 03:10:39 +00:00
code cleanup
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9434 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e1fe36f182
commit
369709d481
@ -43,15 +43,21 @@ SWITCH_MODULE_DEFINITION(mod_fax, mod_fax_load, NULL, NULL);
|
|||||||
*/
|
*/
|
||||||
static void span_message(int level, const char *msg)
|
static void span_message(int level, const char *msg)
|
||||||
{
|
{
|
||||||
if (msg==NULL) return;
|
|
||||||
int fs_log_level = SWITCH_LOG_NOTICE;
|
int fs_log_level = SWITCH_LOG_NOTICE;
|
||||||
|
|
||||||
|
if (msg==NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: verify all the span_log_levels available
|
// TODO: verify all the span_log_levels available
|
||||||
if (level == SPAN_LOG_ERROR)
|
if (level == SPAN_LOG_ERROR) {
|
||||||
fs_log_level = SWITCH_LOG_ERROR;
|
fs_log_level = SWITCH_LOG_ERROR;
|
||||||
else if (level == SPAN_LOG_WARNING)
|
} else if (level == SPAN_LOG_WARNING) {
|
||||||
fs_log_level = SWITCH_LOG_WARNING;
|
fs_log_level = SWITCH_LOG_WARNING;
|
||||||
else
|
} else {
|
||||||
fs_log_level = SWITCH_LOG_DEBUG;
|
fs_log_level = SWITCH_LOG_DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, fs_log_level, "%s", msg );
|
switch_log_printf(SWITCH_CHANNEL_LOG, fs_log_level, "%s", msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,18 +81,22 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
const char *local_ident = NULL;
|
const char *local_ident = NULL;
|
||||||
const char *far_ident = NULL;
|
const char *far_ident = NULL;
|
||||||
switch_channel_t *chan = (switch_channel_t *) user_data;
|
switch_channel_t *chan = (switch_channel_t *) user_data;
|
||||||
|
char buf[128];
|
||||||
|
|
||||||
if (result == T30_ERR_OK)
|
if (result == T30_ERR_OK) {
|
||||||
{
|
|
||||||
t30_get_transfer_statistics(s, &t);
|
t30_get_transfer_statistics(s, &t);
|
||||||
far_ident = t30_get_tx_ident(s);
|
far_ident = t30_get_tx_ident(s);
|
||||||
|
|
||||||
if (!switch_strlen_zero(far_ident)) {
|
if (!switch_strlen_zero(far_ident)) {
|
||||||
far_ident = "";
|
far_ident = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
local_ident = t30_get_rx_ident(s);
|
local_ident = t30_get_rx_ident(s);
|
||||||
|
|
||||||
if (!switch_strlen_zero(local_ident)) {
|
if (!switch_strlen_zero(local_ident)) {
|
||||||
local_ident = "";
|
local_ident = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
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");
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote station id: %s\n", far_ident);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote station id: %s\n", far_ident);
|
||||||
@ -95,21 +105,17 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Image resolution: %i x %i\n", t.x_resolution, t.y_resolution);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Image resolution: %i x %i\n", t.x_resolution, t.y_resolution);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax receive not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result));
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax receive not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result));
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: remove the assert once this has been tested
|
//TODO: remove the assert once this has been tested
|
||||||
assert(user_data != NULL);
|
switch_assert(user_data != NULL);
|
||||||
//TODO: is the buffer too little?
|
//TODO: is the buffer too little?
|
||||||
switch_channel_set_variable(chan, "FAX_REMOTESTATIONID", far_ident);
|
switch_channel_set_variable(chan, "FAX_REMOTESTATIONID", far_ident);
|
||||||
char buf[128];
|
|
||||||
snprintf(buf, sizeof(buf), "%d", t.pages_transferred);
|
snprintf(buf, sizeof(buf), "%d", t.pages_transferred);
|
||||||
switch_channel_set_variable(chan, "FAX_PAGES", buf);
|
switch_channel_set_variable(chan, "FAX_PAGES", buf);
|
||||||
snprintf(buf, sizeof(buf), "%dx%d", t.x_resolution, t.y_resolution);
|
snprintf(buf, sizeof(buf), "%dx%d", t.x_resolution, t.y_resolution);
|
||||||
@ -131,8 +137,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
{
|
{
|
||||||
t30_stats_t t;
|
t30_stats_t t;
|
||||||
|
|
||||||
if (result)
|
if (result) {
|
||||||
{
|
|
||||||
t30_get_transfer_statistics(s, &t);
|
t30_get_transfer_statistics(s, &t);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Pages transferred: %i\n", t.pages_transferred);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Pages transferred: %i\n", t.pages_transferred);
|
||||||
@ -141,8 +146,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int result)
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bad rows %i\n", t.bad_rows);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bad rows %i\n", t.bad_rows);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Longest bad row run %i\n", t.longest_bad_row_run);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Longest bad row run %i\n", t.longest_bad_row_run);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Compression type %i %s\n", t.encoding,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Compression type %i %s\n", t.encoding, t4_encoding_to_str(t.encoding));
|
||||||
t4_encoding_to_str(t.encoding));
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Image size (bytes) %i\n", t.image_size);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Image size (bytes) %i\n", t.image_size);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "==============================================================================\n");
|
||||||
}
|
}
|
||||||
@ -174,7 +178,7 @@ SWITCH_STANDARD_APP(rxfax_function)
|
|||||||
|
|
||||||
// make sure we have a valid channel when starting the FAX application
|
// make sure we have a valid channel when starting the FAX application
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
|
|
||||||
/* reset output variables */
|
/* reset output variables */
|
||||||
switch_channel_set_variable(channel, "FAX_REMOTESTATIONID", "unknown");
|
switch_channel_set_variable(channel, "FAX_REMOTESTATIONID", "unknown");
|
||||||
@ -337,7 +341,6 @@ SWITCH_STANDARD_APP(rxfax_function)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -386,5 +389,5 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fax_load)
|
|||||||
* c-basic-offset:4
|
* c-basic-offset:4
|
||||||
* End:
|
* End:
|
||||||
* For VIM:
|
* For VIM:
|
||||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user