提交 1c907e5b authored 作者: Kapil Gupta's avatar Kapil Gupta

adding code to invoke freetdm dtmf removal api

上级 b15c1d12
...@@ -208,6 +208,51 @@ done: ...@@ -208,6 +208,51 @@ done:
return status; return status;
} }
switch_status_t megaco_tdm_term_dtmf_removal(mg_termination_t *term, int enable)
{
char buf[128];
switch_event_t *event = NULL;
mg_termination_t* tdm_term = NULL;
if(NULL == term) return SWITCH_STATUS_FALSE;
if(MG_TERM_RTP == term->type){
if(NULL == term->context) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Null Context from rtp term, not able to get tdm term \n");
return SWITCH_STATUS_FALSE;
}
tdm_term = megaco_context_get_peer_term(term->context, term);
}else{
tdm_term = term;
}
if(NULL == tdm_term) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Null TDM term \n");
return SWITCH_STATUS_FALSE;
}
memset(&buf[0],0,sizeof(buf));
if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to create NOTIFY event\n");
return SWITCH_STATUS_FALSE;
}
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", tdm_term->u.tdm.span_name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", tdm_term->u.tdm.channel);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "mg-tdm-dtmfremoval");
sprintf(buf,"%s",(1 == enable)?"enable":"disable");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Sending DTMF Removal Event[%s] for MG Term[%s], TDM span[%s] channel[%d]\n",
buf,tdm_term->name, tdm_term->u.tdm.span_name, tdm_term->u.tdm.channel);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "command", buf);
switch_event_fire(&event);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t megaco_prepare_tdm_termination(mg_termination_t *term) switch_status_t megaco_prepare_tdm_termination(mg_termination_t *term)
{ {
switch_event_t *event = NULL; switch_event_t *event = NULL;
...@@ -403,6 +448,23 @@ void megaco_termination_destroy(mg_termination_t *term) ...@@ -403,6 +448,23 @@ void megaco_termination_destroy(mg_termination_t *term)
} }
} }
mg_termination_t* megaco_context_get_peer_term(mg_context_t *ctx, mg_termination_t *term)
{
switch_assert(ctx != NULL);
switch_assert(term != NULL);
if (ctx->terminations[0] && (term == ctx->terminations[0])) {
return ctx->terminations[1];
}
if (ctx->terminations[1] && (term == ctx->terminations[1])) {
return ctx->terminations[0];
}
return NULL;
}
switch_status_t megaco_context_is_term_present(mg_context_t *ctx, mg_termination_t *term) switch_status_t megaco_context_is_term_present(mg_context_t *ctx, mg_termination_t *term)
{ {
......
...@@ -741,6 +741,17 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i ...@@ -741,6 +741,17 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
goto error; goto error;
} }
if(is_rtp){
mg_termination_t* tdm_term = NULL;
/* disable dtmf removal */
tdm_term = megaco_context_get_peer_term(mg_ctxt, term);
if(term->u.rtp.rfc2833_pt){
megaco_tdm_term_dtmf_removal(tdm_term,0x01);
}else{
megaco_tdm_term_dtmf_removal(tdm_term,0x00);
}
}
mg_print_t38_attributes(term); mg_print_t38_attributes(term);
......
...@@ -321,6 +321,7 @@ static inline megaco_codec_t megaco_codec_parse(const char *codec) { ...@@ -321,6 +321,7 @@ static inline megaco_codec_t megaco_codec_parse(const char *codec) {
} }
switch_status_t megaco_tdm_term_dtmf_removal(mg_termination_t *term, int enable);
megaco_profile_t *megaco_profile_locate(const char *name); megaco_profile_t *megaco_profile_locate(const char *name);
mg_termination_t *megaco_term_locate_by_span_chan_id(const char *span_name, const char *chan_number); mg_termination_t *megaco_term_locate_by_span_chan_id(const char *span_name, const char *chan_number);
mg_peer_profile_t *megaco_peer_profile_locate(const char *name); mg_peer_profile_t *megaco_peer_profile_locate(const char *name);
...@@ -363,6 +364,7 @@ switch_status_t megaco_context_is_term_present(mg_context_t *ctx, mg_termination ...@@ -363,6 +364,7 @@ switch_status_t megaco_context_is_term_present(mg_context_t *ctx, mg_termination
switch_status_t megaco_prepare_tdm_termination(mg_termination_t *term); switch_status_t megaco_prepare_tdm_termination(mg_termination_t *term);
switch_status_t megaco_check_tdm_termination(mg_termination_t *term); switch_status_t megaco_check_tdm_termination(mg_termination_t *term);
mg_termination_t* megaco_context_get_peer_term(mg_context_t *ctx, mg_termination_t *term);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论