FS-8685: multiple member arguments for conference relate api command
multiple member arguments can be separated by a comma, eg: conference foo relate 1 2,3,4 nohear conference foo relate 1,2 3 nospeak
This commit is contained in:
parent
013fb1d29c
commit
75f94438bc
|
@ -71,7 +71,7 @@ api_command_t conference_api_sub_commands[] = {
|
||||||
{"unvmute", (void_fn_t) & conference_api_sub_unvmute, CONF_API_SUB_MEMBER_TARGET, "unvmute", "<[member_id|all]|last|non_moderator> [<quiet>]"},
|
{"unvmute", (void_fn_t) & conference_api_sub_unvmute, CONF_API_SUB_MEMBER_TARGET, "unvmute", "<[member_id|all]|last|non_moderator> [<quiet>]"},
|
||||||
{"deaf", (void_fn_t) & conference_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "deaf", "<[member_id|all]|last|non_moderator>"},
|
{"deaf", (void_fn_t) & conference_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "deaf", "<[member_id|all]|last|non_moderator>"},
|
||||||
{"undeaf", (void_fn_t) & conference_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, "undeaf", "<[member_id|all]|last|non_moderator>"},
|
{"undeaf", (void_fn_t) & conference_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, "undeaf", "<[member_id|all]|last|non_moderator>"},
|
||||||
{"relate", (void_fn_t) & conference_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, "relate", "<member_id> <other_member_id> [nospeak|nohear|clear]"},
|
{"relate", (void_fn_t) & conference_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, "relate", "<member_id>[,<member_id>] <other_member_id>[,<other_member_id>] [nospeak|nohear|clear]"},
|
||||||
{"lock", (void_fn_t) & conference_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "lock", ""},
|
{"lock", (void_fn_t) & conference_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "lock", ""},
|
||||||
{"unlock", (void_fn_t) & conference_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "unlock", ""},
|
{"unlock", (void_fn_t) & conference_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "unlock", ""},
|
||||||
{"agc", (void_fn_t) & conference_api_sub_agc, CONF_API_SUB_ARGS_SPLIT, "agc", ""},
|
{"agc", (void_fn_t) & conference_api_sub_agc, CONF_API_SUB_ARGS_SPLIT, "agc", ""},
|
||||||
|
@ -1937,23 +1937,9 @@ switch_status_t conference_api_sub_stop(conference_obj_t *conference, switch_str
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
|
void _conference_api_sub_relate_show_member_relationships(conference_obj_t *conference, switch_stream_handle_t *stream, uint32_t member_id)
|
||||||
{
|
{
|
||||||
uint8_t nospeak = 0, nohear = 0, sendvideo = 0, clear = 0;
|
|
||||||
|
|
||||||
switch_assert(conference != NULL);
|
|
||||||
switch_assert(stream != NULL);
|
|
||||||
|
|
||||||
if (argc <= 3) {
|
|
||||||
conference_member_t *member;
|
conference_member_t *member;
|
||||||
|
|
||||||
switch_mutex_lock(conference->mutex);
|
|
||||||
|
|
||||||
if (conference->relationship_total) {
|
|
||||||
uint32_t member_id = 0;
|
|
||||||
|
|
||||||
if (argc == 3) member_id = atoi(argv[2]);
|
|
||||||
|
|
||||||
for (member = conference->members; member; member = member->next) {
|
for (member = conference->members; member; member = member->next) {
|
||||||
conference_relationship_t *rel;
|
conference_relationship_t *rel;
|
||||||
|
|
||||||
|
@ -1966,33 +1952,11 @@ switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_s
|
||||||
(rel->flags & RFLAG_CAN_SEND_VIDEO) ? "SENDVIDEO " : "NOSENDVIDEO ");
|
(rel->flags & RFLAG_CAN_SEND_VIDEO) ? "SENDVIDEO " : "NOSENDVIDEO ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
stream->write_function(stream, "No relationships\n");
|
|
||||||
}
|
|
||||||
switch_mutex_unlock(conference->mutex);
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc <= 4)
|
void _conference_api_sub_relate_clear_member_relationship(conference_obj_t *conference, switch_stream_handle_t *stream, uint32_t id, uint32_t oid)
|
||||||
return SWITCH_STATUS_GENERR;
|
{
|
||||||
|
|
||||||
nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
|
|
||||||
nohear = strstr(argv[4], "nohear") ? 1 : 0;
|
|
||||||
sendvideo = strstr(argv[4], "sendvideo") ? 1 : 0;
|
|
||||||
|
|
||||||
if (!strcasecmp(argv[4], "clear")) {
|
|
||||||
clear = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(clear || nospeak || nohear || sendvideo)) {
|
|
||||||
return SWITCH_STATUS_GENERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clear) {
|
|
||||||
conference_member_t *member = NULL, *other_member = NULL;
|
conference_member_t *member = NULL, *other_member = NULL;
|
||||||
uint32_t id = atoi(argv[2]);
|
|
||||||
uint32_t oid = atoi(argv[3]);
|
|
||||||
|
|
||||||
if ((member = conference_member_get(conference, id))) {
|
if ((member = conference_member_get(conference, id))) {
|
||||||
conference_member_del_relationship(member, oid);
|
conference_member_del_relationship(member, oid);
|
||||||
other_member = conference_member_get(conference, oid);
|
other_member = conference_member_get(conference, oid);
|
||||||
|
@ -2012,13 +1976,12 @@ switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_s
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "relationship %u->%u not found.\n", id, oid);
|
stream->write_function(stream, "relationship %u->%u not found.\n", id, oid);
|
||||||
}
|
}
|
||||||
return SWITCH_STATUS_SUCCESS;
|
}
|
||||||
}
|
|
||||||
|
void _conference_api_sub_relate_set_member_relationship(conference_obj_t *conference, switch_stream_handle_t *stream, uint32_t id, uint32_t oid, uint8_t nospeak, uint8_t nohear, uint8_t sendvideo, char *action)
|
||||||
|
{
|
||||||
|
|
||||||
if (nospeak || nohear || sendvideo) {
|
|
||||||
conference_member_t *member = NULL, *other_member = NULL;
|
conference_member_t *member = NULL, *other_member = NULL;
|
||||||
uint32_t id = atoi(argv[2]);
|
|
||||||
uint32_t oid = atoi(argv[3]);
|
|
||||||
|
|
||||||
if ((member = conference_member_get(conference, id))) {
|
if ((member = conference_member_get(conference, id))) {
|
||||||
other_member = conference_member_get(conference, oid);
|
other_member = conference_member_get(conference, oid);
|
||||||
|
@ -2053,7 +2016,7 @@ switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_s
|
||||||
switch_core_session_request_video_refresh(member->session);
|
switch_core_session_request_video_refresh(member->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->write_function(stream, "ok %u->%u %s set\n", id, oid, argv[4]);
|
stream->write_function(stream, "ok %u->%u %s set\n", id, oid, action);
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "error!\n");
|
stream->write_function(stream, "error!\n");
|
||||||
}
|
}
|
||||||
|
@ -2061,7 +2024,7 @@ switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_s
|
||||||
stream->write_function(stream, "relationship %u->%u not found.\n", id, oid);
|
stream->write_function(stream, "relationship %u->%u not found.\n", id, oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
if (member) {
|
if (member) {
|
||||||
switch_thread_rwlock_unlock(member->rwlock);
|
switch_thread_rwlock_unlock(member->rwlock);
|
||||||
}
|
}
|
||||||
|
@ -2069,7 +2032,85 @@ switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_s
|
||||||
if (other_member) {
|
if (other_member) {
|
||||||
switch_thread_rwlock_unlock(other_member->rwlock);
|
switch_thread_rwlock_unlock(other_member->rwlock);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||||
|
{
|
||||||
|
uint8_t nospeak = 0, nohear = 0, sendvideo = 0, clear = 0;
|
||||||
|
int members = 0;
|
||||||
|
int other_members = 0;
|
||||||
|
char *members_array[100] = { 0 };
|
||||||
|
char *other_members_array[100] = { 0 };
|
||||||
|
char *lbuf_members = NULL, *lbuf_other_members = NULL, *action = NULL;
|
||||||
|
|
||||||
|
switch_assert(conference != NULL);
|
||||||
|
switch_assert(stream != NULL);
|
||||||
|
|
||||||
|
if (argc <= 3) {
|
||||||
|
switch_mutex_lock(conference->mutex);
|
||||||
|
|
||||||
|
if (conference->relationship_total) {
|
||||||
|
if (argc == 3) {
|
||||||
|
char *lbuf = NULL;
|
||||||
|
lbuf = strdup(argv[2]);
|
||||||
|
members = switch_separate_string(lbuf, ',', members_array, (sizeof(members_array) / sizeof(members_array[0])));
|
||||||
|
if (members) {
|
||||||
|
int i;
|
||||||
|
uint32_t member_id;
|
||||||
|
for (i = 0; i < members && members_array[i]; i++) {
|
||||||
|
member_id = atoi(members_array[i]);
|
||||||
|
_conference_api_sub_relate_show_member_relationships(conference, stream, member_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
switch_safe_free(lbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
stream->write_function(stream, "No relationships\n");
|
||||||
|
}
|
||||||
|
switch_mutex_unlock(conference->mutex);
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc <= 4)
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
|
||||||
|
nospeak = strstr(argv[4], "nospeak") ? 1 : 0;
|
||||||
|
nohear = strstr(argv[4], "nohear") ? 1 : 0;
|
||||||
|
sendvideo = strstr(argv[4], "sendvideo") ? 1 : 0;
|
||||||
|
|
||||||
|
if (!strcasecmp(argv[4], "clear")) {
|
||||||
|
clear = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(clear || nospeak || nohear || sendvideo)) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
lbuf_members = strdup(argv[2]);
|
||||||
|
lbuf_other_members = strdup(argv[3]);
|
||||||
|
action = strdup(argv[4]);
|
||||||
|
members = switch_separate_string(lbuf_members, ',', members_array, (sizeof(members_array) / sizeof(members_array[0])));
|
||||||
|
other_members = switch_separate_string(lbuf_other_members, ',', other_members_array, (sizeof(other_members_array) / sizeof(other_members_array[0])));
|
||||||
|
if (members && other_members) {
|
||||||
|
int i, i2;
|
||||||
|
uint32_t member_id, other_member_id;
|
||||||
|
for (i = 0; i < members && members_array[i]; i++) {
|
||||||
|
member_id = atoi(members_array[i]);
|
||||||
|
for (i2 = 0; i2 < other_members && other_members_array[i2]; i2++) {
|
||||||
|
other_member_id = atoi(other_members_array[i2]);
|
||||||
|
if (clear) {
|
||||||
|
_conference_api_sub_relate_clear_member_relationship(conference, stream, member_id, other_member_id);
|
||||||
|
}
|
||||||
|
if (nospeak || nohear || sendvideo) {
|
||||||
|
_conference_api_sub_relate_set_member_relationship(conference, stream, member_id, other_member_id, nospeak, nohear, sendvideo, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch_safe_free(lbuf_members);
|
||||||
|
switch_safe_free(lbuf_other_members);
|
||||||
|
switch_safe_free(action);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue