use span name instead of id. implement termination choose for tdm.

This commit is contained in:
Mathieu Rene committed 2012-07-25 17:18:18 -04:00
1 parent 828a13733b
commit 6cf298a746
4 files changed
+43 -9

No files matched your search

+12 -2
View File
@@ -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;
@@ -97,7 +98,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
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);
*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 +113,22 @@ 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(szspanid) && 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 (!span_id) {
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");
}
}
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");