提交 4943f682 authored 作者: Anthony Minessale's avatar Anthony Minessale

set rtp stack into optimal mode for transferring data during fax situations…

set rtp stack into optimal mode for transferring data during fax situations (that does not mean we support the idea of audio fax over ip......)
上级 19dad4a5
......@@ -872,6 +872,7 @@ typedef enum {
SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH,
SWITCH_MESSAGE_INDICATE_SIGNAL_DATA,
SWITCH_MESSAGE_INDICATE_INFO,
SWITCH_MESSAGE_INDICATE_AUDIO_DATA,
SWITCH_MESSAGE_INVALID
} switch_core_session_message_types_t;
......
......@@ -264,6 +264,40 @@ SWITCH_STANDARD_API(stop_tone_detect_api)
}
void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on)
{
switch_core_session_t *target_session = NULL;
int locked = 0;
if (self) {
target_session = session;
} else {
if (switch_core_session_get_partner(session, &target_session) == SWITCH_STATUS_SUCCESS) {
locked = 1;
} else {
target_session = NULL;
}
}
if (target_session) {
switch_core_session_message_t *msg;
msg = switch_core_session_alloc(target_session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_AUDIO_DATA;
msg->from = __FILE__;
msg->numeric_arg = on;
switch_core_session_queue_message(target_session, msg);
if (locked) {
switch_core_session_rwunlock(target_session);
locked = 0;
}
}
}
/* **************************************************************************
CONFIGURATION
************************************************************************* */
......
......@@ -138,3 +138,4 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
switch_status_t spandsp_fax_stop_detect_session(switch_core_session_t *session);
void spanfax_log_message(int level, const char *msg);
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);
......@@ -650,7 +650,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
{
switch_channel_t *channel;
private_t *tech_pvt;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
......@@ -661,16 +661,23 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
case SWITCH_MESSAGE_INDICATE_ANSWER:
t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_CONNECTED);
modem_set_state(tech_pvt->modem, MODEM_STATE_CONNECTED);
mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_CONNECTED);
modem_set_state(tech_pvt->modem, MODEM_STATE_CONNECTED);
mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
break;
case SWITCH_MESSAGE_INDICATE_RINGING:
break;
case SWITCH_MESSAGE_INDICATE_BRIDGE:
mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
mod_spandsp_indicate_data(session, SWITCH_FALSE, SWITCH_TRUE);
break;
default:
break;
......@@ -743,6 +750,7 @@ static void tech_attach(private_t *tech_pvt, modem_t *modem)
switch_channel_set_variable_printf(tech_pvt->channel, "modem_slot", "%d", modem->slot);
switch_channel_set_variable(tech_pvt->channel, "modem_devlink", modem->devlink);
switch_channel_set_variable(tech_pvt->channel, "modem_digits", modem->digits);
switch_channel_export_variable(tech_pvt->channel, "rtp_autoflush_during_bridge", "false", SWITCH_EXPORT_VARS_VARIABLE);
}
......
......@@ -1785,6 +1785,28 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
}
break;
case SWITCH_MESSAGE_INDICATE_AUDIO_DATA:
{
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if (msg->numeric_arg) {
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE);
sofia_set_flag(tech_pvt, TFLAG_JB_PAUSED);
}
rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK);
} else {
if (sofia_test_flag(tech_pvt, TFLAG_JB_PAUSED)) {
sofia_clear_flag(tech_pvt, TFLAG_JB_PAUSED);
if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) {
switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE);
}
}
}
}
}
break;
case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
{
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论