Merge branch 'nsg-4.3' of ssh://git.sangoma.com/smg_freeswitch into nsg-4.3
This commit is contained in:
commit
7972837f76
|
@ -178,6 +178,7 @@ static const char* channel_get_variable(switch_core_session_t *session, switch_e
|
|||
ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session_t **sp);
|
||||
void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream);
|
||||
void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream);
|
||||
void ctdm_init(switch_loadable_module_interface_t *module_interface);
|
||||
|
||||
static switch_core_session_t *ftdm_channel_get_session(ftdm_channel_t *channel, int32_t id)
|
||||
{
|
||||
|
@ -5359,6 +5360,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
|
|||
SWITCH_ADD_APP(app_interface, "disable_dtmf", "Disable DTMF Detection", "Disable DTMF Detection", disable_dtmf_function, "", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "enable_dtmf", "Enable DTMF Detection", "Enable DTMF Detection", enable_dtmf_function, "", SAF_NONE);
|
||||
|
||||
ctdm_init(*module_interface);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ void ctdm_init(switch_loadable_module_interface_t *module_interface);
|
|||
|
||||
#define kSPAN_ID "span"
|
||||
#define kCHAN_ID "chan"
|
||||
#define kSPAN_NAME "span_name"
|
||||
|
||||
static struct {
|
||||
switch_memory_pool_t *pool;
|
||||
|
@ -96,8 +97,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
switch_memory_pool_t **pool,
|
||||
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
const char *szspanid = switch_event_get_header(var_event, kSPAN_ID),
|
||||
*szchanid = switch_event_get_header(var_event, kCHAN_ID);
|
||||
const char *szchanid = switch_event_get_header(var_event, kCHAN_ID),
|
||||
*span_name = switch_event_get_header(var_event, kSPAN_NAME);
|
||||
int chan_id;
|
||||
int span_id;
|
||||
|
||||
|
@ -111,14 +112,21 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
|
||||
ctdm_private_t *tech_pvt = NULL;
|
||||
|
||||
if (zstr(szchanid) || zstr(szspanid)) {
|
||||
if (zstr(szchanid) || zstr(span_name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Both ["kSPAN_ID"] and ["kCHAN_ID"] have to be set.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
chan_id = atoi(szchanid);
|
||||
span_id = atoi(szspanid);
|
||||
|
||||
|
||||
if (ftdm_span_find_by_name(span_name, &span) == FTDM_SUCCESS) {
|
||||
span_id = ftdm_span_get_id(span);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find span [%s]\n", span_name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (!(*new_session = switch_core_session_request(ctdm.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't request session.\n");
|
||||
|
@ -262,9 +270,9 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
|||
if (tech_pvt->write_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
|
||||
ftdm_channel_close(&tech_pvt->ftdm_channel);
|
||||
}
|
||||
|
||||
ftdm_channel_close(&tech_pvt->ftdm_channel);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -88,19 +88,6 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
|
|||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
char dialstring[100];
|
||||
switch_call_cause_t cause;
|
||||
|
||||
if (!zstr(term->uuid)) {
|
||||
/* A UUID is present, check if the channel still exists */
|
||||
switch_core_session_t *session;
|
||||
if ((session = switch_core_session_locate(term->uuid))) {
|
||||
switch_core_session_rwunlock(session);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel [%s] already exists for termination [%s]\n", term->uuid, term->name);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* The referenced channel doesn't exist anymore, clear it */
|
||||
term->uuid = NULL;
|
||||
}
|
||||
|
||||
switch_event_create(&var_event, SWITCH_EVENT_CLONE);
|
||||
|
||||
|
@ -120,20 +107,43 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
|
|||
} else if (term->type == MG_TERM_TDM) {
|
||||
switch_snprintf(dialstring, sizeof dialstring, "tdm/%s", term->name);
|
||||
|
||||
switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, kSPAN_ID, "%d", term->u.tdm.span);
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, kSPAN_NAME, term->u.tdm.span_name);
|
||||
switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, kCHAN_ID, "%d", term->u.tdm.channel);
|
||||
}
|
||||
|
||||
/* Set common variables on the channel */
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, "true");
|
||||
|
||||
if (!zstr(term->uuid)) {
|
||||
/* A UUID is present, check if the channel still exists */
|
||||
switch_core_session_t *session;
|
||||
if ((session = switch_core_session_locate(term->uuid))) {
|
||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "command", "media_modify");
|
||||
|
||||
switch_core_session_receive_event(session, &var_event);
|
||||
|
||||
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_CAUSE_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto done;
|
||||
switch_core_session_rwunlock(session);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sent refresh to channel [%s], for termination [%s]\n", term->uuid, term->name);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* The referenced channel doesn't exist anymore, clear it */
|
||||
term->uuid = NULL;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Termination [%s] successfully instanciated as [%s] [%s]\n", term->name, dialstring, switch_core_session_get_uuid(session));
|
||||
if (zstr(term->uuid)) {
|
||||
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_CAUSE_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Termination [%s] successfully instanciated as [%s] [%s]\n", term->name, dialstring, switch_core_session_get_uuid(session));
|
||||
}
|
||||
|
||||
switch_set_flag(term, MGT_ACTIVE);
|
||||
|
||||
done:
|
||||
if (session) {
|
||||
|
@ -151,6 +161,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
|||
mg_termination_t *term = NULL;
|
||||
char name[100];
|
||||
int term_id;
|
||||
size_t prefixlen = strlen(prefix);
|
||||
|
||||
/* Check the termination type by prefix */
|
||||
if (strncasecmp(prefix, profile->rtp_termination_id_prefix, strlen(profile->rtp_termination_id_prefix)) == 0) {
|
||||
|
@ -158,8 +169,14 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
|||
term_id = mg_rtp_request_id(profile);
|
||||
switch_snprintf(name, sizeof name, "%s/%d", profile->rtp_termination_id_prefix, term_id);
|
||||
} else {
|
||||
for (term = profile->physical_terminations; term; term = term->next) {
|
||||
if (!switch_test_flag(term, MGT_ALLOCATED) && !strncasecmp(prefix, term->name, prefixlen)) {
|
||||
switch_set_flag(term, MGT_ALLOCATED);
|
||||
return term;
|
||||
}
|
||||
}
|
||||
|
||||
return term;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
@ -168,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
|||
term->type = termtype;
|
||||
term->active_events = NULL;
|
||||
term->profile = profile;
|
||||
switch_set_flag(term, MGT_ALLOCATED);
|
||||
|
||||
if (termtype == MG_TERM_RTP) {
|
||||
/* Fill in local address and reserve an rtp port */
|
||||
|
@ -175,6 +193,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
|||
term->u.rtp.local_port = switch_rtp_request_port(term->u.rtp.local_addr);
|
||||
term->u.rtp.codec = megaco_codec_str(profile->default_codec);
|
||||
term->u.rtp.term_id = term_id;
|
||||
term->u.rtp.ptime = 20;
|
||||
term->name = switch_core_strdup(term->pool, name);
|
||||
}
|
||||
|
||||
|
@ -212,6 +231,9 @@ void megaco_termination_destroy(mg_termination_t *term)
|
|||
term->active_events = NULL;
|
||||
}
|
||||
|
||||
switch_clear_flag(term, MGT_ALLOCATED);
|
||||
switch_clear_flag(term, MGT_ACTIVE);
|
||||
|
||||
if (term->type == MG_TERM_RTP) {
|
||||
switch_core_hash_delete_wrlock(term->profile->terminations, term->name, term->profile->terminations_rwlock);
|
||||
switch_core_destroy_memory_pool(&term->pool);
|
||||
|
|
|
@ -142,8 +142,13 @@ switch_status_t mg_is_ito_pkg_req(megaco_profile_t* mg_profile, MgMgcoCommand *c
|
|||
(reqEvtPar->u.other.val.u.eq.type.pres == PRSNT_NODEF) &&
|
||||
(reqEvtPar->u.other.val.u.eq.type.val == MGT_VALTYPE_UINT32))
|
||||
{
|
||||
#ifdef BIT_64
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Received Inactivity timer value [%d]\n",
|
||||
reqEvtPar->u.other.val.u.eq.u.decInt.val);
|
||||
#else
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Received Inactivity timer value [%ld]\n",
|
||||
reqEvtPar->u.other.val.u.eq.u.decInt.val);
|
||||
#endif
|
||||
|
||||
mg_profile->inact_tmr = reqEvtPar->u.other.val.u.eq.u.decInt.val/MG_INACTIVITY_TMR_RESOLUTION;
|
||||
|
||||
|
@ -544,7 +549,7 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||
if ((NOTPRSNT != termId->type.pres) &&
|
||||
(MGT_TERMID_CHOOSE == termId->type.val)){
|
||||
|
||||
term = megaco_choose_termination(mg_profile, "RTP"); /* TODO - RTP string has be configured one */
|
||||
term = megaco_choose_termination(mg_profile, mg_profile->rtp_termination_id_prefix);
|
||||
|
||||
if(NULL == term){
|
||||
mg_util_set_err_string(&errTxt, " Resource Failure ");
|
||||
|
@ -660,189 +665,194 @@ 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);
|
||||
|
||||
{
|
||||
/* build local descriptors */
|
||||
/*MgMgcoStreamDesc *stream;*/
|
||||
MgMgcoLocalDesc *local;
|
||||
CmSdpInfoSet *psdp;
|
||||
char* ipAddress = "192.168.1.1";
|
||||
MgMgcoMediaDesc* media = &desc->u.media;
|
||||
/* only for RTP */
|
||||
if(is_rtp){
|
||||
/* build local descriptors */
|
||||
/*MgMgcoStreamDesc *stream;*/
|
||||
MgMgcoLocalDesc *local;
|
||||
CmSdpInfoSet *psdp;
|
||||
char* ipAddress[4];// = "192.168.1.1";
|
||||
MgMgcoMediaDesc* media = &desc->u.media;
|
||||
|
||||
/* Most probably we need to add local descriptor */
|
||||
switch_split((char*)term->u.rtp.local_addr,'.',ipAddress);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
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 */
|
||||
|
||||
/* 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;*/
|
||||
/* 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);
|
||||
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;
|
||||
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));
|
||||
}
|
||||
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);
|
||||
MG_INIT_TOKEN_VALUE(&(stream->streamId), 1);
|
||||
|
||||
|
||||
stream->sl.pres.pres = PRSNT_NODEF;
|
||||
stream->sl.pres.val = 0x01;
|
||||
stream->sl.pres.pres = PRSNT_NODEF;
|
||||
stream->sl.pres.val = 0x01;
|
||||
|
||||
local = &stream->sl.local;
|
||||
local = &stream->sl.local;
|
||||
#endif
|
||||
media->parms[media->num.val-1]->type.pres = PRSNT_NODEF;
|
||||
media->parms[media->num.val-1]->type.val = MGT_MEDIAPAR_LOCAL;
|
||||
media->parms[media->num.val-1]->type.pres = PRSNT_NODEF;
|
||||
media->parms[media->num.val-1]->type.val = MGT_MEDIAPAR_LOCAL;
|
||||
|
||||
local = &media->parms[media->num.val-1]->u.local;
|
||||
local = &media->parms[media->num.val-1]->u.local;
|
||||
|
||||
local->pres.pres = PRSNT_NODEF;
|
||||
local->pres.pres = PRSNT_NODEF;
|
||||
|
||||
psdp = &(local->sdp);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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 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);
|
||||
/* 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]);
|
||||
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]),
|
||||
atoi(ipAddress[0]));
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]),
|
||||
atoi(ipAddress[1]));
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]),
|
||||
atoi(ipAddress[2]));
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]),
|
||||
atoi(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 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);
|
||||
/* 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]);
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[0]), atoi(ipAddress[0]));
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[1]), atoi(ipAddress[1]));
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[2]), atoi(ipAddress[2]));
|
||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->conn.u.ip4.u.uniIp.b[3]), atoi(ipAddress[3]));
|
||||
|
||||
/* t= line */
|
||||
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->sdpTime.pres),1);
|
||||
|
||||
/* 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);
|
||||
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;
|
||||
/* 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
media = med->mediaDesc[med->numComp.val-1];
|
||||
media = med->mediaDesc[med->numComp.val-1];
|
||||
|
||||
MG_INIT_TOKEN_VALUE(&(media->pres),1);
|
||||
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);
|
||||
/* 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.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), term->u.rtp.local_port);
|
||||
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.val), 2904);
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
/* 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);
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
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)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
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]->type), CM_SDP_SPEC);
|
||||
|
||||
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[media->field.par.numProtFmts.val-1]->u.rtp.fmts[0]->val), 4);
|
||||
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;
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
|
||||
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->type),CM_SDP_ATTR_PTIME);
|
||||
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->u.ptime),30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->type),CM_SDP_ATTR_PTIME);
|
||||
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->u.ptime), term->u.rtp.ptime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* We will always send one command at a time..*/
|
||||
|
|
|
@ -77,8 +77,6 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||
//const char *tech = switch_xml_attr(mg_term, "tech");
|
||||
const char *channel_prefix = switch_xml_attr(mg_term, "channel-prefix");
|
||||
const char *channel_map = switch_xml_attr(mg_term, "channel-map");
|
||||
const char *szspan_id = switch_xml_attr(mg_term, "span-id");
|
||||
const int span_id = !zstr(szspan_id) ? atoi(szspan_id) : 0;
|
||||
|
||||
|
||||
if (!zstr(channel_map)) {
|
||||
|
@ -102,12 +100,14 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||
term->type = MG_TERM_TDM;
|
||||
term->profile = profile;
|
||||
term->name = switch_core_sprintf(pool, "%s%d", prefix, j);
|
||||
term->u.tdm.span = span_id;
|
||||
term->u.tdm.channel = j;
|
||||
term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);
|
||||
|
||||
switch_core_hash_insert_wrlock(profile->terminations, term->name, term, profile->terminations_rwlock);
|
||||
term->next = profile->physical_terminations;
|
||||
profile->physical_terminations = term;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Mapped termination [%s] to freetdm span: %d chan: %d\n", term->name, term->u.tdm.span, term->u.tdm.channel);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Mapped termination [%s] to freetdm span: %s chan: %d\n", term->name, term->u.tdm.span_name, term->u.tdm.channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,10 +83,17 @@ typedef struct mg_context_s mg_context_t;
|
|||
/* TDM parameters understood by the controllable channel */
|
||||
#define kSPAN_ID "span"
|
||||
#define kCHAN_ID "chan"
|
||||
#define kSPAN_NAME "span_name"
|
||||
|
||||
|
||||
typedef struct mg_termination_s mg_termination_t;
|
||||
|
||||
enum {
|
||||
MGT_ALLOCATED = (1 << 0),
|
||||
MGT_ACTIVE = (1 << 1),
|
||||
|
||||
} mg_termination_flags;
|
||||
|
||||
struct mg_termination_s {
|
||||
switch_memory_pool_t *pool;
|
||||
mg_termination_type_t type;
|
||||
|
@ -96,6 +103,7 @@ struct mg_termination_s {
|
|||
megaco_profile_t *profile; /*!< Parent MG profile */
|
||||
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
|
||||
mg_termination_t *next; /*!< List for physical terminations */
|
||||
uint32_t flags;
|
||||
|
||||
union {
|
||||
struct {
|
||||
|
@ -116,8 +124,8 @@ struct mg_termination_s {
|
|||
} rtp;
|
||||
|
||||
struct {
|
||||
int span;
|
||||
int channel;
|
||||
const char *span_name;
|
||||
} tdm;
|
||||
} u;
|
||||
};
|
||||
|
@ -165,6 +173,9 @@ struct megaco_profile_s {
|
|||
|
||||
uint8_t rtpid_bitmap[MG_MAX_CONTEXTS/8];
|
||||
uint32_t rtpid_next;
|
||||
|
||||
mg_termination_t *physical_terminations;
|
||||
|
||||
switch_hash_t *terminations;
|
||||
switch_thread_rwlock_t *terminations_rwlock;
|
||||
};
|
||||
|
|
|
@ -93,6 +93,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg);
|
||||
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf);
|
||||
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event);
|
||||
|
||||
switch_state_handler_table_t crtp_state_handlers = {
|
||||
.on_init = channel_on_init,
|
||||
|
@ -104,6 +105,7 @@ switch_io_routines_t crtp_io_routines = {
|
|||
.read_frame = channel_read_frame,
|
||||
.write_frame = channel_write_frame,
|
||||
.receive_message = channel_receive_message,
|
||||
.receive_event = channel_receive_event,
|
||||
.send_dtmf = channel_send_dtmf
|
||||
};
|
||||
|
||||
|
@ -395,6 +397,42 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_bool_t compare_var(switch_event_t *event, switch_channel_t *channel, const char *varname)
|
||||
{
|
||||
const char *chan_val = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1);
|
||||
const char *event_val = switch_event_get_header(event, varname);
|
||||
|
||||
return strcasecmp(chan_val, event_val);
|
||||
}
|
||||
|
||||
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
|
||||
{
|
||||
const char *command = switch_event_get_header(event, "command");
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (!zstr(command) && !strcasecmp(command, "media_modify")) {
|
||||
/* Compare parameters */
|
||||
if (compare_var(event, channel, kREMOTEADDR) ||
|
||||
compare_var(event, channel, kREMOTEPORT) ||
|
||||
compare_var(event, channel, kLOCALADDR) ||
|
||||
compare_var(event, channel, kLOCALPORT)) {
|
||||
/* We need to reset the rtp session */
|
||||
|
||||
}
|
||||
|
||||
if (compare_var(event, channel, kCODEC) ||
|
||||
compare_var(event, channel, kPTIME) ||
|
||||
compare_var(event, channel, kPT) ||
|
||||
compare_var(event, channel, kRATE)) {
|
||||
/* Reset codec */
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
|
||||
}
|
||||
}
|
||||
|
||||
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
||||
{
|
||||
crtp_private_t *tech_pvt = NULL;
|
||||
|
|
Loading…
Reference in New Issue