]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10260: [mod_conference] add conference count api command
authorMike Jerris <mike@jerris.com>
Mon, 24 Apr 2017 21:34:04 +0000 (16:34 -0500)
committerMike Jerris <mike@jerris.com>
Mon, 24 Apr 2017 21:34:19 +0000 (16:34 -0500)
src/mod/applications/mod_conference/conference_api.c
src/mod/applications/mod_conference/mod_conference.h

index cbd8a51aa378bc3340321d61d468d895dc8bb713..95dd7a29ef0476178030921f4634c7bd7cab6522 100644 (file)
@@ -43,6 +43,7 @@
 
 
 api_command_t conference_api_sub_commands[] = {
+       {"count", (void_fn_t) & conference_api_sub_count, CONF_API_SUB_ARGS_SPLIT, "count", ""},
        {"list", (void_fn_t) & conference_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "list", "[delim <string>]|[count]"},
        {"xml_list", (void_fn_t) & conference_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, "xml_list", ""},
        {"json_list", (void_fn_t) & conference_api_sub_json_list, CONF_API_SUB_ARGS_SPLIT, "json_list", "[compact]"},
@@ -220,6 +221,8 @@ switch_status_t conference_api_main_real(const char *cmd, switch_core_session_t
                        /* special case the list command, because it doesn't require a conference argument */
                        if (strcasecmp(argv[0], "list") == 0) {
                                conference_api_sub_list(NULL, stream, argc, argv);
+                       } else if (strcasecmp(argv[0], "count") == 0) {
+                               conference_api_sub_count(NULL, stream, argc, argv);
                        } else if (strcasecmp(argv[0], "xml_list") == 0) {
                                conference_api_sub_xml_list(NULL, stream, argc, argv);
                        } else if (strcasecmp(argv[0], "json_list") == 0) {
@@ -1663,6 +1666,25 @@ switch_status_t conference_api_sub_vid_layout(conference_obj_t *conference, swit
        return SWITCH_STATUS_SUCCESS;
 }
 
+switch_status_t conference_api_sub_count(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
+{
+
+       if (conference) {
+               conference_list_count_only(conference, stream);
+       } else {
+               int count = 0;
+               switch_hash_index_t *hi;
+               switch_mutex_lock(conference_globals.hash_mutex);
+               for (hi = switch_core_hash_first(conference_globals.conference_hash); hi; hi = switch_core_hash_next(&hi)) {
+                       count++;
+               }
+               switch_mutex_unlock(conference_globals.hash_mutex);
+               stream->write_function(stream, "%d", count);
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 switch_status_t conference_api_sub_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
 {
        int ret_status = SWITCH_STATUS_GENERR;
index 8fc46bb40ee5d7433af3b33bdc5b8d9a497d38ba..27cc51351fd67e5a10d128c648d1615a1e5a67ee 100644 (file)
@@ -1214,6 +1214,7 @@ switch_status_t conference_api_sub_write_png(conference_obj_t *conference, switc
 switch_status_t conference_api_sub_file_vol(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);
 switch_status_t conference_api_sub_recording(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);
 switch_status_t conference_api_sub_vid_layout(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);
+switch_status_t conference_api_sub_count(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);
 switch_status_t conference_api_sub_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);
 switch_status_t conference_api_sub_xml_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);
 switch_status_t conference_api_sub_json_list(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);