FreeSWITCH API Documentation  1.7.0
Modules | Functions
Core Library
+ Collaboration diagram for Core Library:

Modules

 Bitpacking
 
 Buffer Routines
 
 Caller Identity / Dialplan
 
 Channel Functions
 
 Config File Parser
 
 Media Bugs
 
 Port Allocation
 
 Startup/Shutdown
 
 Read/Write Locking
 
 State Handlers
 
 Memory Pooling/Allocation
 
 Session Creation / Management
 
 Hash Functions
 
 Timer Functions
 
 Codec Functions
 
 Database Functions
 
 File Functions
 
 ASR/TTS Functions
 
 Directory Service Functions
 
 Misc
 
 Eventing Engine
 
 IVR Library
 
 LIMIT code
 
 Loadable Module Functions
 
 Logger Routines
 
 NAT code
 
 Audio Resample Functions
 
 RTP (RealTime Transport Protocol)
 
 Scheduler
 
 STUN code
 
 XML Library Functions
 

Functions

int switch_core_test_flag (int flag)
 
void switch_core_memory_pool_tag (switch_memory_pool_t *pool, const char *tag)
 
switch_status_t switch_core_perform_new_memory_pool (_Out_ switch_memory_pool_t **pool, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
 
switch_core_session_tswitch_core_session_request_xml (switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool, switch_xml_t xml)
 

Detailed Description

Function Documentation

void switch_core_memory_pool_tag ( switch_memory_pool_t pool,
const char *  tag 
)

Definition at line 320 of file switch_core_memory.c.

Referenced by switch_core_session_thread().

321 {
322  apr_pool_tag(pool, tag);
323 }
switch_memory_pool_t * pool
switch_status_t switch_core_perform_new_memory_pool ( _Out_ switch_memory_pool_t **  pool,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line 
)
switch_core_session_t* switch_core_session_request_xml ( switch_endpoint_interface_t endpoint_interface,
switch_memory_pool_t **  pool,
switch_xml_t  xml 
)

Definition at line 1991 of file switch_core_session.c.

References switch_channel_timetable::answered, switch_caller_profile::callee_id_name, switch_caller_profile::callee_id_number, CC_FLAG_MAX, CF_ACCEPT_CNG, CF_ATTENDED_TRANSFER, CF_BLOCK_BROADCAST_UNTIL_MEDIA, CF_BLOCK_STATE, CF_BREAK, CF_BRIDGE_NOWRITE, CF_BRIDGED, CF_BROADCAST, CF_BROADCAST_DROP_MEDIA, CF_BYPASS_MEDIA_AFTER_BRIDGE, CF_CNG_PLC, CF_CONSUME_ON_ORIGINATE, CF_CONTROLLED, CF_DIALPLAN, CF_DISABLE_RINGBACK, CF_DIVERT_EVENTS, CF_EARLY_HANGUP, CF_EARLY_OK, CF_EVENT_LOCK, CF_EVENT_LOCK_PRI, CF_EVENT_PARSE, CF_FLAG_MAX, CF_FS_RTP, CF_GEN_RINGBACK, CF_HOLD, CF_INNER_BRIDGE, CF_JITTERBUFFER, CF_JITTERBUFFER_PLC, CF_LAZY_ATTENDED_TRANSFER, CF_LEG_HOLDING, CF_MEDIA_ACK, CF_MEDIA_BRIDGE_TTL, CF_MEDIA_SET, CF_NOT_READY, CF_ORIGINATING, CF_ORIGINATOR, CF_PARK, CF_PASSTHRU_PTIME_MISMATCH, CF_PAUSE_BUGS, CF_RECOVERED, CF_RECOVERING, CF_RECOVERING_BRIDGE, CF_REDIRECT, CF_REPORTING, CF_REQ_MEDIA, CF_RESET, CF_SERVICE, CF_SIGNAL_BRIDGE_TTL, CF_SIGNAL_DATA, CF_SIMPLIFY, CF_STOP_BROADCAST, CF_SUSPEND, CF_TAGGED, CF_THREAD_SLEEPING, CF_TIMESTAMP_SET, CF_TRACKED, CF_TRANSFER, CF_UNICAST, CF_VIDEO_DECODED_READ, CF_VIDEO_READY, CF_WINNER, CF_XFER_ZOMBIE, switch_xml::child, switch_channel_timetable::created, switch_channel_timetable::hungup, switch_xml::name, parse_array(), switch_channel_timetable::profile_created, switch_channel_timetable::progress, switch_channel_timetable::progress_media, switch_channel_timetable::resurrected, switch_xml::sibling, SOF_NO_LIMITS, SWITCH_CALL_DIRECTION_INBOUND, SWITCH_CALL_DIRECTION_OUTBOUND, switch_caller_profile_new(), switch_channel_get_caller_profile(), switch_channel_set_caller_profile(), switch_channel_set_cap_value(), switch_channel_set_flag, switch_channel_set_flag_value(), switch_channel_set_name(), switch_channel_set_originatee_caller_profile(), switch_channel_set_originator_caller_profile(), switch_channel_set_variable, switch_core_session_alloc, switch_core_session_destroy, switch_core_session_get_channel(), switch_core_session_get_pool(), switch_core_session_request_uuid(), switch_core_session_strdup, switch_time_now(), switch_url_decode(), switch_xml_child(), switch_caller_profile::times, switch_channel_timetable::transferred, switch_xml::txt, and xml_find_var().

Referenced by recover_callback().

1993 {
1994  switch_core_session_t *session;
1995  switch_channel_t *channel;
1996  switch_xml_t tag, tag2, tag3, vars, callflow;
1998  char *flag_str = NULL, *cap_str = NULL, *direction_s = NULL, *uuid = NULL;
1999  uint32_t flags[CF_FLAG_MAX] = { 0 };
2000  uint32_t caps[CC_FLAG_MAX] = { 0 };
2001  int i;
2002 
2003  vars = switch_xml_child(xml, "variables");
2004  uuid = xml_find_var(vars, "uuid");
2005 
2006  if ((tag = switch_xml_child(xml, "channel_data"))) {
2007  direction_s = xml_find_var(tag, "direction");
2008  direction = !strcmp(direction_s, "outbound") ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND;
2009  flag_str = xml_find_var(tag, "flags");
2010  cap_str = xml_find_var(tag, "caps");
2011  }
2012 
2013  parse_array(flag_str, flags, CF_FLAG_MAX);
2014  parse_array(cap_str, caps, CC_FLAG_MAX);
2015 
2016  flags[CF_RECOVERING] = 0;
2017  flags[CF_RECOVERING_BRIDGE] = 0;
2018  flags[CF_TRACKED] = 0;
2019  flags[CF_TRANSFER] = 0;
2020  flags[CF_ACCEPT_CNG] = 0;
2021  flags[CF_REDIRECT] = 0;
2022  flags[CF_BRIDGED] = 0;
2023  flags[CF_HOLD] = 0;
2024  flags[CF_SERVICE] = 0;
2025  flags[CF_TAGGED] = 0;
2026  flags[CF_WINNER] = 0;
2027  flags[CF_EARLY_OK] = 0;
2028  flags[CF_CONTROLLED] = 0;
2029  flags[CF_SUSPEND] = 0;
2030  flags[CF_EVENT_PARSE] = 0;
2031  flags[CF_GEN_RINGBACK] = 0;
2032  flags[CF_BREAK] = 0;
2033  flags[CF_BROADCAST] = 0;
2034  flags[CF_UNICAST] = 0;
2035  flags[CF_EVENT_LOCK] = 0;
2036  flags[CF_EVENT_LOCK_PRI] = 0;
2037  flags[CF_RESET] = 0;
2038  flags[CF_ORIGINATING] = 0;
2039  flags[CF_STOP_BROADCAST] = 0;
2040  flags[CF_INNER_BRIDGE] = 0;
2041  flags[CF_REQ_MEDIA] = 0;
2042  flags[CF_PAUSE_BUGS] = 0;
2043  flags[CF_DIVERT_EVENTS] = 0;
2044  flags[CF_BLOCK_STATE] = 0;
2045  flags[CF_FS_RTP] = 0;
2046  flags[CF_REPORTING] = 0;
2047  flags[CF_PARK] = 0;
2048  flags[CF_TIMESTAMP_SET] = 0;
2049  flags[CF_ORIGINATOR] = 0;
2050  flags[CF_XFER_ZOMBIE] = 0;
2051  flags[CF_MEDIA_ACK] = 0;
2052  flags[CF_THREAD_SLEEPING] = 0;
2053  flags[CF_DISABLE_RINGBACK] = 0;
2054  flags[CF_NOT_READY] = 0;
2055  flags[CF_SIGNAL_BRIDGE_TTL] = 0;
2056  flags[CF_MEDIA_BRIDGE_TTL] = 0;
2057  flags[CF_BYPASS_MEDIA_AFTER_BRIDGE] = 0;
2058  flags[CF_LEG_HOLDING] = 0;
2059  flags[CF_BROADCAST_DROP_MEDIA] = 0;
2060  flags[CF_EARLY_HANGUP] = 0;
2061  flags[CF_MEDIA_SET] = 0;
2062  flags[CF_CONSUME_ON_ORIGINATE] = 0;
2063  flags[CF_PASSTHRU_PTIME_MISMATCH] = 0;
2064  flags[CF_BRIDGE_NOWRITE] = 0;
2065  flags[CF_RECOVERED] = 0;
2066  flags[CF_JITTERBUFFER] = 0;
2067  flags[CF_JITTERBUFFER_PLC] = 0;
2068  flags[CF_DIALPLAN] = 0;
2069  flags[CF_BLOCK_BROADCAST_UNTIL_MEDIA] = 0;
2070  flags[CF_CNG_PLC] = 0;
2071  flags[CF_ATTENDED_TRANSFER] = 0;
2072  flags[CF_LAZY_ATTENDED_TRANSFER] = 0;
2073  flags[CF_SIGNAL_DATA] = 0;
2074  flags[CF_SIMPLIFY] = 0;
2075  flags[CF_VIDEO_READY] = 0;
2076  flags[CF_VIDEO_DECODED_READ] = 0;
2077 
2078  if (!(session = switch_core_session_request_uuid(endpoint_interface, direction, SOF_NO_LIMITS, pool, uuid))) {
2079  return NULL;
2080  }
2081 
2082  channel = switch_core_session_get_channel(session);
2083 
2084  for (i = 0; i < CF_FLAG_MAX; i++) {
2085  if (flags[i]) {
2086  switch_channel_set_flag_value(channel, i, flags[i]);
2087  }
2088  }
2089 
2090  for (i = 0; i < CC_FLAG_MAX; i++) {
2091  if (caps[i]) {
2092  switch_channel_set_cap_value(channel, i, caps[i]);
2093  }
2094  }
2095 
2096  if ((tag2 = switch_xml_child(xml, "variables"))) {
2097  for (tag = tag2->child; tag; tag = tag->sibling) {
2098  if (tag->name && tag->txt) {
2099  char *p = strdup(tag->txt);
2100  char *val = p;
2101  switch_url_decode(val);
2102  switch_channel_set_variable(channel, tag->name, val);
2103  if (!strcasecmp(tag->name, "channel_name")) {
2104  switch_channel_set_name(channel, val);
2105  }
2106  free(p);
2107  }
2108  }
2109  }
2110 
2111  if ((callflow = switch_xml_child(xml, "callflow"))) {
2112  if ((tag2 = switch_xml_child(callflow, "caller_profile"))) {
2113  switch_caller_profile_t *caller_profile;
2114  char *tmp;
2115 
2116  caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
2117  xml_find_var(tag2, "username"),
2118  xml_find_var(tag2, "dialplan"),
2119  xml_find_var(tag2, "caller_id_name"),
2120  xml_find_var(tag2, "caller_id_number"),
2121  xml_find_var(tag2, "network_addr"),
2122  xml_find_var(tag2, "ani"),
2123  xml_find_var(tag2, "aniii"),
2124  xml_find_var(tag2, "rdnis"),
2125  xml_find_var(tag2, "source"),
2126  xml_find_var(tag2, "context"), xml_find_var(tag2, "destination_number"));
2127 
2128  if ((tmp = xml_find_var(tag2, "callee_id_name"))) {
2129  caller_profile->callee_id_name = switch_core_session_strdup(session, tmp);
2130  }
2131 
2132  if ((tmp = xml_find_var(tag2, "callee_id_number"))) {
2133  caller_profile->callee_id_number = switch_core_session_strdup(session, tmp);
2134  }
2135 
2136  if ((tag3 = switch_xml_child(callflow, "times"))) {
2137  caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(session, sizeof(*caller_profile->times));
2138 
2139  caller_profile->times->resurrected = switch_time_now();
2140 
2141  for (tag3 = tag3->child; tag3; tag3 = tag3->sibling) {
2142  int64_t v;
2143 
2144  if (tag3->name && tag3->txt) {
2145  v = atoll(tag3->txt);
2146  if (!strcmp(tag3->name, "created_time")) {
2147  caller_profile->times->created = v;
2148  } else if (!strcmp(tag3->name, "profile_created_time")) {
2149  caller_profile->times->profile_created = v;
2150  } else if (!strcmp(tag3->name, "progress_time")) {
2151  caller_profile->times->progress = v;
2152  } else if (!strcmp(tag3->name, "progress_media_time")) {
2153  caller_profile->times->progress_media = v;
2154  } else if (!strcmp(tag3->name, "answered_time")) {
2155  caller_profile->times->answered = v;
2156  } else if (!strcmp(tag3->name, "hangup_time")) {
2157  caller_profile->times->hungup = v;
2158  } else if (!strcmp(tag3->name, "transfer_time")) {
2159  caller_profile->times->transferred = v;
2160  }
2161  }
2162 
2163  }
2164  }
2165 
2166  switch_channel_set_caller_profile(channel, caller_profile);
2167  if ((tag = switch_xml_child(tag2, "originator")) && (tag = tag->child)) {
2168  caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
2169  xml_find_var(tag, "username"),
2170  xml_find_var(tag, "dialplan"),
2171  xml_find_var(tag, "caller_id_name"),
2172  xml_find_var(tag, "caller_id_number"),
2173  xml_find_var(tag, "network_addr"),
2174  xml_find_var(tag, "ani"),
2175  xml_find_var(tag, "aniii"),
2176  xml_find_var(tag, "rdnis"),
2177  xml_find_var(tag, "source"),
2178  xml_find_var(tag, "context"), xml_find_var(tag, "destination_number"));
2179 
2180  switch_channel_set_originator_caller_profile(channel, caller_profile);
2181  }
2182 
2183  if ((tag = switch_xml_child(tag2, "originatee")) && (tag = tag->child)) {
2184  caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
2185  xml_find_var(tag, "username"),
2186  xml_find_var(tag, "dialplan"),
2187  xml_find_var(tag, "caller_id_name"),
2188  xml_find_var(tag, "caller_id_number"),
2189  xml_find_var(tag, "network_addr"),
2190  xml_find_var(tag, "ani"),
2191  xml_find_var(tag, "aniii"),
2192  xml_find_var(tag, "rdnis"),
2193  xml_find_var(tag, "source"),
2194  xml_find_var(tag, "context"), xml_find_var(tag, "destination_number"));
2195 
2196  switch_channel_set_originatee_caller_profile(channel, caller_profile);
2197  }
2198 
2199  }
2200 
2201 
2203  }
2204 
2205 
2206  if (!channel || !switch_channel_get_caller_profile(channel)) {
2207  if (session) {
2208  switch_core_session_destroy(&session);
2209  }
2210  }
2211 
2212 
2213  return session;
2214 }
switch_xml_t sibling
Definition: switch_xml.h:90
void switch_channel_set_cap_value(switch_channel_t *channel, switch_channel_cap_t cap, uint32_t value)
switch_core_session_t * switch_core_session_request_uuid(switch_endpoint_interface_t *endpoint_interface, switch_call_direction_t direction, switch_originate_flag_t originate_flags, switch_memory_pool_t **pool, const char *use_uuid)
char * name
Definition: switch_xml.h:78
Call Specific Data.
Definition: switch_caller.h:73
switch_call_direction_t
Definition: switch_types.h:293
switch_xml_t child
Definition: switch_xml.h:94
switch_memory_pool_t * pool
void switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel's caller profile.
static void parse_array(const char *str, uint32_t *array, int32_t array_len)
A representation of an XML tree.
Definition: switch_xml.h:76
switch_caller_profile_t * switch_caller_profile_new(_In_ switch_memory_pool_t *pool, _In_opt_z_ const char *username, _In_opt_z_ const char *dialplan, _In_opt_z_ const char *caller_id_name, _In_opt_z_ const char *caller_id_number, _In_opt_z_ const char *network_addr, _In_opt_z_ const char *ani, _In_opt_z_ const char *aniii, _In_opt_z_ const char *rdnis, _In_opt_z_ const char *source, _In_opt_z_ const char *context, _In_opt_z_ const char *destination_number)
Create a new caller profile object.
switch_channel_t * switch_core_session_get_channel(switch_core_session_t *session)
char * txt
Definition: switch_xml.h:82
static char * xml_find_var(switch_xml_t vars, const char *name)
const char * callee_id_number
Definition: switch_caller.h:89
void switch_channel_set_flag_value(switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value)
Set given flag(s) on a given channel.
switch_time_t profile_created
#define switch_core_session_destroy(session)
Destroy a session and return the memory pool to the core.
Definition: switch_core.h:809
void switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel's originator caller profile.
char * switch_url_decode(char *s)
void switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel's originatee caller profile.
#define switch_channel_set_flag(_c, _f)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
switch_status_t switch_channel_set_name(switch_channel_t *channel, const char *name)
Assign a name to a given channel.
struct switch_channel_timetable * times
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
Definition: switch_core.h:694
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
Definition: switch_apr.c:302
switch_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel's caller profile.
const char * callee_id_name
Definition: switch_caller.h:87
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
switch_time_t progress_media
int switch_core_test_flag ( int  flag)

Definition at line 1800 of file switch_core.c.

References switch_test_flag.

Referenced by switch_channel_expand_variables_check(), switch_core_session_exec(), switch_event_expand_headers_check(), switch_event_init(), and switch_event_shutdown().

1801 {
1802  return switch_test_flag((&runtime), flag);
1803 }
struct switch_runtime runtime
Definition: switch_core.c:64
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624