diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway.c b/src/mod/endpoints/mod_media_gateway/media_gateway.c index 3d10abf05c..e47055236a 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway.c @@ -185,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha term->pool = pool; term->type = termtype; term->active_events = NULL; + term->mg_ctxt = NULL; term->profile = profile; switch_set_flag(term, MGT_ALLOCATED); @@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term) free(term->active_events); term->active_events = NULL; } + + term->mg_ctxt = NULL; switch_clear_flag(term, MGT_ALLOCATED); switch_clear_flag(term, MGT_ACTIVE); 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 27fe1a4a4b..57c8843aee 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 @@ -566,6 +566,10 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i goto error; } + if(!term->mg_ctxt){ + term->mg_ctxt = mg_ctxt; + } + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name); is_rtp = 0x01; @@ -580,6 +584,15 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i goto error; } + if(!term->mg_ctxt){ + term->mg_ctxt = mg_ctxt; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Termination[%s] already in context..rejecting ADD \n", term->name); + mg_util_set_err_string(&errTxt, " Term already is in call "); + err_code = MGT_MGCP_RSP_CODE_PROT_ERROR; + goto error; + } + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name); } /********************************************************************/ 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 9401ce49ce..e5c16df9c0 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -15,6 +15,11 @@ #define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */ +/* rtp/avp profiles */ +#define MG_RTP_AVP_PROFILE_A_LAW 8 +#define MG_RTP_AVP_PROFILE_U_LAW 0 + + typedef enum{ MG_SDP_NONE, MG_SDP_LOCAL, diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c b/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c index 56a1ffdc3a..908b604118 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c @@ -789,7 +789,7 @@ void mgco_print_CmSdpU8OrNil(CmSdpU8OrNil* p) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"CmSdpU8OrNil: Value = %d \n", (NOTPRSNT != p->val.pres)?p->val.val:-1); } -void mgco_print_sdp_media_param(CmSdpMedPar *s) +void mgco_print_sdp_media_param(CmSdpMedPar *s, mg_termination_t* term, mgco_sdp_types_e sdp_type) { int i=0x00; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n"); @@ -832,6 +832,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s) for(i=0;inum.val;i++){ mgco_print_CmSdpU8OrNil(r->fmts[i]); + + if(MG_RTP_AVP_PROFILE_A_LAW == r->fmts[i]->val.val){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " MG_RTP_AVP_PROFILE_A_LAW: \n"); + }else if(MG_RTP_AVP_PROFILE_U_LAW == r->fmts[i]->val.val){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " MG_RTP_AVP_PROFILE_U_LAW: \n"); + } } } break; @@ -1074,7 +1080,7 @@ void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e break; } } - mgco_print_sdp_media_param(&f->par); + mgco_print_sdp_media_param(&f->par, term, sdp_type); } /*info */ diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index f30c1d955d..e3c3b8c3de 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) term->pool = pool; term->type = MG_TERM_TDM; term->profile = profile; + term->mg_ctxt = NULL; + term->active_events = NULL; term->name = switch_core_sprintf(pool, "%s%d", prefix, j); term->u.tdm.channel = j; term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h index bf2fda7a05..e0022d8ecd 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -94,6 +94,14 @@ enum { } mg_termination_flags; +struct mg_context_s { + uint32_t context_id; + mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS]; + megaco_profile_t *profile; + mg_context_t *next; + switch_memory_pool_t *pool; +}; + struct mg_termination_s { switch_memory_pool_t *pool; mg_termination_type_t type; @@ -104,6 +112,7 @@ struct mg_termination_s { MgMgcoReqEvtDesc *active_events; /* !< active megaco events */ mg_termination_t *next; /*!< List for physical terminations */ uint32_t flags; + mg_context_t* mg_ctxt; union { struct { @@ -131,13 +140,7 @@ struct mg_termination_s { }; -struct mg_context_s { - uint32_t context_id; - mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS]; - megaco_profile_t *profile; - mg_context_t *next; - switch_memory_pool_t *pool; -}; + #define MG_CONTEXT_MODULO 16 #define MG_MAX_CONTEXTS 32768