RTS API Documentation  1.10.11
Macros | Enumerations | Functions
Session Creation / Management
+ Collaboration diagram for Session Creation / Management:

Macros

#define switch_core_session_request(_ep, _d, _f, _p)   switch_core_session_request_uuid(_ep, _d, _f, _p, NULL)
 
#define switch_core_session_destroy(session)   switch_core_session_perform_destroy(session, __FILE__, __SWITCH_FUNC__, __LINE__)
 Destroy a session and return the memory pool to the core. More...
 
#define switch_core_session_locate(uuid_str)   switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
 Locate a session based on it's uuid. More...
 
#define switch_core_session_force_locate(uuid_str)   switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
 Locate a session based on it's uuid even if the channel is not ready. More...
 
#define switch_core_session_hupall_matching_var(_vn, _vv, _c)   switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED)
 
#define switch_core_session_hupall_matching_vars(_vs, _c)   switch_core_session_hupall_matching_vars_ans(_vs, _c, SHT_UNANSWERED | SHT_ANSWERED)
 
#define switch_core_session_get_partner(_session, _partner)   switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)
 
#define switch_core_session_execute_application(_a, _b, _c)   switch_core_session_execute_application_get_flags(_a, _b, _c, NULL)
 Execute an application on a session. More...
 
#define switch_core_session_get_private(_s)   switch_core_session_get_private_class(_s, SWITCH_PVT_PRIMARY)
 
#define switch_core_session_set_private(_s, _p)   switch_core_session_set_private_class(_s, _p, SWITCH_PVT_PRIMARY)
 
#define switch_core_service_session(_s)   switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE)
 
#define switch_core_session_receive_message(_session, _message)
 
#define switch_core_session_kill_channel(session, sig)   switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)
 Send a signal to a channel. More...
 

Enumerations

enum  switch_hup_type_t { SHT_NONE = 0, SHT_UNANSWERED = (1 << 0), SHT_ANSWERED = (1 << 1) }
 

Functions

switch_core_session_tswitch_core_session_request_uuid (_In_ switch_endpoint_interface_t *endpoint_interface, _In_ switch_call_direction_t direction, switch_originate_flag_t originate_flags, _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid)
 Allocate and return a new session from the core. More...
 
switch_status_t switch_core_session_set_uuid (_In_ switch_core_session_t *session, _In_z_ const char *use_uuid)
 
switch_status_t switch_core_session_set_external_id (_In_ switch_core_session_t *session, _In_z_ const char *use_external_id)
 
void switch_core_session_perform_destroy (_Inout_ switch_core_session_t **session, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
 
void switch_core_session_destroy_state (switch_core_session_t *session)
 
void switch_core_session_reporting_state (switch_core_session_t *session)
 
void switch_core_session_hangup_state (switch_core_session_t *session, switch_bool_t force)
 
uint32_t switch_core_session_count (void)
 Provide the total number of sessions. More...
 
switch_size_t switch_core_session_get_id (_In_ switch_core_session_t *session)
 
switch_size_t switch_core_session_id (void)
 Provide the current session_id. More...
 
switch_size_t switch_core_session_id_dec (void)
 
switch_core_session_tswitch_core_session_request_by_name (_In_z_ const char *endpoint_name, _In_ switch_call_direction_t direction, _Inout_ switch_memory_pool_t **pool)
 Allocate and return a new session from the core based on a given endpoint module name. More...
 
switch_status_t switch_core_session_thread_launch (_In_ switch_core_session_t *session)
 Launch the session thread (state machine) on a given session. More...
 
switch_status_t switch_thread_pool_launch_thread (switch_thread_data_t **tdp)
 
switch_status_t switch_core_session_thread_pool_launch (switch_core_session_t *session)
 
switch_status_t switch_thread_pool_wait (switch_thread_data_t *td, int ms)
 
_Ret_ switch_channel_tswitch_core_session_get_channel (_In_ switch_core_session_t *session)
 Retrieve a pointer to the channel object associated with a given session. More...
 
switch_mutex_tswitch_core_session_get_mutex (switch_core_session_t *session)
 Signal a session's state machine thread that a state change has occured. More...
 
switch_status_t switch_core_session_wake_session_thread (_In_ switch_core_session_t *session)
 
void switch_core_session_signal_state_change (_In_ switch_core_session_t *session)
 
char * switch_core_session_get_uuid (_In_ switch_core_session_t *session)
 Retrieve the unique identifier from a session. More...
 
const char * switch_core_session_get_external_id (_In_ switch_core_session_t *session)
 Retrieve the unique external identifier from a session. More...
 
switch_status_t switch_core_session_set_loglevel (switch_core_session_t *session, switch_log_level_t loglevel)
 Sets the log level for a session. More...
 
switch_log_level_t switch_core_session_get_loglevel (switch_core_session_t *session)
 Get the log level for a session. More...
 
switch_jb_tswitch_core_session_get_jb (switch_core_session_t *session, switch_media_type_t type)
 
void switch_core_session_soft_lock (switch_core_session_t *session, uint32_t sec)
 
void switch_core_session_soft_unlock (switch_core_session_t *session)
 
void switch_core_session_set_dmachine (switch_core_session_t *session, switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target)
 
switch_ivr_dmachine_tswitch_core_session_get_dmachine (switch_core_session_t *session, switch_digit_action_target_t target)
 
switch_digit_action_target_t switch_ivr_dmachine_get_target (switch_ivr_dmachine_t *dmachine)
 
void switch_ivr_dmachine_set_target (switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target)
 
switch_status_t switch_ivr_dmachine_set_terminators (switch_ivr_dmachine_t *dmachine, const char *terminators)
 
switch_status_t switch_core_session_set_codec_slin (switch_core_session_t *session, switch_slin_data_t *data)
 
void switch_core_session_raw_read (switch_core_session_t *session)
 
char * switch_core_get_uuid (void)
 Retrieve the unique identifier from the core. More...
 
switch_core_session_tswitch_core_session_perform_locate (const char *uuid_str, const char *file, const char *func, int line)
 
switch_core_session_tswitch_core_session_perform_force_locate (const char *uuid_str, const char *file, const char *func, int line)
 
char * switch_core_get_variable (_In_z_ const char *varname)
 Retrieve a global variable from the core. More...
 
char * switch_core_get_variable_dup (_In_z_ const char *varname)
 
char * switch_core_get_variable_pdup (_In_z_ const char *varname, switch_memory_pool_t *pool)
 
const char * switch_core_get_hostname (void)
 
const char * switch_core_get_switchname (void)
 
char * switch_core_get_domain (switch_bool_t dup)
 
void switch_core_set_variable (_In_z_ const char *varname, _In_opt_z_ const char *value)
 Add a global variable to the core. More...
 
switch_status_t switch_core_get_variables (switch_event_t **event)
 
switch_bool_t switch_core_set_var_conditional (_In_z_ const char *varname, _In_opt_z_ const char *value, _In_opt_z_ const char *val2)
 Conditionally add a global variable to the core. More...
 
void switch_core_dump_variables (_In_ switch_stream_handle_t *stream)
 
void switch_core_session_hupall (_In_ switch_call_cause_t cause)
 Hangup all sessions. More...
 
uint32_t switch_core_session_hupall_matching_var_ans (_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause, switch_hup_type_t type)
 Hangup all sessions which match a specific channel variable. More...
 
switch_console_callback_match_tswitch_core_session_findall_matching_var (const char *var_name, const char *var_val)
 
switch_console_callback_match_tswitch_core_session_findall (void)
 
uint32_t switch_core_session_hupall_matching_vars_ans (_In_ switch_event_t *vars, _In_ switch_call_cause_t cause, switch_hup_type_t type)
 Hangup all sessions which match specific channel variable(s) More...
 
void switch_core_session_hupall_endpoint (const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause)
 Hangup all sessions that belong to an endpoint. More...
 
switch_status_t switch_core_session_perform_get_partner (switch_core_session_t *session, switch_core_session_t **partner, const char *file, const char *func, int line)
 Get the session's partner (the session its bridged to) More...
 
switch_status_t switch_core_session_message_send (_In_z_ const char *uuid_str, _In_ switch_core_session_message_t *message)
 Send a message to another session using it's uuid. More...
 
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. More...
 
void switch_core_session_free_message (switch_core_session_message_t **message)
 
switch_status_t switch_core_session_queue_signal_data (switch_core_session_t *session, void *signal_data)
 
switch_status_t switch_core_session_dequeue_signal_data (switch_core_session_t *session, void **signal_data)
 
switch_status_t switch_core_session_pass_indication (_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication)
 pass an indication message on a session More...
 
switch_status_t switch_core_session_queue_indication (_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication)
 Queue an indication message on a session. More...
 
switch_status_t switch_core_session_dequeue_message (_In_ switch_core_session_t *session, _Out_ switch_core_session_message_t **message)
 DE-Queue an message on a given session. More...
 
switch_status_t switch_core_session_flush_message (_In_ switch_core_session_t *session)
 Flush a message queue on a given session. More...
 
switch_status_t switch_core_session_event_send (_In_z_ const char *uuid_str, _Inout_ switch_event_t **event)
 Queue an event on another session using its uuid. More...
 
switch_app_log_tswitch_core_session_get_app_log (_In_ switch_core_session_t *session)
 
switch_status_t switch_core_session_exec (_In_ switch_core_session_t *session, _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg)
 Execute an application on a session. More...
 
void switch_core_session_video_reset (switch_core_session_t *session)
 
switch_status_t switch_core_session_execute_application_get_flags (_In_ switch_core_session_t *session, _In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags)
 Execute an application on a session. More...
 
switch_status_t switch_core_session_execute_application_async (switch_core_session_t *session, const char *app, const char *arg)
 
switch_status_t switch_core_session_get_app_flags (const char *app, int32_t *flags)
 
uint32_t switch_core_session_stack_count (switch_core_session_t *session, int x)
 
switch_status_t switch_core_session_execute_exten (_In_ switch_core_session_t *session, _In_z_ const char *exten, _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context)
 Run a dialplan and execute an extension. More...
 
switch_status_t switch_core_session_receive_event (_In_ switch_core_session_t *session, _Inout_ switch_event_t **event)
 Send an event to a session translating it to it's native message format. More...
 
void * switch_core_session_get_private_class (_In_ switch_core_session_t *session, _In_ switch_pvt_class_t index)
 Retrieve private user data from a session. More...
 
switch_status_t switch_core_session_set_private_class (_In_ switch_core_session_t *session, _In_ void *private_info, _In_ switch_pvt_class_t index)
 Add private user data to a session. More...
 
int switch_core_session_add_stream (_In_ switch_core_session_t *session, _In_opt_ void *private_info)
 Add a logical stream to a session. More...
 
void * switch_core_session_get_stream (_In_ switch_core_session_t *session, _In_ int index)
 Retreive a logical stream from a session. More...
 
int switch_core_session_get_stream_count (_In_ switch_core_session_t *session)
 Determine the number of logical streams a session has. More...
 
const char * switch_core_session_get_text_buffer (switch_core_session_t *session)
 
void switch_core_session_launch_thread (_In_ switch_core_session_t *session, _In_ void *(*func)(switch_thread_t *, void *), _In_opt_ void *obj)
 Launch a thread designed to exist within the scope of a given session. More...
 
void switch_core_thread_session_end (_In_ switch_core_session_t *session)
 Signal a thread using a thread session to terminate. More...
 
void switch_core_service_session_av (_In_ switch_core_session_t *session, switch_bool_t audio, switch_bool_t video)
 Launch a service thread on a session to drop inbound data. More...
 
switch_call_cause_t switch_core_session_outgoing_channel (_In_opt_ switch_core_session_t *session, _In_opt_ switch_event_t *var_event, _In_z_ const char *endpoint_name, _In_ switch_caller_profile_t *caller_profile, _Inout_ switch_core_session_t **new_session, _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 Request an outgoing session spawned from an existing session using a desired endpoing module. More...
 
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. More...
 
switch_status_t switch_core_session_queue_event (_In_ switch_core_session_t *session, _Inout_ switch_event_t **event)
 Queue an event on a given session. More...
 
uint32_t switch_core_session_event_count (_In_ switch_core_session_t *session)
 Indicate the number of waiting events on a session. More...
 
uint32_t switch_core_session_messages_waiting (switch_core_session_t *session)
 
switch_status_t switch_core_session_dequeue_event (_In_ switch_core_session_t *session, _Out_ switch_event_t **event, switch_bool_t force)
 DE-Queue an event on a given session. More...
 
switch_status_t switch_core_session_queue_private_event (_In_ switch_core_session_t *session, _Inout_ switch_event_t **event, switch_bool_t priority)
 Queue a private event on a given session. More...
 
uint32_t switch_core_session_private_event_count (_In_ switch_core_session_t *session)
 Indicate the number of waiting private events on a session. More...
 
switch_status_t switch_core_session_dequeue_private_event (_In_ switch_core_session_t *session, _Out_ switch_event_t **event)
 DE-Queue a private event on a given session. More...
 
uint32_t switch_core_session_flush_private_events (switch_core_session_t *session)
 Flush the private event queue of a session. More...
 
switch_status_t switch_core_session_read_frame (_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
 Read a frame from a session. More...
 
switch_bool_t switch_core_session_transcoding (switch_core_session_t *session_a, switch_core_session_t *session_b, switch_media_type_t type)
 
void switch_core_session_passthru (switch_core_session_t *session, switch_media_type_t type, switch_bool_t on)
 
switch_status_t switch_core_session_read_video_frame (_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
 Read a video frame from a session. More...
 
switch_status_t switch_core_session_write_video_frame (_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
 Write a video frame to a session. More...
 
switch_status_t switch_core_session_write_encoded_video_frame (switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
 
switch_status_t switch_core_session_set_read_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp)
 
switch_status_t switch_core_session_set_write_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp)
 
switch_status_t switch_core_session_set_video_read_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp)
 
switch_status_t switch_core_session_set_video_write_impl (switch_core_session_t *session, const switch_codec_implementation_t *impp)
 
void switch_core_session_reset (_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
 Reset the buffers and resampler on a session. More...
 
switch_status_t switch_core_session_try_reset (switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
 Reset the buffers and resampler on a session, fail if can not lock codec mutexes. More...
 
switch_status_t switch_core_session_write_frame (_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
 Write a frame to a session. More...
 
switch_status_t switch_core_session_perform_kill_channel (_In_ switch_core_session_t *session, const char *file, const char *func, int line, switch_signal_t sig)
 
switch_status_t switch_core_session_send_dtmf (_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf)
 Send DTMF to a session. More...
 
switch_status_t switch_core_session_send_dtmf_string (switch_core_session_t *session, const char *dtmf_string)
 Send DTMF to a session. More...
 
switch_status_t switch_core_session_recv_dtmf (_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf)
 RECV DTMF on a session. More...
 

Detailed Description

Macro Definition Documentation

◆ switch_core_service_session

#define switch_core_service_session (   _s)    switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE)

Definition at line 1216 of file switch_core.h.

Referenced by switch_ivr_play_file(), and switch_ivr_speak_text().

◆ switch_core_session_destroy

#define switch_core_session_destroy (   session)    switch_core_session_perform_destroy(session, __FILE__, __SWITCH_FUNC__, __LINE__)

Destroy a session and return the memory pool to the core.

Parameters
sessionpointer to a pointer of the session to destroy
Returns

Definition at line 817 of file switch_core.h.

Referenced by switch_core_session_request_xml(), and switch_core_session_thread().

◆ switch_core_session_execute_application

#define switch_core_session_execute_application (   _a,
  _b,
  _c 
)    switch_core_session_execute_application_get_flags(_a, _b, _c, NULL)

Execute an application on a session.

Parameters
sessionthe current session
appthe application's name
argapplication arguments
Returns
the application's return value

Definition at line 1129 of file switch_core.h.

Referenced by exec_app(), exec_cb(), CoreSession::execute(), switch_channel_execute_on_value(), switch_core_session_execute_exten(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_ivr_broadcast(), and switch_ivr_parse_event().

◆ switch_core_session_force_locate

#define switch_core_session_force_locate (   uuid_str)    switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)

Locate a session based on it's uuid even if the channel is not ready.

Parameters
uuid_strthe unique id of the session you want to find
Returns
the session or NULL
Note
if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()

Definition at line 941 of file switch_core.h.

Referenced by CoreSession::CoreSession(), and switch_ivr_uuid_force_exists().

◆ switch_core_session_get_partner

#define switch_core_session_get_partner (   _session,
  _partner 
)    switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)

◆ switch_core_session_get_private

#define switch_core_session_get_private (   _s)    switch_core_session_get_private_class(_s, SWITCH_PVT_PRIMARY)

Definition at line 1160 of file switch_core.h.

◆ switch_core_session_hupall_matching_var

#define switch_core_session_hupall_matching_var (   _vn,
  _vv,
  _c 
)    switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED)

Definition at line 1000 of file switch_core.h.

Referenced by switch_loadable_module_unprocess().

◆ switch_core_session_hupall_matching_vars

#define switch_core_session_hupall_matching_vars (   _vs,
  _c 
)    switch_core_session_hupall_matching_vars_ans(_vs, _c, SHT_UNANSWERED | SHT_ANSWERED)

Definition at line 1010 of file switch_core.h.

◆ switch_core_session_kill_channel

#define switch_core_session_kill_channel (   session,
  sig 
)    switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)

◆ switch_core_session_locate

#define switch_core_session_locate (   uuid_str)    switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)

Locate a session based on it's uuid.

Parameters
uuid_strthe unique id of the session you want to find
Returns
the session or NULL
Note
if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()

Definition at line 932 of file switch_core.h.

Referenced by audio_bridge_thread(), check_channel_status(), fs_core_session_locate(), msrp_worker(), rtp_common_read(), sb_on_dtmf(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), switch_channel_clear_flag_partner(), switch_channel_get_private_partner(), switch_channel_get_variable_partner(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_set_flag_partner(), switch_channel_set_variable_partner_var_check(), switch_channel_test_cap_partner(), switch_channel_test_flag_partner(), switch_core_media_receive_message(), switch_core_session_findall_matching_var(), switch_core_session_hupall(), switch_core_session_hupall_endpoint(), switch_core_session_hupall_matching_vars_ans(), switch_core_session_outgoing_channel(), switch_core_session_pass_indication(), switch_core_session_perform_receive_message(), switch_core_session_read_frame(), switch_core_session_write_frame(), switch_core_standard_on_execute(), switch_core_standard_on_reset(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_blind_transfer_ack(), switch_ivr_broadcast(), switch_ivr_eavesdrop_session(), switch_ivr_find_bridged_uuid(), switch_ivr_hold_toggle_uuid(), switch_ivr_hold_uuid(), switch_ivr_intercept_session(), switch_ivr_kill_uuid(), switch_ivr_media(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_parse_event(), switch_ivr_session_transfer(), switch_ivr_soft_hold(), switch_ivr_unhold(), switch_ivr_unhold_uuid(), switch_ivr_uuid_bridge(), switch_ivr_uuid_exists(), switch_log_node_to_json(), SWITCH_STANDARD_API(), SWITCH_STANDARD_SCHED_FUNC(), and uuid_bridge_on_soft_execute().

◆ switch_core_session_receive_message

#define switch_core_session_receive_message (   _session,
  _message 
)
Value:
__FILE__, __SWITCH_FUNC__, __LINE__)
#define __SWITCH_FUNC__
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.

Definition at line 1247 of file switch_core.h.

Referenced by _switch_core_session_request_video_refresh(), audio_bridge_thread(), display_exec_cb(), handle_ice(), signal_bridge_on_hibernate(), switch_core_media_hard_mute(), switch_core_media_media_params(), switch_core_media_receive_message(), switch_core_media_set_video_codec(), switch_core_session_exec(), switch_core_session_message_send(), switch_core_session_pass_indication(), switch_core_session_perform_receive_message(), switch_core_session_read_frame(), switch_core_session_set_uuid(), switch_core_session_write_frame(), switch_core_standard_on_execute(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_blind_transfer_ack(), switch_ivr_check_hold(), switch_ivr_eavesdrop_session(), switch_ivr_hold(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_parse_all_messages(), switch_ivr_parse_signal_data(), switch_ivr_process_indications(), switch_ivr_record_session_event(), switch_ivr_send_prompt(), switch_ivr_session_transfer(), switch_ivr_unhold(), switch_jb_get_packet(), and SWITCH_STANDARD_SCHED_FUNC().

◆ switch_core_session_request

#define switch_core_session_request (   _ep,
  _d,
  _f,
  _p 
)    switch_core_session_request_uuid(_ep, _d, _f, _p, NULL)

Definition at line 803 of file switch_core.h.

Referenced by switch_core_session_request_by_name().

◆ switch_core_session_set_private

#define switch_core_session_set_private (   _s,
  _p 
)    switch_core_session_set_private_class(_s, _p, SWITCH_PVT_PRIMARY)

Definition at line 1169 of file switch_core.h.

Enumeration Type Documentation

◆ switch_hup_type_t

Enumerator
SHT_NONE 
SHT_UNANSWERED 
SHT_ANSWERED 

Definition at line 985 of file switch_core.h.

985  {
986  SHT_NONE = 0,
987  SHT_UNANSWERED = (1 << 0),
988  SHT_ANSWERED = (1 << 1)
switch_hup_type_t
Definition: switch_core.h:985

Function Documentation

◆ switch_core_dump_variables()

void switch_core_dump_variables ( _In_ switch_stream_handle_t stream)

◆ switch_core_get_domain()

char* switch_core_get_domain ( switch_bool_t  dup)

Definition at line 367 of file switch_core.c.

References switch_runtime::global_var_rwlock, switch_core_get_variable(), switch_thread_rwlock_rdlock(), and switch_thread_rwlock_unlock().

368 {
369  char *domain;
370  const char *var;
371 
373  if (!(var = switch_core_get_variable("domain"))) {
374  var = "freeswitch.local";
375  }
376  if (dup) {
377  domain = strdup(var);
378  } else {
379  domain = (char *) var;
380  }
382 
383  return domain;
384 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * global_var_rwlock
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:250
char * switch_core_get_variable(const char *varname)
Definition: switch_core.c:395

◆ switch_core_get_hostname()

const char* switch_core_get_hostname ( void  )

◆ switch_core_get_switchname()

const char* switch_core_get_switchname ( void  )

◆ switch_core_get_uuid()

char* switch_core_get_uuid ( void  )

Retrieve the unique identifier from the core.

Returns
a string representing the uuid

Definition at line 495 of file switch_core.c.

References switch_runtime::uuid_str.

Referenced by switch_core_recovery_recover(), switch_core_recovery_track(), switch_core_recovery_untrack(), switch_event_prep_for_delivery_detailed(), switch_ivr_generate_json_cdr(), and switch_ivr_generate_xml_cdr().

496 {
497  return runtime.uuid_str;
498 }
struct switch_runtime runtime
Definition: switch_core.c:86
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]

◆ switch_core_get_variable()

char* switch_core_get_variable ( _In_z_ const char *  varname)

Retrieve a global variable from the core.

Parameters
varnamethe name of the variable
Returns
the value of the desired variable

Referenced by get_channels(), init_upnp(), switch_ivr_originate(), switch_ivr_set_xml_call_stats(), switch_log_node_to_json(), switch_rtp_add_crypto_key(), switch_xml_clear_user_cache(), and text_callback().

◆ switch_core_get_variable_dup()

char* switch_core_get_variable_dup ( _In_z_ const char *  varname)

◆ switch_core_get_variable_pdup()

char* switch_core_get_variable_pdup ( _In_z_ const char *  varname,
switch_memory_pool_t pool 
)

◆ switch_core_get_variables()

switch_status_t switch_core_get_variables ( switch_event_t **  event)

Definition at line 386 of file switch_core.c.

References switch_runtime::global_var_rwlock, switch_runtime::global_vars, switch_event_dup(), switch_thread_rwlock_rdlock(), and switch_thread_rwlock_unlock().

Referenced by asr_set_json_text_params(), and switch_channel_execute_on().

387 {
388  switch_status_t status;
390  status = switch_event_dup(event, runtime.global_vars);
392  return status;
393 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * global_var_rwlock
switch_event_t * global_vars
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:250
switch_status_t
Common return values.

◆ switch_core_service_session_av()

void switch_core_service_session_av ( _In_ switch_core_session_t session,
switch_bool_t  audio,
switch_bool_t  video 
)

Launch a service thread on a session to drop inbound data.

Parameters
sessionthe session the launch thread on

◆ switch_core_session_add_stream()

int switch_core_session_add_stream ( _In_ switch_core_session_t session,
_In_opt_ void *  private_info 
)

Add a logical stream to a session.

Parameters
sessionthe session to add the stream to
private_infoan optional pointer to private data for the new stream
Returns
the stream id of the new stream

◆ switch_core_session_count()

uint32_t switch_core_session_count ( void  )

Provide the total number of sessions.

Returns
the total number of allocated sessions

Definition at line 2518 of file switch_core_session.c.

References switch_session_manager::session_count, and session_manager.

Referenced by send_heartbeat(), switch_channel_perform_set_running_state(), switch_core_session_ctl(), and thread_launch_failure().

2519 {
2521 }
struct switch_session_manager session_manager

◆ switch_core_session_dequeue_event()

switch_status_t switch_core_session_dequeue_event ( _In_ switch_core_session_t session,
_Out_ switch_event_t **  event,
switch_bool_t  force 
)

DE-Queue an event on a given session.

Parameters
sessionthe session to de-queue the message on
eventthe de-queued event
forceforce the dequeue
Returns
the SWITCH_STATUS_SUCCESS if the event was de-queued

Referenced by audio_bridge_thread(), CoreSession::flushEvents(), switch_ivr_collect_digits_callback(), switch_ivr_eavesdrop_session(), switch_ivr_gentones(), switch_ivr_park(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_session_echo(), switch_ivr_sleep(), and switch_ivr_speak_text_handle().

◆ switch_core_session_dequeue_message()

switch_status_t switch_core_session_dequeue_message ( _In_ switch_core_session_t session,
_Out_ switch_core_session_message_t **  message 
)

DE-Queue an message on a given session.

Parameters
sessionthe session to de-queue the message on
messagethe de-queued message
Returns
SWITCH_STATUS_SUCCESS if the message was de-queued

Referenced by switch_ivr_parse_all_messages().

◆ switch_core_session_dequeue_private_event()

switch_status_t switch_core_session_dequeue_private_event ( _In_ switch_core_session_t session,
_Out_ switch_event_t **  event 
)

DE-Queue a private event on a given session.

Parameters
sessionthe session to de-queue the message on
eventthe de-queued event
Returns
the SWITCH_STATUS_SUCCESS if the event was de-queued

Referenced by switch_ivr_park(), and switch_ivr_parse_next_event().

◆ switch_core_session_dequeue_signal_data()

switch_status_t switch_core_session_dequeue_signal_data ( switch_core_session_t session,
void **  signal_data 
)

Definition at line 1151 of file switch_core_session.c.

References switch_core_session::signal_data_queue, switch_assert, switch_queue_trypop(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by switch_ivr_parse_signal_data().

1152 {
1154  void *pop;
1155 
1156  switch_assert(session != NULL);
1157 
1158  if (session->signal_data_queue) {
1159  if ((status = (switch_status_t) switch_queue_trypop(session->signal_data_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
1160  *signal_data = pop;
1161  }
1162  }
1163 
1164  return status;
1165 }
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
switch_queue_t * signal_data_queue
switch_status_t
Common return values.
#define switch_assert(expr)

◆ switch_core_session_destroy_state()

void switch_core_session_destroy_state ( switch_core_session_t session)

Definition at line 720 of file switch_core_state_machine.c.

References CCS_DOWN, CF_REDIRECT, CF_TRANSFER, switch_core_session::channel, CS_DESTROY, switch_core_session::endpoint_interface, index, switch_endpoint_interface::state_handler, STATE_MACRO, switch_assert, switch_channel_clear_device_record(), switch_channel_clear_flag(), switch_channel_set_callstate, and switch_channel_set_running_state.

Referenced by switch_core_session_perform_destroy().

721 {
723  const switch_endpoint_interface_t *endpoint_interface;
724  const switch_state_handler_table_t *driver_state_handler = NULL;
725  const switch_state_handler_table_t *application_state_handler = NULL;
726  int proceed = 1;
727  int global_proceed = 1;
728  int do_extra_handlers = 1;
729  int silly = 0;
730  int index = 0;
731 
733 
734  switch_assert(session != NULL);
738 
739  endpoint_interface = session->endpoint_interface;
740  switch_assert(endpoint_interface != NULL);
741 
742  driver_state_handler = endpoint_interface->state_handler;
743  switch_assert(driver_state_handler != NULL);
744 
745  STATE_MACRO(destroy, "DESTROY");
746 
748 
749  return;
750 }
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
void switch_channel_clear_device_record(switch_channel_t *channel)
switch_state_handler_table_t * state_handler
switch_channel_t * channel
int index
Definition: switch_cJSON.h:160
#define switch_channel_set_running_state(channel, state)
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
#define switch_channel_set_callstate(channel, state)
#define STATE_MACRO(__STATE, __STATE_STR)
switch_endpoint_interface_t * endpoint_interface
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
#define switch_assert(expr)

◆ switch_core_session_event_count()

uint32_t switch_core_session_event_count ( _In_ switch_core_session_t session)

Indicate the number of waiting events on a session.

Parameters
sessionthe session to check
Returns
the number of events

◆ switch_core_session_event_send()

switch_status_t switch_core_session_event_send ( _In_z_ const char *  uuid_str,
_Inout_ switch_event_t **  event 
)

Queue an event on another session using its uuid.

Parameters
uuid_strthe unique id of the session you want to send a message to
eventthe event to send
Returns
the status returned by the message handler

◆ switch_core_session_exec()

switch_status_t switch_core_session_exec ( _In_ switch_core_session_t session,
_In_ const switch_application_interface_t application_interface,
_In_opt_z_ const char *  arg 
)

Execute an application on a session.

Parameters
sessionthe current session
application_interfacethe interface of the application to execute
argapplication arguments
Warning
Has to be called from the session's thread
Returns
the application's return value

Referenced by collect_thread_run(), switch_ivr_menu_execute(), and switch_ivr_phrase_macro_event().

◆ switch_core_session_execute_application_async()

switch_status_t switch_core_session_execute_application_async ( switch_core_session_t session,
const char *  app,
const char *  arg 
)

Definition at line 2677 of file switch_core_session.c.

References CF_BLOCK_BROADCAST_UNTIL_MEDIA, CF_PROXY_MODE, switch_core_session::channel, switch_channel_set_flag, switch_channel_test_flag(), switch_core_session_queue_private_event(), switch_core_session_strdup, switch_event_add_header_string(), SWITCH_EVENT_COMMAND, switch_event_create, SWITCH_FALSE, SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by audio_bridge_thread(), switch_channel_execute_on_value(), switch_core_session_execute_application_get_flags(), tone_detect_callback(), and tone_on_dtmf().

2678 {
2679  switch_event_t *execute_event;
2680  char *ap, *arp;
2681 
2682  if (!arg && strstr(app, "::")) {
2683  ap = switch_core_session_strdup(session, app);
2684  app = ap;
2685 
2686  if ((arp = strstr(ap, "::"))) {
2687  *arp = '\0';
2688  arg = arp + 2;
2689  }
2690  }
2691 
2693  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
2694  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", app);
2695 
2696  if (arg) {
2697  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
2698  }
2699 
2702  }
2703 
2704  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
2705  switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
2706 
2707  return SWITCH_STATUS_SUCCESS;
2708  }
2709 
2710  return SWITCH_STATUS_FALSE;
2711 }
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.
switch_channel_t * channel
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
Definition: switch_event.h:384
#define switch_channel_set_flag(_c, _f)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
switch_status_t switch_core_session_queue_private_event(switch_core_session_t *session, switch_event_t **event, switch_bool_t priority)

◆ switch_core_session_execute_application_get_flags()

switch_status_t switch_core_session_execute_application_get_flags ( _In_ switch_core_session_t session,
_In_ const char *  app,
_In_opt_z_ const char *  arg,
_Out_opt_ int32_t *  flags 
)

Execute an application on a session.

Parameters
sessionthe current session
appthe application's name
argapplication arguments
flagspointer to a flags variable to set the applications flags to
Returns
the application's return value

Referenced by switch_ivr_broadcast().

◆ switch_core_session_execute_exten()

switch_status_t switch_core_session_execute_exten ( _In_ switch_core_session_t session,
_In_z_ const char *  exten,
_In_opt_z_ const char *  dialplan,
_In_opt_z_ const char *  context 
)

Run a dialplan and execute an extension.

Parameters
sessionthe current session
extenthe interface of the application to execute
argapplication arguments
Note
It does not change the channel back to CS_ROUTING, it manually calls the dialplan and executes the applications
Warning
Has to be called from the session's thread
Returns
the application's return value

◆ switch_core_session_findall()

switch_console_callback_match_t* switch_core_session_findall ( void  )

Definition at line 417 of file switch_core_session.c.

References runtime, switch_runtime::session_hash_mutex, session_manager, switch_session_manager::session_table, switch_console_push_match(), switch_core_hash_first, switch_core_hash_next(), switch_core_hash_this(), switch_core_session_read_lock(), switch_core_session_rwunlock(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, and switch_core_session::uuid_str.

418 {
420  void *val;
421  switch_core_session_t *session;
422  switch_console_callback_match_t *my_matches = NULL;
423 
426  switch_core_hash_this(hi, NULL, NULL, &val);
427  if (val) {
428  session = (switch_core_session_t *) val;
430  switch_console_push_match(&my_matches, session->uuid_str);
432  }
433  }
434  }
436 
437  return my_matches;
438 }
struct switch_session_manager session_manager
switch_status_t switch_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
void switch_console_push_match(switch_console_callback_match_t **matches, const char *new_val)
void switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
Gets the key and value of the current hash element.
switch_hash_index_t * switch_core_hash_next(_In_ switch_hash_index_t **hi)
Gets the next element of a hashtable.
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
switch_mutex_t * session_hash_mutex
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_hash_t * session_table
#define switch_core_hash_first(_h)
Definition: switch_core.h:1592

◆ switch_core_session_findall_matching_var()

switch_console_callback_match_t* switch_core_session_findall_matching_var ( const char *  var_name,
const char *  var_val 
)

Definition at line 289 of file switch_core_session.c.

References switch_core_session::channel, str_node::next, pool, runtime, switch_runtime::session_hash_mutex, session_manager, switch_session_manager::session_table, switch_channel_get_variable_dup(), switch_channel_up_nosig, switch_console_push_match(), switch_core_alloc, switch_core_destroy_memory_pool, switch_core_hash_first, switch_core_hash_next(), switch_core_hash_this(), switch_core_new_memory_pool, switch_core_session_locate, switch_core_session_read_lock(), switch_core_session_rwunlock(), switch_core_strdup, SWITCH_FALSE, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, switch_stristr(), and switch_core_session::uuid_str.

290 {
292  void *val;
293  switch_core_session_t *session;
295  struct str_node *head = NULL, *np;
296  switch_console_callback_match_t *my_matches = NULL;
297  const char *like = NULL;
298 
299  if (var_val && *var_val == '~') {
300  like = var_val + 1;
301  }
302 
304 
307  switch_core_hash_this(hi, NULL, NULL, &val);
308  if (val) {
309  session = (switch_core_session_t *) val;
311  np = switch_core_alloc(pool, sizeof(*np));
312  np->str = switch_core_strdup(pool, session->uuid_str);
313  np->next = head;
314  head = np;
316  }
317  }
318  }
320 
321  for(np = head; np; np = np->next) {
322  if ((session = switch_core_session_locate(np->str))) {
323  const char *this_val;
324  if (switch_channel_up_nosig(session->channel) &&
325  (this_val = switch_channel_get_variable_dup(session->channel, var_name, SWITCH_FALSE, -1)) &&
326  (!var_val || (like && switch_stristr(like, var_val)) || !strcmp(this_val, var_val))) {
327  switch_console_push_match(&my_matches, (const char *) np->str);
328  }
330  }
331  }
332 
334 
335 
336  return my_matches;
337 }
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core&#39;s master pool.
Definition: switch_core.h:633
struct switch_session_manager session_manager
struct str_node * next
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:642
switch_memory_pool_t * pool
switch_status_t switch_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the 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.
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_channel_t * channel
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
void switch_console_push_match(switch_console_callback_match_t **matches, const char *new_val)
void switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
Gets the key and value of the current hash element.
switch_hash_index_t * switch_core_hash_next(_In_ switch_hash_index_t **hi)
Gets the next element of a hashtable.
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
switch_mutex_t * session_hash_mutex
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_hash_t * session_table
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
const char * switch_stristr(const char *instr, const char *str)
struct fspr_pool_t switch_memory_pool_t
#define switch_channel_up_nosig(_channel)
#define switch_core_hash_first(_h)
Definition: switch_core.h:1592

◆ switch_core_session_flush_message()

switch_status_t switch_core_session_flush_message ( _In_ switch_core_session_t session)

Flush a message queue on a given session.

Parameters
sessionthe session to de-queue the message on
Returns
SWITCH_STATUS_SUCCESS if the message was de-queued

◆ switch_core_session_flush_private_events()

uint32_t switch_core_session_flush_private_events ( switch_core_session_t session)

Flush the private event queue of a session.

Parameters
sessionthe session to flush
Returns
SWITCH_STATUS_SUCCESS if the events have been flushed

Definition at line 1348 of file switch_core_session.c.

References check_media, switch_core_session::private_event_queue, switch_core_session::private_event_queue_pri, switch_event_destroy(), switch_queue_trypop(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_perform_destroy(), and switch_ivr_parse_event().

1349 {
1350  int x = 0;
1351  void *pop;
1352 
1353  if (session->private_event_queue) {
1355  if (pop) {
1356  switch_event_t *event = (switch_event_t *) pop;
1357  switch_event_destroy(&event);
1358  }
1359  x++;
1360  }
1362  if (pop) {
1363  switch_event_t *event = (switch_event_t *) pop;
1364  switch_event_destroy(&event);
1365  }
1366  x++;
1367  }
1368  check_media(session);
1369  }
1370 
1371  return x;
1372 }
Representation of an event.
Definition: switch_event.h:80
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
switch_queue_t * private_event_queue
switch_queue_t * private_event_queue_pri
#define check_media(session)
void switch_event_destroy(switch_event_t **event)
Destroy an event.

◆ switch_core_session_free_message()

void switch_core_session_free_message ( switch_core_session_message_t **  message)

Definition at line 1070 of file switch_core_session.c.

References MESSAGE_STRING_ARG_MAX, switch_core_session_message::pointer_arg, SCSMF_DYNAMIC, switch_core_session_message::string_arg, switch_core_session_message::string_array_arg, switch_safe_free, and switch_test_flag.

Referenced by switch_core_session_flush_message(), switch_core_session_perform_receive_message(), and switch_ivr_parse_all_messages().

1071 {
1072  switch_core_session_message_t *to_free = *message;
1073  int i;
1074  char *s;
1075 
1076  *message = NULL;
1077 
1078  if (switch_test_flag(to_free, SCSMF_DYNAMIC)) {
1079  s = (char *) to_free->string_arg;
1080  switch_safe_free(s);
1081  switch_safe_free(to_free->pointer_arg);
1082 
1083  for (i = 0; i < MESSAGE_STRING_ARG_MAX; i++) {
1084  s = (char *) to_free->string_array_arg[i];
1085  switch_safe_free(s);
1086  }
1087 
1088  switch_safe_free(to_free);
1089  }
1090 }
#define MESSAGE_STRING_ARG_MAX
Definition: switch_core.h:177
const char * string_array_arg[MESSAGE_STRING_ARG_MAX]
Definition: switch_core.h:211
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:179
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693

◆ switch_core_session_get_app_flags()

switch_status_t switch_core_session_get_app_flags ( const char *  app,
int32_t *  flags 
)

Definition at line 2652 of file switch_core_session.c.

References switch_application_interface::flags, switch_assert, SWITCH_CHANNEL_LOG, switch_loadable_module_get_application_interface(), SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and UNPROTECT_INTERFACE.

Referenced by switch_ivr_broadcast().

2653 {
2654  switch_application_interface_t *application_interface;
2656 
2657  switch_assert(flags);
2658 
2659  *flags = 0;
2660 
2661  if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
2662  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app);
2663  goto end;
2664  } else if (application_interface->flags) {
2665  *flags = application_interface->flags;
2666  status = SWITCH_STATUS_SUCCESS;
2667  }
2668 
2669  UNPROTECT_INTERFACE(application_interface);
2670 
2671  end:
2672 
2673  return status;
2674 
2675 }
A module interface to implement an application.
#define SWITCH_CHANNEL_LOG
#define UNPROTECT_INTERFACE(_it)
switch_application_interface_t * switch_loadable_module_get_application_interface(const char *name)
Retrieve the application interface by it&#39;s registered name.
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)

◆ switch_core_session_get_app_log()

switch_app_log_t* switch_core_session_get_app_log ( _In_ switch_core_session_t session)

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

Parameters
sessionthe session to retrieve from
Returns
a pointer to the channel object

Referenced by _switch_core_session_request_video_refresh(), asr_set_json_text_params(), audio_bridge_on_consume_media(), audio_bridge_on_exchange_media(), audio_bridge_on_routing(), audio_bridge_thread(), block_on_dtmf(), bridge(), check_channel_status(), check_timeout(), cleanup_proxy_mode_a(), cleanup_proxy_mode_b(), collect_thread_run(), CoreSession::CoreSession(), CoreSession::destroy(), do_dtls(), do_flush(), dtls_state_fail(), dtmf_callback(), early_thread_run(), eavesdrop_callback(), enterprise_originate_ringback_thread(), enterprise_originate_thread(), exec_app(), exec_cb(), CoreSession::flushDigits(), fs_channel_answer(), fs_channel_get_variable(), fs_channel_hangup(), fs_channel_pre_answer(), fs_channel_set_state(), fs_channel_set_variable(), fs_switch_ivr_originate(), gen_ice(), generate_on_dtmf(), CoreSession::getDigits(), handle_ice(), handle_nack(), hanguphook(), inband_dtmf_callback(), inband_dtmf_generate_callback(), inherit_codec(), ivr_send_event(), limit_state_handler(), meta_on_dtmf(), monitor_callback(), CoreSession::originate(), originate_on_consume_media_transmit(), originate_on_routing(), play_and_collect(), play_and_detect_input_callback(), preprocess_callback(), process_rtcp_report(), read_bundle_rtp_packet(), read_displace_callback(), read_rtp_packet(), record_callback(), record_helper_post_process(), recording_thread(), recover_callback(), rtp_common_read(), rtp_common_write(), sb_on_dtmf(), send_display(), session_audio_callback(), set_stats(), CoreSession::setHangupHook(), setup_ringback(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), speech_callback(), speech_on_dtmf(), speech_thread(), switch_channel_clear_flag_partner(), switch_channel_get_hold_music_partner(), switch_channel_get_variable_partner(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_set_flag_partner(), switch_channel_set_variable_partner_var_check(), switch_channel_test_cap_partner(), switch_channel_test_flag_partner(), switch_collect_input_callback(), switch_core_media_activate_rtp(), switch_core_media_build_crypto(), switch_core_media_copy_t38_options(), switch_core_media_negotiate_sdp(), switch_core_media_process_sdp_filter(), switch_core_media_receive_message(), switch_core_media_reset_t38(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_toggle_hold(), switch_core_recovery_track(), switch_core_recovery_untrack(), switch_core_service_session_av(), switch_core_service_thread(), switch_core_session_check_outgoing_crypto(), switch_core_session_read_frame(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_session_write_frame(), switch_core_standard_on_reset(), switch_core_thread_session_end(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_activate_unicast(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_blind_transfer_ack(), switch_ivr_block_dtmf_session(), switch_ivr_bridge_bleg(), switch_ivr_broadcast(), switch_ivr_capture_text(), switch_ivr_check_hold(), switch_ivr_clear_speech_cache(), switch_ivr_collect_digits_callback(), switch_ivr_collect_digits_count(), switch_ivr_deactivate_unicast(), switch_ivr_delay_echo(), switch_ivr_detect_audio(), switch_ivr_detect_silence(), 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_eavesdrop_session(), switch_ivr_eavesdrop_update_display(), switch_ivr_enterprise_orig_and_bridge(), switch_ivr_enterprise_originate(), switch_ivr_find_bridged_uuid(), switch_ivr_generate_json_cdr(), switch_ivr_generate_xml_cdr(), switch_ivr_gentones(), switch_ivr_get_file_handle(), switch_ivr_hold(), switch_ivr_hold_toggle_uuid(), switch_ivr_inband_dtmf_generate_session(), switch_ivr_inband_dtmf_session(), switch_ivr_insert_file(), switch_ivr_intercept_session(), switch_ivr_kill_uuid(), switch_ivr_media(), switch_ivr_menu_execute(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_orig_and_bridge(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_park_session(), switch_ivr_parse_all_events(), switch_ivr_parse_event(), switch_ivr_parse_next_event(), switch_ivr_parse_signal_data(), switch_ivr_pause_detect_speech(), switch_ivr_phrase_macro_event(), switch_ivr_play_and_collect_input(), switch_ivr_play_and_detect_speech(), switch_ivr_play_file(), switch_ivr_preprocess_session(), switch_ivr_process_indications(), switch_ivr_read(), switch_ivr_record_file_event(), switch_ivr_record_session_event(), switch_ivr_record_session_mask(), switch_ivr_record_session_pause(), switch_ivr_resume_detect_speech(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_audio(), switch_ivr_session_echo(), switch_ivr_session_transfer(), switch_ivr_set_param_detect_speech(), switch_ivr_set_user_xml(), switch_ivr_signal_bridge(), switch_ivr_sleep(), switch_ivr_soft_hold(), switch_ivr_sound_test(), switch_ivr_speak_text(), switch_ivr_speak_text_handle(), 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_transfer_recordings(), switch_ivr_transfer_variable(), switch_ivr_unbind_dtmf_meta_session(), switch_ivr_unblock_dtmf_session(), switch_ivr_unhold(), switch_ivr_uuid_bridge(), switch_ivr_video_write_overlay_session(), switch_ivr_wait_for_answer(), switch_ivr_wait_for_silence(), switch_jb_set_session(), switch_limit_incr(), switch_log_meta_vprintf(), switch_log_node_to_json(), switch_play_and_get_digits(), switch_process_import(), switch_regex_set_var_callback(), switch_rtp_activate_jitter_buffer(), switch_rtp_add_crypto_key(), switch_rtp_add_dtls(), switch_rtp_break(), switch_rtp_create(), switch_rtp_dequeue_dtmf(), switch_rtp_enable_vad(), switch_rtp_set_flag(), switch_rtp_set_local_address(), switch_rtp_sync_stats(), switch_rtp_write_frame(), SWITCH_STANDARD_APP(), SWITCH_STANDARD_SCHED_FUNC(), text_bridge_thread(), text_helper_thread(), tone_detect_callback(), tone_detect_set_total_time(), tone_on_dtmf(), transfer_after_bridge(), uuid_bridge_on_hibernate(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), video_helper_thread(), video_write_overlay_callback(), and write_displace_callback().

◆ switch_core_session_get_dmachine()

switch_ivr_dmachine_t* switch_core_session_get_dmachine ( switch_core_session_t session,
switch_digit_action_target_t  target 
)

Definition at line 56 of file switch_core_session.c.

References switch_core_session::dmachine.

Referenced by signal_bridge_on_hibernate().

57 {
58  int i = (int) target;
59 
60  if (i == 0 || i == 1) {
61  return session->dmachine[i];
62  }
63 
64  return NULL;
65 }
const cJSON *const target
switch_ivr_dmachine_t * dmachine[2]

◆ switch_core_session_get_external_id()

const char* switch_core_session_get_external_id ( _In_ switch_core_session_t session)

Retrieve the unique external identifier from a session.

Parameters
sessionthe session to retrieve the uuid from
Returns
a string representing the uuid

Referenced by switch_channel_event_set_basic_data().

◆ switch_core_session_get_id()

switch_size_t switch_core_session_get_id ( _In_ switch_core_session_t session)

◆ switch_core_session_get_jb()

switch_jb_t* switch_core_session_get_jb ( switch_core_session_t session,
switch_media_type_t  type 
)

Definition at line 68 of file switch_core_session.c.

References switch_core_session::endpoint_interface, switch_io_routines::get_jb, and switch_endpoint_interface::io_routines.

Referenced by switch_core_media_read_frame().

69 {
70  if (session->endpoint_interface->io_routines->get_jb) {
71  return session->endpoint_interface->io_routines->get_jb(session, type);
72  }
73 
74  return NULL;
75 }
switch_io_routines_t * io_routines
switch_endpoint_interface_t * endpoint_interface

◆ switch_core_session_get_loglevel()

switch_log_level_t switch_core_session_get_loglevel ( switch_core_session_t session)

Get the log level for a session.

Parameters
sessionthe session to get the log level from
Returns
the log level

Definition at line 3116 of file switch_core_session.c.

References switch_core_session::loglevel, and switch_assert.

3117 {
3118  switch_assert(session != NULL);
3119  return session->loglevel;
3120 }
switch_log_level_t loglevel
#define switch_assert(expr)

◆ switch_core_session_get_mutex()

switch_mutex_t* switch_core_session_get_mutex ( switch_core_session_t session)

Signal a session's state machine thread that a state change has occured.

Definition at line 1437 of file switch_core_session.c.

References switch_core_session::mutex.

Referenced by careful_set().

1438 {
1439  return session->mutex;
1440 }
switch_mutex_t * mutex

◆ switch_core_session_get_private_class()

void* switch_core_session_get_private_class ( _In_ switch_core_session_t session,
_In_ switch_pvt_class_t  index 
)

Retrieve private user data from a session.

Parameters
sessionthe session to retrieve from
Returns
a pointer to the private data

◆ switch_core_session_get_stream()

void* switch_core_session_get_stream ( _In_ switch_core_session_t session,
_In_ int  index 
)

Retreive a logical stream from a session.

Parameters
sessionthe session to add the stream to
indexthe index to retrieve
Returns
the stream

◆ switch_core_session_get_stream_count()

int switch_core_session_get_stream_count ( _In_ switch_core_session_t session)

Determine the number of logical streams a session has.

Parameters
sessionthe session to query
Returns
the total number of logical streams

◆ switch_core_session_get_text_buffer()

const char* switch_core_session_get_text_buffer ( switch_core_session_t session)

Definition at line 1990 of file switch_core_session.c.

References buf, switch_buffer_get_head_pointer(), switch_core_session_strdup, switch_mutex_lock(), switch_mutex_unlock(), switch_core_session::text_buffer, and switch_core_session::text_mutex.

Referenced by switch_ivr_generate_xml_cdr().

1991 {
1992  const char *buf = NULL;
1993 
1994  if (session->text_buffer) {
1995  switch_mutex_lock(session->text_mutex);
1996  buf = (const char *)switch_core_session_strdup(session, (const char *) switch_buffer_get_head_pointer(session->text_buffer));
1997  switch_mutex_unlock(session->text_mutex);
1998  }
1999 
2000  return buf;
2001 }
switch_buffer_t * text_buffer
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_byte_t switch_byte_t * buf
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_mutex_t * text_mutex
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
void * switch_buffer_get_head_pointer(switch_buffer_t *buffer)
Definition: switch_buffer.c:57

◆ switch_core_session_get_uuid()

char* switch_core_session_get_uuid ( _In_ switch_core_session_t session)

◆ switch_core_session_hangup_state()

void switch_core_session_hangup_state ( switch_core_session_t session,
switch_bool_t  force 
)

Definition at line 793 of file switch_core_state_machine.c.

References api_hook(), CCS_HANGUP, CF_EARLY_HANGUP, switch_core_session::channel, switch_core_session::endpoint_interface, index, runtime, SCF_EARLY_HANGUP, SSF_HANGUP, switch_endpoint_interface::state_handler, STATE_MACRO, SWITCH_API_HANGUP_HOOK_VARIABLE, switch_assert, switch_channel_cause2str(), switch_channel_get_cause(), switch_channel_get_cause_q850(), switch_channel_get_name(), switch_channel_get_state(), switch_channel_get_variable, switch_channel_process_device_hangup(), SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_callstate, switch_channel_set_hangup_time(), switch_channel_set_timestamps(), switch_channel_set_variable, switch_channel_set_variable_printf(), switch_channel_stop_broadcast, switch_channel_test_flag(), switch_core_media_bug_remove_all, switch_core_media_set_stats(), SWITCH_LOG_DEBUG10, switch_log_printf(), SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE, switch_set_flag, switch_test_flag, switch_thread_self(), switch_true(), and switch_core_session::thread_id.

Referenced by CoreSession::hangupState(), switch_channel_perform_hangup(), and switch_core_session_run().

794 {
797  int proceed = 1;
798  int global_proceed = 1;
799  int do_extra_handlers = 1;
800  int silly = 0;
801  int index = 0;
803  const switch_endpoint_interface_t *endpoint_interface;
804  const switch_state_handler_table_t *driver_state_handler = NULL;
805  const switch_state_handler_table_t *application_state_handler = NULL;
806  const char *hook_var;
807  int use_session = 0;
808 
809  if (!force) {
811  return;
812  }
813 
814  if (switch_thread_self() != session->thread_id) {
815  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s thread mismatch skipping state handler.\n",
816  switch_channel_get_name(session->channel));
817  return;
818  }
819  }
820 
821  if (switch_test_flag(session, SSF_HANGUP)) {
822  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s handler already called, skipping state handler.\n",
823  switch_channel_get_name(session->channel));
824  return;
825  }
826 
827  endpoint_interface = session->endpoint_interface;
828  switch_assert(endpoint_interface != NULL);
829 
830  driver_state_handler = endpoint_interface->state_handler;
831  switch_assert(driver_state_handler != NULL);
832 
834 
836 
838 
839  switch_channel_set_variable(session->channel, "hangup_cause", switch_channel_cause2str(cause));
840  switch_channel_set_variable_printf(session->channel, "hangup_cause_q850", "%d", cause_q850);
841  //switch_channel_presence(session->channel, "unknown", switch_channel_cause2str(cause), NULL);
842 
845 
846  STATE_MACRO(hangup, "HANGUP");
847 
849 
851 
853  use_session = 1;
854  }
855 
856  api_hook(session, hook_var, use_session);
857  }
858 
860 
861  switch_set_flag(session, SSF_HANGUP);
862 
863 }
switch_status_t switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt,...)
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
switch_status_t switch_channel_set_timestamps(_In_ switch_channel_t *channel)
void switch_channel_set_hangup_time(switch_channel_t *channel)
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
const char * switch_channel_cause2str(_In_ switch_call_cause_t cause)
return a cause string for a given cause
#define switch_channel_stop_broadcast(_channel)
void switch_channel_process_device_hangup(switch_channel_t *channel)
struct switch_runtime runtime
Definition: switch_core.c:86
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_state_handler_table_t * state_handler
switch_channel_t * channel
#define switch_channel_get_variable(_c, _v)
int index
Definition: switch_cJSON.h:160
#define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE
Definition: switch_types.h:178
switch_call_cause_t
void switch_core_media_set_stats(switch_core_session_t *session)
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
#define switch_channel_set_callstate(channel, state)
#define switch_core_media_bug_remove_all(_s)
Definition: switch_core.h:405
switch_call_cause_t switch_channel_get_cause_q850(switch_channel_t *channel)
static void api_hook(switch_core_session_t *session, const char *hook_var, int use_session)
#define STATE_MACRO(__STATE, __STATE_STR)
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
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_endpoint_interface_t * endpoint_interface
switch_thread_id_t switch_thread_self(void)
Definition: switch_apr.c:102
switch_thread_id_t thread_id
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
#define SWITCH_API_HANGUP_HOOK_VARIABLE
Definition: switch_types.h:176
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_call_cause_t switch_channel_get_cause(_In_ switch_channel_t *channel)
return the cause code for a given channel

◆ switch_core_session_hupall()

void switch_core_session_hupall ( _In_ switch_call_cause_t  cause)

Hangup all sessions.

Parameters
causethe hangup cause to apply to the hungup channels

Referenced by switch_core_destroy(), and switch_core_session_ctl().

◆ switch_core_session_hupall_endpoint()

void switch_core_session_hupall_endpoint ( const switch_endpoint_interface_t endpoint_interface,
switch_call_cause_t  cause 
)

Hangup all sessions that belong to an endpoint.

Parameters
endpoint_interfaceThe endpoint interface
causethe hangup cause to apply to the hungup channels

Definition at line 339 of file switch_core_session.c.

References switch_core_session::channel, switch_core_session::endpoint_interface, str_node::next, pool, runtime, switch_runtime::session_hash_mutex, session_manager, switch_session_manager::session_table, switch_channel_hangup, switch_core_alloc, switch_core_destroy_memory_pool, switch_core_hash_first, switch_core_hash_next(), switch_core_hash_this(), switch_core_new_memory_pool, switch_core_session_locate, switch_core_session_read_lock(), switch_core_session_rwunlock(), switch_core_strdup, switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_SUCCESS, and switch_core_session::uuid_str.

Referenced by switch_loadable_module_unprocess().

340 {
342  void *val;
343  switch_core_session_t *session;
345  struct str_node *head = NULL, *np;
346 
348 
351  switch_core_hash_this(hi, NULL, NULL, &val);
352  if (val) {
353  session = (switch_core_session_t *) val;
355  if (session->endpoint_interface == endpoint_interface) {
356  np = switch_core_alloc(pool, sizeof(*np));
357  np->str = switch_core_strdup(pool, session->uuid_str);
358  np->next = head;
359  head = np;
360  }
362  }
363  }
364  }
366 
367  for(np = head; np; np = np->next) {
368  if ((session = switch_core_session_locate(np->str))) {
369  switch_channel_hangup(session->channel, cause);
371  }
372  }
373 
375 
376 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core&#39;s master pool.
Definition: switch_core.h:633
struct switch_session_manager session_manager
struct str_node * next
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:642
switch_memory_pool_t * pool
switch_status_t switch_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_channel_t * channel
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:684
void switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
Gets the key and value of the current hash element.
switch_hash_index_t * switch_core_hash_next(_In_ switch_hash_index_t **hi)
Gets the next element of a hashtable.
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
switch_mutex_t * session_hash_mutex
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_hash_t * session_table
#define switch_core_session_locate(uuid_str)
Locate a session based on it&#39;s uuid.
Definition: switch_core.h:932
switch_endpoint_interface_t * endpoint_interface
struct fspr_pool_t switch_memory_pool_t
#define switch_core_hash_first(_h)
Definition: switch_core.h:1592

◆ switch_core_session_hupall_matching_var_ans()

uint32_t switch_core_session_hupall_matching_var_ans ( _In_ const char *  var_name,
_In_ const char *  var_val,
_In_ switch_call_cause_t  cause,
switch_hup_type_t  type 
)

Hangup all sessions which match a specific channel variable.

Parameters
var_nameThe variable name to look for
var_valThe value to look for
causethe hangup cause to apply to the hungup channels

◆ switch_core_session_hupall_matching_vars_ans()

uint32_t switch_core_session_hupall_matching_vars_ans ( _In_ switch_event_t vars,
_In_ switch_call_cause_t  cause,
switch_hup_type_t  type 
)

Hangup all sessions which match specific channel variable(s)

Parameters
var_nameThe variable name to look for
var_valThe value to look for
causethe hangup cause to apply to the hungup channels

◆ switch_core_session_id()

switch_size_t switch_core_session_id ( void  )

Provide the current session_id.

Returns
the total number of allocated sessions since core startup

Definition at line 2536 of file switch_core_session.c.

References switch_session_manager::session_id, and session_manager.

Referenced by send_heartbeat(), and switch_channel_perform_set_running_state().

2537 {
2538  return session_manager.session_id;
2539 }
struct switch_session_manager session_manager

◆ switch_core_session_id_dec()

switch_size_t switch_core_session_id_dec ( void  )

Definition at line 2528 of file switch_core_session.c.

References runtime, switch_runtime::session_hash_mutex, switch_session_manager::session_id, session_manager, switch_mutex_lock(), and switch_mutex_unlock().

2529 {
2533  return session_manager.session_id;
2534 }
struct switch_session_manager session_manager
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_mutex_t * session_hash_mutex

◆ switch_core_session_launch_thread()

void switch_core_session_launch_thread ( _In_ switch_core_session_t session,
_In_ void *(*)(switch_thread_t *, void *)  func,
_In_opt_ void *  obj 
)

Launch a thread designed to exist within the scope of a given session.

Parameters
sessiona session to allocate the thread from
funca function to execute in the thread
objan arguement

Referenced by switch_core_service_session_av().

◆ switch_core_session_message_send()

switch_status_t switch_core_session_message_send ( _In_z_ const char *  uuid_str,
_In_ switch_core_session_message_t message 
)

Send a message to another session using it's uuid.

Parameters
uuid_strthe unique id of the session you want to send a message to
messagethe switch_core_session_message_t object to send
Returns
the status returned by the message handler

◆ switch_core_session_messages_waiting()

uint32_t switch_core_session_messages_waiting ( switch_core_session_t session)

Definition at line 1223 of file switch_core_session.c.

References switch_core_session::message_queue, switch_core_session::private_event_queue, and switch_queue_size().

Referenced by check_channel_status().

1224 {
1225  int x = 0;
1226 
1227  if (session->private_event_queue) {
1228  x += switch_queue_size(session->private_event_queue);
1229  }
1230 
1231  if (session->message_queue) {
1232  x += switch_queue_size(session->message_queue);
1233  }
1234 
1235  return x;
1236 }
unsigned int switch_queue_size(switch_queue_t *queue)
Definition: switch_apr.c:1238
switch_queue_t * private_event_queue
switch_queue_t * message_queue

◆ switch_core_session_outgoing_channel()

switch_call_cause_t switch_core_session_outgoing_channel ( _In_opt_ switch_core_session_t session,
_In_opt_ switch_event_t var_event,
_In_z_ const char *  endpoint_name,
_In_ switch_caller_profile_t caller_profile,
_Inout_ switch_core_session_t **  new_session,
_Inout_ switch_memory_pool_t **  pool,
_In_ switch_originate_flag_t  flags,
switch_call_cause_t cancel_cause 
)

Request an outgoing session spawned from an existing session using a desired endpoing module.

Parameters
sessionthe originating session
var_eventswitch_event_t containing paramaters
endpoint_namethe name of the module to use for the new session
caller_profilethe originator's caller profile
new_sessiona NULL pointer to aim at the newly created session
pooloptional existing memory pool to donate to the session
flagsflags to use
Returns
the cause code of the attempted call

Referenced by switch_ivr_originate().

◆ switch_core_session_pass_indication()

switch_status_t switch_core_session_pass_indication ( _In_ switch_core_session_t session,
_In_ switch_core_session_message_types_t  indication 
)

pass an indication message on a session

Parameters
sessionthe session to pass the message across
indicationthe indication message to pass
Returns
SWITCH_STATUS_SUCCESS if the message was passed

◆ switch_core_session_passthru()

void switch_core_session_passthru ( switch_core_session_t session,
switch_media_type_t  type,
switch_bool_t  on 
)

Definition at line 15014 of file switch_core_media.c.

References switch_core_session::channel, switch_media_handle_s::engines, switch_core_session::media_handle, switch_rtp_engine_s::rtp_session, switch_channel_var_true(), switch_core_media_gen_key_frame, switch_core_session_request_video_refresh, SWITCH_MEDIA_TYPE_VIDEO, switch_rtp_clear_flag(), SWITCH_RTP_FLAG_PASSTHRU, switch_rtp_ready(), switch_rtp_set_flag(), switch_snprintf(), and type2str.

Referenced by audio_bridge_thread(), and text_bridge_thread().

15015 {
15016  switch_rtp_engine_t *engine;
15017 
15018  if (!session->media_handle) return;
15019 
15020  engine = &session->media_handle->engines[type];
15021 
15022 
15023  if (switch_rtp_ready(engine->rtp_session)) {
15024  char var[50] = "";
15025  switch_snprintf(var, sizeof(var), "disable_%s_jb_during_passthru", type2str(type));
15026 
15027  if (switch_channel_var_true(session->channel, var)) {
15028  if (on) {
15030  } else {
15032  }
15033  }
15034 
15035  if (type == SWITCH_MEDIA_TYPE_VIDEO) {
15037  if (!on) {
15039  }
15040  }
15041 
15042  }
15043 
15044 }
#define switch_core_media_gen_key_frame(_session)
uint8_t switch_rtp_ready(switch_rtp_t *rtp_session)
Test if an RTP session is ready.
Definition: switch_rtp.c:5147
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
switch_media_handle_t * media_handle
switch_channel_t * channel
switch_rtp_t * rtp_session
#define switch_core_session_request_video_refresh(_s)
Definition: switch_core.h:2881
static int switch_channel_var_true(switch_channel_t *channel, const char *variable)
void switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag)
Clear an RTP Flag.
Definition: switch_rtp.c:5431
void switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag)
Set an RTP Flag.
Definition: switch_rtp.c:5372
switch_rtp_engine_t engines[SWITCH_MEDIA_TYPE_TOTAL]
#define type2str(type)

◆ switch_core_session_perform_destroy()

void switch_core_session_perform_destroy ( _Inout_ switch_core_session_t **  session,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line 
)

◆ switch_core_session_perform_force_locate()

switch_core_session_t* switch_core_session_perform_force_locate ( const char *  uuid_str,
const char *  file,
const char *  func,
int  line 
)

Definition at line 152 of file switch_core_session.c.

References switch_core_session::channel, runtime, switch_core_session::rwlock, switch_runtime::session_hash_mutex, session_manager, switch_session_manager::session_table, SSF_DESTROYED, switch_channel_get_name(), SWITCH_CHANNEL_ID_LOG, switch_core_hash_find(), switch_core_session_get_uuid(), SWITCH_LOG_ERROR, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, and switch_thread_rwlock_tryrdlock().

153 {
154  switch_core_session_t *session = NULL;
155  switch_status_t status;
156 
157  if (uuid_str) {
159  if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) {
160  /* Acquire a read lock on the session */
161 
162  if (switch_test_flag(session, SSF_DESTROYED)) {
163  status = SWITCH_STATUS_FALSE;
164 #ifdef SWITCH_DEBUG_RWLOCKS
165  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, uuid_str, SWITCH_LOG_ERROR, "%s %s Read lock FAIL\n",
167 #endif
168  } else {
170 #ifdef SWITCH_DEBUG_RWLOCKS
171  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, uuid_str, SWITCH_LOG_ERROR, "%s %s Read lock ACQUIRED\n",
173 #endif
174  }
175 
176  if (status != SWITCH_STATUS_SUCCESS) {
177  /* not available, forget it */
178  session = NULL;
179  }
180  }
182  }
183 
184  /* if its not NULL, now it's up to you to rwunlock this */
185  return session;
186 }
struct switch_session_manager session_manager
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_channel_t * channel
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_status_t switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:255
switch_mutex_t * session_hash_mutex
switch_status_t
Common return values.
switch_hash_t * session_table
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
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.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_thread_rwlock_t * rwlock
char * switch_core_session_get_uuid(switch_core_session_t *session)

◆ switch_core_session_perform_get_partner()

switch_status_t switch_core_session_perform_get_partner ( switch_core_session_t session,
switch_core_session_t **  partner,
const char *  file,
const char *  func,
int  line 
)

Get the session's partner (the session its bridged to)

Parameters
sessionThe session we're searching with
partner[out] The session's partner, or NULL if it wasnt found
Returns
SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if this session isn't bridged

Definition at line 189 of file switch_core_session.c.

References switch_core_session::channel, switch_channel_get_partner_uuid_copy(), switch_core_session_perform_locate(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and SWITCH_UUID_FORMATTED_LENGTH.

191 {
192  const char *uuid;
193  char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
194 
195  if ((uuid = switch_channel_get_partner_uuid_copy(session->channel, uuid_str, sizeof(uuid_str)))) {
196  if ((*partner = switch_core_session_perform_locate(uuid, file, func, line))) {
197  return SWITCH_STATUS_SUCCESS;
198  }
199  }
200 
201  *partner = NULL;
202  return SWITCH_STATUS_FALSE;
203 }
const char * switch_channel_get_partner_uuid_copy(switch_channel_t *channel, char *buf, switch_size_t blen)
switch_channel_t * channel
switch_core_session_t * switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line)
#define SWITCH_UUID_FORMATTED_LENGTH
Definition: switch_apr.h:545

◆ switch_core_session_perform_kill_channel()

switch_status_t switch_core_session_perform_kill_channel ( _In_ switch_core_session_t session,
const char *  file,
const char *  func,
int  line,
switch_signal_t  sig 
)

◆ switch_core_session_perform_locate()

switch_core_session_t* switch_core_session_perform_locate ( const char *  uuid_str,
const char *  file,
const char *  func,
int  line 
)

Definition at line 121 of file switch_core_session.c.

References runtime, switch_runtime::session_hash_mutex, session_manager, switch_session_manager::session_table, switch_core_hash_find(), switch_core_session_read_lock(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_perform_get_partner().

122 {
123  switch_core_session_t *session = NULL;
124 
125  if (uuid_str) {
127  if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) {
128  /* Acquire a read lock on the session */
129 #ifdef SWITCH_DEBUG_RWLOCKS
130  if (switch_core_session_perform_read_lock(session, file, func, line) != SWITCH_STATUS_SUCCESS) {
131 #if EMACS_CC_MODE_IS_BUGGY
132  }
133 #endif
134 #else
136 #endif
137  /* not available, forget it */
138  session = NULL;
139  }
140  }
142  }
143 
144  /* if its not NULL, now it's up to you to rwunlock this */
145  return session;
146 }
struct switch_session_manager session_manager
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_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
struct switch_runtime runtime
Definition: switch_core.c:86
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_mutex_t * session_hash_mutex
switch_hash_t * session_table

◆ switch_core_session_perform_receive_message()

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.

Parameters
sessionthe session to receive the message from
messagethe message to recieve
Returns
the status returned by the message handler

Referenced by send_ind(), switch_channel_perform_answer(), switch_channel_perform_pre_answer(), and switch_channel_perform_ring_ready_value().

◆ switch_core_session_private_event_count()

uint32_t switch_core_session_private_event_count ( _In_ switch_core_session_t session)

Indicate the number of waiting private events on a session.

Parameters
sessionthe session to check
Returns
the number of events

Referenced by audio_bridge_thread().

◆ switch_core_session_queue_event()

switch_status_t switch_core_session_queue_event ( _In_ switch_core_session_t session,
_Inout_ switch_event_t **  event 
)

Queue an event on a given session.

Parameters
sessionthe session to queue the message on
eventthe event to queue
Returns
the status returned by the message handler

Referenced by generate_on_dtmf(), speech_thread(), switch_channel_dequeue_dtmf(), switch_core_session_read_text_frame(), text_callback(), and tone_detect_callback().

◆ switch_core_session_queue_indication()

switch_status_t switch_core_session_queue_indication ( _In_ switch_core_session_t session,
_In_ switch_core_session_message_types_t  indication 
)

Queue an indication message on a session.

Parameters
sessionthe session to queue the message to
indicationthe indication message to queue
Returns
SWITCH_STATUS_SUCCESS if the message was queued

◆ switch_core_session_queue_message()

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.

Parameters
sessionthe session to queue the message to
messagethe message to queue
Returns
SWITCH_STATUS_SUCCESS if the message was queued

Referenced by check_stream_changes(), hanguphook(), send_display(), switch_channel_perform_audio_sync(), switch_channel_perform_video_sync(), and switch_core_media_negotiate_sdp().

◆ switch_core_session_queue_private_event()

switch_status_t switch_core_session_queue_private_event ( _In_ switch_core_session_t session,
_Inout_ switch_event_t **  event,
switch_bool_t  priority 
)

Queue a private event on a given session.

Parameters
sessionthe session to queue the message on
eventthe event to queue
priorityevent has high priority
Returns
the status returned by the message handler

Referenced by switch_ivr_broadcast().

◆ switch_core_session_queue_signal_data()

switch_status_t switch_core_session_queue_signal_data ( switch_core_session_t session,
void *  signal_data 
)

Definition at line 1131 of file switch_core_session.c.

References switch_core_session::signal_data_queue, switch_assert, switch_core_session_kill_channel, switch_core_session_wake_session_thread(), switch_queue_push(), SWITCH_SIG_BREAK, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

1132 {
1134 
1135  switch_assert(session != NULL);
1136 
1137  if (session->signal_data_queue) {
1138  if (switch_queue_push(session->signal_data_queue, signal_data) == SWITCH_STATUS_SUCCESS) {
1139  status = SWITCH_STATUS_SUCCESS;
1140  }
1141 
1143 
1145 
1146  }
1147 
1148  return status;
1149 }
switch_status_t switch_core_session_wake_session_thread(switch_core_session_t *session)
switch_queue_t * signal_data_queue
switch_status_t
Common return values.
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1253
#define switch_assert(expr)
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
Definition: switch_core.h:1393

◆ switch_core_session_raw_read()

void switch_core_session_raw_read ( switch_core_session_t session)

Definition at line 3128 of file switch_core_session.c.

References switch_slin_data::codec, memset(), switch_core_session::sdata, switch_core_codec_destroy(), switch_core_codec_ready(), switch_core_session_alloc, and switch_core_session_set_codec_slin().

Referenced by switch_ivr_session_echo().

3129 {
3130  if (session->sdata) {
3131  if (session->sdata && switch_core_codec_ready(&session->sdata->codec)) {
3133  }
3134  memset(session->sdata, 0, sizeof(*session->sdata));
3135  } else {
3136  session->sdata = switch_core_session_alloc(session, sizeof(*session->sdata));
3137  }
3138 
3139  switch_core_session_set_codec_slin(session, session->sdata);
3140 }
switch_status_t switch_core_session_set_codec_slin(switch_core_session_t *session, switch_slin_data_t *data)
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
switch_slin_data_t * sdata
memset(buf, 0, buflen)

◆ switch_core_session_read_frame()

switch_status_t switch_core_session_read_frame ( _In_ switch_core_session_t session,
switch_frame_t **  frame,
switch_io_flag_t  flags,
int  stream_id 
)

◆ switch_core_session_read_video_frame()

switch_status_t switch_core_session_read_video_frame ( _In_ switch_core_session_t session,
switch_frame_t **  frame,
switch_io_flag_t  flags,
int  stream_id 
)

Read a video frame from a session.

Parameters
sessionthe session to read from
framea NULL pointer to a frame to aim at the newly read frame
flagsI/O flags to modify behavior (i.e. non blocking)
stream_idwhich logical media channel to use
Returns
SWITCH_STATUS_SUCCESS a if the frame was read

Referenced by audio_bridge_thread(), switch_core_service_thread(), and text_bridge_thread().

◆ switch_core_session_receive_event()

switch_status_t switch_core_session_receive_event ( _In_ switch_core_session_t session,
_Inout_ switch_event_t **  event 
)

Send an event to a session translating it to it's native message format.

Parameters
sessionthe session to receive the event
eventthe event to receive
Returns
the status returned by the handler

Referenced by audio_bridge_thread(), and CoreSession::sendEvent().

◆ switch_core_session_recv_dtmf()

switch_status_t switch_core_session_recv_dtmf ( _In_ switch_core_session_t session,
const switch_dtmf_t dtmf 
)

RECV DTMF on a session.

Parameters
sessionsession to recv DTMF from
dtmfstring to recv from the session
Returns
SWITCH_STATUS_SUCCESS if the dtmf is ok to queue

Referenced by switch_channel_queue_dtmf().

◆ switch_core_session_reporting_state()

void switch_core_session_reporting_state ( switch_core_session_t session)

Definition at line 865 of file switch_core_state_machine.c.

References api_hook(), CF_NO_CDR, CF_REPORTING, switch_core_session::channel, switch_core_session::endpoint_interface, db_job::event, index, switch_endpoint_interface::state_handler, STATE_MACRO, SWITCH_API_REPORTING_HOOK_VARIABLE, switch_assert, switch_channel_cause2str(), switch_channel_event_set_data(), switch_channel_get_cause(), switch_channel_get_originatee_caller_profile(), switch_channel_get_originator_caller_profile(), switch_channel_get_state(), switch_channel_get_variable, switch_channel_set_flag, switch_channel_str2cause(), switch_channel_test_flag(), switch_core_session_strdup, switch_event_add_body(), switch_event_add_header_string(), SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE, switch_event_create, switch_event_fire, SWITCH_FALSE, switch_ivr_generate_xml_cdr(), SWITCH_PROCESS_CDR_VARIABLE, switch_safe_free, SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE, SWITCH_SKIP_CDR_CAUSES_VARIABLE, switch_split, SWITCH_STACK_BOTTOM, SWITCH_STATUS_SUCCESS, switch_true(), switch_xml_free(), switch_xml_toxml, and zstr.

Referenced by switch_core_session_run().

866 {
868  const switch_endpoint_interface_t *endpoint_interface;
869  const switch_state_handler_table_t *driver_state_handler = NULL;
870  const switch_state_handler_table_t *application_state_handler = NULL;
871  int proceed = 1;
872  int global_proceed = 1;
873  int do_extra_handlers = 1;
874  int silly = 0;
875  int index = 0;
877  const char *skip_var = switch_channel_get_variable(session->channel, SWITCH_SKIP_CDR_CAUSES_VARIABLE);
878  const char *hook_var;
879  int use_session = 0;
880  switch_event_t *event;
882 
884  return;
885  }
886 
888 
889  switch_assert(session != NULL);
890 
891  endpoint_interface = session->endpoint_interface;
892  switch_assert(endpoint_interface != NULL);
893 
894  driver_state_handler = endpoint_interface->state_handler;
895  switch_assert(driver_state_handler != NULL);
896 
897  if (!zstr(var)) {
898  if (!strcasecmp(var, "a_only")) {
900  do_extra_handlers = 0;
901  }
902  } else if (!strcasecmp(var, "b_only")) {
904  do_extra_handlers = 0;
905  }
906  } else if (!switch_true(var)) {
907  do_extra_handlers = 0;
908  }
909  }
910 
911 
912  if (!zstr(skip_var)) {
913  int x, ttl = 0;
914  char *list[128] = { 0 };
915  char *dup = switch_core_session_strdup(session, skip_var);
916 
917  ttl = switch_split(dup, '|', list);
918 
919  for(x = 0; x < ttl; x++) {
920  if (switch_channel_str2cause(list[x]) == cause) {
921  do_extra_handlers = 0;
922  break;
923  }
924  }
925  }
926 
927  if (switch_channel_test_flag(session->channel, CF_NO_CDR)) {
928  do_extra_handlers = 0;
929  }
930 
931 
932  STATE_MACRO(reporting, "REPORTING");
933 
935 
937  use_session = 1;
938  }
939 
940  api_hook(session, hook_var, use_session);
941  }
942 
945  switch_channel_event_set_data(session->channel, event);
946  if (switch_true(switch_channel_get_variable(session->channel, "hangup_complete_with_xml"))) {
947  switch_xml_t cdr = NULL;
948  char *xml_cdr_text;
949 
950  if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
951  xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
952  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CDR-Attached", "xml");
953  switch_event_add_body(event, "%s", xml_cdr_text);
954  switch_xml_free(cdr);
955  switch_safe_free(xml_cdr_text);
956  }
957  }
958  switch_event_fire(&event);
959  }
960 
961 
962 
963  return;
964 }
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_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
const char * switch_channel_cause2str(_In_ switch_call_cause_t cause)
return a cause string for a given cause
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.
#define switch_split(_data, _delim, _array)
Definition: switch_utils.h:375
Representation of an event.
Definition: switch_event.h:80
switch_status_t switch_event_add_body(switch_event_t *event, const char *fmt,...) PRINTF_FUNCTION(2
Add a body to an event.
A representation of an XML tree.
Definition: switch_xml.h:79
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
#define SWITCH_SKIP_CDR_CAUSES_VARIABLE
Definition: switch_types.h:180
#define zstr(x)
Definition: switch_utils.h:314
switch_caller_profile_t * switch_channel_get_originatee_caller_profile(switch_channel_t *channel)
Retrieve the given channel&#39;s originatee caller profile.
switch_state_handler_table_t * state_handler
#define SWITCH_PROCESS_CDR_VARIABLE
Definition: switch_types.h:179
switch_channel_t * channel
#define SWITCH_API_REPORTING_HOOK_VARIABLE
Definition: switch_types.h:177
#define switch_channel_get_variable(_c, _v)
int index
Definition: switch_cJSON.h:160
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
#define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE
Definition: switch_types.h:178
switch_call_cause_t switch_channel_str2cause(_In_ const char *str)
return a cause code for a given string
switch_call_cause_t
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
Definition: switch_event.h:384
#define switch_channel_set_flag(_c, _f)
static void api_hook(switch_core_session_t *session, const char *hook_var, int use_session)
#define STATE_MACRO(__STATE, __STATE_STR)
switch_endpoint_interface_t * endpoint_interface
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
#define switch_assert(expr)
switch_status_t switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr)
Generate an XML CDR report.
Definition: switch_ivr.c:2862
switch_call_cause_t switch_channel_get_cause(_In_ switch_channel_t *channel)
return the cause code for a given channel
#define switch_xml_toxml(xml, prn_header)
Converts an switch_xml structure back to xml in html format. Returns a string of html data that \ mus...
Definition: switch_xml.h:224
switch_caller_profile_t * switch_channel_get_originator_caller_profile(switch_channel_t *channel)
Retrieve the given channel&#39;s originator caller profile.

◆ switch_core_session_request_by_name()

switch_core_session_t* switch_core_session_request_by_name ( _In_z_ const char *  endpoint_name,
_In_ switch_call_direction_t  direction,
_Inout_ switch_memory_pool_t **  pool 
)

Allocate and return a new session from the core based on a given endpoint module name.

Parameters
endpoint_namethe name of the endpoint module
poolthe pool to use
Returns
the newly created session

◆ switch_core_session_request_uuid()

switch_core_session_t* switch_core_session_request_uuid ( _In_ switch_endpoint_interface_t endpoint_interface,
_In_ switch_call_direction_t  direction,
switch_originate_flag_t  originate_flags,
_Inout_opt_ switch_memory_pool_t **  pool,
_In_opt_z_ const char *  use_uuid 
)

Allocate and return a new session from the core.

Parameters
endpoint_interfacethe endpoint interface the session is to be based on
poolthe pool to use for the allocation (a new one will be used if NULL)
Returns
the newly created session

◆ switch_core_session_reset()

void switch_core_session_reset ( _In_ switch_core_session_t session,
switch_bool_t  flush_dtmf,
switch_bool_t  reset_read_codec 
)

◆ switch_core_session_send_dtmf()

switch_status_t switch_core_session_send_dtmf ( _In_ switch_core_session_t session,
const switch_dtmf_t dtmf 
)

Send DTMF to a session.

Parameters
sessionsession to send DTMF to
dtmfdtmf to send to the session
Returns
SWITCH_STATUS_SUCCESS if the dtmf was written

Referenced by audio_bridge_thread().

◆ switch_core_session_send_dtmf_string()

switch_status_t switch_core_session_send_dtmf_string ( switch_core_session_t session,
const char *  dtmf_string 
)

Send DTMF to a session.

Parameters
sessionsession to send DTMF to
dtmf_stringstring to send to the session
Returns
SWITCH_STATUS_SUCCESS if the dtmf was written

Definition at line 1121 of file switch_core_io.c.

References switch_codec_implementation::actual_samples_per_second, switch_core_session::channel, switch_dtmf_t::digit, DTMF_FLAG_SKIP_PROCESS, switch_dtmf_t::duration, switch_dtmf_t::flags, is_dtmf, string, switch_assert, switch_channel_down, switch_channel_get_name(), switch_channel_pre_answer, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable, switch_core_default_dtmf_duration(), switch_core_max_dtmf_duration(), switch_core_min_dtmf_duration(), switch_core_session_get_write_impl(), switch_core_session_send_dtmf(), switch_core_session_strdup, SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_LOG_WARNING, switch_separate_string(), switch_snprintf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.

1122 {
1123  char *p;
1125  int sent = 0, dur;
1126  char *string;
1127  int i, argc;
1128  char *argv[256];
1129  int dur_total = 0;
1130  int rate_mult = 8;
1131 
1132  switch_codec_implementation_t write_impl = { 0 };
1133 
1134  switch_assert(session != NULL);
1135 
1136  if (zstr(dtmf_string)) {
1137  return SWITCH_STATUS_FALSE;
1138  }
1139 
1140  if (*dtmf_string == '~') {
1141  dtmf_string++;
1142  dtmf.flags = 0;
1143  }
1144 
1145  if (switch_channel_down(session->channel)) {
1146  return SWITCH_STATUS_FALSE;
1147  }
1148 
1149 
1150  if (strlen(dtmf_string) > 99) {
1151  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Attempt to send very large dtmf string ignored!\n");
1152  return SWITCH_STATUS_FALSE;
1153  }
1154 
1155  string = switch_core_session_strdup(session, dtmf_string);
1156  argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
1157 
1158  if (argc) {
1160  }
1161 
1162  switch_core_session_get_write_impl(session, &write_impl);
1163 
1164  if (write_impl.actual_samples_per_second >= 1000) {
1165  rate_mult = (write_impl.actual_samples_per_second / 1000);
1166  }
1167 
1168  for (i = 0; i < argc; i++) {
1170  dur = switch_core_default_dtmf_duration(0) / rate_mult;
1171  if ((p = strchr(argv[i], '@'))) {
1172  *p++ = '\0';
1173  if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / rate_mult) {
1174  dtmf.duration = dur * rate_mult;
1175  }
1176  }
1177 
1178 
1179  for (p = argv[i]; p && *p; p++) {
1180  if (is_dtmf(*p)) {
1181  dtmf.digit = *p;
1182 
1183  if (dtmf.digit != 'w' && dtmf.digit != 'W') {
1184  if (dtmf.duration > switch_core_max_dtmf_duration(0)) {
1185  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n",
1186  switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
1188  } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) {
1189  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n",
1190  switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
1192  }
1193  }
1194 
1195  if (!dtmf.duration) {
1197  }
1198 
1199 
1200  if (switch_core_session_send_dtmf(session, &dtmf) == SWITCH_STATUS_SUCCESS) {
1201  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
1202  switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
1203  sent++;
1204  dur_total += dtmf.duration + (250 * rate_mult); /* account for 250ms pause */
1205  }
1206  }
1207  }
1208 
1209  if (dur_total) {
1210  char tmp[32] = "";
1211  switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / rate_mult);
1212  switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
1213  }
1214 
1215  }
1217 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
uint32_t duration
Definition: switch_types.h:298
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define zstr(x)
Definition: switch_utils.h:314
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1704
#define is_dtmf(key)
determine if a character is a valid DTMF key
Definition: switch_utils.h:683
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1744
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_channel_t * channel
const char *const string
Definition: switch_cJSON.h:162
switch_status_t switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1721
#define switch_channel_down(_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.
A table of settings and callbacks that define a paticular implementation of a codec.
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
switch_status_t switch_core_session_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
#define switch_assert(expr)
#define switch_channel_set_variable(_channel, _var, _val)
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.

◆ switch_core_session_set_codec_slin()

switch_status_t switch_core_session_set_codec_slin ( switch_core_session_t session,
switch_slin_data_t data 
)

Definition at line 87 of file switch_core_session.c.

References switch_codec_implementation::actual_samples_per_second, switch_frame::buflen, switch_frame::codec, switch_slin_data::codec, switch_frame::data, switch_frame::datalen, switch_slin_data::frame_data, memset(), switch_codec_implementation::microseconds_per_packet, switch_codec_implementation::number_of_channels, switch_slin_data::session, SWITCH_CHANNEL_SESSION_LOG, SWITCH_CODEC_FLAG_DECODE, SWITCH_CODEC_FLAG_ENCODE, switch_core_codec_init, switch_core_session_get_read_impl(), switch_core_session_set_read_codec(), SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_slin_data::write_frame.

Referenced by switch_core_session_raw_read().

89 {
90  switch_codec_implementation_t read_impl = { 0 };
91  int interval;
92 
93  switch_core_session_get_read_impl(session, &read_impl);
94  interval = read_impl.microseconds_per_packet / 1000;
95  data->session = session;
96 
97  if (switch_core_codec_init(&data->codec,
98  "L16",
99  NULL,
100  NULL,
101  read_impl.actual_samples_per_second,
102  interval,
105  SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %dms\n", read_impl.actual_samples_per_second, interval);
106 
107  memset(&data->write_frame, 0, sizeof(data->write_frame));
108 
109  data->write_frame.codec = &data->codec;
110  data->write_frame.data = data->frame_data;
111  data->write_frame.buflen = sizeof(data->frame_data);
112  data->write_frame.datalen = 0;
113  switch_core_session_set_read_codec(session, &data->codec);
114  return SWITCH_STATUS_SUCCESS;
115  }
116 
117  return SWITCH_STATUS_FALSE;
118 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_status_t switch_core_session_set_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the read codec to a given session.
switch_core_session_t * session
switch_codec_t * codec
Definition: switch_frame.h:56
switch_status_t switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
uint32_t buflen
Definition: switch_frame.h:70
uint32_t datalen
Definition: switch_frame.h:68
#define switch_core_codec_init(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool)
Initialize a codec handle.
Definition: switch_core.h:1693
char frame_data[SWITCH_RECOMMENDED_BUFFER_SIZE]
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.
A table of settings and callbacks that define a paticular implementation of a codec.
memset(buf, 0, buflen)

◆ switch_core_session_set_dmachine()

void switch_core_session_set_dmachine ( switch_core_session_t session,
switch_ivr_dmachine_t dmachine,
switch_digit_action_target_t  target 
)

Definition at line 44 of file switch_core_session.c.

References switch_core_session::dmachine, and switch_ivr_dmachine_set_target().

45 {
46  int i = (int) target;
47 
48  if (i == 0 || i == 1) {
49  if (dmachine) {
51  }
52  session->dmachine[i] = dmachine;
53  }
54 }
void switch_ivr_dmachine_set_target(switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target)
const cJSON *const target
switch_ivr_dmachine_t * dmachine[2]

◆ switch_core_session_set_external_id()

switch_status_t switch_core_session_set_external_id ( _In_ switch_core_session_t session,
_In_z_ const char *  use_external_id 
)

◆ switch_core_session_set_loglevel()

switch_status_t switch_core_session_set_loglevel ( switch_core_session_t session,
switch_log_level_t  loglevel 
)

Sets the log level for a session.

Parameters
sessionthe session to set the log level on
Returns
SWITCH_STATUS_SUCCESS

Definition at line 3109 of file switch_core_session.c.

References switch_core_session::loglevel, switch_assert, and SWITCH_STATUS_SUCCESS.

3110 {
3111  switch_assert(session != NULL);
3112  session->loglevel = loglevel;
3113  return SWITCH_STATUS_SUCCESS;
3114 }
switch_log_level_t loglevel
#define switch_assert(expr)

◆ switch_core_session_set_private_class()

switch_status_t switch_core_session_set_private_class ( _In_ switch_core_session_t session,
_In_ void *  private_info,
_In_ switch_pvt_class_t  index 
)

Add private user data to a session.

Parameters
sessionthe session to add used data to
private_infothe used data to add
Returns
SWITCH_STATUS_SUCCESS if data is added

◆ switch_core_session_set_read_impl()

switch_status_t switch_core_session_set_read_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 384 of file switch_core_codec.c.

References switch_core_session::read_impl, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_media_set_codec().

385 {
386  session->read_impl = *impp;
387  return SWITCH_STATUS_SUCCESS;
388 }
switch_codec_implementation_t read_impl

◆ switch_core_session_set_uuid()

switch_status_t switch_core_session_set_uuid ( _In_ switch_core_session_t session,
_In_z_ const char *  use_uuid 
)

◆ switch_core_session_set_video_read_impl()

switch_status_t switch_core_session_set_video_read_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 396 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS, and switch_core_session::video_read_impl.

397 {
398  session->video_read_impl = *impp;
399  return SWITCH_STATUS_SUCCESS;
400 }
switch_codec_implementation_t video_read_impl

◆ switch_core_session_set_video_write_impl()

switch_status_t switch_core_session_set_video_write_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 402 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS, and switch_core_session::video_write_impl.

403 {
404  session->video_write_impl = *impp;
405  return SWITCH_STATUS_SUCCESS;
406 }
switch_codec_implementation_t video_write_impl

◆ switch_core_session_set_write_impl()

switch_status_t switch_core_session_set_write_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 390 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS, and switch_core_session::write_impl.

Referenced by switch_core_media_set_codec().

391 {
392  session->write_impl = *impp;
393  return SWITCH_STATUS_SUCCESS;
394 }
switch_codec_implementation_t write_impl

◆ switch_core_session_signal_state_change()

void switch_core_session_signal_state_change ( _In_ switch_core_session_t session)

◆ switch_core_session_soft_lock()

void switch_core_session_soft_lock ( switch_core_session_t session,
uint32_t  sec 
)

Definition at line 77 of file switch_core_session.c.

References switch_core_session::soft_lock.

78 {
79  session->soft_lock = sec;
80 }

◆ switch_core_session_soft_unlock()

void switch_core_session_soft_unlock ( switch_core_session_t session)

Definition at line 82 of file switch_core_session.c.

References switch_core_session::soft_lock.

83 {
84  session->soft_lock = 0;
85 }

◆ switch_core_session_stack_count()

uint32_t switch_core_session_stack_count ( switch_core_session_t session,
int  x 
)

Definition at line 2992 of file switch_core_session.c.

References switch_core_session::stack_count, switch_core_session::stack_count_mutex, switch_mutex_lock(), and switch_mutex_unlock().

Referenced by switch_core_session_exec(), switch_core_session_execute_exten(), switch_ivr_parse_all_events(), and switch_ivr_parse_event().

2993 {
2994  uint32_t stack_count = 0;
2996  if (x > 0) session->stack_count++;
2997  else if (x < 0) session->stack_count--;
2998 
2999  stack_count = session->stack_count;
3001  return stack_count;
3002 }
switch_mutex_t * stack_count_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308

◆ switch_core_session_thread_launch()

switch_status_t switch_core_session_thread_launch ( _In_ switch_core_session_t session)

Launch the session thread (state machine) on a given session.

Parameters
sessionthe session to activate the state machine on
Returns
SWITCH_STATUS_SUCCESS if the thread was launched

Referenced by recover_callback(), switch_channel_perform_hangup(), and switch_ivr_originate().

◆ switch_core_session_thread_pool_launch()

switch_status_t switch_core_session_thread_pool_launch ( switch_core_session_t session)

Definition at line 1918 of file switch_core_session.c.

References check_queue(), switch_thread_data_s::func, switch_core_session::mutex, switch_thread_data_s::obj, session_manager, SSF_THREAD_RUNNING, SSF_THREAD_STARTED, SWITCH_CHANNEL_SESSION_LOG, switch_core_session_alloc, switch_core_session_thread(), SWITCH_LOG_CRIT, switch_log_printf(), switch_mutex_lock(), switch_mutex_unlock(), switch_queue_push(), switch_set_flag, SWITCH_STATUS_INUSE, switch_test_flag, and switch_session_manager::thread_queue.

Referenced by switch_core_session_thread_launch().

1919 {
1922 
1923  switch_mutex_lock(session->mutex);
1924  if (switch_test_flag(session, SSF_THREAD_RUNNING)) {
1925  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Cannot double-launch thread!\n");
1926  } else if (switch_test_flag(session, SSF_THREAD_STARTED)) {
1927  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Cannot launch thread again after it has already been run!\n");
1928  } else {
1931  td = switch_core_session_alloc(session, sizeof(*td));
1932  td->obj = session;
1935  check_queue();
1936  }
1937  switch_mutex_unlock(session->mutex);
1938 
1939  return status;
1940 }
struct switch_session_manager session_manager
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
switch_queue_t * thread_queue
static switch_status_t check_queue(void)
static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
switch_thread_start_t func
Definition: switch_core.h:67
switch_status_t
Common return values.
switch_mutex_t * mutex
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session&#39;s pool.
Definition: switch_core.h:696
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1253
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
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_core_session_transcoding()

switch_bool_t switch_core_session_transcoding ( switch_core_session_t session_a,
switch_core_session_t session_b,
switch_media_type_t  type 
)

Definition at line 14985 of file switch_core_media.c.

References CF_VIDEO_DECODED_READ, switch_core_session::channel, switch_codec_implementation::decoded_bytes_per_packet, switch_codec_implementation::impl_id, switch_channel_test_flag(), switch_core_session_get_read_impl(), SWITCH_FALSE, SWITCH_MEDIA_TYPE_AUDIO, and SWITCH_MEDIA_TYPE_VIDEO.

Referenced by audio_bridge_thread(), and text_bridge_thread().

14986 {
14987  switch_bool_t transcoding = SWITCH_FALSE;
14988 
14989  switch(type) {
14991  {
14992  switch_codec_implementation_t read_impl_a = { 0 }, read_impl_b = { 0 };
14993 
14994  switch_core_session_get_read_impl(session_a, &read_impl_a);
14995  switch_core_session_get_read_impl(session_b, &read_impl_b);
14996 
14997  if (read_impl_a.impl_id && read_impl_b.impl_id) {
14998  transcoding = (read_impl_a.impl_id != read_impl_b.impl_id || read_impl_a.decoded_bytes_per_packet != read_impl_b.decoded_bytes_per_packet);
14999  }
15000  }
15001  break;
15003  transcoding = (switch_channel_test_flag(session_a->channel, CF_VIDEO_DECODED_READ) ||
15005  break;
15006  default:
15007  break;
15008  }
15009 
15010  return transcoding;
15011 
15012 }
switch_bool_t
Definition: switch_types.h:437
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_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
switch_channel_t * channel
A table of settings and callbacks that define a paticular implementation of a codec.

◆ switch_core_session_try_reset()

switch_status_t switch_core_session_try_reset ( switch_core_session_t session,
switch_bool_t  flush_dtmf,
switch_bool_t  reset_read_codec 
)

Reset the buffers and resampler on a session, fail if can not lock codec mutexes.

Parameters
sessionthe session to reset
flush_dtmfflush all queued dtmf events too
Returns
SWITCH_STATUS_SUCCESS if the session was reset

Definition at line 1374 of file switch_core_session.c.

References switch_core_session::codec_read_mutex, switch_core_session::codec_write_mutex, switch_core_session_reset(), switch_mutex_trylock(), switch_mutex_unlock(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

1375 {
1377 
1380  switch_core_session_reset(session, flush_dtmf, reset_read_codec);
1382  status = SWITCH_STATUS_SUCCESS;
1383  }
1384 
1386  }
1387 
1388  return status;
1389 }
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
Definition: switch_apr.c:318
switch_mutex_t * codec_write_mutex
switch_mutex_t * codec_read_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
void switch_core_session_reset(switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
switch_status_t
Common return values.

◆ switch_core_session_video_reset()

void switch_core_session_video_reset ( switch_core_session_t session)

Definition at line 2713 of file switch_core_session.c.

References CF_VIDEO_BLANK, CF_VIDEO_DEBUG_READ, CF_VIDEO_DEBUG_WRITE, CF_VIDEO_ECHO, CF_VIDEO_PASSIVE, switch_core_session::channel, switch_channel_clear_flag(), and switch_core_session_request_video_refresh.

Referenced by audio_bridge_thread(), switch_core_media_set_video_file(), switch_core_media_start_engine_function(), switch_core_standard_on_execute(), and switch_ivr_session_echo().

2714 {
2717  //switch_channel_clear_flag(session->channel, CF_VIDEO_DECODED_READ);
2722 }
switch_channel_t * channel
#define switch_core_session_request_video_refresh(_s)
Definition: switch_core.h:2881
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.

◆ switch_core_session_wake_session_thread()

switch_status_t switch_core_session_wake_session_thread ( _In_ switch_core_session_t session)

◆ switch_core_session_write_encoded_video_frame()

switch_status_t switch_core_session_write_encoded_video_frame ( switch_core_session_t session,
switch_frame_t frame,
switch_io_flag_t  flags,
int  stream_id 
)

Definition at line 14658 of file switch_core_media.c.

References switch_core_session::endpoint_interface, switch_core_session::event_hooks, switch_endpoint_interface::io_routines, switch_io_event_hook_video_write_frame::next, SWITCH_CHANNEL_SESSION_LOG, switch_core_session_media_flow(), SWITCH_LOG_DEBUG3, switch_log_printf(), SWITCH_MEDIA_FLOW_INACTIVE, SWITCH_MEDIA_FLOW_RECVONLY, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_io_event_hook_video_write_frame::video_write_frame, and switch_io_routines::write_video_frame.

Referenced by switch_core_session_write_video_frame().

14660 {
14663 
14665  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG3, "Writing video to RECVONLY/INACTIVE session\n");
14666  return SWITCH_STATUS_SUCCESS;
14667  }
14668 
14670  if ((status = session->endpoint_interface->io_routines->write_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
14671  for (ptr = session->event_hooks.video_write_frame; ptr; ptr = ptr->next) {
14672  if ((status = ptr->video_write_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
14673  break;
14674  }
14675  }
14676  }
14677  }
14678 
14679  return status;
14680 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
Node in which to store custom video_write_frame channel callback hooks.
switch_io_routines_t * io_routines
switch_video_write_frame_hook_t video_write_frame
struct switch_io_event_hook_video_write_frame * next
switch_io_event_hooks_t event_hooks
switch_media_flow_t switch_core_session_media_flow(switch_core_session_t *session, switch_media_type_t type)
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.
switch_io_write_video_frame_t write_video_frame
switch_endpoint_interface_t * endpoint_interface

◆ switch_core_session_write_frame()

switch_status_t switch_core_session_write_frame ( _In_ switch_core_session_t session,
switch_frame_t frame,
switch_io_flag_t  flags,
int  stream_id 
)

Write a frame to a session.

Parameters
sessionthe session to write to
framethe frame to write
flagsI/O flags to modify behavior (i.e. non blocking)
stream_idwhich logical media channel to use
Returns
SWITCH_STATUS_SUCCESS a the frame was written

Referenced by audio_bridge_thread(), eavesdrop_callback(), switch_ivr_collect_digits_count(), switch_ivr_delay_echo(), switch_ivr_detect_audio(), switch_ivr_detect_silence(), switch_ivr_eavesdrop_session(), switch_ivr_gentones(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_play_file(), switch_ivr_record_file_event(), switch_ivr_session_echo(), switch_ivr_sleep(), switch_ivr_speak_text_handle(), switch_ivr_wait_for_answer(), switch_ivr_wait_for_silence(), and unicast_thread_run().

◆ switch_core_session_write_video_frame()

switch_status_t switch_core_session_write_video_frame ( _In_ switch_core_session_t session,
switch_frame_t frame,
switch_io_flag_t  flags,
int  stream_id 
)

Write a video frame to a session.

Parameters
sessionthe session to write to
framea pointer to a frame to write
flagsI/O flags to modify behavior (i.e. non blocking)
stream_idwhich logical media channel to use
Returns
SWITCH_STATUS_SUCCESS a if the frame was written

Referenced by audio_bridge_thread(), eavesdrop_callback(), and text_bridge_thread().

◆ switch_core_set_var_conditional()

switch_bool_t switch_core_set_var_conditional ( _In_z_ const char *  varname,
_In_opt_z_ const char *  value,
_In_opt_z_ const char *  val2 
)

Conditionally add a global variable to the core.

Parameters
varnamethe name of the variable
valuethe value of the variable
val2the value of the variable to verify against \ If the global did not exist and val2=="", add global with value, return true \ If the global exists with the value of val2, replace it, return true \ If the global exists with a value other than val2, return false

Referenced by globalSetVariable().

◆ switch_core_set_variable()

void switch_core_set_variable ( _In_z_ const char *  varname,
_In_opt_z_ const char *  value 
)

Add a global variable to the core.

Parameters
varnamethe name of the variable
valuethe value of the variable \ If value is NULL, then varname is deleted.

Referenced by fst_init_core_and_modload(), globalSetVariable(), preprocess(), preprocess_env_set(), preprocess_exec_set(), preprocess_stun_set(), setGlobalVariable(), and switch_nat_init().

◆ switch_core_thread_session_end()

void switch_core_thread_session_end ( _In_ switch_core_session_t session)

Signal a thread using a thread session to terminate.

Parameters
sessionthe session to indicate to

Referenced by switch_ivr_play_file(), and switch_ivr_speak_text().

◆ switch_ivr_dmachine_get_target()

switch_digit_action_target_t switch_ivr_dmachine_get_target ( switch_ivr_dmachine_t dmachine)

Definition at line 98 of file switch_ivr_async.c.

References switch_assert, and switch_ivr_dmachine::target.

99 {
100  switch_assert(dmachine);
101  return dmachine->target;
102 }
switch_digit_action_target_t target
#define switch_assert(expr)

◆ switch_ivr_dmachine_set_target()

void switch_ivr_dmachine_set_target ( switch_ivr_dmachine_t dmachine,
switch_digit_action_target_t  target 
)

Definition at line 104 of file switch_ivr_async.c.

References switch_assert, switch_ivr_dmachine::target, and target.

Referenced by switch_core_session_set_dmachine().

105 {
106  switch_assert(dmachine);
107  dmachine->target = target;
108 }
switch_digit_action_target_t target
const cJSON *const target
#define switch_assert(expr)

◆ switch_ivr_dmachine_set_terminators()

switch_status_t switch_ivr_dmachine_set_terminators ( switch_ivr_dmachine_t dmachine,
const char *  terminators 
)

Definition at line 201 of file switch_ivr_async.c.

References dm_binding_head_t::name, switch_ivr_dmachine::name, switch_ivr_dmachine::pool, switch_ivr_dmachine::realm, SWITCH_CHANNEL_LOG, switch_core_strdup, SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and dm_binding_head_t::terminators.

202 {
203  if (!dmachine->realm) {
204  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No realm selected.\n");
205  return SWITCH_STATUS_FALSE;
206  }
207 
208 
209  dmachine->realm->terminators = switch_core_strdup(dmachine->pool, terminators);
210  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digit parser %s: Setting terminators for realm '%s' to '%s'\n",
211  dmachine->name, dmachine->realm->name, terminators);
212 
213  return SWITCH_STATUS_SUCCESS;
214 }
#define SWITCH_CHANNEL_LOG
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:733
dm_binding_head_t * realm
switch_memory_pool_t * pool
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_thread_pool_launch_thread()

switch_status_t switch_thread_pool_launch_thread ( switch_thread_data_t **  tdp)

Definition at line 1893 of file switch_core_session.c.

References check_queue(), session_manager, switch_assert, switch_queue_push(), SWITCH_STATUS_SUCCESS, and switch_session_manager::thread_queue.

Referenced by switch_event_channel_broadcast(), switch_event_deliver_thread_pool(), switch_ivr_bg_media(), switch_sql_queue_manager_execute_sql_callback(), switch_sql_queue_manager_execute_sql_callback_err(), switch_sql_queue_manager_execute_sql_event_callback(), and switch_sql_queue_manager_execute_sql_event_callback_err().

1894 {
1897 
1898  switch_assert(tdp);
1899 
1900  td = *tdp;
1901  *tdp = NULL;
1902 
1904  check_queue();
1905 
1906  return status;
1907 }
struct switch_session_manager session_manager
switch_queue_t * thread_queue
static switch_status_t check_queue(void)
switch_status_t
Common return values.
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1253
#define switch_assert(expr)

◆ switch_thread_pool_wait()

switch_status_t switch_thread_pool_wait ( switch_thread_data_t td,
int  ms 
)

Definition at line 1909 of file switch_core_session.c.

References switch_thread_data_s::running, switch_cond_next(), SWITCH_STATUS_SUCCESS, and SWITCH_STATUS_TIMEOUT.

1910 {
1911  while(!td->running && --ms > 0) {
1912  switch_cond_next();
1913  }
1914 
1915  return ms > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TIMEOUT;
1916 }
void switch_cond_next(void)
Definition: switch_time.c:658