]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adding API to send FAX state change notification
authorKapil Gupta <kgupta@sangoma.com>
Tue, 14 Aug 2012 19:53:51 +0000 (15:53 -0400)
committerKapil Gupta <kgupta@sangoma.com>
Tue, 14 Aug 2012 19:53:51 +0000 (15:53 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h

index 53d6775a69dfbcb544d9d20fc69cbb8a6d78b3ab..bb1560df4606d854bc188157fba981f82cf5e5e6 100644 (file)
@@ -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);
 }
index d06e796c541127259d840d37dea3d348ffe936ff..cac19d255dca8f0e966cce1f92aed22b0aedbbed 100644 (file)
@@ -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);