提交 efca0c80 authored 作者: Anthony Minessale's avatar Anthony Minessale

hack up the core with a butcher knife

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5314 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 40ce37c6
...@@ -789,7 +789,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_se ...@@ -789,7 +789,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_se
\param dtmf string to send to the session \param dtmf string to send to the session
\return SWITCH_STATUS_SUCCESS if the dtmf was written \return SWITCH_STATUS_SUCCESS if the dtmf was written
*/ */
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, char *dtmf); SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, const char *dtmf);
/*!
\brief RECV DTMF on a session
\param session session to recv DTMF from
\param dtmf string to recv from the session
\return SWITCH_STATUS_SUCCESS if the dtmf is ok to queue
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_session_t *session, const char *dtmf);
///\} ///\}
......
...@@ -136,11 +136,6 @@ static void event_handler(switch_event_t *event) ...@@ -136,11 +136,6 @@ static void event_handler(switch_event_t *event)
if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) { if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
send = 1; send = 1;
} }
} else {
int x;
for(x = 0; x <= SWITCH_EVENT_ALL; x++) {
printf("%d ", l->event_list[x]);
}
} }
if (send && switch_test_flag(l, LFLAG_MYEVENTS)) { if (send && switch_test_flag(l, LFLAG_MYEVENTS)) {
......
...@@ -208,7 +208,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan ...@@ -208,7 +208,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan
assert(channel != NULL); assert(channel != NULL);
switch_mutex_lock(channel->dtmf_mutex); switch_mutex_lock(channel->dtmf_mutex);
if ((status = switch_core_session_recv_dtmf(channel->session, dtmf) != SWITCH_STATUS_SUCCESS)) {
goto done;
}
inuse = switch_buffer_inuse(channel->dtmf_buffer); inuse = switch_buffer_inuse(channel->dtmf_buffer);
len = strlen(dtmf); len = strlen(dtmf);
...@@ -227,6 +231,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan ...@@ -227,6 +231,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_queue_dtmf(switch_channel_t *chan
p++; p++;
} }
status = switch_buffer_write(channel->dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR; status = switch_buffer_write(channel->dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR;
done:
switch_mutex_unlock(channel->dtmf_mutex); switch_mutex_unlock(channel->dtmf_mutex);
return status; return status;
......
...@@ -31,222 +31,18 @@ ...@@ -31,222 +31,18 @@
#include "switch.h" #include "switch.h"
#include "private/switch_core_pvt.h" #include "private/switch_core_pvt.h"
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing(switch_core_session_t *session, switch_outgoing_channel_hook_t outgoing_channel)
{
switch_io_event_hook_outgoing_channel_t *hook, *ptr; NEW_HOOK_DECL(outgoing_channel)
NEW_HOOK_DECL(receive_message)
assert(outgoing_channel != NULL); NEW_HOOK_DECL(receive_event)
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) { NEW_HOOK_DECL(state_change)
hook->outgoing_channel = outgoing_channel; NEW_HOOK_DECL(read_frame)
if (!session->event_hooks.outgoing_channel) { NEW_HOOK_DECL(write_frame)
session->event_hooks.outgoing_channel = hook; NEW_HOOK_DECL(video_read_frame)
} else { NEW_HOOK_DECL(video_write_frame)
for (ptr = session->event_hooks.outgoing_channel; ptr && ptr->next; ptr = ptr->next); NEW_HOOK_DECL(kill_channel)
ptr->next = hook; NEW_HOOK_DECL(waitfor_read)
NEW_HOOK_DECL(waitfor_write)
} NEW_HOOK_DECL(send_dtmf)
NEW_HOOK_DECL(recv_dtmf)
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_state_change(switch_core_session_t *session, switch_state_change_hook_t state_change)
{
switch_io_event_hook_state_change_t *hook, *ptr;
assert(state_change != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->state_change = state_change;
if (!session->event_hooks.state_change) {
session->event_hooks.state_change = hook;
} else {
for (ptr = session->event_hooks.state_change; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_read_frame(switch_core_session_t *session, switch_read_frame_hook_t read_frame)
{
switch_io_event_hook_read_frame_t *hook, *ptr;
assert(read_frame != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->read_frame = read_frame;
if (!session->event_hooks.read_frame) {
session->event_hooks.read_frame = hook;
} else {
for (ptr = session->event_hooks.read_frame; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_write_frame(switch_core_session_t *session, switch_write_frame_hook_t write_frame)
{
switch_io_event_hook_write_frame_t *hook, *ptr;
assert(write_frame != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->write_frame = write_frame;
if (!session->event_hooks.write_frame) {
session->event_hooks.write_frame = hook;
} else {
for (ptr = session->event_hooks.write_frame; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_video_read_frame(switch_core_session_t *session, switch_video_read_frame_hook_t video_read_frame)
{
switch_io_event_hook_video_read_frame_t *hook, *ptr;
assert(video_read_frame != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->video_read_frame = video_read_frame;
if (!session->event_hooks.video_read_frame) {
session->event_hooks.video_read_frame = hook;
} else {
for (ptr = session->event_hooks.video_read_frame; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_video_write_frame(switch_core_session_t *session, switch_video_write_frame_hook_t video_write_frame)
{
switch_io_event_hook_video_write_frame_t *hook, *ptr;
assert(video_write_frame != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->video_write_frame = video_write_frame;
if (!session->event_hooks.video_write_frame) {
session->event_hooks.video_write_frame = hook;
} else {
for (ptr = session->event_hooks.video_write_frame; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_kill_channel(switch_core_session_t *session, switch_kill_channel_hook_t kill_channel)
{
switch_io_event_hook_kill_channel_t *hook, *ptr;
assert(kill_channel != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->kill_channel = kill_channel;
if (!session->event_hooks.kill_channel) {
session->event_hooks.kill_channel = hook;
} else {
for (ptr = session->event_hooks.kill_channel; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_waitfor_read(switch_core_session_t *session, switch_waitfor_read_hook_t waitfor_read)
{
switch_io_event_hook_waitfor_read_t *hook, *ptr;
assert(waitfor_read != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->waitfor_read = waitfor_read;
if (!session->event_hooks.waitfor_read) {
session->event_hooks.waitfor_read = hook;
} else {
for (ptr = session->event_hooks.waitfor_read; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_waitfor_write(switch_core_session_t *session, switch_waitfor_write_hook_t waitfor_write)
{
switch_io_event_hook_waitfor_write_t *hook, *ptr;
assert(waitfor_write != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->waitfor_write = waitfor_write;
if (!session->event_hooks.waitfor_write) {
session->event_hooks.waitfor_write = hook;
} else {
for (ptr = session->event_hooks.waitfor_write; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_send_dtmf(switch_core_session_t *session, switch_send_dtmf_hook_t send_dtmf)
{
switch_io_event_hook_send_dtmf_t *hook, *ptr;
assert(send_dtmf != NULL);
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
hook->send_dtmf = send_dtmf;
if (!session->event_hooks.send_dtmf) {
session->event_hooks.send_dtmf = hook;
} else {
for (ptr = session->event_hooks.send_dtmf; ptr && ptr->next; ptr = ptr->next);
ptr->next = hook;
}
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
}
...@@ -464,7 +464,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess ...@@ -464,7 +464,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
session->write_resampler->from_len = write_frame->datalen / 2; session->write_resampler->from_len = write_frame->datalen / 2;
switch_short_to_float(data, session->write_resampler->from, session->write_resampler->from_len); switch_short_to_float(data, session->write_resampler->from, session->write_resampler->from_len);
session->write_resampler->to_len = (uint32_t) session->write_resampler->to_len = (uint32_t)
switch_resample_process(session->write_resampler, session->write_resampler->from, switch_resample_process(session->write_resampler, session->write_resampler->from,
...@@ -497,7 +497,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess ...@@ -497,7 +497,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
} else if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) { } else if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
do_bugs = 0; do_bugs = 0;
if (bp->callback) { if (bp->callback) {
bp->replace_frame_in = frame; bp->replace_frame_in = write_frame;
bp->replace_frame_out = NULL; bp->replace_frame_out = NULL;
if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE_REPLACE)) == SWITCH_TRUE) { if ((ok = bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_WRITE_REPLACE)) == SWITCH_TRUE) {
write_frame = bp->replace_frame_out; write_frame = bp->replace_frame_out;
...@@ -790,14 +790,34 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_se ...@@ -790,14 +790,34 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_waitfor_write(switch_core_se
} }
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, char *dtmf) SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_session_t *session, const char *dtmf)
{
switch_io_event_hook_recv_dtmf_t *ptr;
switch_status_t status;
for (ptr = session->event_hooks.recv_dtmf; ptr; ptr = ptr->next) {
if ((status = ptr->recv_dtmf(session, dtmf)) != SWITCH_STATUS_SUCCESS) {
return status;
}
}
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_session_t *session, const char *dtmf)
{ {
switch_io_event_hook_send_dtmf_t *ptr; switch_io_event_hook_send_dtmf_t *ptr;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
for (ptr = session->event_hooks.send_dtmf; ptr; ptr = ptr->next) {
if ((status = ptr->send_dtmf(session, dtmf)) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_SUCCESS;
}
}
if (session->endpoint_interface->io_routines->send_dtmf) { if (session->endpoint_interface->io_routines->send_dtmf) {
if (strchr(dtmf, 'w') || strchr(dtmf, 'W')) { if (strchr(dtmf, 'w') || strchr(dtmf, 'W')) {
char *d; const char *d;
for (d = dtmf; d && *d; d++) { for (d = dtmf; d && *d; d++) {
char digit[2] = { 0 }; char digit[2] = { 0 };
...@@ -815,16 +835,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio ...@@ -815,16 +835,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio
} }
} }
} else { } else {
status = session->endpoint_interface->io_routines->send_dtmf(session, dtmf); status = session->endpoint_interface->io_routines->send_dtmf(session, (char *)dtmf);
} }
if (status == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.send_dtmf; ptr; ptr = ptr->next) {
if ((status = ptr->send_dtmf(session, dtmf)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
}
} }
return status; return status;
......
...@@ -871,6 +871,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_ ...@@ -871,6 +871,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
context = new_profile->context; context = new_profile->context;
} }
if (switch_strlen_zero(context)) {
context = "default";
}
if (switch_strlen_zero(dialplan)) {
context = "XML";
}
switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL); switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL);
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
......
...@@ -120,7 +120,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj) ...@@ -120,7 +120,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
char dtmf[128]; char dtmf[128];
switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf)); switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf));
switch_core_session_send_dtmf(session_b, dtmf); switch_core_session_send_dtmf(session_b, dtmf);
if (input_callback) { if (input_callback) {
if (input_callback(session_a, dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0) != SWITCH_STATUS_SUCCESS) { if (input_callback(session_a, dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a));
...@@ -526,13 +525,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses ...@@ -526,13 +525,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid)); switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid));
b_leg->stream_id = stream_id; b_leg->stream_id = stream_id;
b_leg->input_callback = input_callback; b_leg->input_callback = input_callback;
b_leg->session_data = session_data; b_leg->session_data = peer_session_data;
a_leg->session = session; a_leg->session = session;
switch_copy_string(a_leg->b_uuid, switch_core_session_get_uuid(peer_session), sizeof(a_leg->b_uuid)); switch_copy_string(a_leg->b_uuid, switch_core_session_get_uuid(peer_session), sizeof(a_leg->b_uuid));
b_leg->stream_id = stream_id; a_leg->stream_id = stream_id;
b_leg->input_callback = input_callback; a_leg->input_callback = input_callback;
b_leg->session_data = peer_session_data; a_leg->session_data = session_data;
switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers); switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
...@@ -543,6 +542,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses ...@@ -543,6 +542,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) { if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
switch_event_t *event; switch_event_t *event;
switch_core_session_message_t msg = { 0 }; switch_core_session_message_t msg = { 0 };
const switch_application_interface_t *application_interface;
char *app, *data;
switch_channel_set_state(peer_channel, CS_HOLD); switch_channel_set_state(peer_channel, CS_HOLD);
...@@ -555,6 +556,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses ...@@ -555,6 +556,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session)); switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session)); switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_app"))) {
data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_aleg_data");
if ((application_interface = switch_loadable_module_get_application_interface(app))) {
switch_core_session_exec(session, application_interface, data);
}
}
if ((app = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_app"))) {
data = switch_channel_get_variable(caller_channel, "bridge_pre_execute_bleg_data");
if ((application_interface = switch_loadable_module_get_application_interface(app))) {
switch_core_session_exec(peer_session, application_interface, data);
}
}
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE; msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
msg.from = __FILE__; msg.from = __FILE__;
msg.string_arg = switch_core_session_strdup(peer_session, switch_core_session_get_uuid(session)); msg.string_arg = switch_core_session_strdup(peer_session, switch_core_session_get_uuid(session));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论