RTS API Documentation  1.10.11
Macros | Functions
Channel Functions
+ Collaboration diagram for Channel Functions:

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__)
 

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)
 

Detailed Description

The switch_channel object is a private entity that belongs to a session that contains the call specific information such as the call state, variables, caller profiles and DTMF queue

Macro Definition Documentation

◆ switch_channel_acknowledge_call

#define switch_channel_acknowledge_call (   channel)    switch_channel_perform_acknowledge_call(channel, __FILE__, __SWITCH_FUNC__, __LINE__)

Definition at line 481 of file switch_channel.h.

◆ switch_channel_answer

#define switch_channel_answer (   channel)    switch_channel_perform_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)

Answer a channel (initiate/acknowledge a successful connection)

Parameters
channelchannel to answer
Returns
SWITCH_STATUS_SUCCESS if channel was answered successfully

Definition at line 463 of file switch_channel.h.

Referenced by CoreSession::answer(), audio_bridge_thread(), check_channel_status(), fs_channel_answer(), switch_ivr_intercept_session(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_ivr_process_indications(), and SWITCH_STANDARD_APP().

◆ switch_channel_audio_sync

#define switch_channel_audio_sync (   _c)    switch_channel_perform_audio_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)

◆ switch_channel_clear_app_flag

#define switch_channel_clear_app_flag (   _c,
  _f 
)    switch_channel_clear_app_flag_key(__FILE__, _c, _f)

Definition at line 680 of file switch_channel.h.

◆ switch_channel_down

#define switch_channel_down (   _channel)    (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) >= CS_HANGUP)

◆ switch_channel_down_nosig

#define switch_channel_down_nosig (   _channel)    (switch_channel_get_state(_channel) >= CS_HANGUP)

◆ switch_channel_expand_variables

#define switch_channel_expand_variables (   _channel,
  _in 
)    switch_channel_expand_variables_check(_channel, _in, NULL, NULL, 0)

◆ switch_channel_export_variable

#define switch_channel_export_variable (   _channel,
  _varname,
  _value,
  _ev 
)    switch_channel_export_variable_var_check(_channel, _varname, _value, _ev, SWITCH_TRUE)

Definition at line 312 of file switch_channel.h.

Referenced by switch_channel_export_variable_printf().

◆ switch_channel_get_variable

#define switch_channel_get_variable (   _c,
  _v 
)    switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE, -1)

Definition at line 326 of file switch_channel.h.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb(), check_media_timeout_params(), check_stream_changes(), fs_channel_get_variable(), fs_switch_channel_get_variable(), fs_switch_ivr_originate(), get_recording_var(), CoreSession::getVariable(), handle_ice(), hanguphook(), inherit_codec(), limit_state_handler(), monitor_callback(), play_and_collect(), play_and_detect_input_callback(), record_helper_post_process(), recover_callback(), rtp_common_read(), rtp_common_write(), sb_on_dtmf(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), speech_thread(), CoreSession::streamFile(), switch_channel_caller_extension_masquerade(), switch_channel_export_variable_var_check(), switch_channel_flip_cid(), switch_channel_get_hold_music(), switch_channel_get_partner_uuid(), switch_channel_get_variable_partner(), switch_channel_handle_cause(), switch_channel_mark_hold(), switch_channel_pass_sdp(), switch_channel_perform_answer(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_presence(), switch_channel_process_export(), switch_channel_set_presence_data_vals(), switch_channel_set_timestamps(), switch_core_media_absorb_sdp(), switch_core_media_activate_rtp(), switch_core_media_bug_add(), switch_core_media_build_crypto(), switch_core_media_check_autoadj(), switch_core_media_check_dtmf_type(), switch_core_media_check_outgoing_proxy(), switch_core_media_choose_port(), switch_core_media_gen_local_sdp(), switch_core_media_get_codec_string(), switch_core_media_negotiate_sdp(), switch_core_media_parse_media_flags(), switch_core_media_prepare_codecs(), switch_core_media_proxy_remote_addr(), switch_core_media_read_frame(), switch_core_media_receive_message(), switch_core_media_recover_session(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_udptl_image_sdp(), switch_core_media_start_udptl(), switch_core_media_toggle_hold(), switch_core_session_enable_heartbeat(), switch_core_session_exec(), switch_core_session_get_recovery_crypto_key(), switch_core_session_hangup_state(), switch_core_session_hupall_matching_vars_ans(), switch_core_session_outgoing_channel(), switch_core_session_parse_codec_settings(), switch_core_session_parse_crypto_prefs(), switch_core_session_perform_receive_message(), switch_core_session_reporting_state(), switch_core_session_sched_heartbeat(), switch_core_session_thread(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_event_add_presence_data_cols(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_blind_transfer_ack(), switch_ivr_collect_digits_count(), switch_ivr_delay_echo(), switch_ivr_detect_speech(), switch_ivr_detect_speech_init(), switch_ivr_displace_session(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_find_bridged_uuid(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_orig_and_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_event(), switch_ivr_phrase_macro_event(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_transfer(), switch_ivr_sleep(), switch_ivr_speak_text(), switch_ivr_speak_text_handle(), switch_ivr_tone_detect_session(), switch_ivr_transfer_recordings(), switch_ivr_transfer_variable(), switch_ivr_wait_for_answer(), switch_limit_incr(), switch_log_node_to_json(), switch_play_and_get_digits(), switch_process_import(), switch_rtp_add_crypto_key(), switch_rtp_add_dtls(), switch_rtp_enable_vad(), switch_rtp_set_flag(), switch_rtp_set_local_address(), SWITCH_STANDARD_APP(), uuid_bridge_on_soft_execute(), video_helper_thread(), and video_write_thread().

◆ switch_channel_hangup

#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.

Parameters
channelchannel to hangup
hangup_causethe appropriate hangup cause
Returns
the resulting channel state.

Definition at line 589 of file switch_channel.h.

Referenced by abort_call(), audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_per_channel_timeouts(), check_timeout(), cleanup_proxy_mode_a(), collect_thread_run(), CoreSession::destroy(), dtls_state_fail(), eavesdrop_callback(), enterprise_originate_thread(), fs_channel_hangup(), fs_switch_ivr_originate(), CoreSession::hangup(), monitor_callback(), read_bundle_rtp_packet(), read_rtp_packet(), record_callback(), recording_thread(), setup_ringback(), signal_bridge_on_hangup(), switch_channel_handle_cause(), switch_channel_perform_answer(), switch_channel_perform_pre_answer(), switch_channel_perform_ring_ready_value(), switch_core_media_activate_rtp(), switch_core_media_choose_ports(), switch_core_media_negotiate_sdp(), switch_core_media_process_t38_passthru(), switch_core_media_read_frame(), switch_core_media_set_codec(), switch_core_session_execute_application_get_flags(), switch_core_session_hupall(), switch_core_session_hupall_endpoint(), switch_core_session_hupall_matching_vars_ans(), switch_core_session_read_frame(), switch_core_session_run(), switch_core_session_write_frame(), switch_core_standard_on_execute(), switch_core_standard_on_routing(), switch_ivr_displace_session(), switch_ivr_intercept_session(), switch_ivr_kill_uuid(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_event(), switch_ivr_process_indications(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_wait_for_answer(), switch_rtp_add_dtls(), SWITCH_STANDARD_SCHED_FUNC(), text_bridge_thread(), and uuid_bridge_on_soft_execute().

◆ switch_channel_inbound_display

#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)))

Definition at line 656 of file switch_channel.h.

Referenced by switch_ivr_uuid_bridge().

◆ switch_channel_mark_answered

#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)

Parameters
channelchannel to mark answered
Returns
SWITCH_STATUS_SUCCESS if channel was answered successfully

Definition at line 470 of file switch_channel.h.

◆ switch_channel_mark_pre_answered

#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)

Parameters
channelchannel to mark pre_answered
Returns
SWITCH_STATUS_SUCCESS if channel was pre_answered successfully

Definition at line 477 of file switch_channel.h.

◆ switch_channel_mark_ring_ready

#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.

Parameters
channelchannel
Returns
SWITCH_STATUS_SUCCESS

Definition at line 516 of file switch_channel.h.

◆ switch_channel_mark_ring_ready_value

#define switch_channel_mark_ring_ready_value (   channel,
  _rv 
)    switch_channel_perform_mark_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)

Definition at line 519 of file switch_channel.h.

◆ switch_channel_media_ack

#define switch_channel_media_ack (   _channel)    (!switch_channel_test_cap(_channel, CC_MEDIA_ACK) || switch_channel_test_flag(_channel, CF_MEDIA_ACK))

Definition at line 94 of file switch_channel.h.

Referenced by audio_bridge_thread(), and switch_ivr_eavesdrop_session().

◆ switch_channel_media_ready

#define switch_channel_media_ready (   _channel)    switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE)

◆ switch_channel_media_up

#define switch_channel_media_up (   _channel)    (switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA))

◆ switch_channel_outbound_display

#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)))

Definition at line 658 of file switch_channel.h.

Referenced by switch_ivr_uuid_bridge().

◆ switch_channel_pre_answer

#define switch_channel_pre_answer (   channel)    switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)

◆ switch_channel_presence

#define switch_channel_presence (   _a,
  _b,
  _c,
  _d 
)    switch_channel_perform_presence(_a, _b, _c, _d, __FILE__, __SWITCH_FUNC__, __LINE__)

◆ switch_channel_ready

#define switch_channel_ready (   _channel)    switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE)

◆ switch_channel_ring_ready

#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.

Parameters
channelchannel to ring
Returns
SWITCH_STATUS_SUCCESS if successful

Definition at line 491 of file switch_channel.h.

Referenced by check_channel_status(), and switch_ivr_process_indications().

◆ switch_channel_ring_ready_value

#define switch_channel_ring_ready_value (   channel,
  _rv 
)    switch_channel_perform_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)

Definition at line 492 of file switch_channel.h.

Referenced by check_channel_status().

◆ switch_channel_set_app_flag

#define switch_channel_set_app_flag (   _c,
  _f 
)    switch_channel_set_app_flag_key(__FILE__, _c, _f)

Definition at line 679 of file switch_channel.h.

◆ switch_channel_set_callstate

#define switch_channel_set_callstate (   channel,
  state 
)    switch_channel_perform_set_callstate(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)

◆ switch_channel_set_cap

#define switch_channel_set_cap (   _c,
  _cc 
)    switch_channel_set_cap_value(_c, _cc, 1)

Definition at line 413 of file switch_channel.h.

◆ switch_channel_set_flag

#define switch_channel_set_flag (   _c,
  _f 
)    switch_channel_set_flag_value(_c, _f, 1)

Definition at line 408 of file switch_channel.h.

Referenced by add_uuid(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb(), check_stream_changes(), collect_thread_run(), enterprise_originate_ringback_thread(), process_device_hup(), process_rtcp_report(), recover_callback(), signal_bridge_on_hangup(), switch_channel_init(), switch_channel_mark_hold(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_set_flag_partner(), switch_channel_set_timestamps(), switch_channel_sort_cid(), switch_channel_transfer_to_extension(), switch_core_media_activate_rtp(), switch_core_media_bug_pause(), switch_core_media_build_crypto(), switch_core_media_check_outgoing_proxy(), switch_core_media_check_video_codecs(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_patch_sdp(), switch_core_media_proxy_remote_addr(), switch_core_media_read_frame(), switch_core_media_receive_message(), switch_core_media_recover_session(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_smode(), switch_core_media_set_video_file(), switch_core_media_toggle_hold(), switch_core_recovery_track(), switch_core_service_session_av(), switch_core_service_thread(), switch_core_session_check_incoming_crypto(), switch_core_session_check_outgoing_crypto(), switch_core_session_execute_application_async(), switch_core_session_get_recovery_crypto_key(), switch_core_session_outgoing_channel(), switch_core_session_perform_receive_message(), switch_core_session_read_text_frame(), switch_core_session_read_video_frame(), switch_core_session_reporting_state(), switch_core_session_request_uuid(), switch_core_session_request_xml(), switch_core_session_run(), switch_core_session_send_dtmf(), switch_core_session_set_ice(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_wake_session_thread(), switch_core_standard_on_execute(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_activate_unicast(), switch_ivr_bridge_bleg(), switch_ivr_broadcast(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_hold(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_orig_and_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_park_session(), switch_ivr_parse_event(), switch_ivr_parse_signal_data(), switch_ivr_record_file_event(), switch_ivr_session_echo(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_sleep(), switch_ivr_uuid_bridge(), switch_media_handle_create(), SWITCH_STANDARD_APP(), text_helper_thread(), video_helper_thread(), and video_write_thread().

◆ switch_channel_set_running_state

#define switch_channel_set_running_state (   channel,
  state 
)    switch_channel_perform_set_running_state(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)

Definition at line 113 of file switch_channel.h.

Referenced by switch_core_session_destroy_state(), and switch_core_session_run().

◆ switch_channel_set_state

#define switch_channel_set_state (   channel,
  state 
)    switch_channel_perform_set_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__, state)

◆ switch_channel_set_variable

#define switch_channel_set_variable (   _channel,
  _var,
  _val 
)    switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_TRUE)

Definition at line 299 of file switch_channel.h.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb(), check_presence(), check_stream_changes(), cleanup_proxy_mode_a(), collect_thread_run(), enterprise_originate_thread(), fs_channel_set_variable(), fs_switch_channel_set_variable(), handle_ice(), inherit_codec(), limit_state_handler(), monitor_callback(), record_callback(), rtp_common_read(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), switch_channel_alloc(), switch_channel_caller_extension_masquerade(), switch_channel_clear_flag(), switch_channel_clear_flag_recursive(), switch_channel_del_variable_prefix(), switch_channel_export_variable_var_check(), switch_channel_flip_cid(), switch_channel_pass_sdp(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_process_export(), switch_channel_set_direction(), switch_channel_set_flag_recursive(), switch_channel_set_flag_value(), switch_channel_set_name(), switch_channel_set_timestamps(), switch_channel_set_variable_name_printf(), switch_channel_set_variable_printf(), switch_channel_transfer_variable_prefix(), switch_core_media_activate_rtp(), switch_core_media_choose_port(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_prepare_codecs(), switch_core_media_process_t38_passthru(), switch_core_media_process_udptl(), switch_core_media_receive_message(), switch_core_media_set_codec(), switch_core_media_set_local_sdp(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_rmode(), switch_core_media_set_smode(), switch_core_media_set_video_codec(), switch_core_session_apply_crypto(), switch_core_session_check_incoming_crypto(), switch_core_session_clear_crypto(), switch_core_session_exec(), switch_core_session_hangup_state(), switch_core_session_outgoing_channel(), switch_core_session_perform_receive_message(), switch_core_session_request_uuid(), switch_core_session_request_xml(), switch_core_session_send_dtmf_string(), switch_core_session_set_external_id(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_standard_on_execute(), switch_core_standard_on_reset(), switch_core_standard_on_routing(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_detect_audio(), switch_ivr_detect_silence(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_intercept_session(), switch_ivr_menu_execute(), switch_ivr_multi_threaded_bridge(), switch_ivr_orig_and_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_event(), switch_ivr_phrase_macro_event(), switch_ivr_play_file(), switch_ivr_read(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_transfer(), switch_ivr_set_user_xml(), switch_ivr_signal_bridge(), switch_ivr_transfer_recordings(), switch_ivr_transfer_variable(), switch_ivr_uuid_bridge(), switch_ivr_wait_for_silence(), switch_limit_incr(), switch_media_handle_create(), switch_play_and_get_digits(), switch_process_import(), switch_rtp_add_crypto_key(), transfer_after_bridge(), and uuid_bridge_on_soft_execute().

◆ switch_channel_set_variable_partner

#define switch_channel_set_variable_partner (   _channel,
  _var,
  _val 
)    switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)

◆ switch_channel_set_variable_safe

#define switch_channel_set_variable_safe (   _channel,
  _var,
  _val 
)    switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_FALSE)

Definition at line 298 of file switch_channel.h.

◆ switch_channel_set_variable_strip_quotes

#define switch_channel_set_variable_strip_quotes (   _channel,
  _var,
  _val 
)    switch_channel_set_variable_strip_quotes_var_check(_channel, _var, _val, SWITCH_TRUE)

Definition at line 300 of file switch_channel.h.

◆ switch_channel_stop_broadcast

#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;}

◆ switch_channel_test_app_flag

#define switch_channel_test_app_flag (   _c,
  _f 
)    switch_channel_test_app_flag_key(__FILE__, _c, _f)

Definition at line 681 of file switch_channel.h.

◆ switch_channel_text_only

#define switch_channel_text_only (   _channel)    (switch_channel_test_flag(_channel, CF_HAS_TEXT) && !switch_channel_test_flag(_channel, CF_AUDIO))

Definition at line 96 of file switch_channel.h.

Referenced by switch_core_session_execute_application_get_flags().

◆ switch_channel_up

#define switch_channel_up (   _channel)    (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) < CS_HANGUP)

◆ switch_channel_up_nosig

#define switch_channel_up_nosig (   _channel)    (switch_channel_get_state(_channel) < CS_HANGUP)

◆ switch_channel_video_sync

#define switch_channel_video_sync (   _c)    switch_channel_perform_video_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)

Function Documentation

◆ switch_channel_add_state_handler()

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

Parameters
channelchannel on which to add the state handler table
state_handlertable of state handler functions
Returns
the index number/priority of the table negative value indicates failure

Definition at line 3043 of file switch_channel.c.

References index, state_handler_index, state_handlers, state_mutex, switch_assert, SWITCH_MAX_STATE_HANDLERS, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_ivr_signal_bridge(), and switch_ivr_uuid_bridge().

3044 {
3045  int x, index;
3046 
3047  switch_assert(channel != NULL);
3048  switch_mutex_lock(channel->state_mutex);
3049  for (x = 0; x < SWITCH_MAX_STATE_HANDLERS; x++) {
3050  if (channel->state_handlers[x] == state_handler) {
3051  index = x;
3052  goto end;
3053  }
3054  }
3055  index = channel->state_handler_index++;
3056 
3057  if (channel->state_handler_index >= SWITCH_MAX_STATE_HANDLERS) {
3058  index = -1;
3059  goto end;
3060  }
3061 
3062  channel->state_handlers[index] = state_handler;
3063 
3064  end:
3065  switch_mutex_unlock(channel->state_mutex);
3066  return index;
3067 }
switch_mutex_t * state_mutex
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:592
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
int index
Definition: switch_cJSON.h:160
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
#define switch_assert(expr)

◆ switch_channel_add_variable_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 
)

Definition at line 1562 of file switch_channel.c.

References profile_mutex, switch_assert, SWITCH_CHANNEL_CHANNEL_LOG, switch_event_add_header_string(), switch_event_base_add_header(), switch_event_del_header, SWITCH_LOG_CRIT, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_string_var_check_const(), variables, and zstr.

Referenced by switch_ivr_originate(), switch_ivr_session_transfer(), switch_ivr_uuid_bridge(), and switch_regex_set_var_callback().

1564 {
1566 
1567  switch_assert(channel != NULL);
1568 
1569  switch_mutex_lock(channel->profile_mutex);
1570  if (channel->variables && !zstr(varname)) {
1571  if (zstr(value)) {
1572  switch_event_del_header(channel->variables, varname);
1573  } else {
1574  int ok = 1;
1575 
1576  if (var_check) {
1578  }
1579  if (ok) {
1580  switch_event_add_header_string(channel->variables, stack, varname, value);
1581  } else {
1582  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname);
1583  }
1584  }
1585  status = SWITCH_STATUS_SUCCESS;
1586  }
1588 
1589  return status;
1590 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
const char *const const char *const const cJSON *const value
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
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
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 switch_bool_t switch_string_var_check_const(const char *s)
Definition: switch_utils.h:788
switch_status_t
Common return values.
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_assert(expr)
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_alloc()

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.

Parameters
channelNULL pointer to allocate channel to
poolmemory_pool to use for allocation
Returns
SWITCH_STATUS_SUCCESS if successful

Referenced by switch_core_session_request_uuid().

◆ switch_channel_build_param_string()

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_channel_caller_extension_masquerade()

switch_status_t switch_channel_caller_extension_masquerade ( switch_channel_t orig_channel,
switch_channel_t new_channel,
uint32_t  offset 
)

Definition at line 3139 of file switch_channel.c.

References switch_caller_application::application_data, switch_caller_application::application_name, caller_profile, switch_caller_profile::destination_number, switch_event::headers, switch_event_header::name, switch_event_header::next, switch_caller_application::next, switch_caller_profile::pool, profile_mutex, session, switch_assert, switch_caller_extension_add_application(), switch_caller_extension_new(), switch_caller_profile_clone(), switch_channel_get_caller_extension(), switch_channel_get_variable, switch_channel_set_caller_extension(), switch_channel_set_caller_profile(), switch_channel_set_variable, switch_core_session_strdup, switch_core_strdup, switch_mutex_lock(), switch_mutex_unlock(), switch_separate_string(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_event_header::value, and variables.

Referenced by switch_channel_var_true(), and switch_ivr_originate().

3140 {
3141  switch_caller_profile_t *caller_profile;
3142  switch_caller_extension_t *extension = NULL, *orig_extension = NULL;
3145  switch_event_header_t *hi = NULL;
3146  const char *no_copy = switch_channel_get_variable(orig_channel, "attended_transfer_no_copy");
3147  char *dup;
3148  int i, argc = 0;
3149  char *argv[128];
3150 
3151  if (no_copy) {
3152  dup = switch_core_session_strdup(new_channel->session, no_copy);
3153  argc = switch_separate_string(dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
3154  }
3155 
3156 
3157  switch_mutex_lock(orig_channel->profile_mutex);
3158  switch_mutex_lock(new_channel->profile_mutex);
3159 
3160 
3161  caller_profile = switch_caller_profile_clone(new_channel->session, new_channel->caller_profile);
3162  switch_assert(caller_profile);
3163  extension = switch_caller_extension_new(new_channel->session, caller_profile->destination_number, caller_profile->destination_number);
3164  orig_extension = switch_channel_get_caller_extension(orig_channel);
3165 
3166 
3167  if (extension && orig_extension) {
3168  for (ap = orig_extension->current_application; ap && offset > 0; offset--) {
3169  ap = ap->next;
3170  }
3171 
3172  for (; ap; ap = ap->next) {
3174  }
3175 
3176  caller_profile->destination_number = switch_core_strdup(caller_profile->pool, orig_channel->caller_profile->destination_number);
3177  switch_channel_set_caller_profile(new_channel, caller_profile);
3178  switch_channel_set_caller_extension(new_channel, extension);
3179 
3180  for (hi = orig_channel->variables->headers; hi; hi = hi->next) {
3181  int ok = 1;
3182  for (i = 0; i < argc; i++) {
3183  if (!strcasecmp(argv[i], hi->name)) {
3184  ok = 0;
3185  break;
3186  }
3187  }
3188 
3189  if (!ok)
3190  continue;
3191 
3192  switch_channel_set_variable(new_channel, hi->name, hi->value);
3193  }
3194 
3195  status = SWITCH_STATUS_SUCCESS;
3196  }
3197 
3198 
3199  switch_mutex_unlock(new_channel->profile_mutex);
3200  switch_mutex_unlock(orig_channel->profile_mutex);
3201 
3202 
3203  return status;
3204 }
switch_caller_extension_t * switch_channel_get_caller_extension(switch_channel_t *channel)
Retrieve caller extension from a given channel.
switch_event_t * variables
An Abstract Representation of a dialplan extension.
Call Specific Data.
Definition: switch_caller.h:73
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
switch_caller_profile_t * caller_profile
An event Header.
Definition: switch_event.h:65
An Abstract Representation of a dialplan Application.
switch_caller_profile_t * switch_caller_profile_clone(_In_ switch_core_session_t *session, _In_ switch_caller_profile_t *tocopy)
Clone an existing caller profile object.
void switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel&#39;s caller profile.
struct switch_caller_application * next
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
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.
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_channel_get_variable(_c, _v)
void switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
Assign a caller extension to a given channel.
void switch_caller_extension_add_application(_In_ switch_core_session_t *session, _In_ switch_caller_extension_t *caller_extension, _In_z_ const char *application_name, _In_z_ const char *extra_data)
Add an application (instruction) to the given extension.
switch_caller_extension_t * switch_caller_extension_new(_In_ switch_core_session_t *session, _In_z_ const char *extension_name, _In_z_ const char *extension_number)
Create a new extension with desired parameters.
switch_status_t
Common return values.
struct switch_event_header * next
Definition: switch_event.h:76
#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)
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
switch_event_header_t * headers
Definition: switch_event.h:90
switch_memory_pool_t * pool

◆ switch_channel_callstate2str()

const char* switch_channel_callstate2str ( switch_channel_callstate_t  callstate)

Definition at line 315 of file switch_channel.c.

References CALLSTATE_CHART, and switch_callstate_table::name.

Referenced by switch_channel_check_device_state(), switch_channel_event_set_basic_data(), and switch_channel_perform_set_callstate().

316 {
317  uint8_t x;
318  const char *str = "UNKNOWN";
319 
320  for (x = 0; x < (sizeof(CALLSTATE_CHART) / sizeof(struct switch_cause_table)) - 1; x++) {
321  if (CALLSTATE_CHART[x].callstate == callstate) {
322  str = CALLSTATE_CHART[x].name;
323  break;
324  }
325  }
326 
327  return str;
328 }
static struct switch_callstate_table CALLSTATE_CHART[]

◆ switch_channel_cause2str()

const char* switch_channel_cause2str ( _In_ switch_call_cause_t  cause)

◆ switch_channel_cause_q850()

switch_call_cause_t switch_channel_cause_q850 ( switch_call_cause_t  cause)

Definition at line 405 of file switch_channel.c.

References switch_cause_table::cause, SWITCH_CAUSE_INTERWORKING, and SWITCH_CAUSE_NORMAL_CLEARING.

Referenced by switch_channel_get_cause_q850().

406 {
407  if (cause <= SWITCH_CAUSE_INTERWORKING) {
408  return cause;
409  } else {
411  }
412 }

◆ switch_channel_check_signal()

int switch_channel_check_signal ( switch_channel_t channel,
switch_bool_t  in_thread_only 
)

Definition at line 2264 of file switch_channel.c.

References session, SWITCH_FALSE, and switch_ivr_parse_signal_data().

Referenced by switch_channel_test_ready(), and switch_channel_wait_for_state_timeout().

2265 {
2266  switch_ivr_parse_signal_data(channel->session, SWITCH_FALSE, in_thread_only);
2267  return 0;
2268 }
switch_status_t switch_ivr_parse_signal_data(switch_core_session_t *session, switch_bool_t all, switch_bool_t only_session_thread)
Definition: switch_ivr.c:869
switch_core_session_t * session

◆ switch_channel_clear_app_flag_key()

void switch_channel_clear_app_flag_key ( const char *  app,
switch_channel_t channel,
uint32_t  flags 
)

Definition at line 2094 of file switch_channel.c.

References app_flag_hash, flag_mutex, switch_assert, switch_core_hash_find(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_media_negotiate_sdp(), switch_core_media_reset_t38(), and switch_ivr_eavesdrop_update_display().

2095 {
2096  uint32_t *flagp = NULL;
2097 
2098  switch_assert(channel != NULL);
2099  switch_mutex_lock(channel->flag_mutex);
2100  if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
2101  if (!flags) {
2102  *flagp = 0;
2103  } else {
2104  *flagp &= ~flags;
2105  }
2106  }
2107  switch_mutex_unlock(channel->flag_mutex);
2108 }
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
switch_hash_t * app_flag_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
switch_mutex_t * flag_mutex
char * key
Definition: switch_msrp.c:64
#define switch_assert(expr)

◆ switch_channel_clear_cap()

void switch_channel_clear_cap ( switch_channel_t channel,
switch_channel_cap_t  cap 
)

Definition at line 1864 of file switch_channel.c.

References caps, flag_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

1865 {
1866  switch_assert(channel != NULL);
1867  switch_assert(channel->flag_mutex);
1868 
1869  switch_mutex_lock(channel->flag_mutex);
1870  channel->caps[cap] = 0;
1871  switch_mutex_unlock(channel->flag_mutex);
1872 }
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
switch_mutex_t * flag_mutex
uint32_t caps[CC_FLAG_MAX]
#define switch_assert(expr)

◆ switch_channel_clear_flag()

void switch_channel_clear_flag ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Clear given flag(s) from a channel.

Parameters
channelchannel to clear flags from
flagflag to clear

Definition at line 2145 of file switch_channel.c.

References caller_profile, CCS_ACTIVE, CCS_UNHELD, CF_ANSWERED, CF_BRIDGED, CF_DIALPLAN, CF_LEG_HOLDING, CF_NO_RECOVER, CF_ORIGINATOR, CF_OUTBOUND, CF_PROXY_MODE, CF_RECOVERED, CF_RECOVERING, CF_VIDEO, CF_VIDEO_PASSIVE, CF_VIDEO_READY, device_node, device_uuid_node_s::direction, direction, flag_mutex, flags, hangup_cause, switch_channel_timetable::hold_accum, hold_record, switch_channel_timetable::last_hold, logical_direction, switch_hold_record_s::off, profile_mutex, session, switch_assert, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_set_callstate, switch_channel_set_variable, switch_channel_test_flag(), switch_channel_up_nosig, switch_core_recovery_track(), switch_core_session_wake_video_thread(), switch_mutex_lock(), switch_mutex_unlock(), switch_time_now(), and switch_caller_profile::times.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_dtls_reinvite(), check_per_channel_timeouts(), check_stream_changes(), switch_channel_clear_flag_partner(), switch_channel_mark_hold(), switch_channel_perform_hangup(), switch_channel_perform_set_running_state(), switch_channel_sort_cid(), switch_core_media_activate_rtp(), switch_core_media_bug_resume(), switch_core_media_deactivate_rtp(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_receive_message(), switch_core_media_reset_t38(), switch_core_media_set_udptl_image_sdp(), switch_core_media_set_video_file(), switch_core_media_start_udptl(), switch_core_media_toggle_hold(), switch_core_recovery_untrack(), switch_core_service_thread(), switch_core_session_destroy_state(), switch_core_session_exec(), switch_core_session_outgoing_channel(), switch_core_session_perform_receive_message(), switch_core_session_read_text_frame(), switch_core_session_reset(), switch_core_session_run(), switch_core_session_send_dtmf(), switch_core_session_stop_media(), switch_core_session_video_reset(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_core_standard_on_init(), switch_core_standard_on_reset(), switch_core_thread_session_end(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_blind_transfer_ack(), switch_ivr_bridge_bleg(), switch_ivr_collect_digits_callback(), switch_ivr_deactivate_unicast(), switch_ivr_enterprise_originate(), switch_ivr_gentones(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_all_events(), switch_ivr_parse_event(), switch_ivr_parse_signal_data(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_session_echo(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_sleep(), switch_ivr_speak_text_handle(), switch_ivr_unhold(), switch_ivr_uuid_bridge(), switch_rtp_break(), SWITCH_STANDARD_APP(), text_bridge_thread(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), and video_write_thread().

2146 {
2147  int ACTIVE = 0;
2148  int CLEAR = 0;
2149 
2150  switch_assert(channel != NULL);
2151  switch_assert(channel->flag_mutex);
2152 
2153  switch_mutex_lock(channel->flag_mutex);
2154  if (flag == CF_LEG_HOLDING && channel->flags[flag] && channel->flags[CF_ANSWERED]) {
2155  ACTIVE = 1;
2156  }
2157 
2158  if (flag == CF_VIDEO_PASSIVE && channel->flags[CF_VIDEO]) {
2159  channel->flags[CF_VIDEO_READY] = 1;
2160 
2161  if (channel->flags[flag]) {
2162  CLEAR = 1;
2163  }
2164  }
2165 
2166  channel->flags[flag] = 0;
2167  switch_mutex_unlock(channel->flag_mutex);
2168 
2169  if (flag == CF_DIALPLAN) {
2170  if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
2172  if (channel->device_node) {
2174  }
2175  }
2176  }
2177 
2178  if (ACTIVE) {
2180  switch_mutex_lock(channel->profile_mutex);
2181  if (channel->caller_profile->times->last_hold) {
2183  }
2184 
2185  if (channel->hold_record) {
2186  channel->hold_record->off = switch_time_now();
2187  }
2188 
2191  }
2192 
2194  }
2195 
2196  if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
2198  }
2199 
2200  if (flag == CF_OUTBOUND) {
2201  switch_channel_set_variable(channel, "is_outbound", NULL);
2202  }
2203 
2204  if (flag == CF_RECOVERED) {
2205  switch_channel_set_variable(channel, "recovered", NULL);
2206  }
2207 
2208  if (flag == CF_VIDEO_PASSIVE && CLEAR) {
2210  }
2211 
2212  if (flag == CF_RECOVERING && !channel->hangup_cause && !switch_channel_test_flag(channel, CF_NO_RECOVER)) {
2214  }
2215 
2216 }
switch_caller_profile_t * caller_profile
switch_hold_record_t * hold_record
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_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_core_recovery_track(switch_core_session_t *session)
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_call_direction_t direction
Definition: switch_core.h:88
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_channel_set_callstate(channel, state)
void switch_core_session_wake_video_thread(switch_core_session_t *session)
switch_call_direction_t direction
struct switch_channel_timetable * times
switch_device_node_t * device_node
#define switch_channel_up_nosig(_channel)
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
Definition: switch_apr.c:325
switch_core_session_t * session
switch_time_t off
Definition: switch_core.h:76
switch_call_cause_t hangup_cause

◆ switch_channel_clear_flag_partner()

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.

Parameters
channelchannel to derive the partner channel to clear flag(s) from
flagthe flag to clear
Returns
true if the flag was cleared

Definition at line 1726 of file switch_channel.c.

References switch_assert, switch_channel_clear_flag(), switch_channel_get_partner_uuid(), switch_core_session_get_channel(), switch_core_session_locate, switch_core_session_rwunlock(), SWITCH_FALSE, and SWITCH_TRUE.

1727 {
1728  const char *uuid;
1729 
1730  switch_assert(channel != NULL);
1731 
1732  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1733  switch_core_session_t *session;
1734  if ((session = switch_core_session_locate(uuid))) {
1737  return SWITCH_TRUE;
1738  }
1739  }
1740 
1741  return SWITCH_FALSE;
1742 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
#define switch_assert(expr)

◆ switch_channel_clear_flag_recursive()

void switch_channel_clear_flag_recursive ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 2219 of file switch_channel.c.

References CF_OUTBOUND, flag_mutex, flags, switch_assert, switch_channel_set_variable, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by eavesdrop_callback(), hanguphook(), signal_bridge_on_hangup(), switch_core_media_bug_close(), switch_core_media_set_video_file(), switch_ivr_multi_threaded_bridge(), switch_ivr_parse_event(), switch_ivr_record_file_event(), switch_ivr_session_echo(), switch_jb_get_packet(), and text_bridge_thread().

2220 {
2221  switch_assert(channel != NULL);
2222  switch_assert(channel->flag_mutex);
2223 
2224  switch_mutex_lock(channel->flag_mutex);
2225  if (channel->flags[flag]) {
2226  channel->flags[flag]--;
2227  }
2228  switch_mutex_unlock(channel->flag_mutex);
2229 
2230  if (flag == CF_OUTBOUND) {
2231  switch_channel_set_variable(channel, "is_outbound", NULL);
2232  }
2233 }
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
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)

◆ switch_channel_clear_private_flag()

void switch_channel_clear_private_flag ( switch_channel_t channel,
uint32_t  flags 
)

Definition at line 2056 of file switch_channel.c.

References flag_mutex, private_flags, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

2057 {
2058  switch_assert(channel != NULL);
2059  switch_mutex_lock(channel->flag_mutex);
2060  channel->private_flags &= ~flags;
2061  switch_mutex_unlock(channel->flag_mutex);
2062 }
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
uint32_t private_flags
switch_mutex_t * flag_mutex
#define switch_assert(expr)

◆ switch_channel_clear_state_flag()

void switch_channel_clear_state_flag ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 2136 of file switch_channel.c.

References flag_mutex, state_flags, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_uuid_bridge().

2137 {
2138  switch_assert(channel != NULL);
2139 
2140  switch_mutex_lock(channel->flag_mutex);
2141  channel->state_flags[flag] = 0;
2142  switch_mutex_unlock(channel->flag_mutex);
2143 }
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
switch_mutex_t * flag_mutex
#define switch_assert(expr)
uint8_t state_flags[CF_FLAG_MAX]

◆ switch_channel_clear_state_handler()

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

Parameters
channelchannel from which to clear the state handler table
state_handlertable of state handler functions

Definition at line 3086 of file switch_channel.c.

References index, SSH_FLAG_STICKY, state_handler_index, state_handlers, state_mutex, switch_assert, SWITCH_MAX_STATE_HANDLERS, switch_mutex_lock(), switch_mutex_unlock(), and switch_test_flag.

Referenced by audio_bridge_on_exchange_media(), originate_on_consume_media_transmit(), switch_ivr_3p_media(), switch_ivr_media(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_uuid_bridge(), and uuid_bridge_on_soft_execute().

3087 {
3088  int index, i = channel->state_handler_index;
3089  const switch_state_handler_table_t *new_handlers[SWITCH_MAX_STATE_HANDLERS] = { 0 };
3090 
3091  switch_assert(channel != NULL);
3092 
3093  switch_mutex_lock(channel->state_mutex);
3094  channel->state_handler_index = 0;
3095 
3096  if (state_handler) {
3097  for (index = 0; index < i; index++) {
3098  if (channel->state_handlers[index] != state_handler) {
3099  new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
3100  }
3101  }
3102  } else {
3103  for (index = 0; index < i; index++) {
3104  if (channel->state_handlers[index] && switch_test_flag(channel->state_handlers[index], SSH_FLAG_STICKY)) {
3105  new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
3106  }
3107  }
3108  }
3109 
3110  for (index = 0; index < SWITCH_MAX_STATE_HANDLERS; index++) {
3111  channel->state_handlers[index] = NULL;
3112  }
3113 
3114  if (channel->state_handler_index > 0) {
3115  for (index = 0; index < channel->state_handler_index; index++) {
3116  channel->state_handlers[index] = new_handlers[index];
3117  }
3118  }
3119 
3120  switch_mutex_unlock(channel->state_mutex);
3121 }
switch_mutex_t * state_mutex
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:592
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
int index
Definition: switch_cJSON.h:160
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
#define switch_assert(expr)

◆ switch_channel_del_variable_prefix()

uint32_t switch_channel_del_variable_prefix ( switch_channel_t channel,
const char *  prefix 
)

Definition at line 1383 of file switch_channel.c.

References switch_event::headers, switch_event_header::name, switch_event_header::next, switch_channel_get_variables(), switch_channel_set_variable, switch_event_destroy(), and zstr.

1384 {
1385  switch_event_t *event;
1387  uint32_t r = 0;
1388 
1389  switch_channel_get_variables(channel, &event);
1390 
1391  if (event) {
1392  for (hp = event->headers; hp; hp = hp->next) {
1393  if (zstr(prefix) || !strncasecmp(hp->name, prefix, strlen(prefix))) {
1394  switch_channel_set_variable(channel, hp->name, NULL);
1395  }
1396  }
1397  }
1398 
1399  switch_event_destroy(&event);
1400 
1401  return r;
1402 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
#define zstr(x)
Definition: switch_utils.h:314
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.
#define switch_channel_set_variable(_channel, _var, _val)
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_channel_dequeue_dtmf()

switch_status_t switch_channel_dequeue_dtmf ( _In_ switch_channel_t channel,
_In_ switch_dtmf_t dtmf 
)

◆ switch_channel_dequeue_dtmf_string()

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 
)

◆ switch_channel_direction()

switch_call_direction_t switch_channel_direction ( switch_channel_t channel)

◆ switch_channel_dtmf_lock()

switch_status_t switch_channel_dtmf_lock ( switch_channel_t channel)

Definition at line 477 of file switch_channel.c.

References dtmf_mutex, and switch_mutex_lock().

Referenced by switch_core_session_read_frame().

478 {
479  return switch_mutex_lock(channel->dtmf_mutex);
480 }
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_mutex_t * dtmf_mutex

◆ switch_channel_dtmf_unlock()

switch_status_t switch_channel_dtmf_unlock ( switch_channel_t channel)

Definition at line 487 of file switch_channel.c.

References dtmf_mutex, and switch_mutex_unlock().

Referenced by switch_core_session_read_frame().

488 {
489  return switch_mutex_unlock(channel->dtmf_mutex);
490 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_mutex_t * dtmf_mutex

◆ switch_channel_event_set_basic_data()

void switch_channel_event_set_basic_data ( _In_ switch_channel_t channel,
_In_ switch_event_t event 
)

◆ switch_channel_event_set_data()

void switch_channel_event_set_data ( _In_ switch_channel_t channel,
_In_ switch_event_t event 
)

◆ switch_channel_event_set_extended_data()

void switch_channel_event_set_extended_data ( _In_ switch_channel_t channel,
_In_ switch_event_t event 
)

◆ switch_channel_expand_variables_check()

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.

Parameters
channelchannel to expand the variables from
inthe original string
Returns
the original string if no expansion takes place otherwise a new string that must be freed
Note
it's necessary to test if the return val is the same as the input and free the string if it is not.

Definition at line 3986 of file switch_channel.c.

References switch_stream_handle::data, end_of_p, in, memset(), resize, SCF_API_EXPANSION, session, switch_api_execute(), switch_assert, SWITCH_CHANNEL_CHANNEL_LOG, switch_channel_get_variable_dup(), switch_core_test_flag(), switch_event_check_permission_list(), SWITCH_LOG_CRIT, switch_log_printf(), switch_safe_free, SWITCH_STANDARD_STREAM, SWITCH_STATUS_SUCCESS, switch_string_has_escaped_data(), switch_string_var_check_const(), SWITCH_TRUE, and zstr.

3987 {
3988  char *p, *c = NULL;
3989  char *data, *indup, *endof_indup;
3990  size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128;
3991  char *cloned_sub_val = NULL, *sub_val = NULL, *expanded_sub_val = NULL;
3992  char *func_val = NULL, *sb = NULL;
3993  int nv = 0;
3994 
3995  if (recur > 100) {
3996  return (char *) in;
3997  }
3998 
3999  if (zstr(in)) {
4000  return (char *) in;
4001  }
4002 
4004 
4005  if (!nv) {
4006  return (char *) in;
4007  }
4008 
4009 
4010  nv = 0;
4011  olen = strlen(in) + 1;
4012  indup = strdup(in);
4013  endof_indup = end_of_p(indup) + 1;
4014 
4015  if ((data = malloc(olen))) {
4016  memset(data, 0, olen);
4017  c = data;
4018  for (p = indup; p && p < endof_indup && *p; p++) {
4019  int global = 0;
4020  vtype = 0;
4021 
4022  if (*p == '\\') {
4023  if (*(p + 1) == '$') {
4024  nv = 1;
4025  p++;
4026  if (*(p + 1) == '$') {
4027  p++;
4028  }
4029  } else if (*(p + 1) == '\'') {
4030  p++;
4031  continue;
4032  } else if (*(p + 1) == '\\') {
4033  if (len + 1 >= olen) {
4034  resize(1);
4035  }
4036 
4037  *c++ = *p++;
4038  len++;
4039  continue;
4040  }
4041  }
4042 
4043  if (*p == '$' && !nv) {
4044 
4045  if (*(p + 1) == '$') {
4046  p++;
4047  global++;
4048  }
4049 
4050  if (*(p + 1)) {
4051  if (*(p + 1) == '{') {
4052  vtype = global ? 3 : 1;
4053  } else {
4054  nv = 1;
4055  }
4056  } else {
4057  nv = 1;
4058  }
4059  }
4060 
4061  if (nv) {
4062  if (len + 1 >= olen) {
4063  resize(1);
4064  }
4065 
4066  *c++ = *p;
4067  len++;
4068  nv = 0;
4069  continue;
4070  }
4071 
4072  if (vtype) {
4073  char *s = p, *e, *vname, *vval = NULL;
4074  size_t nlen;
4075 
4076  s++;
4077 
4078  if ((vtype == 1 || vtype == 3) && *s == '{') {
4079  br = 1;
4080  s++;
4081  }
4082 
4083  e = s;
4084  vname = s;
4085  while (*e) {
4086  if (br == 1 && *e == '}') {
4087  br = 0;
4088  *e++ = '\0';
4089  break;
4090  }
4091 
4092  if (br > 0) {
4093  if (e != s && *e == '{') {
4094  br++;
4095  } else if (br > 1 && *e == '}') {
4096  br--;
4097  }
4098  }
4099 
4100  e++;
4101  }
4102  p = e > endof_indup ? endof_indup : e;
4103 
4104  vval = NULL;
4105  for(sb = vname; sb && *sb; sb++) {
4106  if (*sb == ' ') {
4107  vval = sb;
4108  break;
4109  } else if (*sb == '(') {
4110  vval = sb;
4111  br = 1;
4112  break;
4113  }
4114  }
4115 
4116  if (vval) {
4117  e = vval - 1;
4118  *vval++ = '\0';
4119  while (*e == ' ') {
4120  *e-- = '\0';
4121  }
4122  e = vval;
4123 
4124  while (e && *e) {
4125  if (*e == '(') {
4126  br++;
4127  } else if (br > 1 && *e == ')') {
4128  br--;
4129  } else if (br == 1 && *e == ')') {
4130  *e = '\0';
4131  break;
4132  }
4133  e++;
4134  }
4135 
4136  vtype = 2;
4137  }
4138 
4139  if (vtype == 1 || vtype == 3) {
4140  char *expanded = NULL;
4141  int offset = 0;
4142  int ooffset = 0;
4143  char *ptr;
4144  int idx = -1;
4145 
4146  if ((expanded = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list, recur+1)) == vname) {
4147  expanded = NULL;
4148  } else {
4149  vname = expanded;
4150  }
4151 
4152  if ((ptr = strchr(vname, ':'))) {
4153  *ptr++ = '\0';
4154  offset = atoi(ptr);
4155  if ((ptr = strchr(ptr, ':'))) {
4156  ptr++;
4157  ooffset = atoi(ptr);
4158  }
4159  }
4160 
4161  if ((ptr = strchr(vname, '[')) && strchr(ptr, ']')) {
4162  *ptr++ = '\0';
4163  idx = atoi(ptr);
4164  }
4165 
4166  if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
4167  if (var_list && !switch_event_check_permission_list(var_list, vname)) {
4168  sub_val = "<Variable Expansion Permission Denied>";
4169  }
4170 
4171  if ((expanded_sub_val = switch_channel_expand_variables_check(channel, sub_val, var_list, api_list, recur+1)) == sub_val) {
4172  expanded_sub_val = NULL;
4173  } else {
4174  sub_val = expanded_sub_val;
4175  }
4176 
4177  if (offset || ooffset) {
4178  cloned_sub_val = strdup(sub_val);
4179  switch_assert(cloned_sub_val);
4180  sub_val = cloned_sub_val;
4181  }
4182 
4183  if (offset >= 0) {
4184  if ((size_t) offset > strlen(sub_val)) {
4185  *sub_val = '\0';
4186  } else {
4187  sub_val += offset;
4188  }
4189  } else if ((size_t) abs(offset) <= strlen(sub_val)) {
4190  sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
4191  }
4192 
4193  if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
4194  if ((ptr = (char *) sub_val + ooffset)) {
4195  *ptr = '\0';
4196  }
4197  }
4198  }
4199 
4200  switch_safe_free(expanded);
4201  } else {
4202  switch_stream_handle_t stream = { 0 };
4203  char *expanded = NULL;
4204 
4205  SWITCH_STANDARD_STREAM(stream);
4206 
4207  if (stream.data) {
4208  char *expanded_vname = NULL;
4209 
4210  if ((expanded_vname = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list, recur+1)) == vname) {
4211  expanded_vname = NULL;
4212  } else {
4213  vname = expanded_vname;
4214  }
4215 
4216  if ((expanded = switch_channel_expand_variables_check(channel, vval, var_list, api_list, recur+1)) == vval) {
4217  expanded = NULL;
4218  } else {
4219  vval = expanded;
4220  }
4221 
4222  if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
4223  func_val = NULL;
4224  sub_val = "<API Execute Permission Denied>";
4225  free(stream.data);
4226  } else {
4227  if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) {
4228  func_val = stream.data;
4229  sub_val = func_val;
4230  } else {
4231  free(stream.data);
4232  }
4233  }
4234 
4235  switch_safe_free(expanded);
4236  switch_safe_free(expanded_vname);
4237 
4238  } else {
4239  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Memory Error!\n");
4240  free(data);
4241  free(indup);
4242  return (char *) in;
4243  }
4244  }
4245  if ((nlen = sub_val ? strlen(sub_val) : 0)) {
4246  if (len + nlen >= olen) {
4247  resize(nlen);
4248  }
4249 
4250  len += nlen;
4251  strcat(c, sub_val);
4252  c += nlen;
4253  }
4254 
4255  switch_safe_free(func_val);
4256  switch_safe_free(cloned_sub_val);
4257  switch_safe_free(expanded_sub_val);
4258  sub_val = NULL;
4259  vname = NULL;
4260  br = 0;
4261  }
4262 
4263  if (sp) {
4264  if (len + 1 >= olen) {
4265  resize(1);
4266  }
4267 
4268  *c++ = ' ';
4269  sp = 0;
4270  len++;
4271  }
4272 
4273  if (*p == '$') {
4274  p--;
4275  } else {
4276  if (len + 1 >= olen) {
4277  resize(1);
4278  }
4279 
4280  *c++ = *p;
4281  len++;
4282  }
4283  }
4284  }
4285  free(indup);
4286 
4287  return data;
4288 }
int switch_core_test_flag(int flag)
Definition: switch_core.c:1792
static int switch_string_has_escaped_data(const char *in)
Definition: switch_utils.h:384
switch_status_t switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
Execute a registered API command.
int switch_event_check_permission_list(switch_event_t *list, const char *name)
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.
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.
#define end_of_p(_s)
Definition: switch_utils.h:686
#define zstr(x)
Definition: switch_utils.h:314
#define resize(l)
switch_byte_t in
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
static switch_bool_t switch_string_var_check_const(const char *s)
Definition: switch_utils.h:788
#define SWITCH_STANDARD_STREAM(s)
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_assert(expr)
switch_core_session_t * session
memset(buf, 0, buflen)
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_export_variable_printf()

switch_status_t switch_channel_export_variable_printf ( switch_channel_t channel,
const char *  varname,
const char *  export_varname,
const char *  fmt,
  ... 
)

Definition at line 1357 of file switch_channel.c.

References switch_assert, switch_channel_export_variable, SWITCH_STATUS_FALSE, and switch_vasprintf().

1359 {
1361  char *data = NULL;
1362  va_list ap;
1363  int ret;
1364 
1365  switch_assert(channel != NULL);
1366 
1367  va_start(ap, fmt);
1368  ret = switch_vasprintf(&data, fmt, ap);
1369  va_end(ap);
1370 
1371  if (ret == -1) {
1372  return SWITCH_STATUS_FALSE;
1373  }
1374 
1375  status = switch_channel_export_variable(channel, varname, data, export_varname);
1376 
1377  free(data);
1378 
1379  return status;
1380 }
#define switch_channel_export_variable(_channel, _varname, _value, _ev)
int cJSON_bool fmt
Definition: switch_cJSON.h:150
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
switch_status_t
Common return values.
#define switch_assert(expr)

◆ switch_channel_export_variable_var_check()

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 
)

Definition at line 1309 of file switch_channel.c.

References session, switch_channel_get_variable, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable, switch_channel_set_variable_var_check(), switch_core_session_strdup, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mprintf(), switch_safe_free, and SWITCH_STATUS_SUCCESS.

1312 {
1313  char *var_name = NULL;
1314  const char *exports;
1315  char *var, *new_exports, *new_exports_d = NULL;
1316  int local = 1;
1317 
1318  exports = switch_channel_get_variable(channel, export_varname);
1319 
1320  var = switch_core_session_strdup(channel->session, varname);
1321 
1322  if (var) {
1323  if (!strncasecmp(var, "nolocal:", 8)) { /* remove this later ? */
1324  var_name = var + 8;
1325  local = 0;
1326  } else if (!strncasecmp(var, "_nolocal_", 9)) {
1327  var_name = var + 9;
1328  local = 0;
1329  } else {
1330  var_name = var;
1331  }
1332  }
1333 
1334  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "EXPORT (%s) %s[%s]=[%s]\n",
1335  export_varname, local ? "" : "(REMOTE ONLY) ",
1336  var_name ? var_name : "", val ? val : "UNDEF");
1337 
1338 
1339  switch_channel_set_variable_var_check(channel, var, val, var_check);
1340 
1341  if (var && val) {
1342  if (exports) {
1343  new_exports_d = switch_mprintf("%s,%s", exports, var);
1344  new_exports = new_exports_d;
1345  } else {
1346  new_exports = var;
1347  }
1348 
1349  switch_channel_set_variable(channel, export_varname, new_exports);
1350 
1351  switch_safe_free(new_exports_d);
1352  }
1353 
1354  return SWITCH_STATUS_SUCCESS;
1355 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
#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 switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
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_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)

◆ switch_channel_flip_cid()

void switch_channel_flip_cid ( switch_channel_t channel)

Definition at line 3236 of file switch_channel.c.

References switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, switch_caller_profile::caller_id_name, switch_caller_profile::caller_id_number, caller_profile, CF_BRIDGED, CF_RECOVERING, switch_caller_profile::pool, profile_mutex, session, SWITCH_BLANK_STRING, switch_channel_event_set_data(), switch_channel_get_name(), switch_channel_get_partner_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable, switch_channel_test_flag(), switch_core_strdup, switch_event_add_header_string(), SWITCH_EVENT_CALL_UPDATE, switch_event_create, switch_event_fire, SWITCH_LOG_INFO, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_SUCCESS, switch_str_nil, and switch_true().

Referenced by switch_channel_sort_cid(), switch_channel_var_true(), and switch_ivr_uuid_bridge().

3237 {
3238  switch_event_t *event;
3239  const char *tmp = NULL;
3240 
3241  switch_mutex_lock(channel->profile_mutex);
3242 
3243  if (switch_channel_test_flag(channel, CF_RECOVERING) && switch_true(switch_channel_get_variable(channel, "channel_cid_flipped"))) {
3245  return;
3246  }
3247 
3248  if (channel->caller_profile->callee_id_name) {
3249  tmp = channel->caller_profile->caller_id_name;
3250  switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name);
3252  }
3253 
3254  if (switch_channel_test_flag(channel, CF_BRIDGED)) {
3256  } else if (tmp) {
3257  channel->caller_profile->callee_id_name = tmp;
3258  }
3259 
3260  if (channel->caller_profile->callee_id_number) {
3261  tmp = channel->caller_profile->caller_id_number;
3262  switch_channel_set_variable(channel, "pre_transfer_caller_id_number", channel->caller_profile->caller_id_number);
3264  }
3265 
3266  if (switch_channel_test_flag(channel, CF_BRIDGED)) {
3268  } else if (tmp) {
3269  channel->caller_profile->callee_id_number = tmp;
3270  }
3271 
3272  switch_channel_set_variable(channel, "channel_cid_flipped", "yes");
3273 
3275 
3276 
3278  const char *uuid = switch_channel_get_partner_uuid(channel);
3279  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
3280 
3281  if (uuid) {
3282  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
3283  }
3284  switch_channel_event_set_data(channel, event);
3285  switch_event_fire(&event);
3286  }
3287 
3288 
3289  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n",
3290  switch_channel_get_name(channel),
3291  switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_name")),
3292  switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_number")),
3293  channel->caller_profile->caller_id_name,
3295  );
3296 
3297 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
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_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
switch_caller_profile_t * caller_profile
Representation of an event.
Definition: switch_event.h:80
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.
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
const char * callee_id_number
Definition: switch_caller.h:89
#define switch_channel_get_variable(_c, _v)
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.
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_BLANK_STRING
Definition: switch_types.h:48
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:993
#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
const char * caller_id_number
Definition: switch_caller.h:81
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_set_variable(_channel, _var, _val)
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_core_session_t * session
const char * callee_id_name
Definition: switch_caller.h:87
switch_memory_pool_t * pool

◆ switch_channel_flush_dtmf()

void switch_channel_flush_dtmf ( _In_ switch_channel_t channel)

◆ switch_channel_get_caller_extension()

switch_caller_extension_t* switch_channel_get_caller_extension ( switch_channel_t channel)

Retrieve caller extension from a given channel.

Parameters
channelchannel to retrieve extension from
Returns
the requested extension

Definition at line 3346 of file switch_channel.c.

References switch_caller_profile::caller_extension, caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_channel_caller_extension_masquerade(), switch_channel_var_true(), switch_core_standard_on_execute(), and switch_core_standard_on_hangup().

3347 {
3348  switch_caller_extension_t *extension = NULL;
3349 
3350  switch_assert(channel != NULL);
3351  switch_mutex_lock(channel->profile_mutex);
3352  if (channel->caller_profile) {
3353  extension = channel->caller_profile->caller_extension;
3354  }
3356  return extension;
3357 }
An Abstract Representation of a dialplan extension.
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
#define switch_assert(expr)
struct switch_caller_extension * caller_extension

◆ switch_channel_get_caller_profile()

switch_caller_profile_t* switch_channel_get_caller_profile ( switch_channel_t channel)

Retrieve the given channel's caller profile.

Parameters
channelchannel to retrieve the profile from
Returns
the requested profile

Definition at line 2914 of file switch_channel.c.

References caller_profile, switch_caller_profile::hunt_caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by check_bridge_export(), check_channel_status(), send_display(), switch_channel_build_param_string(), switch_channel_get_variable_dup(), switch_channel_invert_cid(), switch_core_session_execute_exten(), switch_core_session_outgoing_channel(), switch_core_session_request_xml(), switch_core_session_set_uuid(), switch_core_standard_on_routing(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_originate(), switch_ivr_generate_json_cdr(), switch_ivr_generate_xml_cdr(), switch_ivr_originate(), switch_ivr_session_transfer(), switch_ivr_set_user_xml(), and switch_ivr_uuid_bridge().

2915 {
2916  switch_caller_profile_t *profile;
2917  switch_assert(channel != NULL);
2918  switch_mutex_lock(channel->profile_mutex);
2919  if ((profile = channel->caller_profile) && profile->hunt_caller_profile) {
2920  profile = profile->hunt_caller_profile;
2921  }
2923  return profile;
2924 }
Call Specific Data.
Definition: switch_caller.h:73
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
struct switch_caller_profile * hunt_caller_profile
#define switch_assert(expr)

◆ switch_channel_get_callstate()

switch_channel_callstate_t switch_channel_get_callstate ( switch_channel_t channel)

Definition at line 309 of file switch_channel.c.

References callstate.

Referenced by switch_core_session_read_frame(), switch_ivr_hold(), switch_ivr_hold_toggle_uuid(), and switch_ivr_unhold().

310 {
311  return channel->callstate;
312 }
switch_channel_callstate_t callstate

◆ switch_channel_get_cap_string()

char* switch_channel_get_cap_string ( switch_channel_t channel)

Definition at line 1924 of file switch_channel.c.

References caps, CC_FLAG_MAX, switch_stream_handle::data, end_of, flag_mutex, if(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STANDARD_STREAM, and switch_stream_handle::write_function.

Referenced by switch_ivr_generate_json_cdr(), and switch_ivr_generate_xml_cdr().

1925 {
1926  switch_stream_handle_t stream = { 0 };
1927  char *r;
1928  int i = 0;
1929 
1930  SWITCH_STANDARD_STREAM(stream);
1931 
1932  switch_mutex_lock(channel->flag_mutex);
1933  for (i = 0; i < CC_FLAG_MAX; i++) {
1934  if (channel->caps[i]) {
1935  stream.write_function(&stream, "%d=%d;", i, channel->caps[i]);
1936  }
1937  }
1938  switch_mutex_unlock(channel->flag_mutex);
1939 
1940  r = (char *) stream.data;
1941 
1942  if (end_of(r) == ';') {
1943  end_of(r) = '\0';
1944  }
1945 
1946  return r;
1947 
1948 }
#define end_of(_s)
Definition: switch_utils.h:685
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_mutex_t * flag_mutex
#define SWITCH_STANDARD_STREAM(s)
switch_stream_handle_write_function_t write_function
uint32_t caps[CC_FLAG_MAX]

◆ switch_channel_get_cause()

switch_call_cause_t switch_channel_get_cause ( _In_ switch_channel_t channel)

◆ switch_channel_get_cause_ptr()

switch_call_cause_t* switch_channel_get_cause_ptr ( switch_channel_t channel)

Definition at line 244 of file switch_channel.c.

References hangup_cause.

245 {
246  return &channel->hangup_cause;
247 }
switch_call_cause_t hangup_cause

◆ switch_channel_get_cause_q850()

switch_call_cause_t switch_channel_get_cause_q850 ( switch_channel_t channel)

Definition at line 414 of file switch_channel.c.

References hangup_cause, and switch_channel_cause_q850().

Referenced by switch_core_session_hangup_state().

415 {
416  return switch_channel_cause_q850(channel->hangup_cause);
417 }
switch_call_cause_t switch_channel_cause_q850(switch_call_cause_t cause)
switch_call_cause_t hangup_cause

◆ switch_channel_get_flag_string()

char* switch_channel_get_flag_string ( switch_channel_t channel)

Definition at line 1898 of file switch_channel.c.

References CF_FLAG_MAX, switch_stream_handle::data, end_of, flag_mutex, flags, if(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STANDARD_STREAM, and switch_stream_handle::write_function.

Referenced by switch_ivr_generate_json_cdr(), and switch_ivr_generate_xml_cdr().

1899 {
1900  switch_stream_handle_t stream = { 0 };
1901  char *r;
1902  int i = 0;
1903 
1904  SWITCH_STANDARD_STREAM(stream);
1905 
1906  switch_mutex_lock(channel->flag_mutex);
1907  for (i = 0; i < CF_FLAG_MAX; i++) {
1908  if (channel->flags[i]) {
1909  stream.write_function(&stream, "%d=%d;", i, channel->flags[i]);
1910  }
1911  }
1912  switch_mutex_unlock(channel->flag_mutex);
1913 
1914  r = (char *) stream.data;
1915 
1916  if (end_of(r) == ';') {
1917  end_of(r) = '\0';
1918  }
1919 
1920  return r;
1921 
1922 }
#define end_of(_s)
Definition: switch_utils.h:685
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define SWITCH_STANDARD_STREAM(s)
switch_stream_handle_write_function_t write_function

◆ switch_channel_get_hold_music()

const char* switch_channel_get_hold_music ( switch_channel_t channel)

Definition at line 894 of file switch_channel.c.

References session, switch_channel_expand_variables, switch_channel_get_variable, switch_core_session_strdup, SWITCH_HOLD_MUSIC_VARIABLE, SWITCH_TEMP_HOLD_MUSIC_VARIABLE, and zstr.

Referenced by switch_channel_get_hold_music_partner(), switch_core_media_toggle_hold(), switch_ivr_hold(), switch_ivr_parse_event(), and switch_ivr_soft_hold().

895 {
896  const char *var;
897 
900  }
901 
902  if (!zstr(var)) {
903  char *expanded = switch_channel_expand_variables(channel, var);
904 
905  if (expanded != var) {
906  var = switch_core_session_strdup(channel->session, expanded);
907  free(expanded);
908  }
909  }
910 
911 
912  return var;
913 }
#define SWITCH_HOLD_MUSIC_VARIABLE
Definition: switch_types.h:193
#define zstr(x)
Definition: switch_utils.h:314
#define switch_channel_get_variable(_c, _v)
#define switch_channel_expand_variables(_channel, _in)
#define SWITCH_TEMP_HOLD_MUSIC_VARIABLE
Definition: switch_types.h:194
#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

◆ switch_channel_get_hold_music_partner()

const char* switch_channel_get_hold_music_partner ( switch_channel_t channel)

Definition at line 915 of file switch_channel.c.

References session, switch_channel_get_hold_music(), switch_core_session_get_channel(), switch_core_session_get_partner, switch_core_session_rwunlock(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_ivr_parse_event().

916 {
917  switch_core_session_t *session;
918  const char *r = NULL;
919 
923  }
924 
925  return r;
926 }
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
const char * switch_channel_get_hold_music(switch_channel_t *channel)
#define switch_core_session_get_partner(_session, _partner)
Definition: switch_core.h:1028
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_core_session_t * session

◆ switch_channel_get_log_tags()

switch_status_t switch_channel_get_log_tags ( switch_channel_t channel,
switch_event_t **  log_tags 
)

Definition at line 1473 of file switch_channel.c.

References log_tags, profile_mutex, switch_assert, switch_event_dup(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_FALSE.

Referenced by switch_log_meta_vprintf().

1474 {
1476  switch_assert(channel != NULL);
1477  if (!channel->log_tags) {
1478  return status;
1479  }
1480  switch_mutex_lock(channel->profile_mutex);
1481  if (channel->log_tags && log_tags) {
1482  status = switch_event_dup(log_tags, channel->log_tags);
1483  }
1485  return status;
1486 }
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_event_t * log_tags
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_status_t
Common return values.
#define switch_assert(expr)

◆ switch_channel_get_name()

char* switch_channel_get_name ( switch_channel_t channel)

Retrieve the name of a given channel.

Parameters
channelchannel to get name of
Returns
the channel's name

Definition at line 1148 of file switch_channel.c.

References name, switch_assert, and zstr.

Referenced by _switch_core_session_request_video_refresh(), audio_bridge_on_consume_media(), audio_bridge_on_routing(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb_sync(), collect_thread_run(), CoreSession::destroy(), do_flush(), exec_cb(), handle_ice(), handle_nack(), inband_dtmf_generate_callback(), inherit_codec(), ip_choose_family(), meta_on_dtmf(), play_and_detect_input_callback(), read_bundle_rtp_packet(), read_rtp_packet(), recover_callback(), rtp_common_write(), setup_ringback(), signal_bridge_on_hibernate(), switch_channel_check_device_state(), switch_channel_dequeue_dtmf(), switch_channel_event_set_basic_data(), switch_channel_flip_cid(), switch_channel_process_export(), switch_channel_queue_dtmf(), switch_channel_queue_dtmf_string(), switch_collect_input_callback(), switch_core_media_activate_rtp(), switch_core_media_bug_add(), switch_core_media_bug_close(), switch_core_media_bug_read(), switch_core_media_choose_ports(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_patch_sdp(), switch_core_media_process_sdp_filter(), switch_core_media_process_t38_passthru(), switch_core_media_read_frame(), switch_core_media_read_lock_unlock(), switch_core_media_receive_message(), switch_core_media_set_codec(), switch_core_media_set_udptl_image_sdp(), switch_core_media_set_video_codec(), switch_core_session_enable_heartbeat(), switch_core_session_exec(), switch_core_session_execute_application_get_flags(), switch_core_session_execute_exten(), switch_core_session_hangup_state(), switch_core_session_outgoing_channel(), switch_core_session_perform_destroy(), switch_core_session_perform_force_locate(), switch_core_session_perform_kill_channel(), switch_core_session_perform_receive_message(), switch_core_session_read_frame(), switch_core_session_read_lock(), switch_core_session_read_lock_hangup(), switch_core_session_recv_dtmf(), switch_core_session_run(), switch_core_session_send_dtmf(), switch_core_session_send_dtmf_string(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_thread(), switch_core_session_wake_video_thread(), switch_core_session_write_frame(), switch_core_session_write_lock(), switch_core_session_write_text_frame(), switch_core_session_write_video_frame(), switch_core_standard_on_consume_media(), switch_core_standard_on_destroy(), switch_core_standard_on_exchange_media(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_core_standard_on_hibernate(), switch_core_standard_on_init(), switch_core_standard_on_park(), switch_core_standard_on_reporting(), switch_core_standard_on_reset(), switch_core_standard_on_routing(), switch_core_standard_on_soft_execute(), switch_ivr_3p_media(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_parse_event(), switch_ivr_play_and_collect_input(), switch_ivr_play_and_detect_speech(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_session_transfer(), switch_ivr_soft_hold(), switch_ivr_tone_detect_session(), switch_ivr_uuid_bridge(), switch_rtp_write_frame(), text_bridge_thread(), text_helper_thread(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), and video_helper_thread().

1149 {
1150  switch_assert(channel != NULL);
1151  return (!zstr(channel->name)) ? channel->name : "N/A";
1152 }
#define zstr(x)
Definition: switch_utils.h:314
#define switch_assert(expr)

◆ switch_channel_get_originatee_caller_profile()

switch_caller_profile_t* switch_channel_get_originatee_caller_profile ( switch_channel_t channel)

Retrieve the given channel's originatee caller profile.

Parameters
channelchannel to retrieve the profile from
Returns
the requested profile

Definition at line 3022 of file switch_channel.c.

References caller_profile, switch_caller_profile::originatee_caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_reporting_state().

3023 {
3024  switch_caller_profile_t *profile = NULL;
3025  switch_assert(channel != NULL);
3026 
3027  switch_mutex_lock(channel->profile_mutex);
3028  if (channel->caller_profile) {
3029  profile = channel->caller_profile->originatee_caller_profile;
3030  }
3032 
3033  return profile;
3034 }
Call Specific Data.
Definition: switch_caller.h:73
struct switch_caller_profile * originatee_caller_profile
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
#define switch_assert(expr)

◆ switch_channel_get_origination_caller_profile()

switch_caller_profile_t* switch_channel_get_origination_caller_profile ( switch_channel_t channel)

Retrieve the given channel's origination caller profile.

Parameters
channelchannel to retrieve the profile from
Returns
the requested profile

Definition at line 2976 of file switch_channel.c.

References caller_profile, switch_caller_profile::origination_caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

2977 {
2978  switch_caller_profile_t *profile = NULL;
2979  switch_assert(channel != NULL);
2980 
2981  switch_mutex_lock(channel->profile_mutex);
2982  if (channel->caller_profile) {
2983  profile = channel->caller_profile->origination_caller_profile;
2984  }
2986 
2987  return profile;
2988 }
Call Specific Data.
Definition: switch_caller.h:73
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
struct switch_caller_profile * origination_caller_profile
#define switch_assert(expr)

◆ switch_channel_get_originator_caller_profile()

switch_caller_profile_t* switch_channel_get_originator_caller_profile ( switch_channel_t channel)

Retrieve the given channel's originator caller profile.

Parameters
channelchannel to retrieve the profile from
Returns
the requested profile

Definition at line 3007 of file switch_channel.c.

References caller_profile, switch_caller_profile::originator_caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_reporting_state().

3008 {
3009  switch_caller_profile_t *profile = NULL;
3010  switch_assert(channel != NULL);
3011 
3012  switch_mutex_lock(channel->profile_mutex);
3013 
3014  if (channel->caller_profile) {
3015  profile = channel->caller_profile->originator_caller_profile;
3016  }
3018 
3019  return profile;
3020 }
Call Specific Data.
Definition: switch_caller.h:73
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
struct switch_caller_profile * originator_caller_profile
#define switch_assert(expr)

◆ switch_channel_get_private()

void* switch_channel_get_private ( switch_channel_t channel,
const char *  key 
)

Retrieve private from a given channel.

Parameters
channelchannel to retrieve data from
keyunique keyname to retrieve your private data
Returns
void pointer to channel's private data

Definition at line 1100 of file switch_channel.c.

References private_hash, profile_mutex, switch_assert, and switch_core_hash_find_locked().

Referenced by audio_bridge_on_exchange_media(), block_on_dtmf(), dtmf_callback(), generate_on_dtmf(), CoreSession::getPrivate(), hanguphook(), meta_on_dtmf(), monitor_callback(), rtp_common_read(), sb_on_dtmf(), signal_bridge_on_hangup(), speech_on_dtmf(), switch_core_media_copy_t38_options(), switch_core_media_process_udptl(), switch_core_media_receive_message(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_block_dtmf_session(), switch_ivr_capture_text(), switch_ivr_clear_speech_cache(), switch_ivr_deactivate_unicast(), switch_ivr_detect_speech(), switch_ivr_detect_speech_disable_all_grammars(), switch_ivr_detect_speech_disable_grammar(), switch_ivr_detect_speech_enable_grammar(), switch_ivr_detect_speech_init(), switch_ivr_detect_speech_load_grammar(), switch_ivr_detect_speech_start_input_timers(), switch_ivr_detect_speech_unload_grammar(), switch_ivr_displace_session(), switch_ivr_get_file_handle(), switch_ivr_park(), switch_ivr_pause_detect_speech(), switch_ivr_preprocess_session(), switch_ivr_record_session_event(), switch_ivr_record_session_mask(), switch_ivr_record_session_pause(), switch_ivr_resume_detect_speech(), switch_ivr_session_audio(), switch_ivr_set_param_detect_speech(), switch_ivr_speak_text(), switch_ivr_stop_detect_speech(), switch_ivr_stop_displace_session(), switch_ivr_stop_inband_dtmf_generate_session(), switch_ivr_stop_inband_dtmf_session(), switch_ivr_stop_record_session(), switch_ivr_stop_session_audio(), switch_ivr_stop_tone_detect_session(), switch_ivr_stop_video_write_overlay_session(), switch_ivr_tone_detect_session(), switch_ivr_unbind_dtmf_meta_session(), switch_ivr_unblock_dtmf_session(), switch_ivr_video_write_overlay_session(), and tone_on_dtmf().

1101 {
1102  void *val;
1103  switch_assert(channel != NULL);
1104  val = switch_core_hash_find_locked(channel->private_hash, key, channel->profile_mutex);
1105  return val;
1106 }
void * switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex)
Retrieve data from a given hash.
switch_hash_t * private_hash
switch_mutex_t * profile_mutex
char * key
Definition: switch_msrp.c:64
#define switch_assert(expr)

◆ switch_channel_get_private_partner()

void* switch_channel_get_private_partner ( switch_channel_t channel,
const char *  key 
)

Definition at line 1108 of file switch_channel.c.

References private_hash, profile_mutex, switch_assert, switch_channel_get_partner_uuid(), switch_core_hash_find_locked(), switch_core_session_locate, and switch_core_session_rwunlock().

1109 {
1110  const char *uuid;
1111  void *val = NULL;
1112 
1113  switch_assert(channel != NULL);
1114 
1115  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1116  switch_core_session_t *session;
1117  if ((session = switch_core_session_locate(uuid))) {
1118  val = switch_core_hash_find_locked(channel->private_hash, key, channel->profile_mutex);
1120  }
1121  }
1122 
1123  return val;
1124 }
void * switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex)
Retrieve data from a given hash.
switch_hash_t * private_hash
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
switch_mutex_t * profile_mutex
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
char * key
Definition: switch_msrp.c:64
#define switch_assert(expr)

◆ switch_channel_get_running_state()

switch_channel_state_t switch_channel_get_running_state ( switch_channel_t channel)

Definition at line 2245 of file switch_channel.c.

References running_state, and switch_assert.

Referenced by check_presence(), switch_core_session_run(), and uuid_bridge_on_soft_execute().

2246 {
2248  switch_assert(channel != NULL);
2249 
2250  state = channel->running_state;
2251 
2252  return state;
2253 }
switch_channel_state_t running_state
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
#define switch_assert(expr)

◆ switch_channel_get_scope_variables()

switch_status_t switch_channel_get_scope_variables ( switch_channel_t channel,
switch_event_t **  event 
)

Definition at line 946 of file switch_channel.c.

References switch_event::headers, switch_event_header::name, switch_event_header::next, switch_event::next, profile_mutex, scope_variables, switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_DATA, switch_event_create_plain(), switch_event_get_header, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_event_header::value.

947 {
949  switch_event_t *new_event;
950 
952  if (channel->scope_variables) {
953  switch_event_t *ep;
955 
957  status = SWITCH_STATUS_SUCCESS;
958  *event = new_event;
959 
960  for (ep = channel->scope_variables; ep; ep = ep->next) {
961  for (hp = ep->headers; hp; hp = hp->next) {
962  if (!switch_event_get_header(new_event, hp->value)) {
964  }
965  }
966  }
967  }
969 
970  return status;
971 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
struct switch_event * next
Definition: switch_event.h:101
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_event_t * scope_variables
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 switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
Definition: switch_event.h:386
switch_status_t
Common return values.
struct switch_event_header * next
Definition: switch_event.h:76
#define switch_event_get_header(_e, _h)
Definition: switch_event.h:172
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_channel_get_session()

switch_core_session_t* switch_channel_get_session ( switch_channel_t channel)

Definition at line 4482 of file switch_channel.c.

References session, and switch_assert.

4483 {
4484  switch_assert(channel);
4485  return channel->session;
4486 }
#define switch_assert(expr)
switch_core_session_t * session

◆ switch_channel_get_state()

switch_channel_state_t switch_channel_get_state ( switch_channel_t channel)

Get the current state of a channel in the state engine.

Parameters
channelchannel to retrieve state from
Returns
current state of channel

Definition at line 2235 of file switch_channel.c.

References state, and switch_assert.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_per_channel_timeouts(), fs_channel_set_state(), CoreSession::getState(), hanguphook(), limit_state_handler(), originate_on_consume_media_transmit(), originate_on_routing(), CoreSession::setHangupHook(), signal_bridge_on_hibernate(), switch_channel_handle_cause(), switch_core_recovery_track(), switch_core_recovery_untrack(), switch_core_session_hangup_state(), switch_core_session_perform_destroy(), switch_core_session_read_frame(), switch_core_session_read_lock_hangup(), switch_core_session_reporting_state(), switch_core_session_run(), switch_core_standard_on_execute(), switch_ivr_generate_json_cdr(), switch_ivr_generate_xml_cdr(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_uuid_bridge(), switch_ivr_wait_for_answer(), and uuid_bridge_on_soft_execute().

2236 {
2238  switch_assert(channel != NULL);
2239 
2240  state = channel->state;
2241 
2242  return state;
2243 }
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
switch_channel_state_t state
#define switch_assert(expr)

◆ switch_channel_get_state_handler()

const switch_state_handler_table_t* switch_channel_get_state_handler ( switch_channel_t channel,
int  index 
)

Retrieve an state handler tablefrom a given channel at given index level.

Parameters
channelchannel from which to retrieve the state handler table
indexthe index of the state handler table (start from 0)
Returns
given channel's state handler table at given index or NULL if requested index does not exist.

Definition at line 3069 of file switch_channel.c.

References index, state_handler_index, state_handlers, state_mutex, switch_assert, SWITCH_MAX_STATE_HANDLERS, switch_mutex_lock(), and switch_mutex_unlock().

3070 {
3071  const switch_state_handler_table_t *h = NULL;
3072 
3073  switch_assert(channel != NULL);
3074 
3076  return NULL;
3077  }
3078 
3079  switch_mutex_lock(channel->state_mutex);
3080  h = channel->state_handlers[index];
3081  switch_mutex_unlock(channel->state_mutex);
3082 
3083  return h;
3084 }
switch_mutex_t * state_mutex
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:592
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
int index
Definition: switch_cJSON.h:160
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
#define switch_assert(expr)

◆ switch_channel_get_timetable()

switch_channel_timetable_t* switch_channel_get_timetable ( _In_ switch_channel_t channel)

View the timetable of a channel.

Parameters
channelchannel to retrieve timetable from
Returns
a pointer to the channel's timetable (created, answered, etc..)

◆ switch_channel_get_uuid()

char* switch_channel_get_uuid ( switch_channel_t channel)

Retrieve the given channel's unique id.

Parameters
channelchannel to retrieve the unique id from
Returns
the unique id

Definition at line 3036 of file switch_channel.c.

References session, switch_assert, and switch_core_session_get_uuid().

Referenced by switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_perform_ring_ready_value(), switch_channel_perform_set_callstate(), switch_channel_perform_set_running_state(), switch_channel_perform_set_state(), switch_ivr_originate(), and switch_rtp_add_crypto_key().

3037 {
3038  switch_assert(channel != NULL);
3039  switch_assert(channel->session != NULL);
3040  return switch_core_session_get_uuid(channel->session);
3041 }
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
#define switch_assert(expr)
switch_core_session_t * session

◆ switch_channel_get_variable_buf()

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.

Parameters
channelchannel to retrieve variable from
varnamethe name of the variable
bufa pre allocated buffer to put the value to
buflensize of the buffer
Returns
SWITCH_STATUS_SUCCESS if the value was copied to the buffer and it is not NULL, SWITCH_STATUS_FALSE otherwise.

Definition at line 1032 of file switch_channel.c.

References switch_channel_get_variable_dup(), switch_copy_string(), SWITCH_FALSE, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and value.

1033 {
1034  const char *value = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1);
1035 
1036  if (value && buf && buflen && switch_copy_string(buf, value, buflen)) {
1037  return SWITCH_STATUS_SUCCESS;
1038  }
1039 
1040  return SWITCH_STATUS_FALSE;
1041 }
const char *const const char *const const cJSON *const value
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.
switch_byte_t switch_byte_t * buf
switch_byte_t switch_byte_t uint32_t buflen
char * switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size)

◆ switch_channel_get_variable_dup()

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.

Parameters
channelchannel to retrieve variable from
varnamethe name of the variable
Returns
the value of the requested variable

Definition at line 973 of file switch_channel.c.

References switch_event::next, switch_caller_profile::originatee_caller_profile, switch_caller_profile::originator_caller_profile, profile_mutex, scope_variables, session, switch_assert, switch_caller_get_field_by_name(), switch_channel_get_caller_profile(), switch_core_get_variable_pdup(), switch_core_session_get_pool(), switch_core_session_strdup, switch_event_get_header_idx(), switch_mutex_lock(), switch_mutex_unlock(), variables, and zstr.

Referenced by audio_bridge_thread(), check_ice(), check_jb_sync(), switch_channel_event_set_basic_data(), switch_channel_expand_variables_check(), switch_channel_get_partner_uuid_copy(), switch_channel_get_variable_buf(), switch_channel_get_variable_strdup(), switch_channel_queue_dtmf(), switch_channel_set_presence_data_vals(), switch_channel_var_false(), switch_channel_var_true(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_prepare_codecs(), switch_core_media_toggle_hold(), switch_core_recovery_track(), switch_core_session_enable_heartbeat(), switch_core_session_findall_matching_var(), switch_core_session_send_dtmf(), switch_jb_set_session(), and switch_rtp_activate_jitter_buffer().

974 {
975  const char *v = NULL, *r = NULL, *vdup = NULL;
976  switch_assert(channel != NULL);
977 
979 
980  if (!zstr(varname)) {
981  if (channel->scope_variables) {
982  switch_event_t *ep;
983 
984  for (ep = channel->scope_variables; ep; ep = ep->next) {
985  if ((v = switch_event_get_header_idx(ep, varname, idx))) {
986  break;
987  }
988  }
989  }
990 
991  if (!v && (!channel->variables || !(v = switch_event_get_header_idx(channel->variables, varname, idx)))) {
993 
994  if (cp) {
995  if (!strncmp(varname, "aleg_", 5)) {
996  cp = cp->originator_caller_profile;
997  varname += 5;
998  } else if (!strncmp(varname, "bleg_", 5)) {
999  cp = cp->originatee_caller_profile;
1000  varname += 5;
1001  }
1002  }
1003 
1004  if (!cp || !(v = switch_caller_get_field_by_name(cp, varname))) {
1005  if ((vdup = switch_core_get_variable_pdup(varname, switch_core_session_get_pool(channel->session)))) {
1006  v = vdup;
1007  }
1008  }
1009  }
1010  }
1011 
1012  if (dup && v != vdup) {
1013  if (v) {
1014  r = switch_core_session_strdup(channel->session, v);
1015  }
1016  } else {
1017  r = v;
1018  }
1019 
1021 
1022  return r;
1023 }
_Ret_opt_z_ char * switch_event_get_header_idx(switch_event_t *event, const char *header_name, int idx)
Definition: switch_event.c:846
switch_event_t * variables
Call Specific Data.
Definition: switch_caller.h:73
struct switch_caller_profile * originatee_caller_profile
char * switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool)
Representation of an event.
Definition: switch_event.h:80
struct switch_event * next
Definition: switch_event.h:101
_Check_return_ _Ret_opt_z_ const char * switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile, _In_z_ const char *name)
Get the value of a field in a caller profile based on it&#39;s name.
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_event_t * scope_variables
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
struct switch_caller_profile * originator_caller_profile
#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_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel&#39;s caller profile.
switch_core_session_t * session
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.

◆ switch_channel_get_variable_partner()

const char* switch_channel_get_variable_partner ( switch_channel_t channel,
const char *  varname 
)

Definition at line 1043 of file switch_channel.c.

References session, switch_assert, switch_channel_get_partner_uuid(), switch_channel_get_variable, switch_core_session_get_channel(), switch_core_session_locate, switch_core_session_rwunlock(), switch_core_session_strdup, and zstr.

Referenced by switch_core_media_negotiate_sdp().

1044 {
1045  const char *uuid;
1046  const char *val = NULL, *r = NULL;
1047  switch_assert(channel != NULL);
1048 
1049  if (!zstr(varname)) {
1050  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1051  switch_core_session_t *session;
1052  if ((session = switch_core_session_locate(uuid))) {
1054  val = switch_channel_get_variable(tchannel, varname);
1056  }
1057  }
1058  }
1059 
1060  if (val)
1061  r = switch_core_session_strdup(channel->session, val);
1062 
1063  return r;
1064 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
#define zstr(x)
Definition: switch_utils.h:314
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
#define switch_channel_get_variable(_c, _v)
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#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_variable_strdup()

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.

Parameters
channelchannel to retrieve variable from
varnamethe name of the variable
Returns
a strdup copy the value of the requested variable without using a memory pool.

Definition at line 1025 of file switch_channel.c.

References switch_channel_get_variable_dup(), SWITCH_FALSE, and value.

1026 {
1027  const char *value = switch_channel_get_variable_dup(channel, varname, SWITCH_FALSE, -1);
1028 
1029  return value ? (const char *)strdup(value) : NULL;
1030 }
const char *const const char *const const cJSON *const value
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.

◆ switch_channel_get_variables()

switch_status_t switch_channel_get_variables ( switch_channel_t channel,
switch_event_t **  event 
)

Definition at line 4446 of file switch_channel.c.

References profile_mutex, SWITCH_EVENT_CHANNEL_DATA, switch_event_create, switch_event_dup(), switch_mutex_lock(), switch_mutex_unlock(), and variables.

Referenced by api_hook(), asr_set_json_text_params(), switch_channel_api_on(), switch_channel_del_variable_prefix(), switch_channel_execute_on(), and switch_ivr_transfer_variable().

4447 {
4448  switch_status_t status;
4449  switch_mutex_lock(channel->profile_mutex);
4450  if (channel->variables) {
4451  status = switch_event_dup(event, channel->variables);
4452  } else {
4454  }
4456  return status;
4457 }
switch_event_t * variables
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
switch_mutex_t * profile_mutex
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
switch_status_t
Common return values.
#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

◆ switch_channel_get_variables_prefix()

switch_status_t switch_channel_get_variables_prefix ( switch_channel_t channel,
const char *  prefix,
switch_event_t **  event 
)

Definition at line 4459 of file switch_channel.c.

References switch_event::headers, switch_event_header::name, switch_event_header::next, profile_mutex, switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_DATA, switch_event_create, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_SUCCESS, switch_event_header::value, and variables.

4460 {
4462  switch_event_t *vars;
4463 
4465 
4466  switch_mutex_lock(channel->profile_mutex);
4467  if (channel->variables) {
4469 
4470  for (hi = channel->variables->headers; hi; hi = hi->next) {
4471  if (!strncmp(hi->name, prefix, strlen(prefix))) {
4473  }
4474  }
4475  }
4477 
4478  *event = vars;
4479  return status;
4480 }
switch_event_t * variables
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
switch_mutex_t * profile_mutex
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
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.
switch_status_t
Common return values.
struct switch_event_header * next
Definition: switch_event.h:76
#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
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_channel_has_dtmf()

switch_size_t switch_channel_has_dtmf ( _In_ switch_channel_t channel)

◆ switch_channel_init()

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.

Parameters
channelthe channel to initilize
sessionthe session to connect the channel to
statethe initial state of the channel
flagsthe initial channel flags

Definition at line 767 of file switch_channel.c.

References CS_NONE, running_state, session, state, switch_assert, switch_channel_set_flag, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_request_uuid().

769 {
770  switch_assert(channel != NULL);
771  channel->state = state;
772  switch_channel_set_flag(channel, flag);
773  channel->session = session;
774  channel->running_state = CS_NONE;
775  return SWITCH_STATUS_SUCCESS;
776 }
switch_channel_state_t running_state
switch_channel_state_t state
#define switch_channel_set_flag(_c, _f)
#define switch_assert(expr)
switch_core_session_t * session

◆ switch_channel_invert_cid()

void switch_channel_invert_cid ( switch_channel_t channel)

Definition at line 3206 of file switch_channel.c.

References switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, switch_caller_profile::caller_id_name, switch_caller_profile::caller_id_number, switch_channel_get_caller_profile(), SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, switch_log_printf(), and zstr.

Referenced by switch_channel_var_true(), and switch_ivr_uuid_bridge().

3207 {
3208  const char *tname, *tnum;
3210 
3211  cp = switch_channel_get_caller_profile(channel);
3212 
3213  tname = cp->caller_id_name;
3214  tnum = cp->caller_id_number;
3215 
3216 #ifdef DEEP_DEBUG_CID
3218 #endif
3219 
3220  cp->caller_id_name = cp->callee_id_name;
3222 
3223  cp->callee_id_name = tname;
3224  cp->callee_id_number = tnum;
3225 
3226  if (zstr(cp->caller_id_name)) {
3227  cp->caller_id_name = "Unknown";
3228  }
3229 
3230  if (zstr(cp->caller_id_number)) {
3231  cp->caller_id_number = "Unknown";
3232  }
3233 }
Call Specific Data.
Definition: switch_caller.h:73
#define SWITCH_CHANNEL_LOG
#define zstr(x)
Definition: switch_utils.h:314
const char * callee_id_number
Definition: switch_caller.h:89
const char * caller_id_name
Definition: switch_caller.h:79
const char * caller_id_number
Definition: switch_caller.h:81
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_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel&#39;s caller profile.
const char * callee_id_name
Definition: switch_caller.h:87

◆ switch_channel_logical_direction()

switch_call_direction_t switch_channel_logical_direction ( switch_channel_t channel)

Definition at line 445 of file switch_channel.c.

References logical_direction.

446 {
447  return channel->logical_direction;
448 }
switch_call_direction_t logical_direction

◆ switch_channel_mark_hold()

void switch_channel_mark_hold ( switch_channel_t channel,
switch_bool_t  on 
)

Definition at line 861 of file switch_channel.c.

References CF_LEG_HOLDING, session, switch_channel_clear_flag(), switch_channel_event_set_data(), switch_channel_get_variable, switch_channel_set_flag, switch_channel_test_flag(), switch_core_session_get_partner, switch_core_session_rwunlock(), SWITCH_EVENT_CHANNEL_HOLD, SWITCH_EVENT_CHANNEL_UNHOLD, switch_event_create, switch_event_fire, switch_ivr_transfer_recordings(), SWITCH_STATUS_SUCCESS, and switch_true().

Referenced by audio_bridge_thread(), switch_channel_perform_hangup(), switch_core_media_toggle_hold(), and switch_ivr_intercept_session().

862 {
863  switch_event_t *event;
864 
865  if (!!on == !!switch_channel_test_flag(channel, CF_LEG_HOLDING)) {
866  goto end;
867  }
868 
869  if (on) {
871  } else {
873  }
874 
876  switch_channel_event_set_data(channel, event);
877  switch_event_fire(&event);
878  }
879 
880  end:
881 
882  if (on) {
883  if (switch_true(switch_channel_get_variable(channel, "flip_record_on_hold"))) {
884  switch_core_session_t *other_session;
885  if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
886  switch_ivr_transfer_recordings(channel->session, other_session);
887  switch_core_session_rwunlock(other_session);
888  }
889  }
890  }
891 
892 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
Representation of an event.
Definition: switch_event.h:80
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.
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
#define switch_channel_get_variable(_c, _v)
#define switch_core_session_get_partner(_session, _partner)
Definition: switch_core.h:1028
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#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
#define switch_channel_set_flag(_c, _f)
switch_status_t switch_ivr_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
switch_core_session_t * session

◆ switch_channel_name_state()

switch_channel_state_t switch_channel_name_state ( _In_ const char *  name)

Render the enum of the provided state name.

Parameters
namethe name of the state
Returns
the enum value (numeric)

Referenced by fs_channel_set_state().

◆ switch_channel_pass_callee_id()

switch_status_t switch_channel_pass_callee_id ( switch_channel_t channel,
switch_channel_t other_channel 
)

Definition at line 4420 of file switch_channel.c.

References switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, caller_profile, switch_caller_profile::pool, profile_mutex, switch_assert, switch_core_strdup, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.

Referenced by audio_bridge_thread(), check_channel_status(), switch_ivr_multi_threaded_bridge(), and switch_ivr_originate().

4421 {
4422  int x = 0;
4423 
4424  switch_assert(channel);
4425  switch_assert(other_channel);
4426 
4427  switch_mutex_lock(channel->profile_mutex);
4428  switch_mutex_lock(other_channel->profile_mutex);
4429 
4430  if (!zstr(channel->caller_profile->callee_id_name)) {
4432  x++;
4433  }
4434 
4435  if (!zstr(channel->caller_profile->callee_id_number)) {
4437  x++;
4438  }
4439 
4440  switch_mutex_unlock(other_channel->profile_mutex);
4442 
4444 }
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
switch_caller_profile_t * caller_profile
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
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
const char * callee_id_number
Definition: switch_caller.h:89
#define switch_assert(expr)
const char * callee_id_name
Definition: switch_caller.h:87
switch_memory_pool_t * pool

◆ switch_channel_perform_acknowledge_call()

switch_status_t switch_channel_perform_acknowledge_call ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3467 of file switch_channel.c.

References send_ind(), SWITCH_MESSAGE_INDICATE_ACKNOWLEDGE_CALL, and SWITCH_STATUS_SUCCESS.

3469 {
3470  send_ind(channel, SWITCH_MESSAGE_INDICATE_ACKNOWLEDGE_CALL, file, func, line);
3471 
3472  return SWITCH_STATUS_SUCCESS;
3473 }
static switch_status_t send_ind(switch_channel_t *channel, switch_core_session_message_types_t msg_id, const char *file, const char *func, int line)

◆ switch_channel_perform_answer()

switch_status_t switch_channel_perform_answer ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3925 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CF_HAS_TEXT, CF_PROXY_MODE, CS_HANGUP, switch_core_session_message::from, hangup_cause, switch_core_session_message::message_id, name, session, state, switch_assert, SWITCH_CALL_DIRECTION_OUTBOUND, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION, switch_channel_audio_sync, switch_channel_direction(), switch_channel_get_variable, switch_channel_hangup, switch_channel_perform_mark_answered(), SWITCH_CHANNEL_SESSION_LOG, switch_channel_test_flag(), switch_core_session_in_thread(), switch_core_session_perform_receive_message(), switch_ivr_sleep(), SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_MESSAGE_INDICATE_ANSWER, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and SWITCH_TRUE.

3926 {
3927  switch_core_session_message_t msg = { 0 };
3929 
3930  switch_assert(channel != NULL);
3931 
3933  return SWITCH_STATUS_SUCCESS;
3934  }
3935 
3936  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3937  return SWITCH_STATUS_FALSE;
3938  }
3939 
3940  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3941  return SWITCH_STATUS_SUCCESS;
3942  }
3943 
3945  msg.from = channel->name;
3946  status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
3947 
3948 
3949  if (status == SWITCH_STATUS_SUCCESS) {
3950  switch_channel_perform_mark_answered(channel, file, func, line);
3951  if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3952  switch_channel_audio_sync(channel);
3953  }
3954  } else {
3956  }
3957 
3958 
3961  const char *delay;
3962 
3963  if ((delay = switch_channel_get_variable(channel, "answer_delay"))) {
3964  uint32_t msec = atoi(delay);
3965 
3966  if (msec) {
3967  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "Answer delay for %u msec\n", msec);
3968  switch_ivr_sleep(channel->session, msec, SWITCH_TRUE, NULL);
3969  }
3970  }
3971  }
3972 
3973  return status;
3974 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_core_session_message_types_t message_id
Definition: switch_core.h:183
switch_status_t switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args)
Wait for time to pass for a specified number of milliseconds.
Definition: switch_ivr.c:127
switch_status_t switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line)
Receive a message on a given session.
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.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:179
#define switch_channel_audio_sync(_c)
#define switch_channel_get_variable(_c, _v)
switch_status_t
Common return values.
switch_channel_state_t state
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
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_assert(expr)
switch_core_session_t * session
switch_bool_t switch_core_session_in_thread(switch_core_session_t *session)
switch_call_cause_t hangup_cause
switch_status_t switch_channel_perform_mark_answered(switch_channel_t *channel, const char *file, const char *func, int line)

◆ switch_channel_perform_audio_sync()

void switch_channel_perform_audio_sync ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 366 of file switch_channel.c.

References switch_core_session_message::_file, switch_core_session_message::_func, switch_core_session_message::_line, switch_core_session_message::from, switch_core_session_message::message_id, MESSAGE_STAMP_FFL, name, session, switch_channel_media_up, switch_core_session_alloc, switch_core_session_queue_message(), and SWITCH_MESSAGE_INDICATE_AUDIO_SYNC.

367 {
368  if (switch_channel_media_up(channel)) {
369  switch_core_session_message_t *msg = NULL;
370 
371  msg = switch_core_session_alloc(channel->session, sizeof(*msg));
372  MESSAGE_STAMP_FFL(msg);
374  msg->from = channel->name;
375  msg->_file = file;
376  msg->_func = func;
377  msg->_line = line;
378 
380  }
381 }
switch_core_session_message_types_t message_id
Definition: switch_core.h:183
switch_status_t switch_core_session_queue_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message)
Queue a message on a session.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:179
#define MESSAGE_STAMP_FFL(_m)
Definition: switch_core.h:175
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
switch_core_session_t * session
#define switch_channel_media_up(_channel)

◆ switch_channel_perform_hangup()

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 
)

Definition at line 3380 of file switch_channel.c.

References CF_BLOCK_STATE, CF_BRIDGE_ORIGINATOR, CF_BRIDGED, CF_HANGUP_HELD, CF_LEG_HOLDING, CS_HANGUP, hangup_cause, hold_record, name, OCF_HANGUP, switch_hold_record_s::off, opaque_flags, profile_mutex, session, state, state_mutex, state_names, switch_assert, switch_channel_cause2str(), switch_channel_clear_flag(), switch_channel_event_set_data(), switch_channel_get_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_ID_LOG, switch_channel_mark_hold(), switch_channel_set_flag, switch_channel_set_variable, switch_channel_set_variable_partner, switch_channel_test_flag(), switch_core_session_hangup_state(), switch_core_session_kill_channel, switch_core_session_running(), switch_core_session_signal_state_change(), switch_core_session_started(), switch_core_session_thread_launch(), SWITCH_EVENT_CHANNEL_HANGUP, switch_event_create, switch_event_fire, SWITCH_FALSE, SWITCH_LOG_NOTICE, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, SWITCH_SIG_KILL, SWITCH_STATUS_SUCCESS, and switch_time_now().

3382 {
3383  int ok = 0;
3384 
3385  switch_assert(channel != NULL);
3386 
3387  /* one per customer */
3388  switch_mutex_lock(channel->state_mutex);
3389  if (!(channel->opaque_flags & OCF_HANGUP)) {
3390  channel->opaque_flags |= OCF_HANGUP;
3391  ok = 1;
3392  }
3393  switch_mutex_unlock(channel->state_mutex);
3394 
3395  if (switch_channel_test_flag(channel, CF_LEG_HOLDING)) {
3398  }
3399 
3400  if (!ok) {
3401  return channel->state;
3402  }
3403 
3405 
3406  if (channel->state < CS_HANGUP) {
3407  switch_channel_state_t last_state;
3408  switch_event_t *event;
3409  const char *var;
3410 
3411 
3412  switch_mutex_lock(channel->profile_mutex);
3413  if (channel->hold_record && !channel->hold_record->off) {
3414  channel->hold_record->off = switch_time_now();
3415  }
3417 
3418  switch_mutex_lock(channel->state_mutex);
3419  last_state = channel->state;
3420  channel->state = CS_HANGUP;
3421  switch_mutex_unlock(channel->state_mutex);
3422 
3423  channel->hangup_cause = hangup_cause;
3424  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
3425  channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
3426 
3427 
3428  switch_channel_set_variable_partner(channel, "last_bridge_hangup_cause", switch_channel_cause2str(hangup_cause));
3429 
3432  }
3433 
3435  switch_channel_set_variable(channel, "last_bridge_role", "originator");
3436  } else if (switch_channel_test_flag(channel, CF_BRIDGED)) {
3437  switch_channel_set_variable(channel, "last_bridge_role", "originatee");
3438  }
3439 
3440 
3443  }
3444 
3446  switch_channel_event_set_data(channel, event);
3447  switch_event_fire(&event);
3448  }
3449 
3453  }
3454 
3455  return channel->state;
3456 }
void switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force)
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
void switch_core_session_signal_state_change(_In_ switch_core_session_t *session)
opaque_channel_flag_t opaque_flags
#define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE
Definition: switch_types.h:143
Representation of an event.
Definition: switch_event.h:80
switch_hold_record_t * hold_record
static const char * state_names[]
switch_mutex_t * state_mutex
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_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_channel_mark_hold(switch_channel_t *channel, switch_bool_t on)
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_channel_get_variable(_c, _v)
#define switch_channel_set_variable_partner(_channel, _var, _val)
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
unsigned int switch_core_session_running(_In_ switch_core_session_t *session)
determine if the session&#39;s state machine is running
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
switch_channel_state_t state
#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
#define switch_channel_set_flag(_c, _f)
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.
unsigned int switch_core_session_started(_In_ switch_core_session_t *session)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
Definition: switch_apr.c:325
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
Definition: switch_core.h:1393
switch_core_session_t * session
switch_time_t off
Definition: switch_core.h:76
switch_call_cause_t hangup_cause
switch_status_t switch_core_session_thread_launch(_In_ switch_core_session_t *session)
Launch the session thread (state machine) on a given session.
const char * switch_channel_cause2str(switch_call_cause_t cause)

◆ switch_channel_perform_mark_answered()

switch_status_t switch_channel_perform_mark_answered ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3813 of file switch_channel.c.

References switch_channel_timetable::answered, caller_profile, CCS_ACTIVE, CF_ANSWERED, CF_EARLY_MEDIA, CF_NO_RECOVER, CF_PASSTHRU_PTIME_MISMATCH, CF_RTT, CF_VIDEO_MIRROR_INPUT, CS_HANGUP, hangup_cause, name, profile_mutex, send_ind(), session, state, switch_assert, switch_channel_api_on(), SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE, SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE, switch_channel_event_set_data(), switch_channel_execute_on(), SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE, switch_channel_get_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_ID_LOG, switch_channel_presence, switch_channel_set_callstate, switch_channel_set_flag, switch_channel_set_flag_partner(), switch_channel_set_variable, switch_channel_test_flag(), switch_core_media_check_autoadj(), switch_core_media_check_dtls(), switch_core_recovery_track(), switch_core_session_enable_heartbeat(), switch_core_session_kill_channel, switch_core_session_locate, switch_core_session_rwunlock(), SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, SWITCH_EVENT_CHANNEL_ANSWER, switch_event_create, switch_event_fire, switch_is_number(), SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_MEDIA_TYPE_AUDIO, SWITCH_MESSAGE_ANSWER_EVENT, switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_ORIGINATOR_VARIABLE, SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE, SWITCH_SIG_BREAK, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_true(), and switch_caller_profile::times.

Referenced by switch_channel_perform_answer().

3814 {
3815  switch_event_t *event;
3816  const char *uuid;
3817  switch_core_session_t *other_session;
3818  const char *var;
3819 
3820  switch_assert(channel != NULL);
3821 
3822  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3823  return SWITCH_STATUS_FALSE;
3824  }
3825 
3826  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3827  return SWITCH_STATUS_SUCCESS;
3828  }
3829 
3831 
3832  if (channel->caller_profile && channel->caller_profile->times) {
3833  switch_mutex_lock(channel->profile_mutex);
3836  }
3837 
3839 
3840  if (switch_true(switch_channel_get_variable(channel, "video_mirror_input"))) {
3842  //switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
3843  }
3844 
3845 
3847  switch_channel_event_set_data(channel, event);
3848  switch_event_fire(&event);
3849  }
3850 
3851  /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
3852  a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
3853  */
3855  && (other_session = switch_core_session_locate(uuid))) {
3857  switch_core_session_rwunlock(other_session);
3858  }
3859 
3862  }
3863 
3865  uint32_t seconds = 60;
3866  int tmp;
3867 
3868  if (switch_is_number(var)) {
3869  tmp = atoi(var);
3870  if (tmp > 0) {
3871  seconds = tmp;
3872  }
3873  } else if (!switch_true(var)) {
3874  seconds = 0;
3875  }
3876 
3877  if (seconds) {
3878  switch_core_session_enable_heartbeat(channel->session, seconds);
3879  }
3880  }
3881 
3883  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n",
3884  channel->name);
3885 
3886 
3887  if (switch_channel_get_variable(channel, "absolute_codec_string")) {
3888  /* inherit_codec == true will implicitly clear the absolute_codec_string
3889  variable if used since it was the reason it was set in the first place and is no longer needed */
3890  if (switch_true(switch_channel_get_variable(channel, "inherit_codec"))) {
3891  switch_channel_set_variable(channel, "absolute_codec_string", NULL);
3892  }
3893  }
3894 
3896 
3897  if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3900  }
3901 
3903 
3904  switch_channel_presence(channel, "unknown", "answered", NULL);
3905 
3906  //switch_channel_audio_sync(channel);
3907 
3908  if (!switch_channel_test_flag(channel, CF_NO_RECOVER)) {
3910  }
3911 
3913 
3914  send_ind(channel, SWITCH_MESSAGE_ANSWER_EVENT, file, func, line);
3915 
3917 
3918  if (switch_channel_test_flag(channel, CF_RTT)) {
3920  }
3921 
3922  return SWITCH_STATUS_SUCCESS;
3923 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
#define SWITCH_ORIGINATOR_VARIABLE
Definition: switch_types.h:205
#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE
Definition: switch_types.h:152
#define switch_channel_presence(_a, _b, _c, _d)
switch_caller_profile_t * caller_profile
Representation of an event.
Definition: switch_event.h:80
switch_bool_t switch_is_number(const char *str)
switch_bool_t switch_core_media_check_dtls(switch_core_session_t *session, switch_media_type_t type)
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.
static switch_status_t send_ind(switch_channel_t *channel, switch_core_session_message_types_t msg_id, const char *file, const char *func, int line)
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_core_recovery_track(switch_core_session_t *session)
switch_status_t switch_core_media_check_autoadj(switch_core_session_t *session)
void switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds)
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE
Definition: switch_types.h:192
#define switch_channel_get_variable(_c, _v)
#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE
Definition: switch_types.h:150
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&#39;s bridge partner.
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_channel_set_callstate(channel, state)
#define SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE
Definition: switch_types.h:135
#define SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE
Definition: switch_types.h:136
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
switch_channel_state_t state
#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
#define switch_channel_set_flag(_c, _f)
struct switch_channel_timetable * times
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_API_ON_MEDIA_VARIABLE
Definition: switch_types.h:164
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
Definition: switch_core.h:1393
switch_core_session_t * session
switch_call_cause_t hangup_cause
switch_status_t switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix)
switch_status_t switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
#define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE
Definition: switch_types.h:162

◆ switch_channel_perform_mark_pre_answered()

switch_status_t switch_channel_perform_mark_pre_answered ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3523 of file switch_channel.c.

References caller_profile, CCS_EARLY, CF_ANSWERED, CF_EARLY_MEDIA, CF_PASSTHRU_PTIME_MISMATCH, CF_VIDEO_MIRROR_INPUT, name, switch_caller_profile::originator_caller_profile, profile_mutex, switch_channel_timetable::progress_media, send_ind(), session, switch_channel_api_on(), SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE, SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE, switch_channel_event_set_data(), switch_channel_execute_on(), SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE, SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE, switch_channel_get_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_ID_LOG, switch_channel_set_callstate, switch_channel_set_flag, switch_channel_set_variable, switch_channel_test_flag(), switch_core_media_check_autoadj(), switch_core_media_check_dtls(), switch_core_session_get_channel(), switch_core_session_kill_channel, switch_core_session_locate, switch_core_session_rwunlock(), SWITCH_ENDPOINT_DISPOSITION_VARIABLE, SWITCH_EVENT_CHANNEL_PROGRESS_MEDIA, switch_event_create, switch_event_fire, SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_MEDIA_TYPE_AUDIO, SWITCH_MESSAGE_PROGRESS_EVENT, switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_ORIGINATOR_VARIABLE, SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE, SWITCH_SIG_BREAK, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_true(), switch_caller_profile::times, and switch_caller_profile::uuid.

Referenced by switch_channel_perform_pre_answer().

3524 {
3525  switch_event_t *event;
3526 
3528  const char *uuid;
3529  switch_core_session_t *other_session;
3530 
3532 
3533  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
3535 
3537 
3538  if (switch_true(switch_channel_get_variable(channel, "video_mirror_input"))) {
3540  }
3541 
3542  if (channel->caller_profile && channel->caller_profile->times) {
3543  switch_mutex_lock(channel->profile_mutex);
3545  if (channel->caller_profile->originator_caller_profile) {
3546  switch_core_session_t *osession;
3548  switch_channel_t *other_channel;
3549  other_channel = switch_core_session_get_channel(osession);
3550  if (other_channel->caller_profile) {
3551  other_channel->caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
3552  }
3553  switch_core_session_rwunlock(osession);
3554  }
3556  }
3558  }
3559 
3561  switch_channel_event_set_data(channel, event);
3562  switch_event_fire(&event);
3563  }
3564 
3567 
3570 
3573  }
3574 
3575 
3576  /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
3577  a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
3578  */
3580  && (other_session = switch_core_session_locate(uuid))) {
3582  switch_core_session_rwunlock(other_session);
3583  }
3584 
3586 
3587  send_ind(channel, SWITCH_MESSAGE_PROGRESS_EVENT, file, func, line);
3588 
3590 
3591  return SWITCH_STATUS_SUCCESS;
3592  }
3593 
3594  return SWITCH_STATUS_FALSE;
3595 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
#define SWITCH_ORIGINATOR_VARIABLE
Definition: switch_types.h:205
#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE
Definition: switch_types.h:152
#define SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE
Definition: switch_types.h:163
switch_caller_profile_t * caller_profile
Representation of an event.
Definition: switch_event.h:80
switch_bool_t switch_core_media_check_dtls(switch_core_session_t *session, switch_media_type_t type)
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.
static switch_status_t send_ind(switch_channel_t *channel, switch_core_session_message_types_t msg_id, const char *file, const char *func, int line)
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
switch_status_t switch_core_media_check_autoadj(switch_core_session_t *session)
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE
Definition: switch_types.h:192
#define switch_channel_get_variable(_c, _v)
struct switch_caller_profile * originator_caller_profile
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_channel_set_callstate(channel, state)
#define SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE
Definition: switch_types.h:135
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#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
#define switch_channel_set_flag(_c, _f)
struct switch_channel_timetable * times
#define SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE
Definition: switch_types.h:151
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_API_ON_MEDIA_VARIABLE
Definition: switch_types.h:164
#define switch_channel_set_variable(_channel, _var, _val)
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
Definition: switch_core.h:1393
switch_core_session_t * session
switch_time_t progress_media
switch_status_t switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix)
switch_status_t switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)

◆ switch_channel_perform_mark_ring_ready_value()

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 
)

Definition at line 3475 of file switch_channel.c.

References caller_profile, CCS_RINGING, CF_ANSWERED, CF_RING_READY, name, switch_caller_profile::originator_caller_profile, profile_mutex, switch_channel_timetable::progress, send_ind(), switch_channel_api_on(), SWITCH_CHANNEL_API_ON_RING_VARIABLE, switch_channel_event_set_data(), switch_channel_execute_on(), SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE, switch_channel_get_uuid(), SWITCH_CHANNEL_ID_LOG, switch_channel_set_callstate, switch_channel_set_flag_value(), switch_channel_test_flag(), switch_core_session_get_channel(), switch_core_session_locate, switch_core_session_rwunlock(), SWITCH_EVENT_CHANNEL_PROGRESS, switch_event_create, switch_event_fire, SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_MESSAGE_RING_EVENT, switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_caller_profile::times, and switch_caller_profile::uuid.

Referenced by switch_channel_perform_ring_ready_value().

3478 {
3479  switch_event_t *event;
3480 
3482  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
3484 
3485  switch_mutex_lock(channel->profile_mutex);
3486  if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->progress) {
3488  if (channel->caller_profile->originator_caller_profile) {
3489  switch_core_session_t *other_session;
3490  if ((other_session = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) {
3491  switch_channel_t *other_channel;
3492  other_channel = switch_core_session_get_channel(other_session);
3493  switch_mutex_lock(other_channel->profile_mutex);
3494  if (other_channel->caller_profile && !other_channel->caller_profile->times->progress) {
3495  other_channel->caller_profile->times->progress = channel->caller_profile->times->progress;
3496  }
3497  switch_mutex_unlock(other_channel->profile_mutex);
3498  switch_core_session_rwunlock(other_session);
3499  }
3501  }
3502  }
3504 
3506  switch_channel_event_set_data(channel, event);
3507  switch_event_fire(&event);
3508  }
3509 
3512 
3514 
3515  send_ind(channel, SWITCH_MESSAGE_RING_EVENT, file, func, line);
3516 
3517  return SWITCH_STATUS_SUCCESS;
3518  }
3519 
3520  return SWITCH_STATUS_FALSE;
3521 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
switch_caller_profile_t * caller_profile
Representation of an event.
Definition: switch_event.h:80
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.
static switch_status_t send_ind(switch_channel_t *channel, switch_core_session_message_types_t msg_id, const char *file, const char *func, int line)
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
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.
struct switch_caller_profile * originator_caller_profile
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE
Definition: switch_types.h:153
#define switch_channel_set_callstate(channel, state)
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#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 switch_channel_timetable * times
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_API_ON_RING_VARIABLE
Definition: switch_types.h:165
switch_status_t switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix)
switch_status_t switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)

◆ switch_channel_perform_pre_answer()

switch_status_t switch_channel_perform_pre_answer ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3597 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CS_HANGUP, switch_core_session_message::from, hangup_cause, switch_core_session_message::message_id, name, session, state, switch_assert, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION, switch_channel_audio_sync, switch_channel_direction(), switch_channel_hangup, switch_channel_perform_mark_pre_answered(), switch_channel_test_flag(), switch_core_session_perform_receive_message(), SWITCH_MESSAGE_INDICATE_PROGRESS, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

3598 {
3599  switch_core_session_message_t msg = { 0 };
3601 
3602  switch_assert(channel != NULL);
3603 
3604  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3605  return SWITCH_STATUS_FALSE;
3606  }
3607 
3608  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3609  return SWITCH_STATUS_SUCCESS;
3610  }
3611 
3612  if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3613  return SWITCH_STATUS_SUCCESS;
3614  }
3615 
3618  msg.from = channel->name;
3619  status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
3620  }
3621 
3622  if (status == SWITCH_STATUS_SUCCESS) {
3623  switch_channel_perform_mark_pre_answered(channel, file, func, line);
3624  switch_channel_audio_sync(channel);
3625  } else {
3627  }
3628 
3629  return status;
3630 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
switch_core_session_message_types_t message_id
Definition: switch_core.h:183
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_core_session_perform_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line)
Receive a message on a given session.
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.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:179
#define switch_channel_audio_sync(_c)
switch_status_t
Common return values.
switch_channel_state_t state
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
#define switch_assert(expr)
switch_core_session_t * session
switch_call_cause_t hangup_cause

◆ switch_channel_perform_presence()

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.

Parameters
channelthe channel to initilize
rpidthe rpid if for the icon to use
statusthe status message
idpresence id

Definition at line 778 of file switch_channel.c.

References CF_ANSWERED, CF_NO_PRESENCE, CF_SLA_INTERCEPT, direction, event_count, SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_event_set_data(), switch_channel_get_variable, switch_channel_test_flag(), switch_channel_up_nosig, switch_event_add_header(), switch_event_add_header_string(), switch_event_create, switch_event_fire, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_PRESENCE_OUT, SWITCH_STACK_BOTTOM, SWITCH_STATUS_SUCCESS, and switch_true().

780 {
781  switch_event_t *event;
783  const char *call_info = NULL;
784  char *call_info_state = "active";
785 
787  return;
788  }
789 
790  if (!status) {
792  status = "idle";
793  }
794 
795  if (!id) {
796  id = switch_channel_get_variable(channel, "presence_id");
797  }
798 
799  if (!id) {
800  return;
801  }
802 
803  call_info = switch_channel_get_variable(channel, "presence_call_info");
804 
805  if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
806  switch_channel_event_set_data(channel, event);
807  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "any");
808  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", __FILE__);
810  if (type == SWITCH_EVENT_PRESENCE_IN) {
811  if (!rpid) {
812  rpid = "unknown";
813  }
815  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", status);
816  }
817  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
818  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
819 
820 
821  if (!strcasecmp(status, "idle") || !switch_channel_up_nosig(channel)) {
822  call_info_state = "idle";
823  } else if (!strcasecmp(status, "hold-private")) {
824  call_info_state = "held-private";
825  } else if (!strcasecmp(status, "hold")) {
826  call_info_state = "held";
827  } else if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
828  if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
829  call_info_state = "progressing";
830  } else {
832  call_info_state = "idle";
833  } else {
834  call_info_state = "alerting";
835  }
836  }
837  }
838 
839  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info-state", call_info_state);
840 
841  if (call_info) {
842  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info", call_info);
843  }
844 
845  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction",
846  channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
847 
848  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++);
849  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Calling-File", file);
850  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Calling-Function", func);
851  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Presence-Calling-Line", "%d", line);
852 
853  if (switch_true(switch_channel_get_variable(channel, "presence_privacy"))) {
854  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Privacy", "true");
855  }
856 
857  switch_event_fire(&event);
858  }
859 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
switch_event_types_t
Built-in Events.
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
Definition: switch_event.h:80
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.
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
#define switch_channel_get_variable(_c, _v)
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.
switch_call_direction_t direction
#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
#define switch_channel_up_nosig(_channel)

◆ switch_channel_perform_ring_ready_value()

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 
)

Definition at line 3632 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CS_HANGUP, switch_core_session_message::from, hangup_cause, switch_core_session_message::message_id, name, switch_core_session_message::numeric_arg, session, state, switch_assert, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION, switch_channel_direction(), switch_channel_get_uuid(), switch_channel_hangup, SWITCH_CHANNEL_ID_LOG, switch_channel_perform_mark_ring_ready_value(), switch_channel_test_flag(), switch_core_session_perform_receive_message(), SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_MESSAGE_INDICATE_RINGING, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

3634 {
3635  switch_core_session_message_t msg = { 0 };
3637 
3638  switch_assert(channel != NULL);
3639 
3640  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3641  return SWITCH_STATUS_FALSE;
3642  }
3643 
3644  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3645  return SWITCH_STATUS_SUCCESS;
3646  }
3647 
3648  if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3649  return SWITCH_STATUS_SUCCESS;
3650  }
3651 
3654  msg.from = channel->name;
3655  msg.numeric_arg = rv;
3656  status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
3657  }
3658 
3659  if (status == SWITCH_STATUS_SUCCESS) {
3660  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
3661  switch_channel_perform_mark_ring_ready_value(channel, rv, file, func, line);
3662  } else {
3664  }
3665 
3666  return status;
3667 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
switch_core_session_message_types_t message_id
Definition: switch_core.h:183
switch_status_t switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line)
Receive a message on a given session.
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.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:179
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)
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
switch_status_t
Common return values.
switch_channel_state_t state
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
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_assert(expr)
switch_core_session_t * session
switch_call_cause_t hangup_cause

◆ switch_channel_perform_set_callstate()

void switch_channel_perform_set_callstate ( switch_channel_t channel,
switch_channel_callstate_t  callstate,
const char *  file,
const char *  func,
int  line 
)

Definition at line 283 of file switch_channel.c.

References device_uuid_node_s::callstate, callstate, CCS_HANGUP, device_node, name, switch_channel_callstate2str(), switch_channel_check_device_state(), switch_channel_event_set_data(), switch_channel_get_uuid(), SWITCH_CHANNEL_ID_LOG, switch_event_add_header(), switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_CALLSTATE, switch_event_create, switch_event_fire, SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_STACK_BOTTOM, and SWITCH_STATUS_SUCCESS.

285 {
286  switch_event_t *event;
287  switch_channel_callstate_t o_callstate = channel->callstate;
288 
289  if (o_callstate == callstate || o_callstate == CCS_HANGUP) return;
290 
291  channel->callstate = callstate;
292  if (channel->device_node) {
293  channel->device_node->callstate = callstate;
294  }
296  "(%s) Callstate Change %s -> %s\n", channel->name,
298 
299  switch_channel_check_device_state(channel, channel->callstate);
300 
302  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Original-Channel-Call-State", switch_channel_callstate2str(o_callstate));
303  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Call-State-Number", "%d", callstate);
304  switch_channel_event_set_data(channel, event);
305  switch_event_fire(&event);
306  }
307 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
const char * switch_channel_callstate2str(switch_channel_callstate_t callstate)
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
Definition: switch_event.h:80
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
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 void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
switch_channel_callstate_t
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
switch_channel_callstate_t callstate
Definition: switch_core.h:85
#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
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
switch_channel_callstate_t callstate

◆ switch_channel_perform_set_running_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 
)

Definition at line 2366 of file switch_channel.c.

References careful_set(), CCS_ACTIVE, CCS_EARLY, CCS_RINGING, CF_ANSWERED, CF_EARLY_MEDIA, CF_FLAG_MAX, CF_TAGGED, CS_DESTROY, CS_HANGUP, CS_ROUTING, flag_mutex, flags, name, running_state, state_flags, state_mutex, state_names, SWITCH_CALL_DIRECTION_INBOUND, switch_channel_clear_flag(), switch_channel_direction(), switch_channel_event_set_data(), switch_channel_get_uuid(), SWITCH_CHANNEL_ID_LOG, switch_channel_set_callstate, switch_channel_test_flag(), switch_core_session_count(), switch_core_session_id(), SWITCH_EVENT_CHANNEL_STATE, switch_event_create, switch_event_fire, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_SIZE_T_FMT, and SWITCH_STATUS_SUCCESS.

2368 {
2369  int x;
2370 
2371  switch_mutex_lock(channel->flag_mutex);
2372  if (channel->state_flags[0]) {
2373  for (x = 1; x < CF_FLAG_MAX; x++) {
2374  if (channel->state_flags[x]) {
2375  channel->flags[x] = 1;
2376  channel->state_flags[x] = 0;
2377  }
2378  }
2379  channel->state_flags[0] = 0;
2380  }
2381  switch_mutex_unlock(channel->flag_mutex);
2382 
2384 
2385 
2386  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s (Cur %d Tot %" SWITCH_SIZE_T_FMT ")\n",
2388 
2389  switch_mutex_lock(channel->state_mutex);
2390 
2391  careful_set(channel, &channel->running_state, state);
2392 
2393  if (state <= CS_DESTROY) {
2394  switch_event_t *event;
2395 
2397  if (state < CS_HANGUP) {
2398  if (state == CS_ROUTING) {
2400  } else if (switch_channel_test_flag(channel, CF_ANSWERED)) {
2402  } else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
2404  }
2405  }
2406  }
2407 
2409  switch_channel_event_set_data(channel, event);
2410  switch_event_fire(&event);
2411  }
2412  }
2413 
2414  switch_mutex_unlock(channel->state_mutex);
2415 
2417 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
Representation of an event.
Definition: switch_event.h:80
static const char * state_names[]
switch_mutex_t * state_mutex
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_size_t switch_core_session_id(void)
Provide the current session_id.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_channel_state_t running_state
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
uint32_t switch_core_session_count(void)
Provide the total number of sessions.
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
#define switch_channel_set_callstate(channel, state)
#define SWITCH_SIZE_T_FMT
#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
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
static void careful_set(switch_channel_t *channel, switch_channel_state_t *state, switch_channel_state_t val)
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.
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
uint8_t state_flags[CF_FLAG_MAX]

◆ switch_channel_perform_set_state()

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 
)

Definition at line 2419 of file switch_channel.c.

References careful_set(), CS_CONSUME_MEDIA, CS_DESTROY, CS_EXCHANGE_MEDIA, CS_EXECUTE, CS_HANGUP, CS_HIBERNATE, CS_INIT, CS_NEW, CS_PARK, CS_REPORTING, CS_RESET, CS_ROUTING, CS_SOFT_EXECUTE, hangup_cause, name, session, state, state_mutex, state_names, switch_assert, SWITCH_CAUSE_NORMAL_CLEARING, switch_channel_get_uuid(), SWITCH_CHANNEL_ID_LOG, switch_core_session_signal_state_change(), SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_LOG_WARNING, switch_mutex_lock(), and switch_mutex_unlock().

2421 {
2422  switch_channel_state_t last_state;
2423  int ok = 0;
2424 
2425  switch_assert(channel != NULL);
2427  switch_mutex_lock(channel->state_mutex);
2428 
2429  last_state = channel->state;
2430  switch_assert(last_state <= CS_DESTROY);
2431 
2432  if (last_state == state) {
2433  goto done;
2434  }
2435 
2436  if (last_state >= CS_HANGUP && state < last_state) {
2437  goto done;
2438  }
2439 
2440  /* STUB for more dev
2441  case CS_INIT:
2442  switch(state) {
2443 
2444  case CS_NEW:
2445  case CS_INIT:
2446  case CS_EXCHANGE_MEDIA:
2447  case CS_SOFT_EXECUTE:
2448  case CS_ROUTING:
2449  case CS_EXECUTE:
2450  case CS_HANGUP:
2451  case CS_DESTROY:
2452 
2453  default:
2454  break;
2455  }
2456  break;
2457  */
2458 
2459  switch (last_state) {
2460  case CS_NEW:
2461  case CS_RESET:
2462  switch (state) {
2463  default:
2464  ok++;
2465  break;
2466  }
2467  break;
2468 
2469  case CS_INIT:
2470  switch (state) {
2471  case CS_EXCHANGE_MEDIA:
2472  case CS_SOFT_EXECUTE:
2473  case CS_ROUTING:
2474  case CS_EXECUTE:
2475  case CS_PARK:
2476  case CS_CONSUME_MEDIA:
2477  case CS_HIBERNATE:
2478  case CS_RESET:
2479  ok++;
2480  default:
2481  break;
2482  }
2483  break;
2484 
2485  case CS_EXCHANGE_MEDIA:
2486  switch (state) {
2487  case CS_SOFT_EXECUTE:
2488  case CS_ROUTING:
2489  case CS_EXECUTE:
2490  case CS_PARK:
2491  case CS_CONSUME_MEDIA:
2492  case CS_HIBERNATE:
2493  case CS_RESET:
2494  ok++;
2495  default:
2496  break;
2497  }
2498  break;
2499 
2500  case CS_SOFT_EXECUTE:
2501  switch (state) {
2502  case CS_EXCHANGE_MEDIA:
2503  case CS_ROUTING:
2504  case CS_EXECUTE:
2505  case CS_PARK:
2506  case CS_CONSUME_MEDIA:
2507  case CS_HIBERNATE:
2508  case CS_RESET:
2509  ok++;
2510  default:
2511  break;
2512  }
2513  break;
2514 
2515  case CS_PARK:
2516  switch (state) {
2517  case CS_EXCHANGE_MEDIA:
2518  case CS_ROUTING:
2519  case CS_EXECUTE:
2520  case CS_SOFT_EXECUTE:
2521  case CS_HIBERNATE:
2522  case CS_RESET:
2523  case CS_CONSUME_MEDIA:
2524  ok++;
2525  default:
2526  break;
2527  }
2528  break;
2529 
2530  case CS_CONSUME_MEDIA:
2531  switch (state) {
2532  case CS_EXCHANGE_MEDIA:
2533  case CS_ROUTING:
2534  case CS_EXECUTE:
2535  case CS_SOFT_EXECUTE:
2536  case CS_HIBERNATE:
2537  case CS_RESET:
2538  case CS_PARK:
2539  ok++;
2540  default:
2541  break;
2542  }
2543  break;
2544  case CS_HIBERNATE:
2545  switch (state) {
2546  case CS_EXCHANGE_MEDIA:
2547  case CS_INIT:
2548  case CS_ROUTING:
2549  case CS_EXECUTE:
2550  case CS_SOFT_EXECUTE:
2551  case CS_PARK:
2552  case CS_CONSUME_MEDIA:
2553  case CS_RESET:
2554  ok++;
2555  default:
2556  break;
2557  }
2558  break;
2559 
2560  case CS_ROUTING:
2561  switch (state) {
2562  case CS_EXCHANGE_MEDIA:
2563  case CS_EXECUTE:
2564  case CS_SOFT_EXECUTE:
2565  case CS_PARK:
2566  case CS_CONSUME_MEDIA:
2567  case CS_HIBERNATE:
2568  case CS_RESET:
2569  ok++;
2570  default:
2571  break;
2572  }
2573  break;
2574 
2575  case CS_EXECUTE:
2576  switch (state) {
2577  case CS_EXCHANGE_MEDIA:
2578  case CS_SOFT_EXECUTE:
2579  case CS_ROUTING:
2580  case CS_PARK:
2581  case CS_CONSUME_MEDIA:
2582  case CS_HIBERNATE:
2583  case CS_RESET:
2584  ok++;
2585  default:
2586  break;
2587  }
2588  break;
2589 
2590  case CS_HANGUP:
2591  switch (state) {
2592  case CS_REPORTING:
2593  case CS_DESTROY:
2594  ok++;
2595  default:
2596  break;
2597  }
2598  break;
2599 
2600  case CS_REPORTING:
2601  switch (state) {
2602  case CS_DESTROY:
2603  ok++;
2604  default:
2605  break;
2606  }
2607  break;
2608 
2609  default:
2610  break;
2611 
2612  }
2613 
2614  if (ok) {
2615  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) State Change %s -> %s\n",
2616  channel->name, state_names[last_state], state_names[state]);
2617 
2618  careful_set(channel, &channel->state, state);
2619 
2620  if (state == CS_HANGUP && !channel->hangup_cause) {
2622  }
2623 
2624  if (state <= CS_DESTROY) {
2626  }
2627  } else {
2629  "(%s) Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
2630  /* we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee! */
2631  /* not cool lets crash this bad boy and figure out wtf is going on */
2632  switch_assert(channel->state >= CS_HANGUP);
2633  }
2634  done:
2635 
2636  switch_mutex_unlock(channel->state_mutex);
2637  return channel->state;
2638 }
void switch_core_session_signal_state_change(_In_ switch_core_session_t *session)
static const char * state_names[]
switch_mutex_t * state_mutex
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
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel&#39;s unique id.
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
switch_channel_state_t state
static void careful_set(switch_channel_t *channel, switch_channel_state_t *state, switch_channel_state_t val)
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_assert(expr)
switch_core_session_t * session
switch_call_cause_t hangup_cause

◆ switch_channel_perform_video_sync()

void switch_channel_perform_video_sync ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 384 of file switch_channel.c.

References switch_core_session_message::_file, switch_core_session_message::_func, switch_core_session_message::_line, switch_core_session_message::from, switch_core_session_message::message_id, MESSAGE_STAMP_FFL, name, session, switch_channel_media_up, switch_core_session_alloc, switch_core_session_queue_message(), switch_core_session_request_video_refresh, and SWITCH_MESSAGE_INDICATE_VIDEO_SYNC.

385 {
386 
387  if (switch_channel_media_up(channel)) {
388  switch_core_session_message_t *msg = NULL;
389 
390  msg = switch_core_session_alloc(channel->session, sizeof(*msg));
391  MESSAGE_STAMP_FFL(msg);
393  msg->from = channel->name;
394  msg->_file = file;
395  msg->_func = func;
396  msg->_line = line;
397 
400  }
401 }
switch_core_session_message_types_t message_id
Definition: switch_core.h:183
switch_status_t switch_core_session_queue_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message)
Queue a message on a session.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:179
#define switch_core_session_request_video_refresh(_s)
Definition: switch_core.h:2881
#define MESSAGE_STAMP_FFL(_m)
Definition: switch_core.h:175
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
switch_core_session_t * session
#define switch_channel_media_up(_channel)

◆ switch_channel_process_export()

void switch_channel_process_export ( switch_channel_t channel,
switch_channel_t peer_channel,
switch_event_t var_event,
const char *  export_varname 
)

Definition at line 1252 of file switch_channel.c.

References session, switch_channel_get_name(), switch_channel_get_variable, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable, switch_core_session_strdup, switch_event_add_header_string(), switch_event_del_header, SWITCH_LOG_DEBUG, switch_log_printf(), switch_separate_string(), SWITCH_STACK_BOTTOM, and zstr.

Referenced by check_bridge_export(), switch_ivr_enterprise_originate(), and switch_ivr_originate().

1254 {
1255 
1256  const char *export_vars = switch_channel_get_variable(channel, export_varname);
1257  char *cptmp = switch_core_session_strdup(channel->session, export_vars);
1258  int argc;
1259  char *argv[256];
1260 
1261  if (zstr(export_vars)) return;
1262 
1263 
1264  if (var_event) {
1265  switch_event_del_header(var_event, export_varname);
1266  switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, export_varname, export_vars);
1267  }
1268 
1269  if (peer_channel) {
1270  switch_channel_set_variable(peer_channel, export_varname, export_vars);
1271  }
1272 
1273  if ((argc = switch_separate_string(cptmp, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
1274  int x;
1275 
1276  for (x = 0; x < argc; x++) {
1277  const char *vval;
1278  if ((vval = switch_channel_get_variable(channel, argv[x]))) {
1279  char *vvar = argv[x];
1280  if (!strncasecmp(vvar, "nolocal:", 8)) { /* remove this later ? */
1281  vvar += 8;
1282  } else if (!strncasecmp(vvar, "_nolocal_", 9)) {
1283  vvar += 9;
1284  }
1285  if (var_event) {
1286  switch_event_del_header(var_event, vvar);
1287  switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, vvar, vval);
1289  "%s EXPORTING[%s] [%s]=[%s] to event\n",
1290  switch_channel_get_name(channel),
1291  export_varname,
1292  vvar, vval);
1293  }
1294  if (peer_channel) {
1296  "%s EXPORTING[%s] [%s]=[%s] to %s\n",
1297  switch_channel_get_name(channel),
1298  export_varname,
1299  vvar, vval, switch_channel_get_name(peer_channel));
1300  switch_channel_set_variable(peer_channel, vvar, vval);
1301  }
1302  }
1303  }
1304  }
1305 
1306 
1307 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
#define zstr(x)
Definition: switch_utils.h:314
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)
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.
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_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
#define switch_channel_set_variable(_channel, _var, _val)
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_core_session_t * session

◆ switch_channel_queue_dtmf()

switch_status_t switch_channel_queue_dtmf ( _In_ switch_channel_t channel,
_In_ const switch_dtmf_t dtmf 
)

Queue DTMF on a given channel.

Parameters
channelchannel to queue DTMF to
dtmfdigit
Returns
SWITCH_STATUS_SUCCESS if successful

Referenced by inband_dtmf_callback(), speech_thread(), and switch_core_media_read_frame().

◆ switch_channel_queue_dtmf_string()

switch_status_t switch_channel_queue_dtmf_string ( _In_ switch_channel_t channel,
_In_ const char *  dtmf_string 
)

◆ switch_channel_restart()

void switch_channel_restart ( switch_channel_t channel)

Definition at line 3123 of file switch_channel.c.

References CS_EXECUTE, CS_RESET, switch_channel_set_state, and switch_channel_wait_for_state_timeout().

Referenced by switch_channel_var_true(), and switch_ivr_originate().

3124 {
3128 }
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
void switch_channel_wait_for_state_timeout(switch_channel_t *channel, switch_channel_state_t want_state, uint32_t timeout)

◆ switch_channel_set_app_flag_key()

void switch_channel_set_app_flag_key ( const char *  app,
switch_channel_t channel,
uint32_t  flags 
)

Definition at line 2070 of file switch_channel.c.

References app_flag_hash, flag_mutex, session, switch_assert, switch_core_hash_find(), switch_core_hash_init, switch_core_hash_insert, switch_core_session_alloc, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_media_negotiate_sdp(), switch_core_media_process_udptl(), switch_core_media_reset_t38(), and switch_ivr_eavesdrop_update_display().

2071 {
2072  uint32_t *flagp = NULL;
2073  switch_byte_t new = 0;
2074 
2075  switch_assert(channel != NULL);
2076  switch_mutex_lock(channel->flag_mutex);
2077 
2078  if (!channel->app_flag_hash) {
2080  new++;
2081  }
2082 
2083  if (new || !(flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
2084  flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
2085  switch_core_hash_insert(channel->app_flag_hash, key, flagp);
2086  }
2087 
2088  switch_assert(flagp);
2089  *flagp |= flags;
2090 
2091  switch_mutex_unlock(channel->flag_mutex);
2092 }
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
#define switch_core_hash_init(_hash)
Definition: switch_core.h:1431
switch_hash_t * app_flag_hash
uint8_t switch_byte_t
Definition: switch_types.h:256
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
switch_mutex_t * flag_mutex
#define switch_core_hash_insert(_h, _k, _d)
Definition: switch_core.h:1479
char * key
Definition: switch_msrp.c:64
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
#define switch_assert(expr)
switch_core_session_t * session

◆ switch_channel_set_bridge_time()

void switch_channel_set_bridge_time ( switch_channel_t channel)

Definition at line 3360 of file switch_channel.c.

References switch_channel_timetable::bridged, caller_profile, profile_mutex, switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), and switch_caller_profile::times.

Referenced by signal_bridge_on_hibernate(), and switch_ivr_multi_threaded_bridge().

3361 {
3362  switch_mutex_lock(channel->profile_mutex);
3363  if (channel->caller_profile && channel->caller_profile->times) {
3365  }
3367 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
struct switch_channel_timetable * times

◆ switch_channel_set_caller_extension()

void switch_channel_set_caller_extension ( switch_channel_t channel,
switch_caller_extension_t caller_extension 
)

Assign a caller extension to a given channel.

Parameters
channelchannel to assign extension to
caller_extensionextension to assign

Definition at line 3333 of file switch_channel.c.

References switch_caller_profile::caller_extension, caller_profile, switch_caller_extension::next, profile_mutex, switch_assert, switch_channel_sort_cid(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by audio_bridge_thread(), recover_callback(), switch_channel_caller_extension_masquerade(), switch_channel_var_true(), and switch_core_standard_on_routing().

3334 {
3335  switch_assert(channel != NULL);
3336 
3337  switch_channel_sort_cid(channel);
3338 
3339  switch_mutex_lock(channel->profile_mutex);
3340  caller_extension->next = channel->caller_profile->caller_extension;
3341  channel->caller_profile->caller_extension = caller_extension;
3343 }
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
struct switch_caller_extension * next
void switch_channel_sort_cid(switch_channel_t *channel)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_assert(expr)
struct switch_caller_extension * caller_extension

◆ switch_channel_set_caller_profile()

void switch_channel_set_caller_profile ( switch_channel_t channel,
switch_caller_profile_t caller_profile 
)

Set the given channel's caller profile.

Parameters
channelchannel to assign the profile to
caller_profilethe profile to assign

Definition at line 2863 of file switch_channel.c.

References switch_channel_timetable::answered, switch_caller_profile::caller_extension, caller_profile, switch_caller_profile::chan_name, switch_caller_profile::context, switch_channel_timetable::created, switch_caller_profile::direction, direction, switch_channel_timetable::hungup, switch_caller_profile::logical_direction, logical_direction, name, switch_caller_profile::next, switch_caller_profile::pool, switch_channel_timetable::profile_created, switch_caller_profile::profile_index, profile_index, profile_mutex, switch_channel_timetable::progress, switch_channel_timetable::progress_media, session, switch_assert, switch_caller_extension_clone(), switch_core_session_alloc, switch_core_session_get_uuid(), switch_core_session_strdup, switch_core_sprintf(), switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), switch_caller_profile::times, switch_channel_timetable::transferred, and switch_caller_profile::uuid.

Referenced by switch_channel_caller_extension_masquerade(), switch_channel_step_caller_profile(), switch_core_session_request_xml(), and switch_ivr_session_transfer().

2864 {
2865  char *uuid = NULL;
2866  switch_assert(channel != NULL);
2867  switch_assert(channel->session != NULL);
2868  switch_mutex_lock(channel->profile_mutex);
2869  switch_assert(caller_profile != NULL);
2870 
2871  caller_profile->direction = channel->direction;
2872  caller_profile->logical_direction = channel->logical_direction;
2873  uuid = switch_core_session_get_uuid(channel->session);
2874 
2875  if (!caller_profile->uuid || strcasecmp(caller_profile->uuid, uuid)) {
2876  caller_profile->uuid = switch_core_session_strdup(channel->session, uuid);
2877  }
2878 
2879  if (!caller_profile->chan_name || strcasecmp(caller_profile->chan_name, channel->name)) {
2880  caller_profile->chan_name = switch_core_session_strdup(channel->session, channel->name);
2881  }
2882 
2883  if (!caller_profile->context) {
2884  caller_profile->context = switch_core_session_strdup(channel->session, "default");
2885  }
2886 
2887  if (!caller_profile->times) {
2888  caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times));
2889  caller_profile->times->profile_created = switch_micro_time_now();
2890  }
2891 
2892  if (channel->caller_profile && channel->caller_profile->times) {
2893  channel->caller_profile->times->transferred = caller_profile->times->profile_created;
2894  caller_profile->times->answered = channel->caller_profile->times->answered;
2895  caller_profile->times->progress = channel->caller_profile->times->progress;
2896  caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
2897  caller_profile->times->created = channel->caller_profile->times->created;
2898  caller_profile->times->hungup = channel->caller_profile->times->hungup;
2899  if (channel->caller_profile->caller_extension) {
2900  switch_caller_extension_clone(&caller_profile->caller_extension, channel->caller_profile->caller_extension, caller_profile->pool);
2901  }
2902  } else {
2903  caller_profile->times->created = switch_micro_time_now();
2904  }
2905 
2906 
2907  caller_profile->next = channel->caller_profile;
2908  channel->caller_profile = caller_profile;
2909  caller_profile->profile_index = switch_core_sprintf(caller_profile->pool, "%d", ++channel->profile_index);
2910 
2912 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
switch_call_direction_t logical_direction
switch_caller_profile_t * caller_profile
struct switch_caller_profile * next
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_time_t profile_created
switch_call_direction_t direction
const char * profile_index
switch_status_t switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, switch_memory_pool_t *pool)
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_call_direction_t direction
struct switch_channel_timetable * times
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...
#define switch_assert(expr)
switch_core_session_t * session
switch_time_t progress_media
struct switch_caller_extension * caller_extension
switch_memory_pool_t * pool

◆ switch_channel_set_cap_value()

void switch_channel_set_cap_value ( switch_channel_t channel,
switch_channel_cap_t  cap,
uint32_t  value 
)

Definition at line 1854 of file switch_channel.c.

References caps, flag_mutex, switch_assert, switch_mutex_lock(), switch_mutex_unlock(), and value.

Referenced by switch_core_session_request_xml().

1855 {
1856  switch_assert(channel);
1857  switch_assert(channel->flag_mutex);
1858 
1859  switch_mutex_lock(channel->flag_mutex);
1860  channel->caps[cap] = value;
1861  switch_mutex_unlock(channel->flag_mutex);
1862 }
const char *const const char *const const cJSON *const value
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
switch_mutex_t * flag_mutex
uint32_t caps[CC_FLAG_MAX]
#define switch_assert(expr)

◆ switch_channel_set_direction()

void switch_channel_set_direction ( switch_channel_t channel,
switch_call_direction_t  direction 
)

Definition at line 432 of file switch_channel.c.

References direction, logical_direction, session, SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_direction(), switch_channel_set_variable, and switch_core_session_in_thread().

433 {
434  if (!switch_core_session_in_thread(channel->session)) {
435  channel->direction = channel->logical_direction = direction;
436  switch_channel_set_variable(channel, "direction", switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
437  }
438 }
switch_call_direction_t logical_direction
switch_call_direction_t direction
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
switch_bool_t switch_core_session_in_thread(switch_core_session_t *session)

◆ switch_channel_set_flag_partner()

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.

Parameters
channelchannel to derive the partner channel to set flag on
flagto set
Returns
true if the flag was set

Definition at line 1690 of file switch_channel.c.

References switch_assert, switch_channel_get_partner_uuid(), switch_channel_set_flag, switch_core_session_get_channel(), switch_core_session_locate, switch_core_session_rwunlock(), SWITCH_FALSE, and SWITCH_TRUE.

Referenced by switch_channel_perform_mark_answered().

1691 {
1692  const char *uuid;
1693 
1694  switch_assert(channel != NULL);
1695 
1696  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1697  switch_core_session_t *session;
1698  if ((session = switch_core_session_locate(uuid))) {
1701  return SWITCH_TRUE;
1702  }
1703  }
1704 
1705  return SWITCH_FALSE;
1706 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#define switch_channel_set_flag(_c, _f)
#define switch_assert(expr)

◆ switch_channel_set_flag_recursive()

void switch_channel_set_flag_recursive ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 2029 of file switch_channel.c.

References CF_OUTBOUND, CF_RECOVERED, flag_mutex, flags, switch_assert, switch_channel_set_variable, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by eavesdrop_callback(), switch_core_media_bug_add(), switch_core_media_set_video_file(), switch_ivr_multi_threaded_bridge(), switch_ivr_parse_event(), switch_ivr_record_file_event(), switch_ivr_session_echo(), switch_ivr_signal_bridge(), switch_jb_get_packet(), and text_bridge_thread().

2030 {
2031  switch_assert(channel);
2032  switch_assert(channel->flag_mutex);
2033 
2034  switch_mutex_lock(channel->flag_mutex);
2035  channel->flags[flag]++;
2036  switch_mutex_unlock(channel->flag_mutex);
2037 
2038  if (flag == CF_OUTBOUND) {
2039  switch_channel_set_variable(channel, "is_outbound", "true");
2040  }
2041 
2042  if (flag == CF_RECOVERED) {
2043  switch_channel_set_variable(channel, "recovered", "true");
2044  }
2045 }
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
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)

◆ switch_channel_set_flag_value()

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.

Parameters
channelchannel on which to set flag
flagor'd list of flags to set

Definition at line 1950 of file switch_channel.c.

References caller_profile, CCS_HELD, CCS_RING_WAIT, CF_ANSWERED, CF_DIALPLAN, CF_LEG_HOLDING, CF_ORIGINATOR, CF_OUTBOUND, CF_RECOVERED, CF_VIDEO, CF_VIDEO_BLANK, CF_VIDEO_DECODED_READ, CF_VIDEO_ECHO, CF_VIDEO_PASSIVE, CF_VIDEO_READY, device_node, device_uuid_node_s::direction, direction, flag_mutex, flags, hold_record, switch_channel_timetable::last_hold, logical_direction, switch_hold_record_s::next, switch_hold_record_s::on, profile_mutex, session, switch_assert, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_get_partner_uuid(), switch_channel_set_callstate, switch_channel_set_variable, switch_channel_test_flag(), switch_channel_up_nosig, switch_core_session_alloc, switch_core_session_request_video_refresh, switch_core_session_start_video_thread(), switch_core_session_strdup, switch_mutex_lock(), switch_mutex_unlock(), switch_time_now(), switch_caller_profile::times, switch_hold_record_s::uuid, and value.

Referenced by switch_channel_perform_mark_ring_ready_value(), switch_channel_var_true(), and switch_core_session_request_xml().

1951 {
1952  int HELD = 0;
1953  int just_set = 0;
1954 
1955  switch_assert(channel);
1956  switch_assert(channel->flag_mutex);
1957 
1958  switch_mutex_lock(channel->flag_mutex);
1959  if (flag == CF_LEG_HOLDING && !channel->flags[flag] && channel->flags[CF_ANSWERED]) {
1960  HELD = 1;
1961  }
1962  if (channel->flags[flag] != value) {
1963  just_set = 1;
1964  channel->flags[flag] = value;
1965  }
1966  switch_mutex_unlock(channel->flag_mutex);
1967 
1968  if (flag == CF_VIDEO_READY && just_set) {
1970  }
1971 
1972  if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
1974  }
1975 
1976  if (flag == CF_DIALPLAN) {
1977  if (channel->direction == SWITCH_CALL_DIRECTION_INBOUND) {
1979  if (channel->device_node) {
1981  }
1982  } else {
1984  if (channel->device_node) {
1986  }
1987  }
1988  }
1989 
1990  if (HELD) {
1992  const char *brto = switch_channel_get_partner_uuid(channel);
1993 
1995  switch_mutex_lock(channel->profile_mutex);
1997 
1998  hr = switch_core_session_alloc(channel->session, sizeof(*hr));
1999  hr->on = switch_time_now();
2000  if (brto) {
2001  hr->uuid = switch_core_session_strdup(channel->session, brto);
2002  }
2003 
2004  if (channel->hold_record) {
2005  hr->next = channel->hold_record;
2006  }
2007  channel->hold_record = hr;
2008 
2010  }
2011 
2012  if (flag == CF_OUTBOUND) {
2013  switch_channel_set_variable(channel, "is_outbound", "true");
2014  }
2015 
2016  if (flag == CF_RECOVERED) {
2017  switch_channel_set_variable(channel, "recovered", "true");
2018  }
2019 
2020  if (flag == CF_VIDEO_ECHO || flag == CF_VIDEO_BLANK || flag == CF_VIDEO_DECODED_READ || flag == CF_VIDEO_PASSIVE) {
2022  }
2023 
2024  if (flag == CF_VIDEO_DECODED_READ && channel->flags[CF_VIDEO]) {
2026  }
2027 }
struct switch_hold_record_s * next
Definition: switch_core.h:78
switch_caller_profile_t * caller_profile
switch_hold_record_t * hold_record
const char *const const char *const const cJSON *const value
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.
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_time_t on
Definition: switch_core.h:75
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_core_session_request_video_refresh(_s)
Definition: switch_core.h:2881
switch_call_direction_t direction
Definition: switch_core.h:88
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_channel_set_callstate(channel, state)
switch_call_direction_t direction
switch_status_t switch_core_session_start_video_thread(switch_core_session_t *session)
struct switch_channel_timetable * times
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
switch_device_node_t * device_node
#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
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
Definition: switch_apr.c:325
switch_core_session_t * session

◆ switch_channel_set_hangup_time()

void switch_channel_set_hangup_time ( switch_channel_t channel)

Definition at line 3370 of file switch_channel.c.

References caller_profile, switch_channel_timetable::hungup, profile_mutex, switch_micro_time_now(), switch_mutex_lock(), switch_mutex_unlock(), and switch_caller_profile::times.

Referenced by switch_core_session_hangup_state().

3371 {
3372  if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
3373  switch_mutex_lock(channel->profile_mutex);
3376  }
3377 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
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
struct switch_channel_timetable * times

◆ switch_channel_set_hunt_caller_profile()

void switch_channel_set_hunt_caller_profile ( switch_channel_t channel,
switch_caller_profile_t caller_profile 
)

Definition at line 2945 of file switch_channel.c.

References caller_profile, switch_caller_profile::direction, direction, switch_caller_profile::hunt_caller_profile, switch_caller_profile::logical_direction, logical_direction, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_execute_exten().

2946 {
2947  switch_assert(channel != NULL);
2948  switch_assert(channel->caller_profile != NULL);
2949 
2950  switch_mutex_lock(channel->profile_mutex);
2951 
2952  channel->caller_profile->hunt_caller_profile = NULL;
2953  if (channel->caller_profile && caller_profile) {
2954  caller_profile->direction = channel->direction;
2955  caller_profile->logical_direction = channel->logical_direction;
2956  channel->caller_profile->hunt_caller_profile = caller_profile;
2957  }
2959 }
switch_call_direction_t logical_direction
switch_caller_profile_t * caller_profile
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_call_direction_t direction
switch_call_direction_t direction
struct switch_caller_profile * hunt_caller_profile
#define switch_assert(expr)

◆ switch_channel_set_log_tag()

switch_status_t switch_channel_set_log_tag ( switch_channel_t channel,
const char *  tagname,
const char *  tagvalue 
)

Definition at line 1453 of file switch_channel.c.

References log_tags, profile_mutex, switch_assert, switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_DATA, switch_event_create_plain(), switch_event_del_header, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.

1454 {
1456  switch_assert(channel != NULL);
1457  switch_mutex_lock(channel->profile_mutex);
1458  if (!zstr(tagname)) {
1459  if (!channel->log_tags) {
1461  }
1462  if (zstr(tagvalue)) {
1463  switch_event_del_header(channel->log_tags, tagname);
1464  } else {
1465  switch_event_add_header_string(channel->log_tags, SWITCH_STACK_BOTTOM, tagname, tagvalue);
1466  }
1467  status = SWITCH_STATUS_SUCCESS;
1468  }
1470  return status;
1471 }
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_event_t * log_tags
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 switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
Definition: switch_event.h:386
switch_status_t
Common return values.
#define switch_assert(expr)

◆ switch_channel_set_name()

switch_status_t switch_channel_set_name ( switch_channel_t channel,
const char *  name 
)

Assign a name to a given channel.

Parameters
channelchannel to assign name to
namename to assign
Returns
SWITCH_STATUS_SUCCESS if name was assigned

Definition at line 1126 of file switch_channel.c.

References name, session, switch_assert, SWITCH_CHANNEL_CHANNEL_LOG, SWITCH_CHANNEL_NAME_VARIABLE, switch_channel_set_variable, switch_core_session_get_uuid(), switch_core_session_strdup, SWITCH_LOG_NOTICE, switch_log_printf(), SWITCH_STATUS_SUCCESS, and zstr.

Referenced by switch_core_session_request_xml(), and switch_ivr_originate().

1127 {
1128  const char *old = NULL;
1129 
1130  switch_assert(channel != NULL);
1131  if (!zstr(channel->name)) {
1132  old = channel->name;
1133  }
1134  channel->name = NULL;
1135  if (name) {
1136  char *uuid = switch_core_session_get_uuid(channel->session);
1137  channel->name = switch_core_session_strdup(channel->session, name);
1139  if (old) {
1140  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_NOTICE, "Rename Channel %s->%s [%s]\n", old, name, uuid);
1141  } else {
1142  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_NOTICE, "New Channel %s [%s]\n", name, uuid);
1143  }
1144  }
1145  return SWITCH_STATUS_SUCCESS;
1146 }
#define zstr(x)
Definition: switch_utils.h:314
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
#define SWITCH_CHANNEL_NAME_VARIABLE
Definition: switch_types.h:183
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.
const char *const name
Definition: switch_cJSON.h:250
#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)
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_set_originatee_caller_profile()

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.

Parameters
channelchannel to assign the profile to
caller_profilethe profile to assign

Definition at line 2991 of file switch_channel.c.

References caller_profile, last_profile_type, LP_ORIGINATEE, switch_caller_profile::next, switch_caller_profile::originatee_caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_request_xml(), switch_ivr_enterprise_originate(), switch_ivr_originate(), and switch_ivr_uuid_bridge().

2992 {
2993  switch_assert(channel != NULL);
2994  switch_assert(channel->caller_profile != NULL);
2995 
2996  switch_mutex_lock(channel->profile_mutex);
2997 
2998  if (channel->caller_profile) {
2999  caller_profile->next = channel->caller_profile->originatee_caller_profile;
3000  channel->caller_profile->originatee_caller_profile = caller_profile;
3001  channel->last_profile_type = LP_ORIGINATEE;
3002  }
3005 }
struct switch_caller_profile * originatee_caller_profile
switch_caller_profile_t * caller_profile
struct switch_caller_profile * next
switch_mutex_t * profile_mutex
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
switch_originator_type_t last_profile_type
#define switch_assert(expr)

◆ switch_channel_set_origination_caller_profile()

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.

Parameters
channelchannel to assign the profile to
caller_profilethe profile to assign

Definition at line 2961 of file switch_channel.c.

References caller_profile, switch_caller_profile::next, switch_caller_profile::origination_caller_profile, profile_mutex, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_outgoing_channel().

2962 {
2963  switch_assert(channel != NULL);
2964  switch_assert(channel->caller_profile != NULL);
2965 
2966  switch_mutex_lock(channel->profile_mutex);
2967 
2968  if (channel->caller_profile) {
2969  caller_profile->next = channel->caller_profile->origination_caller_profile;
2970  channel->caller_profile->origination_caller_profile = caller_profile;
2971  }
2974 }
switch_caller_profile_t * caller_profile
struct switch_caller_profile * next
switch_mutex_t * profile_mutex
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
struct switch_caller_profile * origination_caller_profile
#define switch_assert(expr)

◆ switch_channel_set_originator_caller_profile()

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.

Parameters
channelchannel to assign the profile to
caller_profilethe profile to assign

Definition at line 2926 of file switch_channel.c.

References caller_profile, last_profile_type, LP_ORIGINATOR, switch_caller_profile::next, switch_caller_profile::originator_caller_profile, switch_caller_profile::pool, profile_mutex, switch_assert, switch_core_alloc, switch_mutex_lock(), switch_mutex_unlock(), and switch_caller_profile::times.

Referenced by switch_core_session_outgoing_channel(), switch_core_session_request_xml(), switch_ivr_enterprise_originate(), and switch_ivr_uuid_bridge().

2927 {
2928  switch_assert(channel != NULL);
2929  switch_assert(channel->caller_profile != NULL);
2930  switch_mutex_lock(channel->profile_mutex);
2931 
2932  if (!caller_profile->times) {
2933  caller_profile->times = (switch_channel_timetable_t *) switch_core_alloc(caller_profile->pool, sizeof(*caller_profile->times));
2934  }
2935 
2936  if (channel->caller_profile) {
2937  caller_profile->next = channel->caller_profile->originator_caller_profile;
2938  channel->caller_profile->originator_caller_profile = caller_profile;
2939  channel->last_profile_type = LP_ORIGINATOR;
2940  }
2943 }
switch_caller_profile_t * caller_profile
struct switch_caller_profile * next
switch_mutex_t * profile_mutex
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
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
switch_originator_type_t last_profile_type
struct switch_caller_profile * originator_caller_profile
struct switch_channel_timetable * times
#define switch_assert(expr)
switch_memory_pool_t * pool

◆ switch_channel_set_presence_data_vals()

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.

Parameters
channelthe channel on which to set the channel profile variables
presence_data_colsis a colon separated list of channel variables to copy to channel profile variables

Definition at line 1425 of file switch_channel.c.

References switch_channel_get_variable, switch_channel_get_variable_dup(), switch_channel_set_profile_var(), SWITCH_FALSE, switch_safe_free, switch_snprintf(), switch_split, and zstr.

1426 {
1427  char *cols[128] = { 0 };
1428  char header_name[128] = "";
1429  int col_count = 0, i = 0;
1430  char *data_copy = NULL;
1431 
1432  if (zstr(presence_data_cols)) {
1433  presence_data_cols = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1);
1434  if (zstr(presence_data_cols)) {
1435  return;
1436  }
1437  }
1438 
1439  data_copy = strdup(presence_data_cols);
1440 
1441  col_count = switch_split(data_copy, ':', cols);
1442 
1443  for (i = 0; i < col_count; i++) {
1444  const char *val = NULL;
1445  switch_snprintf(header_name, sizeof(header_name), "PD-%s", cols[i]);
1446  val = switch_channel_get_variable(channel, cols[i]);
1447  switch_channel_set_profile_var(channel, header_name, val);
1448  }
1449 
1450  switch_safe_free(data_copy);
1451 }
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.
#define switch_split(_data, _delim, _array)
Definition: switch_utils.h:375
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.
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define zstr(x)
Definition: switch_utils.h:314
#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_channel_set_private()

switch_status_t switch_channel_set_private ( switch_channel_t channel,
const char *  key,
const void *  private_info 
)

Set private data on channel.

Parameters
channelchannel on which to set data
keyunique keyname to associate your private data to
private_infovoid pointer to private data
Returns
SWITCH_STATUS_SUCCESS if data was set
Remarks
set NULL to delete your private data

Definition at line 1093 of file switch_channel.c.

References private_hash, profile_mutex, switch_assert, switch_core_hash_insert_locked(), and SWITCH_STATUS_SUCCESS.

Referenced by audio_bridge_on_exchange_media(), check_channel_status(), CoreSession::destroy(), monitor_callback(), preprocess_callback(), read_displace_callback(), record_callback(), session_audio_callback(), CoreSession::setDTMFCallback(), CoreSession::setHangupHook(), CoreSession::setPrivate(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), speech_callback(), switch_core_media_copy_t38_options(), switch_core_media_process_udptl(), switch_core_media_reset_t38(), switch_ivr_activate_unicast(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_block_dtmf_session(), switch_ivr_capture_text(), switch_ivr_clear_speech_cache(), switch_ivr_detect_speech_init(), switch_ivr_displace_session(), switch_ivr_inband_dtmf_generate_session(), switch_ivr_inband_dtmf_session(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_ivr_play_file(), switch_ivr_preprocess_session(), switch_ivr_record_session_event(), switch_ivr_session_audio(), switch_ivr_speak_text(), switch_ivr_stop_detect_speech(), switch_ivr_stop_displace_session(), switch_ivr_stop_inband_dtmf_generate_session(), switch_ivr_stop_inband_dtmf_session(), switch_ivr_stop_session_audio(), switch_ivr_stop_tone_detect_session(), switch_ivr_stop_video_write_overlay_session(), switch_ivr_tone_detect_session(), switch_ivr_unbind_dtmf_meta_session(), switch_ivr_unblock_dtmf_session(), switch_ivr_video_write_overlay_session(), switch_rtp_create(), and write_displace_callback().

1094 {
1095  switch_assert(channel != NULL);
1096  switch_core_hash_insert_locked(channel->private_hash, key, private_info, channel->profile_mutex);
1097  return SWITCH_STATUS_SUCCESS;
1098 }
switch_hash_t * private_hash
switch_mutex_t * profile_mutex
switch_status_t switch_core_hash_insert_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data, _In_opt_ switch_mutex_t *mutex)
Insert data into a hash.
char * key
Definition: switch_msrp.c:64
#define switch_assert(expr)

◆ switch_channel_set_private_flag()

void switch_channel_set_private_flag ( switch_channel_t channel,
uint32_t  flags 
)

Definition at line 2048 of file switch_channel.c.

References flag_mutex, private_flags, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

2049 {
2050  switch_assert(channel != NULL);
2051  switch_mutex_lock(channel->flag_mutex);
2052  channel->private_flags |= flags;
2053  switch_mutex_unlock(channel->flag_mutex);
2054 }
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
uint32_t private_flags
switch_mutex_t * flag_mutex
#define switch_assert(expr)

◆ switch_channel_set_profile_var()

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.

Parameters
channelchannel to set variable on
varnamethe name of the variable
valuethe value of the variable
Returns
SWITCH_STATUS_SUCCESS if successful

Definition at line 1154 of file switch_channel.c.

References switch_caller_profile::ani, switch_caller_profile::aniii, switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, switch_caller_profile::caller_id_name, switch_caller_profile::caller_id_number, switch_caller_profile::caller_numplan, caller_profile, switch_caller_profile::caller_ton, switch_caller_profile::chan_name, switch_caller_profile::context, switch_caller_profile::destination_number, switch_caller_profile::destination_number_numplan, switch_caller_profile::destination_number_ton, switch_caller_profile::dialplan, switch_caller_profile::network_addr, profile_node_s::next, switch_caller_profile::pool, profile_mutex, switch_caller_profile::rdnis, switch_caller_profile::soft, switch_caller_profile::source, SWITCH_BLANK_STRING, switch_channel_set_device_id(), switch_core_alloc, switch_core_strdup, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, switch_caller_profile::username, switch_caller_profile::uuid, profile_node_s::val, profile_node_s::var, and zstr.

Referenced by switch_channel_set_presence_data_vals(), switch_ivr_originate(), and switch_ivr_set_user_xml().

1155 {
1156  char *v;
1158 
1159  switch_mutex_lock(channel->profile_mutex);
1160 
1161 
1162  if (!strcasecmp(name, "device_id") && !zstr(val)) {
1163  const char *device_id;
1164  if (!(device_id = switch_channel_set_device_id(channel, val))) {
1165  /* one time setting */
1167  return status;
1168  }
1169 
1170  val = device_id;
1171  }
1172 
1173  if (!zstr(val)) {
1174  v = switch_core_strdup(channel->caller_profile->pool, val);
1175  } else {
1176  v = SWITCH_BLANK_STRING;
1177  }
1178 
1179  if (!strcasecmp(name, "dialplan")) {
1180  channel->caller_profile->dialplan = v;
1181  } else if (!strcasecmp(name, "username")) {
1182  channel->caller_profile->username = v;
1183  } else if (!strcasecmp(name, "caller_id_name")) {
1184  channel->caller_profile->caller_id_name = v;
1185  } else if (!strcasecmp(name, "caller_id_number")) {
1186  channel->caller_profile->caller_id_number = v;
1187  } else if (!strcasecmp(name, "callee_id_name")) {
1188  channel->caller_profile->callee_id_name = v;
1189  } else if (!strcasecmp(name, "callee_id_number")) {
1190  channel->caller_profile->callee_id_number = v;
1191  } else if (val && !strcasecmp(name, "caller_ton")) {
1192  channel->caller_profile->caller_ton = (uint8_t) atoi(v);
1193  } else if (val && !strcasecmp(name, "caller_numplan")) {
1194  channel->caller_profile->caller_numplan = (uint8_t) atoi(v);
1195  } else if (val && !strcasecmp(name, "destination_number_ton")) {
1196  channel->caller_profile->destination_number_ton = (uint8_t) atoi(v);
1197  } else if (val && !strcasecmp(name, "destination_number_numplan")) {
1198  channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v);
1199  } else if (!strcasecmp(name, "ani")) {
1200  channel->caller_profile->ani = v;
1201  } else if (!strcasecmp(name, "aniii")) {
1202  channel->caller_profile->aniii = v;
1203  } else if (!strcasecmp(name, "network_addr")) {
1204  channel->caller_profile->network_addr = v;
1205  } else if (!strcasecmp(name, "rdnis")) {
1206  channel->caller_profile->rdnis = v;
1207  } else if (!strcasecmp(name, "destination_number")) {
1208  channel->caller_profile->destination_number = v;
1209  } else if (!strcasecmp(name, "uuid")) {
1210  channel->caller_profile->uuid = v;
1211  } else if (!strcasecmp(name, "source")) {
1212  channel->caller_profile->source = v;
1213  } else if (!strcasecmp(name, "context")) {
1214  channel->caller_profile->context = v;
1215  } else if (!strcasecmp(name, "chan_name")) {
1216  channel->caller_profile->chan_name = v;
1217  } else {
1218  profile_node_t *pn, *n = switch_core_alloc(channel->caller_profile->pool, sizeof(*n));
1219  int var_found;
1220 
1221  n->var = switch_core_strdup(channel->caller_profile->pool, name);
1222  n->val = v;
1223 
1224  if (!channel->caller_profile->soft) {
1225  channel->caller_profile->soft = n;
1226  } else {
1227  var_found = 0;
1228 
1229  for(pn = channel->caller_profile->soft; pn ; pn = pn->next) {
1230  if (!strcasecmp(pn->var,n->var)) {
1231  pn->val = n->val;
1232  var_found = 1;
1233  break;
1234  }
1235 
1236  if(!pn->next) {
1237  break;
1238  }
1239  }
1240 
1241  if (pn && !pn->next && !var_found) {
1242  pn->next = n;
1243  }
1244  }
1245  }
1247 
1248  return status;
1249 }
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
const char * network_addr
Definition: switch_caller.h:93
switch_caller_profile_t * caller_profile
const char * dialplan
Definition: switch_caller.h:77
const char * username
Definition: switch_caller.h:75
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
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
const char * callee_id_number
Definition: switch_caller.h:89
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_BLANK_STRING
Definition: switch_types.h:48
struct profile_node_s * next
Definition: switch_caller.h:66
uint8_t destination_number_numplan
const char * switch_channel_set_device_id(switch_channel_t *channel, const char *device_id)
switch_status_t
Common return values.
const char * caller_id_number
Definition: switch_caller.h:81
profile_node_t * soft
const char *const name
Definition: switch_cJSON.h:250
const char * callee_id_name
Definition: switch_caller.h:87
switch_memory_pool_t * pool

◆ switch_channel_set_scope_variables()

void switch_channel_set_scope_variables ( switch_channel_t channel,
switch_event_t **  event 
)

Definition at line 928 of file switch_channel.c.

References switch_event::next, profile_mutex, scope_variables, switch_event_destroy(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_exec().

929 {
931 
932  if (event && *event) { /* push */
933  (*event)->next = channel->scope_variables;
934  channel->scope_variables = *event;
935  *event = NULL;
936  } else if (channel->scope_variables) { /* pop */
937  switch_event_t *top_event = channel->scope_variables;
938  channel->scope_variables = channel->scope_variables->next;
939  switch_event_destroy(&top_event);
940  }
941 
943 
944 }
Representation of an event.
Definition: switch_event.h:80
struct switch_event * next
Definition: switch_event.h:101
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_event_t * scope_variables
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
void switch_event_destroy(switch_event_t **event)
Destroy an event.

◆ switch_channel_set_state_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.

Parameters
channelchannel on which to set flag(s)
flagflag to set

Definition at line 2126 of file switch_channel.c.

References flag_mutex, state_flags, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_intercept_session(), switch_ivr_signal_bridge(), and switch_ivr_uuid_bridge().

2127 {
2128  switch_assert(channel != NULL);
2129 
2130  switch_mutex_lock(channel->flag_mutex);
2131  channel->state_flags[0] = 1;
2132  channel->state_flags[flag] = 1;
2133  switch_mutex_unlock(channel->flag_mutex);
2134 }
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
switch_mutex_t * flag_mutex
#define switch_assert(expr)
uint8_t state_flags[CF_FLAG_MAX]

◆ switch_channel_set_timestamps()

switch_status_t switch_channel_set_timestamps ( _In_ switch_channel_t channel)

◆ switch_channel_set_variable_name_printf()

switch_status_t switch_channel_set_variable_name_printf ( switch_channel_t channel,
const char *  val,
const char *  fmt,
  ... 
)

Definition at line 1626 of file switch_channel.c.

References profile_mutex, switch_assert, switch_channel_set_variable, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_MEMERR, and switch_vasprintf().

Referenced by switch_core_media_build_crypto(), switch_ivr_multi_threaded_bridge(), and tone_detect_set_total_time().

1627 {
1628  int ret = 0;
1629  char *varname;
1630  va_list ap;
1632 
1633  switch_assert(channel != NULL);
1634 
1635  switch_mutex_lock(channel->profile_mutex);
1636 
1637  va_start(ap, fmt);
1638  ret = switch_vasprintf(&varname, fmt, ap);
1639  va_end(ap);
1640 
1641  if (ret == -1) {
1643  return SWITCH_STATUS_MEMERR;
1644  }
1645 
1646  status = switch_channel_set_variable(channel, varname, val);
1647 
1648  free(varname);
1649 
1651 
1652  return status;
1653 }
int cJSON_bool fmt
Definition: switch_cJSON.h:150
switch_mutex_t * profile_mutex
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
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
switch_status_t
Common return values.
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)

◆ switch_channel_set_variable_partner_var_check()

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 
)

Definition at line 1656 of file switch_channel.c.

References switch_assert, switch_channel_get_partner_uuid(), switch_channel_set_variable_var_check(), switch_core_session_get_channel(), switch_core_session_locate, switch_core_session_rwunlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.

1658 {
1659  const char *uuid;
1660  switch_assert(channel != NULL);
1661 
1662  if (!zstr(varname)) {
1663  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1664  switch_core_session_t *session;
1665  if ((session = switch_core_session_locate(uuid))) {
1667  switch_channel_set_variable_var_check(tchannel, varname, value, var_check);
1669  }
1670  return SWITCH_STATUS_SUCCESS;
1671  }
1672  }
1673 
1674  return SWITCH_STATUS_FALSE;
1675 }
const char *const const char *const const cJSON *const value
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
#define zstr(x)
Definition: switch_utils.h:314
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_status_t switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#define switch_assert(expr)

◆ switch_channel_set_variable_printf()

switch_status_t switch_channel_set_variable_printf ( switch_channel_t channel,
const char *  varname,
const char *  fmt,
  ... 
)

Definition at line 1595 of file switch_channel.c.

References profile_mutex, switch_assert, switch_channel_set_variable, switch_event_del_header, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_MEMERR, switch_vasprintf(), variables, and zstr.

Referenced by check_jb_size(), play_and_detect_input_callback(), send_record_stop_event(), switch_core_media_activate_rtp(), switch_core_media_choose_port(), switch_core_media_get_video_fps(), switch_core_media_negotiate_sdp(), switch_core_media_read_frame(), switch_core_media_receive_message(), switch_core_media_recover_session(), switch_core_media_set_codec(), switch_core_media_set_video_codec(), switch_core_session_check_incoming_crypto(), switch_core_session_hangup_state(), switch_core_session_read_video_frame(), switch_core_session_request_uuid(), switch_ivr_detect_audio(), switch_ivr_detect_silence(), switch_ivr_parse_event(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_wait_for_silence(), switch_jb_reset(), switch_jb_set_jitter_estimator(), switch_limit_incr(), and switch_rtp_sync_stats().

1596 {
1597  int ret = 0;
1598  char *data;
1599  va_list ap;
1601 
1602  switch_assert(channel != NULL);
1603 
1604  switch_mutex_lock(channel->profile_mutex);
1605  if (channel->variables && !zstr(varname)) {
1606  switch_event_del_header(channel->variables, varname);
1607 
1608  va_start(ap, fmt);
1609  ret = switch_vasprintf(&data, fmt, ap);
1610  va_end(ap);
1611 
1612  if (ret == -1) {
1614  return SWITCH_STATUS_MEMERR;
1615  }
1616 
1617  status = switch_channel_set_variable(channel, varname, data);
1618  free(data);
1619  }
1621 
1622  return status;
1623 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
#define zstr(x)
Definition: switch_utils.h:314
int cJSON_bool fmt
Definition: switch_cJSON.h:150
switch_mutex_t * profile_mutex
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
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
switch_status_t
Common return values.
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)

◆ switch_channel_set_variable_strip_quotes_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 
)

Definition at line 1518 of file switch_channel.c.

References end_of, profile_mutex, switch_assert, SWITCH_CHANNEL_CHANNEL_LOG, switch_event_add_header_string(), switch_event_del_header, SWITCH_LOG_CRIT, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_safe_free, SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_string_var_check_const(), variables, and zstr.

1520 {
1522 
1523  switch_assert(channel != NULL);
1524 
1525  switch_mutex_lock(channel->profile_mutex);
1526  if (channel->variables && !zstr(varname)) {
1527  if (zstr(value)) {
1528  switch_event_del_header(channel->variables, varname);
1529  } else {
1530  int ok = 1;
1531  char *t = (char *)value;
1532  char *r = (char *)value;
1533  char *tmp = NULL;
1534 
1535  if (t && *t == '"') {
1536  t++;
1537  if (end_of(t) == '"') {
1538  r = tmp = strdup(t);
1539  switch_assert(r);
1540  end_of(r) = '\0';
1541  }
1542  }
1543 
1544  if (var_check) {
1546  }
1547  if (ok) {
1549  } else {
1550  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname);
1551  }
1552 
1553  switch_safe_free(tmp);
1554  }
1555  status = SWITCH_STATUS_SUCCESS;
1556  }
1558 
1559  return status;
1560 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
const char *const const char *const const cJSON *const value
#define end_of(_s)
Definition: switch_utils.h:685
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
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
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.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
static switch_bool_t switch_string_var_check_const(const char *s)
Definition: switch_utils.h:788
switch_status_t
Common return values.
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_assert(expr)
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_set_variable_var_check()

switch_status_t switch_channel_set_variable_var_check ( switch_channel_t channel,
const char *  varname,
const char *  value,
switch_bool_t  var_check 
)

Definition at line 1488 of file switch_channel.c.

References profile_mutex, switch_assert, SWITCH_CHANNEL_CHANNEL_LOG, switch_event_add_header_string(), switch_event_del_header, SWITCH_LOG_CRIT, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_string_var_check_const(), variables, and zstr.

Referenced by CoreSession::setVariable(), switch_channel_export_variable_var_check(), switch_channel_set_variable_partner_var_check(), switch_core_session_exec(), switch_ivr_originate(), and switch_ivr_session_transfer().

1490 {
1492 
1493  switch_assert(channel != NULL);
1494 
1495  switch_mutex_lock(channel->profile_mutex);
1496  if (channel->variables && !zstr(varname)) {
1497  if (zstr(value)) {
1498  switch_event_del_header(channel->variables, varname);
1499  } else {
1500  int ok = 1;
1501 
1502  if (var_check) {
1504  }
1505  if (ok) {
1507  } else {
1508  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname);
1509  }
1510  }
1511  status = SWITCH_STATUS_SUCCESS;
1512  }
1514 
1515  return status;
1516 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
const char *const const char *const const cJSON *const value
#define zstr(x)
Definition: switch_utils.h:314
switch_mutex_t * profile_mutex
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
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 switch_bool_t switch_string_var_check_const(const char *s)
Definition: switch_utils.h:788
switch_status_t
Common return values.
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_assert(expr)
#define SWITCH_CHANNEL_CHANNEL_LOG(x)

◆ switch_channel_sort_cid()

void switch_channel_sort_cid ( switch_channel_t channel)

Definition at line 3299 of file switch_channel.c.

References CF_BLEG, CF_DIALPLAN, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_clear_flag(), switch_channel_direction(), switch_channel_flip_cid(), switch_channel_set_flag, and switch_channel_test_flag().

Referenced by switch_channel_set_caller_extension(), and switch_channel_var_true().

3300 {
3301 
3303  switch_channel_flip_cid(channel);
3307  switch_channel_flip_cid(channel);
3308  }
3309 }
void switch_channel_flip_cid(switch_channel_t *channel)
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.
#define switch_channel_set_flag(_c, _f)
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.

◆ switch_channel_state_change_pending()

int switch_channel_state_change_pending ( switch_channel_t channel)

Definition at line 2255 of file switch_channel.c.

References running_state, session, state, switch_channel_down_nosig, and switch_core_session_in_thread().

Referenced by switch_channel_test_ready(), switch_ivr_eavesdrop_session(), and switch_ivr_originate().

2256 {
2258  return 0;
2259  }
2260 
2261  return channel->running_state != channel->state;
2262 }
switch_channel_state_t running_state
#define switch_channel_down_nosig(_channel)
switch_channel_state_t state
switch_core_session_t * session
switch_bool_t switch_core_session_in_thread(switch_core_session_t *session)

◆ switch_channel_state_name()

const char* switch_channel_state_name ( _In_ switch_channel_state_t  state)

Render the name of the provided state enum.

Parameters
statestate to get name of
Returns
the string representation of the state

Referenced by check_presence(), CoreSession::getState(), switch_core_session_perform_destroy(), switch_core_session_run(), switch_ivr_generate_json_cdr(), and switch_ivr_generate_xml_cdr().

◆ switch_channel_step_caller_profile()

void switch_channel_step_caller_profile ( switch_channel_t channel)

Definition at line 2851 of file switch_channel.c.

References caller_profile, profile_mutex, session, switch_caller_profile_clone(), switch_channel_set_caller_profile(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_uuid_bridge().

2852 {
2854 
2855 
2856  switch_mutex_lock(channel->profile_mutex);
2857  cp = switch_caller_profile_clone(channel->session, channel->caller_profile);
2859 
2860  switch_channel_set_caller_profile(channel, cp);
2861 }
Call Specific Data.
Definition: switch_caller.h:73
switch_caller_profile_t * caller_profile
switch_caller_profile_t * switch_caller_profile_clone(_In_ switch_core_session_t *session, _In_ switch_caller_profile_t *tocopy)
Clone an existing caller profile object.
void switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel&#39;s caller profile.
switch_mutex_t * profile_mutex
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
switch_core_session_t * session

◆ switch_channel_str2callstate()

switch_channel_callstate_t switch_channel_str2callstate ( const char *  str)

Definition at line 346 of file switch_channel.c.

References switch_callstate_table::callstate, CALLSTATE_CHART, switch_cause_table::name, and SWITCH_CAUSE_NONE.

347 {
348  uint8_t x;
350 
351  if (*str > 47 && *str < 58) {
352  callstate = atoi(str);
353  } else {
354  for (x = 0; x < (sizeof(CALLSTATE_CHART) / sizeof(struct switch_callstate_table)) - 1 && CALLSTATE_CHART[x].name; x++) {
355  if (!strcasecmp(CALLSTATE_CHART[x].name, str)) {
356  callstate = CALLSTATE_CHART[x].callstate;
357  break;
358  }
359  }
360  }
361  return callstate;
362 }
switch_channel_callstate_t callstate
switch_channel_callstate_t
static struct switch_callstate_table CALLSTATE_CHART[]
const char *const name
Definition: switch_cJSON.h:250

◆ switch_channel_str2cause()

switch_call_cause_t switch_channel_str2cause ( _In_ const char *  str)

return a cause code for a given string

Parameters
strthe string to check
Returns
the code

Referenced by fs_channel_hangup(), CoreSession::hangup(), monitor_callback(), switch_core_session_reporting_state(), switch_ivr_park(), and switch_ivr_parse_event().

◆ switch_channel_test_app_flag_key()

int switch_channel_test_app_flag_key ( const char *  app,
switch_channel_t channel,
uint32_t  flags 
)

Definition at line 2110 of file switch_channel.c.

References app_flag_hash, flag_mutex, switch_assert, switch_core_hash_find(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_channel_wait_for_app_flag(), switch_core_media_negotiate_sdp(), and switch_ivr_eavesdrop_update_display().

2111 {
2112  int r = 0;
2113  uint32_t *flagp = NULL;
2114  switch_assert(channel != NULL);
2115 
2116  switch_mutex_lock(channel->flag_mutex);
2117  if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
2118  r = (*flagp & flags);
2119  }
2120  switch_mutex_unlock(channel->flag_mutex);
2121 
2122 
2123  return r;
2124 }
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
switch_hash_t * app_flag_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
switch_mutex_t * flag_mutex
char * key
Definition: switch_msrp.c:64
#define switch_assert(expr)

◆ switch_channel_test_cap()

uint32_t switch_channel_test_cap ( switch_channel_t channel,
switch_channel_cap_t  cap 
)

◆ switch_channel_test_cap_partner()

uint32_t switch_channel_test_cap_partner ( switch_channel_t channel,
switch_channel_cap_t  cap 
)

Definition at line 1880 of file switch_channel.c.

References switch_assert, switch_channel_get_partner_uuid(), switch_channel_test_cap(), switch_core_session_get_channel(), switch_core_session_locate, and switch_core_session_rwunlock().

Referenced by switch_core_media_receive_message().

1881 {
1882  const char *uuid;
1883  int r = 0;
1884 
1885  switch_assert(channel != NULL);
1886 
1887  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1888  switch_core_session_t *session;
1889  if ((session = switch_core_session_locate(uuid))) {
1892  }
1893  }
1894 
1895  return r;
1896 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
uint32_t switch_channel_test_cap(switch_channel_t *channel, switch_channel_cap_t cap)
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#define switch_assert(expr)

◆ switch_channel_test_flag()

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.

Parameters
channelchannel to test
flagto test
Returns
TRUE if flags were present

Definition at line 1677 of file switch_channel.c.

References flag_mutex, flags, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by _switch_core_session_request_video_refresh(), CoreSession::answered(), audio_bridge_on_exchange_media(), audio_bridge_thread(), block_on_dtmf(), CoreSession::bridged(), check_channel_status(), check_dtls_reinvite(), check_ice(), check_jb_sync(), check_per_channel_timeouts(), check_stream_changes(), cleanup_proxy_mode_a(), cleanup_proxy_mode_b(), CoreSession::destroy(), do_dtls(), dtls_ok(), early_thread_run(), generate_m(), generate_on_dtmf(), get_media_profile_name(), hanguphook(), meta_on_dtmf(), originate_on_consume_media_transmit(), perform_write(), read_rtp_packet(), recover_callback(), rtp_common_read(), rtp_common_write(), sb_on_dtmf(), send_display(), setup_ringback(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), switch_channel_check_device_state(), switch_channel_clear_device_record(), switch_channel_clear_flag(), switch_channel_dequeue_dtmf(), switch_channel_event_set_basic_data(), switch_channel_event_set_extended_data(), switch_channel_flip_cid(), switch_channel_handle_cause(), switch_channel_mark_hold(), switch_channel_perform_answer(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_perform_pre_answer(), switch_channel_perform_presence(), switch_channel_perform_ring_ready_value(), switch_channel_perform_set_running_state(), switch_channel_set_flag_value(), switch_channel_set_timestamps(), switch_channel_sort_cid(), switch_channel_test_flag_partner(), switch_channel_test_ready(), switch_channel_var_true(), switch_channel_wait_for_flag(), switch_core_media_activate_rtp(), switch_core_media_build_crypto(), switch_core_media_check_autoadj(), switch_core_media_check_dtls(), switch_core_media_check_outgoing_proxy(), switch_core_media_check_video_codecs(), switch_core_media_choose_port(), switch_core_media_choose_ports(), switch_core_media_codec_control(), switch_core_media_gen_local_sdp(), switch_core_media_get_video_file(), switch_core_media_get_video_fps(), switch_core_media_lock_video_file(), switch_core_media_media_params(), switch_core_media_negotiate_sdp(), switch_core_media_patch_sdp(), switch_core_media_prepare_codecs(), switch_core_media_proxy_remote_addr(), switch_core_media_read_frame(), switch_core_media_read_lock_unlock(), switch_core_media_receive_message(), switch_core_media_recover_session(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_rmode(), switch_core_media_set_smode(), switch_core_media_set_video_file(), switch_core_media_start_udptl(), switch_core_media_toggle_hold(), switch_core_media_unlock_video_file(), switch_core_recovery_track(), switch_core_recovery_untrack(), switch_core_service_thread(), switch_core_session_apply_crypto(), switch_core_session_check_incoming_crypto(), switch_core_session_check_outgoing_crypto(), switch_core_session_dequeue_event(), switch_core_session_dequeue_private_event(), switch_core_session_enable_heartbeat(), switch_core_session_execute_application_async(), switch_core_session_execute_application_get_flags(), switch_core_session_hangup_state(), switch_core_session_hupall_matching_vars_ans(), switch_core_session_outgoing_channel(), switch_core_session_parse_crypto_prefs(), switch_core_session_perform_receive_message(), switch_core_session_print(), switch_core_session_private_event_count(), switch_core_session_read_frame(), switch_core_session_read_lock(), switch_core_session_read_text_frame(), switch_core_session_read_video_frame(), switch_core_session_reporting_state(), switch_core_session_run(), switch_core_session_send_and_request_video_refresh(), switch_core_session_send_dtmf(), switch_core_session_start_audio_write_thread(), switch_core_session_start_text_thread(), switch_core_session_start_video_thread(), switch_core_session_transcoding(), switch_core_session_wait_for_video_input_params(), switch_core_session_write_frame(), switch_core_session_write_text_frame(), switch_core_session_write_video_frame(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_core_standard_on_init(), switch_core_standard_on_reset(), switch_core_standard_on_routing(), switch_ice_direction(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_blind_transfer_ack(), switch_ivr_bridge_bleg(), switch_ivr_broadcast(), switch_ivr_check_hold(), switch_ivr_collect_digits_callback(), switch_ivr_collect_digits_count(), switch_ivr_deactivate_unicast(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_gentones(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_orig_and_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_all_events(), switch_ivr_parse_event(), switch_ivr_parse_signal_data(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_session_echo(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_sleep(), switch_ivr_soft_hold(), switch_ivr_speak_text_handle(), switch_ivr_uuid_bridge(), switch_ivr_wait_for_answer(), switch_jb_get_packet(), switch_rtp_break(), switch_rtp_write_frame(), text_bridge_thread(), text_helper_thread(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), video_bug_thread(), video_helper_thread(), and video_write_overlay_callback().

1678 {
1679  uint32_t r = 0;
1680 
1681  switch_assert(channel != NULL);
1682 
1683  switch_mutex_lock(channel->flag_mutex);
1684  r = channel->flags[flag];
1685  switch_mutex_unlock(channel->flag_mutex);
1686 
1687  return r;
1688 }
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
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_assert(expr)

◆ switch_channel_test_flag_partner()

uint32_t switch_channel_test_flag_partner ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 1708 of file switch_channel.c.

References switch_assert, switch_channel_get_partner_uuid(), switch_channel_test_flag(), switch_core_session_get_channel(), switch_core_session_locate, and switch_core_session_rwunlock().

Referenced by switch_core_media_receive_message().

1709 {
1710  const char *uuid;
1711  int r = 0;
1712 
1713  switch_assert(channel != NULL);
1714 
1715  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1716  switch_core_session_t *session;
1717  if ((session = switch_core_session_locate(uuid))) {
1720  }
1721  }
1722 
1723  return r;
1724 }
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.
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
#define switch_assert(expr)

◆ switch_channel_test_private_flag()

int switch_channel_test_private_flag ( switch_channel_t channel,
uint32_t  flags 
)

Definition at line 2064 of file switch_channel.c.

References private_flags, and switch_assert.

2065 {
2066  switch_assert(channel != NULL);
2067  return (channel->private_flags & flags);
2068 }
uint32_t private_flags
#define switch_assert(expr)

◆ switch_channel_test_ready()

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.

Parameters
channelchannel to test
Returns
true if the channel is ready

Definition at line 2270 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CF_NOT_READY, CF_PROXY_MODE, CF_TRANSFER, CS_HANGUP, CS_RESET, CS_ROUTING, hangup_cause, session, state, switch_assert, switch_channel_check_signal(), switch_channel_state_change_pending(), switch_channel_test_flag(), switch_core_session_get_read_codec(), switch_core_session_get_write_codec(), and SWITCH_TRUE.

2271 {
2272  int ret = 0;
2273 
2274  switch_assert(channel != NULL);
2275 
2277 
2278  if (check_media) {
2279  ret = ((switch_channel_test_flag(channel, CF_ANSWERED) ||
2282 
2283 
2284  if (!ret)
2285  return ret;
2286  }
2287 
2288  if (!check_ready)
2289  return ret;
2290 
2291  ret = 0;
2292 
2293  if (!channel->hangup_cause && channel->state > CS_ROUTING && channel->state < CS_HANGUP && channel->state != CS_RESET &&
2296  ret++;
2297  }
2298 
2299 
2300 
2301  return ret;
2302 }
int switch_channel_check_signal(switch_channel_t *channel, switch_bool_t in_thread_only)
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_codec_t * switch_core_session_get_write_codec(_In_ switch_core_session_t *session)
Retrieve the write codec from a given session.
switch_codec_t * switch_core_session_get_read_codec(_In_ switch_core_session_t *session)
Retrieve the read codec from a given session.
#define check_media(session)
int switch_channel_state_change_pending(switch_channel_t *channel)
switch_channel_state_t state
#define switch_assert(expr)
switch_core_session_t * session
switch_call_cause_t hangup_cause

◆ switch_channel_transfer_variable_prefix()

switch_status_t switch_channel_transfer_variable_prefix ( switch_channel_t orig_channel,
switch_channel_t new_channel,
const char *  prefix 
)

Definition at line 1404 of file switch_channel.c.

References switch_event_header::name, switch_event_header::next, switch_channel_set_variable, switch_channel_variable_first(), switch_channel_variable_last(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_event_header::value, and zstr.

Referenced by switch_ivr_transfer_recordings().

1405 {
1406  switch_event_header_t *hi = NULL;
1407  int x = 0;
1408 
1409  if ((hi = switch_channel_variable_first(orig_channel))) {
1410  for (; hi; hi = hi->next) {
1411  char *var = hi->name;
1412  char *val = hi->value;
1413 
1414  if (zstr(prefix) || !strncasecmp(var, prefix, strlen(prefix))) {
1415  x++;
1416  switch_channel_set_variable(new_channel, var, val);
1417  }
1418  }
1419  switch_channel_variable_last(orig_channel);
1420  }
1421 
1423 }
An event Header.
Definition: switch_event.h:65
switch_event_header_t * switch_channel_variable_first(switch_channel_t *channel)
Start iterating over the entries in the channel variable list.
#define zstr(x)
Definition: switch_utils.h:314
struct switch_event_header * next
Definition: switch_event.h:76
void switch_channel_variable_last(switch_channel_t *channel)
Stop iterating over channel variables.
#define switch_channel_set_variable(_channel, _var, _val)

◆ switch_channel_try_dtmf_lock()

switch_status_t switch_channel_try_dtmf_lock ( switch_channel_t channel)

Definition at line 482 of file switch_channel.c.

References dtmf_mutex, and switch_mutex_trylock().

483 {
484  return switch_mutex_trylock(channel->dtmf_mutex);
485 }
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
Definition: switch_apr.c:318
switch_mutex_t * dtmf_mutex

◆ switch_channel_uninit()

void switch_channel_uninit ( switch_channel_t channel)

Uninitalize a channel.

Parameters
channelthe channel to uninit

Definition at line 740 of file switch_channel.c.

References api_list, app_flag_hash, app_list, dtmf_log_queue, log_tags, private_hash, profile_mutex, switch_channel_flush_dtmf(), switch_core_hash_destroy(), switch_event_destroy(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_trypop(), switch_safe_free, SWITCH_STATUS_SUCCESS, var_list, and variables.

Referenced by switch_core_session_perform_destroy().

741 {
742  void *pop;
743  switch_channel_flush_dtmf(channel);
744  while (switch_queue_trypop(channel->dtmf_log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
745  switch_safe_free(pop);
746  }
747 
748  if (channel->private_hash) {
750  }
751 
752  if (channel->app_flag_hash) {
754  }
755 
757  switch_event_destroy(&channel->variables);
758  switch_event_destroy(&channel->api_list);
759  switch_event_destroy(&channel->var_list);
760  switch_event_destroy(&channel->app_list);
761  if (channel->log_tags) {
762  switch_event_destroy(&channel->log_tags);
763  }
765 }
void switch_channel_flush_dtmf(switch_channel_t *channel)
switch_event_t * variables
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
switch_event_t * api_list
switch_queue_t * dtmf_log_queue
switch_hash_t * app_flag_hash
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
switch_hash_t * private_hash
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_event_t * app_list
switch_event_t * log_tags
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_event_t * var_list

◆ switch_channel_var_false()

static int switch_channel_var_false ( switch_channel_t channel,
const char *  variable 
)
inlinestatic

Definition at line 350 of file switch_channel.h.

References switch_channel_get_variable_dup(), SWITCH_FALSE, and switch_false().

Referenced by switch_core_media_build_crypto().

350  {
351  return switch_false(switch_channel_get_variable_dup(channel, variable, SWITCH_FALSE, -1));
352 }
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.
static int switch_false(const char *expr)
Evaluate the falsefullness of a string expression.
Definition: switch_utils.h:551

◆ switch_channel_var_true()

static int switch_channel_var_true ( switch_channel_t channel,
const char *  variable 
)
inlinestatic

Definition at line 354 of file switch_channel.h.

References switch_channel_caller_extension_masquerade(), switch_channel_flip_cid(), switch_channel_get_caller_extension(), switch_channel_get_variable_dup(), switch_channel_invert_cid(), switch_channel_restart(), switch_channel_set_caller_extension(), switch_channel_set_flag_value(), switch_channel_sort_cid(), switch_channel_test_flag(), switch_channel_variable_first(), switch_channel_variable_last(), SWITCH_DECLARE, SWITCH_FALSE, switch_true(), and value.

Referenced by check_dtls_reinvite(), gen_ice(), generate_m(), CoreSession::getDigits(), recover_callback(), switch_core_media_activate_rtp(), switch_core_media_build_crypto(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_smode(), switch_core_session_apply_crypto(), switch_core_session_passthru(), switch_determine_ice_type(), switch_ivr_originate(), switch_ivr_play_and_detect_speech(), switch_ivr_session_echo(), switch_jb_set_session(), switch_rtp_dequeue_dtmf(), and text_helper_thread().

354  {
355  return switch_true(switch_channel_get_variable_dup(channel, variable, SWITCH_FALSE, -1));
356 }
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
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.

◆ switch_channel_variable_first()

switch_event_header_t* switch_channel_variable_first ( switch_channel_t channel)

Start iterating over the entries in the channel variable list.

Parameters
channelthe channel to iterate the variables for
Remarks
This function locks the profile mutex, use switch_channel_variable_last to unlock

Definition at line 1078 of file switch_channel.c.

References switch_event::headers, profile_mutex, switch_assert, switch_mutex_lock(), switch_mutex_unlock(), variables, and vi.

Referenced by switch_channel_build_param_string(), switch_channel_transfer_variable_prefix(), switch_channel_var_true(), switch_ivr_originate(), switch_ivr_set_json_chan_vars(), and switch_ivr_set_xml_chan_vars().

1079 {
1080  switch_event_header_t *hi = NULL;
1081 
1082  switch_assert(channel != NULL);
1083  switch_mutex_lock(channel->profile_mutex);
1084  if (channel->variables && (hi = channel->variables->headers)) {
1085  channel->vi = 1;
1086  } else {
1088  }
1089 
1090  return hi;
1091 }
switch_event_t * variables
An event Header.
Definition: switch_event.h:65
switch_mutex_t * profile_mutex
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
#define switch_assert(expr)
switch_event_header_t * headers
Definition: switch_event.h:90

◆ switch_channel_variable_last()

void switch_channel_variable_last ( switch_channel_t channel)

Stop iterating over channel variables.

Remarks
Unlocks the profile mutex initially locked in switch_channel_variable_first

Definition at line 1067 of file switch_channel.c.

References profile_mutex, switch_assert, switch_mutex_unlock(), and vi.

Referenced by switch_channel_build_param_string(), switch_channel_transfer_variable_prefix(), switch_channel_var_true(), switch_ivr_originate(), switch_ivr_set_json_chan_vars(), and switch_ivr_set_xml_chan_vars().

1068 {
1069  switch_assert(channel != NULL);
1070  if (!channel->vi) {
1071  return;
1072  }
1073  channel->vi = 0;
1075 
1076 }
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
#define switch_assert(expr)

◆ switch_channel_wait_for_app_flag()

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 
)

Definition at line 1818 of file switch_channel.c.

References switch_channel_down, switch_channel_test_app_flag_key(), and switch_cond_next().

Referenced by switch_core_media_negotiate_sdp().

1821 {
1822  int r = 0;
1823 
1824  if (to) {
1825  to++;
1826  }
1827 
1828  for (;;) {
1829  if (pres) {
1830  if ((r = switch_channel_test_app_flag_key(key, channel, app_flag))) {
1831  break;
1832  }
1833  } else {
1834  if (!(r = switch_channel_test_app_flag_key(key, channel, app_flag))) {
1835  break;
1836  }
1837  }
1838 
1839  switch_cond_next();
1840 
1841  if (switch_channel_down(channel)) {
1842  return r;
1843  }
1844 
1845  if (to && !--to) {
1846  return r;
1847  }
1848  }
1849 
1850  return r;
1851 }
cJSON *const to
void switch_cond_next(void)
Definition: switch_time.c:658
#define switch_channel_down(_channel)
char * key
Definition: switch_msrp.c:64
int switch_channel_test_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)

◆ switch_channel_wait_for_flag()

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 
)

Definition at line 1780 of file switch_channel.c.

References switch_channel_down, switch_channel_ready, switch_channel_test_flag(), switch_cond_next(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and SWITCH_STATUS_TIMEOUT.

Referenced by audio_bridge_thread(), switch_core_media_toggle_hold(), switch_core_session_run(), switch_core_standard_on_reset(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_bridge_bleg(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_parse_event(), and switch_ivr_unhold().

1783 {
1784 
1785  if (to) {
1786  to++;
1787  }
1788 
1789  for (;;) {
1790  if (pres) {
1791  if (switch_channel_test_flag(channel, want_flag)) {
1792  break;
1793  }
1794  } else {
1795  if (!switch_channel_test_flag(channel, want_flag)) {
1796  break;
1797  }
1798  }
1799 
1800  switch_cond_next();
1801 
1802  if (super_channel && !switch_channel_ready(super_channel)) {
1803  return SWITCH_STATUS_FALSE;
1804  }
1805 
1806  if (switch_channel_down(channel)) {
1807  return SWITCH_STATUS_FALSE;
1808  }
1809 
1810  if (to && !--to) {
1811  return SWITCH_STATUS_TIMEOUT;
1812  }
1813  }
1814 
1815  return SWITCH_STATUS_SUCCESS;
1816 }
cJSON *const to
#define switch_channel_ready(_channel)
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.
void switch_cond_next(void)
Definition: switch_time.c:658
#define switch_channel_down(_channel)

◆ switch_channel_wait_for_state()

void switch_channel_wait_for_state ( switch_channel_t channel,
switch_channel_t other_channel,
switch_channel_state_t  want_state 
)

Definition at line 1744 of file switch_channel.c.

References CS_HANGUP, running_state, state, switch_assert, switch_channel_down, switch_channel_down_nosig, and switch_cond_next().

Referenced by CoreSession::CoreSession(), switch_ivr_3p_nomedia(), switch_ivr_multi_threaded_bridge(), and switch_ivr_nomedia().

1745 {
1746 
1747  switch_assert(channel);
1748 
1749  for (;;) {
1750  if ((channel->state < CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) ||
1751  (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down(channel)) {
1752  break;
1753  }
1754  switch_cond_next();
1755  }
1756 }
switch_channel_state_t running_state
#define switch_channel_down_nosig(_channel)
void switch_cond_next(void)
Definition: switch_time.c:658
#define switch_channel_down(_channel)
switch_channel_state_t state
#define switch_assert(expr)

◆ switch_channel_wait_for_state_timeout()

void switch_channel_wait_for_state_timeout ( switch_channel_t other_channel,
switch_channel_state_t  want_state,
uint32_t  timeout 
)

Definition at line 1759 of file switch_channel.c.

References count, CS_HANGUP, running_state, state, switch_channel_check_signal(), switch_cond_next(), and SWITCH_TRUE.

Referenced by switch_channel_restart(), switch_core_standard_on_reset(), and switch_ivr_originate().

1760 {
1761 
1762  uint32_t count = 0;
1763 
1764  for (;;) {
1765 
1766  if ((channel->state == channel->running_state && channel->running_state == want_state) || channel->state >= CS_HANGUP) {
1767  break;
1768  }
1769 
1771 
1772  switch_cond_next();
1773 
1774  if (++count >= timeout) {
1775  break;
1776  }
1777  }
1778 }
int switch_channel_check_signal(switch_channel_t *channel, switch_bool_t in_thread_only)
void switch_cond_next(void)
Definition: switch_time.c:658
int count
Definition: switch_cJSON.h:204