}
} else { /* replace real_read_codec */
switch_codec_t *cur_codec;
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Original read codec replaced with %s:%d\n",
- switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
+ switch_channel_get_name(session->channel), codec->implementation ? codec->implementation->iananame : "undefined", codec->implementation ? codec->implementation->ianacode : -1);
/* Set real_read_codec to front of the list of read_codecs */
cur_codec = session->read_codec;
while (cur_codec != NULL) {
cur_codec->next = codec;
break;
}
+
cur_codec = cur_codec->next;
}
+
session->real_read_codec = codec;
session->real_read_impl = *codec->implementation;
session->bug_codec.implementation->iananame, session->bug_codec.implementation->ianacode);
switch_core_codec_destroy(&session->bug_codec);
}
+
switch_thread_rwlock_unlock(session->bug_rwlock);
} else {
status = SWITCH_STATUS_FALSE;
if (session->read_impl.actual_samples_per_second != session->read_impl.samples_per_second) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-read-codec-rate", "%d", session->read_impl.samples_per_second);
}
+
switch_event_fire(&event);
}
}
switch_mutex_unlock(session->codec_read_mutex);
+
return status;
}
goto end;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Push codec %s:%d\n",
- switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
+ switch_channel_get_name(session->channel), codec->implementation ? codec->implementation->iananame : "undefined", codec->implementation ? codec->implementation->ianacode : -1);
codec->next = session->read_codec;
session->read_codec = codec;
if (codec->implementation) {
switch_mutex_lock(CUSTOM_HASH_MUTEX);
if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
- switch_event_reserve_subclass_detailed(id, subclass_name);
- subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name);
- subclass->bind = 1;
+ if (switch_event_reserve_subclass_detailed(id, subclass_name) == SWITCH_STATUS_SUCCESS) {
+ if ((subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
+ subclass->bind = 1;
+ }
+ }
}
switch_mutex_unlock(CUSTOM_HASH_MUTEX);
if (!subclass) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not reserve subclass. '%s'\n", subclass_name);
+
return SWITCH_STATUS_FALSE;
}
}
if (subclass_name) {
event_node->subclass_name = DUP(subclass_name);
}
+
event_node->callback = callback;
event_node->user_data = user_data;
int x_argc = switch_separate_string_string(key, (char*) sep, x_argv, SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS);
char buf[1024];
int i, r;
+
for(i=x_argc - 1; i > 0; i--) {
int z;
+
memset(buf, 0, 1024);
- sprintf(buf, "%s", x_argv[0]);
+ switch_snprintf(buf, sizeof(buf), "%s", x_argv[0]);
for(z=1; z < i; z++) {
strcat(buf, sep);
- strcat(buf, x_argv[z]);
+ strncat(buf, x_argv[z], sizeof(buf) - strlen(buf) - 1);
}
+
r = _switch_event_channel_broadcast(buf, ecd->event_channel, ecd->json, ecd->key, ecd->id);
t += r;
if (r && switch_core_test_flag(SCF_EVENT_CHANNEL_HIERARCHY_DELIVERY_ONCE)) {
}
} else {
char *p = NULL;
+
if ((p = strchr(key, '.'))) {
*p = '\0';
t += _switch_event_channel_broadcast(key, ecd->event_channel, ecd->json, ecd->key, ecd->id);
}
}
+
switch_safe_free(key);
t += _switch_event_channel_broadcast(SWITCH_EVENT_CHANNEL_GLOBAL, ecd->event_channel, ecd->json, ecd->key, ecd->id);
if(t == 0) {
if (switch_core_test_flag(SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON)) {
char *json = cJSON_Print(ecd->json);
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no subscribers for %s , %s => %s\n", ecd->event_channel, ecd->key, json);
switch_safe_free(json);
} else {
static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void *obj)
{
struct key_collect *collect = (struct key_collect *) obj;
- switch_channel_t *channel = switch_core_session_get_channel(collect->session);
+ switch_channel_t *channel = NULL;
char buf[10] = SWITCH_BLANK_STRING;
switch_application_interface_t *application_interface = NULL;
- if (collect->session) {
- if (switch_core_session_read_lock(collect->session) != SWITCH_STATUS_SUCCESS) {
- return NULL;
- }
- } else {
+ if (!collect->session) {
+ return NULL;
+ }
+
+ channel = switch_core_session_get_channel(collect->session);
+ if (switch_core_session_read_lock(collect->session) != SWITCH_STATUS_SUCCESS) {
return NULL;
}
switch_channel_set_flag(channel, CF_WINNER);
switch_channel_set_variable(channel, "group_dial_status", "winner");
}
+
goto wbreak;
}
switch_ivr_play_file(collect->session, NULL, collect->error_file, NULL);
}
}
+
wbreak:
switch_core_session_rwunlock(collect->session);
case SWITCH_RTP_CRYPTO_RECV:
switch_channel_set_variable(channel, "srtp_remote_crypto_key", (const char *)b64_key);
break;
- case SWITCH_RTP_CRYPTO_SEND_RTCP:
- switch_channel_set_variable(channel, "srtcp_local_crypto_key", (const char *)b64_key);
- break;
- case SWITCH_RTP_CRYPTO_RECV_RTCP:
- switch_channel_set_variable(channel, "srtcp_remote_crypto_key", (const char *)b64_key);
- break;
default:
break;
}
case SWITCH_RTP_CRYPTO_RECV:
switch_channel_set_variable(channel, "srtp_remote_video_crypto_key", (const char *)b64_key);
break;
- case SWITCH_RTP_CRYPTO_SEND_RTCP:
- switch_channel_set_variable(channel, "srtcp_local_video_crypto_key", (const char *)b64_key);
- break;
- case SWITCH_RTP_CRYPTO_RECV_RTCP:
- switch_channel_set_variable(channel, "srtcp_remote_video_crypto_key", (const char *)b64_key);
- break;
default:
break;
}
case SWITCH_RTP_CRYPTO_RECV:
switch_channel_set_variable(channel, "srtp_remote_audio_crypto_key", (const char *)b64_key);
break;
- case SWITCH_RTP_CRYPTO_SEND_RTCP:
- switch_channel_set_variable(channel, "srtcp_local_audio_crypto_key", (const char *)b64_key);
- break;
- case SWITCH_RTP_CRYPTO_RECV_RTCP:
- switch_channel_set_variable(channel, "srtcp_remote_audio_crypto_key", (const char *)b64_key);
- break;
default:
break;
}
switch_xml_root_t root = (switch_xml_root_t) xml;
int i = 0;
- if (!root)
+ if (!root) {
return (const char **) SWITCH_XML_NIL;
- while (root->xml.parent)
+ }
+
+ while (root && root->xml.parent) {
root = (switch_xml_root_t) root->xml.parent; /* root tag */
+ }
+
if (!root || !root->pi) {
return (const char **) SWITCH_XML_NIL;
}
- while (root->pi[i] && strcmp(target, root->pi[i][0]))
+
+ while (root->pi[i] && strcmp(target, root->pi[i][0])) {
i++; /* find target */
+ }
+
return (const char **) ((root->pi[i]) ? root->pi[i] + 1 : SWITCH_XML_NIL);
}
return switch_xml_err(root, d, "unclosed <!--");
} else if (!strncmp(s, "![CDATA[", 8)) { /* cdata */
if ((s = strstr(s, "]]>"))) {
- if (root && root->cur) {
+ if (root->cur) {
root->cur->flags |= SWITCH_XML_CDATA;
}
switch_xml_char_content(root, d + 8, (s += 2) - d - 10, 'c');
}
} while (s && l == SWITCH_XML_BUFSIZE);
- if (!s)
+ if (!s) {
return NULL;
- root = (switch_xml_root_t) switch_xml_parse_str(s, len);
+ }
+
+ if (!(root = (switch_xml_root_t) switch_xml_parse_str(s, len))) {
+ free(s);
+
+ return NULL;
+ }
+
root->dynamic = 1; /* so we know to free s in switch_xml_free() */
+
return &root->xml;
}
if (fd < 0)
return NULL;
- fstat(fd, &st);
- if (!st.st_size) {
+ if (fstat(fd, &st) == -1 || !st.st_size) {
return NULL;
}
if (!(0<(l = read(fd, m, st.st_size)))
|| !(root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l))) {
free(m);
+
return NULL;
}
+
root->dynamic = 1; /* so we know to free s in switch_xml_free() */
return &root->xml;
switch_xml_root_t root;
if ((fd = open(file, O_RDONLY, 0)) > -1) {
- fstat(fd, &st);
- if (!st.st_size) {
+ if (fstat(fd, &st) == -1 || !st.st_size) {
close(fd);
goto error;
}
root->dynamic = 1;
close(fd);
+
return &root->xml;
}