mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-24 19:52:35 +00:00
add ringback to enterprise_originate
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15461 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
bd85ca8108
commit
ddc6612675
@ -1155,6 +1155,13 @@ typedef struct {
|
|||||||
} enterprise_originate_handle_t;
|
} enterprise_originate_handle_t;
|
||||||
|
|
||||||
|
|
||||||
|
struct ent_originate_ringback {
|
||||||
|
switch_core_session_t *session;
|
||||||
|
int running;
|
||||||
|
const char *ringback_data;
|
||||||
|
switch_thread_t *thread;
|
||||||
|
};
|
||||||
|
|
||||||
static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thread, void *obj)
|
static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thread, void *obj)
|
||||||
{
|
{
|
||||||
enterprise_originate_handle_t *handle = (enterprise_originate_handle_t *) obj;
|
enterprise_originate_handle_t *handle = (enterprise_originate_handle_t *) obj;
|
||||||
@ -1176,6 +1183,37 @@ static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thr
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *SWITCH_THREAD_FUNC enterprise_originate_ringback_thread(switch_thread_t *thread, void *obj)
|
||||||
|
{
|
||||||
|
struct ent_originate_ringback *rb_data = (struct ent_originate_ringback *) obj;
|
||||||
|
switch_core_session_t *session = rb_data->session;
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(rb_data->session);
|
||||||
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
|
switch_core_session_read_lock(session);
|
||||||
|
|
||||||
|
while(rb_data->running && switch_channel_ready(channel)) {
|
||||||
|
if (status != SWITCH_STATUS_BREAK) {
|
||||||
|
if (zstr(rb_data->ringback_data) || !strcasecmp(rb_data->ringback_data, "silence")) {
|
||||||
|
status = switch_ivr_collect_digits_callback(session, NULL, 0, 0);
|
||||||
|
} else if (switch_is_file_path(rb_data->ringback_data)) {
|
||||||
|
status = switch_ivr_play_file(session, NULL, rb_data->ringback_data, NULL);
|
||||||
|
} else {
|
||||||
|
status = switch_ivr_gentones(session, rb_data->ringback_data, 0, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == SWITCH_STATUS_BREAK) {
|
||||||
|
switch_channel_set_flag(channel, CF_NOT_READY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
|
||||||
|
rb_data->running = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_session_t *session,
|
SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_session_t *session,
|
||||||
switch_core_session_t **bleg,
|
switch_core_session_t **bleg,
|
||||||
switch_call_cause_t *cause,
|
switch_call_cause_t *cause,
|
||||||
@ -1202,6 +1240,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
|
|||||||
switch_status_t tstatus = SWITCH_STATUS_FALSE;
|
switch_status_t tstatus = SWITCH_STATUS_FALSE;
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
switch_event_header_t *hi = NULL;
|
switch_event_header_t *hi = NULL;
|
||||||
|
struct ent_originate_ringback rb_data = { 0 };
|
||||||
|
const char *ringback_data = NULL;
|
||||||
|
|
||||||
switch_core_new_memory_pool(&pool);
|
switch_core_new_memory_pool(&pool);
|
||||||
|
|
||||||
@ -1252,9 +1292,36 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
|
|||||||
switch_thread_create(&handles[i].thread, thd_attr, enterprise_originate_thread, &handles[i], pool);
|
switch_thread_create(&handles[i].thread, thd_attr, enterprise_originate_thread, &handles[i], pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channel && !switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||||
|
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||||
|
ringback_data = switch_channel_get_variable(channel, "transfer_ringback");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ringback_data) {
|
||||||
|
ringback_data = switch_channel_get_variable(channel, "ringback");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ringback_data || switch_channel_media_ready(channel)) {
|
||||||
|
rb_data.ringback_data = ringback_data;
|
||||||
|
rb_data.session = session;
|
||||||
|
rb_data.running = 1;
|
||||||
|
if (!switch_channel_media_ready(channel)) {
|
||||||
|
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch_thread_create(&rb_data.thread, thd_attr, enterprise_originate_ringback_thread, &rb_data, pool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
running = 0;
|
running = 0;
|
||||||
|
|
||||||
|
if (channel && !switch_channel_ready(channel)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < x_argc; i++) {
|
for(i = 0; i < x_argc; i++) {
|
||||||
if (handles[i].done == 0) {
|
if (handles[i].done == 0) {
|
||||||
running++;
|
running++;
|
||||||
@ -1274,8 +1341,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
if (channel && rb_data.thread) {
|
||||||
|
switch_channel_set_flag(channel, CF_NOT_READY);
|
||||||
|
switch_thread_join(&tstatus, rb_data.thread);
|
||||||
|
switch_channel_clear_flag(channel, CF_NOT_READY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < x_argc; i++) {
|
for(i = 0; i < x_argc; i++) {
|
||||||
if (hp && hp == &handles[i]) {
|
if (hp && hp == &handles[i]) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user