add some write locks to the core and a function to unregister event bindings

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8880 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-07-01 23:41:09 +00:00
parent 34215ce00f
commit 43b712b7b1
10 changed files with 269 additions and 63 deletions
+3
View File
@@ -599,6 +599,9 @@ SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_op
*/
SWITCH_DECLARE(void) switch_core_session_hupall(_In_ switch_call_cause_t cause);
SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause);
SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause);
/*!
\brief Send a message to another session using it's uuid
\param uuid_str the unique id of the session you want to send a message to
+24 -23
View File
@@ -70,14 +70,6 @@ SWITCH_BEGIN_EXTERN_C
struct switch_event_header *next;
};
/*! \brief A registered custom event subclass */
struct switch_event_subclass {
/*! the owner of the subclass */
char *owner;
/*! the subclass name */
char *name;
};
/*! \brief Representation of an event */
struct switch_event {
/*! the event id (descriptor) */
@@ -87,7 +79,7 @@ struct switch_event {
/*! the owner of the event */
char *owner;
/*! the subclass of the event */
switch_event_subclass_t *subclass;
char *subclass_name;
/*! the event headers */
switch_event_header_t *headers;
/*! the event headers tail pointer */
@@ -103,20 +95,7 @@ struct switch_event {
struct switch_event *next;
};
/*! \brief A node to store binded events */
struct switch_event_node {
/*! the id of the node */
char *id;
/*! the event id enumeration to bind to */
switch_event_types_t event_id;
/*! the event subclass to bind to for custom events */
switch_event_subclass_t *subclass;
/*! a callback function to execute when the event is triggered */
switch_event_callback_t callback;
/*! private data */
void *user_data;
struct switch_event_node *next;
};
struct switch_event_node;
#define SWITCH_EVENT_SUBCLASS_ANY NULL
@@ -228,6 +207,25 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con
SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback,
void *user_data);
/*!
\brief Bind an event callback to a specific event
\param id an identifier token of the binder
\param event the event enumeration to bind to
\param subclass_name the event subclass to bind to in the case if SWITCH_EVENT_CUSTOM
\param callback the callback functon to bind
\param user_data optional user specific data to pass whenever the callback is invoked
\param node bind handle to later remove the binding.
\return SWITCH_STATUS_SUCCESS if the event was binded
*/
SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name,
switch_event_callback_t callback, void *user_data, switch_event_node_t **node);
/*!
\brief Unbind a bound event consumer
\param node node to unbind
\return SWITCH_STATUS_SUCCESS if the consumer was unbinded
*/
SWITCH_DECLARE(switch_status_t) switch_event_unbind(switch_event_node_t **node);
/*!
\brief Render the name of an event id enumeration
\param event the event id to render the name of
@@ -253,6 +251,8 @@ SWITCH_DECLARE(switch_status_t) switch_name_event(const char *name, switch_event
*/
SWITCH_DECLARE(switch_status_t) switch_event_reserve_subclass_detailed(const char *owner, const char *subclass_name);
SWITCH_DECLARE(switch_status_t) switch_event_free_subclass_detailed(const char *owner, const char *subclass_name);
/*!
\brief Render a string representation of an event sutable for printing or network transport
\param event the event to render
@@ -311,6 +311,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char
\note the body supplied by this function will supersede an existing body the event may have
*/
#define switch_event_reserve_subclass(subclass_name) switch_event_reserve_subclass_detailed(__FILE__, subclass_name)
#define switch_event_free_subclass(subclass_name) switch_event_free_subclass_detailed(__FILE__, subclass_name)
/*!
\brief Create a new event assuming it will not be custom event and therefore hiding the unused parameters
+14 -2
View File
@@ -195,6 +195,8 @@ struct switch_endpoint_interface {
/*! private information */
void *private_info;
switch_thread_rwlock_t *rwlock;
/* to facilitate linking */
struct switch_endpoint_interface *next;
};
@@ -245,6 +247,7 @@ struct switch_timer_interface {
switch_status_t (*timer_check) (switch_timer_t *, switch_bool_t);
/*! function to deallocate the timer */
switch_status_t (*timer_destroy) (switch_timer_t *);
switch_thread_rwlock_t *rwlock;
struct switch_timer_interface *next;
};
@@ -254,6 +257,7 @@ struct switch_dialplan_interface {
const char *interface_name;
/*! the function to read an extension and set a channels dialpan */
switch_dialplan_hunt_function_t hunt_function;
switch_thread_rwlock_t *rwlock;
struct switch_dialplan_interface *next;
};
@@ -277,6 +281,7 @@ struct switch_file_interface {
switch_status_t (*file_get_string) (switch_file_handle_t *fh, switch_audio_col_t col, const char **string);
/*! list of supported file extensions */
char **extens;
switch_thread_rwlock_t *rwlock;
struct switch_file_interface *next;
};
@@ -353,6 +358,7 @@ struct switch_asr_interface {
switch_status_t (*asr_check_results) (switch_asr_handle_t *ah, switch_asr_flag_t *flags);
/*! function to read results from the ASR */
switch_status_t (*asr_get_results) (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags);
switch_thread_rwlock_t *rwlock;
struct switch_asr_interface *next;
};
@@ -393,7 +399,7 @@ struct switch_speech_interface {
void (*speech_text_param_tts) (switch_speech_handle_t *sh, char *param, const char *val);
void (*speech_numeric_param_tts) (switch_speech_handle_t *sh, char *param, int val);
void (*speech_float_param_tts) (switch_speech_handle_t *sh, char *param, double val);
switch_thread_rwlock_t *rwlock;
struct switch_speech_interface *next;
};
@@ -426,6 +432,7 @@ struct switch_say_interface {
const char *interface_name;
/*! function to pass down to the module */
switch_say_callback_t say_function;
switch_thread_rwlock_t *rwlock;
struct switch_say_interface *next;
};
@@ -435,6 +442,7 @@ struct switch_chat_interface {
const char *interface_name;
/*! function to open the directory interface */
switch_status_t (*chat_send) (char *proto, char *from, char *to, char *subject, char *body, char *hint);
switch_thread_rwlock_t *rwlock;
struct switch_chat_interface *next;
};
@@ -444,6 +452,7 @@ struct switch_management_interface {
const char *relative_oid;
/*! function to open the directory interface */
switch_status_t (*management_function) (char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen);
switch_thread_rwlock_t *rwlock;
struct switch_management_interface *next;
};
@@ -461,7 +470,7 @@ struct switch_directory_interface {
switch_status_t (*directory_next) (switch_directory_handle_t *dh);
/*! function to advance to the next name/value pair in the current record */
switch_status_t (*directory_next_pair) (switch_directory_handle_t *dh, char **var, char **val);
switch_thread_rwlock_t *rwlock;
struct switch_directory_interface *next;
};
@@ -586,6 +595,7 @@ struct switch_codec_interface {
/*! a list of codec implementations related to the codec */
switch_codec_implementation_t *implementations;
uint32_t codec_id;
switch_thread_rwlock_t *rwlock;
struct switch_codec_interface *next;
};
@@ -603,6 +613,7 @@ struct switch_application_interface {
const char *syntax;
/*! flags to control behaviour */
uint32_t flags;
switch_thread_rwlock_t *rwlock;
struct switch_application_interface *next;
};
@@ -616,6 +627,7 @@ struct switch_api_interface {
switch_api_function_t function;
/*! an example of the api syntax */
const char *syntax;
switch_thread_rwlock_t *rwlock;
struct switch_api_interface *next;
};
+1
View File
@@ -100,6 +100,7 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_PATH_SEPARATOR "/"
#endif
#define SWITCH_URL_SEPARATOR "://"
#define SWITCH_CURRENT_APPLICATION_VARIABLE "current_application"
#define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause"
#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE "execute_on_answer"
#define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE "execute_on_ring"