From 4423077a4e6406bac3d28a933ffdb606a5a1e862 Mon Sep 17 00:00:00 2001 From: Kapil Date: Mon, 30 Jul 2012 16:48:53 -0400 Subject: [PATCH] adding API to send T.38 CNG tone notify to MGC --- .../mod_media_gateway/media_gateway_cli.c | 30 +++++++++--- .../media_gateway_cmd_handler.c | 47 +++++++++++++++++++ .../mod_media_gateway/media_gateway_stack.h | 3 ++ 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c index e8cb79097b..080ca4b709 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c @@ -146,23 +146,39 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre } case 5: { - /* mg profile send ito notify */ if(zstr(argv[3])){ goto usage; } - if(strcasecmp(argv[3],"ito")){ + /*************************************************************************/ + if(!strcasecmp(argv[3],"ito")){ + /* mg profile send ito notify */ + + printf("Sending In-Activity NOTIFY \n"); + + megaco_profile_release(profile); + mg_send_ito_notify(profile); + /*************************************************************************/ + }else if(!strcasecmp(argv[3],"cng")){ + /*************************************************************************/ + /* mg profile send cng */ + + if(zstr(argv[4])){ + goto usage; + } + megaco_profile_release(profile); + mg_send_t38_cng_notify(profile, argv[4]); + + /*************************************************************************/ + }else { stream->write_function(stream, "-ERR wrong input \n"); goto usage; } - - printf("Sending In-Activity NOTIFY \n"); - - megaco_profile_release(profile); - mg_send_ito_notify(profile); + /*************************************************************************/ break; } + default: { goto usage; diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c index a1fd12b3df..5a7786839b 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c @@ -2480,6 +2480,53 @@ switch_status_t mg_send_ito_notify(megaco_profile_t* mg_profile ) return mg_send_notify(mg_profile, "ROOT", oevt); } + +/*****************************************************************************************************************************/ +/* API to send T.38 CNG tone Notification */ + +switch_status_t mg_send_t38_cng_notify(megaco_profile_t* mg_profile, const char* term_name) +{ + MgMgcoObsEvt *oevt; + MgMgcoEvtPar* param; + + switch_assert(term_name); + switch_assert(mg_profile); + + mg_stack_alloc_mem((Ptr*)&oevt, sizeof(MgMgcoObsEvt)); + + oevt->pres.pres = PRSNT_NODEF; + + mg_get_time_stamp(&oevt->time); + + MG_INIT_TOKEN_VALUE(&(oevt->pkg.pkgType), MGT_PKG_KNOWN); + + MG_INIT_TOKEN_VALUE(&(oevt->pkg.valType), MGT_PKG_KNOWN); + + MG_INIT_TOKEN_VALUE(&(oevt->pkg.u.val), MGT_PKG_CALL_TYP_DISCR); + + MG_INIT_TOKEN_VALUE(&(oevt->name.type),MGT_GEN_TYPE_KNOWN); + + MG_INIT_TOKEN_VALUE(&(oevt->name.u.val),(U8)MGT_PKG_ENUM_OBSEVTOTHERCALLTYPDISCRDISCTONEDETDISCTONETYPCNG); + + if (mgUtlGrowList((void ***)&oevt->pl.parms, sizeof(MgMgcoEvtPar), &oevt->pl.num, NULL) != ROK) { + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n"); + return SWITCH_STATUS_FALSE; + } + + param = oevt->pl.parms[0]; + + MG_INIT_TOKEN_VALUE(&(param->type),(U8)MGT_EVTPAR_OTHER); + + MG_INIT_TOKEN_VALUE(&(param->u.other.name.type),MGT_GEN_TYPE_KNOWN); + MG_INIT_TOKEN_VALUE(&(param->u.other.name.u.val), MGT_PKG_ENUM_OBSEVTOTHERCALLTYPDISCRDISCTONEDETDISCTONETYP); + + MG_INIT_TOKEN_VALUE(&(param->u.other.val.type),MGT_VALUE_EQUAL); + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.type),MGT_VALTYPE_ENUM); + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERCALLTYPDISCRDISCTONEDETDISCTONETYPCNG); + + + return mg_send_notify(mg_profile, term_name, oevt); +} /*****************************************************************************************************************************/ /* API to send DTMF Digits Notification */ diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h index 4d79a96078..28ff0c2c03 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -167,6 +167,9 @@ switch_status_t mg_add_local_descriptor(MgMgcoMediaDesc* media, megaco_profile_t switch_status_t mg_send_term_service_change(char *span_name, char *chan_number, mg_term_states_e term_state); +switch_status_t mg_send_t38_cng_notify(megaco_profile_t* mg_profile, const char* term_name); + + switch_status_t sng_mgco_cfg(megaco_profile_t* profile); switch_status_t sng_mgco_init(sng_mg_event_interface_t* event); switch_status_t sng_mgco_stack_shutdown(void);