186 return channel->hold_record;
192 const char *str =
"UNKNOWN";
195 if (CAUSE_CHART[x].cause == cause) {
196 str = CAUSE_CHART[x].
name;
210 if (*str > 47 && *str < 58) {
214 if (!strcasecmp(CAUSE_CHART[x].name, str)) {
215 cause = CAUSE_CHART[x].
cause;
227 return channel->hangup_cause;
233 return &channel->hangup_cause;
271 const
char *file, const
char *func,
int line)
276 if (o_callstate == callstate || o_callstate ==
CCS_HANGUP)
return;
278 channel->callstate = callstate;
279 if (channel->device_node) {
280 channel->device_node->callstate = callstate;
283 "(%s) Callstate Change %s -> %s\n", channel->name,
298 return channel->callstate;
305 const char *str =
"UNKNOWN";
308 if (CALLSTATE_CHART[x].callstate == callstate) {
309 str = CALLSTATE_CHART[x].
name;
320 const char *str =
"UNKNOWN";
323 if (DEVICE_STATE_CHART[x].device_state == device_state) {
324 str = DEVICE_STATE_CHART[x].
name;
338 if (*str > 47 && *str < 58) {
339 callstate = atoi(str);
342 if (!strcasecmp(CALLSTATE_CHART[x].
name, str)) {
343 callstate = CALLSTATE_CHART[x].
callstate;
361 msg->
from = channel->name;
380 msg->
from = channel->name;
410 if (channel->caller_profile) {
412 times = channel->caller_profile->times;
422 channel->direction = channel->logical_direction = direction;
429 return channel->direction;
434 return channel->logical_direction;
457 (*channel)->name =
"";
458 (*channel)->direction = (*channel)->logical_direction = direction;
518 if (new_dtmf.
digit !=
'w' && new_dtmf.
digit !=
'W') {
571 if (
zstr(dtmf_string)) {
578 if (*dtmf_string ==
'~') {
586 for (i = 0; i < argc; i++) {
589 if ((p = strchr(argv[i],
'@'))) {
596 for (p = argv[i]; p && *p; p++) {
652 }
else if (!dtmf->duration) {
661 const char *dtmf_source_str = NULL;
665 switch(dtmf->source) {
667 dtmf_source_str =
"INBAND_AUDIO";
670 dtmf_source_str =
"RTP";
673 dtmf_source_str =
"ENDPOINT";
676 dtmf_source_str =
"APP";
680 dtmf_source_str =
"UNKNOWN";
702 dtmf_str[x++] = dtmf.
digit;
731 if (channel->private_hash) {
735 if (channel->app_flag_hash) {
751 channel->state = state;
753 channel->session = session;
754 channel->running_state =
CS_NONE;
759 const
char *file, const
char *func,
int line)
763 const char *call_info = NULL;
764 char *call_info_state =
"active";
802 call_info_state =
"idle";
803 }
else if (!strcasecmp(status,
"hold-private")) {
804 call_info_state =
"held-private";
805 }
else if (!strcasecmp(status,
"hold")) {
806 call_info_state =
"held";
809 call_info_state =
"progressing";
812 call_info_state =
"idle";
814 call_info_state =
"alerting";
885 if (expanded != var) {
898 const char *r = NULL;
912 if (event && *event) {
913 (*event)->next = channel->scope_variables;
914 channel->scope_variables = *event;
916 }
else if (channel->scope_variables) {
918 channel->scope_variables = channel->scope_variables->
next;
932 if (channel->scope_variables) {
940 for (ep = channel->scope_variables; ep; ep = ep->
next) {
955 const char *v = NULL, *r = NULL, *vdup = NULL;
960 if (!
zstr(varname)) {
961 if (channel->scope_variables) {
964 for (ep = channel->scope_variables; ep; ep = ep->
next) {
975 if (!strncmp(varname,
"aleg_", 5)) {
978 }
else if (!strncmp(varname,
"bleg_", 5)) {
992 if (dup && v != vdup) {
1008 const char *val = NULL, *r = NULL;
1011 if (!
zstr(varname)) {
1046 if (channel->variables && (hi = channel->variables->headers)) {
1090 const char *old = NULL;
1093 if (!
zstr(channel->name)) {
1094 old = channel->name;
1096 channel->name = NULL;
1113 return (!
zstr(channel->name)) ? channel->name :
"N/A";
1124 if (!strcasecmp(name,
"device_id") && !
zstr(val)) {
1125 const char *device_id;
1141 if (!strcasecmp(name,
"dialplan")) {
1142 channel->caller_profile->dialplan = v;
1143 }
else if (!strcasecmp(name,
"username")) {
1144 channel->caller_profile->username = v;
1145 }
else if (!strcasecmp(name,
"caller_id_name")) {
1146 channel->caller_profile->caller_id_name = v;
1147 }
else if (!strcasecmp(name,
"caller_id_number")) {
1148 channel->caller_profile->caller_id_number = v;
1149 }
else if (!strcasecmp(name,
"callee_id_name")) {
1150 channel->caller_profile->callee_id_name = v;
1151 }
else if (!strcasecmp(name,
"callee_id_number")) {
1152 channel->caller_profile->callee_id_number = v;
1153 }
else if (val && !strcasecmp(name,
"caller_ton")) {
1154 channel->caller_profile->caller_ton = (uint8_t) atoi(v);
1155 }
else if (val && !strcasecmp(name,
"caller_numplan")) {
1156 channel->caller_profile->caller_numplan = (uint8_t) atoi(v);
1157 }
else if (val && !strcasecmp(name,
"destination_number_ton")) {
1158 channel->caller_profile->destination_number_ton = (uint8_t) atoi(v);
1159 }
else if (val && !strcasecmp(name,
"destination_number_numplan")) {
1160 channel->caller_profile->destination_number_numplan = (uint8_t) atoi(v);
1161 }
else if (!strcasecmp(name,
"ani")) {
1162 channel->caller_profile->ani = v;
1163 }
else if (!strcasecmp(name,
"aniii")) {
1164 channel->caller_profile->aniii = v;
1165 }
else if (!strcasecmp(name,
"network_addr")) {
1166 channel->caller_profile->network_addr = v;
1167 }
else if (!strcasecmp(name,
"rdnis")) {
1168 channel->caller_profile->rdnis = v;
1169 }
else if (!strcasecmp(name,
"destination_number")) {
1170 channel->caller_profile->destination_number = v;
1171 }
else if (!strcasecmp(name,
"uuid")) {
1172 channel->caller_profile->uuid = v;
1173 }
else if (!strcasecmp(name,
"source")) {
1174 channel->caller_profile->source = v;
1175 }
else if (!strcasecmp(name,
"context")) {
1176 channel->caller_profile->context = v;
1177 }
else if (!strcasecmp(name,
"chan_name")) {
1178 channel->caller_profile->chan_name = v;
1186 if (!channel->caller_profile->soft) {
1187 channel->caller_profile->soft = n;
1191 for(pn = channel->caller_profile->soft; pn ; pn = pn->
next) {
1192 if (!strcasecmp(pn->
var,n->
var)) {
1203 if (pn && !pn->
next && !var_found) {
1223 if (
zstr(export_vars))
return;
1238 for (x = 0; x < argc; x++) {
1241 char *vvar = argv[x];
1242 if (!strncasecmp(vvar,
"nolocal:", 8)) {
1244 }
else if (!strncasecmp(vvar,
"_nolocal_", 9)) {
1251 "%s EXPORTING[%s] [%s]=[%s] to event\n",
1258 "%s EXPORTING[%s] [%s]=[%s] to %s\n",
1272 const
char *varname, const
char *val,
1275 char *var_name = NULL;
1276 const char *exports;
1277 char *var, *new_exports, *new_exports_d = NULL;
1285 if (!strncasecmp(var,
"nolocal:", 8)) {
1288 }
else if (!strncasecmp(var,
"_nolocal_", 9)) {
1297 export_varname, local ?
"" :
"(REMOTE ONLY) ",
1298 var_name ? var_name :
"", val ? val :
"UNDEF");
1306 new_exports = new_exports_d;
1320 const
char *export_varname, const
char *fmt, ...)
1355 if (
zstr(prefix) || !strncasecmp(hp->
name, prefix, strlen(prefix))) {
1372 for (; hi; hi = hi->
next) {
1373 char *var = hi->
name;
1374 char *val = hi->
value;
1376 if (
zstr(prefix) || !strncasecmp(var, prefix, strlen(prefix))) {
1389 char *cols[128] = { 0 };
1390 char header_name[128] =
"";
1391 int col_count = 0, i = 0;
1392 char *data_copy = NULL;
1394 if (
zstr(presence_data_cols)) {
1396 if (
zstr(presence_data_cols)) {
1401 data_copy = strdup(presence_data_cols);
1405 for (i = 0; i < col_count; i++) {
1406 const char *val = NULL;
1417 const
char *varname, const
char *value,
switch_bool_t var_check)
1424 if (channel->variables && !
zstr(varname)) {
1455 if (channel->variables && !
zstr(varname)) {
1490 if (channel->variables && !
zstr(varname)) {
1542 const
char *varname, const
char *value,
switch_bool_t var_check)
1547 if (!
zstr(varname)) {
1569 r = channel->flags[flag];
1635 if ((channel->state <
CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) ||
1651 if ((channel->state == channel->running_state && channel->running_state == want_state) || channel->state >=
CS_HANGUP) {
1659 if (++count >= timeout) {
1710 channel->caps[cap] = value;
1720 channel->caps[cap] = 0;
1727 return channel->caps[cap] ? 1 : 0;
1758 if (channel->flags[i]) {
1764 r = (
char *) stream.
data;
1784 if (channel->caps[i]) {
1790 r = (
char *) stream.
data;
1812 if (channel->flags[flag] != value) {
1814 channel->flags[flag] = value;
1829 if (channel->device_node) {
1834 if (channel->device_node) {
1854 if (channel->hold_record) {
1855 hr->
next = channel->hold_record;
1857 channel->hold_record = hr;
1885 channel->flags[flag]++;
1902 channel->private_flags |= flags;
1910 channel->private_flags &= ~flags;
1917 return (channel->private_flags & flags);
1922 uint32_t *flagp = NULL;
1928 if (!channel->app_flag_hash) {
1946 uint32_t *flagp = NULL;
1963 uint32_t *flagp = NULL;
1968 r = (*flagp & flags);
1981 channel->state_flags[0] = 1;
1982 channel->state_flags[flag] = 1;
1991 channel->state_flags[flag] = 0;
2011 if (channel->flags[flag]) {
2016 channel->flags[flag] = 0;
2022 if (channel->device_node) {
2031 if (channel->caller_profile->times->last_hold) {
2032 channel->caller_profile->times->hold_accum += (
switch_time_now() - channel->caller_profile->times->last_hold);
2035 if (channel->hold_record) {
2075 if (channel->flags[flag]) {
2076 channel->flags[flag]--;
2090 state = channel->state;
2100 state = channel->running_state;
2111 return channel->running_state != channel->state;
2160 "CS_EXCHANGE_MEDIA",
2174 return state_names[state];
2181 for (x = 0; state_names[x]; x++) {
2182 if (!strcasecmp(state_names[x], name)) {
2199 for (x = 0; x < 100; x++) {
2217 const
char *file, const
char *func,
int line)
2222 if (channel->state_flags[0]) {
2224 if (channel->state_flags[x]) {
2225 channel->flags[x] = 1;
2226 channel->state_flags[x] = 0;
2229 channel->state_flags[0] = 0;
2237 channel->name, state_names[state]);
2241 careful_set(channel, &channel->running_state, state);
2279 last_state = channel->state;
2282 if (last_state == state) {
2286 if (last_state >=
CS_HANGUP && state < last_state) {
2309 switch (last_state) {
2466 channel->name, state_names[last_state], state_names[state]);
2470 if (state ==
CS_HANGUP && !channel->hangup_cause) {
2479 "(%s) Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
2487 return channel->state;
2509 switch_caller_profile_t *caller_profile, *originator_caller_profile = NULL, *originatee_caller_profile = NULL;
2516 if ((caller_profile = channel->caller_profile)) {
2568 if (channel->hangup_cause) {
2590 if (caller_profile) {
2595 if (originator_caller_profile && channel->last_profile_type ==
LP_ORIGINATOR) {
2598 }
else if (originatee_caller_profile && channel->last_profile_type ==
LP_ORIGINATEE) {
2610 int global_verbose_events = -1;
2616 if (global_verbose_events ||
2649 if (channel->scope_variables) {
2652 for (ep = channel->scope_variables; ep; ep = ep->
next) {
2655 char *vvar = NULL, *vval = NULL;
2657 vvar = (
char *) hi->
name;
2658 vval = (
char *) hi->
value;
2670 if (channel->variables) {
2671 for (hi = channel->variables->headers; hi; hi = hi->
next) {
2673 char *vvar = NULL, *vval = NULL;
2675 vvar = (
char *) hi->
name;
2676 vval = (
char *) hi->
value;
2717 caller_profile->direction = channel->direction;
2718 caller_profile->logical_direction = channel->logical_direction;
2721 if (!caller_profile->uuid || strcasecmp(caller_profile->uuid, uuid)) {
2725 if (!caller_profile->chan_name || strcasecmp(caller_profile->chan_name, channel->name)) {
2729 if (!caller_profile->context) {
2733 if (!caller_profile->times) {
2738 if (channel->caller_profile && channel->caller_profile->times) {
2739 channel->caller_profile->times->transferred = caller_profile->times->profile_created;
2740 caller_profile->times->answered = channel->caller_profile->times->answered;
2741 caller_profile->times->progress = channel->caller_profile->times->progress;
2742 caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
2743 caller_profile->times->created = channel->caller_profile->times->created;
2744 caller_profile->times->hungup = channel->caller_profile->times->hungup;
2745 if (channel->caller_profile->caller_extension) {
2753 caller_profile->next = channel->caller_profile;
2754 channel->caller_profile = caller_profile;
2755 caller_profile->profile_index =
switch_core_sprintf(caller_profile->pool,
"%d", ++channel->profile_index);
2778 if (!caller_profile->times) {
2782 if (channel->caller_profile) {
2783 caller_profile->next = channel->caller_profile->originator_caller_profile;
2784 channel->caller_profile->originator_caller_profile = caller_profile;
2787 switch_assert(channel->caller_profile->originator_caller_profile->next != channel->caller_profile->originator_caller_profile);
2798 channel->caller_profile->hunt_caller_profile = NULL;
2799 if (channel->caller_profile && caller_profile) {
2800 caller_profile->direction = channel->direction;
2801 caller_profile->logical_direction = channel->logical_direction;
2802 channel->caller_profile->hunt_caller_profile = caller_profile;
2814 if (channel->caller_profile) {
2815 caller_profile->next = channel->caller_profile->origination_caller_profile;
2816 channel->caller_profile->origination_caller_profile = caller_profile;
2818 switch_assert(channel->caller_profile->origination_caller_profile->next != channel->caller_profile->origination_caller_profile);
2828 if (channel->caller_profile) {
2844 if (channel->caller_profile) {
2845 caller_profile->next = channel->caller_profile->originatee_caller_profile;
2846 channel->caller_profile->originatee_caller_profile = caller_profile;
2849 switch_assert(channel->caller_profile->originatee_caller_profile->next != channel->caller_profile->originatee_caller_profile);
2860 if (channel->caller_profile) {
2874 if (channel->caller_profile) {
2896 if (channel->state_handlers[x] == state_handler) {
2901 index = channel->state_handler_index++;
2903 if (channel->state_handler_index >= SWITCH_MAX_STATE_HANDLERS) {
2908 channel->state_handlers[index] = state_handler;
2926 h = channel->state_handlers[index];
2934 int index, i = channel->state_handler_index;
2940 channel->state_handler_index = 0;
2942 if (state_handler) {
2943 for (index = 0; index < i; index++) {
2944 if (channel->state_handlers[index] != state_handler) {
2945 new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
2949 for (index = 0; index < i; index++) {
2951 new_handlers[channel->state_handler_index++] = channel->state_handlers[index];
2957 channel->state_handlers[index] = NULL;
2960 if (channel->state_handler_index > 0) {
2961 for (index = 0; index < channel->state_handler_index; index++) {
2962 channel->state_handlers[index] = new_handlers[index];
3013 if (extension && orig_extension) {
3014 for (ap = orig_extension->current_application; ap && offset > 0; offset--) {
3018 for (; ap; ap = ap->
next) {
3026 for (hi = orig_channel->variables->headers; hi; hi = hi->
next) {
3028 for (i = 0; i < argc; i++) {
3029 if (!strcasecmp(argv[i], hi->
name)) {
3054 const char *tname, *tnum;
3062 #ifdef DEEP_DEBUG_CID
3085 const char *tmp = NULL;
3088 if (channel->caller_profile->callee_id_name) {
3089 tmp = channel->caller_profile->caller_id_name;
3091 channel->caller_profile->caller_id_name =
switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name);
3097 channel->caller_profile->callee_id_name = tmp;
3100 if (channel->caller_profile->callee_id_number) {
3101 tmp = channel->caller_profile->caller_id_number;
3103 channel->caller_profile->caller_id_number =
switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number);
3109 channel->caller_profile->callee_id_number = tmp;
3131 channel->caller_profile->caller_id_name,
3132 channel->caller_profile->caller_id_number
3154 caller_extension = channel->queued_extension;
3155 channel->queued_extension = NULL;
3158 return caller_extension;
3164 channel->queued_extension = caller_extension;
3178 caller_extension->next = channel->caller_profile->caller_extension;
3179 channel->caller_profile->caller_extension = caller_extension;
3190 if (channel->caller_profile) {
3191 extension = channel->caller_profile->caller_extension;
3201 if (channel->caller_profile && channel->caller_profile->times) {
3210 if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
3239 return channel->state;
3251 if (channel->hold_record && !channel->hold_record->off) {
3257 last_state = channel->state;
3261 channel->hangup_cause = hangup_cause;
3293 return channel->state;
3308 const
char *file, const
char *func,
int line)
3317 if (channel->caller_profile && channel->caller_profile->times) {
3320 if (channel->caller_profile->originator_caller_profile) {
3330 channel->caller_profile->originator_caller_profile->times->progress = channel->caller_profile->times->progress;
3428 if (channel->caller_profile && channel->caller_profile->times) {
3431 if (channel->caller_profile->originator_caller_profile) {
3441 channel->caller_profile->originator_caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
3490 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3504 msg.
from = channel->name;
3519 const
char *file, const
char *func,
int line)
3526 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3540 msg.
from = channel->name;
3563 if ((arg = strchr(app,
' '))) {
3585 char *var = hp->
name;
3586 char *val = hp->
value;
3588 if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3591 for (i = 0; i < hp->
idx; i++) {
3616 for(p = app; p && *p; p++) {
3617 if (*p ==
' ' || (*p ==
':' && (*(p+1) !=
':'))) {
3621 }
else if (*p ==
':' && (*(p+1) ==
':')) {
3627 if (!strncasecmp(app,
"perl", 4)) {
3649 char *var = hp->
name;
3650 char *val = hp->
value;
3652 if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
3655 for (i = 0; i < hp->
idx; i++) {
3681 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3691 if (channel->caller_profile && channel->caller_profile->times) {
3725 uint32_t seconds = 60;
3790 if (channel->hangup_cause || channel->state >=
CS_HANGUP) {
3799 msg.
from = channel->name;
3817 uint32_t msec = atoi(delay);
3829 #define resize(l) {\
3831 olen += (len + l + block);\
3833 if ((dp = realloc(data, olen))) {\
3836 memset(c, 0, olen - cpos);\
3842 char *data, *indup, *endof_indup;
3843 size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128;
3844 char *cloned_sub_val = NULL, *sub_val = NULL, *expanded_sub_val = NULL;
3845 char *func_val = NULL, *sb = NULL;
3864 olen = strlen(in) + 1;
3868 if ((data = malloc(olen))) {
3871 for (p = indup; p && p < endof_indup && *p; p++) {
3876 if (*(p + 1) ==
'$') {
3879 if (*(p + 1) ==
'$') {
3882 }
else if (*(p + 1) ==
'\'') {
3885 }
else if (*(p + 1) ==
'\\') {
3892 if (*p ==
'$' && !nv) {
3894 if (*(p + 1) ==
'$') {
3900 if (*(p + 1) ==
'{') {
3901 vtype = global ? 3 : 1;
3918 char *s = p, *e, *vname, *vval = NULL;
3923 if ((vtype == 1 || vtype == 3) && *s ==
'{') {
3931 if (br == 1 && *e ==
'}') {
3938 if (e != s && *e ==
'{') {
3940 }
else if (br > 1 && *e ==
'}') {
3947 p = e > endof_indup ? endof_indup : e;
3950 for(sb = vname; sb && *sb; sb++) {
3954 }
else if (*sb ==
'(') {
3972 }
else if (br > 1 && *e ==
')') {
3974 }
else if (br == 1 && *e ==
')') {
3984 if (vtype == 1 || vtype == 3) {
3985 char *expanded = NULL;
3997 if ((ptr = strchr(vname,
':'))) {
4000 if ((ptr = strchr(ptr,
':'))) {
4002 ooffset = atoi(ptr);
4006 if ((ptr = strchr(vname,
'[')) && strchr(ptr,
']')) {
4013 sub_val =
"<Variable Expansion Permission Denied>";
4017 expanded_sub_val = NULL;
4019 sub_val = expanded_sub_val;
4022 if (offset || ooffset) {
4023 cloned_sub_val = strdup(sub_val);
4025 sub_val = cloned_sub_val;
4029 if ((
size_t) offset > strlen(sub_val)) {
4034 }
else if ((
size_t) abs(offset) <= strlen(sub_val)) {
4035 sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
4038 if (ooffset > 0 && (
size_t) ooffset < strlen(sub_val)) {
4039 if ((ptr = (
char *) sub_val + ooffset)) {
4048 char *expanded = NULL;
4053 char *expanded_vname = NULL;
4056 expanded_vname = NULL;
4058 vname = expanded_vname;
4069 sub_val =
"<API Execute Permission Denied>";
4072 func_val = stream.
data;
4089 if ((nlen = sub_val ? strlen(sub_val) : 0)) {
4090 if (len + nlen >= olen) {
4106 if (len + 1 >= olen) {
4133 char *encode_buf = NULL;
4134 const char *prof[13] = { 0 }, *prof_names[13] = {
4146 encode_buf = malloc(encode_len);
4149 if (!caller_profile) {
4155 prof[0] = caller_profile->context;
4156 prof[1] = caller_profile->destination_number;
4157 prof[2] = caller_profile->caller_id_name;
4158 prof[3] = caller_profile->caller_id_number;
4159 prof[4] = caller_profile->network_addr;
4160 prof[5] = caller_profile->ani;
4161 prof[6] = caller_profile->aniii;
4162 prof[7] = caller_profile->rdnis;
4163 prof[8] = caller_profile->source;
4164 prof[9] = caller_profile->chan_name;
4165 prof[10] = caller_profile->uuid;
4166 prof[11] = caller_profile->transfer_source;
4168 prof_names[0] =
"context";
4169 prof_names[1] =
"destination_number";
4170 prof_names[2] =
"caller_id_name";
4171 prof_names[3] =
"caller_id_number";
4172 prof_names[4] =
"network_addr";
4173 prof_names[5] =
"ani";
4174 prof_names[6] =
"aniii";
4175 prof_names[7] =
"rdnis";
4176 prof_names[8] =
"source";
4177 prof_names[9] =
"chan_name";
4178 prof_names[10] =
"uuid";
4179 prof_names[11] =
"transfer_source";
4181 for (x = 0; prof[x]; x++) {
4182 if (
zstr(prof[x])) {
4185 new_len = (strlen(prof[x]) * 3) + 1;
4186 if (encode_len < new_len) {
4189 encode_len = new_len;
4191 if (!(tmp = realloc(encode_buf, encode_len))) {
4198 stream.
write_function(&stream,
"%s=%s&", prof_names[x], encode_buf);
4201 if (channel->caller_profile->soft) {
4204 for(pn = channel->caller_profile->soft; pn; pn = pn->
next) {
4205 char *var = pn->
var;
4206 char *val = pn->
val;
4208 new_len = (strlen((
char *) var) * 3) + 1;
4209 if (encode_len < new_len) {
4212 encode_len = new_len;
4214 tmp = realloc(encode_buf, encode_len);
4220 stream.
write_function(&stream,
"%s=%s&", (
char *) var, encode_buf);
4226 for (; hi; hi = hi->
next) {
4227 char *var = hi->
name;
4228 char *val = hi->
value;
4230 new_len = (strlen((
char *) var) * 3) + 1;
4231 if (encode_len < new_len) {
4234 encode_len = new_len;
4236 tmp = realloc(encode_buf, encode_len);
4242 stream.
write_function(&stream,
"%s=%s&", (
char *) var, encode_buf);
4248 e = (
char *) stream.
data + (strlen((
char *) stream.
data) - 1);
4250 if (e && *e ==
'&') {
4269 if (!
zstr(channel->caller_profile->callee_id_name)) {
4270 other_channel->caller_profile->callee_id_name =
switch_core_strdup(other_channel->caller_profile->pool, channel->caller_profile->callee_id_name);
4274 if (!
zstr(channel->caller_profile->callee_id_number)) {
4275 other_channel->caller_profile->callee_id_number =
switch_core_strdup(other_channel->caller_profile->pool, channel->caller_profile->callee_id_number);
4289 if (channel->variables) {
4301 return channel->session;
4307 const char *cid_buf = NULL;
4310 char *last_app = NULL, *last_arg = NULL;
4311 char start[80] =
"", resurrect[80] =
"", answer[80] =
"", hold[80],
4312 bridge[80] =
"", progress[80] =
"", progress_media[80] =
"", end[80] =
"", tmp[80] =
"",
4313 profile_start[80] =
"";
4314 int32_t duration = 0, legbillsec = 0, billsec = 0, mduration = 0, billmsec = 0, legbillmsec = 0, progressmsec = 0, progress_mediamsec = 0;
4315 int32_t answersec = 0, answermsec = 0, waitsec = 0, waitmsec = 0;
4317 switch_time_t uduration = 0, legbillusec = 0, billusec = 0, progresssec = 0, progressusec = 0, progress_mediasec = 0, progress_mediausec = 0, waitusec = 0;
4318 time_t tt_created = 0, tt_answered = 0, tt_resurrected = 0, tt_bridged, tt_last_hold, tt_hold_accum,
4319 tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_bridged = 0,
4320 mtt_hungup = 0, tt_prof_created, mtt_progress = 0, mtt_progress_media = 0;
4332 if (!(caller_profile = channel->caller_profile) || !channel->variables) {
4340 for (ap = app_log; ap && ap->
next; ap = ap->
next);
4356 dtstr[x++] = dt->
digit;
4364 char *digit_string = dtstr;
4367 char *substituted = NULL;
4373 if ((proceed =
switch_regex_perform(dtstr, var, &re, ovector,
sizeof(ovector) /
sizeof(ovector[0])))) {
4374 int len = (strlen(dtstr) + strlen(var) + 10) * proceed;
4376 const char *replace = NULL;
4380 for (i = 0; i < proceed; i++) {
4381 if (pcre_get_substring(dtstr, ovector, proceed, i, &replace) > 0) {
4389 pcre_free_substring(replace);
4393 if (!
zstr(substituted)) {
4394 digit_string = substituted;
4407 if (caller_profile->
times) {
4410 const char *fmt =
"%Y-%m-%d %T";
4456 if (channel->hold_record) {
4464 for (hr = channel->hold_record; hr; hr = hr->
next) {
4477 tt_created = (time_t) (caller_profile->
times->
created / 1000000);
4478 mtt_created = (time_t) (caller_profile->
times->
created / 1000);
4490 tt_answered = (time_t) (caller_profile->
times->
answered / 1000000);
4491 mtt_answered = (time_t) (caller_profile->
times->
answered / 1000);
4497 tt_bridged = (time_t) (caller_profile->
times->
bridged / 1000000);
4498 mtt_bridged = (time_t) (caller_profile->
times->
bridged / 1000);
4504 tt_last_hold = (time_t) (caller_profile->
times->
last_hold / 1000000);
4510 tt_hold_accum = (time_t) (caller_profile->
times->
hold_accum / 1000000);
4524 tt_progress = (time_t) (caller_profile->
times->
progress / 1000000);
4525 mtt_progress = (time_t) (caller_profile->
times->
progress / 1000);
4538 tt_hungup = (time_t) (caller_profile->
times->
hungup / 1000000);
4539 mtt_hungup = (time_t) (caller_profile->
times->
hungup / 1000);
4545 duration = (int32_t) (tt_hungup - tt_created);
4546 mduration = (int32_t) (mtt_hungup - mtt_created);
4550 waitsec = (int32_t) (tt_bridged - tt_created);
4551 waitmsec = (int32_t) (mtt_bridged - mtt_created);
4560 billsec = (int32_t) (tt_hungup - tt_answered);
4561 billmsec = (int32_t) (mtt_hungup - mtt_answered);
4564 legbillsec = (int32_t) (tt_hungup - tt_created);
4565 legbillmsec = (int32_t) (mtt_hungup - mtt_created);
4568 answersec = (int32_t) (tt_answered - tt_created);
4569 answermsec = (int32_t) (mtt_answered - mtt_created);
4574 progresssec = (int32_t) (tt_progress - tt_created);
4575 progressmsec = (int32_t) (mtt_progress - mtt_created);
4580 progress_mediasec = (int32_t) (tt_progress_media - tt_created);
4581 progress_mediamsec = (int32_t) (mtt_progress_media - mtt_created);
4661 const char *uuid = NULL;
4673 const char *transfer_on_fail = NULL;
4674 char *tof_data = NULL;
4675 char *tof_array[4] = { 0 };
4685 transfer_on_fail = tof_array[0];
4696 const char *continue_on_fail = NULL, *failure_causes = NULL;
4701 if (continue_on_fail || failure_causes) {
4702 const char *cause_str;
4703 char cause_num[35] =
"";
4708 if (failure_causes) {
4710 char *argv[256] = { 0 };
4714 for (i = 0; i < argc; i++) {
4715 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4722 "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4727 if (continue_on_fail) {
4732 char *argv[256] = { 0 };
4736 for (i = 0; i < argc; i++) {
4737 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4739 "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
4752 if (transfer_on_fail || failure_causes) {
4753 const char *cause_str;
4754 char cause_num[35] =
"";
4759 if ((tof_array[1] == NULL ) || (!strcasecmp(tof_array[1],
"auto_cause"))){
4760 tof_array[1] = (
char *) cause_str;
4763 if (failure_causes) {
4765 char *argv[256] = { 0 };
4769 for (i = 0; i < argc; i++) {
4770 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4777 "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
4783 if (transfer_on_fail) {
4788 char *argv[256] = { 0 };
4792 for (i = 0; i < argc; i++) {
4793 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
4795 "Transfer on fail [%s]: Cause: %s\n", transfer_on_fail, cause_str);
4921 while(--sanity && channel->device_node->parent->refs) {
4926 channel->device_node->parent->uuid,
4927 channel->device_node->parent->device_id);
4931 char prefix[80] =
"";
4957 pool = channel->device_node->parent->pool;
5082 switch(drec->
state) {
5140 "%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u "
5141 "Ringing:%u Early:%u Active:%u Held:%u Unheld:%u Hungup:%u Dur: %u Ringtime: %u Holdtime: %u %s\n",
5160 for (ptr =
globals.device_bindings; ptr; ptr = ptr->
next) {
5252 if (channel->device_node) {
5278 if (channel->device_node) {
5280 return channel->device_node->parent;
5288 if (drecp && *drecp) {
5297 assert(
function != NULL);
5307 for (ptr =
globals.device_bindings; ptr && ptr->next; ptr = ptr->next);
5310 ptr->next = binding;
5312 globals.device_bindings = binding;
5326 for (ptr =
globals.device_bindings; ptr; ptr = ptr->
next) {
5348 char *use_sdp = (
char *) sdp;
5349 char *patched_sdp = NULL;
5356 use_sdp = patched_sdp;
struct apr_queue_t switch_queue_t
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,...)
_Ret_opt_z_ char * switch_event_get_header_idx(switch_event_t *event, const char *header_name, int idx)
void switch_channel_set_cap_value(switch_channel_t *channel, switch_channel_cap_t cap, uint32_t value)
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
void switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force)
void * switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex)
Retrieve data from a given hash.
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
#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
unsigned int switch_queue_size(switch_queue_t *queue)
void switch_channel_state_thread_unlock(switch_channel_t *channel)
#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_caller_extension_t * switch_channel_get_caller_extension(switch_channel_t *channel)
Retrieve caller extension from a given channel.
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.
void switch_channel_flush_dtmf(switch_channel_t *channel)
switch_event_t * variables
#define SWITCH_SENSITIVE_DTMF_VARIABLE
#define SWITCH_CHANNEL_SESSION_LOG(x)
An Abstract Representation of a dialplan extension.
switch_channel_callstate_t callstate
void switch_channel_handle_cause(switch_channel_t *channel, switch_call_cause_t cause)
switch_channel_state_t switch_channel_perform_set_state(switch_channel_t *channel, const char *file, const char *func, int line, switch_channel_state_t state)
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
#define SWITCH_ORIGINATOR_VARIABLE
switch_core_session_message_types_t message_id
#define SWITCH_CHANNEL_LOG
switch_status_t switch_channel_set_variable_name_printf(switch_channel_t *channel, const char *val, const char *fmt,...)
switch_status_t switch_mutex_trylock(switch_mutex_t *lock)
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
uint32_t switch_channel_test_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag)
switch_status_t switch_channel_export_variable_var_check(switch_channel_t *channel, const char *varname, const char *val, const char *export_varname, switch_bool_t var_check)
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
void switch_core_session_signal_state_change(_In_ switch_core_session_t *session)
struct switch_device_state_binding_s switch_device_state_binding_t
void switch_channel_set_hangup_time(switch_channel_t *channel)
switch_status_t switch_channel_perform_mark_pre_answered(switch_channel_t *channel, const char *file, const char *func, int line)
#define switch_event_del_header(_e, _h)
#define switch_channel_export_variable(_channel, _varname, _value, _ev)
int switch_core_test_flag(int flag)
#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.
void switch_channel_clear_state_flag(switch_channel_t *channel, switch_channel_flag_t flag)
void switch_channel_perform_video_sync(switch_channel_t *channel, const char *file, const char *func, int line)
switch_call_direction_t switch_channel_logical_direction(switch_channel_t *channel)
void switch_channel_event_set_basic_data(switch_channel_t *channel, switch_event_t *event)
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.
switch_status_t switch_channel_dequeue_dtmf(switch_channel_t *channel, switch_dtmf_t *dtmf)
switch_event_t * api_list
struct switch_caller_profile * originatee_caller_profile
switch_queue_t * dtmf_log_queue
switch_device_state_t state
switch_event_types_t
Built-in Events.
void switch_channel_clear_device_record(switch_channel_t *channel)
#define SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE
switch_device_state_t last_state
switch_hash_t * app_flag_hash
void switch_channel_check_zrtp(switch_channel_t *channel)
char * switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool)
static int switch_string_has_escaped_data(const char *in)
void switch_channel_set_bridge_time(switch_channel_t *channel)
switch_device_stats_t stats
opaque_channel_flag_t opaque_flags
void switch_event_add_presence_data_cols(switch_channel_t *channel, switch_event_t *event, const char *prefix)
const char * switch_channel_callstate2str(switch_channel_callstate_t callstate)
switch_status_t switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line)
Receive a message on a given session.
switch_status_t switch_channel_queue_dtmf(switch_channel_t *channel, const switch_dtmf_t *dtmf)
switch_mutex_t * switch_core_session_get_mutex(switch_core_session_t *session)
Signal a session's state machine thread that a state change has occured.
#define switch_channel_presence(_a, _b, _c, _d)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
void(* switch_device_state_function_t)(switch_core_session_t *session, switch_channel_callstate_t callstate, switch_device_record_t *drec)
#define switch_split(_data, _delim, _array)
#define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE
switch_time_t active_stop
switch_status_t switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
Execute a registered API command.
#define SWITCH_CHANNEL_API_ON_PRE_ANSWER_VARIABLE
switch_caller_profile_t * caller_profile
switch_channel_flag_t
Channel Flags.
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
int switch_event_check_permission_list(switch_event_t *list, const char *name)
switch_caller_profile_t * hup_profile
switch_hold_record_t * hold_record
#define switch_channel_ready(_channel)
An Abstract Representation of a dialplan Application.
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
void * switch_channel_get_private_partner(switch_channel_t *channel, const char *key)
switch_core_session_message_types_t
Possible types of messages for inter-session communication.
switch_hash_t * private_hash
static void do_execute_on(switch_channel_t *channel, const char *variable)
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_size_t switch_channel_dequeue_dtmf_string(switch_channel_t *channel, char *dtmf_str, switch_size_t len)
switch_status_t switch_channel_bind_device_state_handler(switch_device_state_function_t function, void *user_data)
void switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel's caller profile.
switch_channel_state_t switch_channel_get_running_state(switch_channel_t *channel)
void switch_channel_flip_cid(switch_channel_t *channel)
switch_status_t switch_channel_alloc(switch_channel_t **channel, switch_call_direction_t direction, switch_memory_pool_t *pool)
#define SWITCH_HOLD_MUSIC_VARIABLE
switch_status_t switch_channel_set_variable_partner_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
switch_bool_t switch_is_number(const char *str)
switch_status_t switch_time_exp_lt(switch_time_exp_t *result, switch_time_t input)
struct switch_event * next
switch_time_t active_start
const char * switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx)
Retrieve a variable from a given channel.
void switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Set given flag(s) on a given channel to be applied on the next state change.
switch_status_t switch_core_session_queue_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message)
Queue a message on a session.
switch_device_state_binding_t * device_bindings
const char * switch_channel_device_state2str(switch_device_state_t device_state)
static const char * state_names[]
int switch_channel_check_signal(switch_channel_t *channel, switch_bool_t in_thread_only)
struct real_pcre switch_regex_t
char * switch_channel_expand_variables_check(switch_channel_t *channel, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur)
Expand varaibles in a string based on the variables in a paticular channel.
switch_status_t switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session)
switch_mutex_t * state_mutex
char * switch_url_encode(const char *url, char *buf, size_t len)
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
switch_status_t switch_strftime_nocheck(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
switch_event_header_t * switch_channel_variable_first(switch_channel_t *channel)
Start iterating over the entries in the channel variable list.
#define SWITCH_MAX_STATE_HANDLERS
switch_status_t switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line)
switch_status_t switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg)
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,...)
_Check_return_ _Ret_opt_z_ const char * switch_caller_get_field_by_name(_In_ switch_caller_profile_t *caller_profile, _In_z_ const char *name)
Get the value of a field in a caller profile based on it's name.
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
int switch_channel_test_private_flag(switch_channel_t *channel, uint32_t flags)
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.
void switch_channel_event_set_extended_data(switch_channel_t *channel, switch_event_t *event)
void switch_channel_perform_audio_sync(switch_channel_t *channel, const char *file, const char *func, int line)
void switch_channel_set_scope_variables(switch_channel_t *channel, switch_event_t **event)
const char * switch_channel_get_partner_uuid(switch_channel_t *channel)
switch_call_cause_t switch_channel_str2cause(const char *str)
switch_codec_t * switch_core_session_get_write_codec(_In_ switch_core_session_t *session)
Retrieve the write codec from a given session.
A message object designed to allow unlike technologies to exchange data.
void switch_channel_set_origination_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
Set the given channel's origination caller profile.
#define SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE
static void do_api_on(switch_channel_t *channel, const char *variable)
struct device_uuid_node_s * uuid_tail
switch_status_t switch_channel_get_scope_variables(switch_channel_t *channel, switch_event_t **event)
switch_codec_t * switch_core_session_get_read_codec(_In_ switch_core_session_t *session)
Retrieve the read codec from a given session.
switch_caller_profile_t * switch_channel_get_originatee_caller_profile(switch_channel_t *channel)
Retrieve the given channel's originatee caller profile.
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
struct switch_caller_application * next
static switch_status_t send_ind(switch_channel_t *channel, switch_core_session_message_types_t msg_id, const char *file, const char *func, int line)
switch_channel_state_t switch_channel_perform_hangup(switch_channel_t *channel, const char *file, const char *func, int line, switch_call_cause_t hangup_cause)
static void process_device_hup(switch_channel_t *channel)
switch_status_t switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
Transfer an existing session to another location.
switch_mutex_t * profile_mutex
#define is_dtmf(key)
determine if a character is a valid DTMF key
void switch_channel_invert_cid(switch_channel_t *channel)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
void switch_channel_state_thread_lock(switch_channel_t *channel)
switch_event_t * scope_variables
#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.
void switch_core_recovery_track(switch_core_session_t *session)
switch_status_t switch_channel_queue_dtmf_string(switch_channel_t *channel, const char *dtmf_string)
void switch_channel_clear_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
void switch_channel_mark_hold(switch_channel_t *channel, switch_bool_t on)
#define SWITCH_MUTEX_NESTED
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
switch_caller_extension_t * queued_extension
void switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state)
switch_status_t switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line)
void switch_caller_profile_event_set_data(_In_ switch_caller_profile_t *caller_profile, _In_opt_z_ const char *prefix, _In_ switch_event_t *event)
Add headers to an existing event in regards to a specific profile.
void switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds)
switch_channel_state_t running_state
if((uint32_t)(unpack->cur-unpack->buf) > unpack->buflen)
switch_status_t switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel, switch_ring_ready_t rv, const char *file, const char *func, int line)
void switch_channel_event_set_data(switch_channel_t *channel, switch_event_t *event)
switch_byte_t switch_byte_t * buf
switch_event_t * app_list
void switch_channel_set_private_flag(switch_channel_t *channel, uint32_t flags)
switch_channel_timetable_t * switch_channel_get_timetable(switch_channel_t *channel)
const char * switch_channel_state_name(switch_channel_state_t state)
switch_status_t switch_core_get_variables(switch_event_t **event)
#define switch_yield(ms)
Wait a desired number of microseconds and yield the CPU.
switch_device_state_function_t function
#define switch_channel_audio_sync(_c)
unsigned int switch_separate_string(_In_ char *buf, char delim, _Post_count_(return) char **array, unsigned int arraylen)
Separate a string into an array based on a character delimiter.
switch_status_t switch_core_hash_insert_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data, _In_opt_ switch_mutex_t *mutex)
Insert data into a hash.
switch_call_direction_t logical_direction
void switch_channel_global_init(switch_memory_pool_t *pool)
const char * switch_channel_get_hold_music(switch_channel_t *channel)
void switch_channel_sort_cid(switch_channel_t *channel)
void switch_event_merge(switch_event_t *event, switch_event_t *tomerge)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
const char * callee_id_number
void switch_channel_process_export(switch_channel_t *channel, switch_channel_t *peer_channel, switch_event_t *var_event, const char *export_varname)
int switch_channel_test_ready(switch_channel_t *channel, switch_bool_t check_ready, switch_bool_t check_media)
Determine if a channel is ready for io.
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)
static void fetch_device_stats(switch_device_record_t *drec)
switch_queue_t * dtmf_queue
uint32_t switch_channel_test_cap_partner(switch_channel_t *channel, switch_channel_cap_t cap)
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE
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
switch_call_direction_t direction
#define switch_channel_get_variable(_c, _v)
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_channel_caller_extension_masquerade(switch_channel_t *orig_channel, switch_channel_t *new_channel, uint32_t offset)
#define switch_zmalloc(ptr, len)
switch_call_cause_t * switch_channel_get_cause_ptr(switch_channel_t *channel)
const char * caller_id_name
#define switch_channel_set_variable_partner(_channel, _var, _val)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_originator_type_t last_profile_type
switch_call_cause_t switch_channel_get_cause(switch_channel_t *channel)
switch_status_t switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
void switch_channel_process_device_hangup(switch_channel_t *channel)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
#define SWITCH_BLANK_STRING
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.
#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE
switch_status_t switch_channel_transfer_variable_prefix(switch_channel_t *orig_channel, switch_channel_t *new_channel, const char *prefix)
static struct switch_cause_table CAUSE_CHART[]
switch_status_t switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname, const char *export_varname, const char *fmt,...)
#define switch_channel_down_nosig(_channel)
switch_status_t switch_core_session_recv_dtmf(_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf)
RECV DTMF on a session.
struct profile_node_s * next
void switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
Assign a caller extension to a given channel.
struct switch_caller_profile * origination_caller_profile
static void switch_channel_check_device_state(switch_channel_t *channel, switch_channel_callstate_t callstate)
void switch_channel_set_presence_data_vals(switch_channel_t *channel, const char *presence_data_cols)
Takes presence_data_cols as a parameter or as a channel variable and copies them to channel profile v...
int switch_vasprintf(_Out_opt_ char **buf, _In_z_ _Printf_format_string_ const char *format, _In_ va_list ap)
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
void bridge(CoreSession &session_a, CoreSession &session_b)
bridge the audio of session_b into session_a
switch_bool_t switch_channel_set_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag)
Set given flag(s) on a given channel's bridge partner.
switch_status_t switch_channel_pass_sdp(switch_channel_t *from_channel, switch_channel_t *to_channel, const char *sdp)
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.
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.
struct device_uuid_node_s * next
uint32_t flags[CF_FLAG_MAX]
static switch_bool_t switch_string_var_check_const(const char *s)
switch_mutex_t * flag_mutex
void switch_cond_next(void)
#define switch_core_session_get_partner(_session, _partner)
switch_size_t switch_channel_has_dtmf(switch_channel_t *channel)
switch_status_t switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
struct switch_caller_profile * originator_caller_profile
#define SWITCH_STANDARD_STREAM(s)
void switch_channel_global_uninit(void)
const char * switch_channel_get_hold_music_partner(switch_channel_t *channel)
int switch_regex_perform(const char *field, const char *expression, switch_regex_t **new_re, int *ovector, uint32_t olen)
void switch_channel_wait_for_state_timeout(switch_channel_t *channel, switch_channel_state_t want_state, uint32_t timeout)
switch_channel_callstate_t
void switch_channel_restart(switch_channel_t *channel)
switch_status_t switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, switch_memory_pool_t *pool)
switch_status_t switch_core_session_queue_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event)
Queue an event on a given session.
switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data)
void switch_channel_set_hunt_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
static switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
char * switch_channel_get_uuid(switch_channel_t *channel)
Retrieve the given channel's unique id.
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.
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
switch_status_t switch_channel_dtmf_lock(switch_channel_t *channel)
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_channel_callstate_t callstate
switch_status_t switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
uint32_t switch_channel_test_cap(switch_channel_t *channel, switch_channel_cap_t cap)
switch_channel_state_t switch_channel_perform_set_running_state(switch_channel_t *channel, switch_channel_state_t state, const char *file, const char *func, int line)
void switch_channel_set_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
#define SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE
void switch_channel_perform_set_callstate(switch_channel_t *channel, switch_channel_callstate_t callstate, const char *file, const char *func, int line)
#define switch_str_nil(s)
Make a null string a blank string instead.
switch_status_t switch_channel_unbind_device_state_handler(switch_device_state_function_t function)
switch_device_state_t device_state
unsigned int switch_core_session_running(_In_ switch_core_session_t *session)
determine if the session's state machine is running
const char * switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname)
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
#define switch_channel_expand_variables(_channel, _in)
void switch_channel_clear_cap(switch_channel_t *channel, switch_channel_cap_t cap)
switch_status_t switch_core_session_request_video_refresh(switch_core_session_t *session)
switch_stream_handle_write_function_t write_function
static void add_uuid(switch_device_record_t *drec, switch_channel_t *channel)
#define switch_channel_down(_channel)
const char * switch_channel_set_device_id(switch_channel_t *channel, const char *device_id)
#define switch_channel_set_callstate(channel, state)
#define SWITCH_DTMF_LOG_LEN
struct apr_thread_mutex_t switch_mutex_t
void switch_channel_step_caller_profile(switch_channel_t *channel)
#define SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE
void switch_channel_clear_private_flag(switch_channel_t *channel, uint32_t flags)
void switch_channel_uninit(switch_channel_t *channel)
Uninitalize a channel.
switch_status_t
Common return values.
#define MESSAGE_STAMP_FFL(_m)
switch_memory_pool_t * pool
char * switch_string_replace(const char *string, const char *search, const char *replace)
void * switch_channel_get_private(switch_channel_t *channel, const char *key)
Retrieve private from a given channel.
static struct switch_callstate_table CALLSTATE_CHART[]
static switch_status_t create_device_record(switch_device_record_t **drecp, const char *device_id)
switch_core_session_t * switch_channel_get_session(switch_channel_t *channel)
#define SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE
switch_call_direction_t direction
#define SWITCH_SIGNAL_BOND_VARIABLE
uint32_t caps[CC_FLAG_MAX]
#define check_media(session)
char * destination_number
struct switch_device_record_s * parent
const switch_state_handler_table_t * switch_channel_get_state_handler(switch_channel_t *channel, int index)
Retrieve an state handler tablefrom a given channel at given index level.
void switch_channel_variable_last(switch_channel_t *channel)
Stop iterating over channel variables.
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.
switch_device_record_t * switch_channel_get_device_record(switch_channel_t *channel)
switch_mutex_t * dtmf_mutex
#define switch_core_hash_insert(_h, _k, _d)
static struct switch_device_state_table DEVICE_STATE_CHART[]
#define switch_core_session_locate(uuid_str)
Locate a session based on it's uuid.
int switch_channel_state_change_pending(switch_channel_t *channel)
switch_channel_state_t state
struct switch_caller_profile * hunt_caller_profile
#define SWITCH_B_SDP_VARIABLE
switch_call_cause_t switch_channel_get_cause_q850(switch_channel_t *channel)
#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)
uint32_t switch_channel_del_variable_prefix(switch_channel_t *channel, const char *prefix)
#define SWITCH_TEMP_HOLD_MUSIC_VARIABLE
#define switch_event_get_header(_e, _h)
#define switch_channel_set_flag(_c, _f)
switch_status_t switch_channel_set_name(switch_channel_t *channel, const char *name)
Assign a name to a given channel.
#define SWITCH_CHANNEL_NAME_VARIABLE
switch_call_cause_t cause
struct device_uuid_node_s * uuid_list
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)
switch_mutex_t * thread_mutex
switch_call_cause_t switch_channel_cause_q850(switch_call_cause_t cause)
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
struct switch_channel_timetable * times
static void careful_set(switch_channel_t *channel, switch_channel_state_t *state, switch_channel_state_t val)
switch_caller_profile_t * switch_caller_profile_dup(_In_ switch_memory_pool_t *pool, _In_ switch_caller_profile_t *tocopy)
Duplicate an existing caller profile object.
char * switch_channel_build_param_string(switch_channel_t *channel, switch_caller_profile_t *caller_profile, const char *prefix)
#define SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE
const char * caller_id_number
switch_mutex_t * device_mutex
int switch_channel_add_state_handler(switch_channel_t *channel, const switch_state_handler_table_t *state_handler)
add a state handler table to a given channel
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
struct apr_pool_t switch_memory_pool_t
switch_stack_t
Expression of how to stack a list.
#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)
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.
A table of settings and callbacks that define a paticular implementation of a codec.
unsigned int switch_core_session_started(_In_ switch_core_session_t *session)
switch_device_node_t * device_node
switch_channel_callstate_t switch_channel_get_callstate(switch_channel_t *channel)
switch_channel_state_t switch_channel_name_state(const char *name)
switch_hold_record_t * hold_record
switch_device_stats_t last_stats
switch_caller_profile_t * switch_channel_get_origination_caller_profile(switch_channel_t *channel)
Retrieve the given channel's origination caller profile.
#define switch_channel_up_nosig(_channel)
switch_status_t switch_channel_perform_ring_ready_value(switch_channel_t *channel, switch_ring_ready_t rv, const char *file, const char *func, int line)
#define SWITCH_CHANNEL_API_ON_MEDIA_VARIABLE
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
switch_hold_record_t * switch_channel_get_hold_record(switch_channel_t *channel)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_channel_callstate_t callstate
switch_time_t last_call_time
switch_status_t switch_channel_try_dtmf_lock(switch_channel_t *channel)
void switch_channel_set_direction(switch_channel_t *channel, switch_call_direction_t direction)
switch_caller_extension_t * switch_channel_get_queued_extension(switch_channel_t *channel)
int32_t switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
send a control message to the core
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.
int switch_channel_test_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
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 ...
void switch_channel_transfer_to_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
uint8_t state_flags[CF_FLAG_MAX]
#define switch_channel_set_variable(_channel, _var, _val)
switch_time_t switch_time_now(void)
switch_status_t switch_channel_init(switch_channel_t *channel, switch_core_session_t *session, switch_channel_state_t state, switch_channel_flag_t flag)
Connect a newly allocated channel to a session object and setup it's initial state.
switch_status_t switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr)
Generate an XML CDR report.
switch_caller_profile_t * switch_channel_get_caller_profile(switch_channel_t *channel)
Retrieve the given channel's caller profile.
switch_hash_t * device_hash
#define switch_core_session_kill_channel(session, sig)
Send a signal to a channel.
void switch_channel_release_device_record(switch_device_record_t **drecp)
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_core_session_t * session
switch_status_t switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel)
switch_event_t * var_list
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
switch_status_t switch_channel_state_thread_trylock(switch_channel_t *channel)
#define switch_channel_media_up(_channel)
#define SWITCH_CHANNEL_API_ON_RING_VARIABLE
#define SWITCH_CHANNEL_CHANNEL_LOG(x)
const char * callee_id_name
switch_bool_t switch_channel_clear_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag)
Clears given flag(s) on a given channel's bridge partner.
switch_bool_t switch_core_session_in_thread(switch_core_session_t *session)
switch_call_cause_t hangup_cause
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
void switch_channel_perform_presence(switch_channel_t *channel, const char *rpid, const char *status, const char *id, const char *file, const char *func, int line)
Fire A presence event for the channel.
switch_status_t switch_channel_perform_mark_answered(switch_channel_t *channel, const char *file, const char *func, int line)
struct switch_device_state_binding_s * next
switch_event_header_t * headers
switch_status_t switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix)
switch_status_t switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
struct switch_app_log * next
switch_status_t switch_channel_dtmf_unlock(switch_channel_t *channel)
#define SWITCH_CHANNEL_API_ON_ANSWER_VARIABLE
switch_channel_callstate_t switch_channel_str2callstate(const char *str)
switch_status_t switch_core_session_thread_launch(_In_ switch_core_session_t *session)
Launch the session thread (state machine) on a given session.
switch_caller_profile_t * switch_channel_get_originator_caller_profile(switch_channel_t *channel)
Retrieve the given channel's originator caller profile.
switch_status_t switch_channel_set_timestamps(switch_channel_t *channel)
switch_memory_pool_t * pool
const char * switch_channel_cause2str(switch_call_cause_t cause)