const char *module_name,
const char *voice_name,
_In_ unsigned int rate,
- _In_ unsigned int interval, switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool);
+ _In_ unsigned int interval, switch_speech_flag_t *flags, _In_opt_ switch_memory_pool_t *pool);
/*!
\brief Feed text to the TTS module
\param sh the speech handle to feed
* \param dup true if you want the string to be strdup()'d automatically
* \return the switch_xml_t or NULL if an error occured
*/
-SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(_In_z_ char *s, _In_opt_ switch_bool_t dup);
+SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(_In_z_ char *s, _In_ switch_bool_t dup);
/*!
* \brief Parses a string into a switch_xml_t
///\param attrname the attribute name
///\param value the value
///\return an xml node or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_z_ const char *attrname, _In_z_ const char *value);
+SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_opt_z_ const char *attrname, _In_opt_z_ const char *value);
SWITCH_DECLARE(switch_xml_t) switch_xml_find_child_multi(_In_ switch_xml_t node, _In_z_ const char *childname, ...);
///\brief returns the next tag of the same name in the same section and depth or NULL
///\param xml the xml node
///\param idx the index
///\return an xml node or NULL
- switch_xml_t switch_xml_idx(_In_z_ switch_xml_t xml, _In_opt_ int idx);
+ switch_xml_t switch_xml_idx(_In_ switch_xml_t xml, _In_ int idx);
///\brief returns the name of the given tag
///\param xml the xml node
///\param xml the xml node
///\param attr the attribute
///\return the value
-SWITCH_DECLARE(const char *) switch_xml_attr(_In_ switch_xml_t xml, _In_z_ const char *attr);
+SWITCH_DECLARE(const char *) switch_xml_attr(_In_opt_ switch_xml_t xml, _In_opt_z_ const char *attr);
///\brief returns the value of the requested tag attribute, or "" if not found
///\param xml the xml node
///\param xml the xml node
///\param prn_header add <?xml version..> header too
///\return the xml text string
-SWITCH_DECLARE(char *) switch_xml_toxml(_In_ switch_xml_t xml, _In_opt_ switch_bool_t prn_header);
+SWITCH_DECLARE(char *) switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header);
///\brief Converts an switch_xml structure back to xml using the buffer passed in the parameters.
///\param xml the xml node
///\param offset offset to start at
///\param prn_header add <?xml version..> header too
///\return the xml text string
-SWITCH_DECLARE(char *) switch_xml_toxml_buf(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_opt_ switch_size_t offset, _In_opt_ switch_bool_t prn_header);
+SWITCH_DECLARE(char *) switch_xml_toxml_buf(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_ switch_size_t offset, _In_ switch_bool_t prn_header);
///\brief returns a NULL terminated array of processing instructions for the given
///\ target
///\brief frees the memory allocated for an switch_xml structure
///\param xml the xml node
///\note in the case of the root node the readlock will be lifted
-SWITCH_DECLARE(void) switch_xml_free(_In_ switch_xml_t xml);
+SWITCH_DECLARE(void) switch_xml_free(_In_opt_ switch_xml_t xml);
SWITCH_DECLARE(void) switch_xml_free_in_thread(_In_ switch_xml_t xml, _In_ int stacksize);
///\brief returns parser error message or empty string if none
///\param name the name of the tag
///\param off the offset
///\return an xml node or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(_In_ switch_xml_t xml, _In_z_ const char *name, _In_opt_ switch_size_t off);
+SWITCH_DECLARE(switch_xml_t) switch_xml_add_child(_In_ switch_xml_t xml, _In_z_ const char *name, _In_ switch_size_t off);
///\brief wrapper for switch_xml_add_child() that strdup()s name
///\param xml the xml node
SWITCH_DECLARE(switch_xml_t) switch_xml_cut(_In_ switch_xml_t xml);
///\brief inserts an existing tag into an ezxml structure
-SWITCH_DECLARE(switch_xml_t) switch_xml_insert(_In_ switch_xml_t xml, _In_ switch_xml_t dest, _In_opt_ switch_size_t off);
+SWITCH_DECLARE(switch_xml_t) switch_xml_insert(_In_ switch_xml_t xml, _In_ switch_xml_t dest, _In_ switch_size_t off);
///\brief Moves an existing tag to become a subtag of dest at the given offset from
///\ the start of dest's character content. Returns the moved tag.
///\param reload if it's is already open close it and open it again as soon as permissable (blocking)
///\param err a pointer to set error strings
///\return the xml root node or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(_In_opt_ uint8_t reload, _Out_ const char **err);
+SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(_In_ uint8_t reload, _Out_ const char **err);
///\brief initilize the core XML backend
///\param pool a memory pool to use
///\param params optional URL formatted params to pass to external gateways
///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
SWITCH_DECLARE(switch_status_t) switch_xml_locate(_In_z_ const char *section,
- _In_z_ const char *tag_name,
- _In_z_ const char *key_name,
- _In_z_ const char *key_value,
+ _In_opt_z_ const char *tag_name,
+ _In_opt_z_ const char *key_name,
+ _In_opt_z_ const char *key_value,
_Out_ switch_xml_t *root,
_Out_ switch_xml_t *node,
_In_opt_ switch_event_t *params,
- _In_opt_ switch_bool_t clone);
+ _In_ switch_bool_t clone);
SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(_In_z_ const char *domain_name, _In_opt_ switch_event_t *params, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain);
SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(_In_z_ const char *key,
_In_z_ const char *user_name,
_In_z_ const char *domain_name,
- _In_z_ const char *ip,
- _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *user, _Out_ switch_xml_t *ingroup,
+ _In_opt_z_ const char *ip,
+ _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *user, _Out_opt_ switch_xml_t *ingroup,
_In_opt_ switch_event_t *params);
-SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_in_domain(_In_z_ const char *user_name, _In_ switch_xml_t domain, _Out_ switch_xml_t *user, _Out_ switch_xml_t *ingroup);
+SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_in_domain(_In_z_ const char *user_name, _In_ switch_xml_t domain, _Out_ switch_xml_t *user, _Out_opt_ switch_xml_t *ingroup);
///\brief open a config in the core registry
///\param file_path the name of the config section e.g. modules.conf
///\brief parse a string for a list of sections
///\param str a | delimited list of section names
///\return the section mask
-SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_z_ const char *str);
+SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_opt_z_ const char *str);
SWITCH_END_EXTERN_C
///\}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate memory to duplicate execute_app data.\n");
goto done;
}
+
+ if (!app) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find application.\n");
+ goto done;
+ }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute app: %s, %s\n", app, arg);
channel = switch_core_session_get_channel(member->session);
if (imember->session) {
const char *p;
for (p = dtmf; p && *p; p++) {
- switch_dtmf_t dtmf = { *p, SWITCH_DEFAULT_DTMF_DURATION};
+ switch_dtmf_t digit = { *p, SWITCH_DEFAULT_DTMF_DURATION};
switch_mutex_lock(imember->control_mutex);
switch_core_session_kill_channel(imember->session, SWITCH_SIG_BREAK);
- switch_core_session_send_dtmf(imember->session, &dtmf);
+ switch_core_session_send_dtmf(imember->session, &digit);
switch_mutex_unlock(imember->control_mutex);
}
}
argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0])));
- for(i = 0; i < argc; i++) {
+ for(i = 0; i < argc && argv[i]; i++) {
if (!strcasecmp(argv[i], "mute")) {
*f &= ~MFLAG_CAN_SPEAK;
} else if (!strcasecmp(argv[i], "deaf")) {
if ((x_params = switch_xml_child(x_domain, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
- const char *var = switch_xml_attr(x_param, "name");
+ const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
- if (!strcasecmp(var, "dial-string")) {
+ if (!strcasecmp(pvar, "dial-string")) {
dest = val;
} else if (!strncasecmp(var, "dial-var-", 9)) {
if (!var_event) {
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
} else {
- switch_event_del_header(var_event, var + 9);
+ switch_event_del_header(var_event, pvar + 9);
}
- switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, var + 9, val);
+ switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val);
}
}
}
if ((x_params = switch_xml_child(x_group, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
- const char *var = switch_xml_attr(x_param, "name");
+ const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
- if (!strcasecmp(var, "dial-string")) {
+ if (!strcasecmp(pvar, "dial-string")) {
dest = val;
- } else if (!strncasecmp(var, "dial-var-", 9)) {
+ } else if (!strncasecmp(pvar, "dial-var-", 9)) {
if (!var_event) {
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
} else {
- switch_event_del_header(var_event, var + 9);
+ switch_event_del_header(var_event, pvar + 9);
}
- switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, var + 9, val);
+ switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val);
}
}
}
if ((x_params = switch_xml_child(x_user, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
- const char *var = switch_xml_attr(x_param, "name");
+ const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
- if (!strcasecmp(var, "dial-string")) {
+ if (!strcasecmp(pvar, "dial-string")) {
dest = val;
- } else if (!strncasecmp(var, "dial-var-", 9)) {
+ } else if (!strncasecmp(pvar, "dial-var-", 9)) {
if (!var_event) {
switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
} else {
- switch_event_del_header(var_event, var + 9);
+ switch_event_del_header(var_event, pvar + 9);
}
- switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, var + 9, val);
+ switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val);
}
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No dial-string available, please check your user directory.\n");
cause = SWITCH_CAUSE_MANDATORY_IE_MISSING;
} else {
- const char *var;
+ const char *varval;
char *d_dest = NULL;
switch_channel_t *channel;
switch_originate_flag_t myflags = SOF_NONE;
if (session) {
channel = switch_core_session_get_channel(session);
- if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
- || (var = switch_event_get_header(var_event, "leg_timeout"))) {
- timelimit = atoi(var);
+ if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))
+ || (varval = switch_event_get_header(var_event, "leg_timeout"))) {
+ timelimit = atoi(varval);
}
switch_channel_set_variable(channel, "dialed_user", user);
switch_event_dup(&event, var_event);
switch_event_del_header(event, "dialed_user");
switch_event_del_header(event, "dialed_domain");
- if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
- (var = switch_event_get_header(var_event, "leg_timeout"))) {
- timelimit = atoi(var);
+ if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
+ (varval = switch_event_get_header(var_event, "leg_timeout"))) {
+ timelimit = atoi(varval);
}
} else {
switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS);
if (new_channel && xml) {
if ((x_params = switch_xml_child(x_domain, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
- const char *var = switch_xml_attr(x_param, "name");
+ const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
- switch_channel_set_variable(new_channel, var, val);
+ switch_channel_set_variable(new_channel, pvar, val);
}
}
if ((x_params = switch_xml_child(x_user, "variables"))) {
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
- const char *var = switch_xml_attr(x_param, "name");
+ const char *pvar = switch_xml_attr(x_param, "name");
const char *val = switch_xml_attr(x_param, "value");
- switch_channel_set_variable(new_channel, var, val);
+ switch_channel_set_variable(new_channel, pvar, val);
}
}
}
stop_node_thread();
}
- top:
- for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
+ for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_first(NULL, globals.fifo_hash)) {
int x = 0;
switch_hash_this(hi, NULL, NULL, &val);
node = (fifo_node_t *) val;
switch_core_hash_destroy(&node->consumer_hash);
switch_thread_rwlock_unlock(node->rwlock);
switch_core_destroy_memory_pool(&node->pool);
- goto top;
}
+
switch_core_hash_destroy(&globals.fifo_hash);
memset(&globals, 0, sizeof(globals));
switch_mutex_unlock(mutex);
if (id) {
int ok = 1;
- switch_event_t *params = NULL;
+ switch_event_t *locate_params = NULL;
const char *email_addr = NULL;
- switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
- switch_assert(params);
- switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", id);
+ switch_event_create(&locate_params, SWITCH_EVENT_REQUEST_PARAMS);
+ switch_assert(locate_params);
+ switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "mailbox", id);
if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"),
- &x_domain_root, &x_domain, &x_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
+ &x_domain_root, &x_domain, &x_user, NULL, locate_params) == SWITCH_STATUS_SUCCESS) {
if ((x_params = switch_xml_child(x_user, "params"))) {
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
const char *var = switch_xml_attr_soft(x_param, "name");
ok = 0;
}
- switch_event_destroy(¶ms);
+ switch_event_destroy(&locate_params);
if (!ok) {
goto end;
}
if (!profile) {
- switch_hash_index_t *hi;
- void *val;
+ switch_hash_index_t *index;
+ void *value;
switch_mutex_lock(globals.mutex);
- for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, NULL, NULL, &val);
- profile = (vm_profile_t *) val;
+ for (index = switch_hash_first(NULL, globals.profile_hash); index; index = switch_hash_next(index)) {
+ switch_hash_this(index, NULL, NULL, &value);
+ profile = (vm_profile_t *) value;
if (profile) {
switch_thread_rwlock_rdlock(profile->rwlock);
break;
if (switch_test_flag(tech_pvt, TFLAG_CNG)) {
unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE];
uint32_t flag = 0;
- switch_status_t status;
+ switch_status_t encode_status;
uint32_t rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
*frame = &tech_pvt->cng_frame;
memset(&data, 0, sizeof(data));
if (strcasecmp(tech_pvt->read_codec.implementation->iananame, "L16")) {
- status = switch_core_codec_encode(&tech_pvt->read_codec,
+ encode_status = switch_core_codec_encode(&tech_pvt->read_codec,
NULL,
data,
sizeof(data),
&tech_pvt->cng_frame.datalen,
&rate,
&flag);
- if (status != SWITCH_STATUS_SUCCESS) {
+ if (encode_status != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
}
}
- if (switch_test_flag(tech_pvt, TFLAG_LINKED)) {
+ if (switch_test_flag(tech_pvt, TFLAG_LINKED) && tech_pvt->other_tech_pvt) {
switch_frame_t *clone;
if (frame->codec->implementation != tech_pvt->write_codec.implementation) {
end:
- if (switch_event_create(&event, SWITCH_EVENT_RECV_INFO) == SWITCH_STATUS_SUCCESS) {
+ if (sip && switch_event_create(&event, SWITCH_EVENT_RECV_INFO) == SWITCH_STATUS_SUCCESS) {
sip_alert_info_t *alert_info = sip_alert_info(sip);
if (sip && sip->sip_content_type) {
if (listener->session) {
- switch_channel_t *channel = switch_core_session_get_channel(listener->session);
- if (switch_channel_get_state(channel) < CS_HANGUP && switch_channel_test_flag(channel, CF_DIVERT_EVENTS)) {
+ switch_channel_t *chan = switch_core_session_get_channel(listener->session);
+ if (switch_channel_get_state(chan) < CS_HANGUP && switch_channel_test_flag(chan, CF_DIVERT_EVENTS)) {
switch_event_t *e = NULL;
while (switch_core_session_dequeue_event(listener->session, &e, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
if (switch_queue_trypush(listener->event_queue, e) != SWITCH_STATUS_SUCCESS) {
switch_set_flag_locked(listener, LFLAG_CONNECTED);
switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA);
- switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event);
- switch_channel_event_set_data(channel, call_event);
+ if (channel) {
+ switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event);
+ switch_channel_event_set_data(channel, call_event);
+ }
switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply");
switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Reply-Text", "+OK\n");
switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Socket-Mode", switch_test_flag(listener, LFLAG_ASYNC) ? "async" : "static");
}
}
+ if (!local_stream_name) {
+ goto usage;
+ }
+
source = switch_core_hash_find(globals.source_hash, local_stream_name);
if (source) {
if (xml) {
context->stream_url = switch_core_sprintf(context->memory_pool, "http://%s", path);
context->prebuf = handle->prebuf;
launch_read_stream_thread(context);
- while((switch_buffer_inuse(context->audio_buffer) < 1*2*context->samplerate) && ++sanity < 10) {
+ while((switch_buffer_inuse(context->audio_buffer) < (switch_size_t)(2 * context->samplerate)) && ++sanity < 10) {
/* at least 1s of audio and up to 5s initialize */
switch_yield(500000);
}