Session Creation / Management
[Core Library]

Collaboration diagram for Session Creation / Management:

Defines

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

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.
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.
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.
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.
switch_status_t switch_core_session_thread_launch (_In_ switch_core_session_t *session)
 Launch the session thread (state machine) on a given 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.
switch_status_t switch_core_session_wake_session_thread (_In_ switch_core_session_t *session)
 Signal a session's state machine thread that a state change has occured.
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.
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.
switch_log_level_t switch_core_session_get_loglevel (switch_core_session_t *session)
 Get the log level for a session.
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_core_session_set_codec_slin (switch_core_session_t *session, switch_slin_data_t *data)
char * switch_core_get_uuid (void)
 Retrieve the unique identifier from the core.
switch_core_session_tswitch_core_session_locate (_In_z_ const char *uuid_str)
 Locate a session based on it's uuid.
switch_core_session_tswitch_core_session_force_locate (_In_z_ const char *uuid_str)
 Locate a session based on it's uuid even if the channel is not ready.
char * switch_core_get_variable (_In_z_ const char *varname)
 Retrieve a global variable from the core.
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)
void switch_core_set_variable (_In_z_ const char *varname, _In_opt_z_ const char *value)
 Add a global variable to the core.
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.
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.
void switch_core_session_hupall_matching_var (_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause)
 Hangup all sessions which match a specific channel variable.
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.
switch_status_t switch_core_session_get_partner (switch_core_session_t *session, switch_core_session_t **partner)
 Get the session's partner (the session its bridged to).
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.
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.
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
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.
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.
switch_status_t switch_core_session_flush_message (_In_ switch_core_session_t *session)
 Flush a message queue on a given session.
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.
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.
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.
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.
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.
void * switch_core_session_get_private (_In_ switch_core_session_t *session)
 Retrieve private user data from a session.
switch_status_t switch_core_session_set_private (_In_ switch_core_session_t *session, _In_ void *private_info)
 Add private user data to a session.
int switch_core_session_add_stream (_In_ switch_core_session_t *session, _In_opt_ void *private_info)
 Add a logical stream to a session.
void * switch_core_session_get_stream (_In_ switch_core_session_t *session, _In_ int index)
 Retreive a logical stream from a session.
int switch_core_session_get_stream_count (_In_ switch_core_session_t *session)
 Determine the number of logical streams a session has.
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.
void switch_core_thread_session_end (_In_ switch_core_session_t *session)
 Signal a thread using a thread session to terminate.
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.
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.
switch_call_cause_t switch_core_session_resurrect_channel (_In_z_ const char *endpoint_name, _Inout_ switch_core_session_t **new_session, _Inout_ switch_memory_pool_t **pool, _In_ void *data)
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.
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.
uint32_t switch_core_session_event_count (_In_ switch_core_session_t *session)
 Indicate the number of waiting events on a session.
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.
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.
uint32_t switch_core_session_private_event_count (_In_ switch_core_session_t *session)
 Indicate the number of waiting private events on a session.
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.
uint32_t switch_core_session_flush_private_events (switch_core_session_t *session)
 Flush the private event queue of a session.
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.
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.
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.
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.
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.
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.
switch_status_t switch_core_session_send_dtmf_string (switch_core_session_t *session, const char *dtmf_string)
 Send DTMF to a session.
switch_status_t switch_core_session_recv_dtmf (_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf)
 RECV DTMF on a session.


Define Documentation

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

Definition at line 1011 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:
session pointer to a pointer of the session to destroy
Returns:

Definition at line 654 of file switch_core.h.

Referenced by 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:
session the current session
app the application's name
arg application arguments
Returns:
the application's return value

Definition at line 930 of file switch_core.h.

Referenced by do_execute_on(), exec_cb(), CoreSession::execute(), record_callback(), 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_kill_channel ( session,
sig   )     switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)

Send a signal to a channel.

Parameters:
session session to send signal to
sig signal to send
Returns:
status returned by the session's signal handler

Definition at line 1179 of file switch_core.h.

Referenced by audio_bridge_thread(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_core_session_perform_receive_message(), switch_core_session_queue_message(), switch_core_session_queue_private_event(), switch_core_session_queue_signal_data(), switch_core_session_receive_event(), switch_core_session_signal_state_change(), switch_core_thread_session_end(), and switch_ivr_parse_event().

#define switch_core_session_receive_message ( _session,
_message   ) 

Value:

switch_core_session_perform_receive_message(_session, _message, \
                                                                                                                                                                                                                        __FILE__, __SWITCH_FUNC__, __LINE__)

Definition at line 1046 of file switch_core.h.

Referenced by audio_bridge_thread(), display_exec_cb(), hanguphook(), signal_bridge_on_hibernate(), switch_channel_perform_audio_sync(), switch_core_session_exec(), switch_core_session_message_send(), switch_core_session_pass_indication(), switch_core_session_perform_receive_message(), switch_core_session_set_uuid(), switch_core_session_write_frame(), switch_core_standard_on_execute(), switch_ivr_blind_transfer_ack(), switch_ivr_eavesdrop_session(), switch_ivr_hold(), switch_ivr_media(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_parse_all_messages(), switch_ivr_parse_all_signal_data(), switch_ivr_session_transfer(), and switch_ivr_unhold().

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

Definition at line 642 of file switch_core.h.

Referenced by switch_core_session_request_by_name().


Function Documentation

void switch_core_dump_variables ( _In_ switch_stream_handle_t stream  ) 

const char* switch_core_get_hostname ( void   ) 

Definition at line 268 of file switch_core.c.

References switch_runtime::hostname, and runtime.

Referenced by switch_event_prep_for_delivery_detailed().

00269 {
00270         return runtime.hostname;
00271 }

const char* switch_core_get_switchname ( void   ) 

Definition at line 273 of file switch_core.c.

References switch_runtime::hostname, runtime, switch_runtime::switchname, and zstr.

Referenced by core_event_handler(), switch_console_complete(), switch_console_list_uuid(), switch_console_loop(), switch_console_set_alias(), switch_console_set_complete(), switch_core_add_registration(), switch_core_del_registration(), switch_core_expire_registration(), switch_core_sqldb_start(), and switch_event_prep_for_delivery_detailed().

00274 {
00275     if (!zstr(runtime.switchname)) return runtime.switchname;
00276         return runtime.hostname;
00277 }

char* switch_core_get_uuid ( void   ) 

Retrieve the unique identifier from the core.

Returns:
a string representing the uuid

Definition at line 375 of file switch_core.c.

References runtime, and switch_runtime::uuid_str.

Referenced by switch_event_prep_for_delivery_detailed().

00376 {
00377         return runtime.uuid_str;
00378 }

char* switch_core_get_variable ( _In_z_ const char *  varname  ) 

Retrieve a global variable from the core.

Parameters:
varname the name of the variable
Returns:
the value of the desired variable

Referenced by init_upnp(), and switch_ivr_originate().

char* switch_core_get_variable_dup ( _In_z_ const char *  varname  ) 

Referenced by expand_vars(), getGlobalVariable(), switch_core_init_and_modload(), switch_core_set_serial(), switch_event_expand_headers_check(), and switch_find_local_ip().

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

Referenced by switch_channel_get_variable_dup(), switch_core_perform_file_open(), and switch_rtp_init().

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:
session the 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:
session the session to add the stream to
private_info an 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 1943 of file switch_core_session.c.

References switch_session_manager::session_count, and session_manager.

Referenced by send_heartbeat(), and switch_core_session_ctl().

01944 {
01945         return session_manager.session_count;
01946 }

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:
session the session to de-queue the message on
event the de-queued event
force force 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:
session the session to de-queue the message on
message the 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:
session the session to de-queue the message on
event the 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 929 of file switch_core_session.c.

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

Referenced by switch_ivr_parse_all_signal_data().

00930 {
00931         switch_status_t status = SWITCH_STATUS_FALSE;
00932         void *pop;
00933 
00934         switch_assert(session != NULL);
00935 
00936         if (session->signal_data_queue && switch_queue_size(session->signal_data_queue)) {
00937                 if ((status = (switch_status_t) switch_queue_trypop(session->signal_data_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
00938                         *signal_data = pop;
00939                 }
00940         }
00941 
00942         return status;
00943 }

void switch_core_session_destroy_state ( switch_core_session_t session  ) 

Definition at line 502 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_flag(), switch_channel_set_callstate, and switch_channel_set_running_state.

Referenced by switch_core_session_perform_destroy().

00503 {
00504         switch_channel_state_t state = CS_DESTROY, midstate = CS_DESTROY;
00505         const switch_endpoint_interface_t *endpoint_interface;
00506         const switch_state_handler_table_t *driver_state_handler = NULL;
00507         const switch_state_handler_table_t *application_state_handler = NULL;
00508         int proceed = 1;
00509         int global_proceed = 1;
00510         int do_extra_handlers = 1;
00511         int silly = 0;
00512         int index = 0;
00513 
00514         switch_channel_set_callstate(session->channel, CCS_DOWN);
00515 
00516         switch_assert(session != NULL);
00517         switch_channel_set_running_state(session->channel, CS_DESTROY);
00518         switch_channel_clear_flag(session->channel, CF_TRANSFER);
00519         switch_channel_clear_flag(session->channel, CF_REDIRECT);
00520 
00521         endpoint_interface = session->endpoint_interface;
00522         switch_assert(endpoint_interface != NULL);
00523 
00524         driver_state_handler = endpoint_interface->state_handler;
00525         switch_assert(driver_state_handler != NULL);
00526 
00527         STATE_MACRO(destroy, "DESTROY");
00528 
00529         return;
00530 }

uint32_t switch_core_session_event_count ( _In_ switch_core_session_t session  ) 

Indicate the number of waiting events on a session.

Parameters:
session the 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_str the unique id of the session you want to send a message to
event the 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:
session the current session
application_interface the interface of the application to execute
arg application arguments
Warning:
Has to be called from the session's thread
Returns:
the application's return value

Referenced by collect_thread_run(), switch_core_session_execute_application_get_flags(), 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 2080 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(), and tone_on_dtmf().

02081 {
02082         switch_event_t *execute_event;
02083         char *ap, *arp;
02084         
02085         if (!arg && strstr(app, "::")) {
02086                 ap = switch_core_session_strdup(session, app);
02087                 app = ap;
02088 
02089                 if ((arp = strstr(ap, "::"))) {
02090                         *arp = '\0';
02091                         arg = arp + 2;
02092                 }
02093         }
02094         
02095         if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
02096                 switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
02097                 switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", app);
02098 
02099                 if (arg) {
02100                         switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
02101                 }
02102                 
02103                 if (!switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
02104                         switch_channel_set_flag(session->channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
02105                 }
02106 
02107                 switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
02108                 switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
02109                 
02110                 return SWITCH_STATUS_SUCCESS;
02111         }
02112 
02113         return SWITCH_STATUS_FALSE;
02114 }

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:
session the current session
app the application's name
arg application arguments
flags pointer 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:
session the current session
exten the interface of the application to execute
arg application 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_status_t switch_core_session_flush_message ( _In_ switch_core_session_t session  ) 

Flush a message queue on a given session.

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

Referenced by switch_core_session_reset().

uint32_t switch_core_session_flush_private_events ( switch_core_session_t session  ) 

Flush the private event queue of a session.

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

Definition at line 1127 of file switch_core_session.c.

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

Referenced by switch_ivr_parse_event().

01128 {
01129         switch_status_t status = SWITCH_STATUS_FALSE;
01130         int x = 0;
01131         void *pop;
01132 
01133         if (session->private_event_queue) {
01134                 while ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue_pri, &pop)) == SWITCH_STATUS_SUCCESS) {
01135                         x++;
01136                 }
01137                 while ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
01138                         x++;
01139                 }
01140                 check_media(session);
01141         }
01142 
01143         return x;
01144 }

switch_core_session_t* switch_core_session_force_locate ( _In_z_ const char *  uuid_str  ) 

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

Parameters:
uuid_str the 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()

Referenced by CoreSession::CoreSession().

void switch_core_session_free_message ( switch_core_session_message_t **  message  ) 

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

00846 {
00847         switch_core_session_message_t *to_free = *message;
00848         int i;
00849         char *s;
00850 
00851         *message = NULL;
00852 
00853         if (switch_test_flag(to_free, SCSMF_DYNAMIC)) {
00854                 s = (char *) to_free->string_arg;
00855                 switch_safe_free(s);
00856                 switch_safe_free(to_free->pointer_arg);
00857 
00858                 for (i = 0; i < MESSAGE_STRING_ARG_MAX; i++) {
00859                         s = (char *) to_free->string_array_arg[i];
00860                         switch_safe_free(s);
00861                 }
00862 
00863                 switch_safe_free(to_free);
00864         }
00865 }

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

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

02056 {
02057         switch_application_interface_t *application_interface;
02058         switch_status_t status = SWITCH_STATUS_FALSE;
02059 
02060         switch_assert(flags);
02061 
02062         *flags = 0;
02063 
02064         if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
02065                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app);
02066                 goto end;
02067         } else if (application_interface->flags) {
02068                 *flags = application_interface->flags;
02069                 status = SWITCH_STATUS_SUCCESS;
02070         }
02071 
02072         UNPROTECT_INTERFACE(application_interface);
02073 
02074   end:
02075 
02076         return status;
02077 
02078 }

switch_app_log_t* switch_core_session_get_app_log ( _In_ switch_core_session_t session  ) 

Referenced by switch_channel_set_timestamps(), switch_ivr_generate_json_cdr(), and switch_ivr_generate_xml_cdr().

_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:
session the 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(), dtmf_callback(), early_thread_run(), enterprise_originate_ringback_thread(), enterprise_originate_thread(), exec_cb(), CoreSession::flushDigits(), CoreSession::flushEvents(), 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(), hanguphook(), inband_dtmf_callback(), inband_dtmf_generate_callback(), inherit_codec(), 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(), record_callback(), rtp_common_read(), rtp_common_write(), sb_on_dtmf(), send_display(), session_audio_callback(), 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_bug_transfer_recordings(), switch_core_service_session_av(), switch_core_service_thread(), switch_core_session_dequeue_private_event(), switch_core_session_exec(), switch_core_session_execute_exten(), switch_core_session_outgoing_channel(), switch_core_session_pass_indication(), switch_core_session_private_event_count(), switch_core_session_request_xml(), switch_core_session_reset(), 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_thread_session_end(), 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_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_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_all_signal_data(), switch_ivr_parse_event(), 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_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(), 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_tone_detect_session(), switch_ivr_transfer_variable(), switch_ivr_unbind_dtmf_meta_session(), switch_ivr_unblock_dtmf_session(), switch_ivr_unhold(), switch_ivr_uuid_bridge(), switch_ivr_wait_for_answer(), switch_ivr_wait_for_silence(), switch_limit_incr(), switch_play_and_get_digits(), switch_process_import(), switch_regex_set_var_callback(), switch_rtp_add_crypto_key(), switch_rtp_create(), switch_rtp_enable_vad(), switch_rtp_write_frame(), switch_rtp_zerocopy_read_frame(), SWITCH_STANDARD_SCHED_FUNC(), tone_on_dtmf(), transfer_after_bridge(), uuid_bridge_on_hibernate(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), 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 54 of file switch_core_session.c.

Referenced by signal_bridge_on_hibernate().

00055 {
00056         int i = (int) target;
00057 
00058         if (i == 0 || i == 1) { 
00059                 return session->dmachine[i];
00060         }
00061 
00062         return NULL;
00063 }

switch_size_t switch_core_session_get_id ( _In_ switch_core_session_t session  ) 

switch_log_level_t switch_core_session_get_loglevel ( switch_core_session_t session  ) 

Get the log level for a session.

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

Definition at line 2454 of file switch_core_session.c.

References switch_assert.

02455 {
02456         switch_assert(session != NULL);
02457         return session->loglevel;
02458 }

switch_status_t switch_core_session_get_partner ( switch_core_session_t session,
switch_core_session_t **  partner 
)

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

Parameters:
session The 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 183 of file switch_core_session.c.

References switch_channel_get_variable, switch_core_session_locate(), SWITCH_SIGNAL_BOND_VARIABLE, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by cleanup_proxy_mode_a(), switch_channel_check_zrtp(), switch_channel_get_hold_music_partner(), switch_channel_mark_hold(), switch_core_media_bug_read(), and switch_ivr_record_session().

00184 {
00185         const char *uuid;
00186 
00187         if ((uuid = switch_channel_get_variable(session->channel, SWITCH_SIGNAL_BOND_VARIABLE)) || (uuid = switch_channel_get_variable(session->channel, "originate_signal_bond"))) {
00188                 if ((*partner = switch_core_session_locate(uuid))) {
00189                         return SWITCH_STATUS_SUCCESS;
00190                 }
00191         }
00192 
00193         *partner = NULL;
00194         return SWITCH_STATUS_FALSE;
00195 }

void* switch_core_session_get_private ( _In_ switch_core_session_t session  ) 

Retrieve private user data from a session.

Parameters:
session the 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:
session the session to add the stream to
index the 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:
session the session to query
Returns:
the total number of logical streams

char* switch_core_session_get_uuid ( _In_ switch_core_session_t session  ) 

Retrieve the unique identifier from a session.

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

Referenced by audio_bridge_thread(), bcast_thread(), cleanup_proxy_mode_b(), CoreSession::CoreSession(), meta_on_dtmf(), CoreSession::originate(), signal_bridge_on_hangup(), signal_bridge_on_hibernate(), switch_channel_event_set_basic_data(), switch_channel_get_uuid(), switch_channel_set_caller_profile(), switch_channel_set_name(), switch_core_session_force_locate(), switch_core_session_outgoing_channel(), switch_core_session_perform_destroy(), switch_core_session_perform_kill_channel(), switch_core_session_perform_receive_message(), switch_core_session_read_lock(), switch_core_session_read_lock_hangup(), switch_core_session_sched_heartbeat(), switch_core_standard_on_execute(), switch_core_standard_on_reset(), switch_core_standard_on_routing(), switch_ivr_enterprise_originate(), switch_ivr_intercept_session(), switch_ivr_multi_threaded_bridge(), switch_ivr_originate(), switch_ivr_signal_bridge(), switch_ivr_uuid_bridge(), switch_log_vprintf(), and uuid_bridge_on_soft_execute().

void switch_core_session_hangup_state ( switch_core_session_t session,
switch_bool_t  force 
)

Definition at line 573 of file switch_core_state_machine.c.

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

00574 {
00575         switch_call_cause_t cause = switch_channel_get_cause(session->channel);
00576         switch_call_cause_t cause_q850 = switch_channel_get_cause_q850(session->channel);
00577         int proceed = 1;
00578         int global_proceed = 1;
00579         int do_extra_handlers = 1;
00580         int silly = 0;
00581         int index = 0;
00582         switch_channel_state_t state = switch_channel_get_state(session->channel), midstate = state;
00583         const switch_endpoint_interface_t *endpoint_interface;
00584         const switch_state_handler_table_t *driver_state_handler = NULL;
00585         const switch_state_handler_table_t *application_state_handler = NULL;
00586         const char *hook_var;
00587         int use_session = 0;
00588 
00589         if (!force) {
00590                 if (!switch_channel_test_flag(session->channel, CF_EARLY_HANGUP) && !switch_test_flag((&runtime), SCF_EARLY_HANGUP)) {
00591                         return;
00592                 }
00593 
00594                 if (switch_thread_self() != session->thread_id) {
00595                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s thread mismatch skipping state handler.\n",
00596                                                           switch_channel_get_name(session->channel));
00597                         return;
00598                 }
00599         }
00600 
00601         if (switch_test_flag(session, SSF_HANGUP)) {
00602                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s handler already called, skipping state handler.\n",
00603                                                   switch_channel_get_name(session->channel));
00604                 return;
00605         }
00606 
00607         endpoint_interface = session->endpoint_interface;
00608         switch_assert(endpoint_interface != NULL);
00609 
00610         driver_state_handler = endpoint_interface->state_handler;
00611         switch_assert(driver_state_handler != NULL);
00612 
00613         switch_channel_set_hangup_time(session->channel);
00614 
00615         switch_core_media_bug_remove_all(session);
00616 
00617         switch_channel_stop_broadcast(session->channel);
00618 
00619         switch_channel_set_variable(session->channel, "hangup_cause", switch_channel_cause2str(cause));
00620         switch_channel_set_variable_printf(session->channel, "hangup_cause_q850", "%d", cause_q850);
00621         //switch_channel_presence(session->channel, "unknown", switch_channel_cause2str(cause), NULL);
00622 
00623         switch_channel_set_timestamps(session->channel);
00624 
00625         STATE_MACRO(hangup, "HANGUP");
00626 
00627         if ((hook_var = switch_channel_get_variable(session->channel, SWITCH_API_HANGUP_HOOK_VARIABLE))) {
00628 
00629                 if (switch_true(switch_channel_get_variable(session->channel, SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE))) {
00630                         use_session = 1;
00631                 }
00632 
00633                 api_hook(session, hook_var, use_session);
00634         }
00635 
00636         switch_set_flag(session, SSF_HANGUP);
00637 
00638 }

void switch_core_session_hupall ( _In_ switch_call_cause_t  cause  ) 

Hangup all sessions.

Parameters:
cause the 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_interface The endpoint interface
cause the hangup cause to apply to the hungup channels

Definition at line 247 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_hangup, switch_core_alloc, switch_core_new_memory_pool, switch_core_session_locate(), switch_core_session_read_lock(), switch_core_session_rwunlock(), switch_core_strdup, switch_hash_first(), switch_hash_next(), switch_hash_this(), switch_mutex_lock(), switch_mutex_unlock(), and SWITCH_STATUS_SUCCESS.

Referenced by switch_loadable_module_unprocess().

00248 {
00249         switch_hash_index_t *hi;
00250         void *val;
00251         switch_core_session_t *session;
00252         switch_memory_pool_t *pool;
00253     struct str_node *head = NULL, *np;
00254         
00255         switch_core_new_memory_pool(&pool);
00256         
00257         switch_mutex_lock(runtime.session_hash_mutex);
00258         for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
00259                 switch_hash_this(hi, NULL, NULL, &val);
00260                 if (val) {
00261                         session = (switch_core_session_t *) val;
00262                         if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
00263                                 if (session->endpoint_interface == endpoint_interface) {
00264                                         np = switch_core_alloc(pool, sizeof(*np));
00265                     np->str = switch_core_strdup(pool, session->uuid_str);
00266                     np->next = head;
00267                                         head = np;
00268                                 }
00269                                 switch_core_session_rwunlock(session);
00270                         }
00271                 }
00272         }
00273         switch_mutex_unlock(runtime.session_hash_mutex);
00274 
00275         for(np = head; np; np = np->next) {
00276                 if ((session = switch_core_session_locate(np->str))) {
00277                         switch_channel_hangup(session->channel, cause);
00278                         switch_core_session_rwunlock(session);
00279                 }
00280         }
00281 
00282         switch_core_destroy_memory_pool(&pool);
00283 
00284 }

void switch_core_session_hupall_matching_var ( _In_ const char *  var_name,
_In_ const char *  var_val,
_In_ switch_call_cause_t  cause 
)

Hangup all sessions which match a specific channel variable.

Parameters:
var_name The variable name to look for
var_val The value to look for
cause the hangup cause to apply to the hungup channels

Referenced by switch_loadable_module_unprocess().

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

References switch_session_manager::session_id, and session_manager.

Referenced by send_heartbeat().

01954 {
01955         return session_manager.session_id;
01956 }

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:
session a session to allocate the thread from
func a function to execute in the thread
obj an arguement

Referenced by switch_core_service_session_av().

switch_core_session_t* switch_core_session_locate ( _In_z_ const char *  uuid_str  ) 

Locate a session based on it's uuid.

Parameters:
uuid_str the 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()

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_session_get_partner(), switch_core_session_hupall(), switch_core_session_hupall_endpoint(), switch_core_session_hupall_matching_var(), switch_core_session_pass_indication(), switch_core_session_perform_receive_message(), switch_core_session_write_frame(), switch_core_standard_on_execute(), switch_ivr_blind_transfer_ack(), switch_ivr_broadcast(), switch_ivr_eavesdrop_session(), switch_ivr_find_bridged_uuid(), switch_ivr_hold_uuid(), switch_ivr_intercept_session(), switch_ivr_kill_uuid(), switch_ivr_media(), switch_ivr_nomedia(), 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().

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_str the unique id of the session you want to send a message to
message the 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 1003 of file switch_core_session.c.

References switch_queue_size().

Referenced by check_channel_status().

01004 {
01005         int x = 0;
01006 
01007         if (session->private_event_queue) {
01008                 x += switch_queue_size(session->private_event_queue);
01009         }
01010 
01011         if (session->message_queue) {
01012                 x += switch_queue_size(session->message_queue);
01013         }
01014 
01015         return x;
01016 }

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:
session the originating session
var_event switch_event_t containing paramaters
endpoint_name the name of the module to use for the new session
caller_profile the originator's caller profile
new_session a NULL pointer to aim at the newly created session
pool optional existing memory pool to donate to the session
flags flags to use
Returns:
the cause code of the attempted call

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:
session the session to pass the message across
indication the 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_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_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:
session the session to receive the message from
message the message to recieve
Returns:
the status returned by the message handler

Referenced by 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:
session the 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:
session the session to queue the message on
event the event to queue
Returns:
the status returned by the message handler

Referenced by generate_on_dtmf(), speech_thread(), switch_channel_dequeue_dtmf(), and switch_core_session_event_send().

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:
session the session to queue the message to
indication the 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:
session the session to queue the message to
message the message to queue
Returns:
SWITCH_STATUS_SUCCESS if the message was queued

Referenced by send_display(), switch_core_session_dequeue_message(), and switch_core_session_queue_indication().

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:
session the session to queue the message on
event the event to queue
priority event has high priority
Returns:
the status returned by the message handler

Referenced by switch_core_session_execute_application_async(), and switch_ivr_broadcast().

switch_status_t switch_core_session_queue_signal_data ( switch_core_session_t session,
void *  signal_data 
)

Definition at line 908 of file switch_core_session.c.

References CF_PROXY_MODE, CF_THREAD_SLEEPING, switch_assert, switch_channel_test_flag(), switch_core_session_kill_channel, switch_core_session_wake_session_thread(), switch_queue_trypush(), SWITCH_SIG_BREAK, SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

00909 {
00910         switch_status_t status = SWITCH_STATUS_FALSE;
00911 
00912         switch_assert(session != NULL);
00913 
00914         if (session->signal_data_queue) {
00915                 if (switch_queue_trypush(session->signal_data_queue, signal_data) == SWITCH_STATUS_SUCCESS) {
00916                         status = SWITCH_STATUS_SUCCESS;
00917                 }
00918 
00919                 switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
00920 
00921                 if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) {
00922                         switch_core_session_wake_session_thread(session);
00923                 }
00924         }
00925         
00926         return status;
00927 }

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.

Parameters:
session the session to read from
frame a NULL pointer to a frame to aim at the newly read frame
flags I/O flags to modify behavior (i.e. non blocking)
stream_id which logical media channel to use
Returns:
SWITCH_STATUS_SUCCESS a the frame was read

Referenced by audio_bridge_thread(), early_thread_run(), switch_core_service_thread(), switch_ivr_collect_digits_callback(), switch_ivr_collect_digits_count(), switch_ivr_delay_echo(), switch_ivr_eavesdrop_session(), switch_ivr_gentones(), switch_ivr_media(), switch_ivr_park(), switch_ivr_parse_event(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_session_echo(), switch_ivr_sleep(), switch_ivr_sound_test(), switch_ivr_speak_text_handle(), switch_ivr_wait_for_answer(), and switch_ivr_wait_for_silence().

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:
session the session to read from
frame a NULL pointer to a frame to aim at the newly read frame
flags I/O flags to modify behavior (i.e. non blocking)
stream_id which logical media channel to use
Returns:
SWITCH_STATUS_SUCCESS a if the frame was read

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

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:
session the session to receive the event
event the 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:
session session to recv DTMF from
dtmf string 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 640 of file switch_core_state_machine.c.

References api_hook(), CF_REPORTING, 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_test_flag(), 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_STACK_BOTTOM, SWITCH_STATUS_SUCCESS, switch_true(), switch_xml_free(), switch_xml_toxml(), and zstr.

Referenced by switch_core_session_run().

00641 {
00642         switch_channel_state_t state = switch_channel_get_state(session->channel), midstate = state;
00643         const switch_endpoint_interface_t *endpoint_interface;
00644         const switch_state_handler_table_t *driver_state_handler = NULL;
00645         const switch_state_handler_table_t *application_state_handler = NULL;
00646         int proceed = 1;
00647         int global_proceed = 1;
00648         int do_extra_handlers = 1;
00649         int silly = 0;
00650         int index = 0;
00651         const char *var = switch_channel_get_variable(session->channel, SWITCH_PROCESS_CDR_VARIABLE);
00652         const char *hook_var;
00653         int use_session = 0;
00654         switch_event_t *event;
00655         switch_call_cause_t cause = switch_channel_get_cause(session->channel);
00656 
00657         if (switch_channel_test_flag(session->channel, CF_REPORTING)) {
00658                 return;
00659         }
00660 
00661         switch_channel_set_flag(session->channel, CF_REPORTING);
00662 
00663         switch_assert(session != NULL);
00664 
00665         endpoint_interface = session->endpoint_interface;
00666         switch_assert(endpoint_interface != NULL);
00667 
00668         driver_state_handler = endpoint_interface->state_handler;
00669         switch_assert(driver_state_handler != NULL);
00670 
00671         if (!zstr(var)) {
00672                 if (!strcasecmp(var, "a_only")) {
00673                         if (switch_channel_get_originator_caller_profile(session->channel)) {
00674                                 do_extra_handlers = 0;
00675                         }
00676                 } else if (!strcasecmp(var, "b_only")) {
00677                         if (switch_channel_get_originatee_caller_profile(session->channel)) {
00678                                 do_extra_handlers = 0;
00679                         }
00680                 } else if (!switch_true(var)) {
00681                         do_extra_handlers = 0;
00682                 }
00683         }
00684 
00685         STATE_MACRO(reporting, "REPORTING");
00686 
00687         if ((hook_var = switch_channel_get_variable(session->channel, SWITCH_API_REPORTING_HOOK_VARIABLE))) {
00688 
00689                 if (switch_true(switch_channel_get_variable(session->channel, SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE))) {
00690                         use_session = 1;
00691                 }
00692 
00693                 api_hook(session, hook_var, use_session);
00694         }
00695 
00696         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE) == SWITCH_STATUS_SUCCESS) {
00697                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Hangup-Cause", switch_channel_cause2str(cause));
00698                 switch_channel_event_set_data(session->channel, event);
00699                 if (switch_true(switch_channel_get_variable(session->channel, "hangup_complete_with_xml"))) {
00700                         switch_xml_t cdr = NULL;
00701                         char *xml_cdr_text;
00702                         
00703                         if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
00704                                 xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
00705                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "CDR-Attached", "xml");
00706                                 switch_event_add_body(event, "%s", xml_cdr_text);
00707                                 switch_xml_free(cdr);
00708                                 switch_safe_free(xml_cdr_text);
00709                         }
00710                 }
00711                 switch_event_fire(&event);
00712         }
00713 
00714 
00715 
00716         return;
00717 }

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_name the name of the endpoint module
pool the 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_interface the endpoint interface the session is to be based on
pool the pool to use for the allocation (a new one will be used if NULL)
Returns:
the newly created session

Referenced by switch_core_session_request_xml().

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.

Parameters:
session the session to reset
flush_dtmf flush all queued dtmf events too

Referenced by audio_bridge_on_exchange_media(), audio_bridge_thread(), record_callback(), switch_core_session_perform_destroy(), switch_core_standard_on_park(), switch_ivr_displace_session(), switch_ivr_eavesdrop_session(), switch_ivr_play_file(), switch_ivr_record_file(), switch_ivr_record_session(), switch_ivr_session_transfer(), switch_ivr_speak_text(), switch_ivr_wait_for_answer(), switch_ivr_wait_for_silence(), and uuid_bridge_on_soft_execute().

switch_call_cause_t switch_core_session_resurrect_channel ( _In_z_ const char *  endpoint_name,
_Inout_ switch_core_session_t **  new_session,
_Inout_ switch_memory_pool_t **  pool,
_In_ void *  data 
)

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:
session session to send DTMF to
dtmf dtmf to send to the session
Returns:
SWITCH_STATUS_SUCCESS if the dtmf was written

Referenced by audio_bridge_thread(), and switch_core_session_send_dtmf_string().

switch_status_t switch_core_session_send_dtmf_string ( switch_core_session_t session,
const char *  dtmf_string 
)

Send DTMF to a session.

Parameters:
session session to send DTMF to
dtmf_string string to send to the session
Returns:
SWITCH_STATUS_SUCCESS if the dtmf was written

Definition at line 1460 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_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_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.

01461 {
01462         char *p;
01463         switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0), DTMF_FLAG_SKIP_PROCESS, 0};
01464         int sent = 0, dur;
01465         char *string;
01466         int i, argc;
01467         char *argv[256];
01468         int dur_total = 0;
01469 
01470         switch_assert(session != NULL);
01471 
01472         if (*dtmf_string == '~') {
01473                 dtmf_string++;
01474                 dtmf.flags = 0;
01475         }
01476 
01477         if (switch_channel_down(session->channel)) {
01478                 return SWITCH_STATUS_FALSE;
01479         }
01480 
01481         if (zstr(dtmf_string)) {
01482                 return SWITCH_STATUS_FALSE;
01483         }
01484 
01485         if (strlen(dtmf_string) > 99) {
01486                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Attempt to send very large dtmf string ignored!\n");
01487                 return SWITCH_STATUS_FALSE;
01488         }
01489 
01490         string = switch_core_session_strdup(session, dtmf_string);
01491         argc = switch_separate_string(string, '+', argv, (sizeof(argv) / sizeof(argv[0])));
01492 
01493         if (argc) {
01494                 switch_channel_pre_answer(session->channel);
01495         }
01496 
01497         for (i = 0; i < argc; i++) {
01498                 dtmf.duration = switch_core_default_dtmf_duration(0);
01499                 dur = switch_core_default_dtmf_duration(0) / 8;
01500                 if ((p = strchr(argv[i], '@'))) {
01501                         *p++ = '\0';
01502                         if ((dur = atoi(p)) > (int)switch_core_min_dtmf_duration(0) / 8) {
01503                                 dtmf.duration = dur * 8;
01504                         }
01505                 }
01506 
01507 
01508                 for (p = argv[i]; p && *p; p++) {
01509                         if (is_dtmf(*p)) {
01510                                 dtmf.digit = *p;
01511 
01512                                 if (dtmf.digit != 'w' && dtmf.digit != 'W') {
01513                                         if (dtmf.duration > switch_core_max_dtmf_duration(0)) {
01514                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s EXCESSIVE DTMF DIGIT [%c] LEN [%d]\n",
01515                                                                                   switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
01516                                                 dtmf.duration = switch_core_max_dtmf_duration(0);
01517                                         } else if (dtmf.duration < switch_core_min_dtmf_duration(0)) {
01518                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s SHORT DTMF DIGIT [%c] LEN [%d]\n",
01519                                                                                   switch_channel_get_name(session->channel), dtmf.digit, dtmf.duration);
01520                                                 dtmf.duration = switch_core_min_dtmf_duration(0);
01521                                         } 
01522                                 }
01523 
01524                                 if (!dtmf.duration) {
01525                                         dtmf.duration = switch_core_default_dtmf_duration(0);
01526                                 }
01527                                 
01528 
01529                                 if (switch_core_session_send_dtmf(session, &dtmf) == SWITCH_STATUS_SUCCESS) {
01530                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
01531                                                                           switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
01532                                         sent++;
01533                                         dur_total += dtmf.duration + 2000;      /* account for 250ms pause */
01534                                 }
01535                         }
01536                 }
01537 
01538                 if (dur_total) {
01539                         char tmp[32] = "";
01540                         switch_snprintf(tmp, sizeof(tmp), "%d", dur_total / 8);
01541                         switch_channel_set_variable(session->channel, "last_dtmf_duration", tmp);
01542                 }
01543 
01544         }
01545         return sent ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
01546 }

switch_status_t switch_core_session_set_codec_slin ( switch_core_session_t session,
switch_slin_data_t data 
)

Definition at line 75 of file switch_core_session.c.

References switch_codec_implementation::actual_samples_per_second, switch_codec_implementation::microseconds_per_packet, 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.

00077 {
00078         switch_codec_implementation_t read_impl = { 0 };
00079         int interval;
00080 
00081         switch_core_session_get_read_impl(session, &read_impl);
00082         interval = read_impl.microseconds_per_packet / 1000;
00083         data->session = session;
00084 
00085         if (switch_core_codec_init(&data->codec,
00086                                                            "L16",
00087                                                            NULL,
00088                                                            read_impl.actual_samples_per_second,
00089                                                            interval,
00090                                                            1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) == SWITCH_STATUS_SUCCESS) {
00091                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
00092                                                   SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %dms\n", read_impl.actual_samples_per_second, interval);
00093 
00094                 memset(&data->write_frame, 0, sizeof(data->write_frame));
00095 
00096                 data->write_frame.codec = &data->codec;
00097                 data->write_frame.data = data->frame_data;
00098                 data->write_frame.buflen = sizeof(data->frame_data);
00099                 data->write_frame.datalen = 0;
00100                 switch_core_session_set_read_codec(session, &data->codec);
00101                 return SWITCH_STATUS_SUCCESS;
00102         }
00103 
00104         return SWITCH_STATUS_FALSE;
00105 }

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

References switch_ivr_dmachine_set_target().

00043 {
00044         int i = (int) target;
00045 
00046         if (i == 0 || i == 1) {
00047                 if (dmachine) {
00048                         switch_ivr_dmachine_set_target(dmachine, target);
00049                 }
00050                 session->dmachine[i] = dmachine;
00051         }
00052 }

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:
session the session to set the log level on
Returns:
SWITCH_STATUS_SUCCESS

Definition at line 2447 of file switch_core_session.c.

References switch_assert, and SWITCH_STATUS_SUCCESS.

02448 {
02449         switch_assert(session != NULL);
02450         session->loglevel = loglevel;
02451         return SWITCH_STATUS_SUCCESS;
02452 }

switch_status_t switch_core_session_set_private ( _In_ switch_core_session_t session,
_In_ void *  private_info 
)

Add private user data to a session.

Parameters:
session the session to add used data to
private_info the 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 366 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

00367 {
00368         session->read_impl = *impp;
00369         return SWITCH_STATUS_SUCCESS;
00370 }

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

Referenced by switch_core_session_outgoing_channel().

switch_status_t switch_core_session_set_video_read_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 378 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

00379 {
00380         session->video_read_impl = *impp;
00381         return SWITCH_STATUS_SUCCESS;
00382 }

switch_status_t switch_core_session_set_video_write_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 384 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

00385 {
00386         session->video_write_impl = *impp;
00387         return SWITCH_STATUS_SUCCESS;
00388 }

switch_status_t switch_core_session_set_write_impl ( switch_core_session_t session,
const switch_codec_implementation_t impp 
)

Definition at line 372 of file switch_core_codec.c.

References SWITCH_STATUS_SUCCESS.

00373 {
00374         session->write_impl = *impp;
00375         return SWITCH_STATUS_SUCCESS;
00376 }

void switch_core_session_signal_state_change ( _In_ switch_core_session_t session  ) 

Referenced by switch_channel_perform_hangup(), and switch_channel_perform_set_state().

void switch_core_session_soft_lock ( switch_core_session_t session,
uint32_t  sec 
)

Definition at line 65 of file switch_core_session.c.

00066 {
00067         session->soft_lock = sec;
00068 }

void switch_core_session_soft_unlock ( switch_core_session_t session  ) 

Definition at line 70 of file switch_core_session.c.

00071 {
00072         session->soft_lock = 0;
00073 }

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:
session the session to activate the state machine on
Returns:
SWITCH_STATUS_SUCCESS if the thread was launched

Referenced by switch_channel_perform_hangup().

switch_status_t switch_core_session_wake_session_thread ( _In_ switch_core_session_t session  ) 

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

Referenced by check_channel_status(), switch_core_session_queue_event(), switch_core_session_queue_message(), switch_core_session_queue_signal_data(), switch_core_session_read_lock(), and switch_core_session_signal_state_change().

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:
session the session to write to
frame the frame to write
flags I/O flags to modify behavior (i.e. non blocking)
stream_id which 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_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:
session the session to write to
frame a pointer to a frame to write
flags I/O flags to modify behavior (i.e. non blocking)
stream_id which logical media channel to use
Returns:
SWITCH_STATUS_SUCCESS a if the frame was written

Referenced by audio_bridge_thread(), and switch_ivr_session_echo().

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:
varname the name of the variable
value the value of the variable
val2 the 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:
varname the name of the variable
value the value of the variable

Referenced by check_ip(), globalSetVariable(), preprocess(), setGlobalVariable(), switch_core_init(), switch_core_set_serial(), switch_load_core_config(), 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:
session the 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 86 of file switch_ivr_async.c.

References switch_assert.

00087 {
00088         switch_assert(dmachine);
00089         return dmachine->target;
00090 }

void switch_ivr_dmachine_set_target ( switch_ivr_dmachine_t dmachine,
switch_digit_action_target_t  target 
)

Definition at line 92 of file switch_ivr_async.c.

References switch_assert.

Referenced by switch_core_session_set_dmachine().

00093 {
00094         switch_assert(dmachine);
00095         dmachine->target = target;
00096 }


Generated on Wed May 16 04:00:18 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7