RTS API Documentation  1.10.11
switch_core_event_hook.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  * switch_core_event_hook.h Core Event Hooks
29  *
30  */
31 #ifndef SWITCH_EVENT_HOOKS_H
32 #define SWITCH_EVENT_HOOKS_H
33 
34 #include <switch.h>
36 
54 typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
55 typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
56 typedef switch_status_t (*switch_video_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
57 typedef switch_status_t (*switch_write_frame_hook_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
59 typedef switch_status_t (*switch_text_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
60 typedef switch_status_t (*switch_text_write_frame_hook_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
61 typedef switch_status_t (*switch_kill_channel_hook_t) (switch_core_session_t *, int);
62 typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction);
63 typedef switch_status_t (*switch_recv_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *, switch_dtmf_direction_t direction);
64 typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *);
65 typedef switch_status_t (*switch_state_run_hook_t) (switch_core_session_t *);
66 
67 /*! \brief Node in which to store custom receive message callback hooks */
71 };
72 
73 /*! \brief Node in which to store custom receive message callback hooks */
77 };
78 
79 
80 /*! \brief Node in which to store custom receive message callback hooks */
82  /*! the event callback hook */
85 };
86 
87 /*! \brief Node in which to store custom read frame channel callback hooks */
89  /*! the read frame channel callback hook */
92 };
93 
94 /*! \brief Node in which to store custom read frame channel callback hooks */
96  /*! the read frame channel callback hook */
99 };
100 
101 /*! \brief Node in which to store custom write_frame channel callback hooks */
103  /*! the write_frame channel callback hook */
106 };
107 
108 /*! \brief Node in which to store custom video_write_frame channel callback hooks */
110  /*! the video_write_frame channel callback hook */
113 };
114 
115 /*! \brief Node in which to store custom read frame channel callback hooks */
117  /*! the read frame channel callback hook */
120 };
121 
122 /*! \brief Node in which to store custom video_write_frame channel callback hooks */
124  /*! the video_write_frame channel callback hook */
127 };
128 
129 /*! \brief Node in which to store custom kill channel callback hooks */
131  /*! the kill channel callback hook */
134 };
135 
136 /*! \brief Node in which to store custom send dtmf channel callback hooks */
138  /*! the send dtmf channel callback hook */
141 };
142 
143 /*! \brief Node in which to store custom recv dtmf channel callback hooks */
145  /*! the recv dtmf channel callback hook */
148 };
149 
150 /*! \brief Node in which to store state change callback hooks */
152  /*! the state change channel callback hook */
155 };
156 
157 /*! \brief Node in which to store state run callback hooks */
159  /*! the state run channel callback hook */
162 };
163 
164 
165 /*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */
167  /*! a list of outgoing channel hooks */
169  /*! a list of receive message hooks */
171  /*! a list of queue message hooks */
173  /*! a list of read frame hooks */
175  /*! a list of video read frame hooks */
177  /*! a list of write frame hooks */
179  /*! a list of text write frame hooks */
181  /*! a list of text write frame hooks */
183  /*! a list of text read frame hooks */
185  /*! a list of kill channel hooks */
187  /*! a list of send dtmf hooks */
189  /*! a list of recv dtmf hooks */
191  /*! a list of state change hooks */
194 };
195 
196 extern switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session);
197 
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)
200 
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)
203 
204 #define NEW_HOOK_DECL(_NAME) NEW_HOOK_DECL_ADD_P(_NAME) \
205  { \
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; \
215  } else { \
216  switch_assert(ptr); \
217  ptr->next = hook; \
218  } \
219  return SWITCH_STATUS_SUCCESS; \
220  } \
221  return SWITCH_STATUS_MEMERR; \
222  } \
223  NEW_HOOK_DECL_REM_P(_NAME) \
224  { \
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) { \
229  if (last) { \
230  last->next = ptr->next; \
231  } else { \
232  session->event_hooks._NAME = ptr->next; \
233  } \
234  return SWITCH_STATUS_SUCCESS; \
235  } \
236  last = ptr; \
237  } \
238  return SWITCH_STATUS_FALSE; \
239  }
240 
241 
243 NEW_HOOK_DECL_ADD_P(receive_message);
244 NEW_HOOK_DECL_ADD_P(receive_event);
245 NEW_HOOK_DECL_ADD_P(state_change);
246 NEW_HOOK_DECL_ADD_P(state_run);
247 NEW_HOOK_DECL_ADD_P(read_frame);
248 NEW_HOOK_DECL_ADD_P(write_frame);
249 NEW_HOOK_DECL_ADD_P(video_read_frame);
250 NEW_HOOK_DECL_ADD_P(video_write_frame);
251 NEW_HOOK_DECL_ADD_P(text_read_frame);
252 NEW_HOOK_DECL_ADD_P(text_write_frame);
253 NEW_HOOK_DECL_ADD_P(kill_channel);
254 NEW_HOOK_DECL_ADD_P(send_dtmf);
255 NEW_HOOK_DECL_ADD_P(recv_dtmf);
256 
258 NEW_HOOK_DECL_REM_P(receive_message);
259 NEW_HOOK_DECL_REM_P(receive_event);
260 NEW_HOOK_DECL_REM_P(state_change);
261 NEW_HOOK_DECL_REM_P(state_run);
262 NEW_HOOK_DECL_REM_P(read_frame);
263 NEW_HOOK_DECL_REM_P(write_frame);
264 NEW_HOOK_DECL_REM_P(video_read_frame);
265 NEW_HOOK_DECL_REM_P(video_write_frame);
266 NEW_HOOK_DECL_REM_P(text_read_frame);
267 NEW_HOOK_DECL_REM_P(text_write_frame);
268 NEW_HOOK_DECL_REM_P(kill_channel);
269 NEW_HOOK_DECL_REM_P(send_dtmf);
270 NEW_HOOK_DECL_REM_P(recv_dtmf);
271 
272 
274 #endif
275 /* For Emacs:
276  * Local Variables:
277  * mode:c
278  * indent-tabs-mode:t
279  * tab-width:4
280  * c-basic-offset:4
281  * End:
282  * For VIM:
283  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
284  */
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)
Call Specific Data.
Definition: switch_caller.h:73
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
Definition: switch.h:43
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.
Definition: switch_event.h:80
Node in which to store custom read frame channel callback hooks.
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
Definition: switch_types.h:335
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.
Definition: switch_core.h:179
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_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.
Definition: switch_frame.h:54
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_dtmf_direction_t
Definition: switch_types.h:320
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
Main Library Header.
#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_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
Definition: switch.h:42