mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-02 11:19:28 +00:00
wanpipe tweak
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@911 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
2f610e05b8
commit
94bbb8e46b
@ -456,7 +456,7 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
} else {
|
||||
span = 1;
|
||||
span = 0;
|
||||
autospan = 1;
|
||||
}
|
||||
num = p;
|
||||
@ -482,8 +482,7 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "WanPipe/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
switch_channel_set_caller_profile(channel, caller_profile);
|
||||
tech_pvt->caller_profile = caller_profile;
|
||||
|
||||
@ -504,7 +503,10 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
if ((spri = &SPANS[span]->spri)) {
|
||||
if (autospan) {
|
||||
span++;
|
||||
}
|
||||
if ((spri = &SPANS[span]->spri) && switch_test_flag(spri, SANGOMA_PRI_READY)) {
|
||||
chanmap = spri->private_info;
|
||||
if (channo == 0) {
|
||||
if (autochan > 0) {
|
||||
@ -534,7 +536,6 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||
}
|
||||
} while(autospan && span < MAX_SPANS && !spri && !channo);
|
||||
|
||||
|
||||
if (!spri || channo == 0 || channo == (SANGOMA_MAX_CHAN_PER_SPAN)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Free Channels!\n");
|
||||
switch_core_session_destroy(new_session);
|
||||
@ -543,7 +544,9 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||
|
||||
if (spri && (tech_pvt->call = pri_new_call(spri->pri))) {
|
||||
struct pri_sr *sr;
|
||||
|
||||
|
||||
snprintf(name, sizeof(name), "WanPipe/s%dc%d/%s-%04x", spri->span, channo, caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
sr = pri_sr_new();
|
||||
pri_sr_set_channel(sr, channo, 0, 0);
|
||||
pri_sr_set_bearer(sr, 0, SPANS[span]->l1);
|
||||
@ -1164,9 +1167,32 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_dchan_up(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
|
||||
{
|
||||
|
||||
if (!switch_test_flag(spri, SANGOMA_PRI_READY)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Span %d D-Chan UP!\n", spri->span);
|
||||
switch_set_flag(spri, SANGOMA_PRI_READY);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_dchan_down(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
|
||||
{
|
||||
|
||||
if (switch_test_flag(spri, SANGOMA_PRI_READY)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Span %d D-Chan DOWN!\n", spri->span);
|
||||
switch_clear_flag(spri, SANGOMA_PRI_READY);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Caught Event %d (%s)\n", event_type,
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Caught Event span %d %d (%s)\n", spri->span, event_type,
|
||||
sangoma_pri_event_str(event_type));
|
||||
return 0;
|
||||
}
|
||||
@ -1184,6 +1210,8 @@ static void *pri_thread_run(switch_thread *thread, void *obj)
|
||||
//SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_SETUP_ACK, on_proceed);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_PROCEEDING, on_proceed);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_ANSWER, on_answer);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_DCHAN_UP, on_dchan_up);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_DCHAN_DOWN, on_dchan_down);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_HANGUP_REQ, on_hangup);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_HANGUP, on_hangup);
|
||||
SANGOMA_MAP_PRI_EVENT((*spri), SANGOMA_PRI_EVENT_INFO_RECEIVED, on_info);
|
||||
|
@ -923,13 +923,14 @@ SWITCH_DECLARE(switch_status) switch_ivr_multi_threaded_bridge(switch_core_sessi
|
||||
!switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA) &&
|
||||
((time(NULL) - start) < timelimit)) {
|
||||
|
||||
|
||||
|
||||
/* read from the channel while we wait if the audio is up on it */
|
||||
if (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
|
||||
if (switch_core_session_read_frame(session, &read_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
if (switch_core_session_write_frame(session, read_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch_yield(1000);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user