adding code to fill dummy local descriptor sdp to add response

This commit is contained in:
Kapil 2012-07-24 16:57:09 -04:00
parent 12e8e481b5
commit e5821eeb79
1 changed files with 145 additions and 135 deletions

View File

@ -323,6 +323,7 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
U32 txn_id = inc_cmd->transId.val;
mg_termination_t* term = NULL;
MgMgcoMediaDesc* inc_med_desc;
/*MgMgcoStreamDesc* inc_strm_desc;*/
MgMgcoAudRetParm *desc;
mg_context_t* mg_ctxt;
@ -495,180 +496,189 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
desc->type.val = MGT_MEDIADESC;
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
#if 0
{
MgMgcoStreamDesc *stream;
/* build local descriptors */
/*MgMgcoStreamDesc *stream;*/
MgMgcoLocalDesc *local;
MgMgcoRemoteDesc* remote;
CmSdpInfoSet *psdp;
CmSdpInfoSet *prsdp;
char* ipAddress = "192.168.1.1";
MgMgcoMediaDesc* media = &desc->u.media;
/* Most probably we need to add local descriptor */
/* TODO - considering only one descriptor*/
stream = &desc->u.media.parms[0]->u.stream;
/* allocating mem for local descriptor */
if (mgUtlGrowList((void ***)&media->parms, sizeof(MgMgcoMediaPar),
&media->num, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
return SWITCH_STATUS_FALSE;
}
#if 0
/* Kapil - NOT REQUIRED..keeping now just for ref..will delete asap */
media->parms[media->num.val-1]->type.pres = PRSNT_NODEF;
/*media->parms[media->num.val-1]->type.val = MGT_MEDIAPAR_STRPAR;*/
printf("media->num.val[%d]\n",media->num.val);
stream = &media->parms[media->num.val-1]->u.stream;
stream->pres.pres = PRSNT_NODEF;
stream->pres.val = 0x01;
#if 0
if(inc_med_desc->num.pres && inc_med_desc->num.val){
/* TODO - check stream descriptor type for all medias */
inc_strm_desc = &inc_med_desc->parms[0]->u.stream;
memcpy(&stream->streamId, &inc_strm_desc->streamId, sizeof(MgMgcoStreamId));
}
#endif
MG_INIT_TOKEN_VALUE(&(stream->streamId), 1);
stream->sl.pres.pres = PRSNT_NODEF;
stream->sl.pres.val = 0x01;
local = &stream->sl.local;
remote = &stream->sl.remote;
#endif
media->parms[media->num.val-1]->type.pres = PRSNT_NODEF;
media->parms[media->num.val-1]->type.val = MGT_MEDIAPAR_LOCAL;
if(!local->pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Local stream media not present adding it \n");
local = &media->parms[media->num.val-1]->u.local;
/* allocating mem for local descriptor */
if (mgUtlGrowList((void ***)&desc->u.media.parms, sizeof(MgMgcoMediaPar),
&desc->u.media.num, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
local->pres.pres = PRSNT_NODEF;
psdp = &(local->sdp);
if (mgUtlGrowList((void ***)&psdp->info, sizeof(CmSdpInfo),
&psdp->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
return SWITCH_STATUS_FALSE;
}
psdp->info[psdp->numComp.val-1]->pres.pres = PRSNT_NODEF;
/* fill version */
/*memcpy(&psdp->info[0]->ver, &prsdp->info[0]->ver, sizeof(TknU16)); */
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->ver),1);
/* fill orig */
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->orig.pres), 1);
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->orig.type), CM_SDP_SPEC);
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->orig.orig.pres), 1);
MG_SET_TKNSTROSXL(psdp->info[psdp->numComp.val-1]->orig.orig.usrName, 1, "-",
&rsp.u.mgCmdRsp[0]->memCp);
MG_SET_TKNSTROSXL(psdp->info[psdp->numComp.val-1]->orig.orig.sessId, 1, "0",
&rsp.u.mgCmdRsp[0]->memCp);
MG_SET_TKNSTROSXL(psdp->info[psdp->numComp.val-1]->orig.orig.sessVer, 1, "0",
&rsp.u.mgCmdRsp[0]->memCp);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.netType.type),
CM_SDP_NET_TYPE_IN);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.addrType),
CM_SDP_ADDR_TYPE_IPV4);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.addrType),
CM_SDP_IPV4_IP_UNI);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.addrType),
CM_SDP_IPV4_IP_UNI);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[0]),
ipAddress[0]);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]),
ipAddress[1]);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]),
ipAddress[2]);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]),
ipAddress[3]);
/* fill session name */
/* TODO - need to fill proper session name or skip it..*/
MG_SET_TKNSTROSXL(psdp->info[psdp->numComp.val-1]->sessName, 8, "SANGOMA",&rsp.u.mgCmdRsp[0]->memCp);
/* Fill the SDP Connection Info */
/* "c=" line - ipaddress */
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->conn.netType.type),CM_SDP_NET_TYPE_IN);
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->conn.addrType), CM_SDP_ADDR_TYPE_IPV4);
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->conn.u.ip4.addrType), CM_SDP_IPV4_IP_UNI);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[0]), ipAddress[0]);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[1]), ipAddress[1]);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[2]), ipAddress[2]);
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[3]), ipAddress[3]);
/* t= line */
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->sdpTime.pres),1);
#if 0
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->sdpTime.sdpOpTimeSet.numComp),0);
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->sdpTime.zoneAdjSet.numComp),0);
#endif
/* fill media descriptors */
{
CmSdpMediaDescSet* med = &psdp->info[psdp->numComp.val-1]->mediaDescSet;
CmSdpMediaDesc* media;
if (mgUtlGrowList((void ***)&med->mediaDesc, sizeof(CmSdpMediaDesc),
&med->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
return SWITCH_STATUS_FALSE;
}
desc->u.media.parms[desc->u.media.num.val-1]->type.pres = PRSNT_NODEF;
desc->u.media.parms[desc->u.media.num.val-1]->type.val = MGT_MEDIAPAR_STRPAR;
media = med->mediaDesc[med->numComp.val-1];
MG_INIT_TOKEN_VALUE(&(media->pres),1);
stream = &desc->u.media.parms[desc->u.media.num.val-1]->u.stream;
stream->pres.pres = PRSNT_NODEF;
stream->pres.val = 0x01;
stream->sl.pres.pres = PRSNT_NODEF;
stream->sl.pres.val = 0x01;
local = &stream->sl.local;
remote = &stream->sl.remote;
/* Fill CmSdpMediaField */
MG_INIT_TOKEN_VALUE(&(media->field.pres),1);
MG_INIT_TOKEN_VALUE(&(media->field.mediaType),CM_SDP_MEDIA_AUDIO);
memcpy(&stream->streamId, &desc->u.media.parms[0]->u.stream.streamId, sizeof(MgMgcoStreamId));
MG_INIT_TOKEN_VALUE(&(media->field.id.type),CM_SDP_VCID_PORT);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.type),CM_SDP_PORT_INT);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.pres),1);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.type), CM_SDP_SPEC);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.val), 2904);
local->pres.pres = PRSNT_NODEF;
psdp = &(local->sdp);
prsdp = &(remote->sdp);
if (mgUtlGrowList((void ***)&psdp->info, sizeof(CmSdpInfo),
&psdp->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
if (mgUtlGrowList((void ***)&media->field.par.pflst, sizeof(CmSdpMedProtoFmts),
&media->field.par.numProtFmts, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
return SWITCH_STATUS_FALSE;
}
psdp->info[0]->pres.pres = PRSNT_NODEF;
/* fill version */
/*memcpy(&psdp->info[0]->ver, &prsdp->info[0]->ver, sizeof(TknU16)); */
MG_INIT_TOKEN_VALUE(&(psdp->info[0]->ver),1);
/* fill orig */
MG_SET_TKNSTROSXL(psdp->info[0]->orig.orig.usrName, 1, "-",
&rsp.u.mgCmdRsp[0]->memCp);
MG_SET_TKNSTROSXL(psdp->info[0]->orig.orig.sessId, 1, "0",
&rsp.u.mgCmdRsp[0]->memCp);
MG_SET_TKNSTROSXL(psdp->info[0]->orig.orig.sessVer, 1, "0",
&rsp.u.mgCmdRsp[0]->memCp);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.netType.type),
CM_SDP_NET_TYPE_IN);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.addrType),
CM_SDP_ADDR_TYPE_IPV4);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.addrType),
CM_SDP_IPV4_IP_UNI);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.addrType),
CM_SDP_IPV4_IP_UNI);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[0]),
ipAddress[0]);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]),
ipAddress[1]);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]),
ipAddress[2]);
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]),
ipAddress[3]);
/* fill session name */
/*memcpy(&psdp->info[0]->sessName, &prsdp->info[0]->sessName, sizeof(TknStrOSXL));*/
MG_SET_TKNSTROSXL(psdp->info[0]->sessName, 1, "-",&rsp.u.mgCmdRsp[0]->memCp);
/* CmSdpMedProtoFmts */
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[media->field.par.numProtFmts.val-1]->prot.type), CM_SDP_MEDIA_PROTO_RTP)
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[media->field.par.numProtFmts.val-1]->prot.u.subtype.type), CM_SDP_PROTO_RTP_AVP);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[media->field.par.numProtFmts.val-1]->protType), CM_SDP_MEDIA_PROTO_RTP);
/* fill info */
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[0]), ipAddress[0]);
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[1]), ipAddress[1]);
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[2]), ipAddress[2]);
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[3]), ipAddress[3]);
/* Fill the SDP Connection Info */
/* "c=" line - ipaddress */
/*memcpy(&psdp->info[0]->conn, &prsdp->info[0]->conn, sizeof(CmSdpConn));*/
/* fill media descriptors */
if (mgUtlGrowList((void ***)&media->field.par.pflst[media->field.par.numProtFmts.val-1]->u.rtp.fmts, sizeof(CmSdpU8OrNil),
&media->field.par.pflst[media->field.par.numProtFmts.val-1]->u.rtp.num, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
{
CmSdpMediaDescSet* med = &psdp->info[0]->mediaDescSet;
CmSdpMediaDesc* media;
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
return SWITCH_STATUS_FALSE;
}
if (mgUtlGrowList((void ***)&med->mediaDesc, sizeof(CmSdpMediaDesc),
&med->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[media->field.par.numProtFmts.val-1]->u.rtp.fmts[0]->type), CM_SDP_SPEC);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[media->field.par.numProtFmts.val-1]->u.rtp.fmts[0]->val), 4);
/* Fill attribute if reqd */
{
if (mgUtlGrowList((void ***)&media->attrSet.attr, sizeof(CmSdpAttr),
&media->attrSet.numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
return SWITCH_STATUS_FALSE;
}
media = med->mediaDesc[0];
MG_INIT_TOKEN_VALUE(&(media->pres),1);
/* Fill CmSdpMediaField */
MG_INIT_TOKEN_VALUE(&(media->field.pres),1);
MG_INIT_TOKEN_VALUE(&(media->field.mediaType),CM_SDP_MEDIA_AUDIO);
MG_INIT_TOKEN_VALUE(&(media->field.id.type),CM_SDP_VCID_PORT);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.type),CM_SDP_PORT_INT);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.pres),1);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.type),
CM_SDP_SPEC);
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.val), 2904);
MG_INIT_TOKEN_VALUE(&(media->field.par.numProtFmts),1);
MG_GETMEM((media->field.par.pflst),1*sizeof(CmSdpMedProtoFmts*),&rsp.u.mgCmdRsp[0]->memCp, ret);
MG_GETMEM((media->field.par.pflst[0]),sizeof(CmSdpMedProtoFmts),&rsp.u.mgCmdRsp[0]->memCp, ret);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->prot.type),
CM_SDP_MEDIA_PROTO_RTP)
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->prot.u.subtype.type),
CM_SDP_PROTO_RTP_AVP);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->protType),
CM_SDP_MEDIA_PROTO_RTP);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->u.rtp.num),1);
MG_GETMEM((media->field.par.pflst[0]->u.rtp.fmts),
1*sizeof(CmSdpU8OrNil *), &rsp.u.mgCmdRsp[0]->memCp, ret);
MG_GETMEM((media->field.par.pflst[0]->u.rtp.fmts[0]),
sizeof(CmSdpU8OrNil), &rsp.u.mgCmdRsp[0]->memCp, ret);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->u.rtp.fmts[0]->type),
CM_SDP_SPEC);
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->u.rtp.fmts[0]->val),
4);
/* Fill attribute if reqd */
{
MG_INIT_TOKEN_VALUE(&(media->attrSet.numComp),1);
MG_GETMEM((media->attrSet.attr),sizeof(CmSdpAttr*),&rsp.u.mgCmdRsp[0]->memCp, ret);
MG_GETMEM((media->attrSet.attr[0]),sizeof(CmSdpAttr),&rsp.u.mgCmdRsp[0]->memCp, ret);
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->type),CM_SDP_ATTR_PTIME);
media->attrSet.attr[0]->u.ptime.pres = PRSNT_NODEF;
media->attrSet.attr[0]->u.ptime.val = 30;
}
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->type),CM_SDP_ATTR_PTIME);
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->u.ptime),30);
}
printf("ret[%d]\n",ret);
}
}
else {
printf("!local->pres.pres false \n");
}
}
#endif
/* We will always send one command at a time..*/