提交 8d2805fc authored 作者: Chris Rienzo's avatar Chris Rienzo

FS-5659 --resolve Add logging for spandsp dtmf detector when dtmf_verbose…

FS-5659 --resolve Add logging for spandsp dtmf detector when dtmf_verbose channel variable is set to true
上级 b71fe003
/* /*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org> * Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
* *
...@@ -141,7 +141,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session, ...@@ -141,7 +141,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
int hits, const char *app, const char *data, switch_tone_detect_callback_t callback); int hits, const char *app, const char *data, switch_tone_detect_callback_t callback);
switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session); switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session);
void spanfax_log_message(void *user_data, int level, const char *msg); void mod_spandsp_log_message(void *session, int level, const char *msg);
switch_status_t load_configuration(switch_bool_t reload); switch_status_t load_configuration(switch_bool_t reload);
void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on); void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on);
......
...@@ -349,6 +349,7 @@ switch_status_t spandsp_tdd_decode_session(switch_core_session_t *session) ...@@ -349,6 +349,7 @@ switch_status_t spandsp_tdd_decode_session(switch_core_session_t *session)
typedef struct { typedef struct {
switch_core_session_t *session; switch_core_session_t *session;
dtmf_rx_state_t *dtmf_detect; dtmf_rx_state_t *dtmf_detect;
int verbose;
char last_digit; char last_digit;
uint32_t samples; uint32_t samples;
uint32_t last_digit_end; uint32_t last_digit_end;
...@@ -394,6 +395,10 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da ...@@ -394,6 +395,10 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
switch (type) { switch (type) {
case SWITCH_ABC_TYPE_INIT: { case SWITCH_ABC_TYPE_INIT: {
pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL); pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL);
span_log_set_message_handler(dtmf_rx_get_logging_state(pvt->dtmf_detect), mod_spandsp_log_message, pvt->session);
if (pvt->verbose) {
span_log_set_level(dtmf_rx_get_logging_state(pvt->dtmf_detect), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
}
dtmf_rx_parms(pvt->dtmf_detect, pvt->filter_dialtone, pvt->twist, pvt->reverse_twist, pvt->threshold); dtmf_rx_parms(pvt->dtmf_detect, pvt->filter_dialtone, pvt->twist, pvt->reverse_twist, pvt->threshold);
dtmf_rx_set_realtime_callback(pvt->dtmf_detect, spandsp_dtmf_rx_realtime_callback, pvt); dtmf_rx_set_realtime_callback(pvt->dtmf_detect, spandsp_dtmf_rx_realtime_callback, pvt);
break; break;
...@@ -500,6 +505,10 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session) ...@@ -500,6 +505,10 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session)
pvt->filter_dialtone = 0; pvt->filter_dialtone = 0;
} }
if ((value = switch_channel_get_variable(channel, "dtmf_verbose"))) {
pvt->verbose = switch_true(value);
}
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
...@@ -554,7 +563,7 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu ...@@ -554,7 +563,7 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu
* Allocate the tone descriptor * Allocate the tone descriptor
* *
* @param descriptor the descriptor to create * @param descriptor the descriptor to create
* @param name the descriptor name * @param name the descriptor name
* @param memory_pool the pool to use * @param memory_pool the pool to use
* @return SWITCH_STATUS_SUCCESS if successful * @return SWITCH_STATUS_SUCCESS if successful
*/ */
...@@ -632,7 +641,7 @@ static void tone_report_callback(void *user_data, int code, int level, int delay ...@@ -632,7 +641,7 @@ static void tone_report_callback(void *user_data, int code, int level, int delay
/** /**
* Process tone segment report from spandsp (for debugging) * Process tone segment report from spandsp (for debugging)
* *
* @param user_data the tone_detector * @param user_data the tone_detector
* @param f1 the first frequency of the segment * @param f1 the first frequency of the segment
* @param f2 the second frequency of the segment * @param f2 the second frequency of the segment
...@@ -705,7 +714,7 @@ static switch_bool_t tone_detector_process_buffer(tone_detector_t *detector, voi ...@@ -705,7 +714,7 @@ static switch_bool_t tone_detector_process_buffer(tone_detector_t *detector, voi
* Destroy the tone detector * Destroy the tone detector
* @param detector the detector to destroy * @param detector the detector to destroy
*/ */
static void tone_detector_destroy(tone_detector_t *detector) static void tone_detector_destroy(tone_detector_t *detector)
{ {
if (detector) { if (detector) {
if (detector->spandsp_detector) { if (detector->spandsp_detector) {
...@@ -720,7 +729,7 @@ static void tone_detector_destroy(tone_detector_t *detector) ...@@ -720,7 +729,7 @@ static void tone_detector_destroy(tone_detector_t *detector)
* Start call progress detection * Start call progress detection
* *
* @param session the session to detect * @param session the session to detect
* @param name of the descriptor to use * @param name of the descriptor to use
* @return SWITCH_STATUS_SUCCESS if successful * @return SWITCH_STATUS_SUCCESS if successful
*/ */
switch_status_t callprogress_detector_start(switch_core_session_t *session, const char *name) switch_status_t callprogress_detector_start(switch_core_session_t *session, const char *name)
...@@ -759,7 +768,7 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons ...@@ -759,7 +768,7 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons
/** /**
* Process a buffer of audio data for call progress tones * Process a buffer of audio data for call progress tones
* *
* @param bug the session's media bug * @param bug the session's media bug
* @param user_data the detector * @param user_data the detector
* @param type the type of data available from the bug * @param type the type of data available from the bug
* @return SWITCH_TRUE * @return SWITCH_TRUE
...@@ -817,7 +826,7 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu ...@@ -817,7 +826,7 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu
/** /**
* Stop call progress detection * Stop call progress detection
* @param session the session to stop * @param session the session to stop
* @return SWITCH_STATUS_SUCCESS if successful * @return SWITCH_STATUS_SUCCESS if successful
*/ */
switch_status_t callprogress_detector_stop(switch_core_session_t *session) switch_status_t callprogress_detector_stop(switch_core_session_t *session)
......
...@@ -346,23 +346,23 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl ...@@ -346,23 +346,23 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl
if (spandsp_globals.modem_verbose) { if (spandsp_globals.modem_verbose) {
logging = t31_get_logging_state(modem->t31_state); logging = t31_get_logging_state(modem->t31_state);
span_log_set_message_handler(logging, spanfax_log_message, NULL); span_log_set_message_handler(logging, mod_spandsp_log_message, NULL);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
logging = v17_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v17_rx); logging = v17_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v17_rx);
span_log_set_message_handler(logging, spanfax_log_message, NULL); span_log_set_message_handler(logging, mod_spandsp_log_message, NULL);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
logging = v29_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v29_rx); logging = v29_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v29_rx);
span_log_set_message_handler(logging, spanfax_log_message, NULL); span_log_set_message_handler(logging, mod_spandsp_log_message, NULL);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
logging = v27ter_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v27ter_rx); logging = v27ter_rx_get_logging_state(&modem->t31_state->audio.modems.fast_modems.v27ter_rx);
span_log_set_message_handler(logging, spanfax_log_message, NULL); span_log_set_message_handler(logging, mod_spandsp_log_message, NULL);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
logging = t38_core_get_logging_state(modem->t38_core); logging = t38_core_get_logging_state(modem->t38_core);
span_log_set_message_handler(logging, spanfax_log_message, NULL); span_log_set_message_handler(logging, mod_spandsp_log_message, NULL);
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论