From 888393fc73a9b69057a7b57c9c0feaeda300ec37 Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Tue, 14 Aug 2012 15:53:51 -0400 Subject: [PATCH] adding API to send FAX state change notification --- .../media_gateway_cmd_handler.c | 24 +++++++++++++++++-- .../mod_media_gateway/media_gateway_stack.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) 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 53d6775a69..bb1560df46 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 @@ -2662,13 +2662,14 @@ switch_status_t mg_send_ito_notify(megaco_profile_t* mg_profile ) /*****************************************************************************************************************************/ /* API to send T.38 CNG tone Notification */ -switch_status_t mg_send_t38_fax_con_change_notify(megaco_profile_t* mg_profile, const char* term_name) +switch_status_t mg_send_t38_fax_con_change_notify(megaco_profile_t* mg_profile, const char* term_name, char* state) { MgMgcoObsEvt *oevt; MgMgcoEvtPar* param; switch_assert(term_name); switch_assert(mg_profile); + switch_assert(state); mg_stack_alloc_mem((Ptr*)&oevt, sizeof(MgMgcoObsEvt)); @@ -2700,7 +2701,26 @@ switch_status_t mg_send_t38_fax_con_change_notify(megaco_profile_t* mg_profile, 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_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGCONNECTED); + if(!strcasecmp(state,"connected")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGCONNECTED); + } else if(!strcasecmp(state,"negotiating")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGNEGOTIATING); + } else if(!strcasecmp(state,"disconnect")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGDISCONNECT); + } else if(!strcasecmp(state,"prepare")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGPREPARE); + } else if(!strcasecmp(state,"TrainR")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGTRAINR); + } else if(!strcasecmp(state,"TrainT")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGTRAINT); + } else if(!strcasecmp(state,"EOP")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGEOP); + } else if(!strcasecmp(state,"ProcInterrupt")){ + MG_INIT_TOKEN_VALUE(&(param->u.other.val.u.eq.u.enume),MGT_PKG_ENUM_OBSEVTOTHERIPFAXFAXCONNSTATECHNGFAXCONNSTATECHNGPROCINTR); + }else{ + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Invalid input state[%s] param\n", state); + return SWITCH_STATUS_FALSE; + } return mg_send_notify(mg_profile, term_name, oevt); } 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 d06e796c54..cac19d255d 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -216,6 +216,7 @@ switch_status_t mg_rem_unsupported_codecs (megaco_profile_t* mg_profile, mg_term switch_status_t mg_send_oos_service_change(megaco_profile_t* mg_profile, const char* term_name, int wild); switch_status_t mg_send_ins_service_change(megaco_profile_t* mg_profile, const char* term_name, int wild); switch_status_t mg_send_notify(megaco_profile_t* mg_profile, const char* term_name, MgMgcoObsEvt* oevt); +switch_status_t mg_send_t38_fax_con_change_notify(megaco_profile_t* mg_profile, const char* term_name, char* state); switch_status_t mg_send_dtmf_notify(megaco_profile_t* mg_profile, const char* term_name, char* digits, int num_of_collected_digits); switch_status_t mg_send_ito_notify(megaco_profile_t* mg_profile); void mg_print_t38_attributes(mg_termination_t* term);