提交 21e7c025 authored 作者: Michael Jerris's avatar Michael Jerris

cleanup, refactor, reduce indentation.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7417 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 9cb51f53
...@@ -352,7 +352,8 @@ static switch_status_t conference_add_event_member_data(conference_member_t * me ...@@ -352,7 +352,8 @@ static switch_status_t conference_add_event_member_data(conference_member_t * me
{ {
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
if (member) { if (!member) return status;
if (member->session) { if (member->session) {
switch_channel_t *channel = switch_core_session_get_channel(member->session); switch_channel_t *channel = switch_core_session_get_channel(member->session);
switch_channel_event_set_data(channel, event); switch_channel_event_set_data(channel, event);
...@@ -363,7 +364,6 @@ static switch_status_t conference_add_event_member_data(conference_member_t * me ...@@ -363,7 +364,6 @@ static switch_status_t conference_add_event_member_data(conference_member_t * me
} }
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
}
return status; return status;
} }
...@@ -384,38 +384,28 @@ static uint32_t next_member_id(void) ...@@ -384,38 +384,28 @@ static uint32_t next_member_id(void)
/* if other_member has a relationship with member, produce it */ /* if other_member has a relationship with member, produce it */
static conference_relationship_t *member_get_relationship(conference_member_t * member, conference_member_t * other_member) static conference_relationship_t *member_get_relationship(conference_member_t * member, conference_member_t * other_member)
{ {
conference_relationship_t *rel = NULL; conference_relationship_t *rel = NULL, *global = NULL;
if (member != NULL && other_member != NULL) { if (member == NULL || other_member == NULL || member->relationships == NULL) return NULL;
conference_relationship_t *global = NULL;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
switch_mutex_lock(other_member->flag_mutex); switch_mutex_lock(other_member->flag_mutex);
if (member->relationships) {
for (rel = member->relationships; rel; rel = rel->next) { for (rel = member->relationships; rel; rel = rel->next) {
if (rel->id == other_member->id) { if (rel->id == other_member->id) {
break; break;
} }
/* 0 matches everyone. /* 0 matches everyone. (We will still test the others brcause a real match carries more clout) */
(We will still test the others brcause a real match carries more clout) */
if (rel->id == 0) { if (rel->id == 0) {
global = rel; global = rel;
} }
} }
}
switch_mutex_unlock(other_member->flag_mutex); switch_mutex_unlock(other_member->flag_mutex);
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
if (!rel && global) { return rel ? rel : global;
rel = global;
}
}
return rel;
} }
/* traverse the conference member list for the specified member id and return it's pointer */ /* traverse the conference member list for the specified member id and return it's pointer */
...@@ -472,14 +462,14 @@ static conference_relationship_t *member_add_relationship(conference_member_t * ...@@ -472,14 +462,14 @@ static conference_relationship_t *member_add_relationship(conference_member_t *
{ {
conference_relationship_t *rel = NULL; conference_relationship_t *rel = NULL;
if (member != NULL && id != 0 && (rel = switch_core_alloc(member->pool, sizeof(*rel)))) { if (member == NULL || id == 0 || !(rel = switch_core_alloc(member->pool, sizeof(*rel)))) return NULL;
rel->id = id; rel->id = id;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
rel->next = member->relationships; rel->next = member->relationships;
member->relationships = rel; member->relationships = rel;
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
}
return rel; return rel;
} }
...@@ -490,7 +480,8 @@ static switch_status_t member_del_relationship(conference_member_t * member, uin ...@@ -490,7 +480,8 @@ static switch_status_t member_del_relationship(conference_member_t * member, uin
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
conference_relationship_t *rel, *last = NULL; conference_relationship_t *rel, *last = NULL;
if (member != NULL && id != 0) { if (member == NULL || id == 0) return status;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
for (rel = member->relationships; rel; rel = rel->next) { for (rel = member->relationships; rel; rel = rel->next) {
if (rel->id == id) { if (rel->id == id) {
...@@ -506,7 +497,6 @@ static switch_status_t member_del_relationship(conference_member_t * member, uin ...@@ -506,7 +497,6 @@ static switch_status_t member_del_relationship(conference_member_t * member, uin
last = rel; last = rel;
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
}
return status; return status;
} }
...@@ -981,8 +971,6 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, ...@@ -981,8 +971,6 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
switch_event_fire(&event); switch_event_fire(&event);
} }
switch_mutex_lock(conference->mutex); switch_mutex_lock(conference->mutex);
conference_stop_file(conference, FILE_STOP_ASYNC); conference_stop_file(conference, FILE_STOP_ASYNC);
conference_stop_file(conference, FILE_STOP_ALL); conference_stop_file(conference, FILE_STOP_ALL);
...@@ -1072,7 +1060,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, ...@@ -1072,7 +1060,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
static void conference_loop_fn_mute_toggle(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_mute_toggle(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) { if (member == NULL) return;
if (switch_test_flag(member, MFLAG_CAN_SPEAK)) { if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
conf_api_sub_mute(member, NULL, NULL); conf_api_sub_mute(member, NULL, NULL);
} else { } else {
...@@ -1081,12 +1070,12 @@ static void conference_loop_fn_mute_toggle(conference_member_t * member, caller_ ...@@ -1081,12 +1070,12 @@ static void conference_loop_fn_mute_toggle(conference_member_t * member, caller_
conf_api_sub_undeaf(member, NULL, NULL); conf_api_sub_undeaf(member, NULL, NULL);
} }
} }
}
} }
static void conference_loop_fn_deafmute_toggle(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_deafmute_toggle(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) { if (member == NULL) return;
if (switch_test_flag(member, MFLAG_CAN_SPEAK)) { if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
conf_api_sub_mute(member, NULL, NULL); conf_api_sub_mute(member, NULL, NULL);
if (switch_test_flag(member, MFLAG_CAN_HEAR)) { if (switch_test_flag(member, MFLAG_CAN_HEAR)) {
...@@ -1098,15 +1087,15 @@ static void conference_loop_fn_deafmute_toggle(conference_member_t * member, cal ...@@ -1098,15 +1087,15 @@ static void conference_loop_fn_deafmute_toggle(conference_member_t * member, cal
conf_api_sub_undeaf(member, NULL, NULL); conf_api_sub_undeaf(member, NULL, NULL);
} }
} }
}
} }
static void conference_loop_fn_energy_up(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_energy_up(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->energy_level += 200; member->energy_level += 200;
if (member->energy_level > 3000) { if (member->energy_level > 3000) {
...@@ -1123,17 +1112,15 @@ static void conference_loop_fn_energy_up(conference_member_t * member, caller_co ...@@ -1123,17 +1112,15 @@ static void conference_loop_fn_energy_up(conference_member_t * member, caller_co
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_energy_equ_conf(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_energy_equ_conf(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->energy_level = member->conference->energy_level; member->energy_level = member->conference->energy_level;
...@@ -1147,16 +1134,15 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t * member, cal ...@@ -1147,16 +1134,15 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t * member, cal
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_energy_dn(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_energy_dn(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->energy_level -= 100; member->energy_level -= 100;
if (member->energy_level < 0) { if (member->energy_level < 0) {
...@@ -1173,23 +1159,19 @@ static void conference_loop_fn_energy_dn(conference_member_t * member, caller_co ...@@ -1173,23 +1159,19 @@ static void conference_loop_fn_energy_dn(conference_member_t * member, caller_co
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_volume_talk_up(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_volume_talk_up(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_out_level++; member->volume_out_level++;
switch_normalize_volume(member->volume_out_level); switch_normalize_volume(member->volume_out_level);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
...@@ -1198,23 +1180,20 @@ static void conference_loop_fn_volume_talk_up(conference_member_t * member, call ...@@ -1198,23 +1180,20 @@ static void conference_loop_fn_volume_talk_up(conference_member_t * member, call
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_volume_talk_zero(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_volume_talk_zero(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_out_level = 0; member->volume_out_level = 0;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-level");
...@@ -1223,20 +1202,17 @@ static void conference_loop_fn_volume_talk_zero(conference_member_t * member, ca ...@@ -1223,20 +1202,17 @@ static void conference_loop_fn_volume_talk_zero(conference_member_t * member, ca
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_volume_talk_dn(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_volume_talk_dn(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_out_level--; member->volume_out_level--;
switch_normalize_volume(member->volume_out_level); switch_normalize_volume(member->volume_out_level);
...@@ -1251,22 +1227,19 @@ static void conference_loop_fn_volume_talk_dn(conference_member_t * member, call ...@@ -1251,22 +1227,19 @@ static void conference_loop_fn_volume_talk_dn(conference_member_t * member, call
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_volume_listen_up(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_volume_listen_up(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_in_level++; member->volume_in_level++;
switch_normalize_volume(member->volume_in_level); switch_normalize_volume(member->volume_in_level);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
...@@ -1275,21 +1248,17 @@ static void conference_loop_fn_volume_listen_up(conference_member_t * member, ca ...@@ -1275,21 +1248,17 @@ static void conference_loop_fn_volume_listen_up(conference_member_t * member, ca
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_volume_listen_zero(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_volume_listen_zero(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_in_level = 0; member->volume_in_level = 0;
...@@ -1303,23 +1272,19 @@ static void conference_loop_fn_volume_listen_zero(conference_member_t * member, ...@@ -1303,23 +1272,19 @@ static void conference_loop_fn_volume_listen_zero(conference_member_t * member,
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_volume_listen_dn(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_volume_listen_dn(conference_member_t * member, caller_control_action_t * action)
{ {
if (member != NULL) {
char msg[512]; char msg[512];
switch_event_t *event; switch_event_t *event;
if (member == NULL) return;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_in_level--; member->volume_in_level--;
switch_normalize_volume(member->volume_in_level); switch_normalize_volume(member->volume_in_level);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "gain-level");
...@@ -1328,12 +1293,8 @@ static void conference_loop_fn_volume_listen_dn(conference_member_t * member, ca ...@@ -1328,12 +1293,8 @@ static void conference_loop_fn_volume_listen_dn(conference_member_t * member, ca
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0); conference_member_say(member, msg, 0);
}
} }
static void conference_loop_fn_event(conference_member_t * member, caller_control_action_t * action) static void conference_loop_fn_event(conference_member_t * member, caller_control_action_t * action)
...@@ -1503,16 +1464,16 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread, ...@@ -1503,16 +1464,16 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t * thread,
/* launch an input thread for the call leg */ /* launch an input thread for the call leg */
static void launch_conference_loop_input(conference_member_t * member, switch_memory_pool_t *pool) static void launch_conference_loop_input(conference_member_t * member, switch_memory_pool_t *pool)
{ {
if (member != NULL) {
switch_thread_t *thread; switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
if (member == NULL) return;
switch_threadattr_create(&thd_attr, pool); switch_threadattr_create(&thd_attr, pool);
switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_set_flag_locked(member, MFLAG_ITHREAD); switch_set_flag_locked(member, MFLAG_ITHREAD);
switch_thread_create(&thread, thd_attr, conference_loop_input, member, pool); switch_thread_create(&thread, thd_attr, conference_loop_input, member, pool);
}
} }
static caller_control_fn_table_t ccfntbl[] = { static caller_control_fn_table_t ccfntbl[] = {
...@@ -1551,14 +1512,14 @@ static void conference_loop_output(conference_member_t * member) ...@@ -1551,14 +1512,14 @@ static void conference_loop_output(conference_member_t * member)
switch_assert(member->conference != NULL); switch_assert(member->conference != NULL);
if (switch_core_timer_init(&timer, member->conference->timer_name, interval, tsamples, NULL) == SWITCH_STATUS_SUCCESS) { if (switch_core_timer_init(& timer, member->conference->timer_name, interval, tsamples, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u samples: %u\n",
member->conference->timer_name, interval, tsamples);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n");
return; return;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u samples: %u\n",
member->conference->timer_name, interval, tsamples);
write_frame.data = data; write_frame.data = data;
write_frame.buflen = sizeof(data); write_frame.buflen = sizeof(data);
write_frame.codec = &member->write_codec; write_frame.codec = &member->write_codec;
...@@ -2016,10 +1977,10 @@ static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t ...@@ -2016,10 +1977,10 @@ static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t
/* stop playing a file for the member of the conference */ /* stop playing a file for the member of the conference */
static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop) static uint32_t conference_member_stop_file(conference_member_t * member, file_stop_t stop)
{ {
conference_file_node_t *nptr;
uint32_t count = 0; uint32_t count = 0;
if (member != NULL) { if (member == NULL) return count;
conference_file_node_t *nptr;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
...@@ -2036,7 +1997,6 @@ static uint32_t conference_member_stop_file(conference_member_t * member, file_s ...@@ -2036,7 +1997,6 @@ static uint32_t conference_member_stop_file(conference_member_t * member, file_s
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
}
return count; return count;
} }
...@@ -2058,10 +2018,7 @@ static switch_status_t conference_play_file(conference_obj_t * conference, char ...@@ -2058,10 +2018,7 @@ static switch_status_t conference_play_file(conference_obj_t * conference, char
switch_mutex_unlock(conference->member_mutex); switch_mutex_unlock(conference->member_mutex);
switch_mutex_unlock(conference->mutex); switch_mutex_unlock(conference->mutex);
if (!count) { if (!count) return SWITCH_STATUS_FALSE;
status = SWITCH_STATUS_FALSE;
goto done;
}
if (channel) { if (channel) {
if ((expanded = switch_channel_expand_variables(channel, file)) != file) { if ((expanded = switch_channel_expand_variables(channel, file)) != file) {
...@@ -2148,12 +2105,9 @@ static switch_status_t conference_play_file(conference_obj_t * conference, char ...@@ -2148,12 +2105,9 @@ static switch_status_t conference_play_file(conference_obj_t * conference, char
done: done:
switch_safe_free(expanded); switch_safe_free(expanded);
switch_safe_free(dfile); switch_safe_free(dfile);
return status; return status;
} }
...@@ -2162,22 +2116,20 @@ static switch_status_t conference_member_play_file(conference_member_t * member, ...@@ -2162,22 +2116,20 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
{ {
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
char *dfile = NULL, *expanded = NULL; char *dfile = NULL, *expanded = NULL;
if (member != NULL && file != NULL) {
conference_file_node_t *fnode, *nptr = NULL; conference_file_node_t *fnode, *nptr = NULL;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
if (member == NULL || file == NULL) return status;
if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) { if ((expanded = switch_channel_expand_variables(switch_core_session_get_channel(member->session), file)) != file) {
file = expanded; file = expanded;
} else { } else {
expanded = NULL; expanded = NULL;
} }
if (!strncasecmp(file, "say:", 4)) { if (!strncasecmp(file, "say:", 4)) {
status = conference_member_say(member, file + 4, leadin); status = conference_member_say(member, file + 4, leadin);
goto done; goto done;
} }
if (!switch_is_file_path(file)) { if (!switch_is_file_path(file)) {
if (member->conference->sound_prefix) { if (member->conference->sound_prefix) {
if (!(dfile = switch_mprintf("%s%s%s", member->conference->sound_prefix, SWITCH_PATH_SEPARATOR, file))) { if (!(dfile = switch_mprintf("%s%s%s", member->conference->sound_prefix, SWITCH_PATH_SEPARATOR, file))) {
...@@ -2189,14 +2141,12 @@ static switch_status_t conference_member_play_file(conference_member_t * member, ...@@ -2189,14 +2141,12 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
goto done; goto done;
} }
} }
/* Setup a memory pool to use. */ /* Setup a memory pool to use. */
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
status = SWITCH_STATUS_MEMERR; status = SWITCH_STATUS_MEMERR;
goto done; goto done;
} }
/* Create a node object */ /* Create a node object */
if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) { if (!(fnode = switch_core_alloc(pool, sizeof(*fnode)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
...@@ -2204,10 +2154,8 @@ static switch_status_t conference_member_play_file(conference_member_t * member, ...@@ -2204,10 +2154,8 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
status = SWITCH_STATUS_MEMERR; status = SWITCH_STATUS_MEMERR;
goto done; goto done;
} }
fnode->type = NODE_TYPE_FILE; fnode->type = NODE_TYPE_FILE;
fnode->leadin = leadin; fnode->leadin = leadin;
/* Open the file */ /* Open the file */
if (switch_core_file_open(&fnode->fh, if (switch_core_file_open(&fnode->fh,
file, (uint8_t) 1, member->conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, file, (uint8_t) 1, member->conference->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
...@@ -2216,25 +2164,20 @@ static switch_status_t conference_member_play_file(conference_member_t * member, ...@@ -2216,25 +2164,20 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
status = SWITCH_STATUS_NOTFOUND; status = SWITCH_STATUS_NOTFOUND;
goto done; goto done;
} }
fnode->pool = pool; fnode->pool = pool;
/* Queue the node */ /* Queue the node */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n", file); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "queueing file '%s' for play\n", file);
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next); for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
if (nptr) { if (nptr) {
nptr->next = fnode; nptr->next = fnode;
} else { } else {
member->fnode = fnode; member->fnode = fnode;
} }
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
}
done: done:
switch_safe_free(expanded); switch_safe_free(expanded);
switch_safe_free(dfile); switch_safe_free(dfile);
...@@ -2245,13 +2188,13 @@ static switch_status_t conference_member_play_file(conference_member_t * member, ...@@ -2245,13 +2188,13 @@ static switch_status_t conference_member_play_file(conference_member_t * member,
/* Say some thing with TTS in the conference room */ /* Say some thing with TTS in the conference room */
static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin) static switch_status_t conference_member_say(conference_member_t * member, char *text, uint32_t leadin)
{ {
switch_status_t status = SWITCH_STATUS_FALSE;
if (member != NULL && !switch_strlen_zero(text)) {
conference_obj_t *conference = (member != NULL ? member->conference : NULL); conference_obj_t *conference = (member != NULL ? member->conference : NULL);
conference_file_node_t *fnode, *nptr; conference_file_node_t *fnode, *nptr;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE; switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
switch_status_t status = SWITCH_STATUS_FALSE;
if (member == NULL || switch_strlen_zero(text)) return SWITCH_STATUS_FALSE;
switch_assert(conference != NULL); switch_assert(conference != NULL);
...@@ -2317,7 +2260,6 @@ static switch_status_t conference_member_say(conference_member_t * member, char ...@@ -2317,7 +2260,6 @@ static switch_status_t conference_member_say(conference_member_t * member, char
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
}
return status; return status;
} }
...@@ -2462,7 +2404,6 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_ ...@@ -2462,7 +2404,6 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_
switch_assert(stream != NULL); switch_assert(stream != NULL);
switch_assert(delim != NULL); switch_assert(delim != NULL);
switch_mutex_lock(conference->member_mutex); switch_mutex_lock(conference->member_mutex);
for (member = conference->members; member; member = member->next) { for (member = conference->members; member; member = member->next) {
...@@ -2498,16 +2439,14 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_ ...@@ -2498,16 +2439,14 @@ static void conference_list(conference_obj_t * conference, switch_stream_handle_
} }
switch_mutex_unlock(conference->member_mutex); switch_mutex_unlock(conference->member_mutex);
} }
static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
switch_clear_flag_locked(member, MFLAG_CAN_SPEAK); switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
if (member->conference->muted_sound) { if (member->conference->muted_sound) {
conference_member_play_file(member, member->conference->muted_sound, 0); conference_member_play_file(member, member->conference->muted_sound, 0);
...@@ -2525,20 +2464,16 @@ static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_st ...@@ -2525,20 +2464,16 @@ static switch_status_t conf_api_sub_mute(conference_member_t * member, switch_st
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "mute-member");
switch_event_fire(&event); switch_event_fire(&event);
} }
} else {
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
switch_set_flag_locked(member, MFLAG_CAN_SPEAK); switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "OK unmute %u\n", member->id); stream->write_function(stream, "OK unmute %u\n", member->id);
...@@ -2556,20 +2491,16 @@ static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_ ...@@ -2556,20 +2491,16 @@ static switch_status_t conf_api_sub_unmute(conference_member_t * member, switch_
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "unmute-member");
switch_event_fire(&event); switch_event_fire(&event);
} }
} else {
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
switch_clear_flag_locked(member, MFLAG_CAN_HEAR); switch_clear_flag_locked(member, MFLAG_CAN_HEAR);
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "OK deaf %u\n", member->id); stream->write_function(stream, "OK deaf %u\n", member->id);
...@@ -2579,20 +2510,16 @@ static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_st ...@@ -2579,20 +2510,16 @@ static switch_status_t conf_api_sub_deaf(conference_member_t * member, switch_st
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "deaf-member");
switch_event_fire(&event); switch_event_fire(&event);
} }
} else {
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
switch_set_flag_locked(member, MFLAG_CAN_HEAR); switch_set_flag_locked(member, MFLAG_CAN_HEAR);
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "OK undeaf %u\n", member->id); stream->write_function(stream, "OK undeaf %u\n", member->id);
...@@ -2602,40 +2529,30 @@ static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_ ...@@ -2602,40 +2529,30 @@ static switch_status_t conf_api_sub_undeaf(conference_member_t * member, switch_
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "undeaf-member");
switch_event_fire(&event); switch_event_fire(&event);
} }
} else {
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_kick(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_kick(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
switch_clear_flag(member, MFLAG_RUNNING); switch_clear_flag(member, MFLAG_RUNNING);
switch_set_flag(member, MFLAG_KICKED); switch_set_flag(member, MFLAG_KICKED);
switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK); switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "OK kicked %u\n", member->id); stream->write_function(stream, "OK kicked %u\n", member->id);
} }
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "kick-member");
switch_event_fire(&event); switch_event_fire(&event);
} }
} else { return SWITCH_STATUS_SUCCESS;
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status;
} }
...@@ -2654,15 +2571,11 @@ static switch_status_t conf_api_sub_dtmf(conference_member_t * member, switch_st ...@@ -2654,15 +2571,11 @@ static switch_status_t conf_api_sub_dtmf(conference_member_t * member, switch_st
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK); switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
switch_core_session_send_dtmf_string(member->session, (char *)data); switch_core_session_send_dtmf_string(member->session, (char *)data);
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id); stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id);
} }
...@@ -2679,102 +2592,76 @@ static switch_status_t conf_api_sub_dtmf(conference_member_t * member, switch_st ...@@ -2679,102 +2592,76 @@ static switch_status_t conf_api_sub_dtmf(conference_member_t * member, switch_st
static switch_status_t conf_api_sub_energy(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_energy(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
if (data) { if (data) {
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->energy_level = atoi((char *) data); member->energy_level = atoi((char *) data);
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
} }
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level); stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
} }
if (data && switch_event_create_subclass(& event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
if (data) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "energy-level-member");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
switch_event_fire(& event);
switch_event_fire(&event);
}
}
} else {
ret_status = SWITCH_STATUS_GENERR;
} }
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_volume_in(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_volume_in(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
if (data) { if (data) {
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_in_level = atoi((char *) data); member->volume_in_level = atoi((char *) data);
switch_normalize_volume(member->volume_in_level); switch_normalize_volume(member->volume_in_level);
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
} }
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level); stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
} }
if (data) { if (data && switch_event_create_subclass(& event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-in-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-in-member");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_in_level); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_in_level);
switch_event_fire(& event);
switch_event_fire(&event);
}
}
} else {
ret_status = SWITCH_STATUS_GENERR;
} }
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_volume_out(conference_member_t * member, switch_stream_handle_t *stream, void *data) static switch_status_t conf_api_sub_volume_out(conference_member_t * member, switch_stream_handle_t *stream, void *data)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
if (member != NULL) {
switch_event_t *event; switch_event_t *event;
if (member == NULL) return SWITCH_STATUS_GENERR;
if (data) { if (data) {
switch_mutex_lock(member->flag_mutex); switch_mutex_lock(member->flag_mutex);
member->volume_out_level = atoi((char *) data); member->volume_out_level = atoi((char *) data);
switch_normalize_volume(member->volume_out_level); switch_normalize_volume(member->volume_out_level);
switch_mutex_unlock(member->flag_mutex); switch_mutex_unlock(member->flag_mutex);
} }
if (stream != NULL) { if (stream != NULL) {
stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level); stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
} }
if (data && switch_event_create_subclass(& event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
if (data) {
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
conference_add_event_member_data(member, event); conference_add_event_member_data(member, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-out-member"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Action", "volume-out-member");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_out_level); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Volume-Level", "%u", member->volume_out_level);
switch_event_fire(& event);
switch_event_fire(&event);
}
}
} else {
ret_status = SWITCH_STATUS_GENERR;
} }
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_list(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
...@@ -2893,15 +2780,17 @@ static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_s ...@@ -2893,15 +2780,17 @@ static switch_status_t conf_api_sub_play(conference_obj_t * conference, switch_s
static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text) static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
{ {
int ret_status = SWITCH_STATUS_GENERR; switch_event_t *event;
if (switch_strlen_zero(text)) { if (switch_strlen_zero(text)) {
stream->write_function(stream, "(say) Error! No text."); stream->write_function(stream, "(say) Error! No text.");
return ret_status; return SWITCH_STATUS_GENERR;
} }
if (conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) { if (conference_say(conference, text, 0) != SWITCH_STATUS_SUCCESS) {
switch_event_t *event; stream->write_function(stream, "(say) Error!");
return SWITCH_STATUS_GENERR;
}
stream->write_function(stream, "(say) OK\n"); stream->write_function(stream, "(say) OK\n");
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
...@@ -2910,12 +2799,7 @@ static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_st ...@@ -2910,12 +2799,7 @@ static switch_status_t conf_api_sub_say(conference_obj_t * conference, switch_st
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Text", "%s", text);
switch_event_fire(&event); switch_event_fire(&event);
} }
ret_status = SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} else {
stream->write_function(stream, "(say) Error!");
}
return ret_status;
} }
static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text) static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, switch_stream_handle_t *stream, const char *text)
...@@ -2926,6 +2810,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi ...@@ -2926,6 +2810,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi
char *workspace = NULL; char *workspace = NULL;
uint32_t id = 0; uint32_t id = 0;
conference_member_t *member; conference_member_t *member;
switch_event_t *event;
if (switch_strlen_zero(text)) { if (switch_strlen_zero(text)) {
stream->write_function(stream, "(saymember) No Text!\n"); stream->write_function(stream, "(saymember) No Text!\n");
...@@ -2960,8 +2845,10 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi ...@@ -2960,8 +2845,10 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi
expanded = NULL; expanded = NULL;
} }
if (text && conference_member_say(member, (char *) text, 0) == SWITCH_STATUS_SUCCESS) { if (!text || conference_member_say(member, (char*)text, 0) != SWITCH_STATUS_SUCCESS) {
switch_event_t *event; stream->write_function(stream, "(saymember) Error!");
goto done;
}
stream->write_function(stream, "(saymember) OK\n"); stream->write_function(stream, "(saymember) OK\n");
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
...@@ -2971,9 +2858,6 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi ...@@ -2971,9 +2858,6 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi
switch_event_fire(&event); switch_event_fire(&event);
} }
ret_status = SWITCH_STATUS_SUCCESS; ret_status = SWITCH_STATUS_SUCCESS;
} else {
stream->write_function(stream, "(saymember) Error!");
}
done: done:
switch_safe_free(workspace); switch_safe_free(workspace);
...@@ -2983,7 +2867,6 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi ...@@ -2983,7 +2867,6 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t * conference, swi
static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{ {
int ret_status = SWITCH_STATUS_GENERR;
uint8_t current = 0, all = 0; uint8_t current = 0, all = 0;
switch_assert(conference != NULL); switch_assert(conference != NULL);
...@@ -2996,7 +2879,8 @@ static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_s ...@@ -2996,7 +2879,8 @@ static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_s
all = 1; all = 1;
} }
if (current || all) { if (!(current || all)) return SWITCH_STATUS_GENERR;
if (argc == 4) { if (argc == 4) {
uint32_t id = atoi(argv[3]); uint32_t id = atoi(argv[3]);
conference_member_t *member; conference_member_t *member;
...@@ -3007,26 +2891,22 @@ static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_s ...@@ -3007,26 +2891,22 @@ static switch_status_t conf_api_sub_stop(conference_obj_t * conference, switch_s
} else { } else {
stream->write_function(stream, "Member: %u not found.\n", id); stream->write_function(stream, "Member: %u not found.\n", id);
} }
ret_status = SWITCH_STATUS_SUCCESS;
} else { } else {
uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL); uint32_t stopped = conference_stop_file(conference, current ? FILE_STOP_CURRENT : FILE_STOP_ALL);
stream->write_function(stream, "Stopped %u files.\n", stopped); stream->write_function(stream, "Stopped %u files.\n", stopped);
ret_status = SWITCH_STATUS_SUCCESS;
} }
} return SWITCH_STATUS_SUCCESS;
return ret_status;
} }
static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{ {
int ret_status = SWITCH_STATUS_GENERR; uint8_t nospeak = 0, nohear = 0, clear = 0;
switch_assert(conference != NULL); switch_assert(conference != NULL);
switch_assert(stream != NULL); switch_assert(stream != NULL);
if (argc > 4) { if (argc <= 4) return SWITCH_STATUS_GENERR;
uint8_t nospeak = 0, nohear = 0, clear = 0;
nospeak = strstr(argv[4], "nospeak") ? 1 : 0; nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
nohear = strstr(argv[4], "nohear") ? 1 : 0; nohear = strstr(argv[4], "nohear") ? 1 : 0;
...@@ -3035,10 +2915,8 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch ...@@ -3035,10 +2915,8 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch
} }
if (!(clear || nospeak || nohear)) { if (!(clear || nospeak || nohear)) {
ret_status = SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
goto done;
} }
ret_status = SWITCH_STATUS_SUCCESS;
if (clear) { if (clear) {
conference_member_t *member = NULL; conference_member_t *member = NULL;
...@@ -3051,7 +2929,10 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch ...@@ -3051,7 +2929,10 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch
} else { } else {
stream->write_function(stream, "relationship %u->%u not found", id, oid); stream->write_function(stream, "relationship %u->%u not found", id, oid);
} }
} else if (nospeak || nohear) { return SWITCH_STATUS_SUCCESS;
}
if (nospeak || nohear) {
conference_member_t *member = NULL, *other_member = NULL; conference_member_t *member = NULL, *other_member = NULL;
uint32_t id = atoi(argv[2]); uint32_t id = atoi(argv[2]);
uint32_t oid = atoi(argv[3]); uint32_t oid = atoi(argv[3]);
...@@ -3081,10 +2962,8 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch ...@@ -3081,10 +2962,8 @@ static switch_status_t conf_api_sub_relate(conference_obj_t * conference, switch
stream->write_function(stream, "relationship %u->%u not found", id, oid); stream->write_function(stream, "relationship %u->%u not found", id, oid);
} }
} }
}
done: return SWITCH_STATUS_SUCCESS;
return ret_status;
} }
static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_lock(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
...@@ -3128,54 +3007,47 @@ static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch ...@@ -3128,54 +3007,47 @@ static switch_status_t conf_api_sub_unlock(conference_obj_t * conference, switch
switch_event_fire(&event); switch_event_fire(&event);
} }
return 0; return 0;
} }
static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_dial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS; switch_call_cause_t cause;
switch_assert(stream != NULL); switch_assert(stream != NULL);
if (argc > 2) { if (argc <= 2) {
switch_call_cause_t cause; stream->write_function(stream, "Bad Args\n");
return SWITCH_STATUS_GENERR;
}
if (conference) { if (conference) {
conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &cause); conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
} else { } else {
conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &cause); conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
} }
stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause)); stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause));
} else {
stream->write_function(stream, "Bad Args\n");
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
switch_assert(stream != NULL); switch_assert(stream != NULL);
if (argc > 2) { if (argc <= 2) {
stream->write_function(stream, "Bad Args\n");
return SWITCH_STATUS_GENERR;
}
if (conference) { if (conference) {
conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3]); conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3]);
} else { } else {
conference_outcall_bg(NULL, argv[1], NULL, argv[2], 60, NULL, argv[4], argv[3]); conference_outcall_bg(NULL, argv[1], NULL, argv[2], 60, NULL, argv[4], argv[3]);
} }
stream->write_function(stream, "OK\n"); stream->write_function(stream, "OK\n");
} else {
stream->write_function(stream, "Bad Args\n");
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
...@@ -3310,39 +3182,32 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, swit ...@@ -3310,39 +3182,32 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, swit
static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_record(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
switch_assert(conference != NULL); switch_assert(conference != NULL);
switch_assert(stream != NULL); switch_assert(stream != NULL);
if (argc > 2) { if (argc <= 2) return SWITCH_STATUS_GENERR;
stream->write_function(stream, "Record file %s\n", argv[2]); stream->write_function(stream, "Record file %s\n", argv[2]);
launch_conference_record_thread(conference, argv[2]); launch_conference_record_thread(conference, argv[2]);
} else { return SWITCH_STATUS_SUCCESS;
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status;
} }
static switch_status_t conf_api_sub_norecord(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_norecord(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{ {
switch_status_t ret_status = SWITCH_STATUS_SUCCESS; int all;
switch_assert(conference != NULL); switch_assert(conference != NULL);
switch_assert(stream != NULL); switch_assert(stream != NULL);
if (argc > 2) { if (argc <= 2) return SWITCH_STATUS_GENERR;
int all = (strcasecmp(argv[2], "all") == 0);
stream->write_function(stream, "Stop recording file %s\n", argv[2]);
all = (strcasecmp(argv[2], "all") == 0);
stream->write_function(stream, "Stop recording file %s\n", argv[2]);
if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) { if (!conference_record_stop(conference, all ? NULL : argv[2]) && !all) {
stream->write_function(stream, "non-existant recording '%s'\n", argv[2]); stream->write_function(stream, "non-existant recording '%s'\n", argv[2]);
} }
} else {
ret_status = SWITCH_STATUS_GENERR;
}
return ret_status; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t conf_api_sub_pin(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv) static switch_status_t conf_api_sub_pin(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
...@@ -3812,11 +3677,11 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference, ...@@ -3812,11 +3677,11 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference,
switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name, const char *cid_num) switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name, const char *cid_num)
{ {
struct bg_call *call = NULL; struct bg_call *call = NULL;
if ((call = malloc(sizeof(*call)))) {
switch_thread_t *thread; switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
if (!(call = malloc(sizeof(*call)))) return SWITCH_STATUS_MEMERR;
memset(call, 0, sizeof(*call)); memset(call, 0, sizeof(*call));
call->conference = conference; call->conference = conference;
call->session = session; call->session = session;
...@@ -3839,7 +3704,6 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference, ...@@ -3839,7 +3704,6 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference,
call->conference_name = strdup(conference_name); call->conference_name = strdup(conference_name);
} }
switch_threadattr_create(&thd_attr, conference->pool); switch_threadattr_create(&thd_attr, conference->pool);
switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
...@@ -3847,9 +3711,6 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference, ...@@ -3847,9 +3711,6 @@ static switch_status_t conference_outcall_bg(conference_obj_t * conference,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lanuching BG Thread for outcall\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Lanuching BG Thread for outcall\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_MEMERR;
} }
/* Play a file */ /* Play a file */
...@@ -3891,7 +3752,6 @@ static switch_status_t conference_local_play_file(conference_obj_t * conference, ...@@ -3891,7 +3752,6 @@ static switch_status_t conference_local_play_file(conference_obj_t * conference,
goto done; goto done;
} }
if (conference->sound_prefix) { if (conference->sound_prefix) {
if (!(dpath = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, path))) { if (!(dpath = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, path))) {
status = SWITCH_STATUS_MEMERR; status = SWITCH_STATUS_MEMERR;
...@@ -4022,7 +3882,6 @@ SWITCH_STANDARD_APP(conference_function) ...@@ -4022,7 +3882,6 @@ SWITCH_STANDARD_APP(conference_function)
profile_name = "default"; profile_name = "default";
} }
switch_event_create(&params, SWITCH_EVENT_MESSAGE); switch_event_create(&params, SWITCH_EVENT_MESSAGE);
switch_assert(params); switch_assert(params);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "conf_name", conf_name); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "conf_name", conf_name);
...@@ -4505,7 +4364,6 @@ static switch_status_t conf_default_controls(conference_obj_t * conference) ...@@ -4505,7 +4364,6 @@ static switch_status_t conf_default_controls(conference_obj_t * conference)
} }
} }
return status; return status;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论