31 #ifndef SWITCH_EVENT_HOOKS_H
32 #define SWITCH_EVENT_HOOKS_H
176 #define NEW_HOOK_DECL_ADD_P(_NAME) SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_##_NAME \
177 (switch_core_session_t *session, switch_##_NAME##_hook_t _NAME)
179 #define NEW_HOOK_DECL_REM_P(_NAME) SWITCH_DECLARE(switch_status_t) switch_core_event_hook_remove_##_NAME \
180 (switch_core_session_t *session, switch_##_NAME##_hook_t _NAME)
182 #define NEW_HOOK_DECL(_NAME) NEW_HOOK_DECL_ADD_P(_NAME) \
184 switch_io_event_hook_##_NAME##_t *hook, *ptr; \
185 assert(_NAME != NULL); \
186 for (ptr = session->event_hooks._NAME; ptr && ptr->next; ptr = ptr->next) \
187 if (ptr->_NAME == _NAME) return SWITCH_STATUS_FALSE; \
188 if (ptr && ptr->_NAME == _NAME) return SWITCH_STATUS_FALSE; \
189 if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) { \
190 hook->_NAME = _NAME ; \
191 if (! session->event_hooks._NAME ) { \
192 session->event_hooks._NAME = hook; \
196 return SWITCH_STATUS_SUCCESS; \
198 return SWITCH_STATUS_MEMERR; \
200 NEW_HOOK_DECL_REM_P(_NAME) \
202 switch_io_event_hook_##_NAME##_t *ptr, *last = NULL; \
203 assert(_NAME != NULL); \
204 for (ptr = session->event_hooks._NAME; ptr; ptr = ptr->next) { \
205 if (ptr->_NAME == _NAME) { \
207 last->next = ptr->next; \
209 session->event_hooks._NAME = ptr->next; \
211 return SWITCH_STATUS_SUCCESS; \
215 return SWITCH_STATUS_FALSE; \
switch_status_t(* switch_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int)
switch_status_t(* switch_receive_event_hook_t)(switch_core_session_t *, switch_event_t *)
switch_status_t(* switch_video_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int)
switch_status_t(* switch_kill_channel_hook_t)(switch_core_session_t *, int)
switch_send_dtmf_hook_t send_dtmf
struct switch_io_event_hook_outgoing_channel * next
uint32_t switch_io_flag_t
#define SWITCH_END_EXTERN_C
switch_read_frame_hook_t video_read_frame
switch_read_frame_hook_t read_frame
switch_status_t(* switch_video_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int)
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_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_kill_channel_hook_t kill_channel
Node in which to store custom video_write_frame channel callback hooks.
struct switch_io_event_hook_receive_event * next
Representation of an event.
switch_status_t(* switch_receive_message_hook_t)(switch_core_session_t *, switch_core_session_message_t *)
struct switch_io_event_hook_video_read_frame * next
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
switch_status_t(* switch_send_dtmf_hook_t)(switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction)
struct switch_io_event_hook_state_run * next
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
switch_receive_message_hook_t receive_message
switch_status_t(* switch_state_run_hook_t)(switch_core_session_t *)
switch_status_t(* switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int)
switch_write_frame_hook_t write_frame
switch_recv_dtmf_hook_t recv_dtmf
switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session)
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_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
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.
switch_status_t(* switch_recv_dtmf_hook_t)(switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction)
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
switch_status_t(* switch_state_change_hook_t)(switch_core_session_t *)
#define NEW_HOOK_DECL_REM_P(_NAME)
switch_io_event_hook_receive_event_t * receive_event
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_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