FreeSWITCH API Documentation  1.7.0
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_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)
 
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)
 
_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...
 
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)
 
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)
 
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...
 
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_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_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

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

Definition at line 1186 of file switch_core.h.

Referenced by switch_ivr_play_file(), and switch_ivr_speak_text().

#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 809 of file switch_core.h.

Referenced by switch_core_session_request_xml(), and switch_core_session_thread().

#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 1103 of file switch_core.h.

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

#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 925 of file switch_core.h.

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

#define switch_core_session_get_partner (   _session,
  _partner 
)    switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_core_session_get_private (   _s)    switch_core_session_get_private_class(_s, SWITCH_PVT_PRIMARY)

Definition at line 1132 of file switch_core.h.

#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 984 of file switch_core.h.

Referenced by switch_loadable_module_unprocess().

#define switch_core_session_kill_channel (   session,
  sig 
)    switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)
#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 916 of file switch_core.h.

Referenced by audio_bridge_thread(), check_channel_status(), fs_core_session_locate(), 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_var_ans(), 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_rtp_write_frame(), switch_rtp_zerocopy_read_frame(), SWITCH_STANDARD_SCHED_FUNC(), and uuid_bridge_on_soft_execute().

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

Definition at line 797 of file switch_core.h.

Referenced by switch_core_session_request_by_name().

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

Definition at line 1141 of file switch_core.h.

Enumeration Type Documentation

Enumerator
SHT_NONE 
SHT_UNANSWERED 
SHT_ANSWERED 

Definition at line 969 of file switch_core.h.

969  {
970  SHT_NONE = 0,
971  SHT_UNANSWERED = (1 << 0),
972  SHT_ANSWERED = (1 << 1)
switch_hup_type_t
Definition: switch_core.h:969

Function Documentation

void switch_core_dump_variables ( _In_ switch_stream_handle_t stream)
char* switch_core_get_domain ( switch_bool_t  dup)

Definition at line 355 of file switch_core.c.

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

356 {
357  char *domain;
358  const char *var;
359 
361  if (!(var = switch_core_get_variable("domain"))) {
362  var = "freeswitch.local";
363  }
364  if (dup) {
365  domain = strdup(var);
366  } else {
367  domain = (char *) var;
368  }
370 
371  return domain;
372 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
switch_thread_rwlock_t * global_var_rwlock
struct switch_runtime runtime
Definition: switch_core.c:64
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:227
char * switch_core_get_variable(const char *varname)
Definition: switch_core.c:383
const char* switch_core_get_hostname ( void  )
const char* switch_core_get_switchname ( void  )
char* switch_core_get_uuid ( void  )

Retrieve the unique identifier from the core.

Returns
a string representing the uuid

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

483 {
484  return runtime.uuid_str;
485 }
struct switch_runtime runtime
Definition: switch_core.c:64
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
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(), and switch_rtp_add_crypto_key().

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 
)
switch_status_t switch_core_get_variables ( switch_event_t **  event)

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

375 {
376  switch_status_t status;
378  status = switch_event_dup(event, runtime.global_vars);
380  return status;
381 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
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:64
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:227
switch_status_t
Common return values.
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
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
uint32_t switch_core_session_count ( void  )

Provide the total number of sessions.

Returns
the total number of allocated sessions

Definition at line 2360 of file switch_core_session.c.

References switch_session_manager::session_count, and session_manager.

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

2361 {
2363 }
struct switch_session_manager session_manager
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(), switch_ivr_session_echo(), switch_ivr_sleep(), and switch_ivr_speak_text_handle().

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_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(), switch_ivr_parse_next_event(), and switch_ivr_speak_text_handle().

switch_status_t switch_core_session_dequeue_signal_data ( switch_core_session_t session,
void **  signal_data 
)

Definition at line 1079 of file switch_core_session.c.

References switch_assert, switch_queue_trypop(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by switch_ivr_parse_signal_data().

1080 {
1082  void *pop;
1083 
1084  switch_assert(session != NULL);
1085 
1086  if (session->signal_data_queue) {
1087  if ((status = (switch_status_t) switch_queue_trypop(session->signal_data_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
1088  *signal_data = pop;
1089  }
1090  }
1091 
1092  return status;
1093 }
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1140
switch_queue_t * signal_data_queue
switch_status_t
Common return values.
#define switch_assert(expr)
void switch_core_session_destroy_state ( switch_core_session_t session)

Definition at line 685 of file switch_core_state_machine.c.

References CCS_DOWN, CF_REDIRECT, CF_TRANSFER, CS_DESTROY, 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().

686 {
688  const switch_endpoint_interface_t *endpoint_interface;
689  const switch_state_handler_table_t *driver_state_handler = NULL;
690  const switch_state_handler_table_t *application_state_handler = NULL;
691  int proceed = 1;
692  int global_proceed = 1;
693  int do_extra_handlers = 1;
694  int silly = 0;
695  int index = 0;
696 
698 
699  switch_assert(session != NULL);
703 
704  endpoint_interface = session->endpoint_interface;
705  switch_assert(endpoint_interface != NULL);
706 
707  driver_state_handler = endpoint_interface->state_handler;
708  switch_assert(driver_state_handler != NULL);
709 
710  STATE_MACRO(destroy, "DESTROY");
711 
713 
714  return;
715 }
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
#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)
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_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_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_status_t switch_core_session_execute_application_async ( switch_core_session_t session,
const char *  app,
const char *  arg 
)

Definition at line 2514 of file switch_core_session.c.

References CF_BLOCK_BROADCAST_UNTIL_MEDIA, CF_PROXY_MODE, 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(), do_execute_on(), switch_core_session_execute_application_get_flags(), tone_detect_callback(), and tone_on_dtmf().

2515 {
2516  switch_event_t *execute_event;
2517  char *ap, *arp;
2518 
2519  if (!arg && strstr(app, "::")) {
2520  ap = switch_core_session_strdup(session, app);
2521  app = ap;
2522 
2523  if ((arp = strstr(ap, "::"))) {
2524  *arp = '\0';
2525  arg = arp + 2;
2526  }
2527  }
2528 
2530  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
2531  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", app);
2532 
2533  if (arg) {
2534  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
2535  }
2536 
2539  }
2540 
2541  switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
2542  switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
2543 
2544  return SWITCH_STATUS_SUCCESS;
2545  }
2546 
2547  return SWITCH_STATUS_FALSE;
2548 }
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:383
#define switch_channel_set_flag(_c, _f)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
switch_status_t switch_core_session_queue_private_event(switch_core_session_t *session, switch_event_t **event, switch_bool_t priority)
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_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_console_callback_match_t* switch_core_session_findall ( void  )

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

391 {
393  void *val;
394  switch_core_session_t *session;
395  switch_console_callback_match_t *my_matches = NULL;
396 
399  switch_core_hash_this(hi, NULL, NULL, &val);
400  if (val) {
401  session = (switch_core_session_t *) val;
403  switch_console_push_match(&my_matches, session->uuid_str);
405  }
406  }
407  }
409 
410  return my_matches;
411 }
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:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
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:1501
switch_console_callback_match_t* switch_core_session_findall_matching_var ( const char *  var_name,
const char *  var_val 
)

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

263 {
265  void *val;
266  switch_core_session_t *session;
268  struct str_node *head = NULL, *np;
269  switch_console_callback_match_t *my_matches = NULL;
270  const char *like = NULL;
271 
272  if (var_val && *var_val == '~') {
273  like = var_val + 1;
274  }
275 
277 
280  switch_core_hash_this(hi, NULL, NULL, &val);
281  if (val) {
282  session = (switch_core_session_t *) val;
284  np = switch_core_alloc(pool, sizeof(*np));
285  np->str = switch_core_strdup(pool, session->uuid_str);
286  np->next = head;
287  head = np;
289  }
290  }
291  }
293 
294  for(np = head; np; np = np->next) {
295  if ((session = switch_core_session_locate(np->str))) {
296  const char *this_val;
297  if (switch_channel_up_nosig(session->channel) &&
298  (this_val = switch_channel_get_variable_dup(session->channel, var_name, SWITCH_FALSE, -1)) &&
299  (!var_val || (like && switch_stristr(like, var_val)) || !strcmp(this_val, var_val))) {
300  switch_console_push_match(&my_matches, (const char *) np->str);
301  }
303  }
304  }
305 
307 
308 
309  return my_matches;
310 }
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
Definition: switch_core.h:631
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:729
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:640
switch_memory_pool_t * pool
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:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_channel_t * channel
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
void switch_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's uuid.
Definition: switch_core.h:916
struct apr_pool_t switch_memory_pool_t
const char * switch_stristr(const char *instr, const char *str)
#define switch_channel_up_nosig(_channel)
#define switch_core_hash_first(_h)
Definition: switch_core.h:1501
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
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 1276 of file switch_core_session.c.

References check_media, switch_event_destroy(), switch_queue_trypop(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_perform_destroy(), and switch_ivr_parse_event().

1277 {
1279  int x = 0;
1280  void *pop;
1281 
1282  if (session->private_event_queue) {
1283  while ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue_pri, &pop)) == SWITCH_STATUS_SUCCESS) {
1284  if (pop) {
1285  switch_event_t *event = (switch_event_t *) pop;
1286  switch_event_destroy(&event);
1287  }
1288  x++;
1289  }
1290  while ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
1291  if (pop) {
1292  switch_event_t *event = (switch_event_t *) pop;
1293  switch_event_destroy(&event);
1294  }
1295  x++;
1296  }
1297  check_media(session);
1298  }
1299 
1300  return x;
1301 }
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:1140
switch_queue_t * private_event_queue
switch_queue_t * private_event_queue_pri
switch_status_t
Common return values.
#define check_media(session)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
void switch_core_session_free_message ( switch_core_session_message_t **  message)

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

997 {
998  switch_core_session_message_t *to_free = *message;
999  int i;
1000  char *s;
1001 
1002  *message = NULL;
1003 
1004  if (switch_test_flag(to_free, SCSMF_DYNAMIC)) {
1005  s = (char *) to_free->string_arg;
1006  switch_safe_free(s);
1007  switch_safe_free(to_free->pointer_arg);
1008 
1009  for (i = 0; i < MESSAGE_STRING_ARG_MAX; i++) {
1010  s = (char *) to_free->string_array_arg[i];
1011  switch_safe_free(s);
1012  }
1013 
1014  switch_safe_free(to_free);
1015  }
1016 }
#define MESSAGE_STRING_ARG_MAX
Definition: switch_core.h:175
const char * string_array_arg[MESSAGE_STRING_ARG_MAX]
Definition: switch_core.h:209
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:177
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
switch_status_t switch_core_session_get_app_flags ( const char *  app,
int32_t *  flags 
)

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

2490 {
2491  switch_application_interface_t *application_interface;
2493 
2494  switch_assert(flags);
2495 
2496  *flags = 0;
2497 
2498  if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
2499  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app);
2500  goto end;
2501  } else if (application_interface->flags) {
2502  *flags = application_interface->flags;
2503  status = SWITCH_STATUS_SUCCESS;
2504  }
2505 
2506  UNPROTECT_INTERFACE(application_interface);
2507 
2508  end:
2509 
2510  return status;
2511 
2512 }
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'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_app_log_t* switch_core_session_get_app_log ( _In_ switch_core_session_t session)
_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 audio_bridge_on_consume_media(), audio_bridge_on_exchange_media(), audio_bridge_on_routing(), audio_bridge_thread(), block_on_dtmf(), bridge(), check_channel_status(), cleanup_proxy_mode_a(), cleanup_proxy_mode_b(), collect_thread_run(), CoreSession::CoreSession(), CoreSession::destroy(), 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(), generate_on_dtmf(), 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(), read_displace_callback(), read_rtp_packet(), record_callback(), 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_on_dtmf(), speech_thread(), switch_channel_check_zrtp(), 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_core_media_activate_rtp(), switch_core_media_bug_transfer_recordings(), switch_core_media_build_crypto(), switch_core_media_copy_t38_options(), switch_core_media_find_zrtp_hash(), switch_core_media_negotiate_sdp(), switch_core_media_pass_zrtp_hash(), switch_core_media_process_sdp_filter(), switch_core_media_receive_message(), 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_request_video_refresh(), 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_broadcast(), 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_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_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_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_detect_speech(), switch_ivr_play_file(), switch_ivr_preprocess_session(), switch_ivr_process_indications(), switch_ivr_read(), switch_ivr_record_file(), switch_ivr_record_session(), switch_ivr_record_session_mask(), 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_play_and_get_digits(), switch_process_import(), switch_regex_set_var_callback(), switch_rtp_activate_jitter_buffer(), switch_rtp_add_crypto_key(), switch_rtp_break(), switch_rtp_create(), switch_rtp_enable_vad(), switch_rtp_set_flag(), switch_rtp_set_flags(), switch_rtp_set_local_address(), switch_rtp_sync_stats(), switch_rtp_write_frame(), switch_rtp_zerocopy_read_frame(), SWITCH_STANDARD_SCHED_FUNC(), 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_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.

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 }
switch_ivr_dmachine_t * dmachine[2]
switch_size_t switch_core_session_get_id ( _In_ switch_core_session_t session)
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.

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_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 2921 of file switch_core_session.c.

References switch_assert.

2922 {
2923  switch_assert(session != NULL);
2924  return session->loglevel;
2925 }
switch_log_level_t loglevel
#define switch_assert(expr)
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 1361 of file switch_core_session.c.

Referenced by careful_set().

1362 {
1363  return session->mutex;
1364 }
switch_mutex_t * mutex
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
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
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
char* switch_core_session_get_uuid ( _In_ switch_core_session_t session)
void switch_core_session_hangup_state ( switch_core_session_t session,
switch_bool_t  force 
)

Definition at line 758 of file switch_core_state_machine.c.

References api_hook(), CCS_HANGUP, CF_EARLY_HANGUP, 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(), and switch_true().

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

759 {
762  int proceed = 1;
763  int global_proceed = 1;
764  int do_extra_handlers = 1;
765  int silly = 0;
766  int index = 0;
767  switch_channel_state_t state = switch_channel_get_state(session->channel), midstate = state;
768  const switch_endpoint_interface_t *endpoint_interface;
769  const switch_state_handler_table_t *driver_state_handler = NULL;
770  const switch_state_handler_table_t *application_state_handler = NULL;
771  const char *hook_var;
772  int use_session = 0;
773 
774  if (!force) {
776  return;
777  }
778 
779  if (switch_thread_self() != session->thread_id) {
780  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s thread mismatch skipping state handler.\n",
781  switch_channel_get_name(session->channel));
782  return;
783  }
784  }
785 
786  if (switch_test_flag(session, SSF_HANGUP)) {
787  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s handler already called, skipping state handler.\n",
788  switch_channel_get_name(session->channel));
789  return;
790  }
791 
792  endpoint_interface = session->endpoint_interface;
793  switch_assert(endpoint_interface != NULL);
794 
795  driver_state_handler = endpoint_interface->state_handler;
796  switch_assert(driver_state_handler != NULL);
797 
799 
801 
803 
804  switch_channel_set_variable(session->channel, "hangup_cause", switch_channel_cause2str(cause));
805  switch_channel_set_variable_printf(session->channel, "hangup_cause_q850", "%d", cause_q850);
806  //switch_channel_presence(session->channel, "unknown", switch_channel_cause2str(cause), NULL);
807 
810 
811  STATE_MACRO(hangup, "HANGUP");
812 
814 
816 
818  use_session = 1;
819  }
820 
821  api_hook(session, hook_var, use_session);
822  }
823 
825 
826  switch_set_flag(session, SSF_HANGUP);
827 
828 }
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.
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:631
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:64
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_state_handler_table_t * state_handler
switch_channel_t * channel
#define switch_channel_get_variable(_c, _v)
#define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE
Definition: switch_types.h:176
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:404
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:624
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:79
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:174
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
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().

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

313 {
315  void *val;
316  switch_core_session_t *session;
318  struct str_node *head = NULL, *np;
319 
321 
324  switch_core_hash_this(hi, NULL, NULL, &val);
325  if (val) {
326  session = (switch_core_session_t *) val;
328  if (session->endpoint_interface == endpoint_interface) {
329  np = switch_core_alloc(pool, sizeof(*np));
330  np->str = switch_core_strdup(pool, session->uuid_str);
331  np->next = head;
332  head = np;
333  }
335  }
336  }
337  }
339 
340  for(np = head; np; np = np->next) {
341  if ((session = switch_core_session_locate(np->str))) {
342  switch_channel_hangup(session->channel, cause);
344  }
345  }
346 
348 
349 }
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
Definition: switch_core.h:631
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:729
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:640
switch_memory_pool_t * pool
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:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_channel_t * channel
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
Definition: switch_core.h:682
void switch_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's uuid.
Definition: switch_core.h:916
struct apr_pool_t switch_memory_pool_t
switch_endpoint_interface_t * endpoint_interface
#define switch_core_hash_first(_h)
Definition: switch_core.h:1501
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_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 2378 of file switch_core_session.c.

References switch_session_manager::session_id, and session_manager.

Referenced by send_heartbeat().

2379 {
2380  return session_manager.session_id;
2381 }
struct switch_session_manager session_manager
switch_size_t switch_core_session_id_dec ( void  )

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

2371 {
2375  return session_manager.session_id;
2376 }
struct switch_session_manager session_manager
struct switch_runtime runtime
Definition: switch_core.c:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * session_hash_mutex
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_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
uint32_t switch_core_session_messages_waiting ( switch_core_session_t session)

Definition at line 1151 of file switch_core_session.c.

References switch_queue_size().

Referenced by check_channel_status().

1152 {
1153  int x = 0;
1154 
1155  if (session->private_event_queue) {
1156  x += switch_queue_size(session->private_event_queue);
1157  }
1158 
1159  if (session->message_queue) {
1160  x += switch_queue_size(session->message_queue);
1161  }
1162 
1163  return x;
1164 }
unsigned int switch_queue_size(switch_queue_t *queue)
Definition: switch_apr.c:1114
switch_queue_t * private_event_queue
switch_queue_t * message_queue
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_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
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_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:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_channel_t * channel
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_status_t switch_thread_rwlock_tryrdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:232
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:624
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_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_channel_get_partner_uuid(), switch_core_session_perform_locate(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

191 {
192  const char *uuid;
193 
194  if ((uuid = switch_channel_get_partner_uuid(session->channel))) {
195  if ((*partner = switch_core_session_perform_locate(uuid, file, func, line))) {
196  return SWITCH_STATUS_SUCCESS;
197  }
198  }
199 
200  *partner = NULL;
201  return SWITCH_STATUS_FALSE;
202 }
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
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)
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_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:64
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_mutex_t * session_hash_mutex
switch_hash_t * session_table
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().

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_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(), and tone_detect_callback().

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_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 hanguphook(), send_display(), switch_channel_perform_audio_sync(), switch_channel_perform_video_sync(), and switch_core_media_negotiate_sdp().

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_status_t switch_core_session_queue_signal_data ( switch_core_session_t session,
void *  signal_data 
)

Definition at line 1059 of file switch_core_session.c.

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

1060 {
1062 
1063  switch_assert(session != NULL);
1064 
1065  if (session->signal_data_queue) {
1066  if (switch_queue_push(session->signal_data_queue, signal_data) == SWITCH_STATUS_SUCCESS) {
1067  status = SWITCH_STATUS_SUCCESS;
1068  }
1069 
1071 
1073 
1074  }
1075 
1076  return status;
1077 }
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:1129
#define switch_assert(expr)
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
Definition: switch_core.h:1352
void switch_core_session_raw_read ( switch_core_session_t session)

Definition at line 2933 of file switch_core_session.c.

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

2934 {
2935  if (session->sdata) {
2936  if (session->sdata && switch_core_codec_ready(&session->sdata->codec)) {
2938  }
2939  memset(session->sdata, 0, sizeof(*session->sdata));
2940  } else {
2941  session->sdata = switch_core_session_alloc(session, sizeof(*session->sdata));
2942  }
2943 
2944  switch_core_session_set_codec_slin(session, session->sdata);
2945 }
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's pool.
Definition: switch_core.h:694
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
switch_slin_data_t * sdata
memset(buf, 0, buflen)
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_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(), and switch_core_service_thread().

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

void switch_core_session_reporting_state ( switch_core_session_t session)

Definition at line 830 of file switch_core_state_machine.c.

References api_hook(), CF_NO_CDR, CF_REPORTING, db_job::event, 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().

831 {
832  switch_channel_state_t state = switch_channel_get_state(session->channel), midstate = state;
833  const switch_endpoint_interface_t *endpoint_interface;
834  const switch_state_handler_table_t *driver_state_handler = NULL;
835  const switch_state_handler_table_t *application_state_handler = NULL;
836  int proceed = 1;
837  int global_proceed = 1;
838  int do_extra_handlers = 1;
839  int silly = 0;
840  int index = 0;
842  const char *skip_var = switch_channel_get_variable(session->channel, SWITCH_SKIP_CDR_CAUSES_VARIABLE);
843  const char *hook_var;
844  int use_session = 0;
845  switch_event_t *event;
847 
849  return;
850  }
851 
853 
854  switch_assert(session != NULL);
855 
856  endpoint_interface = session->endpoint_interface;
857  switch_assert(endpoint_interface != NULL);
858 
859  driver_state_handler = endpoint_interface->state_handler;
860  switch_assert(driver_state_handler != NULL);
861 
862  if (!zstr(var)) {
863  if (!strcasecmp(var, "a_only")) {
865  do_extra_handlers = 0;
866  }
867  } else if (!strcasecmp(var, "b_only")) {
869  do_extra_handlers = 0;
870  }
871  } else if (!switch_true(var)) {
872  do_extra_handlers = 0;
873  }
874  }
875 
876 
877  if (!zstr(skip_var)) {
878  int x, ttl = 0;
879  char *list[128] = { 0 };
880  char *dup = switch_core_session_strdup(session, skip_var);
881 
882  ttl = switch_split(dup, '|', list);
883 
884  for(x = 0; x < ttl; x++) {
885  if (switch_channel_str2cause(list[x]) == cause) {
886  do_extra_handlers = 0;
887  break;
888  }
889  }
890  }
891 
892  if (switch_channel_test_flag(session->channel, CF_NO_CDR)) {
893  do_extra_handlers = 0;
894  }
895 
896 
897  STATE_MACRO(reporting, "REPORTING");
898 
900 
902  use_session = 1;
903  }
904 
905  api_hook(session, hook_var, use_session);
906  }
907 
910  switch_channel_event_set_data(session->channel, event);
911  if (switch_true(switch_channel_get_variable(session->channel, "hangup_complete_with_xml"))) {
912  switch_xml_t cdr = NULL;
913  char *xml_cdr_text;
914 
915  if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
916  xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
917  switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CDR-Attached", "xml");
918  switch_event_add_body(event, "%s", xml_cdr_text);
919  switch_xml_free(cdr);
920  switch_safe_free(xml_cdr_text);
921  }
922  }
923  switch_event_fire(&event);
924  }
925 
926 
927 
928  return;
929 }
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:412
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
char * switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header)
Converts an switch_xml structure back to xml in html format. Returns a string of html data that \ mus...
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:342
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:76
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
#define SWITCH_SKIP_CDR_CAUSES_VARIABLE
Definition: switch_types.h:178
#define zstr(x)
Definition: switch_utils.h:281
switch_caller_profile_t * switch_channel_get_originatee_caller_profile(switch_channel_t *channel)
Retrieve the given channel's originatee caller profile.
switch_state_handler_table_t * state_handler
#define SWITCH_PROCESS_CDR_VARIABLE
Definition: switch_types.h:177
switch_channel_t * channel
#define SWITCH_API_REPORTING_HOOK_VARIABLE
Definition: switch_types.h:175
#define switch_channel_get_variable(_c, _v)
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
#define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE
Definition: switch_types.h:176
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:383
#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's pool.
Definition: switch_core.h:717
#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:2713
switch_call_cause_t switch_channel_get_cause(_In_ switch_channel_t *channel)
return the cause code for a given channel
switch_caller_profile_t * switch_channel_get_originator_caller_profile(switch_channel_t *channel)
Retrieve the given channel's originator caller profile.
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_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
void switch_core_session_reset ( _In_ switch_core_session_t session,
switch_bool_t  flush_dtmf,
switch_bool_t  reset_read_codec 
)
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_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 1823 of file switch_core_io.c.

References switch_dtmf_t::digit, DTMF_FLAG_SKIP_PROCESS, switch_dtmf_t::duration, switch_dtmf_t::flags, is_dtmf, 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_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.

1824 {
1825  char *p;
1827  int sent = 0, dur;
1828  char *string;
1829  int i, argc;
1830  char *argv[256];
1831  int dur_total = 0;
1832 
1833  switch_assert(session != NULL);
1834 
1835  if (zstr(dtmf_string)) {
1836  return SWITCH_STATUS_FALSE;
1837  }
1838 
1839  if (*dtmf_string == '~') {
1840  dtmf_string++;
1841  dtmf.flags = 0;
1842  }
1843 
1844  if (switch_channel_down(session->channel)) {
1845  return SWITCH_STATUS_FALSE;
1846  }
1847 
1848 
1849  if (strlen(dtmf_string) > 99) {
1850  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Attempt to send very large dtmf string ignored!\n");
1851  return SWITCH_STATUS_FALSE;
1852  }
1853 
1854  string = switch_core_session_strdup(session, dtmf_string);
1855  argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
1856 
1857  if (argc) {
1859  }
1860 
1861  for (i = 0; i < argc; i++) {
1863  dur = switch_core_default_dtmf_duration(0) / 8;
1864  if ((p = strchr(argv[i], '@'))) {
1865  *p++ = '\0';
1866  if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / 8) {
1867  dtmf.duration = dur * 8;
1868  }
1869  }
1870 
1871 
1872  for (p = argv[i]; p && *p; p++) {
1873  if (is_dtmf(*p)) {
1874  dtmf.digit = *p;
1875 
1876  if (dtmf.digit != 'w' && dtmf.digit != 'W') {
1877  if (dtmf.duration > switch_core_max_dtmf_duration(0)) {
1878  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n",
1879  switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
1881  } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) {
1882  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n",
1883  switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
1885  }
1886  }
1887 
1888  if (!dtmf.duration) {
1890  }
1891 
1892 
1893  if (switch_core_session_send_dtmf(session, &dtmf) == SWITCH_STATUS_SUCCESS) {
1894  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
1895  switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
1896  sent++;
1897  dur_total += dtmf.duration + 2000; /* account for 250ms pause */
1898  }
1899  }
1900  }
1901 
1902  if (dur_total) {
1903  char tmp[32] = "";
1904  switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / 8);
1905  switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
1906  }
1907 
1908  }
1910 }
#define SWITCH_CHANNEL_SESSION_LOG(x)
uint32_t duration
Definition: switch_types.h:288
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
#define zstr(x)
Definition: switch_utils.h:281
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1664
#define is_dtmf(key)
determine if a character is a valid DTMF key
Definition: switch_utils.h:614
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1704
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
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1681
#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.
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
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_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, memset(), switch_codec_implementation::microseconds_per_packet, switch_codec_implementation::number_of_channels, 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, and SWITCH_STATUS_SUCCESS.

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:45
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:59
uint32_t datalen
Definition: switch_frame.h:57
#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:1602
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)
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_ivr_dmachine_set_target().

45 {
46  int i = (int) target;
47 
48  if (i == 0 || i == 1) {
49  if (dmachine) {
50  switch_ivr_dmachine_set_target(dmachine, target);
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)
switch_ivr_dmachine_t * dmachine[2]
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 2914 of file switch_core_session.c.

References switch_assert, and SWITCH_STATUS_SUCCESS.

2915 {
2916  switch_assert(session != NULL);
2917  session->loglevel = loglevel;
2918  return SWITCH_STATUS_SUCCESS;
2919 }
switch_log_level_t loglevel
#define switch_assert(expr)
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_status_t switch_core_session_set_read_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 376 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

Referenced by switch_core_media_set_codec().

377 {
378  session->read_impl = *impp;
379  return SWITCH_STATUS_SUCCESS;
380 }
switch_codec_implementation_t read_impl
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_video_read_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 388 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

389 {
390  session->video_read_impl = *impp;
391  return SWITCH_STATUS_SUCCESS;
392 }
switch_codec_implementation_t video_read_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 394 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

395 {
396  session->video_write_impl = *impp;
397  return SWITCH_STATUS_SUCCESS;
398 }
switch_codec_implementation_t video_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 382 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

Referenced by switch_core_media_set_codec().

383 {
384  session->write_impl = *impp;
385  return SWITCH_STATUS_SUCCESS;
386 }
switch_codec_implementation_t write_impl
void switch_core_session_signal_state_change ( _In_ switch_core_session_t session)
void switch_core_session_soft_lock ( switch_core_session_t session,
uint32_t  sec 
)

Definition at line 77 of file switch_core_session.c.

78 {
79  session->soft_lock = sec;
80 }
void switch_core_session_soft_unlock ( switch_core_session_t session)

Definition at line 82 of file switch_core_session.c.

83 {
84  session->soft_lock = 0;
85 }
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_status_t switch_core_session_thread_pool_launch ( switch_core_session_t session)

Definition at line 1809 of file switch_core_session.c.

References check_queue(), switch_thread_data_s::func, 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().

1810 {
1813 
1814  switch_mutex_lock(session->mutex);
1815  if (switch_test_flag(session, SSF_THREAD_RUNNING)) {
1816  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Cannot double-launch thread!\n");
1817  } else if (switch_test_flag(session, SSF_THREAD_STARTED)) {
1818  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Cannot launch thread again after it has already been run!\n");
1819  } else {
1822  td = switch_core_session_alloc(session, sizeof(*td));
1823  td->obj = session;
1826  check_queue();
1827  }
1828  switch_mutex_unlock(session->mutex);
1829 
1830  return status;
1831 }
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:631
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
switch_thread_start_t func
Definition: switch_core.h:66
switch_status_t
Common return values.
switch_mutex_t * mutex
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1129
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
void switch_core_session_video_reset ( switch_core_session_t session)

Definition at line 2550 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_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_video_function(), switch_core_standard_on_execute(), and switch_ivr_session_echo().

2551 {
2554  //switch_channel_clear_flag(session->channel, CF_VIDEO_DECODED_READ);
2559 }
switch_channel_t * channel
switch_status_t switch_core_session_request_video_refresh(switch_core_session_t *session)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
switch_status_t switch_core_session_wake_session_thread ( _In_ switch_core_session_t session)
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 11013 of file switch_core_media.c.

References 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_RECVONLY, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_io_event_hook_video_write_frame::video_write_frame.

Referenced by switch_core_session_write_video_frame().

11015 {
11018 
11020  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG3, "Writing video to RECVONLY session\n");
11021  return SWITCH_STATUS_SUCCESS;
11022  }
11023 
11025  if ((status = session->endpoint_interface->io_routines->write_video_frame(session, frame, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
11026  for (ptr = session->event_hooks.video_write_frame; ptr; ptr = ptr->next) {
11027  if ((status = ptr->video_write_frame(session, frame, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
11028  break;
11029  }
11030  }
11031  }
11032  }
11033 
11034  return status;
11035 }
#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_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(), switch_ivr_collect_digits_count(), switch_ivr_delay_echo(), switch_ivr_eavesdrop_session(), switch_ivr_gentones(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_play_file(), switch_ivr_record_file(), 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_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(), and eavesdrop_callback().

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

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 globalSetVariable(), preprocess(), preprocess_exec_set(), setGlobalVariable(), switch_nat_init(), and switch_rtp_init().

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_digit_action_target_t switch_ivr_dmachine_get_target ( switch_ivr_dmachine_t dmachine)

Definition at line 91 of file switch_ivr_async.c.

References switch_assert.

92 {
93  switch_assert(dmachine);
94  return dmachine->target;
95 }
switch_digit_action_target_t target
#define switch_assert(expr)
void switch_ivr_dmachine_set_target ( switch_ivr_dmachine_t dmachine,
switch_digit_action_target_t  target 
)

Definition at line 97 of file switch_ivr_async.c.

References switch_assert.

Referenced by switch_core_session_set_dmachine().

98 {
99  switch_assert(dmachine);
100  dmachine->target = target;
101 }
switch_digit_action_target_t target
#define switch_assert(expr)
switch_status_t switch_ivr_dmachine_set_terminators ( switch_ivr_dmachine_t dmachine,
const char *  terminators 
)

Definition at line 194 of file switch_ivr_async.c.

References SWITCH_CHANNEL_LOG, switch_core_strdup, SWITCH_LOG_DEBUG, SWITCH_LOG_ERROR, switch_log_printf(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

195 {
196  if (!dmachine->realm) {
197  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No realm selected.\n");
198  return SWITCH_STATUS_FALSE;
199  }
200 
201 
202  dmachine->realm->terminators = switch_core_strdup(dmachine->pool, terminators);
203  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digit parser %s: Setting terminators for realm '%s' to '%s'\n",
204  dmachine->name, dmachine->realm->name, terminators);
205 
206  return SWITCH_STATUS_SUCCESS;
207 }
#define SWITCH_CHANNEL_LOG
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
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_status_t switch_thread_pool_launch_thread ( switch_thread_data_t **  tdp)

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

1794 {
1797 
1798  switch_assert(tdp);
1799 
1800  td = *tdp;
1801  *tdp = NULL;
1802 
1804  check_queue();
1805 
1806  return status;
1807 }
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:1129
#define switch_assert(expr)