FreeSWITCH API Documentation  1.7.0
Data Structures | Macros | Typedefs | Functions
switch_channel.h File Reference

Media Channel Interface. More...

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

Go to the source code of this file.

Data Structures

struct  switch_channel_timetable
 

Macros

#define switch_channel_ready(_channel)   switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE)
 
#define switch_channel_media_ready(_channel)   switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE)
 
#define switch_channel_media_up(_channel)   (switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA))
 
#define switch_channel_up(_channel)   (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) < CS_HANGUP)
 
#define switch_channel_down(_channel)   (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) >= CS_HANGUP)
 
#define switch_channel_up_nosig(_channel)   (switch_channel_get_state(_channel) < CS_HANGUP)
 
#define switch_channel_down_nosig(_channel)   (switch_channel_get_state(_channel) >= CS_HANGUP)
 
#define switch_channel_media_ack(_channel)   (!switch_channel_test_cap(_channel, CC_MEDIA_ACK) || switch_channel_test_flag(_channel, CF_MEDIA_ACK))
 
#define switch_channel_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__)
 

Typedefs

typedef struct
switch_channel_timetable 
switch_channel_timetable_t
 

Functions

switch_channel_state_t switch_channel_get_state (switch_channel_t *channel)
 Get the current state of a channel in the state engine. More...
 
switch_channel_state_t switch_channel_get_running_state (switch_channel_t *channel)
 
int switch_channel_check_signal (switch_channel_t *channel, switch_bool_t in_thread_only)
 
int switch_channel_test_ready (switch_channel_t *channel, switch_bool_t check_ready, switch_bool_t check_media)
 Determine if a channel is ready for io. More...
 
void switch_channel_wait_for_state (switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state)
 
void switch_channel_wait_for_state_timeout (switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout)
 
switch_status_t switch_channel_wait_for_flag (switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to, switch_channel_t *super_channel)
 
switch_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)
 
switch_status_t switch_channel_execute_on (switch_channel_t *channel, const char *variable_prefix)
 
switch_status_t switch_channel_api_on (switch_channel_t *channel, const char *variable_prefix)
 
void switch_channel_process_device_hangup (switch_channel_t *channel)
 
switch_caller_extension_tswitch_channel_get_queued_extension (switch_channel_t *channel)
 
void switch_channel_transfer_to_extension (switch_channel_t *channel, switch_caller_extension_t *caller_extension)
 
const char * switch_channel_get_partner_uuid (switch_channel_t *channel)
 
switch_hold_record_tswitch_channel_get_hold_record (switch_channel_t *channel)
 
void switch_channel_state_thread_lock (switch_channel_t *channel)
 
void switch_channel_state_thread_unlock (switch_channel_t *channel)
 
switch_status_t switch_channel_state_thread_trylock (switch_channel_t *channel)
 
void switch_channel_handle_cause (switch_channel_t *channel, switch_call_cause_t cause)
 
void switch_channel_global_init (switch_memory_pool_t *pool)
 
void switch_channel_global_uninit (void)
 
const char * switch_channel_set_device_id (switch_channel_t *channel, const char *device_id)
 
void switch_channel_clear_device_record (switch_channel_t *channel)
 
switch_device_record_tswitch_channel_get_device_record (switch_channel_t *channel)
 
void switch_channel_release_device_record (switch_device_record_t **dcdrp)
 
switch_status_t switch_channel_bind_device_state_handler (switch_device_state_function_t function, void *user_data)
 
switch_status_t switch_channel_unbind_device_state_handler (switch_device_state_function_t function)
 
const char * switch_channel_device_state2str (switch_device_state_t device_state)
 
switch_status_t switch_channel_pass_sdp (switch_channel_t *from_channel, switch_channel_t *to_channel, const char *sdp)
 

Detailed Description

Media Channel Interface.

See also
switch_channel

Definition in file switch_channel.h.

Typedef Documentation

Definition at line 58 of file switch_channel.h.

Function Documentation

switch_status_t switch_channel_api_on ( switch_channel_t channel,
const char *  variable_prefix 
)

Definition at line 3575 of file switch_channel.c.

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

Referenced by audio_bridge_thread(), check_channel_status(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_core_media_process_udptl(), switch_ivr_originate(), and tone_on_dtmf().

3576 {
3578  switch_event_t *event;
3579  int x = 0;
3580 
3581 
3582  switch_channel_get_variables(channel, &event);
3583 
3584  for (hp = event->headers; hp; hp = hp->next) {
3585  char *var = hp->name;
3586  char *val = hp->value;
3587 
3588  if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3589  if (hp->idx) {
3590  int i;
3591  for (i = 0; i < hp->idx; i++) {
3592  x++;
3593  do_api_on(channel, hp->array[i]);
3594  }
3595  } else {
3596  x++;
3597  do_api_on(channel, val);
3598  }
3599  }
3600  }
3601 
3602  switch_event_destroy(&event);
3603 
3605 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
static void do_api_on(switch_channel_t *channel, const char *variable)
switch_status_t switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
struct switch_event_header * next
Definition: switch_event.h:76
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_event_header_t * headers
Definition: switch_event.h:90
switch_status_t switch_channel_bind_device_state_handler ( switch_device_state_function_t  function,
void *  user_data 
)

Definition at line 5294 of file switch_channel.c.

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

5295 {
5296  switch_device_state_binding_t *binding = NULL, *ptr = NULL;
5297  assert(function != NULL);
5298 
5299  if (!(binding = (switch_device_state_binding_t *) switch_core_alloc(globals.pool, sizeof(*binding)))) {
5300  return SWITCH_STATUS_MEMERR;
5301  }
5302 
5303  binding->function = function;
5304  binding->user_data = user_data;
5305 
5306  switch_mutex_lock(globals.device_mutex);
5307  for (ptr = globals.device_bindings; ptr && ptr->next; ptr = ptr->next);
5308 
5309  if (ptr) {
5310  ptr->next = binding;
5311  } else {
5312  globals.device_bindings = binding;
5313  }
5314 
5315  switch_mutex_unlock(globals.device_mutex);
5316 
5317  return SWITCH_STATUS_SUCCESS;
5318 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
static struct @0 globals
switch_device_state_function_t function
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
void switch_channel_clear_device_record ( switch_channel_t channel)

Definition at line 4910 of file switch_channel.c.

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

Referenced by switch_core_session_destroy_state().

4911 {
4913  int sanity = 100;
4915  switch_event_t *event;
4916 
4917  if (!channel->device_node || !switch_channel_test_flag(channel, CF_FINAL_DEVICE_LEG)) {
4918  return;
4919  }
4920 
4921  while(--sanity && channel->device_node->parent->refs) {
4922  switch_yield(100000);
4923  }
4924 
4925  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Destroying device cdr %s on device [%s]\n",
4926  channel->device_node->parent->uuid,
4927  channel->device_node->parent->device_id);
4928 
4930  int x = 0;
4931  char prefix[80] = "";
4932 
4933  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Type", "device");
4935 
4937  for(np = channel->device_node->parent->uuid_list; np; np = np->next) {
4938  switch_snprintf(prefix, sizeof(prefix), "Call-%d", ++x);
4940  }
4942 
4943  switch_event_fire(&event);
4944  }
4945 
4947  for(np = channel->device_node->parent->uuid_list; np; np = np->next) {
4948  if (np->xml_cdr) {
4949  switch_xml_free(np->xml_cdr);
4950  }
4951  if (np->event) {
4953  }
4954  }
4956 
4957  pool = channel->device_node->parent->pool;
4958 
4959  switch_mutex_lock(globals.device_mutex);
4961 
4962  switch_mutex_unlock(globals.device_mutex);
4963 
4964 
4965 }
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:412
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
switch_xml_t xml_cdr
Definition: switch_core.h:81
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:640
switch_memory_pool_t * pool
Representation of an event.
Definition: switch_event.h:80
switch_caller_profile_t * hup_profile
Definition: switch_core.h:85
switch_mutex_t * mutex
Definition: switch_core.h:138
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_event_t * event
Definition: switch_core.h:82
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
void switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile, _In_opt_z_ const char *prefix, _In_ switch_event_t *event)
Add headers to an existing event in regards to a specific profile.
static struct @0 globals
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
Definition: switch_utils.h:908
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.
struct device_uuid_node_s * next
Definition: switch_core.h:88
switch_memory_pool_t * pool
Definition: switch_core.h:139
struct switch_device_record_s * parent
Definition: switch_core.h:87
#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 device_uuid_node_s * uuid_list
Definition: switch_core.h:136
struct apr_pool_t switch_memory_pool_t
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_device_node_t * device_node
void switch_event_destroy(switch_event_t **event)
Destroy an event.
#define SWITCH_CHANNEL_CHANNEL_LOG(x)
const char* switch_channel_device_state2str ( switch_device_state_t  device_state)

Definition at line 317 of file switch_channel.c.

References DEVICE_STATE_CHART, and switch_device_state_table::name.

Referenced by switch_channel_check_device_state().

318 {
319  uint8_t x;
320  const char *str = "UNKNOWN";
321 
322  for (x = 0; x < (sizeof(DEVICE_STATE_CHART) / sizeof(struct switch_cause_table)) - 1; x++) {
323  if (DEVICE_STATE_CHART[x].device_state == device_state) {
324  str = DEVICE_STATE_CHART[x].name;
325  break;
326  }
327  }
328 
329  return str;
330 }
static struct switch_device_state_table DEVICE_STATE_CHART[]
switch_status_t switch_channel_execute_on ( switch_channel_t channel,
const char *  variable_prefix 
)

Definition at line 3638 of file switch_channel.c.

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

Referenced by audio_bridge_thread(), check_channel_status(), record_callback(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_core_media_process_udptl(), switch_core_media_read_frame(), switch_ivr_originate(), switch_ivr_session_transfer(), tone_detect_callback(), and tone_on_dtmf().

3639 {
3641  switch_event_t *event, *cevent;
3642  int x = 0;
3643 
3644  switch_core_get_variables(&event);
3645  switch_channel_get_variables(channel, &cevent);
3646  switch_event_merge(event, cevent);
3647 
3648  for (hp = event->headers; hp; hp = hp->next) {
3649  char *var = hp->name;
3650  char *val = hp->value;
3651 
3652  if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3653  if (hp->idx) {
3654  int i;
3655  for (i = 0; i < hp->idx; i++) {
3656  x++;
3657  do_execute_on(channel, hp->array[i]);
3658  }
3659  } else {
3660  x++;
3661  do_execute_on(channel, val);
3662  }
3663  }
3664  }
3665 
3666  switch_event_destroy(&event);
3667  switch_event_destroy(&cevent);
3668 
3670 }
Representation of an event.
Definition: switch_event.h:80
An event Header.
Definition: switch_event.h:65
static void do_execute_on(switch_channel_t *channel, const char *variable)
switch_status_t switch_core_get_variables(switch_event_t **event)
Definition: switch_core.c:374
void switch_event_merge(switch_event_t *event, switch_event_t *tomerge)
switch_status_t switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
struct switch_event_header * next
Definition: switch_event.h:76
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_event_header_t * headers
Definition: switch_event.h:90
switch_device_record_t* switch_channel_get_device_record ( switch_channel_t channel)

Definition at line 5276 of file switch_channel.c.

References switch_mutex_lock().

5277 {
5278  if (channel->device_node) {
5280  return channel->device_node->parent;
5281  }
5282 
5283  return NULL;
5284 }
switch_mutex_t * mutex
Definition: switch_core.h:138
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
struct switch_device_record_s * parent
Definition: switch_core.h:87
switch_device_node_t * device_node
switch_hold_record_t* switch_channel_get_hold_record ( switch_channel_t channel)

Definition at line 184 of file switch_channel.c.

Referenced by switch_ivr_generate_xml_cdr().

185 {
186  return channel->hold_record;
187 }
switch_hold_record_t * hold_record
const char* switch_channel_get_partner_uuid ( switch_channel_t channel)

Definition at line 4659 of file switch_channel.c.

References switch_channel_get_variable, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE, and SWITCH_SIGNAL_BOND_VARIABLE.

Referenced by recover_callback(), rtp_common_read(), switch_channel_clear_flag_partner(), switch_channel_flip_cid(), switch_channel_get_private_partner(), switch_channel_get_variable_partner(), switch_channel_set_flag_partner(), switch_channel_set_flag_value(), switch_channel_set_variable_partner_var_check(), switch_channel_test_cap_partner(), switch_channel_test_flag_partner(), switch_core_media_gen_local_sdp(), switch_core_media_receive_message(), switch_core_session_pass_indication(), switch_core_session_perform_get_partner(), switch_core_session_read_frame(), switch_core_session_write_frame(), switch_core_standard_on_reset(), switch_ivr_broadcast(), switch_ivr_find_bridged_uuid(), switch_ivr_hold(), switch_ivr_intercept_session(), switch_ivr_parse_event(), switch_ivr_soft_hold(), switch_ivr_unhold(), switch_rtp_write_frame(), and switch_rtp_zerocopy_read_frame().

4660 {
4661  const char *uuid = NULL;
4662 
4663  if (!(uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
4665  }
4666 
4667  return uuid;
4668 }
#define SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE
Definition: switch_types.h:203
#define switch_channel_get_variable(_c, _v)
#define SWITCH_SIGNAL_BOND_VARIABLE
Definition: switch_types.h:202
switch_caller_extension_t* switch_channel_get_queued_extension ( switch_channel_t channel)

Definition at line 3149 of file switch_channel.c.

References switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_standard_on_routing().

3150 {
3151  switch_caller_extension_t *caller_extension;
3152 
3153  switch_mutex_lock(channel->profile_mutex);
3154  caller_extension = channel->queued_extension;
3155  channel->queued_extension = NULL;
3157 
3158  return caller_extension;
3159 }
An Abstract Representation of a dialplan extension.
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_caller_extension_t * queued_extension
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
void switch_channel_global_init ( switch_memory_pool_t pool)

Definition at line 4811 of file switch_channel.c.

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

Referenced by switch_core_init().

4812 {
4813  memset(&globals, 0, sizeof(globals));
4814  globals.pool = pool;
4815 
4817  switch_core_hash_init(&globals.device_hash);
4818 }
#define switch_core_hash_init(_hash)
Definition: switch_core.h:1390
switch_memory_pool_t * pool
#define SWITCH_MUTEX_NESTED
Definition: switch_apr.h:318
static struct @0 globals
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
Definition: switch_apr.c:270
memset(buf, 0, buflen)
void switch_channel_global_uninit ( void  )

Definition at line 4820 of file switch_channel.c.

References globals, and switch_core_hash_destroy().

Referenced by switch_core_destroy().

4821 {
4822  switch_core_hash_destroy(&globals.device_hash);
4823 }
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
static struct @0 globals
void switch_channel_handle_cause ( switch_channel_t channel,
switch_call_cause_t  cause 
)

Definition at line 4670 of file switch_channel.c.

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

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

4671 {
4672  switch_core_session_t *session = channel->session;
4673  const char *transfer_on_fail = NULL;
4674  char *tof_data = NULL;
4675  char *tof_array[4] = { 0 };
4676  //int tof_arrayc = 0;
4677 
4678  if (!switch_channel_up_nosig(channel)) {
4679  return;
4680  }
4681 
4682  transfer_on_fail = switch_channel_get_variable(channel, "transfer_on_fail");
4683  tof_data = switch_core_session_strdup(session, transfer_on_fail);
4684  switch_split(tof_data, ' ', tof_array);
4685  transfer_on_fail = tof_array[0];
4686 
4687  /*
4688  if the variable continue_on_fail is set it can be:
4689  'true' to continue on all failures.
4690  'false' to not continue.
4691  A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
4692  failure_causes acts as the opposite version
4693  EXCEPTION... ATTENDED_TRANSFER never is a reason to continue.......
4694  */
4695  if (cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
4696  const char *continue_on_fail = NULL, *failure_causes = NULL;
4697 
4698  continue_on_fail = switch_channel_get_variable(channel, "continue_on_fail");
4699  failure_causes = switch_channel_get_variable(channel, "failure_causes");
4700 
4701  if (continue_on_fail || failure_causes) {
4702  const char *cause_str;
4703  char cause_num[35] = "";
4704 
4705  cause_str = switch_channel_cause2str(cause);
4706  switch_snprintf(cause_num, sizeof(cause_num), "%u", cause);
4707 
4708  if (failure_causes) {
4709  char *lbuf = switch_core_session_strdup(session, failure_causes);
4710  char *argv[256] = { 0 };
4711  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4712  int i, x = 0;
4713 
4714  for (i = 0; i < argc; i++) {
4715  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4716  x++;
4717  break;
4718  }
4719  }
4720  if (!x) {
4722  "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4723  return;
4724  }
4725  }
4726 
4727  if (continue_on_fail) {
4728  if (switch_true(continue_on_fail)) {
4729  return;
4730  } else {
4731  char *lbuf = switch_core_session_strdup(session, continue_on_fail);
4732  char *argv[256] = { 0 };
4733  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4734  int i;
4735 
4736  for (i = 0; i < argc; i++) {
4737  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4739  "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
4740  return;
4741  }
4742  }
4743  }
4744  }
4745  } else {
4746  /* no answer is *always* a reason to continue */
4748  return;
4749  }
4750  }
4751 
4752  if (transfer_on_fail || failure_causes) {
4753  const char *cause_str;
4754  char cause_num[35] = "";
4755 
4756  cause_str = switch_channel_cause2str(cause);
4757  switch_snprintf(cause_num, sizeof(cause_num), "%u", cause);
4758 
4759  if ((tof_array[1] == NULL ) || (!strcasecmp(tof_array[1], "auto_cause"))){
4760  tof_array[1] = (char *) cause_str;
4761  }
4762 
4763  if (failure_causes) {
4764  char *lbuf = switch_core_session_strdup(session, failure_causes);
4765  char *argv[256] = { 0 };
4766  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4767  int i, x = 0;
4768 
4769  for (i = 0; i < argc; i++) {
4770  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4771  x++;
4772  break;
4773  }
4774  }
4775  if (!x) {
4777  "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4778 
4779  switch_ivr_session_transfer(session, tof_array[1], tof_array[2], tof_array[3]);
4780  }
4781  }
4782 
4783  if (transfer_on_fail) {
4784  if (switch_true(transfer_on_fail)) {
4785  return;
4786  } else {
4787  char *lbuf = switch_core_session_strdup(session, transfer_on_fail);
4788  char *argv[256] = { 0 };
4789  int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
4790  int i;
4791 
4792  for (i = 0; i < argc; i++) {
4793  if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4795  "Transfer on fail [%s]: Cause: %s\n", transfer_on_fail, cause_str);
4796  switch_ivr_session_transfer(session, tof_array[1], tof_array[2], tof_array[3]);
4797  }
4798  }
4799  }
4800  }
4801  }
4802  }
4803 
4804 
4806  switch_channel_get_state(channel) != CS_ROUTING) {
4807  switch_channel_hangup(channel, cause);
4808  }
4809 }
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_split(_data, _delim, _array)
Definition: switch_utils.h:342
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
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.
switch_status_t switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
Transfer an existing session to another location.
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
#define switch_channel_get_variable(_c, _v)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
#define switch_channel_up_nosig(_channel)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
switch_core_session_t * session
const char * switch_channel_cause2str(switch_call_cause_t cause)
switch_status_t switch_channel_pass_sdp ( switch_channel_t from_channel,
switch_channel_t to_channel,
const char *  sdp 
)

Definition at line 5345 of file switch_channel.c.

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

Referenced by switch_core_session_outgoing_channel().

5346 {
5348  char *use_sdp = (char *) sdp;
5349  char *patched_sdp = NULL;
5350 
5352  const char *var;
5353 
5354  if ((var = switch_channel_get_variable(from_channel, "bypass_media_sdp_filter"))) {
5355  if ((patched_sdp = switch_core_media_process_sdp_filter(use_sdp, var, from_channel->session))) {
5356  use_sdp = patched_sdp;
5357  }
5358  }
5359 
5360  switch_channel_set_variable(to_channel, SWITCH_B_SDP_VARIABLE, use_sdp);
5361  }
5362 
5363  switch_safe_free(patched_sdp);
5364 
5365  return status;
5366 }
char * switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session)
#define switch_channel_get_variable(_c, _v)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
switch_status_t
Common return values.
#define SWITCH_B_SDP_VARIABLE
Definition: switch_types.h:198
#define switch_channel_set_variable(_channel, _var, _val)
switch_core_session_t * session
void switch_channel_process_device_hangup ( switch_channel_t channel)

Definition at line 4967 of file switch_channel.c.

References process_device_hup(), and switch_channel_check_device_state().

Referenced by switch_core_session_hangup_state().

4968 {
4969 
4970  switch_channel_check_device_state(channel, channel->callstate);
4971  process_device_hup(channel);
4972 
4973 }
static void process_device_hup(switch_channel_t *channel)
static void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
switch_channel_callstate_t callstate
void switch_channel_release_device_record ( switch_device_record_t **  dcdrp)

Definition at line 5286 of file switch_channel.c.

References switch_mutex_unlock().

5287 {
5288  if (drecp && *drecp) {
5289  switch_mutex_unlock((*drecp)->mutex);
5290  *drecp = NULL;
5291  }
5292 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
const char* switch_channel_set_device_id ( switch_channel_t channel,
const char *  device_id 
)

Definition at line 5248 of file switch_channel.c.

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

Referenced by switch_channel_set_profile_var().

5249 {
5250  switch_device_record_t *drec;
5251 
5252  if (channel->device_node) {
5253  return NULL;
5254  }
5255 
5256  channel->device_id = switch_core_session_strdup(channel->session, device_id);
5257 
5258  switch_mutex_lock(globals.device_mutex);
5259 
5260  if (!(drec = switch_core_hash_find(globals.device_hash, channel->device_id))) {
5261  create_device_record(&drec, channel->device_id);
5262  switch_core_hash_insert(globals.device_hash, drec->device_id, drec);
5263  }
5264 
5265  add_uuid(drec, channel);
5266 
5267  switch_mutex_unlock(globals.device_mutex);
5268 
5269  switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Setting DEVICE ID to [%s]\n", device_id);
5270 
5271  switch_channel_check_device_state(channel, channel->callstate);
5272 
5273  return device_id;
5274 }
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
static struct @0 globals
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
static void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
static void add_uuid(switch_device_record_t *drec, switch_channel_t *channel)
static switch_status_t create_device_record(switch_device_record_t **drecp, const char *device_id)
#define switch_core_hash_insert(_h, _k, _d)
Definition: switch_core.h:1410
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_device_node_t * device_node
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
switch_channel_callstate_t callstate
switch_core_session_t * session
#define SWITCH_CHANNEL_CHANNEL_LOG(x)
void switch_channel_state_thread_lock ( switch_channel_t channel)

Definition at line 2490 of file switch_channel.c.

References switch_mutex_lock().

Referenced by switch_core_session_run().

2491 {
2492  switch_mutex_lock(channel->thread_mutex);
2493 }
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * thread_mutex
switch_status_t switch_channel_state_thread_trylock ( switch_channel_t channel)

Definition at line 2496 of file switch_channel.c.

References switch_mutex_trylock().

Referenced by switch_core_session_wake_session_thread().

2497 {
2498  return switch_mutex_trylock(channel->thread_mutex);
2499 }
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
Definition: switch_apr.c:295
switch_mutex_t * thread_mutex
void switch_channel_state_thread_unlock ( switch_channel_t channel)

Definition at line 2502 of file switch_channel.c.

References switch_mutex_unlock().

Referenced by switch_core_session_run(), and switch_core_session_wake_session_thread().

2503 {
2505 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_mutex_t * thread_mutex
void switch_channel_transfer_to_extension ( switch_channel_t channel,
switch_caller_extension_t caller_extension 
)

Definition at line 3161 of file switch_channel.c.

References CF_TRANSFER, CS_ROUTING, switch_channel_set_flag, switch_channel_set_state, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_ivr_parse_event().

3162 {
3163  switch_mutex_lock(channel->profile_mutex);
3164  channel->queued_extension = caller_extension;
3166 
3169 }
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_mutex_t * profile_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_caller_extension_t * queued_extension
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_channel_set_flag(_c, _f)
switch_status_t switch_channel_unbind_device_state_handler ( switch_device_state_function_t  function)

Definition at line 5320 of file switch_channel.c.

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

5321 {
5322  switch_device_state_binding_t *ptr, *last = NULL;
5324 
5325  switch_mutex_lock(globals.device_mutex);
5326  for (ptr = globals.device_bindings; ptr; ptr = ptr->next) {
5327  if (ptr->function == function) {
5328  status = SWITCH_STATUS_SUCCESS;
5329 
5330  if (last) {
5331  last->next = ptr->next;
5332  } else {
5333  globals.device_bindings = ptr->next;
5334  last = NULL;
5335  continue;
5336  }
5337  }
5338  last = ptr;
5339  }
5340  switch_mutex_unlock(globals.device_mutex);
5341 
5342  return status;
5343 }
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
static struct @0 globals
switch_device_state_function_t function
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_status_t
Common return values.
struct switch_device_state_binding_s * next