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

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