*
*
*/
-switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *cmd, mg_termination_t* term)
+switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *cmd, mg_termination_t* term, CmMemListCp *memCp)
{
CmSdpMedProtoFmts *format;
TknU8 *fmt;
}
}
- mgco_handle_sdp(&local->sdp, term, MG_SDP_LOCAL);
+ mgco_handle_incoming_sdp(&local->sdp, term, MG_SDP_LOCAL, mg_profile, memCp);
break;
}
remote = &mediaPar->u.remote;
sdp = remote->sdp.info[0];
/* for Matt - same like local descriptor */
- mgco_handle_sdp(&remote->sdp, term, MG_SDP_REMOTE);
+ mgco_handle_incoming_sdp(&remote->sdp, term, MG_SDP_REMOTE, mg_profile, memCp);
break;
}
if (mgStream->sl.remote.pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n");
- mgco_handle_sdp(&mgStream->sl.remote.sdp, term, MG_SDP_LOCAL);
+ mgco_handle_incoming_sdp(&mgStream->sl.remote.sdp, term, MG_SDP_LOCAL, mg_profile, memCp);
}
if (mgStream->sl.local.pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got local stream media description:\n");
- mgco_handle_sdp(&mgStream->sl.local.sdp, term, MG_SDP_REMOTE);
+ mgco_handle_incoming_sdp(&mgStream->sl.local.sdp, term, MG_SDP_REMOTE, mg_profile, memCp);
}
break;
/********************************************************************/
- ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
+ ret = mg_prc_descriptors(mg_profile, inc_cmd, term, &inc_cmd->u.mgCmdInd[0]->memCp);
+
+ /* IF there is any error , return */
+ if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
+ mg_util_set_err_string(&errTxt, " Unsupported Codec ");
+ err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
+ goto error;
+ }
/* TODO - locally assigned SDP must be the part of termination...which we can use to fill responses*/
/********************************************************************/
- ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
+ ret = mg_prc_descriptors(mg_profile, inc_cmd, term, &inc_cmd->u.mgCmdInd[0]->memCp);
+
+ /* IF there is any error , return */
+ if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
+ mg_util_set_err_string(&errTxt, " Unsupported Codec ");
+ err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
+ goto error;
+ }
/* SDP updated to termination */
megaco_activate_termination(term);
(_reqId)->id.val = 0xFFFFFFFF;
-switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, mg_termination_t* term);
+switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, mg_termination_t* term, CmMemListCp *memCp);
void handle_sng_log(uint8_t level, char *fmt, ...);
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* msg);
switch_status_t mg_is_ito_pkg_req(megaco_profile_t* mg_profile, MgMgcoCommand *cmd);
switch_status_t mg_send_end_of_axn(SuId suId, MgMgcoTransId* transId, MgMgcoContextId* ctxtId, TknU32* peerId);
-void mgco_handle_sdp(CmSdpInfoSet *sdp,mg_termination_t* term, mgco_sdp_types_e sdp_type);
+void mgco_handle_incoming_sdp(CmSdpInfoSet *sdp,mg_termination_t* term, mgco_sdp_types_e sdp_type, megaco_profile_t* mg_profile, CmMemListCp *memCp);
void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId);
switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, MgMgcoContextId* new_ctxtId);
switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd);
}
/*****************************************************************************************************************************/
-void mgco_print_sdp_attr_set(CmSdpAttrSet *s)
+void mgco_handle_sdp_attr_set(CmSdpAttrSet *s, mg_termination_t* term)
{
int i=0x00;
if (s->numComp.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\t PTIME = %ld \n",
(NOTPRSNT != a->u.ptime.pres)?a->u.ptime.val:-1);
#endif
+ if(MG_TERM_RTP == term->type){
+ term->u.rtp.ptime = a->u.ptime.val;
+ }
break;
}
case CM_SDP_ATTR_RECVONLY:
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, mg_termination_t* term, mgco_sdp_types_e sdp_type)
+const char* mg_get_codec_name(megaco_profile_t* mg_profile, int iana_code)
+{
+ int i = 0x00;
+ const switch_codec_implementation_t *codecs[16];
+ char *codec_prefs[16] = { 0 };
+ char *szcodec_prefs;
+ int codec_count;
+
+ szcodec_prefs = strdup(mg_profile->codec_prefs);
+ codec_count = switch_split(szcodec_prefs, ',', codec_prefs);
+
+ /* Get the list of codecs, by preference */
+ switch_loadable_module_get_codecs_sorted(codecs, switch_arraylen(codecs), codec_prefs, switch_arraylen(codec_prefs));
+ /* see if received codec is present in our codec supported list */
+ for (i = 0; codecs[i] && i < codec_count; i++) {
+ if(iana_code == codecs[i]->ianacode){
+ return codecs[i]->iananame;
+ }
+ }
+
+ return NULL;
+}
+
+void mgco_handle_sdp_media_param(CmSdpMedPar *s, mg_termination_t* term, mgco_sdp_types_e sdp_type, megaco_profile_t* mg_profile, CmSdpAttrSet *attrSet, CmMemListCp *memCp)
{
int i=0x00;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n");
}
}
}
+
+ /* Ideally remote descriptor should have supported codec..but just in case calling remove un-supported codecs api */
+ mg_rem_unsupported_codecs(mg_profile, term , r, attrSet, memCp);
+
+
+ /* now whatever we have , that will be suported one */
+ if((NOTPRSNT != r->num.pres) && (0 != r->num.val) && (NULL != r->fmts[0])){
+ const char* name = mg_get_codec_name(mg_profile, r->fmts[0]->val.val);
+ if(name){
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " Updating codec to[%d], name[%s] \n",
+ r->fmts[0]->val.val, name);
+ if(MG_TERM_RTP == term->type){
+ term->u.rtp.codec = name;
+ }
+ }else{
+ /* ERROR */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " NO Codec Name found against iana[%d] \n", r->fmts[0]->val.val);
+ }
+ }
+
break;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "**************** \n");
}
-void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e sdp_type)
+void mgco_handle_incoming_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e sdp_type, megaco_profile_t* mg_profile, CmMemListCp *memCp)
{
int i;
/************************************************************************************************************************/
/* Attribute Set */
- mgco_print_sdp_attr_set(&s->attrSet);
+ mgco_handle_sdp_attr_set(&s->attrSet, term);
/************************************************************************************************************************/
/* Media Descriptor Set */
break;
}
}
- mgco_print_sdp_media_param(&f->par, term, sdp_type);
+ mgco_handle_sdp_media_param(&f->par, term, sdp_type, mg_profile, &desc->attrSet, memCp);
}
/*info */
}
/* attribute set */
- mgco_print_sdp_attr_set(&desc->attrSet);
+ mgco_handle_sdp_attr_set(&desc->attrSet, term);
if (desc->field.mediaType.val == CM_SDP_MEDIA_AUDIO &&