changes on test box

This commit is contained in:
root 2012-07-26 12:30:33 -04:00
parent f57825f1fe
commit ee8047ebbf
8 changed files with 296 additions and 256 deletions

View File

@ -301,6 +301,8 @@ switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *
} }
} }
mgco_handle_sdp(&local->sdp, term, MG_SDP_LOCAL);
break; break;
} }
@ -311,6 +313,7 @@ switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *
remote = &mediaPar->u.remote; remote = &mediaPar->u.remote;
sdp = remote->sdp.info[0]; sdp = remote->sdp.info[0];
/* for Matt - same like local descriptor */ /* for Matt - same like local descriptor */
mgco_handle_sdp(&remote->sdp, term, MG_SDP_REMOTE);
break; break;
} }
@ -403,12 +406,12 @@ switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *
if (mgStream->sl.remote.pres.pres) { if (mgStream->sl.remote.pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n");
mgco_print_sdp(&mgStream->sl.remote.sdp); mgco_handle_sdp(&mgStream->sl.remote.sdp, term, MG_SDP_LOCAL);
} }
if (mgStream->sl.local.pres.pres) { if (mgStream->sl.local.pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got local stream media description:\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got local stream media description:\n");
mgco_print_sdp(&mgStream->sl.local.sdp); mgco_handle_sdp(&mgStream->sl.local.sdp, term, MG_SDP_REMOTE);
} }
break; break;
@ -567,11 +570,8 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
is_rtp = 0x01; is_rtp = 0x01;
/* TODO - Matt */
/* allocate rtp term and associated the same to context */
/********************************************************************/ /********************************************************************/
}else{ /* Physical termination */ }else{ /* Physical termination */
printf("termId->name.lcl.val[%s]\n",termId->name.lcl.val);
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val); term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
if(NULL == term){ if(NULL == term){
@ -581,9 +581,6 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
} }
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name);
/* get physical termination */
} }
/********************************************************************/ /********************************************************************/
/* associate physical termination to context */ /* associate physical termination to context */
@ -694,8 +691,6 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
switch_split(dup,'.',ipAddress); switch_split(dup,'.',ipAddress);
printf("ipAddress[0]=%s, ipAddress[1]=%s, ipAddress[2]=%s,ipAddress[3]=%s\n",ipAddress[0],ipAddress[1],ipAddress[2],ipAddress[3]);
/* Most probably we need to add local descriptor */ /* Most probably we need to add local descriptor */
/* allocating mem for local descriptor */ /* allocating mem for local descriptor */
@ -1033,6 +1028,9 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
ret = mg_prc_descriptors(mg_profile, inc_cmd, term); ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
/* SDP updated to termination */
megaco_activate_termination(term);
} }
/********************************************************************/ /********************************************************************/

View File

@ -15,6 +15,13 @@
#define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */ #define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */
typedef enum{
MG_SDP_NONE,
MG_SDP_LOCAL,
MG_SDP_REMOTE,
}mgco_sdp_types_e;
typedef enum{ typedef enum{
SNG_MG_TPT_NONE, SNG_MG_TPT_NONE,
SNG_MG_TPT_UDP, SNG_MG_TPT_UDP,
@ -151,7 +158,7 @@ int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, m
switch_status_t mg_is_ito_pkg_req(megaco_profile_t* mg_profile, MgMgcoCommand *cmd); 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); switch_status_t mg_send_end_of_axn(SuId suId, MgMgcoTransId* transId, MgMgcoContextId* ctxtId, TknU32* peerId);
void mgco_print_sdp(CmSdpInfoSet *sdp); void mgco_handle_sdp(CmSdpInfoSet *sdp,mg_termination_t* term, mgco_sdp_types_e sdp_type);
void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId); 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_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); switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd);

View File

@ -740,8 +740,11 @@ void mgco_print_sdp_attr_set(CmSdpAttrSet *s)
} }
void mgco_print_sdp_c_line(CmSdpConn *s) void mgco_handle_sdp_c_line(CmSdpConn *s, mg_termination_t* term, mgco_sdp_types_e sdp_type)
{ {
char ipadd[12];
memset(ipadd, 0, 12);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "********** SDP connection line ****** \n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "********** SDP connection line ****** \n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\t Net Type = %d \n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\t Net Type = %d \n",
@ -760,6 +763,20 @@ void mgco_print_sdp_c_line(CmSdpConn *s)
s->u.ip4.u.uniIp.b[1].val, s->u.ip4.u.uniIp.b[1].val,
s->u.ip4.u.uniIp.b[2].val, s->u.ip4.u.uniIp.b[2].val,
s->u.ip4.u.uniIp.b[3].val); s->u.ip4.u.uniIp.b[3].val);
if(MG_SDP_REMOTE == sdp_type) {
sprintf(ipadd,"%d.%d.%d.%d",
s->u.ip4.u.uniIp.b[0].val,
s->u.ip4.u.uniIp.b[1].val,
s->u.ip4.u.uniIp.b[2].val,
s->u.ip4.u.uniIp.b[3].val);
printf("Remote ip = %s \n", ipadd);
/* update remote ip */
if(MG_TERM_RTP == term->type){
term->u.rtp.remote_addr = strdup(ipadd);
printf("Update remote ip to [%s]\n", term->u.rtp.remote_addr);
}
}
} }
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "**************** \n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "**************** \n");
@ -834,12 +851,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "**************** \n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "**************** \n");
} }
void mgco_print_sdp(CmSdpInfoSet *sdp) void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e sdp_type)
{ {
int i; int i;
if (sdp->numComp.pres == NOTPRSNT) { if (sdp->numComp.pres == NOTPRSNT) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " No %s SDP present \n", (MG_SDP_LOCAL== sdp_type)?"MG_SDP_LOCAL":"MG_SDP_REMOTE");
return; return;
} }
@ -940,7 +957,7 @@ void mgco_print_sdp(CmSdpInfoSet *sdp)
/************************************************************************************************************************/ /************************************************************************************************************************/
/* connection line */ /* connection line */
mgco_print_sdp_c_line(&s->conn); mgco_handle_sdp_c_line(&s->conn, term, sdp_type);
/************************************************************************************************************************/ /************************************************************************************************************************/
/* Bandwidth */ /* Bandwidth */
/* TODO */ /* TODO */
@ -1031,7 +1048,16 @@ void mgco_print_sdp(CmSdpInfoSet *sdp)
{ {
case CM_SDP_PORT_INT: case CM_SDP_PORT_INT:
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\t CM_SDP_PORT_INT: SDP port = %d type = %d \n", p->u.portInt.port.val.val, p->u.portInt.port.type.val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
"\t CM_SDP_PORT_INT: SDP port = %d type = %d \n",
p->u.portInt.port.val.val, p->u.portInt.port.type.val);
if(MG_SDP_REMOTE == sdp_type) {
/* update remote information */
if(MG_TERM_RTP == term->type){
term->u.rtp.remote_port = p->u.portInt.port.val.val;
printf("Update remote port to [%d]\n", term->u.rtp.remote_port);
}
}
break; break;
} }
case CM_SDP_PORT_VPCID: case CM_SDP_PORT_VPCID:
@ -1061,7 +1087,7 @@ void mgco_print_sdp(CmSdpInfoSet *sdp)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\t Number of Connection component[%d]\n",desc->connSet.numComp.val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\t Number of Connection component[%d]\n",desc->connSet.numComp.val);
for(cnt=0;cnt<desc->connSet.numComp.val;cnt++){ for(cnt=0;cnt<desc->connSet.numComp.val;cnt++){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "************************\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "************************\n");
mgco_print_sdp_c_line(desc->connSet.connSet[cnt]); mgco_handle_sdp_c_line(desc->connSet.connSet[cnt], term, sdp_type);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "************************\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "************************\n");
} }
} }
@ -1078,7 +1104,6 @@ void mgco_print_sdp(CmSdpInfoSet *sdp)
int port = desc->field.id.u.port.u.portInt.port.val.val; int port = desc->field.id.u.port.u.portInt.port.val.val;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Port: %d\n", port); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Port: %d\n", port);
} }
} }
} }

View File

@ -639,7 +639,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
MgMgcoNtfyReply* ntfy = &cmd->u.mgCmdCfm[0]->u.ntfy; MgMgcoNtfyReply* ntfy = &cmd->u.mgCmdCfm[0]->u.ntfy;
MgMgcoTermId* term = NULL; MgMgcoTermId* term = NULL;
char term_name[32]; char term_name[32];
memset(&term_name[0], 32, 0x00); memset(&term_name[0], 0x00,32);
strcpy(&term_name[0], "Invalid"); strcpy(&term_name[0], "Invalid");
@ -685,7 +685,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
MgMgcoSvcChgReply* svc = &cmd->u.mgCmdCfm[0]->u.svc; MgMgcoSvcChgReply* svc = &cmd->u.mgCmdCfm[0]->u.svc;
MgMgcoTermId* term = NULL; MgMgcoTermId* term = NULL;
char term_name[32]; char term_name[32];
memset(&term_name[0], 32, 0x00); memset(&term_name[0], 0x00, 32);
strcpy(&term_name[0], "Invalid"); strcpy(&term_name[0], "Invalid");

View File

@ -231,6 +231,7 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile);
void megaco_release_context(mg_context_t *ctx); void megaco_release_context(mg_context_t *ctx);
switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term); switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term);
switch_status_t megaco_context_sub_all_termination(mg_context_t *ctx); switch_status_t megaco_context_sub_all_termination(mg_context_t *ctx);
switch_status_t megaco_activate_termination(mg_termination_t *term);
mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const char *prefix); mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const char *prefix);
mg_termination_t *megaco_find_termination(megaco_profile_t *profile, const char *name); mg_termination_t *megaco_find_termination(megaco_profile_t *profile, const char *name);

View File

@ -315,7 +315,8 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
tech_pvt = switch_core_session_get_private(session); tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL); assert(tech_pvt != NULL);
if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_RECVONLY) { if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_SENDONLY) {
switch_yield(20000); /* replace by local timer XXX */
goto cng; goto cng;
} }
@ -338,6 +339,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
cng: cng:
*frame = &tech_pvt->read_frame; *frame = &tech_pvt->read_frame;
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
tech_pvt->read_frame.flags |= SFF_CNG; tech_pvt->read_frame.flags |= SFF_CNG;
tech_pvt->read_frame.datalen = 0; tech_pvt->read_frame.datalen = 0;
@ -370,6 +372,9 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
tech_pvt->timestamp_send += samples; tech_pvt->timestamp_send += samples;
#endif #endif
if (tech_pvt->mode == RTP_RECVONLY) {
return SWITCH_STATUS_SUCCESS;
}
switch_rtp_write_frame(tech_pvt->rtp_session, frame); switch_rtp_write_frame(tech_pvt->rtp_session, frame);
@ -404,6 +409,10 @@ static switch_bool_t compare_var(switch_event_t *event, switch_channel_t *channe
const char *chan_val = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1); const char *chan_val = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1);
const char *event_val = switch_event_get_header(event, varname); const char *event_val = switch_event_get_header(event, varname);
if (zstr(chan_val) || zstr(event_val)) {
return 1;
}
return strcasecmp(chan_val, event_val); return strcasecmp(chan_val, event_val);
} }
@ -418,7 +427,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
if (compare_var(event, channel, kREMOTEADDR) || if (compare_var(event, channel, kREMOTEADDR) ||
compare_var(event, channel, kREMOTEPORT)) { compare_var(event, channel, kREMOTEPORT)) {
char *remote_addr = switch_event_get_header(event, kREMOTEADDR); char *remote_addr = switch_event_get_header(event, kREMOTEADDR);
char *szremote_port = switch_event_get_header(event, kREMOTEADDR); char *szremote_port = switch_event_get_header(event, kREMOTEPORT);
switch_port_t remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0; switch_port_t remote_port = !zstr(szremote_port) ? atoi(szremote_port) : 0;
const char *err; const char *err;

View File

@ -4154,8 +4154,8 @@ SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid(switch_channel_t *c
{ {
const char *uuid = NULL; const char *uuid = NULL;
if (!(uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { if (!(uuid = switch_channel_get_variable_dup(channel, SWITCH_SIGNAL_BOND_VARIABLE, SWITCH_FALSE, -1))) {
uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE); uuid = switch_channel_get_variable_dup(channel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE, SWITCH_FALSE, -1);
} }
return uuid; return uuid;

View File

@ -2165,7 +2165,7 @@ SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session)
} }
switch_mutex_lock(rtp_session->flag_mutex); switch_mutex_lock(rtp_session->flag_mutex);
ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input && rtp_session->sock_output && rtp_session->remote_addr ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input /* && rtp_session->sock_output && rtp_session->remote_addr */
&& rtp_session->ready == 2) ? 1 : 0; && rtp_session->ready == 2) ? 1 : 0;
switch_mutex_unlock(rtp_session->flag_mutex); switch_mutex_unlock(rtp_session->flag_mutex);