RTS API Documentation  1.10.11
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
 
 VAD code with optional libfvad
 
 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)
 
void switch_core_pool_stats (switch_stream_handle_t *stream)
 
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

◆ switch_core_memory_pool_tag()

void switch_core_memory_pool_tag ( switch_memory_pool_t pool,
const char *  tag 
)

Definition at line 331 of file switch_core_memory.c.

Referenced by switch_core_session_thread().

332 {
333  fspr_pool_tag(pool, tag);
334 }
switch_memory_pool_t * pool

◆ switch_core_perform_new_memory_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_pool_stats()

void switch_core_pool_stats ( switch_stream_handle_t stream)

Definition at line 376 of file switch_core_memory.c.

References switch_runtime::memory_pool, runtime, and switch_stream_handle::write_function.

377 {
378 #if APR_POOL_DEBUG
379  if (runtime.memory_pool) {
380  fspr_pool_walk_tree_debug(runtime.memory_pool, switch_core_pool_stats_callback, (void *)stream);
381  }
382 #else
383  if (stream) {
384  stream->write_function(stream, "Unable to get core pool statictics. Please rebuild FreeSWITCH with --enable-pool-debug");
385  } else {
386  printf("Unable to get core pool statictics. Please rebuild FreeSWITCH with --enable-pool-debug");
387  }
388 #endif
389 }
struct switch_runtime runtime
Definition: switch_core.c:86
switch_stream_handle_write_function_t write_function
switch_memory_pool_t * memory_pool

◆ switch_core_session_request_xml()

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

2150 {
2151  switch_core_session_t *session;
2152  switch_channel_t *channel;
2153  switch_xml_t tag, tag2, tag3, vars, callflow;
2155  char *flag_str = NULL, *cap_str = NULL, *direction_s = NULL, *uuid = NULL;
2156  uint32_t flags[CF_FLAG_MAX] = { 0 };
2157  uint32_t caps[CC_FLAG_MAX] = { 0 };
2158  int i;
2159 
2160  vars = switch_xml_child(xml, "variables");
2161  uuid = xml_find_var(vars, "uuid");
2162 
2163  if ((tag = switch_xml_child(xml, "channel_data"))) {
2164  direction_s = xml_find_var(tag, "direction");
2165  direction = !strcmp(direction_s, "outbound") ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND;
2166  flag_str = xml_find_var(tag, "flags");
2167  cap_str = xml_find_var(tag, "caps");
2168  }
2169 
2170  parse_array(flag_str, flags, CF_FLAG_MAX);
2171  parse_array(cap_str, caps, CC_FLAG_MAX);
2172 
2173  flags[CF_RECOVERING] = 0;
2174  flags[CF_RECOVERING_BRIDGE] = 0;
2175  flags[CF_TRACKED] = 0;
2176  flags[CF_TRANSFER] = 0;
2177  flags[CF_ACCEPT_CNG] = 0;
2178  flags[CF_REDIRECT] = 0;
2179  flags[CF_BRIDGED] = 0;
2180  flags[CF_HOLD] = 0;
2181  flags[CF_SERVICE] = 0;
2182  flags[CF_TAGGED] = 0;
2183  flags[CF_WINNER] = 0;
2184  flags[CF_EARLY_OK] = 0;
2185  flags[CF_CONTROLLED] = 0;
2186  flags[CF_SUSPEND] = 0;
2187  flags[CF_EVENT_PARSE] = 0;
2188  flags[CF_GEN_RINGBACK] = 0;
2189  flags[CF_BREAK] = 0;
2190  flags[CF_BROADCAST] = 0;
2191  flags[CF_UNICAST] = 0;
2192  flags[CF_EVENT_LOCK] = 0;
2193  flags[CF_EVENT_LOCK_PRI] = 0;
2194  flags[CF_RESET] = 0;
2195  flags[CF_ORIGINATING] = 0;
2196  flags[CF_STOP_BROADCAST] = 0;
2197  flags[CF_INNER_BRIDGE] = 0;
2198  flags[CF_REQ_MEDIA] = 0;
2199  flags[CF_PAUSE_BUGS] = 0;
2200  flags[CF_DIVERT_EVENTS] = 0;
2201  flags[CF_BLOCK_STATE] = 0;
2202  flags[CF_FS_RTP] = 0;
2203  flags[CF_REPORTING] = 0;
2204  flags[CF_PARK] = 0;
2205  flags[CF_TIMESTAMP_SET] = 0;
2206  flags[CF_ORIGINATOR] = 0;
2207  flags[CF_XFER_ZOMBIE] = 0;
2208  flags[CF_MEDIA_ACK] = 0;
2209  flags[CF_THREAD_SLEEPING] = 0;
2210  flags[CF_DISABLE_RINGBACK] = 0;
2211  flags[CF_NOT_READY] = 0;
2212  flags[CF_SIGNAL_BRIDGE_TTL] = 0;
2213  flags[CF_MEDIA_BRIDGE_TTL] = 0;
2214  flags[CF_BYPASS_MEDIA_AFTER_BRIDGE] = 0;
2215  flags[CF_LEG_HOLDING] = 0;
2216  flags[CF_BROADCAST_DROP_MEDIA] = 0;
2217  flags[CF_EARLY_HANGUP] = 0;
2218  flags[CF_MEDIA_SET] = 0;
2219  flags[CF_CONSUME_ON_ORIGINATE] = 0;
2220  flags[CF_PASSTHRU_PTIME_MISMATCH] = 0;
2221  flags[CF_BRIDGE_NOWRITE] = 0;
2222  flags[CF_RECOVERED] = 0;
2223  flags[CF_JITTERBUFFER] = 0;
2224  flags[CF_JITTERBUFFER_PLC] = 0;
2225  flags[CF_DIALPLAN] = 0;
2226  flags[CF_BLOCK_BROADCAST_UNTIL_MEDIA] = 0;
2227  flags[CF_CNG_PLC] = 0;
2228  flags[CF_ATTENDED_TRANSFER] = 0;
2229  flags[CF_LAZY_ATTENDED_TRANSFER] = 0;
2230  flags[CF_SIGNAL_DATA] = 0;
2231  flags[CF_SIMPLIFY] = 0;
2232  flags[CF_VIDEO_READY] = 0;
2233  flags[CF_VIDEO_DECODED_READ] = 0;
2234 
2235  if (!(session = switch_core_session_request_uuid(endpoint_interface, direction, SOF_NO_LIMITS, pool, uuid))) {
2236  return NULL;
2237  }
2238 
2239  channel = switch_core_session_get_channel(session);
2240 
2241  for (i = 0; i < CF_FLAG_MAX; i++) {
2242  if (flags[i]) {
2243  switch_channel_set_flag_value(channel, i, flags[i]);
2244  }
2245  }
2246 
2247  for (i = 0; i < CC_FLAG_MAX; i++) {
2248  if (caps[i]) {
2249  switch_channel_set_cap_value(channel, i, caps[i]);
2250  }
2251  }
2252 
2253  if ((tag2 = switch_xml_child(xml, "variables"))) {
2254  for (tag = tag2->child; tag; tag = tag->sibling) {
2255  if (tag->name && tag->txt) {
2256  char *p = strdup(tag->txt);
2257  char *val = p;
2258  switch_url_decode(val);
2259  switch_channel_set_variable(channel, tag->name, val);
2260  if (!strcasecmp(tag->name, "channel_name")) {
2261  switch_channel_set_name(channel, val);
2262  }
2263  free(p);
2264  }
2265  }
2266  }
2267 
2268  if ((callflow = switch_xml_child(xml, "callflow"))) {
2269  if ((tag2 = switch_xml_child(callflow, "caller_profile"))) {
2270  switch_caller_profile_t *caller_profile;
2271  char *tmp;
2272 
2273  caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
2274  xml_find_var(tag2, "username"),
2275  xml_find_var(tag2, "dialplan"),
2276  xml_find_var(tag2, "caller_id_name"),
2277  xml_find_var(tag2, "caller_id_number"),
2278  xml_find_var(tag2, "network_addr"),
2279  xml_find_var(tag2, "ani"),
2280  xml_find_var(tag2, "aniii"),
2281  xml_find_var(tag2, "rdnis"),
2282  xml_find_var(tag2, "source"),
2283  xml_find_var(tag2, "context"), xml_find_var(tag2, "destination_number"));
2284 
2285  if ((tmp = xml_find_var(tag2, "callee_id_name"))) {
2286  caller_profile->callee_id_name = switch_core_session_strdup(session, tmp);
2287  }
2288 
2289  if ((tmp = xml_find_var(tag2, "callee_id_number"))) {
2290  caller_profile->callee_id_number = switch_core_session_strdup(session, tmp);
2291  }
2292 
2293  if ((tag3 = switch_xml_child(callflow, "times"))) {
2294  caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(session, sizeof(*caller_profile->times));
2295 
2296  caller_profile->times->resurrected = switch_time_now();
2297 
2298  for (tag3 = tag3->child; tag3; tag3 = tag3->sibling) {
2299  int64_t v;
2300 
2301  if (tag3->name && tag3->txt) {
2302  v = atoll(tag3->txt);
2303  if (!strcmp(tag3->name, "created_time")) {
2304  caller_profile->times->created = v;
2305  } else if (!strcmp(tag3->name, "profile_created_time")) {
2306  caller_profile->times->profile_created = v;
2307  } else if (!strcmp(tag3->name, "progress_time")) {
2308  caller_profile->times->progress = v;
2309  } else if (!strcmp(tag3->name, "progress_media_time")) {
2310  caller_profile->times->progress_media = v;
2311  } else if (!strcmp(tag3->name, "answered_time")) {
2312  caller_profile->times->answered = v;
2313  } else if (!strcmp(tag3->name, "hangup_time")) {
2314  caller_profile->times->hungup = v;
2315  } else if (!strcmp(tag3->name, "transfer_time")) {
2316  caller_profile->times->transferred = v;
2317  }
2318  }
2319 
2320  }
2321  }
2322 
2323  switch_channel_set_caller_profile(channel, caller_profile);
2324  if ((tag = switch_xml_child(tag2, "originator")) && (tag = tag->child)) {
2325  caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
2326  xml_find_var(tag, "username"),
2327  xml_find_var(tag, "dialplan"),
2328  xml_find_var(tag, "caller_id_name"),
2329  xml_find_var(tag, "caller_id_number"),
2330  xml_find_var(tag, "network_addr"),
2331  xml_find_var(tag, "ani"),
2332  xml_find_var(tag, "aniii"),
2333  xml_find_var(tag, "rdnis"),
2334  xml_find_var(tag, "source"),
2335  xml_find_var(tag, "context"), xml_find_var(tag, "destination_number"));
2336 
2337  switch_channel_set_originator_caller_profile(channel, caller_profile);
2338  }
2339 
2340  if ((tag = switch_xml_child(tag2, "originatee")) && (tag = tag->child)) {
2341  caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
2342  xml_find_var(tag, "username"),
2343  xml_find_var(tag, "dialplan"),
2344  xml_find_var(tag, "caller_id_name"),
2345  xml_find_var(tag, "caller_id_number"),
2346  xml_find_var(tag, "network_addr"),
2347  xml_find_var(tag, "ani"),
2348  xml_find_var(tag, "aniii"),
2349  xml_find_var(tag, "rdnis"),
2350  xml_find_var(tag, "source"),
2351  xml_find_var(tag, "context"), xml_find_var(tag, "destination_number"));
2352 
2353  switch_channel_set_originatee_caller_profile(channel, caller_profile);
2354  }
2355 
2356  }
2357 
2358 
2360  }
2361 
2362 
2363  if (!channel || !switch_channel_get_caller_profile(channel)) {
2364  if (session) {
2365  switch_core_session_destroy(&session);
2366  }
2367  }
2368 
2369 
2370  return session;
2371 }
switch_xml_t sibling
Definition: switch_xml.h:93
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:81
Call Specific Data.
Definition: switch_caller.h:73
switch_call_direction_t
Definition: switch_types.h:307
switch_xml_t child
Definition: switch_xml.h:97
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&#39;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:79
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:85
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:817
void switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel&#39;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&#39;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&#39;s pool.
Definition: switch_core.h:696
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session&#39;s pool.
Definition: switch_core.h:719
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
Definition: switch_apr.c:325
switch_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel&#39;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

◆ switch_core_test_flag()

int switch_core_test_flag ( int  flag)

Definition at line 1792 of file switch_core.c.

References switch_test_flag.

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

1793 {
1794  return switch_test_flag((&runtime), flag);
1795 }
struct switch_runtime runtime
Definition: switch_core.c:86
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693