Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

switch_core_session.c File Reference


Defines

#define SWITCH_PREFIX_DIR   "."

Functions

switch_core_session_tswitch_core_session_locate (const char *uuid_str)
void switch_core_session_hupall (switch_call_cause_t cause)
switch_status_t switch_core_session_message_send (const char *uuid_str, switch_core_session_message_t *message)
switch_status_t switch_core_session_event_send (const char *uuid_str, switch_event_t **event)
void * switch_core_session_get_private (switch_core_session_t *session)
switch_status_t switch_core_session_set_private (switch_core_session_t *session, void *private_info)
int switch_core_session_add_stream (switch_core_session_t *session, void *private_info)
void * switch_core_session_get_stream (switch_core_session_t *session, int index)
int switch_core_session_get_stream_count (switch_core_session_t *session)
switch_call_cause_t switch_core_session_resurrect_channel (const char *endpoint_name, switch_core_session_t **new_session, switch_memory_pool_t **pool, void *data)
switch_call_cause_t switch_core_session_outgoing_channel (switch_core_session_t *session, switch_event_t *var_event, const char *endpoint_name, switch_caller_profile_t *caller_profile, switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
switch_status_t switch_core_session_receive_message (switch_core_session_t *session, switch_core_session_message_t *message)
switch_status_t switch_core_session_pass_indication (switch_core_session_t *session, switch_core_session_message_types_t indication)
switch_status_t switch_core_session_queue_indication (switch_core_session_t *session, switch_core_session_message_types_t indication)
switch_status_t switch_core_session_queue_message (switch_core_session_t *session, switch_core_session_message_t *message)
switch_status_t switch_core_session_dequeue_message (switch_core_session_t *session, switch_core_session_message_t **message)
switch_status_t switch_core_session_flush_message (switch_core_session_t *session)
switch_status_t switch_core_session_receive_event (switch_core_session_t *session, switch_event_t **event)
switch_status_t switch_core_session_queue_event (switch_core_session_t *session, switch_event_t **event)
uint32_t switch_core_session_event_count (switch_core_session_t *session)
switch_status_t switch_core_session_dequeue_event (switch_core_session_t *session, switch_event_t **event)
switch_status_t switch_core_session_queue_private_event (switch_core_session_t *session, switch_event_t **event)
uint32_t switch_core_session_private_event_count (switch_core_session_t *session)
switch_status_t switch_core_session_dequeue_private_event (switch_core_session_t *session, switch_event_t **event)
uint32_t switch_core_session_flush_private_events (switch_core_session_t *session)
 Flush the private event queue of a session.
void switch_core_session_reset (switch_core_session_t *session, switch_bool_t flush_dtmf)
switch_channel_tswitch_core_session_get_channel (switch_core_session_t *session)
void switch_core_session_signal_state_change (switch_core_session_t *session)
unsigned int switch_core_session_running (switch_core_session_t *session)
void switch_core_session_perform_destroy (switch_core_session_t **session, const char *file, const char *func, int line)
switch_status_t switch_core_session_thread_launch (switch_core_session_t *session)
void switch_core_session_launch_thread (switch_core_session_t *session, switch_thread_start_t func, void *obj)
switch_core_session_tswitch_core_session_request (const switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool)
uint32_t switch_core_session_count (void)
 Provide the total number of sessions.
switch_size_t switch_core_session_id (void)
 Provide the current session_id.
switch_core_session_tswitch_core_session_request_by_name (const char *endpoint_name, switch_memory_pool_t **pool)
uint8_t switch_core_session_compare (switch_core_session_t *a, switch_core_session_t *b)
 indicate if 2 sessions are the same type
char * switch_core_session_get_uuid (switch_core_session_t *session)
uint32_t switch_core_session_limit (uint32_t new_limit)
uint32_t switch_core_sessions_per_second (uint32_t new_limit)
void switch_core_session_init (switch_memory_pool_t *pool)
void switch_core_session_uninit (void)
switch_app_log_tswitch_core_session_get_app_log (switch_core_session_t *session)
switch_status_t switch_core_session_execute_application (switch_core_session_t *session, const char *app, const char *arg)
switch_status_t switch_core_session_exec (switch_core_session_t *session, const switch_application_interface_t *application_interface, const char *arg)
switch_status_t switch_core_session_execute_exten (switch_core_session_t *session, const char *exten, const char *dialplan, const char *context)


Define Documentation

#define SWITCH_PREFIX_DIR   "."
 


Function Documentation

int switch_core_session_add_stream switch_core_session_t session,
void *  private_info
 

00160 {
00161         session->streams[session->stream_count++] = private_info;
00162         return session->stream_count - 1;
00163 }

switch_status_t switch_core_session_dequeue_event switch_core_session_t session,
switch_event_t **  event
 

00544 {
00545         switch_status_t status = SWITCH_STATUS_FALSE;
00546         void *pop;
00547 
00548         switch_assert(session != NULL);
00549 
00550         if (session->event_queue) {
00551                 if ((status = (switch_status_t) switch_queue_trypop(session->event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
00552                         *event = (switch_event_t *) pop;
00553                 }
00554         }
00555 
00556         return status;
00557 }

Here is the call graph for this function:

switch_status_t switch_core_session_dequeue_message switch_core_session_t session,
switch_core_session_message_t **  message
 

00449 {
00450         switch_status_t status = SWITCH_STATUS_FALSE;
00451         void *pop;
00452 
00453         switch_assert(session != NULL);
00454 
00455         if (session->message_queue) {
00456                 if ((status = (switch_status_t) switch_queue_trypop(session->message_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
00457                         *message = (switch_core_session_message_t *) pop;
00458                 }
00459         }
00460 
00461         return status;
00462 }

Here is the call graph for this function:

switch_status_t switch_core_session_dequeue_private_event switch_core_session_t session,
switch_event_t **  event
 

00589 {
00590         switch_status_t status = SWITCH_STATUS_FALSE;
00591         void *pop;
00592         switch_channel_t *channel = switch_core_session_get_channel(session);
00593 
00594         if (switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
00595                 return status;
00596         }
00597 
00598         if (session->private_event_queue) {
00599                 if ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
00600                         *event = (switch_event_t *) pop;
00601                 }
00602         }
00603 
00604         return status;
00605 }

Here is the call graph for this function:

uint32_t switch_core_session_event_count switch_core_session_t session  ) 
 

00535 {
00536         if (session->event_queue) {
00537                 return switch_queue_size(session->event_queue);
00538         }
00539 
00540         return 0;
00541 }

Here is the call graph for this function:

switch_status_t switch_core_session_event_send const char *  uuid_str,
switch_event_t **  event
 

00125 {
00126         switch_core_session_t *session = NULL;
00127         switch_status_t status = SWITCH_STATUS_FALSE;
00128 
00129         switch_mutex_lock(runtime.throttle_mutex);
00130         if ((session = switch_core_hash_find(session_manager.session_table, uuid_str)) != 0) {
00131                 /* Acquire a read lock on the session or forget it the channel is dead */
00132                 if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
00133                         if (switch_channel_get_state(session->channel) < CS_HANGUP) {
00134                                 status = switch_core_session_queue_event(session, event);
00135                         }
00136                         switch_core_session_rwunlock(session);
00137                 }
00138         }
00139         switch_mutex_unlock(runtime.throttle_mutex);
00140 
00141         return status;
00142 }

Here is the call graph for this function:

switch_status_t switch_core_session_exec switch_core_session_t session,
const switch_application_interface_t application_interface,
const char *  arg
 

01016                                                                                                                                                                                                {
01017         switch_app_log_t *log, *lp;
01018         switch_event_t *event;
01019         const char *var;
01020 
01021         if (!arg) {
01022                 arg = "";
01023         }
01024 
01025         if (!(var = switch_channel_get_variable(session->channel, SWITCH_DISABLE_APP_LOG_VARIABLE)) || (!(switch_true(var)))) {
01026                 log = switch_core_session_alloc(session, sizeof(*log));
01027 
01028                 log->app = switch_core_session_strdup(session, application_interface->interface_name);
01029                 log->arg = switch_core_session_strdup(session, arg);
01030 
01031                 for(lp = session->app_log; lp && lp->next; lp = lp->next);
01032 
01033                 if (lp) {
01034                         lp->next = log;
01035                 } else {
01036                         session->app_log = log;
01037                 }
01038         }
01039         
01040         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
01041                 switch_channel_event_set_data(session->channel, event);
01042                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
01043                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", arg);
01044                 switch_event_fire(&event);
01045         }
01046 
01047         switch_channel_clear_flag(session->channel, CF_BREAK);
01048 
01049         switch_assert(application_interface->application_function);
01050 
01051         application_interface->application_function(session, arg);
01052         
01053         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
01054                 switch_channel_event_set_data(session->channel, event);
01055                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
01056                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", arg);
01057                 switch_event_fire(&event);
01058         }
01059 
01060         return SWITCH_STATUS_SUCCESS;
01061 }

Here is the call graph for this function:

switch_status_t switch_core_session_execute_application switch_core_session_t session,
const char *  app,
const char *  arg
 

00962 {
00963         const switch_application_interface_t *application_interface;
00964         char *expanded = NULL;
00965 
00966         if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
00967                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app);
00968                 switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
00969                 return SWITCH_STATUS_FALSE;
00970         }
00971                 
00972         if (!application_interface->application_function) {
00973                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Function for %s\n", app);
00974                 switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
00975                 return SWITCH_STATUS_FALSE;
00976         }
00977                 
00978         if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
00979                 switch_ivr_media(session->uuid_str, SMF_NONE);
00980                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Application %s Requires media on channel %s!\n",
00981                                                   app, switch_channel_get_name(session->channel));
00982         } else if (!switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA) && !switch_channel_media_ready(session->channel)) {
00983                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Application %s Requires media! pre_answering channel %s\n",
00984                                                   app, switch_channel_get_name(session->channel));
00985                 if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) {
00986                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Well, that didn't work very well did it? ...\n");
00987                         return SWITCH_STATUS_FALSE;
00988                 }
00989         }
00990 
00991         if (arg && (expanded = switch_channel_expand_variables(session->channel, arg)) != arg) {
00992                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Expanded String %s(%s)\n", switch_channel_get_name(session->channel), app, expanded);
00993         }
00994 
00995         if (switch_channel_get_variable(session->channel, "presence_id")) {
00996                 char *myarg = NULL;
00997                 if (expanded) {
00998                         switch_mprintf("%s(%s)", app, expanded);
00999                 }
01000                 if (myarg) {
01001                         switch_channel_presence(session->channel, "unknown", myarg);
01002                         switch_safe_free(myarg);
01003                 }
01004         }
01005 
01006         switch_core_session_exec(session, application_interface, expanded);
01007         
01008         if (expanded != arg) {
01009                 switch_safe_free(expanded);
01010         }
01011 
01012         return SWITCH_STATUS_SUCCESS;
01013 }

Here is the call graph for this function:

switch_status_t switch_core_session_execute_exten switch_core_session_t session,
const char *  exten,
const char *  dialplan,
const char *  context
 

01064 {
01065         char *dp[25];
01066         char *dpstr;
01067         int argc, x, count = 0;
01068         switch_caller_profile_t *profile, *new_profile, *pp = NULL;
01069         switch_channel_t *channel = switch_core_session_get_channel(session);
01070         switch_dialplan_interface_t *dialplan_interface = NULL;
01071         switch_caller_extension_t *extension = NULL;
01072         switch_status_t status = SWITCH_STATUS_SUCCESS;
01073 
01074         if (!(profile = switch_channel_get_caller_profile(channel))) {
01075                 return SWITCH_STATUS_FALSE;
01076         }
01077         
01078         if (session->stack_count > SWITCH_MAX_STACKS) {
01079                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s too many stacked extensions\n", switch_channel_get_name(session->channel));
01080                 return SWITCH_STATUS_FALSE;
01081         }
01082 
01083         session->stack_count++;
01084         
01085         new_profile = switch_caller_profile_clone(session, profile);
01086         new_profile->destination_number = switch_core_session_strdup(session, exten);
01087                 
01088         if (!switch_strlen_zero(dialplan)) {
01089                 new_profile->dialplan = switch_core_session_strdup(session, dialplan);
01090         }
01091         
01092         if (!switch_strlen_zero(context)) {
01093                 new_profile->context = switch_core_session_strdup(session, context);
01094         }
01095 
01096         if (!(dpstr = switch_core_session_strdup(session, new_profile->dialplan))) {
01097                 abort();
01098         }
01099 
01100         argc = switch_separate_string(dpstr, ',', dp, (sizeof(dp) / sizeof(dp[0])));
01101         for (x = 0; x < argc; x++) {
01102                 char *dpname = dp[x];
01103                 char *dparg = NULL;
01104                         
01105                 if (dpname) {
01106                         if ((dparg = strchr(dpname, ':'))) {
01107                                 *dparg++ = '\0';
01108                         }
01109                 } else {
01110                         continue;
01111                 }
01112 
01113                 if (!(dialplan_interface = switch_loadable_module_get_dialplan_interface(dpname))) {
01114                         continue;
01115                 }
01116                         
01117                 count++;
01118                 
01119                 if ((extension = dialplan_interface->hunt_function(session, dparg, new_profile)) != 0) {
01120                         break;
01121                 }
01122         }
01123         
01124         if (!extension) {
01125                 status = SWITCH_STATUS_FALSE;
01126                 goto done;
01127         }
01128 
01129         new_profile->caller_extension = extension;
01130 
01131         if (profile->caller_extension) {
01132                 for(pp = profile->caller_extension->children; pp && pp->next; pp = pp->next);
01133  
01134                 if (pp) {
01135                         pp->next = new_profile;
01136                 } else {
01137                         profile->caller_extension->children = new_profile;
01138                 }
01139         }
01140 
01141         while (switch_channel_ready(channel) && extension->current_application) {
01142                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Execute %s(%s)\n",
01143                                                   extension->current_application->application_name, switch_str_nil(extension->current_application->application_data));
01144                 
01145                 if (switch_core_session_execute_application(session,
01146                                                                                                         extension->current_application->application_name,
01147                                                                                                         extension->current_application->application_data) != SWITCH_STATUS_SUCCESS) {
01148                         goto done;
01149                 }
01150                 
01151                 extension->current_application = extension->current_application->next;          
01152         }
01153 
01154  done:
01155         session->stack_count--;
01156         return status;  
01157 }

Here is the call graph for this function:

switch_status_t switch_core_session_flush_message switch_core_session_t session  ) 
 

00465 {
00466         switch_core_session_message_t *message;
00467 
00468         if (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
00469                 if (switch_test_flag(message, SCSMF_DYNAMIC)) {
00470                         switch_safe_free(message);
00471                 } else {
00472                         message = NULL;
00473                 }
00474         }
00475 
00476         return SWITCH_STATUS_SUCCESS;
00477 }

Here is the call graph for this function:

switch_app_log_t* switch_core_session_get_app_log switch_core_session_t session  ) 
 

00957 {
00958         return session->app_log;
00959 }

switch_channel_t* switch_core_session_get_channel switch_core_session_t session  ) 
 

00651 {
00652         switch_assert(session->channel);
00653         return session->channel;
00654 }

void* switch_core_session_get_private switch_core_session_t session  ) 
 

00146 {
00147         switch_assert(session != NULL);
00148         return session->private_info;
00149 }

void* switch_core_session_get_stream switch_core_session_t session,
int  index
 

00166 {
00167         return session->streams[index];
00168 }

int switch_core_session_get_stream_count switch_core_session_t session  ) 
 

00172 {
00173         return session->stream_count;
00174 }

char* switch_core_session_get_uuid switch_core_session_t session  ) 
 

00919 {
00920         return session->uuid_str;
00921 }

void switch_core_session_hupall switch_call_cause_t  cause  ) 
 

00076 {
00077         switch_hash_index_t *hi;
00078         void *val;
00079         switch_core_session_t *session;
00080         uint32_t loops = 0;
00081 
00082         switch_mutex_lock(runtime.throttle_mutex);
00083         for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
00084                 switch_hash_this(hi, NULL, NULL, &val);
00085                 if (val) {
00086                         session = (switch_core_session_t *) val;
00087                         switch_core_session_read_lock(session);
00088                         switch_channel_hangup(switch_core_session_get_channel(session), cause);
00089                         switch_core_session_rwunlock(session);
00090                 }
00091         }
00092         switch_mutex_unlock(runtime.throttle_mutex);
00093 
00094         while (session_manager.session_count > 0) {
00095                 switch_yield(100000);
00096                 if (++loops == 100) {
00097                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Giving up with %d session%s remaining\n",
00098                                                           session_manager.session_count, session_manager.session_count == 1 ? "" : "s");
00099                         break;
00100                 }
00101         }
00102 }

Here is the call graph for this function:

void switch_core_session_init switch_memory_pool_t pool  ) 
 

00943 {
00944         memset(&session_manager, 0, sizeof(session_manager));
00945         session_manager.session_limit = 1000;
00946         session_manager.session_id = 1;
00947         session_manager.memory_pool = pool;
00948         switch_core_hash_init(&session_manager.session_table, session_manager.memory_pool);
00949 }

Here is the call graph for this function:

void switch_core_session_launch_thread switch_core_session_t session,
switch_thread_start_t  func,
void *  obj
 

00792 {
00793         switch_thread_t *thread;
00794         switch_threadattr_t *thd_attr = NULL;
00795         switch_threadattr_create(&thd_attr, session->pool);
00796         switch_threadattr_detach_set(thd_attr, 1);
00797 
00798         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
00799         switch_thread_create(&thread, thd_attr, func, obj, session->pool);
00800 
00801 }

Here is the call graph for this function:

uint32_t switch_core_session_limit uint32_t  new_limit  ) 
 

00925 {
00926         if (new_limit) {
00927                 session_manager.session_limit = new_limit;
00928         }
00929 
00930         return session_manager.session_limit;
00931 }

switch_core_session_t* switch_core_session_locate const char *  uuid_str  ) 
 

00052 {
00053         switch_core_session_t *session = NULL;
00054 
00055         if (uuid_str) {
00056                 switch_mutex_lock(runtime.throttle_mutex);
00057                 if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) {
00058                         /* Acquire a read lock on the session */
00059 #ifdef SWITCH_DEBUG_RWLOCKS
00060                         if (switch_core_session_perform_read_lock(session, file, func, line) != SWITCH_STATUS_SUCCESS) {
00061 #else
00062                         if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
00063 #endif
00064                                 /* not available, forget it */
00065                                 session = NULL;
00066                         }
00067                 }
00068                 switch_mutex_unlock(runtime.throttle_mutex);
00069         }
00070 
00071         /* if its not NULL, now it's up to you to rwunlock this */
00072         return session;
00073 }

Here is the call graph for this function:

switch_status_t switch_core_session_message_send const char *  uuid_str,
switch_core_session_message_t message
 

00105 {
00106         switch_core_session_t *session = NULL;
00107         switch_status_t status = SWITCH_STATUS_FALSE;
00108 
00109         switch_mutex_lock(runtime.throttle_mutex);
00110         if ((session = switch_core_hash_find(session_manager.session_table, uuid_str)) != 0) {
00111                 /* Acquire a read lock on the session or forget it the channel is dead */
00112                 if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
00113                         if (switch_channel_get_state(session->channel) < CS_HANGUP) {
00114                                 status = switch_core_session_receive_message(session, message);
00115                         }
00116                         switch_core_session_rwunlock(session);
00117                 }
00118         }
00119         switch_mutex_unlock(runtime.throttle_mutex);
00120 
00121         return status;
00122 }

Here is the call graph for this function:

switch_call_cause_t switch_core_session_outgoing_channel switch_core_session_t session,
switch_event_t var_event,
const char *  endpoint_name,
switch_caller_profile_t caller_profile,
switch_core_session_t **  new_session,
switch_memory_pool_t **  pool,
switch_originate_flag_t  flags
 

00197 {
00198         switch_io_event_hook_outgoing_channel_t *ptr;
00199         switch_status_t status = SWITCH_STATUS_FALSE;
00200         const switch_endpoint_interface_t *endpoint_interface;
00201         switch_channel_t *channel = NULL;
00202         switch_caller_profile_t *outgoing_profile = caller_profile;
00203         switch_call_cause_t cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL;
00204         const char *forwardvar;
00205         int forwardval = 70;
00206 
00207         if ((endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name)) == 0) {
00208                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate channel type %s\n", endpoint_name);
00209                 return SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED;
00210         }
00211 
00212         if (!endpoint_interface->io_routines->outgoing_channel) {
00213                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate outgoing channel interface for %s\n", endpoint_name);
00214                 return SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED;
00215         }
00216 
00217         if (session) {
00218                 channel = switch_core_session_get_channel(session);
00219 
00220                 switch_assert(channel != NULL);
00221                 
00222                 forwardvar = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
00223                 if (!switch_strlen_zero(forwardvar)) {
00224                         forwardval =  atoi(forwardvar) - 1;
00225                 }
00226                 if (forwardval <= 0) {
00227                         return SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR;
00228                 }
00229 
00230                 if (caller_profile) {
00231                         const char *ecaller_id_name = NULL, *ecaller_id_number = NULL;
00232 
00233                         ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name");
00234                         ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number");
00235 
00236                         if (ecaller_id_name || ecaller_id_number) {
00237                                 outgoing_profile = switch_caller_profile_clone(session, caller_profile);
00238 
00239                                 if (ecaller_id_name) {
00240                                         outgoing_profile->caller_id_name = ecaller_id_name;
00241                                 }
00242                                 if (ecaller_id_number) {
00243                                         outgoing_profile->caller_id_number = ecaller_id_number;
00244                                 }
00245                         }
00246                 }
00247                 if (!outgoing_profile) {
00248                         outgoing_profile = switch_channel_get_caller_profile(channel);
00249                 }
00250         }
00251 
00252         if ((cause = endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags)) != SWITCH_CAUSE_SUCCESS) {
00253                 return cause;
00254         }
00255 
00256         if (session) {
00257                 for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) {
00258                         if ((status = ptr->outgoing_channel(session, var_event, caller_profile, *new_session, flags)) != SWITCH_STATUS_SUCCESS) {
00259                                 break;
00260                         }
00261                 }
00262         }
00263 
00264         if (!*new_session) {
00265                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n", 
00266                                                   endpoint_name, switch_channel_cause2str(cause));
00267                 return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
00268         } else {
00269                 switch_caller_profile_t *profile = NULL, *peer_profile = NULL, *cloned_profile = NULL;
00270                 switch_event_t *event;
00271                 switch_channel_t *peer_channel = switch_core_session_get_channel(*new_session);
00272                 
00273                 switch_assert(peer_channel);
00274                 
00275                 peer_profile = switch_channel_get_caller_profile(peer_channel);
00276 
00277                 if (channel) {
00278                         const char *export_vars, *val;
00279                         switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
00280                         const char *max_forwards = switch_core_session_sprintf(session, "%d", forwardval);
00281 
00282                         switch_channel_set_variable(peer_channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
00283 
00284                         profile = switch_channel_get_caller_profile(channel);
00285 
00286                         if (read_codec) {
00287                                 char tmp[80];
00288                                 switch_codec2str(read_codec, tmp, sizeof(tmp));
00289                                 switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_CODEC_VARIABLE, tmp);
00290                         }
00291 
00292                         switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VARIABLE, switch_core_session_get_uuid(session));
00293                         switch_channel_set_variable(peer_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(session));
00294                         switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(*new_session));
00295 
00296                         /* A comma (,) separated list of variable names that should ne propagated from originator to originatee */
00297                         if ((export_vars = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE))) {
00298                                 char *cptmp = switch_core_session_strdup(session, export_vars);
00299                                 int argc;
00300                                 char *argv[256];
00301 
00302                                 if ((argc = switch_separate_string(cptmp, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
00303                                         int x;
00304 
00305                                         for (x = 0; x < argc; x++) {
00306                                                 const char *vval;
00307                                                 if ((vval = switch_channel_get_variable(channel, argv[x]))) {
00308                                                         char *vvar = argv[x];
00309                                                         if (!strncasecmp(vvar, "nolocal:", 8)) {
00310                                                                 vvar += 8;
00311                                                         }
00312                                                         switch_channel_set_variable(peer_channel, vvar, vval);
00313                                                 }
00314                                         }
00315                                 }
00316                         }
00317 
00318                         if ((val = switch_channel_get_variable(channel, SWITCH_PROCESS_CDR_VARIABLE))) {
00319                                 switch_channel_set_variable(peer_channel, SWITCH_PROCESS_CDR_VARIABLE, val);
00320                         }
00321 
00322                         if ((val = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE))) {
00323                                 switch_channel_set_variable(peer_channel, SWITCH_B_SDP_VARIABLE, val);
00324                         }
00325 
00326                         if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
00327                                 switch_channel_set_flag(peer_channel, CF_PROXY_MODE);
00328                         }
00329 
00330                         if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
00331                                 switch_channel_set_flag(peer_channel, CF_PROXY_MEDIA);
00332                                 if (switch_channel_test_flag(channel, CF_VIDEO)) {
00333                                         switch_channel_set_flag(peer_channel, CF_VIDEO);
00334                                 }
00335                         }
00336 
00337                         if (profile) {
00338                                 if ((cloned_profile = switch_caller_profile_clone(*new_session, profile)) != 0) {
00339                                         switch_channel_set_originator_caller_profile(peer_channel, cloned_profile);
00340                                 }
00341                         }
00342                         
00343                         if (peer_profile) {
00344                                 if ((cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) {
00345                                         switch_channel_set_originatee_caller_profile(channel, cloned_profile);
00346                                 }
00347                         }
00348                 }
00349 
00350                 if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_OUTGOING) == SWITCH_STATUS_SUCCESS) {
00351                         switch_channel_event_set_data(peer_channel, event);
00352                         switch_event_fire(&event);
00353                 }
00354         }
00355 
00356         return cause;
00357 }

Here is the call graph for this function:

switch_status_t switch_core_session_pass_indication switch_core_session_t session,
switch_core_session_message_types_t  indication
 

00398 {
00399         switch_core_session_message_t msg = {0};
00400         switch_core_session_t *other_session;
00401         const char *uuid;
00402         switch_channel_t *channel = switch_core_session_get_channel(session);
00403         switch_status_t status = SWITCH_STATUS_SUCCESS;
00404 
00405         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
00406                 msg.message_id = indication;
00407                 msg.from = __FILE__;
00408                 status = switch_core_session_receive_message(other_session, &msg);
00409                 switch_core_session_rwunlock(other_session);
00410         } else {
00411                 status = SWITCH_STATUS_FALSE;
00412         }
00413         
00414         return status;
00415 }

Here is the call graph for this function:

void switch_core_session_perform_destroy switch_core_session_t **  session,
const char *  file,
const char *  func,
int  line
 

00688 {
00689         switch_memory_pool_t *pool;
00690         switch_event_t *event;
00691 
00692         switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n", 
00693                                           switch_channel_get_name((*session)->channel),
00694                                           switch_channel_state_name(switch_channel_get_state((*session)->channel)));
00695 
00696         switch_core_media_bug_remove_all(*session);     
00697         switch_ivr_deactivate_unicast(*session);
00698         
00699         switch_scheduler_del_task_group((*session)->uuid_str);
00700 
00701         switch_mutex_lock(runtime.throttle_mutex);
00702         switch_core_hash_delete(session_manager.session_table, (*session)->uuid_str);
00703         if (session_manager.session_count) {
00704                 session_manager.session_count--;
00705         }
00706         switch_mutex_unlock(runtime.throttle_mutex);
00707 
00708         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) {
00709                 switch_channel_event_set_data((*session)->channel, event);
00710                 switch_event_fire(&event);
00711         }
00712 
00713 
00714         switch_buffer_destroy(&(*session)->raw_read_buffer);
00715         switch_buffer_destroy(&(*session)->raw_write_buffer);
00716         switch_ivr_clear_speech_cache(*session);
00717         switch_channel_uninit((*session)->channel);
00718 
00719         pool = (*session)->pool;
00720         //#ifndef NDEBUG
00721         //memset(*session, 0, sizeof(switch_core_session_t));
00722         //#endif
00723         *session = NULL;
00724         switch_core_destroy_memory_pool(&pool);
00725         
00726 }

Here is the call graph for this function:

uint32_t switch_core_session_private_event_count switch_core_session_t session  ) 
 

00578 {
00579         switch_channel_t *channel = switch_core_session_get_channel(session);
00580 
00581         if (!switch_channel_test_flag(channel, CF_EVENT_LOCK) && session->private_event_queue) {
00582                 return switch_queue_size(session->private_event_queue);
00583         }
00584         
00585         return 0;
00586 }

Here is the call graph for this function:

switch_status_t switch_core_session_queue_event switch_core_session_t session,
switch_event_t **  event
 

00519 {
00520         switch_status_t status = SWITCH_STATUS_FALSE;
00521 
00522         switch_assert(session != NULL);
00523 
00524         if (session->event_queue) {
00525                 if (switch_queue_trypush(session->event_queue, *event) == SWITCH_STATUS_SUCCESS) {
00526                         *event = NULL;
00527                         status = SWITCH_STATUS_SUCCESS;
00528                 }
00529         }
00530 
00531         return status;
00532 }

Here is the call graph for this function:

switch_status_t switch_core_session_queue_indication switch_core_session_t session,
switch_core_session_message_types_t  indication