52 int64_t global_total = 0, global_sum = 0, period_sum = 0;
54 int period_avg = 0, global_avg = 0;
88 data = (int16_t *) read_frame->
data;
91 for (i = 0; i < read_frame->
samples; i++) {
92 const int16_t s = (int16_t) abs(data[i]);
107 period_avg = (int) (period_sum / period_total);
110 "\npacket_avg=%d packet_peak=%d period_avg=%d global_avg=%d\n\n", avg, peak, period_avg, global_avg);
112 if (period_total >= period_len) {
113 global_avg = (int) (global_sum / global_total);
138 unsigned char *abuf = NULL;
174 && (sval = atoi(var))) {
178 if (ms > 10 && sval) {
198 write_frame.
codec = &codec;
200 write_frame.
data = abuf;
211 cng_frame.
data = data;
226 elapsed = (int32_t) ((now - start) / 1000);
240 if (now > done || left <= 0) {
256 if (!args->input_callback && !args->buf && !args->dmachine) {
262 if (args->dmachine) {
263 char ds[2] = {dtmf.
digit,
'\0'};
269 if (args->input_callback) {
271 }
else if (args->buf) {
272 *((
char *) args->buf) = dtmf.
digit;
277 if (args->input_callback) {
300 if (args && args->dmachine) {
306 if (sval && write_frame.
datalen) {
321 if (write_frame.
codec) {
385 if (++sanity >= 10000) {
401 char *remote_ip,
switch_port_t remote_port,
char *transport,
char *flags)
416 if (!strcasecmp(transport,
"udp")) {
417 conninfo->
type = AF_INET;
419 }
else if (!strcasecmp(transport,
"tcp")) {
420 conninfo->
type = AF_INET;
428 if (strstr(flags,
"native")) {
447 "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
501 unsigned long cmd_hash;
535 int frame_count = atoi(lead_frames);
536 int max_frames = frame_count * 2;
538 while (frame_count > 0 && --max_frames > 0) {
549 if (cmd_hash == CMD_EXECUTE) {
559 if (
zstr(app_arg) && !
zstr(content_type) && !strcasecmp(content_type,
"text/plain")) {
564 loops = atoi(loop_h);
569 const char *b_uuid = NULL;
620 for (x = 0; x < loops || loops < 0; x++) {
668 }
else if (cmd_hash == CMD_UNICAST) {
676 if (
zstr(local_ip)) {
677 local_ip =
"127.0.0.1";
679 if (
zstr(remote_ip)) {
680 remote_ip =
"127.0.0.1";
682 if (
zstr(local_port)) {
685 if (
zstr(remote_port)) {
686 remote_port =
"8026";
688 if (
zstr(transport)) {
694 }
else if (cmd_hash == CMD_XFEREXT) {
703 for (hp = event->headers; hp; hp = hp->
next) {
707 if (!strcasecmp(hp->
name,
"application")) {
708 app = strdup(hp->
value);
710 data = strchr(app,
' ');
724 }
else if (cmd_hash == CMD_HANGUP) {
733 }
else if (cmd_hash == CMD_NOMEDIA) {
777 switch(message->message_id) {
911 unsigned char *abuf = NULL;
934 if ((cause_str = strchr(to,
':'))) {
938 if ((timeout = atoi(to)) < 0) {
983 write_frame.
codec = &codec;
985 write_frame.
data = abuf;
1014 if (rate && write_frame.
data && sval) {
1045 uint32_t dlen =
sizeof(decoded);
1048 uint32_t sendlen = 0;
1055 memset(decoded, 255, sendlen);
1071 sendbuf = read_frame->
data;
1072 sendlen = read_frame->
datalen;
1102 if (args && !args->input_callback && !args->buf && !args->dmachine) {
1110 if (args->dmachine) {
1111 char ds[2] = {dtmf.
digit,
'\0'};
1117 if (args->input_callback) {
1126 if (args && args->input_callback) {
1139 if (args && args->dmachine) {
1152 if (write_frame.
codec) {
1174 uint32_t abs_timeout)
1179 uint32_t abs_elapsed = 0, digit_elapsed = 0;
1190 if (digit_timeout) {
1207 if (abs_elapsed >= abs_timeout) {
1212 if (digit_timeout) {
1214 if (digit_elapsed >= digit_timeout) {
1225 if (!args->input_callback && !args->buf && !args->dmachine) {
1231 if (args->dmachine) {
1232 char ds[2] = {dtmf.
digit,
'\0'};
1238 if (args->input_callback) {
1242 if (digit_timeout) {
1269 if (args && args->dmachine) {
1275 if (read_frame && args && (args->read_frame_callback)) {
1291 const
char *terminators,
char *terminator,
1292 uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
1298 uint32_t abs_elapsed = 0, digit_elapsed = 0;
1299 uint32_t eff_timeout = 0;
1301 unsigned char *abuf = NULL;
1328 write_frame.
codec = &codec;
1330 write_frame.
data = abuf;
1336 if (terminator != NULL) {
1340 if (!
zstr(terminators)) {
1341 for (i = 0; i < x; i++) {
1342 if (strchr(terminators, buf[i]) && terminator != NULL) {
1343 *terminator = buf[i];
1355 if (digit_timeout && first_timeout) {
1356 eff_timeout = first_timeout;
1357 }
else if (digit_timeout && !first_timeout) {
1358 first_timeout = eff_timeout = digit_timeout;
1359 }
else if (first_timeout) {
1360 digit_timeout = eff_timeout = first_timeout;
1373 if (abs_elapsed >= abs_timeout) {
1387 if (digit_elapsed >= eff_timeout) {
1398 eff_timeout = digit_timeout;
1402 for (y = 0; y <= maxdigits; y++) {
1407 if (!
zstr(terminators) && strchr(terminators, dtmf.
digit) && terminator != NULL) {
1408 *terminator = dtmf.
digit;
1414 buf[x++] = dtmf.
digit;
1417 if (x >= buflen || x >= maxdigits) {
1432 if (write_frame.
data) {
1440 if (write_frame.
codec) {
1454 const char *other_uuid;
1459 msg.
from = __FILE__;
1505 }
else if (callstate ==
CCS_HELD) {
1519 const char *other_uuid;
1524 msg.
from = __FILE__;
1566 const char *other_uuid = NULL;
1575 msg.
from = __FILE__;
1600 msg2.
from = __FILE__;
1634 if ((flags & SMF_REBRIDGE)
1653 if (other_channel) {
1660 if (other_channel) {
1676 const char *other_uuid = NULL;
1685 msg.
from = __FILE__;
1709 msg2.
from = __FILE__;
1739 if ((flags & SMF_REBRIDGE)
1752 if (other_channel) {
1760 if (other_channel) {
1776 const char *other_uuid;
1784 msg.
from = __FILE__;
1849 if (other_channel) {
1882 const char *other_uuid;
1890 msg.
from = __FILE__;
1943 if (other_channel) {
2038 const
char *context)
2045 const char *uuid = NULL;
2046 const char *max_forwards;
2049 int forwardval = 70;
2050 const char *use_dialplan = dialplan, *use_context = context;
2052 if (
zstr(forwardvar)) {
2056 if (!
zstr(forwardvar)) {
2057 forwardval = atoi(forwardvar) - 1;
2059 if (forwardval <= 0) {
2089 if (
zstr(use_dialplan)) {
2091 if (!
zstr(use_dialplan) && !strcasecmp(use_dialplan,
"inline")) {
2092 use_dialplan = NULL;
2096 if (
zstr(use_context)) {
2097 use_context = profile->
context;
2100 if (
zstr(use_dialplan)) {
2101 use_dialplan =
"XML";
2104 if (
zstr(use_context)) {
2105 use_context =
"default";
2108 if (
zstr(extension)) {
2109 extension =
"service";
2164 msg.
from = __FILE__;
2168 extension, use_context);
2173 extension, use_context, use_dialplan);
2188 const char *val = NULL;
2191 if (var && *var ==
'~') {
2196 if (var && !prefix) {
2205 for (hi = var_event->
headers; hi; hi = hi->
next) {
2206 char *vvar = hi->
name;
2207 char *vval = hi->
value;
2208 if (vvar && vval && (!prefix || (var && !strncmp((
char *) vvar, var, strlen(var))))) {
2241 if (parser != NULL) {
2242 int pool_auto_created = 0;
2249 pool_auto_created = 1;
2257 if (pool && *parser != NULL) {
2259 (*parser)->pool_auto_created = pool_auto_created;
2260 (*parser)->pool =
pool;
2261 (*parser)->digit_timeout_ms = 1000;
2268 if (pool != NULL && pool_auto_created) {
2281 if (parser != NULL) {
2282 if (parser->hash != NULL) {
2284 parser->hash = NULL;
2287 if (parser->pool_auto_created && parser->pool != NULL) {
2300 if (parser && stream && *stream == NULL) {
2303 memset(*stream, 0,
sizeof(**stream));
2329 if (parser != NULL && digits != NULL && *digits && parser->hash != NULL) {
2340 if (len > parser->buflen) {
2341 parser->buflen = len;
2344 if (parser->terminator ==
'\0') {
2345 if (len > parser->maxlen) {
2346 parser->maxlen = len;
2349 if (parser->minlen == 0 || len < parser->minlen) {
2350 parser->minlen = len;
2371 if (parser != NULL && digits != NULL && *digits) {
2384 void *result = NULL;
2391 len = strlen(stream->digits);
2396 if (digit != parser->terminator) {
2400 if (len > 0 && parser->maxlen != 0 && len >= parser->maxlen) {
2401 char *src = stream->digits + 1;
2402 char *dst = stream->digits;
2405 *(dst++) = *(src++);
2409 *(stream->digits + (len++)) = digit;
2410 *(stream->digits + len) =
'\0';
2417 if (parser->maxlen - parser->minlen > 0 && (
switch_micro_time_now() / 1000) - stream->last_digit_time < parser->digit_timeout_ms) {
2426 if (result != NULL || parser->terminator == digit) {
2427 *stream->digits =
'\0';
2441 *stream->digits =
'\0';
2442 stream->last_digit_time = 0;
2452 if (parser != NULL) {
2453 parser->terminator = digit;
2533 if (caller_profile->transfer_source) {
2551 if (caller_profile->soft) {
2554 for (pn = caller_profile->soft; pn; pn = pn->
next) {
2569 #define add_stat(_x, _i, _s) \
2570 switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_SIZE_T_FMT, _i); \
2571 x_tmp = switch_xml_add_child_d(_x, _s, loff++); \
2572 switch_xml_set_txt_d(x_tmp, var_val)
2574 #define add_stat_double(_x, _i, _s) \
2575 switch_snprintf(var_val, sizeof(var_val), "%0.2f", _i); \
2576 x_tmp = switch_xml_add_child_d(_x, _s, loff++); \
2577 switch_xml_set_txt_d(x_tmp, var_val)
2585 char var_val[35] =
"";
2587 if (!stats)
return off;
2676 if ((data = malloc(dlen))) {
2697 for (; hi; hi = hi->
next) {
2701 for (i = 0; i < hi->
idx; i++) {
2717 switch_xml_t variables, cdr, x_main_cp, x_caller_profile, x_caller_extension, x_times, time_tag,
2718 x_application, x_callflow, x_inner_extension, x_apps, x_o, x_channel_data, x_field, xhr, x_hold;
2721 int cdr_off = 0, v_off = 0, cd_off = 0;
2783 for (ap = app_log; ap; ap = ap->
next) {
2805 for (hr = hold_record; hr; hr = hr->
next) {
2831 while (caller_profile) {
2882 int i_off = 0, i_app_off = 0;
2966 if (caller_profile->
times) {
3039 caller_profile = caller_profile->
next;
3072 #define add_jstat(_j, _i, _s) \
3073 switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_SIZE_T_FMT, _i); \
3074 cJSON_AddItemToObject(_j, _s, cJSON_CreateNumber(_i))
3079 cJSON *j_stat, *j_in, *j_out;
3081 char var_val[35] =
"";
3116 cJSON *j_err_log, *j_err;
3153 for (; hi; hi = hi->
next) {
3155 char *data = hi->
value;
3159 if ((data = malloc(dlen))) {
3167 if (data != hi->
value) {
3182 cJSON *variables, *j_main_cp, *j_caller_profile, *j_caller_extension, *j_caller_extension_apps, *j_times, *j_application,
3183 *j_callflow, *j_profile, *j_inner_extension, *j_app_log, *j_apps, *j_o, *j_o_profiles, *j_channel_data, *callStats;
3228 for (ap = app_log; ap; ap = ap->
next) {
3244 while (caller_profile) {
3361 if (caller_profile->
times) {
3401 caller_profile = caller_profile->
next;
3437 if (delay_ms < 1 || delay_ms > 10000) {
3444 if (delay_ms < interval * 2) {
3445 delay_ms = interval * 2;
3449 qlen = delay_ms / (interval);
3478 if (read_frame->
packet) {
3481 }
else if (is_rtp) {
3493 write_frame.
datalen = (uint32_t) plen - 12;
3494 write_frame.
buflen = (uint32_t) plen;
3509 const
char *module_name,
3510 const
char *say_type,
3511 const
char *say_method,
3512 const
char *say_gender,
3518 const char *save_path = NULL, *chan_lang = NULL, *lang = NULL, *sound_path = NULL;
3520 switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL;
3530 if (
zstr(module_name)) {
3539 if ((p = strchr(module_name,
':'))) {
3551 chan_lang = module_name;
3576 module_name = chan_lang;
3579 if (!(sound_path = (
char *)
switch_xml_attr(language,
"sound-prefix"))) {
3580 if (!(sound_path = (
char *)
switch_xml_attr(language,
"sound-path"))) {
3603 status = si->
say_function(session, (
char *) tosay, &say_args, args);
3633 const
char *module_name,
3634 const
char *say_type,
3635 const
char *say_method,
3636 const
char *say_gender,
3642 const char *save_path = NULL, *chan_lang = NULL, *sound_path = NULL;
3644 switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL;
3664 if (!lang) lang =
"en";
3665 if (!chan_lang) chan_lang = lang;
3685 module_name = chan_lang;
3688 if (!(sound_path = (
char *)
switch_xml_attr(language,
"sound-prefix"))) {
3689 if (!(sound_path = (
char *)
switch_xml_attr(language,
"sound-path"))) {
3724 if (save_path && channel) {
3736 static const char *
get_prefixed_str(
char *buffer,
size_t buffer_size,
const char *prefix,
size_t prefix_size,
const char *str)
3748 str_len = strlen(str);
3749 memcpy(buffer, prefix, prefix_size);
3751 if (str_len + prefix_size + 1 > buffer_size) {
3752 memcpy(buffer + prefix_size, str, buffer_size - prefix_size - 1);
3753 buffer[buffer_size - prefix_size - 1] =
'\0';
3755 memcpy(buffer + prefix_size, str, str_len + 1);
3762 const
char *user, const
char *domain,
switch_xml_t x_user)
3769 char *prefix_buffer = NULL;
3770 size_t buffer_size = 0;
3771 size_t prefix_size = 0;
3776 if (!
zstr(prefix)) {
3777 prefix_size = strlen(prefix);
3778 buffer_size = 1024 + prefix_size + 1;
3782 if ((number_alias = (
char *)
switch_xml_attr(x_user,
"number-alias"))) {
3808 if (user && domain) {
3819 char *user, *domain;
3830 if ((prefix = strchr(user,
' '))) {
3834 if (!(domain = strchr(user,
'@'))) {
3899 if (!strncasecmp(cmd,
"speed", 5)) {
3902 if ((p = strchr(cmd,
':'))) {
3904 if (*p ==
'+' || *p ==
'-') {
3906 if (!(step = atoi(p))) {
3911 int speed = atoi(p);
3919 }
else if (!strncasecmp(cmd,
"volume", 6)) {
3922 if ((p = strchr(cmd,
':'))) {
3924 if (*p ==
'+' || *p ==
'-') {
3926 if (!(step = atoi(p))) {
3942 }
else if (!strcasecmp(cmd,
"pause")) {
3952 }
else if (!strcasecmp(cmd,
"stop")) {
3955 }
else if (!strcasecmp(cmd,
"truncate")) {
3957 }
else if (!strcasecmp(cmd,
"restart")) {
3958 unsigned int pos = 0;
3962 }
else if (!strncasecmp(cmd,
"seek", 4)) {
3964 unsigned int samps = 0;
3965 unsigned int pos = 0;
3969 if ((p = strchr(cmd,
':'))) {
3971 if (*p ==
'+' || *p ==
'-') {
3974 if (!(step = atoi(p))) {
3978 samps = step * (fhp->native_rate / 1000);
3979 target = (int32_t)fhp->offset_pos + samps;
3999 if (!strcmp(cmd,
"true") || !strcmp(cmd,
"undefined")) {
4007 #define START_SAMPLES 32768
4017 int16_t *abuf = NULL;
4028 if ((ext = strrchr(file,
'.'))) {
4074 if ((sample_count + olen) > sample_point) {
4075 olen = sample_point - sample_count;
4082 sample_count += olen;
4110 sample_count += olen;
4139 sample_count += olen;
4178 char *cf =
"presence_map.conf";
4183 int proceed = 0, ovector[100];
4188 if ( !
zstr(domain_name) ) {
4192 if ( !
zstr(exten_name) ) {
4208 if (!dname || (strcasecmp(dname,
"*") && strcasecmp(domain_name, dname)))
continue;
4214 if (!
zstr(regex) && !
zstr(proto)) {
4215 proceed =
switch_regex_perform(exten_name, regex, &re, ovector,
sizeof(ovector) /
sizeof(ovector[0]));
4220 exten_name, domain_name, proto, regex);
4268 msg.
from = __FILE__;
#define switch_event_prep_for_delivery(_event)
char * switch_channel_get_cap_string(switch_channel_t *channel)
switch_status_t switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt,...)
switch_status_t switch_ivr_digit_stream_reset(switch_ivr_digit_stream_t *stream)
Reset the collected digit stream to nothing.
#define SWITCH_SIGNAL_BRIDGE_VARIABLE
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
const char * switch_core_get_switchname(void)
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
cJSON * cJSON_CreateObject(void)
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
switch_status_t switch_jb_get_packet(switch_jb_t *jb, switch_rtp_packet_t *packet, switch_size_t *len)
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it's state machine to end.
#define switch_regex_safe_free(re)
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
#define switch_channel_answer(channel)
Answer a channel (initiate/acknowledge a successful connection)
switch_status_t switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
int switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_caller_profile_t *caller_profile, int off)
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
void switch_channel_set_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag)
switch_sockaddr_t * local_addr
cJSON * cJSON_CreateNumber(double num)
char * switch_core_session_sprintf(_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the session ...
switch_status_t switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val)
Set a variable on a given channel.
unsigned int digit_timeout_ms
unsigned int switch_atoui(const char *nptr)
void switch_ivr_bg_media(const char *uuid, switch_media_flag_t flags, switch_bool_t on, switch_bool_t is3p, uint32_t delay)
switch_status_t switch_ivr_digit_stream_parser_set_terminator(switch_ivr_digit_stream_parser_t *parser, char digit)
Set a digit string terminator.
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_core_session_force_locate(uuid_str)
Locate a session based on it's uuid even if the channel is not ready.
An Abstract Representation of a dialplan extension.
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
switch_rtp_numbers_t inbound
switch_core_session_message_types_t message_id
#define SWITCH_CHANNEL_LOG
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_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
switch_status_t switch_ivr_parse_all_signal_data(switch_core_session_t *session)
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
struct switch_hold_record_s * next
switch_say_callback_t say_function
const char * switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr)
returns the value of the requested tag attribute, or NULL if not found
switch_status_t switch_socket_bind(switch_socket_t *sock, switch_sockaddr_t *sa)
switch_status_t switch_ivr_process_indications(switch_core_session_t *session, switch_core_session_message_t *message)
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
#define switch_core_hash_init(_hash)
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
switch_hold_record_t * switch_channel_get_hold_record(switch_channel_t *channel)
#define SWITCH_TRANSFER_SOURCE_VARIABLE
switch_status_t switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args)
Wait for time to pass for a specified number of milliseconds.
struct switch_caller_profile * originatee_caller_profile
switch_status_t switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
switch_status_t switch_ivr_nomedia(const char *uuid, switch_media_flag_t flags)
Signal a session to request indirect media allowing it to exchange media directly with another device...
#define switch_channel_stop_broadcast(_channel)
switch_status_t switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for DTMF digits calling a pluggable callback function when digits are collected.
#define SWITCH_RECOMMENDED_BUFFER_SIZE
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
switch_status_t switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language)
static int switch_ivr_set_xml_chan_var(switch_xml_t xml, const char *var, const char *val, int off)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
static void switch_ivr_set_json_profile_data(cJSON *json, switch_caller_profile_t *caller_profile)
switch_size_t largest_jb_size
struct error_period * next
switch_status_t switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t **stream)
Destroys a digit stream object.
switch_status_t switch_xml_locate_user_merged(const char *key, const char *user_name, const char *domain_name, const char *ip, switch_xml_t *user, switch_event_t *params)
switch_status_t switch_ivr_unhold_uuid(const char *uuid)
Signal the session with a protocol specific unhold message.
const char * network_addr
switch_status_t switch_ivr_broadcast(const char *uuid, const char *path, switch_media_flag_t flags)
Signal the session to broadcast audio.
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
switch_say_method_t method
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
uint32_t decoded_bytes_per_packet
switch_memory_pool_t * pool
#define switch_xml_add_child_d(xml, name, off)
wrapper for switch_xml_add_child() that strdup()s name
Representation of an event.
#define switch_channel_ready(_channel)
switch_say_string_callback_t say_string_function
#define arg_recursion_check_stop(_args)
switch_status_t switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh)
Signal the session with a protocol specific hold message.
An Abstract Representation of a dialplan Application.
void switch_core_session_free_message(switch_core_session_message_t **message)
switch_caller_profile_t * switch_caller_profile_clone(_In_ switch_core_session_t *session, _In_ switch_caller_profile_t *tocopy)
Clone an existing caller profile object.
switch_status_t switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
void switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel's caller profile.
void switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t channels, uint32_t divisor)
Generate static noise.
#define switch_channel_media_ready(_channel)
switch_sockaddr_t * remote_addr
switch_status_t switch_core_codec_decode(switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data, uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
Decode data using a codec handle.
A representation of an XML tree.
switch_memory_pool_t * pool
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
struct switch_caller_profile * next
const char * switch_channel_state_name(_In_ switch_channel_state_t state)
Render the name of the provided state enum.
switch_status_t switch_socket_recv(switch_socket_t *sock, char *buf, switch_size_t *len)
switch_status_t switch_jb_put_packet(switch_jb_t *jb, switch_rtp_packet_t *packet, switch_size_t len)
switch_status_t switch_jb_destroy(switch_jb_t **jbp)
switch_size_t media_bytes
struct real_pcre switch_regex_t
char * switch_url_encode(const char *url, char *buf, size_t len)
switch_status_t switch_ivr_parse_all_events(switch_core_session_t *session)
Parse all commands from an event.
switch_event_header_t * switch_channel_variable_first(switch_channel_t *channel)
Start iterating over the entries in the channel variable list.
switch_status_t switch_ivr_media(const char *uuid, switch_media_flag_t flags)
Signal a session to request direct media access to it's remote end.
switch_size_t dtmf_packet_count
static switch_thread_t * thread
char * switch_channel_get_flag_string(switch_channel_t *channel)
int switch_snprintf(_Out_z_cap_(len) char *buf, _In_ switch_size_t len, _In_z_ _Printf_format_string_ const char *format,...)
static const char * get_prefixed_str(char *buffer, size_t buffer_size, const char *prefix, size_t prefix_size, const char *str)
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
int switch_ivr_set_xml_call_stats(switch_xml_t xml, switch_core_session_t *session, int off, switch_media_type_t type)
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
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.
A message object designed to allow unlike technologies to exchange data.
switch_codec_t * switch_core_session_get_read_codec(_In_ switch_core_session_t *session)
Retrieve the read codec from a given session.
#define SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE
#define SWITCH_PARK_AFTER_BRIDGE_VARIABLE
struct switch_caller_application * next
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_thread_join(switch_status_t *retval, switch_thread_t *thd)
switch_status_t switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
#define switch_core_session_execute_application(_a, _b, _c)
Execute an application on a session.
_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.
switch_status_t switch_ivr_parse_next_event(switch_core_session_t *session)
#define SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE
switch_status_t switch_file_rename(const char *from_path, const char *to_path, switch_memory_pool_t *pool)
#define SWITCH_MUTEX_NESTED
void switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state)
static void unicast_thread_launch(switch_unicast_conninfo_t *conninfo)
#define SWITCH_PATH_SEPARATOR
const switch_codec_implementation_t * implementation
switch_port_t remote_port
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
switch_status_t switch_ivr_collect_digits_count(switch_core_session_t *session, char *buf, switch_size_t buflen, switch_size_t maxdigits, const char *terminators, char *terminator, uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up...
switch_rtcp_numbers_t rtcp
switch_byte_t switch_byte_t * buf
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
#define switch_channel_audio_sync(_c)
SWITCH_BEGIN_EXTERN_C switch_status_t switch_jb_create(switch_jb_t **jbp, switch_jb_type_t type, uint32_t min_frame_len, uint32_t max_frame_len, switch_memory_pool_t *pool)
#define switch_normalize_volume(x)
const char * switch_channel_get_hold_music(switch_channel_t *channel)
switch_status_t switch_ivr_digit_stream_parser_del_event(switch_ivr_digit_stream_parser_t *parser, char *digits)
Delete a string to action mapping.
char * switch_core_get_uuid(void)
Retrieve the unique identifier from the core.
switch_status_t switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len)
static switch_bool_t switch_is_moh(const char *s)
switch_status_t switch_ivr_parse_event(switch_core_session_t *session, switch_event_t *event)
Abstract interface to a say module.
void cJSON_AddItemToArray(cJSON *array, cJSON *item)
switch_status_t switch_core_session_dequeue_signal_data(switch_core_session_t *session, void **signal_data)
switch_status_t switch_channel_add_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check, switch_stack_t stack)
char * switch_event_get_body(switch_event_t *event)
Retrieve the body value from an event.
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
uint32_t actual_samples_per_second
void switch_channel_clear_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler)
clear a state handler table from a given channel
#define switch_channel_get_variable(_c, _v)
#define SWITCH_THREAD_STACKSIZE
switch_status_t switch_channel_dequeue_dtmf(_In_ switch_channel_t *channel, _In_ switch_dtmf_t *dtmf)
Retrieve DTMF digits from a given channel.
switch_caller_application_t * applications
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
switch_status_t switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser)
Create a digit stream parser object.
#define switch_zmalloc(ptr, len)
switch_codec_t read_codec
const char * caller_id_name
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
#define add_stat(_x, _i, _s)
switch_rtp_numbers_t outbound
switch_thread_start_t func
switch_xml_t switch_xml_new(_In_opt_z_ const char *name)
returns a new empty switch_xml structure with the given root tag name
switch_status_t switch_ivr_uuid_bridge(const char *originator_uuid, const char *originatee_uuid)
Bridge two existing sessions.
struct switch_caller_profile * children
#define switch_channel_ring_ready(channel)
Send Ringing message to a channel.
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_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
switch_status_t switch_ivr_hold_toggle_uuid(const char *uuid, const char *message, switch_bool_t moh)
Toggles channel hold state of session.
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
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.
switch_call_cause_t switch_channel_str2cause(_In_ const char *str)
return a cause code for a given string
switch_time_t last_digit_time
#define SWITCH_IVR_VERIFY_SILENCE_DIVISOR(divisor)
struct profile_node_s * next
struct switch_caller_profile * origination_caller_profile
An abstraction of a data frame.
#define arg_recursion_check_start(_args)
#define switch_set_flag_locked(obj, flag)
Set a flag on an arbitrary object while locked.
void switch_caller_extension_add_application(_In_ switch_core_session_t *session, _In_ switch_caller_extension_t *caller_extension, _In_z_ const char *application_name, _In_z_ const char *extra_data)
Add an application (instruction) to the given extension.
switch_status_t switch_ivr_transfer_variable(switch_core_session_t *sessa, switch_core_session_t *sessb, char *var)
Transfer variables from one session to another.
static void *SWITCH_THREAD_FUNC media_thread_run(switch_thread_t *thread, void *obj)
switch_byte_t switch_byte_t uint32_t buflen
#define switch_core_codec_init(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool)
Initialize a codec handle.
const char * profile_index
void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
void switch_cond_next(void)
struct switch_caller_profile * originator_caller_profile
const char * switch_channel_get_hold_music_partner(switch_channel_t *channel)
int microseconds_per_packet
int switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
switch_channel_callstate_t
switch_say_gender_t gender
switch_size_t packet_count
#define SWITCH_BRIDGE_VARIABLE
switch_caller_application_t * current_application
switch_caller_extension_t * switch_caller_extension_new(_In_ switch_core_session_t *session, _In_z_ const char *extension_name, _In_z_ const char *extension_number)
Create a new extension with desired parameters.
void * switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key)
Delete data from a hash based on desired key.
switch_mutex_t * flag_mutex
switch_status_t switch_ivr_digit_stream_parser_set_event(switch_ivr_digit_stream_parser_t *parser, char *digits, void *data)
Set a digit string to action mapping.
#define switch_core_session_receive_message(_session, _message)
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
void * switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t *stream, char digit)
Feed digits collected into the stream for event match testing.
switch_directories SWITCH_GLOBAL_dirs
#define add_stat_double(_x, _i, _s)
switch_size_t jb_packet_count
switch_status_t switch_ivr_parse_next_signal_data(switch_core_session_t *session)
switch_status_t switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
cJSON * cJSON_CreateString(const char *string)
switch_size_t skip_packet_count
switch_status_t switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream)
Create a new digit stream object.
#define switch_str_nil(s)
Make a null string a blank string instead.
switch_frame_t write_frame
void switch_jb_debug_level(switch_jb_t *jb, uint8_t level)
#define switch_xml_set_attr_d_buf(xml, name, value)
void switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
#define SWITCH_R_SDP_VARIABLE
uint32_t samples_per_packet
switch_status_t switch_ivr_3p_nomedia(const char *uuid, switch_media_flag_t flags)
switch_status_t switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
switch_status_t switch_ivr_activate_unicast(switch_core_session_t *session, char *local_ip, switch_port_t local_port, char *remote_ip, switch_port_t remote_port, char *transport, char *flags)
#define switch_clear_flag_locked(obj, flag)
Clear a flag on an arbitrary object.
uint8_t number_of_channels
uint32_t samples_per_second
switch_status_t switch_ivr_generate_json_cdr(switch_core_session_t *session, cJSON **json_cdr, switch_bool_t urlencode)
Generate an JSON CDR report.
switch_status_t
Common return values.
void * switch_channel_get_private(switch_channel_t *channel, const char *key)
Retrieve private from a given channel.
#define switch_goto_status(_status, _label)
struct error_period * error_log
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_say_interface_t * switch_loadable_module_get_say_interface(const char *name)
Retrieve the say interface by it's registered name.
switch_status_t switch_ivr_unhold(switch_core_session_t *session)
Signal the session with a protocol specific unhold message.
#define SWITCH_SIGNAL_BOND_VARIABLE
switch_xml_t switch_xml_open_cfg(_In_z_ const char *file_path, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params)
open a config in the core registry
char * destination_number
void switch_channel_variable_last(switch_channel_t *channel)
Stop iterating over channel variables.
switch_status_t switch_socket_close(switch_socket_t *sock)
switch_size_t switch_channel_has_dtmf(_In_ switch_channel_t *channel)
Test for presence of DTMF on a given channel.
switch_status_t switch_event_dup_reply(switch_event_t **event, switch_event_t *todup)
#define switch_core_hash_insert(_h, _k, _d)
switch_status_t switch_socket_shutdown(switch_socket_t *sock, switch_shutdown_how_e how)
struct apr_thread_t switch_thread_t
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
char body[SWITCH_RTP_MAX_BUF_LEN+4+sizeof(char *)]
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
switch_status_t switch_ivr_parse_signal_data(switch_core_session_t *session, switch_bool_t all, switch_bool_t only_session_thread)
switch_size_t flush_packet_count
#define switch_xml_set_txt_d(xml, txt)
wrapper for switch_xml_set_txt() that strdup()s txt \ sets the character content for the given tag an...
#define SWITCH_TEMP_HOLD_MUSIC_VARIABLE
unsigned int switch_hashfunc_default(const char *key, switch_ssize_t *klen)
void switch_uuid_get(switch_uuid_t *uuid)
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.
void switch_channel_transfer_to_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
#define switch_event_get_header(_e, _h)
#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_core_session_t * session
switch_size_t media_packet_count
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
switch_app_log_t * switch_core_session_get_app_log(_In_ switch_core_session_t *session)
struct switch_channel_timetable * times
int switch_ivr_set_xml_chan_vars(switch_xml_t xml, switch_channel_t *channel, int off)
#define SWITCH_TRANSFER_HISTORY_VARIABLE
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
const char * caller_id_number
cJSON * cJSON_CreateArray(void)
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
struct apr_pool_t switch_memory_pool_t
uint32_t switch_media_flag_t
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_channel_clear_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag)
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_status_t switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
A table of settings and callbacks that define a paticular implementation of a codec.
switch_channel_callstate_t switch_channel_get_callstate(switch_channel_t *channel)
#define SWITCH_MAX_SESSION_TRANSFERS_VARIABLE
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
switch_status_t switch_ivr_deactivate_unicast(switch_core_session_t *session)
#define switch_xml_set_attr_d(xml, name, value)
Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL.
void switch_event_destroy(switch_event_t **event)
Destroy an event.
static void switch_ivr_set_json_chan_vars(cJSON *json, switch_channel_t *channel, switch_bool_t urlencode)
switch_status_t switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to, switch_channel_t *super_channel)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
switch_status_t switch_ivr_signal_bridge(switch_core_session_t *session, switch_core_session_t *peer_session)
Bridge Signalling from one session to another.
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...
switch_status_t switch_ivr_3p_media(const char *uuid, switch_media_flag_t flags)
#define SWITCH_MAX_FORWARDS_VARIABLE
#define switch_channel_set_variable(_channel, _var, _val)
switch_status_t switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool)
switch_status_t switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr)
Generate an XML CDR report.
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
switch_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel's caller profile.
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_status_t switch_ivr_hold_uuid(const char *uuid, const char *message, switch_bool_t moh)
Signal the session with a protocol specific hold message.
#define SWITCH_READ_ACCEPTABLE(status)
#define switch_channel_media_up(_channel)
switch_byte_t write_frame_data[SWITCH_RECOMMENDED_BUFFER_SIZE]
switch_bool_t switch_core_session_in_thread(switch_core_session_t *session)
void switch_ivr_set_json_call_stats(cJSON *json, switch_core_session_t *session, switch_media_type_t type)
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
switch_status_t switch_ivr_digit_stream_parser_destroy(switch_ivr_digit_stream_parser_t *parser)
Destroy a digit stream parser object.
#define SWITCH_UUID_FORMATTED_LENGTH
switch_event_header_t * headers
switch_memory_pool_t * pool
struct switch_app_log * next
struct switch_caller_extension * caller_extension
static void *SWITCH_THREAD_FUNC unicast_thread_run(switch_thread_t *thread, void *obj)
switch_status_t switch_thread_pool_launch_thread(switch_thread_data_t **tdp)
switch_size_t cng_packet_count
#define add_jstat(_j, _i, _s)
switch_status_t switch_ivr_parse_all_messages(switch_core_session_t *session)
switch_memory_pool_t * pool