mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 20:48:21 +00:00
turn on echo cancellation and turn it off in mg_notify
This commit is contained in:
parent
fd39c5b44a
commit
a7d51f5f4f
@ -40,6 +40,8 @@ void ctdm_init(switch_loadable_module_interface_t *module_interface);
|
|||||||
#define kCHAN_ID "chan"
|
#define kCHAN_ID "chan"
|
||||||
#define kSPAN_NAME "span_name"
|
#define kSPAN_NAME "span_name"
|
||||||
#define kPREBUFFER_LEN "prebuffer_len"
|
#define kPREBUFFER_LEN "prebuffer_len"
|
||||||
|
#define kECHOCANCEL "echo_cancel"
|
||||||
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
@ -374,6 +376,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL)) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to set enable echo cancellation.\n");
|
||||||
|
}
|
||||||
|
|
||||||
switch(codec) {
|
switch(codec) {
|
||||||
case FTDM_CODEC_ULAW:
|
case FTDM_CODEC_ULAW:
|
||||||
{
|
{
|
||||||
@ -477,6 +483,10 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
|||||||
|
|
||||||
if ((tech_pvt = switch_core_session_get_private(session))) {
|
if ((tech_pvt = switch_core_session_get_private(session))) {
|
||||||
|
|
||||||
|
if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL)) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to enable echo cancellation.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (tech_pvt->read_codec.implementation) {
|
if (tech_pvt->read_codec.implementation) {
|
||||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||||
}
|
}
|
||||||
@ -639,7 +649,8 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
|
|||||||
const char *command = switch_event_get_header(event, "command");
|
const char *command = switch_event_get_header(event, "command");
|
||||||
ctdm_private_t *tech_pvt = switch_core_session_get_private(session);
|
ctdm_private_t *tech_pvt = switch_core_session_get_private(session);
|
||||||
|
|
||||||
if (!zstr(command) && !strcasecmp(command, kPREBUFFER_LEN)) {
|
if (!zstr(command)) {
|
||||||
|
if (!strcasecmp(command, kPREBUFFER_LEN)) {
|
||||||
const char *szval = switch_event_get_header(event, kPREBUFFER_LEN);
|
const char *szval = switch_event_get_header(event, kPREBUFFER_LEN);
|
||||||
int val = !zstr(szval) ? atoi(szval) : 0;
|
int val = !zstr(szval) ? atoi(szval) : 0;
|
||||||
|
|
||||||
@ -650,8 +661,15 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
|
|||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (!strcasecmp(command, kECHOCANCEL)) {
|
||||||
|
const char *szval = switch_event_get_header(event, kECHOCANCEL);
|
||||||
|
int enabled = !!switch_true(szval);
|
||||||
|
|
||||||
|
if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, enabled ? FTDM_COMMAND_ENABLE_ECHOCANCEL : FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL)) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to %s echo cancellation.\n", enable ? "enable" : "disable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -761,6 +761,34 @@ void mg_term_set_pre_buffer_size(mg_termination_t *term, int newval)
|
|||||||
switch_event_destroy(&event);
|
switch_event_destroy(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mg_term_set_ec(mg_termination_t *term, int enable)
|
||||||
|
{
|
||||||
|
switch_event_t *event = NULL, *event2 = NULL;
|
||||||
|
switch_core_session_t *session, *session2;
|
||||||
|
|
||||||
|
if (!zstr(term->uuid) && (session = switch_core_session_locate(term->uuid))) {
|
||||||
|
switch_event_create(&event, SWITCH_EVENT_CLONE);
|
||||||
|
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "command", kECHOCANCEL);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, kECHOCANCEL, enable ? "true" : "false");
|
||||||
|
|
||||||
|
/* Propagate event to bridged session if there is one */
|
||||||
|
if (switch_core_session_get_partner(session, &session2) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_dup(&event2, event);
|
||||||
|
switch_core_session_receive_event(session2, &event2);
|
||||||
|
switch_core_session_rwunlock(session2);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_core_session_receive_event(session, &event);
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sent echo_cancel event to [%s] to [%s]\n", term->uuid, enable ? "enable" : "disable");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_event_destroy(&event);
|
||||||
|
}
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* mode:c
|
* mode:c
|
||||||
|
@ -39,9 +39,13 @@ SWITCH_STANDARD_APP(mg_notify_function)
|
|||||||
if (!strcmp(data, "cng")) {
|
if (!strcmp(data, "cng")) {
|
||||||
mg_send_t38_cng_notify(term->profile, term->name);
|
mg_send_t38_cng_notify(term->profile, term->name);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CNG notify\n");
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CNG notify\n");
|
||||||
|
/* Disable echo cancellation */
|
||||||
|
mg_term_set_ec(term, 0);
|
||||||
} else if (!strcmp(data, "ced")) {
|
} else if (!strcmp(data, "ced")) {
|
||||||
mg_send_t38_ans_notify(term->profile, term->name);
|
mg_send_t38_ans_notify(term->profile, term->name);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CED notify\n");
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sent CED notify\n");
|
||||||
|
/* Disable echo cancellation */
|
||||||
|
mg_term_set_ec(term, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ typedef struct mg_context_s mg_context_t;
|
|||||||
#define kCHAN_ID "chan"
|
#define kCHAN_ID "chan"
|
||||||
#define kSPAN_NAME "span_name"
|
#define kSPAN_NAME "span_name"
|
||||||
#define kPREBUFFER_LEN "prebuffer_len"
|
#define kPREBUFFER_LEN "prebuffer_len"
|
||||||
|
#define kECHOCANCEL "echo_cancel"
|
||||||
|
|
||||||
typedef struct mg_termination_s mg_termination_t;
|
typedef struct mg_termination_s mg_termination_t;
|
||||||
|
|
||||||
@ -269,6 +270,7 @@ switch_status_t megaco_profile_destroy(megaco_profile_t **profile);
|
|||||||
uint32_t mg_rtp_request_id(megaco_profile_t *profile);
|
uint32_t mg_rtp_request_id(megaco_profile_t *profile);
|
||||||
void mg_rtp_release_id(megaco_profile_t *profile, uint32_t id);
|
void mg_rtp_release_id(megaco_profile_t *profile, uint32_t id);
|
||||||
void mg_term_set_pre_buffer_size(mg_termination_t *term, int newval);
|
void mg_term_set_pre_buffer_size(mg_termination_t *term, int newval);
|
||||||
|
void mg_term_set_ec(mg_termination_t *term, int enable);
|
||||||
|
|
||||||
mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id);
|
mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id);
|
||||||
mg_context_t *megaco_choose_context(megaco_profile_t *profile);
|
mg_context_t *megaco_choose_context(megaco_profile_t *profile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user