RTS API Documentation  1.10.11
Data Structures | Macros | Typedefs | Functions
switch_channel.h File Reference

Media Channel Interface. More...

#include <switch.h>
+ Include dependency graph for switch_channel.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  switch_channel_timetable
 

Macros

#define switch_channel_ready(_channel)   switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE)
 
#define switch_channel_media_ready(_channel)   switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE)
 
#define switch_channel_media_up(_channel)   (switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA))
 
#define switch_channel_up(_channel)   (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) < CS_HANGUP)
 
#define switch_channel_down(_channel)   (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) >= CS_HANGUP)
 
#define switch_channel_up_nosig(_channel)   (switch_channel_get_state(_channel) < CS_HANGUP)
 
#define switch_channel_down_nosig(_channel)   (switch_channel_get_state(_channel) >= CS_HANGUP)
 
#define switch_channel_media_ack(_channel)   (!switch_channel_test_cap(_channel, CC_MEDIA_ACK) || switch_channel_test_flag(_channel, CF_MEDIA_ACK))
 
#define switch_channel_text_only(_channel)   (switch_channel_test_flag(_channel, CF_HAS_TEXT) && !switch_channel_test_flag(_channel, CF_AUDIO))
 
#define switch_channel_set_running_state(channel, state)   switch_channel_perform_set_running_state(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_set_state(channel, state)   switch_channel_perform_set_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__, state)
 Set the current state of a channel. More...
 
#define switch_channel_presence(_a, _b, _c, _d)   switch_channel_perform_presence(_a, _b, _c, _d, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_set_variable_safe(_channel, _var, _val)   switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_FALSE)
 
#define switch_channel_set_variable(_channel, _var, _val)   switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_TRUE)
 
#define switch_channel_set_variable_strip_quotes(_channel, _var, _val)   switch_channel_set_variable_strip_quotes_var_check(_channel, _var, _val, SWITCH_TRUE)
 
#define switch_channel_set_variable_partner(_channel, _var, _val)   switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
 
#define switch_channel_export_variable(_channel, _varname, _value, _ev)   switch_channel_export_variable_var_check(_channel, _varname, _value, _ev, SWITCH_TRUE)
 
#define switch_channel_get_variable(_c, _v)   switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE, -1)
 
#define switch_channel_set_flag(_c, _f)   switch_channel_set_flag_value(_c, _f, 1)
 
#define switch_channel_set_cap(_c, _cc)   switch_channel_set_cap_value(_c, _cc, 1)
 
#define switch_channel_answer(channel)   switch_channel_perform_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 Answer a channel (initiate/acknowledge a successful connection) More...
 
#define switch_channel_mark_answered(channel)   switch_channel_perform_mark_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 Mark a channel answered with no indication (for outbound calls) More...
 
#define switch_channel_mark_pre_answered(channel)   switch_channel_perform_mark_pre_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 Mark a channel pre_answered (early media) with no indication (for outbound calls) More...
 
#define switch_channel_acknowledge_call(channel)   switch_channel_perform_acknowledge_call(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_ring_ready(channel)   switch_channel_perform_ring_ready_value(channel, SWITCH_RING_READY_RINGING, __FILE__, __SWITCH_FUNC__, __LINE__)
 Send Ringing message to a channel. More...
 
#define switch_channel_ring_ready_value(channel, _rv)   switch_channel_perform_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_pre_answer(channel)   switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
 Indicate progress on a channel to attempt early media. More...
 
#define switch_channel_mark_ring_ready(channel)   switch_channel_perform_mark_ring_ready_value(channel, SWITCH_RING_READY_RINGING, __FILE__, __SWITCH_FUNC__, __LINE__)
 Indicate a channel is ready to provide ringback. More...
 
#define switch_channel_mark_ring_ready_value(channel, _rv)   switch_channel_perform_mark_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_hangup(channel, hangup_cause)   switch_channel_perform_hangup(channel, __FILE__, __SWITCH_FUNC__, __LINE__, hangup_cause)
 Hangup a channel flagging it's state machine to end. More...
 
#define switch_channel_expand_variables(_channel, _in)   switch_channel_expand_variables_check(_channel, _in, NULL, NULL, 0)
 
#define switch_channel_inbound_display(_channel)   ((switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(_channel, CF_BLEG)) || (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_test_flag(_channel, CF_DIALPLAN)))
 
#define switch_channel_outbound_display(_channel)   ((switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND && switch_channel_test_flag(_channel, CF_BLEG)) || (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && !switch_channel_test_flag(_channel, CF_DIALPLAN)))
 
#define switch_channel_stop_broadcast(_channel)   for(;;) {if (switch_channel_test_flag(_channel, CF_BROADCAST)) {switch_channel_set_flag(_channel, CF_STOP_BROADCAST); switch_channel_set_flag(_channel, CF_BREAK); } break;}
 
#define switch_channel_audio_sync(_c)   switch_channel_perform_audio_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_video_sync(_c)   switch_channel_perform_video_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_channel_set_app_flag(_c, _f)   switch_channel_set_app_flag_key(__FILE__, _c, _f)
 
#define switch_channel_clear_app_flag(_c, _f)   switch_channel_clear_app_flag_key(__FILE__, _c, _f)
 
#define switch_channel_test_app_flag(_c, _f)   switch_channel_test_app_flag_key(__FILE__, _c, _f)
 
#define switch_channel_set_callstate(channel, state)   switch_channel_perform_set_callstate(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)
 

Typedefs

typedef struct switch_channel_timetable switch_channel_timetable_t
 

Functions

switch_channel_state_t switch_channel_get_state (switch_channel_t *channel)
 Get the current state of a channel in the state engine. More...
 
switch_channel_state_t switch_channel_get_running_state (switch_channel_t *channel)
 
int switch_channel_check_signal (switch_channel_t *channel, switch_bool_t in_thread_only)
 
int switch_channel_test_ready (switch_channel_t *channel, switch_bool_t check_ready, switch_bool_t check_media)
 Determine if a channel is ready for io. More...
 
void switch_channel_wait_for_state (switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state)
 
void switch_channel_wait_for_state_timeout (switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout)
 
switch_status_t switch_channel_wait_for_flag (switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to, switch_channel_t *super_channel)
 
switch_status_t switch_channel_wait_for_app_flag (switch_channel_t *channel, uint32_t app_flag, const char *key, switch_bool_t pres, uint32_t to)
 
switch_channel_state_t switch_channel_perform_set_state (switch_channel_t *channel, const char *file, const char *func, int line, switch_channel_state_t state)
 
switch_channel_state_t switch_channel_perform_set_running_state (switch_channel_t *channel, switch_channel_state_t state, const char *file, const char *func, int line)
 
switch_call_cause_t switch_channel_str2cause (_In_ const char *str)
 return a cause code for a given string More...
 
switch_call_cause_t switch_channel_get_cause (_In_ switch_channel_t *channel)
 return the cause code for a given channel More...
 
switch_call_cause_t switch_channel_cause_q850 (switch_call_cause_t cause)
 
switch_call_cause_t switch_channel_get_cause_q850 (switch_channel_t *channel)
 
switch_call_cause_tswitch_channel_get_cause_ptr (switch_channel_t *channel)
 
const char * switch_channel_cause2str (_In_ switch_call_cause_t cause)
 return a cause string for a given cause More...
 
switch_channel_timetable_tswitch_channel_get_timetable (_In_ switch_channel_t *channel)
 View the timetable of a channel. More...
 
switch_status_t switch_channel_alloc (_In_ switch_channel_t **channel, _In_ switch_call_direction_t direction, _In_ switch_memory_pool_t *pool)
 Allocate a new channel. More...
 
switch_status_t switch_channel_init (switch_channel_t *channel, switch_core_session_t *session, switch_channel_state_t state, switch_channel_flag_t flag)
 Connect a newly allocated channel to a session object and setup it's initial state. More...
 
void switch_channel_set_presence_data_vals (switch_channel_t *channel, const char *presence_data_cols)
 Takes presence_data_cols as a parameter or as a channel variable and copies them to channel profile variables. More...
 
void switch_channel_perform_presence (switch_channel_t *channel, const char *rpid, const char *status, const char *id, const char *file, const char *func, int line)
 Fire A presence event for the channel. More...
 
void switch_channel_uninit (switch_channel_t *channel)
 Uninitalize a channel. More...
 
void switch_channel_set_caller_profile (switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 Set the given channel's caller profile. More...
 
void switch_channel_step_caller_profile (switch_channel_t *channel)
 
switch_caller_profile_tswitch_channel_get_caller_profile (switch_channel_t *channel)
 Retrieve the given channel's caller profile. More...
 
void switch_channel_set_originator_caller_profile (switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 Set the given channel's originator caller profile. More...
 
void switch_channel_set_hunt_caller_profile (switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 
switch_caller_profile_tswitch_channel_get_originator_caller_profile (switch_channel_t *channel)
 Retrieve the given channel's originator caller profile. More...
 
void switch_channel_set_originatee_caller_profile (switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 Set the given channel's originatee caller profile. More...
 
switch_caller_profile_tswitch_channel_get_originatee_caller_profile (switch_channel_t *channel)
 Retrieve the given channel's originatee caller profile. More...
 
void switch_channel_set_origination_caller_profile (switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 Set the given channel's origination caller profile. More...
 
switch_caller_profile_tswitch_channel_get_origination_caller_profile (switch_channel_t *channel)
 Retrieve the given channel's origination caller profile. More...
 
char * switch_channel_get_uuid (switch_channel_t *channel)
 Retrieve the given channel's unique id. More...
 
switch_status_t switch_channel_set_profile_var (switch_channel_t *channel, const char *name, const char *val)
 Set a variable on a given channel. More...
 
switch_status_t switch_channel_set_log_tag (switch_channel_t *channel, const char *tagname, const char *tagvalue)
 
switch_status_t switch_channel_get_log_tags (switch_channel_t *channel, switch_event_t **log_tags)
 
switch_status_t switch_channel_set_variable_var_check (switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
 
switch_status_t switch_channel_set_variable_strip_quotes_var_check (switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
 
switch_status_t switch_channel_add_variable_var_check (switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check, switch_stack_t stack)
 
switch_status_t switch_channel_set_variable_printf (switch_channel_t *channel, const char *varname, const char *fmt,...)
 
switch_status_t switch_channel_set_variable_name_printf (switch_channel_t *channel, const char *val, const char *fmt,...)
 
switch_status_t switch_channel_set_variable_partner_var_check (switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
 
const char * switch_channel_get_variable_partner (switch_channel_t *channel, const char *varname)
 
const char * switch_channel_get_hold_music (switch_channel_t *channel)
 
const char * switch_channel_get_hold_music_partner (switch_channel_t *channel)
 
uint32_t switch_channel_del_variable_prefix (switch_channel_t *channel, const char *prefix)
 
switch_status_t switch_channel_transfer_variable_prefix (switch_channel_t *orig_channel, switch_channel_t *new_channel, const char *prefix)
 
switch_status_t switch_channel_export_variable_var_check (switch_channel_t *channel, const char *varname, const char *val, const char *export_varname, switch_bool_t var_check)
 
void switch_channel_process_export (switch_channel_t *channel, switch_channel_t *peer_channel, switch_event_t *var_event, const char *export_varname)
 
switch_status_t switch_channel_export_variable_printf (switch_channel_t *channel, const char *varname, const char *export_varname, const char *fmt,...)
 
void switch_channel_set_scope_variables (switch_channel_t *channel, switch_event_t **event)
 
switch_status_t switch_channel_get_scope_variables (switch_channel_t *channel, switch_event_t **event)
 
const char * switch_channel_get_variable_dup (switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx)
 Retrieve a variable from a given channel. More...
 
const char * switch_channel_get_variable_strdup (switch_channel_t *channel, const char *varname)
 Retrieve a copy of a variable from a given channel. switch_safe_free() call will be required. More...
 
switch_status_t switch_channel_get_variable_buf (switch_channel_t *channel, const char *varname, char *buf, switch_size_t buflen)
 Retrieve a variable from a given channel to a pre-allocated buffer without using a memory pool. More...
 
switch_status_t switch_channel_get_variables (switch_channel_t *channel, switch_event_t **event)
 
switch_status_t switch_channel_get_variables_prefix (switch_channel_t *channel, const char *prefix, switch_event_t **event)
 
switch_status_t switch_channel_pass_callee_id (switch_channel_t *channel, switch_channel_t *other_channel)
 
static int switch_channel_var_false (switch_channel_t *channel, const char *variable)
 
static int switch_channel_var_true (switch_channel_t *channel, const char *variable)
 
switch_event_header_tswitch_channel_variable_first (switch_channel_t *channel)
 Start iterating over the entries in the channel variable list. More...
 
void switch_channel_variable_last (switch_channel_t *channel)
 Stop iterating over channel variables. More...
 
void switch_channel_restart (switch_channel_t *channel)
 
switch_status_t switch_channel_caller_extension_masquerade (switch_channel_t *orig_channel, switch_channel_t *new_channel, uint32_t offset)
 
void switch_channel_set_caller_extension (switch_channel_t *channel, switch_caller_extension_t *caller_extension)
 Assign a caller extension to a given channel. More...
 
void switch_channel_invert_cid (switch_channel_t *channel)
 
void switch_channel_flip_cid (switch_channel_t *channel)
 
void switch_channel_sort_cid (switch_channel_t *channel)
 
switch_caller_extension_tswitch_channel_get_caller_extension (switch_channel_t *channel)
 Retrieve caller extension from a given channel. More...
 
uint32_t switch_channel_test_flag (switch_channel_t *channel, switch_channel_flag_t flag)
 Test for presence of given flag on a given channel. More...
 
void switch_channel_set_flag_value (switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value)
 Set given flag(s) on a given channel. More...
 
void switch_channel_set_flag_recursive (switch_channel_t *channel, switch_channel_flag_t flag)
 
void switch_channel_set_cap_value (switch_channel_t *channel, switch_channel_cap_t cap, uint32_t value)
 
void switch_channel_clear_cap (switch_channel_t *channel, switch_channel_cap_t cap)
 
uint32_t switch_channel_test_cap (switch_channel_t *channel, switch_channel_cap_t cap)
 
uint32_t switch_channel_test_cap_partner (switch_channel_t *channel, switch_channel_cap_t cap)
 
switch_bool_t switch_channel_set_flag_partner (switch_channel_t *channel, switch_channel_flag_t flag)
 Set given flag(s) on a given channel's bridge partner. More...
 
switch_bool_t switch_channel_clear_flag_partner (switch_channel_t *channel, switch_channel_flag_t flag)
 Clears given flag(s) on a given channel's bridge partner. More...
 
uint32_t switch_channel_test_flag_partner (switch_channel_t *channel, switch_channel_flag_t flag)
 
void switch_channel_set_state_flag (switch_channel_t *channel, switch_channel_flag_t flag)
 Set given flag(s) on a given channel to be applied on the next state change. More...
 
void switch_channel_clear_state_flag (switch_channel_t *channel, switch_channel_flag_t flag)
 
void switch_channel_clear_flag (switch_channel_t *channel, switch_channel_flag_t flag)
 Clear given flag(s) from a channel. More...
 
void switch_channel_clear_flag_recursive (switch_channel_t *channel, switch_channel_flag_t flag)
 
switch_status_t switch_channel_perform_answer (switch_channel_t *channel, const char *file, const char *func, int line)
 
switch_status_t switch_channel_perform_mark_answered (switch_channel_t *channel, const char *file, const char *func, int line)
 
switch_status_t switch_channel_perform_acknowledge_call (switch_channel_t *channel, const char *file, const char *func, int line)
 
switch_status_t switch_channel_perform_ring_ready_value (switch_channel_t *channel, switch_ring_ready_t rv, const char *file, const char *func, int line)
 
switch_status_t switch_channel_perform_pre_answer (switch_channel_t *channel, const char *file, const char *func, int line)
 
switch_status_t switch_channel_perform_mark_pre_answered (switch_channel_t *channel, const char *file, const char *func, int line)
 
switch_status_t switch_channel_perform_mark_ring_ready_value (switch_channel_t *channel, switch_ring_ready_t rv, const char *file, const char *func, int line)
 
int switch_channel_add_state_handler (switch_channel_t *channel, const switch_state_handler_table_t *state_handler)
 add a state handler table to a given channel More...
 
void switch_channel_clear_state_handler (switch_channel_t *channel, const switch_state_handler_table_t *state_handler)
 clear a state handler table from a given channel More...
 
const switch_state_handler_table_tswitch_channel_get_state_handler (switch_channel_t *channel, int index)
 Retrieve an state handler tablefrom a given channel at given index level. More...
 
switch_status_t switch_channel_set_private (switch_channel_t *channel, const char *key, const void *private_info)
 Set private data on channel. More...
 
void * switch_channel_get_private (switch_channel_t *channel, const char *key)
 Retrieve private from a given channel. More...
 
void * switch_channel_get_private_partner (switch_channel_t *channel, const char *key)
 
switch_status_t switch_channel_set_name (switch_channel_t *channel, const char *name)
 Assign a name to a given channel. More...
 
char * switch_channel_get_name (switch_channel_t *channel)
 Retrieve the name of a given channel. More...
 
switch_channel_state_t switch_channel_perform_hangup (switch_channel_t *channel, const char *file, const char *func, int line, switch_call_cause_t hangup_cause)
 
switch_size_t switch_channel_has_dtmf (_In_ switch_channel_t *channel)
 Test for presence of DTMF on a given channel. More...
 
switch_status_t switch_channel_dtmf_lock (switch_channel_t *channel)
 
switch_status_t switch_channel_try_dtmf_lock (switch_channel_t *channel)
 
switch_status_t switch_channel_dtmf_unlock (switch_channel_t *channel)
 
switch_status_t switch_channel_queue_dtmf (_In_ switch_channel_t *channel, _In_ const switch_dtmf_t *dtmf)
 Queue DTMF on a given channel. More...
 
switch_status_t switch_channel_queue_dtmf_string (_In_ switch_channel_t *channel, _In_ const char *dtmf_string)
 
switch_status_t switch_channel_dequeue_dtmf (_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf)
 Retrieve DTMF digits from a given channel. More...
 
void switch_channel_flush_dtmf (_In_ switch_channel_t *channel)
 
switch_size_t switch_channel_dequeue_dtmf_string (_In_ switch_channel_t *channel, _Out_opt_bytecapcount_(len) char *dtmf_str, _In_ switch_size_t len)
 
const char * switch_channel_state_name (_In_ switch_channel_state_t state)
 Render the name of the provided state enum. More...
 
switch_channel_state_t switch_channel_name_state (_In_ const char *name)
 Render the enum of the provided state name. More...
 
void switch_channel_event_set_data (_In_ switch_channel_t *channel, _In_ switch_event_t *event)
 Add information about a given channel to an event object. More...
 
void switch_channel_event_set_basic_data (_In_ switch_channel_t *channel, _In_ switch_event_t *event)
 
void switch_channel_event_set_extended_data (_In_ switch_channel_t *channel, _In_ switch_event_t *event)
 
char * switch_channel_expand_variables_check (switch_channel_t *channel, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur)
 Expand varaibles in a string based on the variables in a paticular channel. More...
 
char * switch_channel_build_param_string (_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile, _In_opt_ const char *prefix)
 
switch_status_t switch_channel_set_timestamps (_In_ switch_channel_t *channel)
 
void switch_channel_perform_audio_sync (switch_channel_t *channel, const char *file, const char *func, int line)
 
void switch_channel_perform_video_sync (switch_channel_t *channel, const char *file, const char *func, int line)
 
void switch_channel_set_private_flag (switch_channel_t *channel, uint32_t flags)
 
void switch_channel_clear_private_flag (switch_channel_t *channel, uint32_t flags)
 
int switch_channel_test_private_flag (switch_channel_t *channel, uint32_t flags)
 
void switch_channel_set_app_flag_key (const char *app, switch_channel_t *channel, uint32_t flags)
 
void switch_channel_clear_app_flag_key (const char *app, switch_channel_t *channel, uint32_t flags)
 
int switch_channel_test_app_flag_key (const char *app, switch_channel_t *channel, uint32_t flags)
 
void switch_channel_set_bridge_time (switch_channel_t *channel)
 
void switch_channel_set_hangup_time (switch_channel_t *channel)
 
switch_call_direction_t switch_channel_direction (switch_channel_t *channel)
 
switch_call_direction_t switch_channel_logical_direction (switch_channel_t *channel)
 
void switch_channel_set_direction (switch_channel_t *channel, switch_call_direction_t direction)
 
switch_core_session_tswitch_channel_get_session (switch_channel_t *channel)
 
char * switch_channel_get_flag_string (switch_channel_t *channel)
 
char * switch_channel_get_cap_string (switch_channel_t *channel)
 
int switch_channel_state_change_pending (switch_channel_t *channel)
 
void switch_channel_perform_set_callstate (switch_channel_t *channel, switch_channel_callstate_t callstate, const char *file, const char *func, int line)
 
switch_channel_callstate_t switch_channel_get_callstate (switch_channel_t *channel)
 
const char * switch_channel_callstate2str (switch_channel_callstate_t callstate)
 
switch_channel_callstate_t switch_channel_str2callstate (const char *str)
 
void switch_channel_mark_hold (switch_channel_t *channel, switch_bool_t on)
 
switch_status_t switch_channel_execute_on (switch_channel_t *channel, const char *variable_prefix)
 
switch_status_t switch_channel_execute_on_value (switch_channel_t *channel, const char *variable_value)
 
switch_status_t switch_channel_api_on (switch_channel_t *channel, const char *variable_prefix)
 
void switch_channel_process_device_hangup (switch_channel_t *channel)
 
switch_caller_extension_tswitch_channel_get_queued_extension (switch_channel_t *channel)
 
void switch_channel_transfer_to_extension (switch_channel_t *channel, switch_caller_extension_t *caller_extension)
 
const char * switch_channel_get_partner_uuid (switch_channel_t *channel)
 
const char * switch_channel_get_partner_uuid_copy (switch_channel_t *channel, char *buf, switch_size_t blen)
 
switch_hold_record_tswitch_channel_get_hold_record (switch_channel_t *channel)
 
void switch_channel_state_thread_lock (switch_channel_t *channel)
 
void switch_channel_state_thread_unlock (switch_channel_t *channel)
 
switch_status_t switch_channel_state_thread_trylock (switch_channel_t *channel)
 
void switch_channel_handle_cause (switch_channel_t *channel, switch_call_cause_t cause)
 
void switch_channel_global_init (switch_memory_pool_t *pool)
 
void switch_channel_global_uninit (void)
 
const char * switch_channel_set_device_id (switch_channel_t *channel, const char *device_id)
 
void switch_channel_clear_device_record (switch_channel_t *channel)
 
switch_device_record_tswitch_channel_get_device_record (switch_channel_t *channel)
 
void switch_channel_release_device_record (switch_device_record_t **dcdrp)
 
switch_status_t switch_channel_bind_device_state_handler (switch_device_state_function_t function, void *user_data)
 
switch_status_t switch_channel_unbind_device_state_handler (switch_device_state_function_t function)
 
const char * switch_channel_device_state2str (switch_device_state_t device_state)
 
switch_status_t switch_channel_pass_sdp (switch_channel_t *from_channel, switch_channel_t *to_channel, const char *sdp)
 

Detailed Description

Media Channel Interface.

See also
switch_channel

Definition in file switch_channel.h.

Typedef Documentation

◆ switch_channel_timetable_t

Definition at line 58 of file switch_channel.h.

Function Documentation

◆ switch_channel_api_on()

switch_status_t switch_channel_api_on ( switch_channel_t channel,
const char *  variable_prefix 
)

Definition at line 3702 of file switch_channel.c.

References switch_event_header::array, do_api_on(), switch_event::headers, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_channel_get_variables(), switch_event_destroy(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_event_header::value.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), record_callback(), send_record_stop_event(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_core_media_process_udptl(), switch_ivr_originate(), switch_ivr_record_file_event(), and tone_on_dtmf().

3703 {
3705  switch_event_t *event;
3706  int x = 0;
3707 
3708 
3709  switch_channel_get_variables(channel, &event);
3710 
3711  for (hp = event->headers; hp; hp = hp->next) {
3712  char *var = hp->name;
3713  char *val = hp->value;
3714 
3715  if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3716  if (hp->idx) {
3717  int i;
3718  for (i = 0; i < hp->idx; i++) {
3719  x++;
3720  do_api_on(channel, hp->array[i]);
3721  }
3722  } else {
3723  x++;
3724  do_api_on(channel, val);
3725  }
3726  }
3727  }
3728 
3729  switch_event_destroy(&event);
3730 
3732 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
static void do_api_on(switch_channel_t *channel, const char *variable)
switch_status_t switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
struct switch_event_header * next
Definition: switch_event.h:76
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_channel_bind_device_state_handler()

switch_status_t switch_channel_bind_device_state_handler ( switch_device_state_function_t  function,
void *  user_data 
)

Definition at line 5500 of file switch_channel.c.

References switch_device_state_binding_s::function, globals, switch_core_alloc, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_MEMERR, SWITCH_STATUS_SUCCESS, and switch_device_state_binding_s::user_data.

5501 {
5502  switch_device_state_binding_t *binding = NULL, *ptr = NULL;
5503  assert(function != NULL);
5504 
5505  if (!(binding = (switch_device_state_binding_t *) switch_core_alloc(globals.pool, sizeof(*binding)))) {
5506  return SWITCH_STATUS_MEMERR;
5507  }
5508 
5509  binding->function = function;
5510  binding->user_data = user_data;
5511 
5512  switch_mutex_lock(globals.device_mutex);
5513  for (ptr = globals.device_bindings; ptr && ptr->next; ptr = ptr->next);
5514 
5515  if (ptr) {
5516  ptr->next = binding;
5517  } else {
5518  globals.device_bindings = binding;
5519  }
5520 
5521  switch_mutex_unlock(globals.device_mutex);
5522 
5523  return SWITCH_STATUS_SUCCESS;
5524 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_device_state_function_t function
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
static struct @1 globals

◆ switch_channel_clear_device_record()

void switch_channel_clear_device_record ( switch_channel_t channel)

Definition at line 5116 of file switch_channel.c.

References CF_FINAL_DEVICE_LEG, switch_device_record_s::device_id, switch_channel::device_node, device_uuid_node_s::event, globals, device_uuid_node_s::hup_profile, switch_device_record_s::mutex, device_uuid_node_s::next, device_uuid_node_s::parent, pool, switch_device_record_s::pool, switch_device_record_s::refs, switch_caller_profile_event_set_data(), SWITCH_CHANNEL_CHANNEL_LOG, switch_channel_test_flag(), switch_core_destroy_memory_pool, switch_event_add_header_string(), SWITCH_EVENT_CALL_DETAIL, switch_event_create, switch_event_destroy(), switch_event_fire, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_snprintf(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_SUCCESS, switch_xml_free(), switch_yield, switch_device_record_s::uuid, switch_device_record_s::uuid_list, and device_uuid_node_s::xml_cdr.

Referenced by switch_core_session_destroy_state().

5117 {
5119  int sanity = 100;
5121  switch_event_t *event;
5122 
5123  if (!channel->device_node || !switch_channel_test_flag(channel, CF_FINAL_DEVICE_LEG)) {
5124  return;
5125  }
5126 
5127  while(--sanity && channel->device_node->parent->refs) {
5128  switch_yield(100000);
5129  }
5130 
5131  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Destroying device cdr %s on device [%s]\n",
5132  channel->device_node->parent->uuid,
5133  channel->device_node->parent->device_id);
5134 
5136  int x = 0;
5137  char prefix[80] = "";
5138 
5139  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Type", "device");
5141 
5143  for(np = channel->device_node->parent->uuid_list; np; np = np->next) {
5144  switch_snprintf(prefix, sizeof(prefix), "Call-%d", ++x);
5146  }
5148 
5149  switch_event_fire(&event);
5150  }
5151 
5153  for(np = channel->device_node->parent->uuid_list; np; np = np->next) {
5154  if (np->xml_cdr) {
5155  switch_xml_free(np->xml_cdr);
5156  }
5157  if (np->event) {
5159  }
5160  }
5162 
5163  pool = channel->device_node->parent->pool;
5164 
5165  switch_mutex_lock(globals.device_mutex);
5167 
5168  switch_mutex_unlock(globals.device_mutex);
5169 
5170 
5171 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
switch_xml_t xml_cdr
Definition: switch_core.h:83
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:642
switch_memory_pool_t * pool
Representation of an event.
Definition: switch_event.h:80
switch_caller_profile_t * hup_profile
Definition: switch_core.h:87
switch_mutex_t * mutex
Definition: switch_core.h:140
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_event_t * event
Definition: switch_core.h:84
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile, _In_opt_z_ const char *prefix, _In_ switch_event_t *event)
Add headers to an existing event in regards to a specific profile.
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
Definition: switch_utils.h:998
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
static struct @1 globals
struct device_uuid_node_s * next
Definition: switch_core.h:90
switch_memory_pool_t * pool
Definition: switch_core.h:141
struct switch_device_record_s * parent
Definition: switch_core.h:89
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
Definition: switch_event.h:384
struct device_uuid_node_s * uuid_list
Definition: switch_core.h:138
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_device_node_t * device_node
struct fspr_pool_t switch_memory_pool_t
void switch_event_destroy(switch_event_t **event)
Destroy an event.
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_device_state2str()

const char* switch_channel_device_state2str ( switch_device_state_t  device_state)

Definition at line 330 of file switch_channel.c.

References DEVICE_STATE_CHART, and switch_device_state_table::name.

Referenced by switch_channel_check_device_state().

331 {
332  uint8_t x;
333  const char *str = "UNKNOWN";
334 
335  for (x = 0; x < (sizeof(DEVICE_STATE_CHART) / sizeof(struct switch_cause_table)) - 1; x++) {
336  if (DEVICE_STATE_CHART[x].device_state == device_state) {
337  str = DEVICE_STATE_CHART[x].name;
338  break;
339  }
340  }
341 
342  return str;
343 }
static struct switch_device_state_table DEVICE_STATE_CHART[]

◆ switch_channel_execute_on()

switch_status_t switch_channel_execute_on ( switch_channel_t channel,
const char *  variable_prefix 
)

Definition at line 3780 of file switch_channel.c.

References switch_event_header::array, switch_event::headers, switch_event_header::idx, switch_event_header::name, switch_event_header::next, switch_channel_execute_on_value(), switch_channel_get_variables(), switch_core_get_variables(), switch_event_destroy(), switch_event_merge(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_event_header::value.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_timeout(), record_callback(), record_helper_post_process(), send_record_stop_event(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_core_media_activate_rtp(), switch_core_media_negotiate_sdp(), switch_core_media_process_t38_passthru(), switch_core_media_process_udptl(), switch_core_media_read_frame(), switch_core_media_set_codec(), switch_ivr_originate(), switch_ivr_record_file_event(), switch_ivr_session_transfer(), tone_detect_callback(), and tone_on_dtmf().

3781 {
3783  switch_event_t *event, *cevent;
3784  int x = 0;
3785 
3786  switch_core_get_variables(&event);
3787  switch_channel_get_variables(channel, &cevent);
3788  switch_event_merge(event, cevent);
3789 
3790  for (hp = event->headers; hp; hp = hp->next) {
3791  char *var = hp->name;
3792  char *val = hp->value;
3793 
3794  if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3795  if (hp->idx) {
3796  int i;
3797  for (i = 0; i < hp->idx; i++) {
3798  x++;
3799  switch_channel_execute_on_value(channel, hp->array[i]);
3800  }
3801  } else {
3802  x++;
3803  switch_channel_execute_on_value(channel, val);
3804  }
3805  }
3806  }
3807 
3808  switch_event_destroy(&event);
3809  switch_event_destroy(&cevent);
3810 
3812 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
switch_status_t switch_core_get_variables(switch_event_t **event)
Definition: switch_core.c:386
void switch_event_merge(switch_event_t *event, switch_event_t *tomerge)
switch_status_t switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
struct switch_event_header * next
Definition: switch_event.h:76
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_status_t switch_channel_execute_on_value(switch_channel_t *channel, const char *variable_value)
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_channel_execute_on_value()

switch_status_t switch_channel_execute_on_value ( switch_channel_t channel,
const char *  variable_value 
)

Definition at line 3734 of file switch_channel.c.

References switch_channel::session, switch_assert, switch_channel_expand_variables, switch_core_session_execute_application, switch_core_session_execute_application_async(), switch_core_session_strdup, and zstr.

Referenced by record_callback(), record_helper_post_process(), send_record_stop_event(), switch_channel_execute_on(), and switch_ivr_record_file_event().

3735 {
3736  switch_status_t status;
3737  char *arg = NULL;
3738  char *p;
3739  int bg = 0;
3740  char *app;
3741  char *expanded = NULL;
3742 
3743  app = switch_core_session_strdup(channel->session, variable_value);
3744 
3745  for(p = app; p && *p; p++) {
3746  if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) {
3747  *p++ = '\0';
3748  arg = p;
3749  break;
3750  } else if (*p == ':' && (*(p+1) == ':')) {
3751  bg++;
3752  break;
3753  }
3754  }
3755 
3756  switch_assert(app != NULL);
3757  if (!strncasecmp(app, "perl", 4)) {
3758  bg++;
3759  }
3760 
3761  if (zstr(arg)) {
3762  expanded = arg;
3763  } else {
3764  expanded = switch_channel_expand_variables(channel, arg);
3765  }
3766 
3767  if (bg) {
3768  status = switch_core_session_execute_application_async(channel->session, app, arg);
3769  } else {
3770  status = switch_core_session_execute_application(channel->session, app, arg);
3771  }
3772 
3773  if (expanded && expanded != arg) {
3774  free(expanded);
3775  }
3776 
3777  return status;
3778 }
switch_status_t switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg)
#define zstr(x)
Definition: switch_utils.h:314
#define switch_core_session_execute_application(_a, _b, _c)
Execute an application on a session.
Definition: switch_core.h:1129
#define switch_channel_expand_variables(_channel, _in)
switch_status_t
Common return values.
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
#define switch_assert(expr)
switch_core_session_t * session

◆ switch_channel_get_device_record()

switch_device_record_t* switch_channel_get_device_record ( switch_channel_t channel)

Definition at line 5482 of file switch_channel.c.

References switch_channel::device_node, switch_device_record_s::mutex, device_uuid_node_s::parent, and switch_mutex_lock().

5483 {
5484  if (channel->device_node) {
5486  return channel->device_node->parent;
5487  }
5488 
5489  return NULL;
5490 }
switch_mutex_t * mutex
Definition: switch_core.h:140
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
struct switch_device_record_s * parent
Definition: switch_core.h:89
switch_device_node_t * device_node

◆ switch_channel_get_hold_record()

switch_hold_record_t* switch_channel_get_hold_record ( switch_channel_t channel)

Definition at line 197 of file switch_channel.c.

References switch_channel::hold_record.

Referenced by switch_ivr_generate_xml_cdr().

198 {
199  return channel->hold_record;
200 }
switch_hold_record_t * hold_record

◆ switch_channel_get_partner_uuid()

const char* switch_channel_get_partner_uuid ( switch_channel_t channel)

◆ switch_channel_get_partner_uuid_copy()

const char* switch_channel_get_partner_uuid_copy ( switch_channel_t channel,
char *  buf,
switch_size_t  blen 
)

Definition at line 4846 of file switch_channel.c.

References switch_channel::profile_mutex, switch_channel_get_variable_dup(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE, SWITCH_SIGNAL_BOND_VARIABLE, and SWITCH_TRUE.

Referenced by switch_core_session_perform_get_partner().

4847 {
4848  const char *uuid = NULL;
4849 
4850  switch_mutex_lock(channel->profile_mutex);
4853  }
4854 
4855  if (uuid) {
4856  strncpy(buf, uuid, blen);
4857  uuid = (const char *) buf;
4858  }
4860 
4861  return uuid;
4862 }
const char * switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx)
Retrieve a variable from a given channel.
#define SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE
Definition: switch_types.h:204
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_byte_t switch_byte_t * buf
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define SWITCH_SIGNAL_BOND_VARIABLE
Definition: switch_types.h:203

◆ switch_channel_get_queued_extension()

switch_caller_extension_t* switch_channel_get_queued_extension ( switch_channel_t channel)

Definition at line 3312 of file switch_channel.c.

References switch_channel::profile_mutex, switch_channel::queued_extension, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_standard_on_routing().

3313 {
3314  switch_caller_extension_t *caller_extension;
3315 
3316  switch_mutex_lock(channel->profile_mutex);
3317  caller_extension = channel->queued_extension;
3318  channel->queued_extension = NULL;
3320 
3321  return caller_extension;
3322 }
An Abstract Representation of a dialplan extension.
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_caller_extension_t * queued_extension
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308

◆ switch_channel_global_init()

void switch_channel_global_init ( switch_memory_pool_t pool)

Definition at line 5017 of file switch_channel.c.

References globals, memset(), pool, switch_core_hash_init, switch_mutex_init(), and SWITCH_MUTEX_NESTED.

Referenced by switch_core_init().

5018 {
5019  memset(&globals, 0, sizeof(globals));
5020  globals.pool = pool;
5021 
5023  switch_core_hash_init(&globals.device_hash);
5024 }
#define switch_core_hash_init(_hash)
Definition: switch_core.h:1431
switch_memory_pool_t * pool
#define SWITCH_MUTEX_NESTED
Definition: switch_apr.h:318
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
Definition: switch_apr.c:293
static struct @1 globals
memset(buf, 0, buflen)

◆ switch_channel_global_uninit()

void switch_channel_global_uninit ( void  )

Definition at line 5026 of file switch_channel.c.

References globals, and switch_core_hash_destroy().

Referenced by switch_core_destroy().

5027 {
5028  switch_core_hash_destroy(&globals.device_hash);
5029 }
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
static struct @1 globals

◆ switch_channel_handle_cause()

void switch_channel_handle_cause ( switch_channel_t channel,
switch_call_cause_t  cause 
)

Definition at line 4876 of file switch_channel.c.

References CF_CONFIRM_BLIND_TRANSFER, CF_TRANSFER, CS_ROUTING, switch_channel::session, SWITCH_CAUSE_ATTENDED_TRANSFER, SWITCH_CAUSE_NO_ANSWER, SWITCH_CAUSE_NO_USER_RESPONSE, SWITCH_CAUSE_ORIGINATOR_CANCEL, switch_channel_cause2str(), switch_channel_get_state(), switch_channel_get_variable, switch_channel_hangup, SWITCH_CHANNEL_SESSION_LOG, switch_channel_test_flag(), switch_channel_up_nosig, switch_core_session_strdup, switch_ivr_session_transfer(), SWITCH_LOG_DEBUG, switch_log_printf(), switch_separate_string(), switch_snprintf(), switch_split, and switch_true().

Referenced by signal_bridge_on_hangup(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_multi_threaded_bridge(), and switch_ivr_orig_and_bridge().

4877 {
4878  switch_core_session_t *session = channel->session;
4879  const char *transfer_on_fail = NULL;
4880  char *tof_data = NULL;
4881  char *tof_array[4] = { 0 };
4882  //int tof_arrayc = 0;
4883 
4884  if (!switch_channel_up_nosig(channel)) {
4885  return;
4886  }
4887 
4888  transfer_on_fail = switch_channel_get_variable(channel, "transfer_on_fail");
4889  tof_data = switch_core_session_strdup(session, transfer_on_fail);
4890  switch_split(tof_data, ' ', tof_array);
4891  transfer_on_fail = tof_array[0];
4892 
4893  /*
4894  if the variable continue_on_fail is set it can be:
4895  'true' to continue on all failures.
4896  'false' to not continue.
4897  A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
4898  failure_causes acts as the opposite version
4899  EXCEPTION... ATTENDED_TRANSFER never is a reason to continue.......
4900  */
4901  if (cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
4902  const char *continue_on_fail = NULL, *failure_causes = NULL;
4903 
4904  continue_on_fail = switch_channel_get_variable(channel, "continue_on_fail");
4905  failure_causes = switch_channel_get_variable(channel, "failure_causes");
4906 
4907  if (continue_on_fail || failure_causes) {
4908  const char *cause_str;
4909  char cause_num[35] = "";
4910 
4911  cause_str = switch_channel_cause2str(cause);
4912  switch_snprintf(cause_num, sizeof(cause_num), "%u", cause);
4913 
4914  if (failure_causes) {
4915  char *lbuf = switch_core_session_strdup(session, failure_causes);
4916  char *argv[256] = { 0 };
4917  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4918  int i, x = 0;
4919 
4920  for (i = 0; i < argc; i++) {
4921  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4922  x++;
4923  break;
4924  }
4925  }
4926  if (!x) {
4928  "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4929  return;
4930  }
4931  }
4932 
4933  if (continue_on_fail) {
4934  if (switch_true(continue_on_fail)) {
4935  return;
4936  } else {
4937  char *lbuf = switch_core_session_strdup(session, continue_on_fail);
4938  char *argv[256] = { 0 };
4939  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4940  int i;
4941 
4942  for (i = 0; i < argc; i++) {
4943  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4945  "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
4946  return;
4947  }
4948  }
4949  }
4950  }
4951  } else {
4952  /* no answer is *always* a reason to continue */
4954  return;
4955  }
4956  }
4957 
4958  if (transfer_on_fail || failure_causes) {
4959  const char *cause_str;
4960  char cause_num[35] = "";
4961 
4962  cause_str = switch_channel_cause2str(cause);
4963  switch_snprintf(cause_num, sizeof(cause_num), "%u", cause);
4964 
4965  if ((tof_array[1] == NULL ) || (!strcasecmp(tof_array[1], "auto_cause"))){
4966  tof_array[1] = (char *) cause_str;
4967  }
4968 
4969  if (failure_causes) {
4970  char *lbuf = switch_core_session_strdup(session, failure_causes);
4971  char *argv[256] = { 0 };
4972  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4973  int i, x = 0;
4974 
4975  for (i = 0; i < argc; i++) {
4976  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4977  x++;
4978  break;
4979  }
4980  }
4981  if (!x) {
4983  "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4984 
4985  switch_ivr_session_transfer(session, tof_array[1], tof_array[2], tof_array[3]);
4986  }
4987  }
4988 
4989  if (transfer_on_fail) {
4990  if (switch_true(transfer_on_fail)) {
4991  return;
4992  } else {
4993  char *lbuf = switch_core_session_strdup(session, transfer_on_fail);
4994  char *argv[256] = { 0 };
4995  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4996  int i;
4997 
4998  for (i = 0; i < argc; i++) {
4999  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
5001  "Transfer on fail [%s]: Cause: %s\n", transfer_on_fail, cause_str);
5002  switch_ivr_session_transfer(session, tof_array[1], tof_array[2], tof_array[3]);
5003  }
5004  }
5005  }
5006  }
5007  }
5008  }
5009 
5010 
5012  switch_channel_get_state(channel) != CS_ROUTING) {
5013  switch_channel_hangup(channel, cause);
5014  }
5015 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_split(_data, _delim, _array)
Definition: switch_utils.h:375
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_status_t switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
Transfer an existing session to another location.
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
#define switch_channel_get_variable(_c, _v)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
#define switch_channel_up_nosig(_channel)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
switch_core_session_t * session
const char * switch_channel_cause2str(switch_call_cause_t cause)

◆ switch_channel_pass_sdp()

switch_status_t switch_channel_pass_sdp ( switch_channel_t from_channel,
switch_channel_t to_channel,
const char *  sdp 
)

Definition at line 5551 of file switch_channel.c.

References switch_channel::session, SWITCH_B_SDP_VARIABLE, switch_channel_get_variable, switch_channel_set_variable, switch_core_media_process_sdp_filter(), switch_safe_free, and SWITCH_STATUS_FALSE.

Referenced by switch_core_session_outgoing_channel().

5552 {
5554  char *use_sdp = (char *) sdp;
5555  char *patched_sdp = NULL;
5556 
5558  const char *var;
5559 
5560  if ((var = switch_channel_get_variable(from_channel, "bypass_media_sdp_filter"))) {
5561  if ((patched_sdp = switch_core_media_process_sdp_filter(use_sdp, var, from_channel->session))) {
5562  use_sdp = patched_sdp;
5563  }
5564  }
5565 
5566  switch_channel_set_variable(to_channel, SWITCH_B_SDP_VARIABLE, use_sdp);
5567  }
5568 
5569  switch_safe_free(patched_sdp);
5570 
5571  return status;
5572 }
char * switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session)
#define switch_channel_get_variable(_c, _v)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
switch_status_t
Common return values.
#define SWITCH_B_SDP_VARIABLE
Definition: switch_types.h:199
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session

◆ switch_channel_process_device_hangup()

void switch_channel_process_device_hangup ( switch_channel_t channel)

Definition at line 5173 of file switch_channel.c.

References switch_channel::callstate, process_device_hup(), and switch_channel_check_device_state().

Referenced by switch_core_session_hangup_state().

5174 {
5175 
5176  switch_channel_check_device_state(channel, channel->callstate);
5177  process_device_hup(channel);
5178 
5179 }
static void process_device_hup(switch_channel_t *channel)
static void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
switch_channel_callstate_t callstate

◆ switch_channel_release_device_record()

void switch_channel_release_device_record ( switch_device_record_t **  dcdrp)

Definition at line 5492 of file switch_channel.c.

References switch_mutex_unlock().

5493 {
5494  if (drecp && *drecp) {
5495  switch_mutex_unlock((*drecp)->mutex);
5496  *drecp = NULL;
5497  }
5498 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313

◆ switch_channel_set_device_id()

const char* switch_channel_set_device_id ( switch_channel_t channel,
const char *  device_id 
)

Definition at line 5454 of file switch_channel.c.

References add_uuid(), switch_channel::callstate, create_device_record(), switch_device_record_s::device_id, switch_channel::device_id, switch_channel::device_node, globals, switch_channel::session, SWITCH_CHANNEL_CHANNEL_LOG, switch_channel_check_device_state(), switch_core_hash_find(), switch_core_hash_insert, switch_core_session_strdup, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_channel_set_profile_var().

5455 {
5456  switch_device_record_t *drec;
5457 
5458  if (channel->device_node) {
5459  return NULL;
5460  }
5461 
5462  channel->device_id = switch_core_session_strdup(channel->session, device_id);
5463 
5464  switch_mutex_lock(globals.device_mutex);
5465 
5466  if (!(drec = switch_core_hash_find(globals.device_hash, channel->device_id))) {
5467  create_device_record(&drec, channel->device_id);
5468  switch_core_hash_insert(globals.device_hash, drec->device_id, drec);
5469  }
5470 
5471  add_uuid(drec, channel);
5472 
5473  switch_mutex_unlock(globals.device_mutex);
5474 
5475  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Setting DEVICE ID to [%s]\n", device_id);
5476 
5477  switch_channel_check_device_state(channel, channel->callstate);
5478 
5479  return device_id;
5480 }
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
static struct @1 globals
static void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
static void add_uuid(switch_device_record_t *drec, switch_channel_t *channel)
static switch_status_t create_device_record(switch_device_record_t **drecp, const char *device_id)
#define switch_core_hash_insert(_h, _k, _d)
Definition: switch_core.h:1479
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_device_node_t * device_node
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
switch_channel_callstate_t callstate
switch_core_session_t * session
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_state_thread_lock()

void switch_channel_state_thread_lock ( switch_channel_t channel)

Definition at line 2640 of file switch_channel.c.

References switch_mutex_lock(), and switch_channel::thread_mutex.

Referenced by switch_core_session_run().

2641 {
2642  switch_mutex_lock(channel->thread_mutex);
2643 }
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_mutex_t * thread_mutex

◆ switch_channel_state_thread_trylock()

switch_status_t switch_channel_state_thread_trylock ( switch_channel_t channel)

Definition at line 2646 of file switch_channel.c.

References switch_mutex_trylock(), and switch_channel::thread_mutex.

Referenced by switch_core_session_wake_session_thread().

2647 {
2648  return switch_mutex_trylock(channel->thread_mutex);
2649 }
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
Definition: switch_apr.c:318
switch_mutex_t * thread_mutex

◆ switch_channel_state_thread_unlock()

void switch_channel_state_thread_unlock ( switch_channel_t channel)

Definition at line 2652 of file switch_channel.c.

References switch_mutex_unlock(), and switch_channel::thread_mutex.

Referenced by switch_core_session_run(), and switch_core_session_wake_session_thread().

2653 {
2655 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_mutex_t * thread_mutex

◆ switch_channel_transfer_to_extension()

void switch_channel_transfer_to_extension ( switch_channel_t channel,
switch_caller_extension_t caller_extension 
)

Definition at line 3324 of file switch_channel.c.

References CF_TRANSFER, CS_ROUTING, switch_channel::profile_mutex, switch_channel::queued_extension, switch_channel_set_flag, switch_channel_set_state, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_parse_event().

3325 {
3326  switch_mutex_lock(channel->profile_mutex);
3327  channel->queued_extension = caller_extension;
3329 
3332 }
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_caller_extension_t * queued_extension
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_channel_set_flag(_c, _f)

◆ switch_channel_unbind_device_state_handler()

switch_status_t switch_channel_unbind_device_state_handler ( switch_device_state_function_t  function)

Definition at line 5526 of file switch_channel.c.

References switch_device_state_binding_s::function, globals, switch_device_state_binding_s::next, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

5527 {
5528  switch_device_state_binding_t *ptr, *last = NULL;
5530 
5531  switch_mutex_lock(globals.device_mutex);
5532  for (ptr = globals.device_bindings; ptr; ptr = ptr->next) {
5533  if (ptr->function == function) {
5534  status = SWITCH_STATUS_SUCCESS;
5535 
5536  if (last) {
5537  last->next = ptr->next;
5538  } else {
5539  globals.device_bindings = ptr->next;
5540  last = NULL;
5541  continue;
5542  }
5543  }
5544  last = ptr;
5545  }
5546  switch_mutex_unlock(globals.device_mutex);
5547 
5548  return status;
5549 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_device_state_function_t function
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
static struct @1 globals
switch_status_t
Common return values.
struct switch_device_state_binding_s * next