31 #ifndef SWITCH_EVENT_HOOKS_H 32 #define SWITCH_EVENT_HOOKS_H 198 #define NEW_HOOK_DECL_ADD_P(_NAME) SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_##_NAME \ 199 (switch_core_session_t *session, switch_##_NAME##_hook_t _NAME) 201 #define NEW_HOOK_DECL_REM_P(_NAME) SWITCH_DECLARE(switch_status_t) switch_core_event_hook_remove_##_NAME \ 202 (switch_core_session_t *session, switch_##_NAME##_hook_t _NAME) 204 #define NEW_HOOK_DECL(_NAME) NEW_HOOK_DECL_ADD_P(_NAME) \ 206 switch_io_event_hook_##_NAME##_t *hook, *ptr; \ 207 assert(_NAME != NULL); \ 208 for (ptr = session->event_hooks._NAME; ptr && ptr->next; ptr = ptr->next) \ 209 if (ptr->_NAME == _NAME) return SWITCH_STATUS_FALSE; \ 210 if (ptr && ptr->_NAME == _NAME) return SWITCH_STATUS_FALSE; \ 211 if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) { \ 212 hook->_NAME = _NAME ; \ 213 if (! session->event_hooks._NAME ) { \ 214 session->event_hooks._NAME = hook; \ 216 switch_assert(ptr); \ 219 return SWITCH_STATUS_SUCCESS; \ 221 return SWITCH_STATUS_MEMERR; \ 223 NEW_HOOK_DECL_REM_P(_NAME) \ 225 switch_io_event_hook_##_NAME##_t *ptr, *last = NULL; \ 226 assert(_NAME != NULL); \ 227 for (ptr = session->event_hooks._NAME; ptr; ptr = ptr->next) { \ 228 if (ptr->_NAME == _NAME) { \ 230 last->next = ptr->next; \ 232 session->event_hooks._NAME = ptr->next; \ 234 return SWITCH_STATUS_SUCCESS; \ 238 return SWITCH_STATUS_FALSE; \ switch_status_t(* switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t)
switch_status_t(* switch_video_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int)
switch_send_dtmf_hook_t send_dtmf
struct switch_io_event_hook_outgoing_channel * next
switch_status_t(* switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int)
struct switch_io_event_hook_text_write_frame * next
uint32_t switch_io_flag_t
switch_video_write_frame_hook_t text_write_frame
#define SWITCH_END_EXTERN_C
switch_read_frame_hook_t video_read_frame
switch_read_frame_hook_t read_frame
switch_io_event_hook_text_write_frame_t * text_write_frame
Node in which to store state change callback hooks.
struct switch_io_event_hook_send_dtmf * next
Node in which to store custom receive message callback hooks.
switch_kill_channel_hook_t kill_channel
Node in which to store custom video_write_frame channel callback hooks.
switch_status_t(* switch_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int)
struct switch_io_event_hook_receive_event * next
Representation of an event.
Node in which to store custom read frame channel callback hooks.
switch_read_frame_hook_t text_read_frame
switch_status_t(* switch_text_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int)
struct switch_io_event_hook_video_read_frame * next
switch_status_t(* switch_kill_channel_hook_t)(switch_core_session_t *, int)
Node in which to store custom read frame channel callback hooks.
switch_receive_event_hook_t receive_event
switch_video_write_frame_hook_t video_write_frame
struct switch_io_event_hook_read_frame * next
struct switch_io_event_hook_video_write_frame * next
uint32_t switch_originate_flag_t
struct switch_io_event_hook_state_run * next
switch_status_t(* switch_state_change_hook_t)(switch_core_session_t *)
Node in which to store custom receive message callback hooks.
A message object designed to allow unlike technologies to exchange data.
Node in which to store custom write_frame channel callback hooks.
switch_io_event_hook_write_frame_t * write_frame
struct switch_io_event_hook_text_read_frame * next
switch_receive_message_hook_t receive_message
switch_write_frame_hook_t write_frame
switch_status_t(* switch_receive_event_hook_t)(switch_core_session_t *, switch_event_t *)
switch_recv_dtmf_hook_t recv_dtmf
switch_status_t(* switch_receive_message_hook_t)(switch_core_session_t *, switch_core_session_message_t *)
switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session)
switch_io_event_hook_text_read_frame_t * text_read_frame
switch_status_t(* switch_recv_dtmf_hook_t)(switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction)
switch_status_t(* switch_video_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int)
Node in which to store state run callback hooks.
switch_io_event_hook_video_read_frame_t * video_read_frame
An abstraction of a data frame.
switch_io_event_hook_send_dtmf_t * send_dtmf
struct switch_io_event_hook_kill_channel * next
switch_status_t(* switch_text_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int)
switch_io_event_hook_outgoing_channel_t * outgoing_channel
switch_io_event_hook_read_frame_t * read_frame
struct switch_io_event_hook_receive_message * next
switch_status_t(* switch_state_run_hook_t)(switch_core_session_t *)
Node in which to store custom read frame channel callback hooks.
switch_state_change_hook_t state_change
struct switch_io_event_hook_state_change * next
switch_status_t
Common return values.
Node in which to store custom receive message callback hooks.
Node in which to store custom send dtmf channel callback hooks.
switch_io_event_hook_video_write_frame_t * video_write_frame
#define NEW_HOOK_DECL_REM_P(_NAME)
switch_io_event_hook_receive_event_t * receive_event
Node in which to store custom video_write_frame channel callback hooks.
switch_io_event_hook_receive_message_t * receive_message
struct switch_io_event_hook_recv_dtmf * next
Node in which to store custom kill channel callback hooks.
struct switch_io_event_hook_write_frame * next
switch_state_run_hook_t state_run
switch_io_event_hook_state_run_t * state_run
switch_io_event_hook_recv_dtmf_t * recv_dtmf
typedefSWITCH_BEGIN_EXTERN_C struct switch_io_event_hooks switch_io_event_hooks_t
Node in which to store custom recv dtmf channel callback hooks.
switch_io_event_hook_kill_channel_t * kill_channel
#define NEW_HOOK_DECL_ADD_P(_NAME)
switch_status_t(* switch_send_dtmf_hook_t)(switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction)
switch_outgoing_channel_hook_t outgoing_channel
A table of lists of io_event_hooks to store the event hooks associated with a session.
switch_io_event_hook_state_change_t * state_change
#define SWITCH_BEGIN_EXTERN_C