mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 16:58:35 +00:00
hack up the core with a butcher knife
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5314 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
40ce37c656
commit
efca0c8087
@ -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);
|
||||||
|
|
||||||
///\}
|
///\}
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
#define SWITCH_EVENT_HOOKS_H
|
#define SWITCH_EVENT_HOOKS_H
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
SWITCH_BEGIN_EXTERN_C typedef struct switch_io_event_hooks switch_io_event_hooks_t;
|
SWITCH_BEGIN_EXTERN_C
|
||||||
|
typedef struct switch_io_event_hooks switch_io_event_hooks_t;
|
||||||
|
|
||||||
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
|
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
|
||||||
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
|
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
|
||||||
@ -45,9 +46,8 @@ typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_chann
|
|||||||
typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read_t;
|
typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read_t;
|
||||||
typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write_t;
|
typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write_t;
|
||||||
typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t;
|
typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t;
|
||||||
|
typedef struct switch_io_event_hook_recv_dtmf switch_io_event_hook_recv_dtmf_t;
|
||||||
typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
|
typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
|
||||||
|
|
||||||
|
|
||||||
typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
|
typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
|
||||||
typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
|
typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
|
||||||
typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
|
typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
|
||||||
@ -58,24 +58,24 @@ typedef switch_status_t (*switch_video_write_frame_hook_t) (switch_core_session_
|
|||||||
typedef switch_status_t (*switch_kill_channel_hook_t) (switch_core_session_t *, int);
|
typedef switch_status_t (*switch_kill_channel_hook_t) (switch_core_session_t *, int);
|
||||||
typedef switch_status_t (*switch_waitfor_read_hook_t) (switch_core_session_t *, int, int);
|
typedef switch_status_t (*switch_waitfor_read_hook_t) (switch_core_session_t *, int, int);
|
||||||
typedef switch_status_t (*switch_waitfor_write_hook_t) (switch_core_session_t *, int, int);
|
typedef switch_status_t (*switch_waitfor_write_hook_t) (switch_core_session_t *, int, int);
|
||||||
typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, char *);
|
typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, const char *);
|
||||||
|
typedef switch_status_t (*switch_recv_dtmf_hook_t) (switch_core_session_t *, const char *);
|
||||||
typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *);
|
typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *);
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Node in which to store custom outgoing channel callback hooks */
|
/*! \brief Node in which to store custom receive message callback hooks */
|
||||||
struct switch_io_event_hook_outgoing_channel {
|
struct switch_io_event_hook_outgoing_channel {
|
||||||
/*! the outgoing channel callback hook */
|
|
||||||
switch_outgoing_channel_hook_t outgoing_channel;
|
switch_outgoing_channel_hook_t outgoing_channel;
|
||||||
struct switch_io_event_hook_outgoing_channel *next;
|
struct switch_io_event_hook_outgoing_channel *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \brief Node in which to store custom receive message callback hooks */
|
/*! \brief Node in which to store custom receive message callback hooks */
|
||||||
struct switch_io_event_hook_receive_message {
|
struct switch_io_event_hook_receive_message {
|
||||||
/*! the message callback hook */
|
|
||||||
switch_receive_message_hook_t receive_message;
|
switch_receive_message_hook_t receive_message;
|
||||||
struct switch_io_event_hook_receive_message *next;
|
struct switch_io_event_hook_receive_message *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Node in which to store custom receive message callback hooks */
|
/*! \brief Node in which to store custom receive message callback hooks */
|
||||||
struct switch_io_event_hook_receive_event {
|
struct switch_io_event_hook_receive_event {
|
||||||
/*! the event callback hook */
|
/*! the event callback hook */
|
||||||
@ -139,9 +139,16 @@ struct switch_io_event_hook_send_dtmf {
|
|||||||
struct switch_io_event_hook_send_dtmf *next;
|
struct switch_io_event_hook_send_dtmf *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*! \brief Node in which to store custom recv dtmf channel callback hooks */
|
||||||
|
struct switch_io_event_hook_recv_dtmf {
|
||||||
|
/*! the recv dtmf channel callback hook */
|
||||||
|
switch_recv_dtmf_hook_t recv_dtmf;
|
||||||
|
struct switch_io_event_hook_recv_dtmf *next;
|
||||||
|
};
|
||||||
|
|
||||||
/*! \brief Node in which to store state change callback hooks */
|
/*! \brief Node in which to store state change callback hooks */
|
||||||
struct switch_io_event_hook_state_change {
|
struct switch_io_event_hook_state_change {
|
||||||
/*! the send dtmf channel callback hook */
|
/*! the state change channel callback hook */
|
||||||
switch_state_change_hook_t state_change;
|
switch_state_change_hook_t state_change;
|
||||||
struct switch_io_event_hook_state_change *next;
|
struct switch_io_event_hook_state_change *next;
|
||||||
};
|
};
|
||||||
@ -170,106 +177,82 @@ struct switch_io_event_hooks {
|
|||||||
switch_io_event_hook_waitfor_write_t *waitfor_write;
|
switch_io_event_hook_waitfor_write_t *waitfor_write;
|
||||||
/*! a list of send dtmf hooks */
|
/*! a list of send dtmf hooks */
|
||||||
switch_io_event_hook_send_dtmf_t *send_dtmf;
|
switch_io_event_hook_send_dtmf_t *send_dtmf;
|
||||||
|
/*! a list of recv dtmf hooks */
|
||||||
|
switch_io_event_hook_recv_dtmf_t *recv_dtmf;
|
||||||
/*! a list of state change hooks */
|
/*! a list of state change hooks */
|
||||||
switch_io_event_hook_state_change_t *state_change;
|
switch_io_event_hook_state_change_t *state_change;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session);
|
extern switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session);
|
||||||
|
|
||||||
|
#define NEW_HOOK_DECL_ADD_P(_NAME) SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_##_NAME \
|
||||||
|
(switch_core_session_t *session, switch_##_NAME##_hook_t _NAME)
|
||||||
|
|
||||||
|
#define NEW_HOOK_DECL_REM_P(_NAME) SWITCH_DECLARE(switch_status_t) switch_core_event_hook_remove_##_NAME \
|
||||||
|
(switch_core_session_t *session, switch_##_NAME##_hook_t _NAME)
|
||||||
|
|
||||||
|
#define NEW_HOOK_DECL(_NAME) NEW_HOOK_DECL_ADD_P(_NAME) \
|
||||||
|
{ \
|
||||||
|
switch_io_event_hook_##_NAME##_t *hook, *ptr; \
|
||||||
|
assert(_NAME != NULL); \
|
||||||
|
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) { \
|
||||||
|
hook->_NAME = _NAME ; \
|
||||||
|
if (! session->event_hooks._NAME ) { \
|
||||||
|
session->event_hooks._NAME = hook; \
|
||||||
|
} else { \
|
||||||
|
for (ptr = session->event_hooks._NAME; ptr && ptr->next; ptr = ptr->next); \
|
||||||
|
ptr->next = hook; \
|
||||||
|
} \
|
||||||
|
return SWITCH_STATUS_SUCCESS; \
|
||||||
|
} \
|
||||||
|
return SWITCH_STATUS_MEMERR; \
|
||||||
|
} \
|
||||||
|
NEW_HOOK_DECL_REM_P(_NAME) \
|
||||||
|
{ \
|
||||||
|
switch_io_event_hook_##_NAME##_t *ptr, *last = NULL; \
|
||||||
|
assert(_NAME != NULL); \
|
||||||
|
for (ptr = session->event_hooks._NAME; ptr; ptr = ptr->next) { \
|
||||||
|
if (ptr->_NAME == _NAME) { \
|
||||||
|
if (last) { \
|
||||||
|
last->next = ptr->next; \
|
||||||
|
} else { \
|
||||||
|
session->event_hooks._NAME = ptr->next; \
|
||||||
|
} \
|
||||||
|
return SWITCH_STATUS_SUCCESS; \
|
||||||
|
} \
|
||||||
|
last = ptr; \
|
||||||
|
} \
|
||||||
|
return SWITCH_STATUS_FALSE; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///\defgroup shooks Session Hook Callbacks
|
NEW_HOOK_DECL_ADD_P(outgoing_channel);
|
||||||
///\ingroup core1
|
NEW_HOOK_DECL_ADD_P(receive_message);
|
||||||
///\{
|
NEW_HOOK_DECL_ADD_P(receive_event);
|
||||||
|
NEW_HOOK_DECL_ADD_P(state_change);
|
||||||
|
NEW_HOOK_DECL_ADD_P(read_frame);
|
||||||
|
NEW_HOOK_DECL_ADD_P(write_frame);
|
||||||
|
NEW_HOOK_DECL_ADD_P(video_read_frame);
|
||||||
|
NEW_HOOK_DECL_ADD_P(video_write_frame);
|
||||||
|
NEW_HOOK_DECL_ADD_P(kill_channel);
|
||||||
|
NEW_HOOK_DECL_ADD_P(waitfor_read);
|
||||||
|
NEW_HOOK_DECL_ADD_P(waitfor_write);
|
||||||
|
NEW_HOOK_DECL_ADD_P(send_dtmf);
|
||||||
|
NEW_HOOK_DECL_ADD_P(recv_dtmf);
|
||||||
|
|
||||||
/*!
|
NEW_HOOK_DECL_REM_P(outgoing_channel);
|
||||||
\brief Add an event hook to be executed when a session requests an outgoing extension
|
NEW_HOOK_DECL_REM_P(receive_message);
|
||||||
\param session session to bind hook to
|
NEW_HOOK_DECL_REM_P(receive_event);
|
||||||
\param outgoing_channel hook to bind
|
NEW_HOOK_DECL_REM_P(state_change);
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
NEW_HOOK_DECL_REM_P(read_frame);
|
||||||
*/
|
NEW_HOOK_DECL_REM_P(write_frame);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing_channel(switch_core_session_t *session,
|
NEW_HOOK_DECL_REM_P(video_read_frame);
|
||||||
switch_outgoing_channel_hook_t outgoing_channel);
|
NEW_HOOK_DECL_REM_P(video_write_frame);
|
||||||
|
NEW_HOOK_DECL_REM_P(kill_channel);
|
||||||
/*!
|
NEW_HOOK_DECL_REM_P(waitfor_read);
|
||||||
\brief Add an event hook to be executed when a session sends a message
|
NEW_HOOK_DECL_REM_P(waitfor_write);
|
||||||
\param session session to bind hook to
|
NEW_HOOK_DECL_REM_P(send_dtmf);
|
||||||
\param receive_message hook to bind
|
NEW_HOOK_DECL_REM_P(recv_dtmf);
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_receive_message(switch_core_session_t *session, switch_receive_message_hook_t receive_message);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session reads a frame
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param read_frame hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_read_frame(switch_core_session_t *session, switch_read_frame_hook_t read_frame);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session reads a frame
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param video_read_frame hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_video_read_frame(switch_core_session_t *session, switch_read_frame_hook_t video_read_frame);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session writes a frame
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param write_frame hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_write_frame(switch_core_session_t *session, switch_write_frame_hook_t write_frame);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session writes a video frame
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param video_write_frame hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session kills a channel
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param kill_channel hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_kill_channel(switch_core_session_t *session, switch_kill_channel_hook_t kill_channel);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session waits for a read event
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param waitfor_read hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_waitfor_read(switch_core_session_t *session, switch_waitfor_read_hook_t waitfor_read);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session waits for a write event
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param waitfor_write hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_waitfor_write(switch_core_session_t *session, switch_waitfor_write_hook_t waitfor_write);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session sends dtmf
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param send_dtmf hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_send_dtmf(switch_core_session_t *session, switch_send_dtmf_hook_t send_dtmf);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Add an event hook to be executed when a session receives a state change signal
|
|
||||||
\param session session to bind hook to
|
|
||||||
\param state_change hook to bind
|
|
||||||
\return SWITCH_STATUS_SUCCESS on suceess
|
|
||||||
*/
|
|
||||||
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_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
|
@ -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
|
|||||||
|
|
||||||
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
|
|||||||
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 @@
|
|||||||
#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;
|
|
||||||
|
|
||||||
assert(outgoing_channel != NULL);
|
NEW_HOOK_DECL(outgoing_channel)
|
||||||
if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
|
NEW_HOOK_DECL(receive_message)
|
||||||
hook->outgoing_channel = outgoing_channel;
|
NEW_HOOK_DECL(receive_event)
|
||||||
if (!session->event_hooks.outgoing_channel) {
|
NEW_HOOK_DECL(state_change)
|
||||||
session->event_hooks.outgoing_channel = hook;
|
NEW_HOOK_DECL(read_frame)
|
||||||
} else {
|
NEW_HOOK_DECL(write_frame)
|
||||||
for (ptr = session->event_hooks.outgoing_channel; ptr && ptr->next; ptr = ptr->next);
|
NEW_HOOK_DECL(video_read_frame)
|
||||||
ptr->next = hook;
|
NEW_HOOK_DECL(video_write_frame)
|
||||||
|
NEW_HOOK_DECL(kill_channel)
|
||||||
}
|
NEW_HOOK_DECL(waitfor_read)
|
||||||
|
NEW_HOOK_DECL(waitfor_write)
|
||||||
return SWITCH_STATUS_SUCCESS;
|
NEW_HOOK_DECL(send_dtmf)
|
||||||
}
|
NEW_HOOK_DECL(recv_dtmf)
|
||||||
|
|
||||||
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
|
|||||||
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
|
|||||||
} 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
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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_
|
|||||||
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)
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user