FreeSWITCH API Documentation  1.7.0
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_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_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_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_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_variable_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...
 
switch_status_t switch_channel_get_variables (switch_channel_t *channel, switch_event_t **event)
 
switch_status_t switch_channel_pass_callee_id (switch_channel_t *channel, switch_channel_t *other_channel)
 
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)
 
void switch_channel_check_zrtp (switch_channel_t *channel)
 
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_t
switch_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

#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 426 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(), and switch_ivr_process_indications().

#define switch_channel_audio_sync (   _c)    switch_channel_perform_audio_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_clear_app_flag (   _c,
  _f 
)    switch_channel_clear_app_flag_key(__FILE__, _c, _f)

Definition at line 639 of file switch_channel.h.

#define switch_channel_down (   _channel)    (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) >= CS_HANGUP)
#define switch_channel_down_nosig (   _channel)    (switch_channel_get_state(_channel) >= CS_HANGUP)
#define switch_channel_expand_variables (   _channel,
  _in 
)    switch_channel_expand_variables_check(_channel, _in, NULL, NULL, 0)
#define switch_channel_export_variable (   _channel,
  _varname,
  _value,
  _ev 
)    switch_channel_export_variable_var_check(_channel, _varname, _value, _ev, SWITCH_TRUE)

Definition at line 300 of file switch_channel.h.

Referenced by switch_channel_export_variable_printf().

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

Definition at line 314 of file switch_channel.h.

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb(), fs_channel_get_variable(), fs_switch_channel_get_variable(), fs_switch_ivr_originate(), CoreSession::getVariable(), handle_ice(), hanguphook(), inherit_codec(), limit_state_handler(), monitor_callback(), play_and_collect(), play_and_detect_input_callback(), record_callback(), recover_callback(), rtp_common_read(), 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_bug_transfer_recordings(), 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_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_var_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_originate(), switch_ivr_find_bridged_uuid(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_phrase_macro_event(), switch_ivr_play_and_detect_speech(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_record_session(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_echo(), 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_play_and_get_digits(), switch_process_import(), switch_rtp_add_crypto_key(), switch_rtp_create(), switch_rtp_enable_vad(), switch_rtp_set_flag(), switch_rtp_set_flags(), switch_rtp_set_local_address(), SWITCH_STANDARD_SCHED_FUNC(), uuid_bridge_on_soft_execute(), and video_helper_thread().

#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 548 of file switch_channel.h.

Referenced by abort_call(), audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_per_channel_timeouts(), 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_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_var_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(), switch_ivr_record_session(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_wait_for_answer(), SWITCH_STANDARD_SCHED_FUNC(), and uuid_bridge_on_soft_execute().

#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 615 of file switch_channel.h.

Referenced by switch_ivr_uuid_bridge().

#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 433 of file switch_channel.h.

#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 440 of file switch_channel.h.

#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 475 of file switch_channel.h.

#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 478 of file switch_channel.h.

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

#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_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 617 of file switch_channel.h.

Referenced by switch_ivr_uuid_bridge().

#define switch_channel_pre_answer (   channel)    switch_channel_perform_pre_answer(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_presence (   _a,
  _b,
  _c,
  _d 
)    switch_channel_perform_presence(_a, _b, _c, _d, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_ready (   _channel)    switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE)
#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 450 of file switch_channel.h.

Referenced by check_channel_status(), and switch_ivr_process_indications().

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

Definition at line 451 of file switch_channel.h.

Referenced by check_channel_status().

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

Definition at line 638 of file switch_channel.h.

#define switch_channel_set_callstate (   channel,
  state 
)    switch_channel_perform_set_callstate(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_set_cap (   _c,
  _cc 
)    switch_channel_set_cap_value(_c, _cc, 1)

Definition at line 375 of file switch_channel.h.

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

Definition at line 370 of file switch_channel.h.

Referenced by add_uuid(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb(), collect_thread_run(), enterprise_originate_ringback_thread(), process_device_hup(), recover_callback(), signal_bridge_on_hangup(), switch_channel_check_zrtp(), 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_codec_control(), switch_core_media_find_zrtp_hash(), 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_receive_message(), switch_core_media_recover_session(), 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_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_standard_on_execute(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_activate_unicast(), switch_ivr_broadcast(), switch_ivr_enterprise_originate(), switch_ivr_hold(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_park_session(), switch_ivr_parse_event(), switch_ivr_parse_signal_data(), switch_ivr_record_file(), switch_ivr_session_echo(), switch_ivr_session_transfer(), switch_ivr_signal_bridge(), switch_ivr_sleep(), switch_ivr_uuid_bridge(), switch_jb_get_packet(), switch_media_handle_create(), video_helper_thread(), and video_write_thread().

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

Definition at line 107 of file switch_channel.h.

Referenced by switch_core_session_destroy_state(), and switch_core_session_run().

#define switch_channel_set_state (   channel,
  state 
)    switch_channel_perform_set_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__, state)
#define switch_channel_set_variable (   _channel,
  _var,
  _val 
)    switch_channel_set_variable_var_check(_channel, _var, _val, SWITCH_TRUE)

Definition at line 288 of file switch_channel.h.

Referenced by _switch_core_media_pass_zrtp_hash2(), audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_ice(), check_jb(), check_presence(), 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_check_zrtp(), 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_bug_transfer_recordings(), switch_core_media_choose_port(), switch_core_media_find_zrtp_hash(), 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_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_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_enterprise_originate(), switch_ivr_intercept_session(), switch_ivr_menu_execute(), switch_ivr_multi_threaded_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(), switch_ivr_record_session(), 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(), switch_rtp_create(), transfer_after_bridge(), and uuid_bridge_on_soft_execute().

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

Definition at line 289 of file switch_channel.h.

Referenced by switch_channel_perform_hangup().

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

Definition at line 287 of file switch_channel.h.

#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_test_app_flag (   _c,
  _f 
)    switch_channel_test_app_flag_key(__FILE__, _c, _f)

Definition at line 640 of file switch_channel.h.

#define switch_channel_up (   _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_video_sync (   _c)    switch_channel_perform_video_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)

Definition at line 628 of file switch_channel.h.

Referenced by switch_core_media_set_video_file().

Function Documentation

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 2889 of file switch_channel.c.

References 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().

2890 {
2891  int x, index;
2892 
2893  switch_assert(channel != NULL);
2894  switch_mutex_lock(channel->state_mutex);
2895  for (x = 0; x < SWITCH_MAX_STATE_HANDLERS; x++) {
2896  if (channel->state_handlers[x] == state_handler) {
2897  index = x;
2898  goto end;
2899  }
2900  }
2901  index = channel->state_handler_index++;
2902 
2903  if (channel->state_handler_index >= SWITCH_MAX_STATE_HANDLERS) {
2904  index = -1;
2905  goto end;
2906  }
2907 
2908  channel->state_handlers[index] = state_handler;
2909 
2910  end:
2911  switch_mutex_unlock(channel->state_mutex);
2912  return index;
2913 }
switch_mutex_t * state_mutex
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:559
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
#define switch_assert(expr)
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 1447 of file switch_channel.c.

References 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_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_string_var_check_const(), and zstr.

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

1449 {
1451 
1452  switch_assert(channel != NULL);
1453 
1454  switch_mutex_lock(channel->profile_mutex);
1455  if (channel->variables && !zstr(varname)) {
1456  if (zstr(value)) {
1457  switch_event_del_header(channel->variables, varname);
1458  } else {
1459  int ok = 1;
1460 
1461  if (var_check) {
1462  ok = !switch_string_var_check_const(value);
1463  }
1464  if (ok) {
1465  switch_event_add_header_string(channel->variables, stack, varname, value);
1466  } else {
1467  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname);
1468  }
1469  }
1470  status = SWITCH_STATUS_SUCCESS;
1471  }
1473 
1474  return status;
1475 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:211
#define zstr(x)
Definition: switch_utils.h:281
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:716
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_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().

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_caller_extension_masquerade ( switch_channel_t orig_channel,
switch_channel_t new_channel,
uint32_t  offset 
)

Definition at line 2985 of file switch_channel.c.

References switch_caller_application::application_data, switch_caller_application::application_name, switch_caller_profile::destination_number, switch_event_header::name, switch_event_header::next, switch_caller_application::next, switch_caller_profile::pool, 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, and switch_event_header::value.

Referenced by switch_ivr_originate().

2986 {
2987  switch_caller_profile_t *caller_profile;
2988  switch_caller_extension_t *extension = NULL, *orig_extension = NULL;
2991  switch_event_header_t *hi = NULL;
2992  const char *no_copy = switch_channel_get_variable(orig_channel, "attended_transfer_no_copy");
2993  char *dup;
2994  int i, argc = 0;
2995  char *argv[128];
2996 
2997  if (no_copy) {
2998  dup = switch_core_session_strdup(new_channel->session, no_copy);
2999  argc = switch_separate_string(dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
3000  }
3001 
3002 
3003  switch_mutex_lock(orig_channel->profile_mutex);
3004  switch_mutex_lock(new_channel->profile_mutex);
3005 
3006 
3007  caller_profile = switch_caller_profile_clone(new_channel->session, new_channel->caller_profile);
3008  switch_assert(caller_profile);
3009  extension = switch_caller_extension_new(new_channel->session, caller_profile->destination_number, caller_profile->destination_number);
3010  orig_extension = switch_channel_get_caller_extension(orig_channel);
3011 
3012 
3013  if (extension && orig_extension) {
3014  for (ap = orig_extension->current_application; ap && offset > 0; offset--) {
3015  ap = ap->next;
3016  }
3017 
3018  for (; ap; ap = ap->next) {
3020  }
3021 
3022  caller_profile->destination_number = switch_core_strdup(caller_profile->pool, orig_channel->caller_profile->destination_number);
3023  switch_channel_set_caller_profile(new_channel, caller_profile);
3024  switch_channel_set_caller_extension(new_channel, extension);
3025 
3026  for (hi = orig_channel->variables->headers; hi; hi = hi->next) {
3027  int ok = 1;
3028  for (i = 0; i < argc; i++) {
3029  if (!strcasecmp(argv[i], hi->name)) {
3030  ok = 0;
3031  break;
3032  }
3033  }
3034 
3035  if (!ok)
3036  continue;
3037 
3038  switch_channel_set_variable(new_channel, hi->name, hi->value);
3039  }
3040 
3041  status = SWITCH_STATUS_SUCCESS;
3042  }
3043 
3044 
3045  switch_mutex_unlock(new_channel->profile_mutex);
3046  switch_mutex_unlock(orig_channel->profile_mutex);
3047 
3048 
3049  return status;
3050 }
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:729
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'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:290
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:285
#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's pool.
Definition: switch_core.h:717
#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
const char* switch_channel_callstate2str ( switch_channel_callstate_t  callstate)

Definition at line 302 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().

303 {
304  uint8_t x;
305  const char *str = "UNKNOWN";
306 
307  for (x = 0; x < (sizeof(CALLSTATE_CHART) / sizeof(struct switch_cause_table)) - 1; x++) {
308  if (CALLSTATE_CHART[x].callstate == callstate) {
309  str = CALLSTATE_CHART[x].name;
310  break;
311  }
312  }
313 
314  return str;
315 }
static struct switch_callstate_table CALLSTATE_CHART[]
const char* switch_channel_cause2str ( _In_ switch_call_cause_t  cause)
switch_call_cause_t switch_channel_cause_q850 ( switch_call_cause_t  cause)

Definition at line 392 of file switch_channel.c.

References SWITCH_CAUSE_INTERWORKING, and SWITCH_CAUSE_NORMAL_CLEARING.

Referenced by switch_channel_get_cause_q850().

393 {
394  if (cause <= SWITCH_CAUSE_INTERWORKING) {
395  return cause;
396  } else {
398  }
399 }
int switch_channel_check_signal ( switch_channel_t channel,
switch_bool_t  in_thread_only 
)

Definition at line 2114 of file switch_channel.c.

References SWITCH_FALSE, and switch_ivr_parse_signal_data().

Referenced by switch_channel_test_ready(), and switch_channel_wait_for_state_timeout().

2115 {
2116  switch_ivr_parse_signal_data(channel->session, SWITCH_FALSE, in_thread_only);
2117  return 0;
2118 }
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:823
switch_core_session_t * session
void switch_channel_check_zrtp ( switch_channel_t channel)

Definition at line 3353 of file switch_channel.c.

References CF_ZRTP_HASH, CF_ZRTP_PASSTHRU, CF_ZRTP_PASSTHRU_REQ, switch_channel_clear_flag(), switch_channel_get_name(), SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_flag, switch_channel_set_variable, switch_channel_test_flag(), switch_core_session_get_channel(), switch_core_session_get_partner, switch_core_session_rwunlock(), SWITCH_LOG_INFO, switch_log_printf(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_channel_perform_mark_answered(), and switch_channel_perform_mark_pre_answered().

3354 {
3355 
3358  && switch_channel_test_flag(channel, CF_ZRTP_HASH)) {
3359  switch_core_session_t *other_session;
3360  switch_channel_t *other_channel;
3361  int doit = 1;
3362 
3363  if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
3364  other_channel = switch_core_session_get_channel(other_session);
3365 
3366  if (switch_channel_test_flag(other_channel, CF_ZRTP_HASH) && !switch_channel_test_flag(other_channel, CF_ZRTP_PASSTHRU)) {
3367 
3369  switch_channel_set_flag(other_channel, CF_ZRTP_PASSTHRU);
3370 
3372  "%s Activating ZRTP passthru mode.\n", switch_channel_get_name(channel));
3373 
3374  switch_channel_set_variable(channel, "zrtp_passthru_active", "true");
3375  switch_channel_set_variable(other_channel, "zrtp_passthru_active", "true");
3376  switch_channel_set_variable(channel, "zrtp_secure_media", "false");
3377  switch_channel_set_variable(other_channel, "zrtp_secure_media", "false");
3378  doit = 0;
3379  }
3380 
3381  switch_core_session_rwunlock(other_session);
3382  }
3383 
3384  if (doit) {
3385  switch_channel_set_variable(channel, "zrtp_passthru_active", "false");
3386  switch_channel_set_variable(channel, "zrtp_secure_media", "true");
3388  "%s ZRTP not negotiated on both sides; disabling ZRTP passthru mode.\n", switch_channel_get_name(channel));
3389 
3392 
3393  if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
3394  other_channel = switch_core_session_get_channel(other_session);
3395 
3396  switch_channel_set_variable(other_channel, "zrtp_passthru_active", "false");
3397  switch_channel_set_variable(other_channel, "zrtp_secure_media", "true");
3399  switch_channel_clear_flag(other_channel, CF_ZRTP_HASH);
3400 
3401  switch_core_session_rwunlock(other_session);
3402  }
3403 
3404  }
3405  }
3406 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
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.
_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_core_session_get_partner(_session, _partner)
Definition: switch_core.h:1002
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_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.
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
#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
void switch_channel_clear_app_flag_key ( const char *  app,
switch_channel_t channel,
uint32_t  flags 
)

Definition at line 1944 of file switch_channel.c.

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

Referenced by switch_core_media_negotiate_sdp(), and switch_ivr_eavesdrop_update_display().

1945 {
1946  uint32_t *flagp = NULL;
1947 
1948  switch_assert(channel != NULL);
1949  switch_mutex_lock(channel->flag_mutex);
1950  if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
1951  if (!flags) {
1952  *flagp = 0;
1953  } else {
1954  *flagp &= ~flags;
1955  }
1956  }
1957  switch_mutex_unlock(channel->flag_mutex);
1958 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
#define switch_assert(expr)
void switch_channel_clear_cap ( switch_channel_t channel,
switch_channel_cap_t  cap 
)

Definition at line 1714 of file switch_channel.c.

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

1715 {
1716  switch_assert(channel != NULL);
1717  switch_assert(channel->flag_mutex);
1718 
1719  switch_mutex_lock(channel->flag_mutex);
1720  channel->caps[cap] = 0;
1721  switch_mutex_unlock(channel->flag_mutex);
1722 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
uint32_t caps[CC_FLAG_MAX]
#define switch_assert(expr)
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 1995 of file switch_channel.c.

References CCS_ACTIVE, CCS_UNHELD, CF_ANSWERED, CF_BRIDGED, CF_DIALPLAN, CF_LEG_HOLDING, CF_ORIGINATOR, CF_OUTBOUND, CF_PROXY_MODE, CF_RECOVERED, CF_RECOVERING, CF_VIDEO, CF_VIDEO_PASSIVE, CF_VIDEO_READY, 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(), and switch_time_now().

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), check_channel_status(), check_per_channel_timeouts(), switch_channel_check_zrtp(), 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_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_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_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(), 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_jb_get_packet(), switch_rtp_break(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), and video_write_thread().

1996 {
1997  int ACTIVE = 0;
1998  int CLEAR = 0;
1999 
2000  switch_assert(channel != NULL);
2001  switch_assert(channel->flag_mutex);
2002 
2003  switch_mutex_lock(channel->flag_mutex);
2004  if (flag == CF_LEG_HOLDING && channel->flags[flag] && channel->flags[CF_ANSWERED]) {
2005  ACTIVE = 1;
2006  }
2007 
2008  if (flag == CF_VIDEO_PASSIVE && channel->flags[CF_VIDEO]) {
2009  channel->flags[CF_VIDEO_READY] = 1;
2010 
2011  if (channel->flags[flag]) {
2012  CLEAR = 1;
2013  }
2014  }
2015 
2016  channel->flags[flag] = 0;
2017  switch_mutex_unlock(channel->flag_mutex);
2018 
2019  if (flag == CF_DIALPLAN) {
2020  if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
2022  if (channel->device_node) {
2024  }
2025  }
2026  }
2027 
2028  if (ACTIVE) {
2030  switch_mutex_lock(channel->profile_mutex);
2031  if (channel->caller_profile->times->last_hold) {
2033  }
2034 
2035  if (channel->hold_record) {
2036  channel->hold_record->off = switch_time_now();
2037  }
2038 
2041  }
2042 
2044  }
2045 
2046  if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
2048  }
2049 
2050  if (flag == CF_OUTBOUND) {
2051  switch_channel_set_variable(channel, "is_outbound", NULL);
2052  }
2053 
2054  if (flag == CF_RECOVERED) {
2055  switch_channel_set_variable(channel, "recovered", NULL);
2056  }
2057 
2058  if (flag == CF_VIDEO_PASSIVE && CLEAR) {
2060  }
2061 
2062  if (flag == CF_RECOVERING && !channel->hangup_cause) {
2064  }
2065 
2066 }
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:290
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:285
switch_call_direction_t direction
Definition: switch_core.h:86
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:302
switch_core_session_t * session
switch_time_t off
Definition: switch_core.h:74
switch_call_cause_t hangup_cause
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 1611 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.

1612 {
1613  const char *uuid;
1614 
1615  switch_assert(channel != NULL);
1616 
1617  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1618  switch_core_session_t *session;
1619  if ((session = switch_core_session_locate(uuid))) {
1622  return SWITCH_TRUE;
1623  }
1624  }
1625 
1626  return SWITCH_FALSE;
1627 }
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's uuid.
Definition: switch_core.h:916
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)
void switch_channel_clear_flag_recursive ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 2069 of file switch_channel.c.

References CF_OUTBOUND, 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(), and switch_ivr_record_file().

2070 {
2071  switch_assert(channel != NULL);
2072  switch_assert(channel->flag_mutex);
2073 
2074  switch_mutex_lock(channel->flag_mutex);
2075  if (channel->flags[flag]) {
2076  channel->flags[flag]--;
2077  }
2078  switch_mutex_unlock(channel->flag_mutex);
2079 
2080  if (flag == CF_OUTBOUND) {
2081  switch_channel_set_variable(channel, "is_outbound", NULL);
2082  }
2083 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
void switch_channel_clear_private_flag ( switch_channel_t channel,
uint32_t  flags 
)

Definition at line 1906 of file switch_channel.c.

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

1907 {
1908  switch_assert(channel != NULL);
1909  switch_mutex_lock(channel->flag_mutex);
1910  channel->private_flags &= ~flags;
1911  switch_mutex_unlock(channel->flag_mutex);
1912 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
uint32_t private_flags
switch_mutex_t * flag_mutex
#define switch_assert(expr)
void switch_channel_clear_state_flag ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 1986 of file switch_channel.c.

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

Referenced by switch_ivr_uuid_bridge().

1987 {
1988  switch_assert(channel != NULL);
1989 
1990  switch_mutex_lock(channel->flag_mutex);
1991  channel->state_flags[flag] = 0;
1992  switch_mutex_unlock(channel->flag_mutex);
1993 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
#define switch_assert(expr)
uint8_t state_flags[CF_FLAG_MAX]
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 2932 of file switch_channel.c.

References SSH_FLAG_STICKY, 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().

2933 {
2934  int index, i = channel->state_handler_index;
2935  const switch_state_handler_table_t *new_handlers[SWITCH_MAX_STATE_HANDLERS] = { 0 };
2936 
2937  switch_assert(channel != NULL);
2938 
2939  switch_mutex_lock(channel->state_mutex);
2940  channel->state_handler_index = 0;
2941 
2942  if (state_handler) {
2943  for (index = 0; index < i; index++) {
2944  if (channel->state_handlers[index] != state_handler) {
2945  new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
2946  }
2947  }
2948  } else {
2949  for (index = 0; index < i; index++) {
2950  if (channel->state_handlers[index] && switch_test_flag(channel->state_handlers[index], SSH_FLAG_STICKY)) {
2951  new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
2952  }
2953  }
2954  }
2955 
2956  for (index = 0; index < SWITCH_MAX_STATE_HANDLERS; index++) {
2957  channel->state_handlers[index] = NULL;
2958  }
2959 
2960  if (channel->state_handler_index > 0) {
2961  for (index = 0; index < channel->state_handler_index; index++) {
2962  channel->state_handlers[index] = new_handlers[index];
2963  }
2964  }
2965 
2966  switch_mutex_unlock(channel->state_mutex);
2967 }
switch_mutex_t * state_mutex
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:559
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:624
#define switch_assert(expr)
uint32_t switch_channel_del_variable_prefix ( switch_channel_t channel,
const char *  prefix 
)

Definition at line 1345 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.

1346 {
1347  switch_event_t *event;
1349  uint32_t r = 0;
1350 
1351  switch_channel_get_variables(channel, &event);
1352 
1353  if (event) {
1354  for (hp = event->headers; hp; hp = hp->next) {
1355  if (zstr(prefix) || !strncasecmp(hp->name, prefix, strlen(prefix))) {
1356  switch_channel_set_variable(channel, hp->name, NULL);
1357  }
1358  }
1359  }
1360 
1361  switch_event_destroy(&event);
1362 
1363  return r;
1364 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
#define zstr(x)
Definition: switch_utils.h:281
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_status_t switch_channel_dequeue_dtmf ( _In_ switch_channel_t channel,
_In_ switch_dtmf_t dtmf 
)
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_call_direction_t switch_channel_direction ( switch_channel_t channel)
switch_status_t switch_channel_dtmf_lock ( switch_channel_t channel)

Definition at line 464 of file switch_channel.c.

References switch_mutex_lock().

Referenced by switch_core_session_read_frame().

465 {
466  return switch_mutex_lock(channel->dtmf_mutex);
467 }
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * dtmf_mutex
switch_status_t switch_channel_dtmf_unlock ( switch_channel_t channel)

Definition at line 474 of file switch_channel.c.

References switch_mutex_unlock().

Referenced by switch_core_session_read_frame().

475 {
476  return switch_mutex_unlock(channel->dtmf_mutex);
477 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_mutex_t * dtmf_mutex
void switch_channel_event_set_basic_data ( _In_ switch_channel_t channel,
_In_ switch_event_t event 
)
void switch_channel_event_set_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.

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 3839 of file switch_channel.c.

References switch_stream_handle::data, end_of_p, in, memset(), resize, SCF_API_EXPANSION, 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.

3840 {
3841  char *p, *c = NULL;
3842  char *data, *indup, *endof_indup;
3843  size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128;
3844  char *cloned_sub_val = NULL, *sub_val = NULL, *expanded_sub_val = NULL;
3845  char *func_val = NULL, *sb = NULL;
3846  int nv = 0;
3847 
3848  if (recur > 100) {
3849  return (char *) in;
3850  }
3851 
3852  if (zstr(in)) {
3853  return (char *) in;
3854  }
3855 
3857 
3858  if (!nv) {
3859  return (char *) in;
3860  }
3861 
3862 
3863  nv = 0;
3864  olen = strlen(in) + 1;
3865  indup = strdup(in);
3866  endof_indup = end_of_p(indup) + 1;
3867 
3868  if ((data = malloc(olen))) {
3869  memset(data, 0, olen);
3870  c = data;
3871  for (p = indup; p && p < endof_indup && *p; p++) {
3872  int global = 0;
3873  vtype = 0;
3874 
3875  if (*p == '\\') {
3876  if (*(p + 1) == '$') {
3877  nv = 1;
3878  p++;
3879  if (*(p + 1) == '$') {
3880  p++;
3881  }
3882  } else if (*(p + 1) == '\'') {
3883  p++;
3884  continue;
3885  } else if (*(p + 1) == '\\') {
3886  *c++ = *p++;
3887  len++;
3888  continue;
3889  }
3890  }
3891 
3892  if (*p == '$' && !nv) {
3893 
3894  if (*(p + 1) == '$') {
3895  p++;
3896  global++;
3897  }
3898 
3899  if (*(p + 1)) {
3900  if (*(p + 1) == '{') {
3901  vtype = global ? 3 : 1;
3902  } else {
3903  nv = 1;
3904  }
3905  } else {
3906  nv = 1;
3907  }
3908  }
3909 
3910  if (nv) {
3911  *c++ = *p;
3912  len++;
3913  nv = 0;
3914  continue;
3915  }
3916 
3917  if (vtype) {
3918  char *s = p, *e, *vname, *vval = NULL;
3919  size_t nlen;
3920 
3921  s++;
3922 
3923  if ((vtype == 1 || vtype == 3) && *s == '{') {
3924  br = 1;
3925  s++;
3926  }
3927 
3928  e = s;
3929  vname = s;
3930  while (*e) {
3931  if (br == 1 && *e == '}') {
3932  br = 0;
3933  *e++ = '\0';
3934  break;
3935  }
3936 
3937  if (br > 0) {
3938  if (e != s && *e == '{') {
3939  br++;
3940  } else if (br > 1 && *e == '}') {
3941  br--;
3942  }
3943  }
3944 
3945  e++;
3946  }
3947  p = e > endof_indup ? endof_indup : e;
3948 
3949  vval = NULL;
3950  for(sb = vname; sb && *sb; sb++) {
3951  if (*sb == ' ') {
3952  vval = sb;
3953  break;
3954  } else if (*sb == '(') {
3955  vval = sb;
3956  br = 1;
3957  break;
3958  }
3959  }
3960 
3961  if (vval) {
3962  e = vval - 1;
3963  *vval++ = '\0';
3964  while (*e == ' ') {
3965  *e-- = '\0';
3966  }
3967  e = vval;
3968 
3969  while (e && *e) {
3970  if (*e == '(') {
3971  br++;
3972  } else if (br > 1 && *e == ')') {
3973  br--;
3974  } else if (br == 1 && *e == ')') {
3975  *e = '\0';
3976  break;
3977  }
3978  e++;
3979  }
3980 
3981  vtype = 2;
3982  }
3983 
3984  if (vtype == 1 || vtype == 3) {
3985  char *expanded = NULL;
3986  int offset = 0;
3987  int ooffset = 0;
3988  char *ptr;
3989  int idx = -1;
3990 
3991  if ((expanded = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list, recur+1)) == vname) {
3992  expanded = NULL;
3993  } else {
3994  vname = expanded;
3995  }
3996 
3997  if ((ptr = strchr(vname, ':'))) {
3998  *ptr++ = '\0';
3999  offset = atoi(ptr);
4000  if ((ptr = strchr(ptr, ':'))) {
4001  ptr++;
4002  ooffset = atoi(ptr);
4003  }
4004  }
4005 
4006  if ((ptr = strchr(vname, '[')) && strchr(ptr, ']')) {
4007  *ptr++ = '\0';
4008  idx = atoi(ptr);
4009  }
4010 
4011  if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
4012  if (var_list && !switch_event_check_permission_list(var_list, vname)) {
4013  sub_val = "<Variable Expansion Permission Denied>";
4014  }
4015 
4016  if ((expanded_sub_val = switch_channel_expand_variables_check(channel, sub_val, var_list, api_list, recur+1)) == sub_val) {
4017  expanded_sub_val = NULL;
4018  } else {
4019  sub_val = expanded_sub_val;
4020  }
4021 
4022  if (offset || ooffset) {
4023  cloned_sub_val = strdup(sub_val);
4024  switch_assert(cloned_sub_val);
4025  sub_val = cloned_sub_val;
4026  }
4027 
4028  if (offset >= 0) {
4029  if ((size_t) offset > strlen(sub_val)) {
4030  *sub_val = '\0';
4031  } else {
4032  sub_val += offset;
4033  }
4034  } else if ((size_t) abs(offset) <= strlen(sub_val)) {
4035  sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
4036  }
4037 
4038  if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
4039  if ((ptr = (char *) sub_val + ooffset)) {
4040  *ptr = '\0';
4041  }
4042  }
4043  }
4044 
4045  switch_safe_free(expanded);
4046  } else {
4047  switch_stream_handle_t stream = { 0 };
4048  char *expanded = NULL;
4049 
4050  SWITCH_STANDARD_STREAM(stream);
4051 
4052  if (stream.data) {
4053  char *expanded_vname = NULL;
4054 
4055  if ((expanded_vname = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list, recur+1)) == vname) {
4056  expanded_vname = NULL;
4057  } else {
4058  vname = expanded_vname;
4059  }
4060 
4061  if ((expanded = switch_channel_expand_variables_check(channel, vval, var_list, api_list, recur+1)) == vval) {
4062  expanded = NULL;
4063  } else {
4064  vval = expanded;
4065  }
4066 
4067  if (!switch_core_test_flag(SCF_API_EXPANSION) || (api_list && !switch_event_check_permission_list(api_list, vname))) {
4068  func_val = NULL;
4069  sub_val = "<API Execute Permission Denied>";
4070  } else {
4071  if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) {
4072  func_val = stream.data;
4073  sub_val = func_val;
4074  } else {
4075  free(stream.data);
4076  }
4077  }
4078 
4079  switch_safe_free(expanded);
4080  switch_safe_free(expanded_vname);
4081 
4082  } else {
4083  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Memory Error!\n");
4084  free(data);
4085  free(indup);
4086  return (char *) in;
4087  }
4088  }
4089  if ((nlen = sub_val ? strlen(sub_val) : 0)) {
4090  if (len + nlen >= olen) {
4091  resize(nlen);
4092  }
4093 
4094  len += nlen;
4095  strcat(c, sub_val);
4096  c += nlen;
4097  }
4098 
4099  switch_safe_free(func_val);
4100  switch_safe_free(cloned_sub_val);
4101  switch_safe_free(expanded_sub_val);
4102  sub_val = NULL;
4103  vname = NULL;
4104  br = 0;
4105  }
4106  if (len + 1 >= olen) {
4107  resize(1);
4108  }
4109 
4110  if (sp) {
4111  *c++ = ' ';
4112  sp = 0;
4113  len++;
4114  }
4115 
4116  if (*p == '$') {
4117  p--;
4118  } else {
4119  *c++ = *p;
4120  len++;
4121  }
4122  }
4123  }
4124  free(indup);
4125 
4126  return data;
4127 }
int switch_core_test_flag(int flag)
Definition: switch_core.c:1800
static int switch_string_has_escaped_data(const char *in)
Definition: switch_utils.h:350
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:617
#define zstr(x)
Definition: switch_utils.h:281
#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:789
static switch_bool_t switch_string_var_check_const(const char *s)
Definition: switch_utils.h:716
#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_status_t switch_channel_export_variable_printf ( switch_channel_t channel,
const char *  varname,
const char *  export_varname,
const char *  fmt,
  ... 
)

Definition at line 1319 of file switch_channel.c.

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

1321 {
1323  char *data = NULL;
1324  va_list ap;
1325  int ret;
1326 
1327  switch_assert(channel != NULL);
1328 
1329  va_start(ap, fmt);
1330  ret = switch_vasprintf(&data, fmt, ap);
1331  va_end(ap);
1332 
1333  if (ret == -1) {
1334  return SWITCH_STATUS_FALSE;
1335  }
1336 
1337  status = switch_channel_export_variable(channel, varname, data, export_varname);
1338 
1339  free(data);
1340 
1341  return status;
1342 }
#define switch_channel_export_variable(_channel, _varname, _value, _ev)
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_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 1271 of file switch_channel.c.

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

1274 {
1275  char *var_name = NULL;
1276  const char *exports;
1277  char *var, *new_exports, *new_exports_d = NULL;
1278  int local = 1;
1279 
1280  exports = switch_channel_get_variable(channel, export_varname);
1281 
1282  var = switch_core_session_strdup(channel->session, varname);
1283 
1284  if (var) {
1285  if (!strncasecmp(var, "nolocal:", 8)) { /* remove this later ? */
1286  var_name = var + 8;
1287  local = 0;
1288  } else if (!strncasecmp(var, "_nolocal_", 9)) {
1289  var_name = var + 9;
1290  local = 0;
1291  } else {
1292  var_name = var;
1293  }
1294  }
1295 
1296  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "EXPORT (%s) %s[%s]=[%s]\n",
1297  export_varname, local ? "" : "(REMOTE ONLY) ",
1298  var_name ? var_name : "", val ? val : "UNDEF");
1299 
1300 
1301  switch_channel_set_variable_var_check(channel, var, val, var_check);
1302 
1303  if (var && val) {
1304  if (exports) {
1305  new_exports_d = switch_mprintf("%s,%s", exports, var);
1306  new_exports = new_exports_d;
1307  } else {
1308  new_exports = var;
1309  }
1310 
1311  switch_channel_set_variable(channel, export_varname, new_exports);
1312 
1313  switch_safe_free(new_exports_d);
1314  }
1315 
1316  return SWITCH_STATUS_SUCCESS;
1317 }
#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:789
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's pool.
Definition: switch_core.h:717
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
void switch_channel_flip_cid ( switch_channel_t channel)

Definition at line 3082 of file switch_channel.c.

References CF_BRIDGED, 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, and switch_str_nil.

Referenced by switch_channel_sort_cid(), and switch_ivr_uuid_bridge().

3083 {
3084  switch_event_t *event;
3085  const char *tmp = NULL;
3086 
3087  switch_mutex_lock(channel->profile_mutex);
3088  if (channel->caller_profile->callee_id_name) {
3089  tmp = channel->caller_profile->caller_id_name;
3090  switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name);
3092  }
3093 
3094  if (switch_channel_test_flag(channel, CF_BRIDGED)) {
3096  } else if (tmp) {
3097  channel->caller_profile->callee_id_name = tmp;
3098  }
3099 
3100  if (channel->caller_profile->callee_id_number) {
3101  tmp = channel->caller_profile->caller_id_number;
3102  switch_channel_set_variable(channel, "pre_transfer_caller_id_number", channel->caller_profile->caller_id_number);
3104  }
3105 
3106  if (switch_channel_test_flag(channel, CF_BRIDGED)) {
3108  } else if (tmp) {
3109  channel->caller_profile->callee_id_number = tmp;
3110  }
3111 
3113 
3114 
3116  const char *uuid = switch_channel_get_partner_uuid(channel);
3117  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
3118 
3119  if (uuid) {
3120  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
3121  }
3122  switch_channel_event_set_data(channel, event);
3123  switch_event_fire(&event);
3124  }
3125 
3126 
3127  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n",
3128  switch_channel_get_name(channel),
3129  switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_name")),
3130  switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_number")),
3131  channel->caller_profile->caller_id_name,
3133  );
3134 
3135 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
#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:729
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:290
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:285
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:47
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:903
#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:383
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
void switch_channel_flush_dtmf ( _In_ switch_channel_t channel)
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 3184 of file switch_channel.c.

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

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

3185 {
3186  switch_caller_extension_t *extension = NULL;
3187 
3188  switch_assert(channel != NULL);
3189  switch_mutex_lock(channel->profile_mutex);
3190  if (channel->caller_profile) {
3191  extension = channel->caller_profile->caller_extension;
3192  }
3194  return extension;
3195 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_assert(expr)
struct switch_caller_extension * caller_extension
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 2760 of file switch_channel.c.

References switch_caller_profile::hunt_caller_profile, 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().

2761 {
2762  switch_caller_profile_t *profile;
2763  switch_assert(channel != NULL);
2764  switch_mutex_lock(channel->profile_mutex);
2765  if ((profile = channel->caller_profile) && profile->hunt_caller_profile) {
2766  profile = profile->hunt_caller_profile;
2767  }
2769  return profile;
2770 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_caller_profile * hunt_caller_profile
#define switch_assert(expr)
switch_channel_callstate_t switch_channel_get_callstate ( switch_channel_t channel)

Definition at line 296 of file switch_channel.c.

Referenced by switch_core_session_read_frame(), and switch_ivr_hold_toggle_uuid().

297 {
298  return channel->callstate;
299 }
switch_channel_callstate_t callstate
char* switch_channel_get_cap_string ( switch_channel_t channel)

Definition at line 1774 of file switch_channel.c.

References CC_FLAG_MAX, switch_stream_handle::data, end_of, 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().

1775 {
1776  switch_stream_handle_t stream = { 0 };
1777  char *r;
1778  int i = 0;
1779 
1780  SWITCH_STANDARD_STREAM(stream);
1781 
1782  switch_mutex_lock(channel->flag_mutex);
1783  for (i = 0; i < CC_FLAG_MAX; i++) {
1784  if (channel->caps[i]) {
1785  stream.write_function(&stream, "%d=%d;", i, channel->caps[i]);
1786  }
1787  }
1788  switch_mutex_unlock(channel->flag_mutex);
1789 
1790  r = (char *) stream.data;
1791 
1792  if (end_of(r) == ';') {
1793  end_of(r) = '\0';
1794  }
1795 
1796  return r;
1797 
1798 }
#define end_of(_s)
Definition: switch_utils.h:616
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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_call_cause_t switch_channel_get_cause ( _In_ switch_channel_t channel)
switch_call_cause_t* switch_channel_get_cause_ptr ( switch_channel_t channel)

Definition at line 231 of file switch_channel.c.

232 {
233  return &channel->hangup_cause;
234 }
switch_call_cause_t hangup_cause
switch_call_cause_t switch_channel_get_cause_q850 ( switch_channel_t channel)

Definition at line 401 of file switch_channel.c.

References switch_channel_cause_q850().

Referenced by switch_core_session_hangup_state().

402 {
403  return switch_channel_cause_q850(channel->hangup_cause);
404 }
switch_call_cause_t switch_channel_cause_q850(switch_call_cause_t cause)
switch_call_cause_t hangup_cause
char* switch_channel_get_flag_string ( switch_channel_t channel)

Definition at line 1748 of file switch_channel.c.

References CF_FLAG_MAX, switch_stream_handle::data, end_of, 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().

1749 {
1750  switch_stream_handle_t stream = { 0 };
1751  char *r;
1752  int i = 0;
1753 
1754  SWITCH_STANDARD_STREAM(stream);
1755 
1756  switch_mutex_lock(channel->flag_mutex);
1757  for (i = 0; i < CF_FLAG_MAX; i++) {
1758  if (channel->flags[i]) {
1759  stream.write_function(&stream, "%d=%d;", i, channel->flags[i]);
1760  }
1761  }
1762  switch_mutex_unlock(channel->flag_mutex);
1763 
1764  r = (char *) stream.data;
1765 
1766  if (end_of(r) == ';') {
1767  end_of(r) = '\0';
1768  }
1769 
1770  return r;
1771 
1772 }
#define end_of(_s)
Definition: switch_utils.h:616
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define SWITCH_STANDARD_STREAM(s)
switch_stream_handle_write_function_t write_function
const char* switch_channel_get_hold_music ( switch_channel_t channel)

Definition at line 874 of file switch_channel.c.

References 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().

875 {
876  const char *var;
877 
880  }
881 
882  if (!zstr(var)) {
883  char *expanded = switch_channel_expand_variables(channel, var);
884 
885  if (expanded != var) {
886  var = switch_core_session_strdup(channel->session, expanded);
887  free(expanded);
888  }
889  }
890 
891 
892  return var;
893 }
#define SWITCH_HOLD_MUSIC_VARIABLE
Definition: switch_types.h:192
#define zstr(x)
Definition: switch_utils.h:281
#define switch_channel_get_variable(_c, _v)
#define switch_channel_expand_variables(_channel, _in)
#define SWITCH_TEMP_HOLD_MUSIC_VARIABLE
Definition: switch_types.h:193
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
switch_core_session_t * session
const char* switch_channel_get_hold_music_partner ( switch_channel_t channel)

Definition at line 895 of file switch_channel.c.

References 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().

896 {
897  switch_core_session_t *session;
898  const char *r = NULL;
899 
903  }
904 
905  return r;
906 }
_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:1002
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
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 1110 of file switch_channel.c.

References switch_assert, and zstr.

Referenced by 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_nack(), inband_dtmf_generate_callback(), inherit_codec(), ip_choose_family(), meta_on_dtmf(), play_and_detect_input_callback(), read_rtp_packet(), recover_callback(), rtp_common_write(), setup_ringback(), signal_bridge_on_hibernate(), switch_channel_check_device_state(), switch_channel_check_zrtp(), 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_core_media_activate_rtp(), switch_core_media_bug_add(), switch_core_media_bug_close(), switch_core_media_bug_read(), switch_core_media_bug_remove_all_function(), 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_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_detect_speech(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_session_transfer(), switch_ivr_soft_hold(), switch_ivr_tone_detect_session(), switch_ivr_uuid_bridge(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), and video_helper_thread().

1111 {
1112  switch_assert(channel != NULL);
1113  return (!zstr(channel->name)) ? channel->name : "N/A";
1114 }
#define zstr(x)
Definition: switch_utils.h:281
#define switch_assert(expr)
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 2868 of file switch_channel.c.

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

Referenced by switch_core_session_reporting_state().

2869 {
2870  switch_caller_profile_t *profile = NULL;
2871  switch_assert(channel != NULL);
2872 
2873  switch_mutex_lock(channel->profile_mutex);
2874  if (channel->caller_profile) {
2875  profile = channel->caller_profile->originatee_caller_profile;
2876  }
2878 
2879  return profile;
2880 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_assert(expr)
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 2822 of file switch_channel.c.

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

2823 {
2824  switch_caller_profile_t *profile = NULL;
2825  switch_assert(channel != NULL);
2826 
2827  switch_mutex_lock(channel->profile_mutex);
2828  if (channel->caller_profile) {
2829  profile = channel->caller_profile->origination_caller_profile;
2830  }
2832 
2833  return profile;
2834 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_caller_profile * origination_caller_profile
#define switch_assert(expr)
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 2853 of file switch_channel.c.

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

Referenced by switch_core_session_reporting_state().

2854 {
2855  switch_caller_profile_t *profile = NULL;
2856  switch_assert(channel != NULL);
2857 
2858  switch_mutex_lock(channel->profile_mutex);
2859 
2860  if (channel->caller_profile) {
2861  profile = channel->caller_profile->originator_caller_profile;
2862  }
2864 
2865  return profile;
2866 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_caller_profile * originator_caller_profile
#define switch_assert(expr)
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 1062 of file switch_channel.c.

References 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_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(), switch_ivr_record_session_mask(), 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(), switch_rtp_create(), switch_rtp_write_frame(), switch_rtp_zerocopy_read_frame(), and tone_on_dtmf().

1063 {
1064  void *val;
1065  switch_assert(channel != NULL);
1066  val = switch_core_hash_find_locked(channel->private_hash, key, channel->profile_mutex);
1067  return val;
1068 }
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
#define switch_assert(expr)
void* switch_channel_get_private_partner ( switch_channel_t channel,
const char *  key 
)

Definition at line 1070 of file switch_channel.c.

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

1071 {
1072  const char *uuid;
1073  void *val = NULL;
1074 
1075  switch_assert(channel != NULL);
1076 
1077  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1078  switch_core_session_t *session;
1079  if ((session = switch_core_session_locate(uuid))) {
1080  val = switch_core_hash_find_locked(channel->private_hash, key, channel->profile_mutex);
1082  }
1083  }
1084 
1085  return val;
1086 }
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's uuid.
Definition: switch_core.h:916
#define switch_assert(expr)
switch_channel_state_t switch_channel_get_running_state ( switch_channel_t channel)

Definition at line 2095 of file switch_channel.c.

References switch_assert.

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

2096 {
2098  switch_assert(channel != NULL);
2099 
2100  state = channel->running_state;
2101 
2102  return state;
2103 }
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_status_t switch_channel_get_scope_variables ( switch_channel_t channel,
switch_event_t **  event 
)

Definition at line 926 of file switch_channel.c.

References ep, switch_event::headers, switch_event_header::name, switch_event_header::next, switch_event::next, 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.

927 {
929  switch_event_t *new_event;
930 
932  if (channel->scope_variables) {
935 
937  status = SWITCH_STATUS_SUCCESS;
938  *event = new_event;
939 
940  for (ep = channel->scope_variables; ep; ep = ep->next) {
941  for (hp = ep->headers; hp; hp = hp->next) {
942  if (!switch_event_get_header(new_event, hp->value)) {
944  }
945  }
946  }
947  }
949 
950  return status;
951 }
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:290
switch_event_t * scope_variables
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:385
static const char * ep
Definition: switch_json.c:36
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_core_session_t* switch_channel_get_session ( switch_channel_t channel)

Definition at line 4298 of file switch_channel.c.

References switch_assert.

4299 {
4300  switch_assert(channel);
4301  return channel->session;
4302 }
#define switch_assert(expr)
switch_core_session_t * session
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 2085 of file switch_channel.c.

References 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().

2086 {
2088  switch_assert(channel != NULL);
2089 
2090  state = channel->state;
2091 
2092  return state;
2093 }
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)
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 2915 of file switch_channel.c.

References switch_assert, SWITCH_MAX_STATE_HANDLERS, switch_mutex_lock(), and switch_mutex_unlock().

2916 {
2917  const switch_state_handler_table_t *h = NULL;
2918 
2919  switch_assert(channel != NULL);
2920 
2921  if (index >= SWITCH_MAX_STATE_HANDLERS || index > channel->state_handler_index) {
2922  return NULL;
2923  }
2924 
2925  switch_mutex_lock(channel->state_mutex);
2926  h = channel->state_handlers[index];
2927  switch_mutex_unlock(channel->state_mutex);
2928 
2929  return h;
2930 }
switch_mutex_t * state_mutex
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:559
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
#define switch_assert(expr)
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..)
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 2882 of file switch_channel.c.

References 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(), and switch_rtp_add_crypto_key().

2883 {
2884  switch_assert(channel != NULL);
2885  switch_assert(channel->session != NULL);
2886  return switch_core_session_get_uuid(channel->session);
2887 }
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
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 953 of file switch_channel.c.

References ep, switch_event::next, switch_caller_profile::originatee_caller_profile, switch_caller_profile::originator_caller_profile, 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(), and zstr.

Referenced by audio_bridge_thread(), check_jb_sync(), switch_channel_event_set_basic_data(), switch_channel_expand_variables_check(), switch_channel_queue_dtmf(), switch_channel_set_presence_data_vals(), switch_core_media_gen_local_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().

954 {
955  const char *v = NULL, *r = NULL, *vdup = NULL;
956  switch_assert(channel != NULL);
957 
959 
960  if (!zstr(varname)) {
961  if (channel->scope_variables) {
963 
964  for (ep = channel->scope_variables; ep; ep = ep->next) {
965  if ((v = switch_event_get_header_idx(ep, varname, idx))) {
966  break;
967  }
968  }
969  }
970 
971  if (!v && (!channel->variables || !(v = switch_event_get_header_idx(channel->variables, varname, idx)))) {
973 
974  if (cp) {
975  if (!strncmp(varname, "aleg_", 5)) {
976  cp = cp->originator_caller_profile;
977  varname += 5;
978  } else if (!strncmp(varname, "bleg_", 5)) {
979  cp = cp->originatee_caller_profile;
980  varname += 5;
981  }
982  }
983 
984  if (!cp || !(v = switch_caller_get_field_by_name(cp, varname))) {
985  if ((vdup = switch_core_get_variable_pdup(varname, switch_core_session_get_pool(channel->session)))) {
986  v = vdup;
987  }
988  }
989  }
990  }
991 
992  if (dup && v != vdup) {
993  if (v) {
994  r = switch_core_session_strdup(channel->session, v);
995  }
996  } else {
997  r = v;
998  }
999 
1001 
1002  return r;
1003 }
_Ret_opt_z_ char * switch_event_get_header_idx(switch_event_t *event, const char *header_name, int idx)
Definition: switch_event.c:817
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's name.
#define zstr(x)
Definition: switch_utils.h:281
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_event_t * scope_variables
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_caller_profile * originator_caller_profile
static const char * ep
Definition: switch_json.c:36
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
#define switch_assert(expr)
switch_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel'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.
const char* switch_channel_get_variable_partner ( switch_channel_t channel,
const char *  varname 
)

Definition at line 1005 of file switch_channel.c.

References 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_gen_local_sdp().

1006 {
1007  const char *uuid;
1008  const char *val = NULL, *r = NULL;
1009  switch_assert(channel != NULL);
1010 
1011  if (!zstr(varname)) {
1012  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1013  switch_core_session_t *session;
1014  if ((session = switch_core_session_locate(uuid))) {
1016  val = switch_channel_get_variable(tchannel, varname);
1018  }
1019  }
1020  }
1021 
1022  if (val)
1023  r = switch_core_session_strdup(channel->session, val);
1024 
1025  return r;
1026 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
#define zstr(x)
Definition: switch_utils.h:281
_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's uuid.
Definition: switch_core.h:916
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
#define switch_assert(expr)
switch_core_session_t * session
switch_status_t switch_channel_get_variables ( switch_channel_t channel,
switch_event_t **  event 
)

Definition at line 4285 of file switch_channel.c.

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

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

4286 {
4287  switch_status_t status;
4288  switch_mutex_lock(channel->profile_mutex);
4289  if (channel->variables) {
4290  status = switch_event_dup(event, channel->variables);
4291  } else {
4293  }
4295  return status;
4296 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:383
switch_size_t switch_channel_has_dtmf ( _In_ switch_channel_t channel)
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 747 of file switch_channel.c.

References CS_NONE, switch_assert, switch_channel_set_flag, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_request_uuid().

749 {
750  switch_assert(channel != NULL);
751  channel->state = state;
752  switch_channel_set_flag(channel, flag);
753  channel->session = session;
754  channel->running_state = CS_NONE;
755  return SWITCH_STATUS_SUCCESS;
756 }
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
void switch_channel_invert_cid ( switch_channel_t channel)

Definition at line 3052 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_ivr_uuid_bridge().

3053 {
3054  const char *tname, *tnum;
3056 
3057  cp = switch_channel_get_caller_profile(channel);
3058 
3059  tname = cp->caller_id_name;
3060  tnum = cp->caller_id_number;
3061 
3062 #ifdef DEEP_DEBUG_CID
3064 #endif
3065 
3066  cp->caller_id_name = cp->callee_id_name;
3068 
3069  cp->callee_id_name = tname;
3070  cp->callee_id_number = tnum;
3071 
3072  if (zstr(cp->caller_id_name)) {
3073  cp->caller_id_name = "Unknown";
3074  }
3075 
3076  if (zstr(cp->caller_id_number)) {
3077  cp->caller_id_number = "Unknown";
3078  }
3079 }
Call Specific Data.
Definition: switch_caller.h:73
#define SWITCH_CHANNEL_LOG
#define zstr(x)
Definition: switch_utils.h:281
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's caller profile.
const char * callee_id_name
Definition: switch_caller.h:87
switch_call_direction_t switch_channel_logical_direction ( switch_channel_t channel)

Definition at line 432 of file switch_channel.c.

433 {
434  return channel->logical_direction;
435 }
switch_call_direction_t logical_direction
void switch_channel_mark_hold ( switch_channel_t channel,
switch_bool_t  on 
)

Definition at line 841 of file switch_channel.c.

References CF_LEG_HOLDING, switch_channel_clear_flag(), switch_channel_event_set_data(), switch_channel_get_variable, switch_channel_set_flag, switch_channel_test_flag(), switch_core_media_bug_transfer_recordings(), switch_core_session_get_partner, switch_core_session_rwunlock(), SWITCH_EVENT_CHANNEL_HOLD, SWITCH_EVENT_CHANNEL_UNHOLD, switch_event_create, switch_event_fire, 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().

842 {
843  switch_event_t *event;
844 
845  if (!!on == !!switch_channel_test_flag(channel, CF_LEG_HOLDING)) {
846  goto end;
847  }
848 
849  if (on) {
851  } else {
853  }
854 
856  switch_channel_event_set_data(channel, event);
857  switch_event_fire(&event);
858  }
859 
860  end:
861 
862  if (on) {
863  if (switch_true(switch_channel_get_variable(channel, "flip_record_on_hold"))) {
864  switch_core_session_t *other_session;
865  if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
866  switch_core_media_bug_transfer_recordings(channel->session, other_session);
867  switch_core_session_rwunlock(other_session);
868  }
869  }
870  }
871 
872 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
Representation of an event.
Definition: switch_event.h:80
switch_status_t switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session)
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
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:1002
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:383
#define switch_channel_set_flag(_c, _f)
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_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_status_t switch_channel_pass_callee_id ( switch_channel_t channel,
switch_channel_t other_channel 
)

Definition at line 4259 of file switch_channel.c.

References 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().

4260 {
4261  int x = 0;
4262 
4263  switch_assert(channel);
4264  switch_assert(other_channel);
4265 
4266  switch_mutex_lock(channel->profile_mutex);
4267  switch_mutex_lock(other_channel->profile_mutex);
4268 
4269  if (!zstr(channel->caller_profile->callee_id_name)) {
4271  x++;
4272  }
4273 
4274  if (!zstr(channel->caller_profile->callee_id_number)) {
4276  x++;
4277  }
4278 
4279  switch_mutex_unlock(other_channel->profile_mutex);
4281 
4283 }
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
switch_caller_profile_t * caller_profile
#define zstr(x)
Definition: switch_utils.h:281
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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_status_t switch_channel_perform_answer ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3779 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CF_PROXY_MODE, CS_HANGUP, switch_core_session_message::from, switch_core_session_message::message_id, 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.

3780 {
3781  switch_core_session_message_t msg = { 0 };
3783 
3784  switch_assert(channel != NULL);
3785 
3787  return SWITCH_STATUS_SUCCESS;
3788  }
3789 
3790  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3791  return SWITCH_STATUS_FALSE;
3792  }
3793 
3794  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3795  return SWITCH_STATUS_SUCCESS;
3796  }
3797 
3799  msg.from = channel->name;
3800  status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
3801 
3802 
3803  if (status == SWITCH_STATUS_SUCCESS) {
3804  switch_channel_perform_mark_answered(channel, file, func, line);
3805  if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3806  switch_channel_audio_sync(channel);
3807  }
3808  } else {
3810  }
3811 
3812 
3814  const char *delay;
3815 
3816  if ((delay = switch_channel_get_variable(channel, "answer_delay"))) {
3817  uint32_t msec = atoi(delay);
3818 
3819  if (msec) {
3820  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_DEBUG, "Answer delay for %u msec\n", msec);
3821  switch_ivr_sleep(channel->session, msec, SWITCH_TRUE, NULL);
3822  }
3823  }
3824  }
3825 
3826  return status;
3827 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_core_session_message_types_t message_id
Definition: switch_core.h:181
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:177
#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)
void switch_channel_perform_audio_sync ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 353 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, switch_channel_media_up, switch_core_session_alloc, switch_core_session_queue_message(), and SWITCH_MESSAGE_INDICATE_AUDIO_SYNC.

354 {
355  if (switch_channel_media_up(channel)) {
356  switch_core_session_message_t *msg = NULL;
357 
358  msg = switch_core_session_alloc(channel->session, sizeof(*msg));
359  MESSAGE_STAMP_FFL(msg);
361  msg->from = channel->name;
362  msg->_file = file;
363  msg->_func = func;
364  msg->_line = line;
365 
367  }
368 }
switch_core_session_message_types_t message_id
Definition: switch_core.h:181
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:177
#define MESSAGE_STAMP_FFL(_m)
Definition: switch_core.h:173
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
switch_core_session_t * session
#define switch_channel_media_up(_channel)
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 3218 of file switch_channel.c.

References CF_BLOCK_STATE, CF_BRIDGE_ORIGINATOR, CF_BRIDGED, CF_HANGUP_HELD, CF_LEG_HOLDING, CS_HANGUP, OCF_HANGUP, 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().

3220 {
3221  int ok = 0;
3222 
3223  switch_assert(channel != NULL);
3224 
3225  /* one per customer */
3226  switch_mutex_lock(channel->state_mutex);
3227  if (!(channel->opaque_flags & OCF_HANGUP)) {
3228  channel->opaque_flags |= OCF_HANGUP;
3229  ok = 1;
3230  }
3231  switch_mutex_unlock(channel->state_mutex);
3232 
3233  if (switch_channel_test_flag(channel, CF_LEG_HOLDING)) {
3236  }
3237 
3238  if (!ok) {
3239  return channel->state;
3240  }
3241 
3243 
3244  if (channel->state < CS_HANGUP) {
3245  switch_channel_state_t last_state;
3246  switch_event_t *event;
3247  const char *var;
3248 
3249 
3250  switch_mutex_lock(channel->profile_mutex);
3251  if (channel->hold_record && !channel->hold_record->off) {
3252  channel->hold_record->off = switch_time_now();
3253  }
3255 
3256  switch_mutex_lock(channel->state_mutex);
3257  last_state = channel->state;
3258  channel->state = CS_HANGUP;
3259  switch_mutex_unlock(channel->state_mutex);
3260 
3261  channel->hangup_cause = hangup_cause;
3262  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
3263  channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
3264 
3265 
3266  switch_channel_set_variable_partner(channel, "last_bridge_hangup_cause", switch_channel_cause2str(hangup_cause));
3267 
3270  }
3271 
3273  switch_channel_set_variable(channel, "last_bridge_role", "originator");
3274  } else if (switch_channel_test_flag(channel, CF_BRIDGED)) {
3275  switch_channel_set_variable(channel, "last_bridge_role", "originatee");
3276  }
3277 
3278 
3281  }
3282 
3284  switch_channel_event_set_data(channel, event);
3285  switch_event_fire(&event);
3286  }
3287 
3291  }
3292 
3293  return channel->state;
3294 }
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:412
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:141
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:290
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:285
#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's unique id.
unsigned int switch_core_session_running(_In_ switch_core_session_t *session)
determine if the session'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:383
#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:302
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
Definition: switch_core.h:1352
switch_core_session_t * session
switch_time_t off
Definition: switch_core.h:74
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_status_t switch_channel_perform_mark_answered ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3672 of file switch_channel.c.

References CCS_ACTIVE, CF_ANSWERED, CF_EARLY_MEDIA, CF_PASSTHRU_PTIME_MISMATCH, CF_VIDEO_MIRROR_INPUT, CS_HANGUP, send_ind(), switch_assert, switch_channel_api_on(), SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE, SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE, switch_channel_check_zrtp(), 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_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, and switch_true().

Referenced by switch_channel_perform_answer().

3673 {
3674  switch_event_t *event;
3675  const char *uuid;
3676  switch_core_session_t *other_session;
3677  const char *var;
3678 
3679  switch_assert(channel != NULL);
3680 
3681  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3682  return SWITCH_STATUS_FALSE;
3683  }
3684 
3685  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3686  return SWITCH_STATUS_SUCCESS;
3687  }
3688 
3690 
3691  if (channel->caller_profile && channel->caller_profile->times) {
3692  switch_mutex_lock(channel->profile_mutex);
3695  }
3696 
3697  switch_channel_check_zrtp(channel);
3699 
3700  if (switch_true(switch_channel_get_variable(channel, "video_mirror_input"))) {
3702  //switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
3703  }
3704 
3705 
3707  switch_channel_event_set_data(channel, event);
3708  switch_event_fire(&event);
3709  }
3710 
3711  /* 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
3712  a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
3713  */
3715  && (other_session = switch_core_session_locate(uuid))) {
3717  switch_core_session_rwunlock(other_session);
3718  }
3719 
3722  }
3723 
3725  uint32_t seconds = 60;
3726  int tmp;
3727 
3728  if (switch_is_number(var)) {
3729  tmp = atoi(var);
3730  if (tmp > 0) {
3731  seconds = tmp;
3732  }
3733  } else if (!switch_true(var)) {
3734  seconds = 0;
3735  }
3736 
3737  if (seconds) {
3738  switch_core_session_enable_heartbeat(channel->session, seconds);
3739  }
3740  }
3741 
3743  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n",
3744  channel->name);
3745 
3746 
3747  if (switch_channel_get_variable(channel, "absolute_codec_string")) {
3748  /* inherit_codec == true will implicitly clear the absolute_codec_string
3749  variable if used since it was the reason it was set in the first place and is no longer needed */
3750  if (switch_true(switch_channel_get_variable(channel, "inherit_codec"))) {
3751  switch_channel_set_variable(channel, "absolute_codec_string", NULL);
3752  }
3753  }
3754 
3756 
3757  if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3760  }
3761 
3763 
3764  switch_channel_presence(channel, "unknown", "answered", NULL);
3765 
3766  //switch_channel_audio_sync(channel);
3767 
3769 
3771 
3772  send_ind(channel, SWITCH_MESSAGE_ANSWER_EVENT, file, func, line);
3773 
3775 
3776  return SWITCH_STATUS_SUCCESS;
3777 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
#define SWITCH_ORIGINATOR_VARIABLE
Definition: switch_types.h:204
#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE
Definition: switch_types.h:150
void switch_channel_check_zrtp(switch_channel_t *channel)
#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)
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
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:290
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:285
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE
Definition: switch_types.h:191
#define switch_channel_get_variable(_c, _v)
#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE
Definition: switch_types.h:148
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel'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:133
#define SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE
Definition: switch_types.h:134
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
Definition: switch_core.h:916
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:383
#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:162
#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:1352
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:160
switch_status_t switch_channel_perform_mark_pre_answered ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3408 of file switch_channel.c.

References caller_profile, CCS_EARLY, CF_ANSWERED, CF_EARLY_MEDIA, CF_PASSTHRU_PTIME_MISMATCH, CF_VIDEO_MIRROR_INPUT, switch_channel_timetable::progress_media, send_ind(), switch_channel_api_on(), SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE, SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE, switch_channel_check_zrtp(), 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(), and switch_caller_profile::times.

Referenced by switch_channel_perform_pre_answer().

3409 {
3410  switch_event_t *event;
3411 
3413  const char *uuid;
3414  switch_core_session_t *other_session;
3415 
3417 
3418  switch_channel_check_zrtp(channel);
3419  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
3421 
3423 
3424  if (switch_true(switch_channel_get_variable(channel, "video_mirror_input"))) {
3426  }
3427 
3428  if (channel->caller_profile && channel->caller_profile->times) {
3429  switch_mutex_lock(channel->profile_mutex);
3431  if (channel->caller_profile->originator_caller_profile) {
3432  switch_core_session_t *osession;
3434  switch_channel_t *other_channel;
3435  other_channel = switch_core_session_get_channel(osession);
3436  if (other_channel->caller_profile) {
3437  other_channel->caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
3438  }
3439  switch_core_session_rwunlock(osession);
3440  }
3442  }
3444  }
3445 
3447  switch_channel_event_set_data(channel, event);
3448  switch_event_fire(&event);
3449  }
3450 
3453 
3456 
3459  }
3460 
3461 
3462  /* 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
3463  a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
3464  */
3466  && (other_session = switch_core_session_locate(uuid))) {
3468  switch_core_session_rwunlock(other_session);
3469  }
3470 
3472 
3473  send_ind(channel, SWITCH_MESSAGE_PROGRESS_EVENT, file, func, line);
3474 
3476 
3477  return SWITCH_STATUS_SUCCESS;
3478  }
3479 
3480  return SWITCH_STATUS_FALSE;
3481 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
#define SWITCH_ORIGINATOR_VARIABLE
Definition: switch_types.h:204
#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE
Definition: switch_types.h:150
void switch_channel_check_zrtp(switch_channel_t *channel)
#define SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE
Definition: switch_types.h:161
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)
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
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:290
_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:285
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE
Definition: switch_types.h:191
#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'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:133
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
Definition: switch_core.h:916
#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:383
#define switch_channel_set_flag(_c, _f)
struct switch_channel_timetable * times
#define SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE
Definition: switch_types.h:149
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:162
#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:1352
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_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 3306 of file switch_channel.c.

References caller_profile, CCS_RINGING, CF_ANSWERED, CF_RING_READY, 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, and switch_caller_profile::times.

Referenced by switch_channel_perform_ring_ready_value().

3309 {
3310  switch_event_t *event;
3311 
3313  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
3315 
3316 
3317  if (channel->caller_profile && channel->caller_profile->times) {
3318  switch_mutex_lock(channel->profile_mutex);
3320  if (channel->caller_profile->originator_caller_profile) {
3321  switch_core_session_t *other_session;
3322  if ((other_session = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) {
3323  switch_channel_t *other_channel;
3324  other_channel = switch_core_session_get_channel(other_session);
3325  if (other_channel->caller_profile) {
3326  other_channel->caller_profile->times->progress = channel->caller_profile->times->progress;
3327  }
3328  switch_core_session_rwunlock(other_session);
3329  }
3331  }
3333  }
3334 
3336  switch_channel_event_set_data(channel, event);
3337  switch_event_fire(&event);
3338  }
3339 
3342 
3344 
3345  send_ind(channel, SWITCH_MESSAGE_RING_EVENT, file, func, line);
3346 
3347  return SWITCH_STATUS_SUCCESS;
3348  }
3349 
3350  return SWITCH_STATUS_FALSE;
3351 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
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:290
_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:285
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'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:151
#define switch_channel_set_callstate(channel, state)
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
Definition: switch_core.h:916
#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:383
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:163
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_status_t switch_channel_perform_pre_answer ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 3483 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CS_HANGUP, switch_core_session_message::from, switch_core_session_message::message_id, 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.

3484 {
3485  switch_core_session_message_t msg = { 0 };
3487 
3488  switch_assert(channel != NULL);
3489 
3490  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3491  return SWITCH_STATUS_FALSE;
3492  }
3493 
3494  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3495  return SWITCH_STATUS_SUCCESS;
3496  }
3497 
3498  if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3499  return SWITCH_STATUS_SUCCESS;
3500  }
3501 
3504  msg.from = channel->name;
3505  status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
3506  }
3507 
3508  if (status == SWITCH_STATUS_SUCCESS) {
3509  switch_channel_perform_mark_pre_answered(channel, file, func, line);
3510  switch_channel_audio_sync(channel);
3511  } else {
3513  }
3514 
3515  return status;
3516 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
switch_core_session_message_types_t message_id
Definition: switch_core.h:181
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:177
#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
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 758 of file switch_channel.c.

References CF_ANSWERED, CF_NO_PRESENCE, CF_SLA_INTERCEPT, 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().

760 {
761  switch_event_t *event;
763  const char *call_info = NULL;
764  char *call_info_state = "active";
765 
767  return;
768  }
769 
770  if (!status) {
772  status = "idle";
773  }
774 
775  if (!id) {
776  id = switch_channel_get_variable(channel, "presence_id");
777  }
778 
779  if (!id) {
780  return;
781  }
782 
783  call_info = switch_channel_get_variable(channel, "presence_call_info");
784 
785  if (switch_event_create(&event, type) == SWITCH_STATUS_SUCCESS) {
786  switch_channel_event_set_data(channel, event);
787  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "any");
788  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", __FILE__);
790  if (type == SWITCH_EVENT_PRESENCE_IN) {
791  if (!rpid) {
792  rpid = "unknown";
793  }
795  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", status);
796  }
797  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
798  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
799 
800 
801  if (!strcasecmp(status, "idle") || !switch_channel_up_nosig(channel)) {
802  call_info_state = "idle";
803  } else if (!strcasecmp(status, "hold-private")) {
804  call_info_state = "held-private";
805  } else if (!strcasecmp(status, "hold")) {
806  call_info_state = "held";
807  } else if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
808  if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
809  call_info_state = "progressing";
810  } else {
812  call_info_state = "idle";
813  } else {
814  call_info_state = "alerting";
815  }
816  }
817  }
818 
819  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info-state", call_info_state);
820 
821  if (call_info) {
822  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-info", call_info);
823  }
824 
825  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction",
826  channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
827 
828  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", channel->event_count++);
829  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Calling-File", file);
830  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Calling-Function", func);
831  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Presence-Calling-Line", "%d", line);
832 
833  if (switch_true(switch_channel_get_variable(channel, "presence_privacy"))) {
834  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Privacy", "true");
835  }
836 
837  switch_event_fire(&event);
838  }
839 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
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
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
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:383
#define switch_channel_up_nosig(_channel)
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 3518 of file switch_channel.c.

References CF_ANSWERED, CF_EARLY_MEDIA, CS_HANGUP, switch_core_session_message::from, switch_core_session_message::message_id, switch_core_session_message::numeric_arg, 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.

3520 {
3521  switch_core_session_message_t msg = { 0 };
3523 
3524  switch_assert(channel != NULL);
3525 
3526  if (channel->hangup_cause || channel->state >= CS_HANGUP) {
3527  return SWITCH_STATUS_FALSE;
3528  }
3529 
3530  if (switch_channel_test_flag(channel, CF_ANSWERED)) {
3531  return SWITCH_STATUS_SUCCESS;
3532  }
3533 
3534  if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
3535  return SWITCH_STATUS_SUCCESS;
3536  }
3537 
3540  msg.from = channel->name;
3541  msg.numeric_arg = rv;
3542  status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
3543  }
3544 
3545  if (status == SWITCH_STATUS_SUCCESS) {
3546  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
3547  switch_channel_perform_mark_ring_ready_value(channel, rv, file, func, line);
3548  } else {
3550  }
3551 
3552  return status;
3553 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
switch_core_session_message_types_t message_id
Definition: switch_core.h:181
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:177
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'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
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 270 of file switch_channel.c.

References CCS_HANGUP, 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.

272 {
273  switch_event_t *event;
274  switch_channel_callstate_t o_callstate = channel->callstate;
275 
276  if (o_callstate == callstate || o_callstate == CCS_HANGUP) return;
277 
278  channel->callstate = callstate;
279  if (channel->device_node) {
280  channel->device_node->callstate = callstate;
281  }
283  "(%s) Callstate Change %s -> %s\n", channel->name,
285 
286  switch_channel_check_device_state(channel, channel->callstate);
287 
289  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Original-Channel-Call-State", switch_channel_callstate2str(o_callstate));
290  switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Call-State-Number", "%d", callstate);
291  switch_channel_event_set_data(channel, event);
292  switch_event_fire(&event);
293  }
294 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
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's unique id.
switch_channel_callstate_t callstate
Definition: switch_core.h:83
#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:383
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_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 2216 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, 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_EVENT_CHANNEL_STATE, switch_event_create, switch_event_fire, SWITCH_LOG_DEBUG, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_SUCCESS.

2218 {
2219  int x;
2220 
2221  switch_mutex_lock(channel->flag_mutex);
2222  if (channel->state_flags[0]) {
2223  for (x = 1; x < CF_FLAG_MAX; x++) {
2224  if (channel->state_flags[x]) {
2225  channel->flags[x] = 1;
2226  channel->state_flags[x] = 0;
2227  }
2228  }
2229  channel->state_flags[0] = 0;
2230  }
2231  switch_mutex_unlock(channel->flag_mutex);
2232 
2234 
2235 
2236  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n",
2237  channel->name, state_names[state]);
2238 
2239  switch_mutex_lock(channel->state_mutex);
2240 
2241  careful_set(channel, &channel->running_state, state);
2242 
2243  if (state <= CS_DESTROY) {
2244  switch_event_t *event;
2245 
2247  if (state < CS_HANGUP) {
2248  if (state == CS_ROUTING) {
2250  } else if (switch_channel_test_flag(channel, CF_ANSWERED)) {
2252  } else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
2254  }
2255  }
2256  }
2257 
2259  switch_channel_event_set_data(channel, event);
2260  switch_event_fire(&event);
2261  }
2262  }
2263 
2264  switch_mutex_unlock(channel->state_mutex);
2265 
2267 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
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_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
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:285
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel'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_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:383
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_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 2269 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, 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().

2271 {
2272  switch_channel_state_t last_state;
2273  int ok = 0;
2274 
2275  switch_assert(channel != NULL);
2277  switch_mutex_lock(channel->state_mutex);
2278 
2279  last_state = channel->state;
2280  switch_assert(last_state <= CS_DESTROY);
2281 
2282  if (last_state == state) {
2283  goto done;
2284  }
2285 
2286  if (last_state >= CS_HANGUP && state < last_state) {
2287  goto done;
2288  }
2289 
2290  /* STUB for more dev
2291  case CS_INIT:
2292  switch(state) {
2293 
2294  case CS_NEW:
2295  case CS_INIT:
2296  case CS_EXCHANGE_MEDIA:
2297  case CS_SOFT_EXECUTE:
2298  case CS_ROUTING:
2299  case CS_EXECUTE:
2300  case CS_HANGUP:
2301  case CS_DESTROY:
2302 
2303  default:
2304  break;
2305  }
2306  break;
2307  */
2308 
2309  switch (last_state) {
2310  case CS_NEW:
2311  case CS_RESET:
2312  switch (state) {
2313  default:
2314  ok++;
2315  break;
2316  }
2317  break;
2318 
2319  case CS_INIT:
2320  switch (state) {
2321  case CS_EXCHANGE_MEDIA:
2322  case CS_SOFT_EXECUTE:
2323  case CS_ROUTING:
2324  case CS_EXECUTE:
2325  case CS_PARK:
2326  case CS_CONSUME_MEDIA:
2327  case CS_HIBERNATE:
2328  case CS_RESET:
2329  ok++;
2330  default:
2331  break;
2332  }
2333  break;
2334 
2335  case CS_EXCHANGE_MEDIA:
2336  switch (state) {
2337  case CS_SOFT_EXECUTE:
2338  case CS_ROUTING:
2339  case CS_EXECUTE:
2340  case CS_PARK:
2341  case CS_CONSUME_MEDIA:
2342  case CS_HIBERNATE:
2343  case CS_RESET:
2344  ok++;
2345  default:
2346  break;
2347  }
2348  break;
2349 
2350  case CS_SOFT_EXECUTE:
2351  switch (state) {
2352  case CS_EXCHANGE_MEDIA:
2353  case CS_ROUTING:
2354  case CS_EXECUTE:
2355  case CS_PARK:
2356  case CS_CONSUME_MEDIA:
2357  case CS_HIBERNATE:
2358  case CS_RESET:
2359  ok++;
2360  default:
2361  break;
2362  }
2363  break;
2364 
2365  case CS_PARK:
2366  switch (state) {
2367  case CS_EXCHANGE_MEDIA:
2368  case CS_ROUTING:
2369  case CS_EXECUTE:
2370  case CS_SOFT_EXECUTE:
2371  case CS_HIBERNATE:
2372  case CS_RESET:
2373  case CS_CONSUME_MEDIA:
2374  ok++;
2375  default:
2376  break;
2377  }
2378  break;
2379 
2380  case CS_CONSUME_MEDIA:
2381  switch (state) {
2382  case CS_EXCHANGE_MEDIA:
2383  case CS_ROUTING:
2384  case CS_EXECUTE:
2385  case CS_SOFT_EXECUTE:
2386  case CS_HIBERNATE:
2387  case CS_RESET:
2388  case CS_PARK:
2389  ok++;
2390  default:
2391  break;
2392  }
2393  break;
2394  case CS_HIBERNATE:
2395  switch (state) {
2396  case CS_EXCHANGE_MEDIA:
2397  case CS_INIT:
2398  case CS_ROUTING:
2399  case CS_EXECUTE:
2400  case CS_SOFT_EXECUTE:
2401  case CS_PARK:
2402  case CS_CONSUME_MEDIA:
2403  case CS_RESET:
2404  ok++;
2405  default:
2406  break;
2407  }
2408  break;
2409 
2410  case CS_ROUTING:
2411  switch (state) {
2412  case CS_EXCHANGE_MEDIA:
2413  case CS_EXECUTE:
2414  case CS_SOFT_EXECUTE:
2415  case CS_PARK:
2416  case CS_CONSUME_MEDIA:
2417  case CS_HIBERNATE:
2418  case CS_RESET:
2419  ok++;
2420  default:
2421  break;
2422  }
2423  break;
2424 
2425  case CS_EXECUTE:
2426  switch (state) {
2427  case CS_EXCHANGE_MEDIA:
2428  case CS_SOFT_EXECUTE:
2429  case CS_ROUTING:
2430  case CS_PARK:
2431  case CS_CONSUME_MEDIA:
2432  case CS_HIBERNATE:
2433  case CS_RESET:
2434  ok++;
2435  default:
2436  break;
2437  }
2438  break;
2439 
2440  case CS_HANGUP:
2441  switch (state) {
2442  case CS_REPORTING:
2443  case CS_DESTROY:
2444  ok++;
2445  default:
2446  break;
2447  }
2448  break;
2449 
2450  case CS_REPORTING:
2451  switch (state) {
2452  case CS_DESTROY:
2453  ok++;
2454  default:
2455  break;
2456  }
2457  break;
2458 
2459  default:
2460  break;
2461 
2462  }
2463 
2464  if (ok) {
2465  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) State Change %s -> %s\n",
2466  channel->name, state_names[last_state], state_names[state]);
2467 
2468  careful_set(channel, &channel->state, state);
2469 
2470  if (state == CS_HANGUP && !channel->hangup_cause) {
2472  }
2473 
2474  if (state <= CS_DESTROY) {
2476  }
2477  } else {
2479  "(%s) Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
2480  /* we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee! */
2481  /* not cool lets crash this bad boy and figure out wtf is going on */
2482  switch_assert(channel->state >= CS_HANGUP);
2483  }
2484  done:
2485 
2486  switch_mutex_unlock(channel->state_mutex);
2487  return channel->state;
2488 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel'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
void switch_channel_perform_video_sync ( switch_channel_t channel,
const char *  file,
const char *  func,
int  line 
)

Definition at line 371 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, 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.

372 {
373 
374  if (switch_channel_media_up(channel)) {
375  switch_core_session_message_t *msg = NULL;
376 
377  msg = switch_core_session_alloc(channel->session, sizeof(*msg));
378  MESSAGE_STAMP_FFL(msg);
380  msg->from = channel->name;
381  msg->_file = file;
382  msg->_func = func;
383  msg->_line = line;
384 
387  }
388 }
switch_core_session_message_types_t message_id
Definition: switch_core.h:181
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:177
switch_status_t switch_core_session_request_video_refresh(switch_core_session_t *session)
#define MESSAGE_STAMP_FFL(_m)
Definition: switch_core.h:173
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
switch_core_session_t * session
#define switch_channel_media_up(_channel)
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 1214 of file switch_channel.c.

References 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().

1216 {
1217 
1218  const char *export_vars = switch_channel_get_variable(channel, export_varname);
1219  char *cptmp = switch_core_session_strdup(channel->session, export_vars);
1220  int argc;
1221  char *argv[256];
1222 
1223  if (zstr(export_vars)) return;
1224 
1225 
1226  if (var_event) {
1227  switch_event_del_header(var_event, export_varname);
1228  switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, export_varname, export_vars);
1229  }
1230 
1231  if (peer_channel) {
1232  switch_channel_set_variable(peer_channel, export_varname, export_vars);
1233  }
1234 
1235  if ((argc = switch_separate_string(cptmp, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
1236  int x;
1237 
1238  for (x = 0; x < argc; x++) {
1239  const char *vval;
1240  if ((vval = switch_channel_get_variable(channel, argv[x]))) {
1241  char *vvar = argv[x];
1242  if (!strncasecmp(vvar, "nolocal:", 8)) { /* remove this later ? */
1243  vvar += 8;
1244  } else if (!strncasecmp(vvar, "_nolocal_", 9)) {
1245  vvar += 9;
1246  }
1247  if (var_event) {
1248  switch_event_del_header(var_event, vvar);
1249  switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, vvar, vval);
1251  "%s EXPORTING[%s] [%s]=[%s] to event\n",
1252  switch_channel_get_name(channel),
1253  export_varname,
1254  vvar, vval);
1255  }
1256  if (peer_channel) {
1258  "%s EXPORTING[%s] [%s]=[%s] to %s\n",
1259  switch_channel_get_name(channel),
1260  export_varname,
1261  vvar, vval, switch_channel_get_name(peer_channel));
1262  switch_channel_set_variable(peer_channel, vvar, vval);
1263  }
1264  }
1265  }
1266  }
1267 
1268 
1269 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:211
#define zstr(x)
Definition: switch_utils.h:281
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's pool.
Definition: switch_core.h:717
#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_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_status_t switch_channel_queue_dtmf_string ( _In_ switch_channel_t channel,
_In_ const char *  dtmf_string 
)
void switch_channel_restart ( switch_channel_t channel)

Definition at line 2969 of file switch_channel.c.

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

Referenced by switch_ivr_originate().

2970 {
2974 }
#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)
void switch_channel_set_app_flag_key ( const char *  app,
switch_channel_t channel,
uint32_t  flags 
)

Definition at line 1920 of file switch_channel.c.

References 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_process_udptl(), and switch_ivr_eavesdrop_update_display().

1921 {
1922  uint32_t *flagp = NULL;
1923  switch_byte_t new = 0;
1924 
1925  switch_assert(channel != NULL);
1926  switch_mutex_lock(channel->flag_mutex);
1927 
1928  if (!channel->app_flag_hash) {
1930  new++;
1931  }
1932 
1933  if (new || !(flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
1934  flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
1935  switch_core_hash_insert(channel->app_flag_hash, key, flagp);
1936  }
1937 
1938  switch_assert(flagp);
1939  *flagp |= flags;
1940 
1941  switch_mutex_unlock(channel->flag_mutex);
1942 }
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:1390
switch_hash_t * app_flag_hash
uint8_t switch_byte_t
Definition: switch_types.h:246
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
#define switch_core_hash_insert(_h, _k, _d)
Definition: switch_core.h:1410
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
#define switch_assert(expr)
switch_core_session_t * session
void switch_channel_set_bridge_time ( switch_channel_t channel)

Definition at line 3198 of file switch_channel.c.

References switch_micro_time_now(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by signal_bridge_on_hibernate(), and switch_ivr_multi_threaded_bridge().

3199 {
3200  switch_mutex_lock(channel->profile_mutex);
3201  if (channel->caller_profile && channel->caller_profile->times) {
3203  }
3205 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_channel_timetable * times
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 3171 of file switch_channel.c.

References 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(), and switch_core_standard_on_routing().

3172 {
3173  switch_assert(channel != NULL);
3174 
3175  switch_channel_sort_cid(channel);
3176 
3177  switch_mutex_lock(channel->profile_mutex);
3178  caller_extension->next = channel->caller_profile->caller_extension;
3179  channel->caller_profile->caller_extension = caller_extension;
3181 }
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:290
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:285
#define switch_assert(expr)
struct switch_caller_extension * caller_extension
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 2709 of file switch_channel.c.

References 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(), and switch_mutex_unlock().

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

2710 {
2711  char *uuid = NULL;
2712  switch_assert(channel != NULL);
2713  switch_assert(channel->session != NULL);
2714  switch_mutex_lock(channel->profile_mutex);
2715  switch_assert(caller_profile != NULL);
2716 
2717  caller_profile->direction = channel->direction;
2718  caller_profile->logical_direction = channel->logical_direction;
2719  uuid = switch_core_session_get_uuid(channel->session);
2720 
2721  if (!caller_profile->uuid || strcasecmp(caller_profile->uuid, uuid)) {
2722  caller_profile->uuid = switch_core_session_strdup(channel->session, uuid);
2723  }
2724 
2725  if (!caller_profile->chan_name || strcasecmp(caller_profile->chan_name, channel->name)) {
2726  caller_profile->chan_name = switch_core_session_strdup(channel->session, channel->name);
2727  }
2728 
2729  if (!caller_profile->context) {
2730  caller_profile->context = switch_core_session_strdup(channel->session, "default");
2731  }
2732 
2733  if (!caller_profile->times) {
2734  caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times));
2735  caller_profile->times->profile_created = switch_micro_time_now();
2736  }
2737 
2738  if (channel->caller_profile && channel->caller_profile->times) {
2739  channel->caller_profile->times->transferred = caller_profile->times->profile_created;
2740  caller_profile->times->answered = channel->caller_profile->times->answered;
2741  caller_profile->times->progress = channel->caller_profile->times->progress;
2742  caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
2743  caller_profile->times->created = channel->caller_profile->times->created;
2744  caller_profile->times->hungup = channel->caller_profile->times->hungup;
2745  if (channel->caller_profile->caller_extension) {
2746  switch_caller_extension_clone(&caller_profile->caller_extension, channel->caller_profile->caller_extension, caller_profile->pool);
2747  }
2748  } else {
2749  caller_profile->times->created = switch_micro_time_now();
2750  }
2751 
2752 
2753  caller_profile->next = channel->caller_profile;
2754  channel->caller_profile = caller_profile;
2755  caller_profile->profile_index = switch_core_sprintf(caller_profile->pool, "%d", ++channel->profile_index);
2756 
2758 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
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:290
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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's pool.
Definition: switch_core.h:694
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
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
void switch_channel_set_cap_value ( switch_channel_t channel,
switch_channel_cap_t  cap,
uint32_t  value 
)

Definition at line 1704 of file switch_channel.c.

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

Referenced by switch_core_session_request_xml().

1705 {
1706  switch_assert(channel);
1707  switch_assert(channel->flag_mutex);
1708 
1709  switch_mutex_lock(channel->flag_mutex);
1710  channel->caps[cap] = value;
1711  switch_mutex_unlock(channel->flag_mutex);
1712 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
uint32_t caps[CC_FLAG_MAX]
#define switch_assert(expr)
void switch_channel_set_direction ( switch_channel_t channel,
switch_call_direction_t  direction 
)

Definition at line 419 of file switch_channel.c.

References SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_direction(), switch_channel_set_variable, and switch_core_session_in_thread().

420 {
421  if (!switch_core_session_in_thread(channel->session)) {
422  channel->direction = channel->logical_direction = direction;
423  switch_channel_set_variable(channel, "direction", switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
424  }
425 }
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_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 1575 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.

1576 {
1577  const char *uuid;
1578 
1579  switch_assert(channel != NULL);
1580 
1581  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1582  switch_core_session_t *session;
1583  if ((session = switch_core_session_locate(uuid))) {
1586  return SWITCH_TRUE;
1587  }
1588  }
1589 
1590  return SWITCH_FALSE;
1591 }
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's uuid.
Definition: switch_core.h:916
#define switch_channel_set_flag(_c, _f)
#define switch_assert(expr)
void switch_channel_set_flag_recursive ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 1879 of file switch_channel.c.

References CF_OUTBOUND, CF_RECOVERED, 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(), and switch_ivr_signal_bridge().

1880 {
1881  switch_assert(channel);
1882  switch_assert(channel->flag_mutex);
1883 
1884  switch_mutex_lock(channel->flag_mutex);
1885  channel->flags[flag]++;
1886  switch_mutex_unlock(channel->flag_mutex);
1887 
1888  if (flag == CF_OUTBOUND) {
1889  switch_channel_set_variable(channel, "is_outbound", "true");
1890  }
1891 
1892  if (flag == CF_RECOVERED) {
1893  switch_channel_set_variable(channel, "recovered", "true");
1894  }
1895 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
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 1800 of file switch_channel.c.

References 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, switch_hold_record_s::next, switch_hold_record_s::on, 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(), and switch_hold_record_s::uuid.

Referenced by switch_channel_perform_mark_ring_ready_value(), and switch_core_session_request_xml().

1801 {
1802  int HELD = 0;
1803  int just_set = 0;
1804 
1805  switch_assert(channel);
1806  switch_assert(channel->flag_mutex);
1807 
1808  switch_mutex_lock(channel->flag_mutex);
1809  if (flag == CF_LEG_HOLDING && !channel->flags[flag] && channel->flags[CF_ANSWERED]) {
1810  HELD = 1;
1811  }
1812  if (channel->flags[flag] != value) {
1813  just_set = 1;
1814  channel->flags[flag] = value;
1815  }
1816  switch_mutex_unlock(channel->flag_mutex);
1817 
1818  if (flag == CF_VIDEO_READY && just_set) {
1820  }
1821 
1822  if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
1824  }
1825 
1826  if (flag == CF_DIALPLAN) {
1827  if (channel->direction == SWITCH_CALL_DIRECTION_INBOUND) {
1829  if (channel->device_node) {
1831  }
1832  } else {
1834  if (channel->device_node) {
1836  }
1837  }
1838  }
1839 
1840  if (HELD) {
1842  const char *brto = switch_channel_get_partner_uuid(channel);
1843 
1845  switch_mutex_lock(channel->profile_mutex);
1847 
1848  hr = switch_core_session_alloc(channel->session, sizeof(*hr));
1849  hr->on = switch_time_now();
1850  if (brto) {
1851  hr->uuid = switch_core_session_strdup(channel->session, brto);
1852  }
1853 
1854  if (channel->hold_record) {
1855  hr->next = channel->hold_record;
1856  }
1857  channel->hold_record = hr;
1858 
1860  }
1861 
1862  if (flag == CF_OUTBOUND) {
1863  switch_channel_set_variable(channel, "is_outbound", "true");
1864  }
1865 
1866  if (flag == CF_RECOVERED) {
1867  switch_channel_set_variable(channel, "recovered", "true");
1868  }
1869 
1870  if (flag == CF_VIDEO_ECHO || flag == CF_VIDEO_BLANK || flag == CF_VIDEO_DECODED_READ || flag == CF_VIDEO_PASSIVE) {
1872  }
1873 
1874  if (flag == CF_VIDEO_DECODED_READ && channel->flags[CF_VIDEO]) {
1876  }
1877 }
struct switch_hold_record_s * next
Definition: switch_core.h:76
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.
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:290
switch_time_t on
Definition: switch_core.h:73
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_call_direction_t direction
Definition: switch_core.h:86
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
switch_status_t switch_core_session_request_video_refresh(switch_core_session_t *session)
#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's pool.
Definition: switch_core.h:694
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's pool.
Definition: switch_core.h:717
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
Definition: switch_apr.c:302
switch_core_session_t * session
void switch_channel_set_hangup_time ( switch_channel_t channel)

Definition at line 3208 of file switch_channel.c.

References switch_micro_time_now(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_hangup_state().

3209 {
3210  if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
3211  switch_mutex_lock(channel->profile_mutex);
3214  }
3215 }
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_channel_timetable * times
void switch_channel_set_hunt_caller_profile ( switch_channel_t channel,
switch_caller_profile_t caller_profile 
)

Definition at line 2791 of file switch_channel.c.

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

Referenced by switch_core_session_execute_exten().

2792 {
2793  switch_assert(channel != NULL);
2794  switch_assert(channel->caller_profile != NULL);
2795 
2796  switch_mutex_lock(channel->profile_mutex);
2797 
2798  channel->caller_profile->hunt_caller_profile = NULL;
2799  if (channel->caller_profile && caller_profile) {
2800  caller_profile->direction = channel->direction;
2801  caller_profile->logical_direction = channel->logical_direction;
2802  channel->caller_profile->hunt_caller_profile = caller_profile;
2803  }
2805 }
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:290
switch_call_direction_t logical_direction
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_call_direction_t direction
switch_call_direction_t direction
struct switch_caller_profile * hunt_caller_profile
#define switch_assert(expr)
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 1088 of file switch_channel.c.

References 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().

1089 {
1090  const char *old = NULL;
1091 
1092  switch_assert(channel != NULL);
1093  if (!zstr(channel->name)) {
1094  old = channel->name;
1095  }
1096  channel->name = NULL;
1097  if (name) {
1098  char *uuid = switch_core_session_get_uuid(channel->session);
1099  channel->name = switch_core_session_strdup(channel->session, name);
1101  if (old) {
1102  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_NOTICE, "Rename Channel %s->%s [%s]\n", old, name, uuid);
1103  } else {
1104  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_NOTICE, "New Channel %s [%s]\n", name, uuid);
1105  }
1106  }
1107  return SWITCH_STATUS_SUCCESS;
1108 }
#define zstr(x)
Definition: switch_utils.h:281
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:181
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's pool.
Definition: switch_core.h:717
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
#define SWITCH_CHANNEL_CHANNEL_LOG(x)
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 2837 of file switch_channel.c.

References LP_ORIGINATEE, switch_assert, switch_mutex_lock(), and switch_mutex_unlock().

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

2838 {
2839  switch_assert(channel != NULL);
2840  switch_assert(channel->caller_profile != NULL);
2841 
2842  switch_mutex_lock(channel->profile_mutex);
2843 
2844  if (channel->caller_profile) {
2845  caller_profile->next = channel->caller_profile->originatee_caller_profile;
2846  channel->caller_profile->originatee_caller_profile = caller_profile;
2847  channel->last_profile_type = LP_ORIGINATEE;
2848  }
2851 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_originator_type_t last_profile_type
#define switch_assert(expr)
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 2807 of file switch_channel.c.

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

Referenced by switch_core_session_outgoing_channel().

2808 {
2809  switch_assert(channel != NULL);
2810  switch_assert(channel->caller_profile != NULL);
2811 
2812  switch_mutex_lock(channel->profile_mutex);
2813 
2814  if (channel->caller_profile) {
2815  caller_profile->next = channel->caller_profile->origination_caller_profile;
2816  channel->caller_profile->origination_caller_profile = caller_profile;
2817  }
2820 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_caller_profile * origination_caller_profile
#define switch_assert(expr)
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 2772 of file switch_channel.c.

References LP_ORIGINATOR, switch_assert, switch_core_alloc, switch_mutex_lock(), and switch_mutex_unlock().

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

2773 {
2774  switch_assert(channel != NULL);
2775  switch_assert(channel->caller_profile != NULL);
2776  switch_mutex_lock(channel->profile_mutex);
2777 
2778  if (!caller_profile->times) {
2779  caller_profile->times = (switch_channel_timetable_t *) switch_core_alloc(caller_profile->pool, sizeof(*caller_profile->times));
2780  }
2781 
2782  if (channel->caller_profile) {
2783  caller_profile->next = channel->caller_profile->originator_caller_profile;
2784  channel->caller_profile->originator_caller_profile = caller_profile;
2785  channel->last_profile_type = LP_ORIGINATOR;
2786  }
2789 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
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
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 1387 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.

1388 {
1389  char *cols[128] = { 0 };
1390  char header_name[128] = "";
1391  int col_count = 0, i = 0;
1392  char *data_copy = NULL;
1393 
1394  if (zstr(presence_data_cols)) {
1395  presence_data_cols = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1);
1396  if (zstr(presence_data_cols)) {
1397  return;
1398  }
1399  }
1400 
1401  data_copy = strdup(presence_data_cols);
1402 
1403  col_count = switch_split(data_copy, ':', cols);
1404 
1405  for (i = 0; i < col_count; i++) {
1406  const char *val = NULL;
1407  switch_snprintf(header_name, sizeof(header_name), "PD-%s", cols[i]);
1408  val = switch_channel_get_variable(channel, cols[i]);
1409  switch_channel_set_profile_var(channel, header_name, val);
1410  }
1411 
1412  switch_safe_free(data_copy);
1413 }
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:342
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:281
#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:789
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 1055 of file switch_channel.c.

References 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(), switch_core_media_copy_t38_options(), switch_core_media_process_udptl(), switch_ivr_activate_unicast(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_block_dtmf_session(), 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(), 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().

1056 {
1057  switch_assert(channel != NULL);
1058  switch_core_hash_insert_locked(channel->private_hash, key, private_info, channel->profile_mutex);
1059  return SWITCH_STATUS_SUCCESS;
1060 }
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.
#define switch_assert(expr)
void switch_channel_set_private_flag ( switch_channel_t channel,
uint32_t  flags 
)

Definition at line 1898 of file switch_channel.c.

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

1899 {
1900  switch_assert(channel != NULL);
1901  switch_mutex_lock(channel->flag_mutex);
1902  channel->private_flags |= flags;
1903  switch_mutex_unlock(channel->flag_mutex);
1904 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
uint32_t private_flags
switch_mutex_t * flag_mutex
#define switch_assert(expr)
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 1116 of file switch_channel.c.

References profile_node_s::next, SWITCH_BLANK_STRING, switch_channel_set_device_id(), switch_core_alloc, switch_core_strdup, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, 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().

1117 {
1118  char *v;
1120 
1121  switch_mutex_lock(channel->profile_mutex);
1122 
1123 
1124  if (!strcasecmp(name, "device_id") && !zstr(val)) {
1125  const char *device_id;
1126  if (!(device_id = switch_channel_set_device_id(channel, val))) {
1127  /* one time setting */
1129  return status;
1130  }
1131 
1132  val = device_id;
1133  }
1134 
1135  if (!zstr(val)) {
1136  v = switch_core_strdup(channel->caller_profile->pool, val);
1137  } else {
1138  v = SWITCH_BLANK_STRING;
1139  }
1140 
1141  if (!strcasecmp(name, "dialplan")) {
1142  channel->caller_profile->dialplan = v;
1143  } else if (!strcasecmp(name, "username")) {
1144  channel->caller_profile->username = v;
1145  } else if (!strcasecmp(name, "caller_id_name")) {
1146  channel->caller_profile->caller_id_name = v;
1147  } else if (!strcasecmp(name, "caller_id_number")) {
1148  channel->caller_profile->caller_id_number = v;
1149  } else if (!strcasecmp(name, "callee_id_name")) {
1150  channel->caller_profile->callee_id_name = v;
1151  } else if (!strcasecmp(name, "callee_id_number")) {
1152  channel->caller_profile->callee_id_number = v;
1153  } else if (val && !strcasecmp(name, "caller_ton")) {
1154  channel->caller_profile->caller_ton = (uint8_t) atoi(v);
1155  } else if (val && !strcasecmp(name, "caller_numplan")) {
1156  channel->caller_profile->caller_numplan = (uint8_t) atoi(v);
1157  } else if (val && !strcasecmp(name, "destination_number_ton")) {
1158  channel->caller_profile->destination_number_ton = (uint8_t) atoi(v);
1159  } else if (val && !strcasecmp(name, "destination_number_numplan")) {
1160  channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v);
1161  } else if (!strcasecmp(name, "ani")) {
1162  channel->caller_profile->ani = v;
1163  } else if (!strcasecmp(name, "aniii")) {
1164  channel->caller_profile->aniii = v;
1165  } else if (!strcasecmp(name, "network_addr")) {
1166  channel->caller_profile->network_addr = v;
1167  } else if (!strcasecmp(name, "rdnis")) {
1168  channel->caller_profile->rdnis = v;
1169  } else if (!strcasecmp(name, "destination_number")) {
1170  channel->caller_profile->destination_number = v;
1171  } else if (!strcasecmp(name, "uuid")) {
1172  channel->caller_profile->uuid = v;
1173  } else if (!strcasecmp(name, "source")) {
1174  channel->caller_profile->source = v;
1175  } else if (!strcasecmp(name, "context")) {
1176  channel->caller_profile->context = v;
1177  } else if (!strcasecmp(name, "chan_name")) {
1178  channel->caller_profile->chan_name = v;
1179  } else {
1180  profile_node_t *pn, *n = switch_core_alloc(channel->caller_profile->pool, sizeof(*n));
1181  int var_found;
1182 
1183  n->var = switch_core_strdup(channel->caller_profile->pool, name);
1184  n->val = v;
1185 
1186  if (!channel->caller_profile->soft) {
1187  channel->caller_profile->soft = n;
1188  } else {
1189  var_found = 0;
1190 
1191  for(pn = channel->caller_profile->soft; pn ; pn = pn->next) {
1192  if (!strcasecmp(pn->var,n->var)) {
1193  pn->val = n->val;
1194  var_found = 1;
1195  break;
1196  }
1197 
1198  if(!pn->next) {
1199  break;
1200  }
1201  }
1202 
1203  if (pn && !pn->next && !var_found) {
1204  pn->next = n;
1205  }
1206  }
1207  }
1209 
1210  return status;
1211 }
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
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:281
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:682
const char * caller_id_name
Definition: switch_caller.h:79
#define SWITCH_BLANK_STRING
Definition: switch_types.h:47
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 * callee_id_name
Definition: switch_caller.h:87
switch_memory_pool_t * pool
void switch_channel_set_scope_variables ( switch_channel_t channel,
switch_event_t **  event 
)

Definition at line 908 of file switch_channel.c.

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

Referenced by switch_core_session_exec().

909 {
911 
912  if (event && *event) { /* push */
913  (*event)->next = channel->scope_variables;
914  channel->scope_variables = *event;
915  *event = NULL;
916  } else if (channel->scope_variables) { /* pop */
917  switch_event_t *top_event = channel->scope_variables;
918  channel->scope_variables = channel->scope_variables->next;
919  switch_event_destroy(&top_event);
920  }
921 
923 
924 }
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:290
switch_event_t * scope_variables
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
void switch_event_destroy(switch_event_t **event)
Destroy an event.
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 1976 of file switch_channel.c.

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

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

1977 {
1978  switch_assert(channel != NULL);
1979 
1980  switch_mutex_lock(channel->flag_mutex);
1981  channel->state_flags[0] = 1;
1982  channel->state_flags[flag] = 1;
1983  switch_mutex_unlock(channel->flag_mutex);
1984 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
#define switch_assert(expr)
uint8_t state_flags[CF_FLAG_MAX]
switch_status_t switch_channel_set_timestamps ( _In_ switch_channel_t channel)
switch_status_t switch_channel_set_variable_name_printf ( switch_channel_t channel,
const char *  val,
const char *  fmt,
  ... 
)

Definition at line 1511 of file switch_channel.c.

References 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().

1512 {
1513  int ret = 0;
1514  char *varname;
1515  va_list ap;
1517 
1518  switch_assert(channel != NULL);
1519 
1520  switch_mutex_lock(channel->profile_mutex);
1521 
1522  va_start(ap, fmt);
1523  ret = switch_vasprintf(&varname, fmt, ap);
1524  va_end(ap);
1525 
1526  if (ret == -1) {
1528  return SWITCH_STATUS_MEMERR;
1529  }
1530 
1531  status = switch_channel_set_variable(channel, varname, val);
1532 
1533  free(varname);
1534 
1536 
1537  return status;
1538 }
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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_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 1541 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.

1543 {
1544  const char *uuid;
1545  switch_assert(channel != NULL);
1546 
1547  if (!zstr(varname)) {
1548  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1549  switch_core_session_t *session;
1550  if ((session = switch_core_session_locate(uuid))) {
1552  switch_channel_set_variable_var_check(tchannel, varname, value, var_check);
1554  }
1555  return SWITCH_STATUS_SUCCESS;
1556  }
1557  }
1558 
1559  return SWITCH_STATUS_FALSE;
1560 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
#define zstr(x)
Definition: switch_utils.h:281
_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's uuid.
Definition: switch_core.h:916
#define switch_assert(expr)
switch_status_t switch_channel_set_variable_printf ( switch_channel_t channel,
const char *  varname,
const char *  fmt,
  ... 
)

Definition at line 1480 of file switch_channel.c.

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

Referenced by 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_parse_event(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_wait_for_silence(), switch_limit_incr(), and switch_rtp_sync_stats().

1481 {
1482  int ret = 0;
1483  char *data;
1484  va_list ap;
1486 
1487  switch_assert(channel != NULL);
1488 
1489  switch_mutex_lock(channel->profile_mutex);
1490  if (channel->variables && !zstr(varname)) {
1491  switch_event_del_header(channel->variables, varname);
1492 
1493  va_start(ap, fmt);
1494  ret = switch_vasprintf(&data, fmt, ap);
1495  va_end(ap);
1496 
1497  if (ret == -1) {
1499  return SWITCH_STATUS_MEMERR;
1500  }
1501 
1502  status = switch_channel_set_variable(channel, varname, data);
1503  free(data);
1504  }
1506 
1507  return status;
1508 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:211
#define zstr(x)
Definition: switch_utils.h:281
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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_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 1416 of file switch_channel.c.

References 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(), 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().

1418 {
1420 
1421  switch_assert(channel != NULL);
1422 
1423  switch_mutex_lock(channel->profile_mutex);
1424  if (channel->variables && !zstr(varname)) {
1425  if (zstr(value)) {
1426  switch_event_del_header(channel->variables, varname);
1427  } else {
1428  int ok = 1;
1429 
1430  if (var_check) {
1431  ok = !switch_string_var_check_const(value);
1432  }
1433  if (ok) {
1435  } else {
1436  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid data (${%s} contains a variable)\n", varname);
1437  }
1438  }
1439  status = SWITCH_STATUS_SUCCESS;
1440  }
1442 
1443  return status;
1444 }
switch_event_t * variables
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:211
#define zstr(x)
Definition: switch_utils.h:281
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:716
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)
void switch_channel_sort_cid ( switch_channel_t channel)

Definition at line 3137 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().

3138 {
3139 
3141  switch_channel_flip_cid(channel);
3145  switch_channel_flip_cid(channel);
3146  }
3147 }
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.
int switch_channel_state_change_pending ( switch_channel_t channel)

Definition at line 2105 of file switch_channel.c.

References switch_channel_down_nosig, and switch_core_session_in_thread().

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

2106 {
2108  return 0;
2109  }
2110 
2111  return channel->running_state != channel->state;
2112 }
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)
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().

void switch_channel_step_caller_profile ( switch_channel_t channel)

Definition at line 2697 of file switch_channel.c.

References switch_caller_profile_clone(), switch_channel_set_caller_profile(), switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_uuid_bridge().

2698 {
2700 
2701 
2702  switch_mutex_lock(channel->profile_mutex);
2703  cp = switch_caller_profile_clone(channel->session, channel->caller_profile);
2705 
2706  switch_channel_set_caller_profile(channel, cp);
2707 }
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's caller profile.
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_core_session_t * session
switch_channel_callstate_t switch_channel_str2callstate ( const char *  str)

Definition at line 333 of file switch_channel.c.

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

334 {
335  uint8_t x;
337 
338  if (*str > 47 && *str < 58) {
339  callstate = atoi(str);
340  } else {
341  for (x = 0; x < (sizeof(CALLSTATE_CHART) / sizeof(struct switch_callstate_table)) - 1 && CALLSTATE_CHART[x].name; x++) {
342  if (!strcasecmp(CALLSTATE_CHART[x].name, str)) {
343  callstate = CALLSTATE_CHART[x].callstate;
344  break;
345  }
346  }
347  }
348  return callstate;
349 }
switch_channel_callstate_t callstate
switch_channel_callstate_t
static struct switch_callstate_table CALLSTATE_CHART[]
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().

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

Definition at line 1960 of file switch_channel.c.

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

Referenced by switch_core_media_negotiate_sdp(), and switch_ivr_eavesdrop_update_display().

1961 {
1962  int r = 0;
1963  uint32_t *flagp = NULL;
1964  switch_assert(channel != NULL);
1965 
1966  switch_mutex_lock(channel->flag_mutex);
1967  if (channel->app_flag_hash && (flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
1968  r = (*flagp & flags);
1969  }
1970  switch_mutex_unlock(channel->flag_mutex);
1971 
1972 
1973  return r;
1974 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * flag_mutex
#define switch_assert(expr)
uint32_t switch_channel_test_cap ( switch_channel_t channel,
switch_channel_cap_t  cap 
)

Definition at line 1724 of file switch_channel.c.

References switch_assert.

Referenced by switch_channel_test_cap_partner(), switch_core_session_outgoing_channel(), and switch_core_session_send_dtmf().

1725 {
1726  switch_assert(channel != NULL);
1727  return channel->caps[cap] ? 1 : 0;
1728 }
uint32_t caps[CC_FLAG_MAX]
#define switch_assert(expr)
uint32_t switch_channel_test_cap_partner ( switch_channel_t channel,
switch_channel_cap_t  cap 
)

Definition at line 1730 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().

1731 {
1732  const char *uuid;
1733  int r = 0;
1734 
1735  switch_assert(channel != NULL);
1736 
1737  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1738  switch_core_session_t *session;
1739  if ((session = switch_core_session_locate(uuid))) {
1742  }
1743  }
1744 
1745  return r;
1746 }
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's uuid.
Definition: switch_core.h:916
#define switch_assert(expr)
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 1562 of file switch_channel.c.

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

Referenced by _switch_core_media_pass_zrtp_hash2(), 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(), cleanup_proxy_mode_a(), cleanup_proxy_mode_b(), CoreSession::destroy(), 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(), recover_callback(), sb_on_dtmf(), send_display(), setup_ringback(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), switch_channel_check_device_state(), switch_channel_check_zrtp(), 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_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_negotiate_sdp(), switch_core_media_pass_zrtp_hash(), 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_video_file(), switch_core_media_start_udptl(), switch_core_media_toggle_hold(), switch_core_media_unlock_video_file(), switch_core_media_write_frame(), 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_var_ans(), switch_core_session_outgoing_channel(), switch_core_session_parse_crypto_prefs(), switch_core_session_perform_receive_message(), switch_core_session_private_event_count(), switch_core_session_read_frame(), switch_core_session_read_lock(), switch_core_session_read_video_frame(), switch_core_session_reporting_state(), switch_core_session_request_video_refresh(), switch_core_session_run(), switch_core_session_send_and_request_video_refresh(), switch_core_session_send_dtmf(), switch_core_session_start_video_thread(), switch_core_session_wait_for_video_input_params(), switch_core_session_write_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_broadcast(), switch_ivr_collect_digits_callback(), switch_ivr_collect_digits_count(), switch_ivr_deactivate_unicast(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_originate(), switch_ivr_gentones(), switch_ivr_intercept_session(), 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(), switch_ivr_record_session(), switch_ivr_session_echo(), 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_create(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), video_helper_thread(), and video_write_overlay_callback().

1563 {
1564  uint32_t r = 0;
1565 
1566  switch_assert(channel != NULL);
1567 
1568  switch_mutex_lock(channel->flag_mutex);
1569  r = channel->flags[flag];
1570  switch_mutex_unlock(channel->flag_mutex);
1571 
1572  return r;
1573 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
uint32_t flags[CF_FLAG_MAX]
switch_mutex_t * flag_mutex
#define switch_assert(expr)
uint32_t switch_channel_test_flag_partner ( switch_channel_t channel,
switch_channel_flag_t  flag 
)

Definition at line 1593 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().

1594 {
1595  const char *uuid;
1596  int r = 0;
1597 
1598  switch_assert(channel != NULL);
1599 
1600  if ((uuid = switch_channel_get_partner_uuid(channel))) {
1601  switch_core_session_t *session;
1602  if ((session = switch_core_session_locate(uuid))) {
1605  }
1606  }
1607 
1608  return r;
1609 }
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's uuid.
Definition: switch_core.h:916
#define switch_assert(expr)
int switch_channel_test_private_flag ( switch_channel_t channel,
uint32_t  flags 
)

Definition at line 1914 of file switch_channel.c.

References switch_assert.

1915 {
1916  switch_assert(channel != NULL);
1917  return (channel->private_flags & flags);
1918 }
uint32_t private_flags
#define switch_assert(expr)
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 2120 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, 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.

2121 {
2122  int ret = 0;
2123 
2124  switch_assert(channel != NULL);
2125 
2127 
2128  if (check_media) {
2129  ret = ((switch_channel_test_flag(channel, CF_ANSWERED) ||
2132 
2133 
2134  if (!ret)
2135  return ret;
2136  }
2137 
2138  if (!check_ready)
2139  return ret;
2140 
2141  ret = 0;
2142 
2143  if (!channel->hangup_cause && channel->state > CS_ROUTING && channel->state < CS_HANGUP && channel->state != CS_RESET &&
2146  ret++;
2147  }
2148 
2149 
2150 
2151  return ret;
2152 }
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_status_t switch_channel_transfer_variable_prefix ( switch_channel_t orig_channel,
switch_channel_t new_channel,
const char *  prefix 
)

Definition at line 1366 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().

1367 {
1368  switch_event_header_t *hi = NULL;
1369  int x = 0;
1370 
1371  if ((hi = switch_channel_variable_first(orig_channel))) {
1372  for (; hi; hi = hi->next) {
1373  char *var = hi->name;
1374  char *val = hi->value;
1375 
1376  if (zstr(prefix) || !strncasecmp(var, prefix, strlen(prefix))) {
1377  x++;
1378  switch_channel_set_variable(new_channel, var, val);
1379  }
1380  }
1381  switch_channel_variable_last(orig_channel);
1382  }
1383 
1385 }
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:281
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_status_t switch_channel_try_dtmf_lock ( switch_channel_t channel)

Definition at line 469 of file switch_channel.c.

References switch_mutex_trylock().

470 {
471  return switch_mutex_trylock(channel->dtmf_mutex);
472 }
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
Definition: switch_apr.c:295
switch_mutex_t * dtmf_mutex
void switch_channel_uninit ( switch_channel_t channel)

Uninitalize a channel.

Parameters
channelthe channel to uninit

Definition at line 723 of file switch_channel.c.

References switch_channel_flush_dtmf(), switch_core_hash_destroy(), switch_event_destroy(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_trypop(), switch_safe_free, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_perform_destroy().

724 {
725  void *pop;
726  switch_channel_flush_dtmf(channel);
727  while (switch_queue_trypop(channel->dtmf_log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
728  switch_safe_free(pop);
729  }
730 
731  if (channel->private_hash) {
733  }
734 
735  if (channel->app_flag_hash) {
737  }
738 
740  switch_event_destroy(&channel->variables);
741  switch_event_destroy(&channel->api_list);
742  switch_event_destroy(&channel->var_list);
743  switch_event_destroy(&channel->app_list);
745 }
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:1140
switch_hash_t * private_hash
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_event_t * app_list
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_event_t * var_list
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 1040 of file switch_channel.c.

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

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

1041 {
1042  switch_event_header_t *hi = NULL;
1043 
1044  switch_assert(channel != NULL);
1045  switch_mutex_lock(channel->profile_mutex);
1046  if (channel->variables && (hi = channel->variables->headers)) {
1047  channel->vi = 1;
1048  } else {
1050  }
1051 
1052  return hi;
1053 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_assert(expr)
switch_event_header_t * headers
Definition: switch_event.h:90
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 1029 of file switch_channel.c.

References switch_assert, and switch_mutex_unlock().

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

1030 {
1031  switch_assert(channel != NULL);
1032  if (!channel->vi) {
1033  return;
1034  }
1035  channel->vi = 0;
1037 
1038 }
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
#define switch_assert(expr)
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 1665 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_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_parse_event(), and switch_ivr_unhold().

1668 {
1669 
1670  if (to) {
1671  to++;
1672  }
1673 
1674  for (;;) {
1675  if (pres) {
1676  if (switch_channel_test_flag(channel, want_flag)) {
1677  break;
1678  }
1679  } else {
1680  if (!switch_channel_test_flag(channel, want_flag)) {
1681  break;
1682  }
1683  }
1684 
1685  switch_cond_next();
1686 
1687  if (super_channel && !switch_channel_ready(super_channel)) {
1688  return SWITCH_STATUS_FALSE;
1689  }
1690 
1691  if (switch_channel_down(channel)) {
1692  return SWITCH_STATUS_FALSE;
1693  }
1694 
1695  if (to && !--to) {
1696  return SWITCH_STATUS_TIMEOUT;
1697  }
1698  }
1699 
1700  return SWITCH_STATUS_SUCCESS;
1701 }
#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:638
#define switch_channel_down(_channel)
void switch_channel_wait_for_state ( switch_channel_t channel,
switch_channel_t other_channel,
switch_channel_state_t  want_state 
)

Definition at line 1629 of file switch_channel.c.

References CS_HANGUP, 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().

1630 {
1631 
1632  switch_assert(channel);
1633 
1634  for (;;) {
1635  if ((channel->state < CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) ||
1636  (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down(channel)) {
1637  break;
1638  }
1639  switch_cond_next();
1640  }
1641 }
switch_channel_state_t running_state
#define switch_channel_down_nosig(_channel)
void switch_cond_next(void)
Definition: switch_time.c:638
#define switch_channel_down(_channel)
switch_channel_state_t state
#define switch_assert(expr)
void switch_channel_wait_for_state_timeout ( switch_channel_t other_channel,
switch_channel_state_t  want_state,
uint32_t  timeout 
)

Definition at line 1644 of file switch_channel.c.

References CS_HANGUP, switch_channel_check_signal(), switch_cond_next(), and SWITCH_TRUE.

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

1645 {
1646 
1647  uint32_t count = 0;
1648 
1649  for (;;) {
1650 
1651  if ((channel->state == channel->running_state && channel->running_state == want_state) || channel->state >= CS_HANGUP) {
1652  break;
1653  }
1654 
1656 
1657  switch_cond_next();
1658 
1659  if (++count >= timeout) {
1660  break;
1661  }
1662  }
1663 }
int switch_channel_check_signal(switch_channel_t *channel, switch_bool_t in_thread_only)
void switch_cond_next(void)
Definition: switch_time.c:638