Merge pull request #648 in FS/freeswitch from ~THEHUNMONKGROUP/freeswitch:feature/FS-8685-conference-relate-multiple-members to master
* commit '75f94438bc85ca7394220279d65aea4164d9c060': FS-8685: multiple member arguments for conference relate api command
This commit is contained in:
commit
815af8fab3
|
@ -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>]"},
|
||||
{"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>"},
|
||||
{"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", ""},
|
||||
{"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", ""},
|
||||
|
@ -1937,23 +1937,9 @@ switch_status_t conference_api_sub_stop(conference_obj_t *conference, switch_str
|
|||
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;
|
||||
|
||||
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) {
|
||||
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 ");
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
if (clear) {
|
||||
void _conference_api_sub_relate_clear_member_relationship(conference_obj_t *conference, switch_stream_handle_t *stream, uint32_t id, uint32_t oid)
|
||||
{
|
||||
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))) {
|
||||
conference_member_del_relationship(member, 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 {
|
||||
stream->write_function(stream, "relationship %u->%u not found.\n", id, oid);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (nospeak || nohear || sendvideo) {
|
||||
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)
|
||||
{
|
||||
|
||||
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))) {
|
||||
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);
|
||||
}
|
||||
|
||||
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 {
|
||||
stream->write_function(stream, "error!\n");
|
||||
}
|
||||
|
@ -2071,6 +2034,84 @@ switch_status_t conference_api_sub_relate(conference_obj_t *conference, switch_s
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue