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";