mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-05 15:10:09 +00:00
Merge branch 'nsg-4.3' of git.sangoma.com:smg_freeswitch into nsg/4.3
Conflicts: src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
This commit is contained in:
commit
3fbde17442
@ -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);
|
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(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 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)
|
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, "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);
|
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 */
|
/* indicate that the module should continue to be loaded */
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ void ctdm_init(switch_loadable_module_interface_t *module_interface);
|
|||||||
|
|
||||||
#define kSPAN_ID "span"
|
#define kSPAN_ID "span"
|
||||||
#define kCHAN_ID "chan"
|
#define kCHAN_ID "chan"
|
||||||
|
#define kSPAN_NAME "span_name"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
@ -51,6 +52,8 @@ typedef struct {
|
|||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_codec_t read_codec, write_codec;
|
switch_codec_t read_codec, write_codec;
|
||||||
switch_frame_t read_frame;
|
switch_frame_t read_frame;
|
||||||
|
|
||||||
|
unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
|
||||||
} ctdm_private_t;
|
} ctdm_private_t;
|
||||||
|
|
||||||
static switch_status_t channel_on_init(switch_core_session_t *session);
|
static switch_status_t channel_on_init(switch_core_session_t *session);
|
||||||
@ -96,11 +99,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
switch_memory_pool_t **pool,
|
switch_memory_pool_t **pool,
|
||||||
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
|
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
|
||||||
{
|
{
|
||||||
const char *szspanid = switch_event_get_header(var_event, kSPAN_ID),
|
const char *szchanid = switch_event_get_header(var_event, kCHAN_ID),
|
||||||
*szchanid = switch_event_get_header(var_event, kCHAN_ID);
|
*span_name = switch_event_get_header(var_event, kSPAN_NAME);
|
||||||
int chan_id;
|
int chan_id;
|
||||||
int span_id;
|
int span_id;
|
||||||
|
switch_caller_profile_t *caller_profile;
|
||||||
ftdm_span_t *span;
|
ftdm_span_t *span;
|
||||||
ftdm_channel_t *chan;
|
ftdm_channel_t *chan;
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
@ -111,13 +114,19 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
|
|
||||||
ctdm_private_t *tech_pvt = NULL;
|
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");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Both ["kSPAN_ID"] and ["kCHAN_ID"] have to be set.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
chan_id = atoi(szchanid);
|
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))) {
|
if (!(*new_session = switch_core_session_request(ctdm.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) {
|
||||||
@ -139,8 +148,14 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
tech_pvt->span_id = span_id;
|
tech_pvt->span_id = span_id;
|
||||||
tech_pvt->ftdm_channel = chan;
|
tech_pvt->ftdm_channel = chan;
|
||||||
tech_pvt->session = *new_session;
|
tech_pvt->session = *new_session;
|
||||||
|
tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
|
||||||
|
tech_pvt->read_frame.data = tech_pvt->databuf;
|
||||||
switch_core_session_set_private(*new_session, tech_pvt);
|
switch_core_session_set_private(*new_session, tech_pvt);
|
||||||
|
|
||||||
|
|
||||||
|
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
||||||
|
switch_channel_set_caller_profile(channel, caller_profile);
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "tdm/%d:%d", span_id, chan_id);
|
snprintf(name, sizeof(name), "tdm/%d:%d", span_id, chan_id);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name);
|
||||||
switch_channel_set_name(channel, name);
|
switch_channel_set_name(channel, name);
|
||||||
@ -220,6 +235,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_channel_mark_answered(channel);
|
||||||
|
|
||||||
return SWITCH_CAUSE_SUCCESS;
|
return SWITCH_CAUSE_SUCCESS;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
@ -246,6 +263,9 @@ fail:
|
|||||||
|
|
||||||
static switch_status_t channel_on_init(switch_core_session_t *session)
|
static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
|
switch_channel_set_state(channel, CS_CONSUME_MEDIA);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,9 +282,9 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
|||||||
if (tech_pvt->write_codec.implementation) {
|
if (tech_pvt->write_codec.implementation) {
|
||||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
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;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -320,6 +340,7 @@ top:
|
|||||||
*frame = &tech_pvt->read_frame;
|
*frame = &tech_pvt->read_frame;
|
||||||
tech_pvt->read_frame.datalen = (uint32_t)len;
|
tech_pvt->read_frame.datalen = (uint32_t)len;
|
||||||
tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen;
|
tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen;
|
||||||
|
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||||
|
|
||||||
if (ftdm_channel_get_codec(tech_pvt->ftdm_channel) == FTDM_CODEC_SLIN) {
|
if (ftdm_channel_get_codec(tech_pvt->ftdm_channel) == FTDM_CODEC_SLIN) {
|
||||||
tech_pvt->read_frame.samples /= 2;
|
tech_pvt->read_frame.samples /= 2;
|
||||||
|
@ -1470,6 +1470,15 @@ FT_DECLARE(ftdm_status_t) ftdm_group_channel_use_count(ftdm_group_t *group, uint
|
|||||||
|
|
||||||
static __inline__ int chan_is_avail(ftdm_channel_t *check)
|
static __inline__ int chan_is_avail(ftdm_channel_t *check)
|
||||||
{
|
{
|
||||||
|
if (check->span->signal_type == FTDM_SIGTYPE_NONE) {
|
||||||
|
if (!ftdm_test_flag(check, FTDM_CHANNEL_READY) ||
|
||||||
|
ftdm_test_flag(check, FTDM_CHANNEL_INUSE) ||
|
||||||
|
ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) ||
|
||||||
|
ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) ||
|
||||||
|
check->state != FTDM_CHANNEL_STATE_DOWN) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (!ftdm_test_flag(check, FTDM_CHANNEL_READY) ||
|
if (!ftdm_test_flag(check, FTDM_CHANNEL_READY) ||
|
||||||
!ftdm_test_flag(check, FTDM_CHANNEL_SIG_UP) ||
|
!ftdm_test_flag(check, FTDM_CHANNEL_SIG_UP) ||
|
||||||
ftdm_test_flag(check, FTDM_CHANNEL_INUSE) ||
|
ftdm_test_flag(check, FTDM_CHANNEL_INUSE) ||
|
||||||
@ -1478,6 +1487,7 @@ static __inline__ int chan_is_avail(ftdm_channel_t *check)
|
|||||||
check->state != FTDM_CHANNEL_STATE_DOWN) {
|
check->state != FTDM_CHANNEL_STATE_DOWN) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5608,16 +5618,61 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_signaling(ftdm_span_t *span, const
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *ftdm_span_service_events(ftdm_thread_t *me, void *obj)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
unsigned waitms;
|
||||||
|
ftdm_event_t *event;
|
||||||
|
ftdm_status_t status = FTDM_SUCCESS;
|
||||||
|
ftdm_span_t *span = (ftdm_span_t*) obj;
|
||||||
|
short *poll_events = ftdm_malloc(sizeof(short) * span->chan_count);
|
||||||
|
|
||||||
|
memset(poll_events, 0, sizeof(short) * span->chan_count);
|
||||||
|
|
||||||
|
for(i = 1; i <= span->chan_count; i++) {
|
||||||
|
poll_events[i] |= FTDM_EVENTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) {
|
||||||
|
waitms = 1000;
|
||||||
|
status = ftdm_span_poll_event(span, waitms, poll_events);
|
||||||
|
switch (status) {
|
||||||
|
case FTDM_FAIL:
|
||||||
|
ftdm_log(FTDM_LOG_CRIT, "%s:Failed to poll span for events\n", span->name);
|
||||||
|
break;
|
||||||
|
case FTDM_TIMEOUT:
|
||||||
|
break;
|
||||||
|
case FTDM_SUCCESS:
|
||||||
|
/* Check if there are any channels that have events available */
|
||||||
|
while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ftdm_log(FTDM_LOG_CRIT, "%s:Unhandled IO event\n", span->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span)
|
FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span)
|
||||||
{
|
{
|
||||||
ftdm_status_t status = FTDM_FAIL;
|
ftdm_status_t status = FTDM_FAIL;
|
||||||
|
|
||||||
ftdm_mutex_lock(span->mutex);
|
ftdm_mutex_lock(span->mutex);
|
||||||
|
|
||||||
if (ftdm_test_flag(span, FTDM_SPAN_STARTED)) {
|
if (ftdm_test_flag(span, FTDM_SPAN_STARTED)) {
|
||||||
status = FTDM_EINVAL;
|
status = FTDM_EINVAL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (span->signal_type == FTDM_SIGTYPE_NONE) {
|
||||||
|
/* If there is no signalling component, start a thread to poll events */
|
||||||
|
status = ftdm_thread_create_detached(ftdm_span_service_events, span);
|
||||||
|
if (status != FTDM_SUCCESS) {
|
||||||
|
ftdm_log(FTDM_LOG_CRIT,"Failed to start span event monitor thread!\n");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = ftdm_report_initial_channels_alarms(span);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (!span->start) {
|
if (!span->start) {
|
||||||
status = FTDM_ENOSYS;
|
status = FTDM_ENOSYS;
|
||||||
@ -5633,7 +5688,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span)
|
|||||||
if (status == FTDM_SUCCESS) {
|
if (status == FTDM_SUCCESS) {
|
||||||
ftdm_set_flag_locked(span, FTDM_SPAN_STARTED);
|
ftdm_set_flag_locked(span, FTDM_SPAN_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ftdm_mutex_unlock(span->mutex);
|
ftdm_mutex_unlock(span->mutex);
|
||||||
return status;
|
return status;
|
||||||
|
@ -89,19 +89,6 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
|
|||||||
char dialstring[100];
|
char dialstring[100];
|
||||||
switch_call_cause_t cause;
|
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);
|
switch_event_create(&var_event, SWITCH_EVENT_CLONE);
|
||||||
|
|
||||||
if (term->type == MG_TERM_RTP) {
|
if (term->type == MG_TERM_RTP) {
|
||||||
@ -120,20 +107,44 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
|
|||||||
} else if (term->type == MG_TERM_TDM) {
|
} else if (term->type == MG_TERM_TDM) {
|
||||||
switch_snprintf(dialstring, sizeof dialstring, "tdm/%s", term->name);
|
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);
|
switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, kCHAN_ID, "%d", term->u.tdm.channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set common variables on the channel */
|
/* Set common variables on the channel */
|
||||||
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, "true");
|
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, SWITCH_PARK_AFTER_BRIDGE_VARIABLE, "true");
|
||||||
|
|
||||||
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_CAUSE_SUCCESS) {
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zstr(term->uuid)) {
|
||||||
|
if (switch_ivr_originate(NULL, &session, &cause, dialstring, 0, NULL, NULL, NULL, NULL, var_event, 0, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to instanciate termination [%s]: %s\n", term->name, switch_channel_cause2str(cause));
|
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;
|
status = SWITCH_STATUS_FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term->uuid = switch_core_strdup(term->pool, switch_core_session_get_uuid(session));
|
||||||
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_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:
|
done:
|
||||||
if (session) {
|
if (session) {
|
||||||
@ -151,6 +162,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
|||||||
mg_termination_t *term = NULL;
|
mg_termination_t *term = NULL;
|
||||||
char name[100];
|
char name[100];
|
||||||
int term_id;
|
int term_id;
|
||||||
|
size_t prefixlen = strlen(prefix);
|
||||||
|
|
||||||
/* Check the termination type by prefix */
|
/* Check the termination type by prefix */
|
||||||
if (strncasecmp(prefix, profile->rtp_termination_id_prefix, strlen(profile->rtp_termination_id_prefix)) == 0) {
|
if (strncasecmp(prefix, profile->rtp_termination_id_prefix, strlen(profile->rtp_termination_id_prefix)) == 0) {
|
||||||
@ -158,16 +170,24 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
|||||||
term_id = mg_rtp_request_id(profile);
|
term_id = mg_rtp_request_id(profile);
|
||||||
switch_snprintf(name, sizeof name, "%s/%d", profile->rtp_termination_id_prefix, term_id);
|
switch_snprintf(name, sizeof name, "%s/%d", profile->rtp_termination_id_prefix, term_id);
|
||||||
} else {
|
} 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);
|
switch_core_new_memory_pool(&pool);
|
||||||
term = switch_core_alloc(pool, sizeof *term);
|
term = switch_core_alloc(pool, sizeof *term);
|
||||||
term->pool = pool;
|
term->pool = pool;
|
||||||
term->type = termtype;
|
term->type = termtype;
|
||||||
term->active_events = NULL;
|
term->active_events = NULL;
|
||||||
|
term->mg_ctxt = NULL;
|
||||||
term->profile = profile;
|
term->profile = profile;
|
||||||
|
switch_set_flag(term, MGT_ALLOCATED);
|
||||||
|
|
||||||
if (termtype == MG_TERM_RTP) {
|
if (termtype == MG_TERM_RTP) {
|
||||||
/* Fill in local address and reserve an rtp port */
|
/* Fill in local address and reserve an rtp port */
|
||||||
@ -175,6 +195,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.local_port = switch_rtp_request_port(term->u.rtp.local_addr);
|
||||||
term->u.rtp.codec = megaco_codec_str(profile->default_codec);
|
term->u.rtp.codec = megaco_codec_str(profile->default_codec);
|
||||||
term->u.rtp.term_id = term_id;
|
term->u.rtp.term_id = term_id;
|
||||||
|
term->u.rtp.ptime = 20;
|
||||||
term->name = switch_core_strdup(term->pool, name);
|
term->name = switch_core_strdup(term->pool, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +233,11 @@ void megaco_termination_destroy(mg_termination_t *term)
|
|||||||
term->active_events = NULL;
|
term->active_events = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term->mg_ctxt = NULL;
|
||||||
|
|
||||||
|
switch_clear_flag(term, MGT_ALLOCATED);
|
||||||
|
switch_clear_flag(term, MGT_ACTIVE);
|
||||||
|
|
||||||
if (term->type == MG_TERM_RTP) {
|
if (term->type == MG_TERM_RTP) {
|
||||||
switch_core_hash_delete_wrlock(term->profile->terminations, term->name, term->profile->terminations_rwlock);
|
switch_core_hash_delete_wrlock(term->profile->terminations, term->name, term->profile->terminations_rwlock);
|
||||||
switch_core_destroy_memory_pool(&term->pool);
|
switch_core_destroy_memory_pool(&term->pool);
|
||||||
@ -263,6 +289,10 @@ switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination
|
|||||||
megaco_activate_termination(ctx->terminations[1]);
|
megaco_activate_termination(ctx->terminations[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bridging: %s (%s) <> %s (%s)\n",
|
||||||
|
ctx->terminations[0]->name, ctx->terminations[0]->uuid,
|
||||||
|
ctx->terminations[1]->name, ctx->terminations[1]->uuid);
|
||||||
|
|
||||||
switch_ivr_uuid_bridge(ctx->terminations[0]->uuid, ctx->terminations[1]->uuid);
|
switch_ivr_uuid_bridge(ctx->terminations[0]->uuid, ctx->terminations[1]->uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.pres == PRSNT_NODEF) &&
|
||||||
(reqEvtPar->u.other.val.u.eq.type.val == MGT_VALTYPE_UINT32))
|
(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",
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Received Inactivity timer value [%d]\n",
|
||||||
(int)reqEvtPar->u.other.val.u.eq.u.decInt.val);
|
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;
|
mg_profile->inact_tmr = reqEvtPar->u.other.val.u.eq.u.decInt.val/MG_INACTIVITY_TMR_RESOLUTION;
|
||||||
|
|
||||||
@ -296,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,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;
|
||||||
@ -490,6 +498,10 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
/*MgMgcoStreamDesc* inc_strm_desc;*/
|
/*MgMgcoStreamDesc* inc_strm_desc;*/
|
||||||
MgMgcoAudRetParm *desc;
|
MgMgcoAudRetParm *desc;
|
||||||
mg_context_t* mg_ctxt;
|
mg_context_t* mg_ctxt;
|
||||||
|
int mediaId;
|
||||||
|
MgMgcoLocalDesc *local = NULL;
|
||||||
|
CmSdpInfoSet *psdp = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* TODO - Kapil dummy line , will need to add with proper code */
|
/* TODO - Kapil dummy line , will need to add with proper code */
|
||||||
inc_med_desc = &cmd->dl.descs[0]->u.media;
|
inc_med_desc = &cmd->dl.descs[0]->u.media;
|
||||||
@ -537,6 +549,12 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
else {
|
else {
|
||||||
/* context already present */
|
/* context already present */
|
||||||
memcpy(new_ctxtId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
memcpy(new_ctxtId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
||||||
|
mg_ctxt = megaco_get_context(mg_profile, inc_cmd->contextId.val.val);
|
||||||
|
if(NULL == mg_ctxt){
|
||||||
|
mg_util_set_err_string(&errTxt, " Resource Failure ");
|
||||||
|
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
@ -544,7 +562,7 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
if ((NOTPRSNT != termId->type.pres) &&
|
if ((NOTPRSNT != termId->type.pres) &&
|
||||||
(MGT_TERMID_CHOOSE == termId->type.val)){
|
(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){
|
if(NULL == term){
|
||||||
mg_util_set_err_string(&errTxt, " Resource Failure ");
|
mg_util_set_err_string(&errTxt, " Resource Failure ");
|
||||||
@ -552,16 +570,34 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
goto error;
|
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);
|
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;
|
is_rtp = 0x01;
|
||||||
|
|
||||||
/* TODO - Matt */
|
|
||||||
/* allocate rtp term and associated the same to context */
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
}else{ /* Physical termination */
|
}else{ /* Physical termination */
|
||||||
|
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
|
||||||
|
|
||||||
/* get physical termination */
|
if(NULL == term){
|
||||||
|
mg_util_set_err_string(&errTxt, " Resource Failure ");
|
||||||
|
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/* associate physical termination to context */
|
/* associate physical termination to context */
|
||||||
@ -654,21 +690,33 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy media descriptor */
|
/* copy media descriptor */
|
||||||
|
|
||||||
desc = rsp.u.mgCmdRsp[0]->u.add.audit.parms[rsp.u.mgCmdRsp[0]->u.add.audit.num.val-1];
|
desc = rsp.u.mgCmdRsp[0]->u.add.audit.parms[rsp.u.mgCmdRsp[0]->u.add.audit.num.val-1];
|
||||||
desc->type.pres = PRSNT_NODEF;
|
desc->type.pres = PRSNT_NODEF;
|
||||||
desc->type.val = MGT_MEDIADESC;
|
desc->type.val = MGT_MEDIADESC;
|
||||||
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
|
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
/* see if we have received local descriptor */
|
||||||
|
if((NOTPRSNT != desc->u.media.num.pres) &&
|
||||||
|
(0 != desc->u.media.num.val))
|
||||||
{
|
{
|
||||||
|
for(mediaId=0; mediaId<desc->u.media.num.val; mediaId++) {
|
||||||
|
if(MGT_MEDIAPAR_LOCAL == desc->u.media.parms[mediaId]->type.val) {
|
||||||
|
local = &desc->u.media.parms[mediaId]->u.local;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* only for RTP */
|
||||||
|
if(is_rtp){
|
||||||
/* build local descriptors */
|
/* build local descriptors */
|
||||||
/*MgMgcoStreamDesc *stream;*/
|
/*MgMgcoStreamDesc *stream;*/
|
||||||
MgMgcoLocalDesc *local;
|
char* ipAddress[4];// = "192.168.1.1";
|
||||||
CmSdpInfoSet *psdp;
|
char* dup = strdup((char*)term->u.rtp.local_addr);
|
||||||
char* ipAddress = "192.168.1.1";
|
|
||||||
MgMgcoMediaDesc* media = &desc->u.media;
|
MgMgcoMediaDesc* media = &desc->u.media;
|
||||||
|
|
||||||
|
switch_split(dup,'.',ipAddress);
|
||||||
|
|
||||||
/* Most probably we need to add local descriptor */
|
/* Most probably we need to add local descriptor */
|
||||||
|
if(!local){
|
||||||
|
|
||||||
/* allocating mem for local descriptor */
|
/* allocating mem for local descriptor */
|
||||||
if (mgUtlGrowList((void ***)&media->parms, sizeof(MgMgcoMediaPar),
|
if (mgUtlGrowList((void ***)&media->parms, sizeof(MgMgcoMediaPar),
|
||||||
@ -708,6 +756,7 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
media->parms[media->num.val-1]->type.val = MGT_MEDIAPAR_LOCAL;
|
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;
|
||||||
|
|
||||||
@ -746,13 +795,13 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.addrType),
|
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.addrType),
|
||||||
CM_SDP_IPV4_IP_UNI);
|
CM_SDP_IPV4_IP_UNI);
|
||||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[0]),
|
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[0]),
|
||||||
ipAddress[0]);
|
atoi(ipAddress[0]));
|
||||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]),
|
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]),
|
||||||
ipAddress[1]);
|
atoi(ipAddress[1]));
|
||||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]),
|
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]),
|
||||||
ipAddress[2]);
|
atoi(ipAddress[2]));
|
||||||
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]),
|
MG_SET_VAL_PRES( (psdp->info[psdp->numComp.val-1]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]),
|
||||||
ipAddress[3]);
|
atoi(ipAddress[3]));
|
||||||
|
|
||||||
/* fill session name */
|
/* fill session name */
|
||||||
/* TODO - need to fill proper session name or skip it..*/
|
/* TODO - need to fill proper session name or skip it..*/
|
||||||
@ -765,10 +814,11 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
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.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_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[0]), atoi(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[1]), atoi(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[2]), atoi(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[3]), atoi(ipAddress[3]));
|
||||||
|
|
||||||
|
|
||||||
/* t= line */
|
/* t= line */
|
||||||
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->sdpTime.pres),1);
|
MG_INIT_TOKEN_VALUE(&(psdp->info[psdp->numComp.val-1]->sdpTime.pres),1);
|
||||||
@ -801,7 +851,7 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.type),CM_SDP_PORT_INT);
|
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.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.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.u.port.u.portInt.port.val), term->u.rtp.local_port);
|
||||||
|
|
||||||
if (mgUtlGrowList((void ***)&media->field.par.pflst, sizeof(CmSdpMedProtoFmts),
|
if (mgUtlGrowList((void ***)&media->field.par.pflst, sizeof(CmSdpMedProtoFmts),
|
||||||
&media->field.par.numProtFmts, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
&media->field.par.numProtFmts, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
||||||
@ -837,11 +887,11 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
|||||||
}
|
}
|
||||||
|
|
||||||
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->type),CM_SDP_ATTR_PTIME);
|
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]->u.ptime), term->u.rtp.ptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(dup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1004,6 +1054,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
@ -15,6 +15,18 @@
|
|||||||
|
|
||||||
#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 */
|
||||||
|
|
||||||
|
/* 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,
|
||||||
|
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 +163,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);
|
||||||
|
@ -112,8 +112,6 @@ S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, C
|
|||||||
/*MG_GETMEM(termId->name.lcl.val, termId->name.lcl.len , memCp, ret);*/
|
/*MG_GETMEM(termId->name.lcl.val, termId->name.lcl.len , memCp, ret);*/
|
||||||
ret = mg_stack_alloc_mem((Ptr*)&termId->name.lcl.val,term_len);
|
ret = mg_stack_alloc_mem((Ptr*)&termId->name.lcl.val,term_len);
|
||||||
|
|
||||||
printf("termId->name.lcl.val[%p]\n",termId->name.lcl.val);
|
|
||||||
|
|
||||||
if( ret != ROK)
|
if( ret != ROK)
|
||||||
RETVALUE(ret);
|
RETVALUE(ret);
|
||||||
|
|
||||||
@ -121,7 +119,7 @@ S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, C
|
|||||||
strncpy((char*)(termId->name.lcl.val), term_str, termId->name.lcl.len);
|
strncpy((char*)(termId->name.lcl.val), term_str, termId->name.lcl.len);
|
||||||
termId->name.lcl.val[termId->name.lcl.len] = '\0';
|
termId->name.lcl.val[termId->name.lcl.len] = '\0';
|
||||||
|
|
||||||
printf("mg_fill_mgco_termid: name.lcl.val[%s], len[%d], term_str[%s], term_len[%d]\n",termId->name.lcl.val, termId->name.lcl.len, term_str,term_len);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"mg_fill_mgco_termid: name.lcl.val[%s], len[%d], term_str[%s], term_len[%d]\n",termId->name.lcl.val, termId->name.lcl.len, term_str,term_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -740,8 +738,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[32];
|
||||||
|
memset(ipadd, 0, sizeof(ipadd));
|
||||||
|
|
||||||
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 +761,19 @@ 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);
|
||||||
|
/* update remote ip */
|
||||||
|
if(MG_TERM_RTP == term->type){
|
||||||
|
term->u.rtp.remote_addr = switch_core_strdup(term->pool,ipadd);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"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");
|
||||||
@ -772,7 +786,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);
|
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;
|
int i=0x00;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n");
|
||||||
@ -815,6 +829,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s)
|
|||||||
|
|
||||||
for(i=0;i<r->num.val;i++){
|
for(i=0;i<r->num.val;i++){
|
||||||
mgco_print_CmSdpU8OrNil(r->fmts[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;
|
break;
|
||||||
@ -834,12 +854,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 +960,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 +1051,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:
|
||||||
@ -1048,7 +1077,7 @@ void mgco_print_sdp(CmSdpInfoSet *sdp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mgco_print_sdp_media_param(&f->par);
|
mgco_print_sdp_media_param(&f->par, term, sdp_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*info */
|
/*info */
|
||||||
@ -1061,7 +1090,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 +1107,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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,60 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||||||
|
|
||||||
profile->idx = ++mg_sap_id;
|
profile->idx = ++mg_sap_id;
|
||||||
|
|
||||||
|
|
||||||
|
if ((mg_phys_terms = switch_xml_child(mg_interface, "physical_terminations"))) {
|
||||||
|
for (mg_term = switch_xml_child(mg_phys_terms, "map"); mg_term; mg_term = mg_term->next) {
|
||||||
|
switch_memory_pool_t *pool;
|
||||||
|
mg_termination_t *term;
|
||||||
|
// <map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map"1-15,17-31"/>
|
||||||
|
const char *prefix = switch_xml_attr(mg_term, "termination-id-prefix");
|
||||||
|
//const char *sztermination_id_base = switch_xml_attr(mg_term, "termination-id-base");
|
||||||
|
//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");
|
||||||
|
|
||||||
|
|
||||||
|
if (!zstr(channel_map)) {
|
||||||
|
/* Split channel-map */
|
||||||
|
char *channel_map_dup = strdup(channel_map);
|
||||||
|
char *chanmap[24];
|
||||||
|
int chanmap_count, i;
|
||||||
|
chanmap_count = switch_split(channel_map_dup, ' ', chanmap);
|
||||||
|
for (i = 0; i < chanmap_count; i++) {
|
||||||
|
char *p = strchr(chanmap[i], '-');
|
||||||
|
if (p) {
|
||||||
|
int startchan, endchan, j;
|
||||||
|
*p++ = '\0';
|
||||||
|
startchan = atoi(chanmap[i]);
|
||||||
|
endchan = atoi(p);
|
||||||
|
|
||||||
|
for (j = startchan; j < endchan; j++) {
|
||||||
|
switch_core_new_memory_pool(&pool);
|
||||||
|
term = switch_core_alloc(profile->pool, sizeof *term);
|
||||||
|
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);
|
||||||
|
|
||||||
|
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: %s chan: %d\n", term->name, term->u.tdm.span_name, term->u.tdm.channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(channel_map_dup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* we should break from here , profile name should be unique */
|
/* we should break from here , profile name should be unique */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -113,59 +167,6 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((mg_phys_terms = switch_xml_child(cfg, "physical_terminations"))) {
|
|
||||||
|
|
||||||
for (mg_term = switch_xml_child(mg_phys_terms, "map"); mg_term; mg_term = mg_term->next) {
|
|
||||||
switch_memory_pool_t *pool;
|
|
||||||
mg_termination_t *term;
|
|
||||||
// <map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map"1-15,17-31"/>
|
|
||||||
const char *prefix = switch_xml_attr(mg_term, "termination-id-prefix");
|
|
||||||
//const char *sztermination_id_base = switch_xml_attr(mg_term, "termination-id-base");
|
|
||||||
//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)) {
|
|
||||||
/* Split channel-map */
|
|
||||||
char *channel_map_dup = strdup(channel_map);
|
|
||||||
char *chanmap[24];
|
|
||||||
int chanmap_count, i;
|
|
||||||
chanmap_count = switch_split(channel_map_dup, ' ', chanmap);
|
|
||||||
for (i = 0; i < chanmap_count; i++) {
|
|
||||||
char *p = strchr(chanmap[i], '-');
|
|
||||||
if (p) {
|
|
||||||
int startchan, endchan, j;
|
|
||||||
*p++ = '\0';
|
|
||||||
startchan = atoi(chanmap[i]);
|
|
||||||
endchan = atoi(p);
|
|
||||||
|
|
||||||
for (j = startchan; j < endchan; j++) {
|
|
||||||
switch_core_new_memory_pool(&pool);
|
|
||||||
term = switch_core_alloc(profile->pool, sizeof *term);
|
|
||||||
term->pool = pool;
|
|
||||||
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;
|
|
||||||
|
|
||||||
switch_core_hash_insert_wrlock(profile->terminations, term->name, term, profile->terminations_rwlock);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(channel_map_dup);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* configure the MEGACO stack */
|
/* configure the MEGACO stack */
|
||||||
status = sng_mgco_cfg(profile);
|
status = sng_mgco_cfg(profile);
|
||||||
|
|
||||||
|
@ -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");
|
||||||
|
|
||||||
|
@ -83,10 +83,25 @@ typedef struct mg_context_s mg_context_t;
|
|||||||
/* TDM parameters understood by the controllable channel */
|
/* TDM parameters understood by the controllable channel */
|
||||||
#define kSPAN_ID "span"
|
#define kSPAN_ID "span"
|
||||||
#define kCHAN_ID "chan"
|
#define kCHAN_ID "chan"
|
||||||
|
#define kSPAN_NAME "span_name"
|
||||||
|
|
||||||
|
|
||||||
typedef struct mg_termination_s mg_termination_t;
|
typedef struct mg_termination_s mg_termination_t;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MGT_ALLOCATED = (1 << 0),
|
||||||
|
MGT_ACTIVE = (1 << 1),
|
||||||
|
|
||||||
|
} 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 {
|
struct mg_termination_s {
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
mg_termination_type_t type;
|
mg_termination_type_t type;
|
||||||
@ -96,6 +111,8 @@ struct mg_termination_s {
|
|||||||
megaco_profile_t *profile; /*!< Parent MG profile */
|
megaco_profile_t *profile; /*!< Parent MG profile */
|
||||||
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
|
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
|
||||||
mg_termination_t *next; /*!< List for physical terminations */
|
mg_termination_t *next; /*!< List for physical terminations */
|
||||||
|
mg_context_t* mg_ctxt;
|
||||||
|
uint32_t flags;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
@ -116,20 +133,14 @@ struct mg_termination_s {
|
|||||||
} rtp;
|
} rtp;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int span;
|
|
||||||
int channel;
|
int channel;
|
||||||
|
const char *span_name;
|
||||||
} tdm;
|
} tdm;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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_CONTEXT_MODULO 16
|
||||||
#define MG_MAX_CONTEXTS 32768
|
#define MG_MAX_CONTEXTS 32768
|
||||||
@ -165,6 +176,9 @@ struct megaco_profile_s {
|
|||||||
|
|
||||||
uint8_t rtpid_bitmap[MG_MAX_CONTEXTS/8];
|
uint8_t rtpid_bitmap[MG_MAX_CONTEXTS/8];
|
||||||
uint32_t rtpid_next;
|
uint32_t rtpid_next;
|
||||||
|
|
||||||
|
mg_termination_t *physical_terminations;
|
||||||
|
|
||||||
switch_hash_t *terminations;
|
switch_hash_t *terminations;
|
||||||
switch_thread_rwlock_t *terminations_rwlock;
|
switch_thread_rwlock_t *terminations_rwlock;
|
||||||
};
|
};
|
||||||
@ -220,6 +234,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);
|
||||||
|
@ -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_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_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_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 = {
|
switch_state_handler_table_t crtp_state_handlers = {
|
||||||
.on_init = channel_on_init,
|
.on_init = channel_on_init,
|
||||||
@ -104,6 +105,7 @@ switch_io_routines_t crtp_io_routines = {
|
|||||||
.read_frame = channel_read_frame,
|
.read_frame = channel_read_frame,
|
||||||
.write_frame = channel_write_frame,
|
.write_frame = channel_write_frame,
|
||||||
.receive_message = channel_receive_message,
|
.receive_message = channel_receive_message,
|
||||||
|
.receive_event = channel_receive_event,
|
||||||
.send_dtmf = channel_send_dtmf
|
.send_dtmf = channel_send_dtmf
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -186,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||||||
tech_pvt->dtmf_type = DTMF_2833; /* XXX */
|
tech_pvt->dtmf_type = DTMF_2833; /* XXX */
|
||||||
|
|
||||||
if (zstr(local_addr) || local_port == 0) {
|
if (zstr(local_addr) || local_port == 0) {
|
||||||
tech_pvt->mode = RTP_SENDONLY;
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n");
|
||||||
|
goto fail;
|
||||||
} else if (zstr(remote_addr) || remote_port == 0) {
|
} else if (zstr(remote_addr) || remote_port == 0) {
|
||||||
tech_pvt->mode = RTP_SENDRECV;
|
tech_pvt->mode = RTP_RECVONLY;
|
||||||
} else {
|
} else {
|
||||||
|
tech_pvt->mode = RTP_SENDRECV;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_core_session_set_private(*new_session, tech_pvt);
|
switch_core_session_set_private(*new_session, tech_pvt);
|
||||||
@ -312,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) {
|
if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_SENDONLY) {
|
||||||
|
switch_yield(20000); /* replace by local timer XXX */
|
||||||
goto cng;
|
goto cng;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,6 +327,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||||||
}
|
}
|
||||||
|
|
||||||
tech_pvt->read_frame.flags = SFF_NONE;
|
tech_pvt->read_frame.flags = SFF_NONE;
|
||||||
|
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||||
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
|
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
|
||||||
|
|
||||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||||
@ -334,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;
|
||||||
|
|
||||||
@ -366,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);
|
||||||
|
|
||||||
@ -395,6 +404,68 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
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);
|
||||||
|
|
||||||
|
if (zstr(chan_val) || zstr(event_val)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
crtp_private_t *tech_pvt = switch_core_session_get_private(session);
|
||||||
|
|
||||||
|
if (!zstr(command) && !strcasecmp(command, "media_modify")) {
|
||||||
|
/* Compare parameters */
|
||||||
|
if (compare_var(event, channel, kREMOTEADDR) ||
|
||||||
|
compare_var(event, channel, kREMOTEPORT)) {
|
||||||
|
char *remote_addr = 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;
|
||||||
|
const char *err;
|
||||||
|
|
||||||
|
|
||||||
|
switch_channel_set_variable(channel, kREMOTEADDR, remote_addr);
|
||||||
|
switch_channel_set_variable(channel, kREMOTEPORT, szremote_port);
|
||||||
|
|
||||||
|
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, remote_addr, remote_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err);
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set RTP remote: %s:%d\n", remote_addr, (int)remote_port);
|
||||||
|
tech_pvt->mode = RTP_SENDRECV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compare_var(event, channel, kCODEC) ||
|
||||||
|
compare_var(event, channel, kPTIME) ||
|
||||||
|
compare_var(event, channel, kPT) ||
|
||||||
|
compare_var(event, channel, kRATE)) {
|
||||||
|
/* Reset codec */
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec not yet implemented\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compare_var(event, channel, kRFC2833PT)) {
|
||||||
|
const char *szpt = switch_channel_get_variable(channel, kRFC2833PT);
|
||||||
|
int pt = !zstr(szpt) ? atoi(szpt) : 0;
|
||||||
|
|
||||||
|
switch_channel_set_variable(channel, kRFC2833PT, szpt);
|
||||||
|
switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
||||||
{
|
{
|
||||||
crtp_private_t *tech_pvt = NULL;
|
crtp_private_t *tech_pvt = NULL;
|
||||||
|
@ -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;
|
||||||
|
@ -1451,7 +1451,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
|
|||||||
uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
|
uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_SRTP
|
#ifndef ENABLE_SRTP
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "SRTP NOT SUPPORTED IN THIS BUILD!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SRTP NOT SUPPORTED IN THIS BUILD!\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
#else
|
#else
|
||||||
switch_rtp_crypto_key_t *crypto_key;
|
switch_rtp_crypto_key_t *crypto_key;
|
||||||
@ -1832,6 +1832,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (zstr(tx_host)) {
|
if (zstr(tx_host)) {
|
||||||
*err = "Missing remote host";
|
*err = "Missing remote host";
|
||||||
goto end;
|
goto end;
|
||||||
@ -1841,6 +1842,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||||||
*err = "Missing remote port";
|
*err = "Missing remote port";
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (switch_rtp_create(&rtp_session, payload, samples_per_interval, ms_per_packet, flags, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
|
if (switch_rtp_create(&rtp_session, payload, samples_per_interval, ms_per_packet, flags, timer_name, err, pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
goto end;
|
goto end;
|
||||||
@ -1854,7 +1856,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, 0, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
|
if (!zstr(tx_host) && switch_rtp_set_remote_address(rtp_session, tx_host, tx_port, 0, SWITCH_TRUE, err) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_mutex_unlock(rtp_session->flag_mutex);
|
switch_mutex_unlock(rtp_session->flag_mutex);
|
||||||
rtp_session = NULL;
|
rtp_session = NULL;
|
||||||
goto end;
|
goto end;
|
||||||
@ -2161,7 +2163,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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user