[mod_conference] Add flag to destroy the conference only when all mandatory members disconnect. And set endconf to end the conference when any member with the flag disconnects (#2079)

* feature/mod_conference_mandatory_member_flag: Add flag to destroy the conference only when all mandatory members disconnect. And set endconf to end the conference when any member with the flag disconnects
This commit is contained in:
David Villasmil 2023-06-28 18:39:22 +02:00 committed by GitHub
parent 244ccaa8a8
commit b355bf21e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 1 deletions

View File

@ -662,6 +662,9 @@ void conference_cdr_render(conference_obj_t *conference)
x_tag = switch_xml_add_child_d(x_flags, "end_conference", flag_off++);
switch_xml_set_txt_d(x_tag, conference_cdr_test_mflag(np, MFLAG_ENDCONF) ? "true" : "false");
x_tag = switch_xml_add_child_d(x_flags, "mandatory_member_end_conference", flag_off++);
switch_xml_set_txt_d(x_tag, conference_cdr_test_mflag(np, MFLAG_MANDATORY_MEMBER_ENDCONF) ? "true" : "false");
x_tag = switch_xml_add_child_d(x_flags, "was_kicked", flag_off++);
switch_xml_set_txt_d(x_tag, conference_cdr_test_mflag(np, MFLAG_KICKED) ? "true" : "false");

View File

@ -766,7 +766,12 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
conference->count++;
}
if (conference_utils_member_test_flag(member, MFLAG_ENDCONF)) {
conference->endconference_time = 0;
}
if (conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF)) {
if (conference->end_count++) {
conference->endconference_time = 0;
}
@ -1314,9 +1319,14 @@ switch_status_t conference_member_del(conference_obj_t *conference, conference_m
conference_video_check_flush(member, SWITCH_FALSE);
/* End conference when any member with "endconf" flag disconnects */
if (conference_utils_member_test_flag(member, MFLAG_ENDCONF)) {
conference_utils_set_flag_locked(conference, CFLAG_DESTRUCT);
}
/* End conference only if all mandatory members have disconnected */
if (conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF)) {
if (!--conference->end_count) {
//conference_utils_set_flag_locked(conference, CFLAG_DESTRUCT);
conference->endconference_time = switch_epoch_time_now(NULL);
}
}

View File

@ -132,6 +132,8 @@ void conference_utils_set_mflags(const char *flags, member_flag_t *f)
f[MFLAG_NOMOH] = 1;
} else if (!strcasecmp(argv[i], "endconf")) {
f[MFLAG_ENDCONF] = 1;
} else if (!strcasecmp(argv[i], "mandatory_member_endconf")) {
f[MFLAG_MANDATORY_MEMBER_ENDCONF] = 1;
} else if (!strcasecmp(argv[i], "mintwo")) {
f[MFLAG_MINTWO] = 1;
} else if (!strcasecmp(argv[i], "talk-data-events")) {

View File

@ -1347,6 +1347,9 @@ void conference_xlist(conference_obj_t *conference, switch_xml_t x_conference, i
x_tag = switch_xml_add_child_d(x_flags, "end_conference", count++);
switch_xml_set_txt_d(x_tag, conference_utils_member_test_flag(member, MFLAG_ENDCONF) ? "true" : "false");
x_tag = switch_xml_add_child_d(x_flags, "mandatory_member_end_conference", count++);
switch_xml_set_txt_d(x_tag, conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF) ? "true" : "false");
x_tag = switch_xml_add_child_d(x_flags, "is_ghost", count++);
switch_xml_set_txt_d(x_tag, conference_utils_member_test_flag(member, MFLAG_GHOST) ? "true" : "false");
@ -1456,6 +1459,7 @@ void conference_jlist(conference_obj_t *conference, cJSON *json_conferences)
ADDBOOL(json_conference_member_flags, "has_floor", member->id == member->conference->floor_holder);
ADDBOOL(json_conference_member_flags, "is_moderator", conference_utils_member_test_flag(member, MFLAG_MOD));
ADDBOOL(json_conference_member_flags, "end_conference", conference_utils_member_test_flag(member, MFLAG_ENDCONF));
ADDBOOL(json_conference_member_flags, "mandatory_member_end_conference", conference_utils_member_test_flag(member, MFLAG_MANDATORY_MEMBER_ENDCONF));
ADDBOOL(json_conference_member_flags, "pass_digits", conference_utils_member_test_flag(member, MFLAG_DIST_DTMF));
}
switch_mutex_unlock(conference->member_mutex);

View File

@ -178,6 +178,7 @@ typedef enum {
MFLAG_NO_MINIMIZE_ENCODING,
MFLAG_FLUSH_BUFFER,
MFLAG_ENDCONF,
MFLAG_MANDATORY_MEMBER_ENDCONF,
MFLAG_HAS_AUDIO,
MFLAG_TALKING,
MFLAG_RESTART,