Skip to content

Commit

Permalink
Added changes from #2161 to AudioBridge, Streaming and TextRoom plugi…
Browse files Browse the repository at this point in the history
…ns too
  • Loading branch information
lminiero committed May 20, 2020
1 parent adb77a1 commit ee5427f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 15 deletions.
20 changes: 17 additions & 3 deletions plugins/janus_audiobridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2965,8 +2965,22 @@ static json_t *janus_audiobridge_process_synchronous_request(janus_audiobridge_s
goto prepare_response;
} else if(!strcasecmp(request_text, "list")) {
/* List all rooms (but private ones) and their details (except for the secret, of course...) */
json_t *list = json_array();
JANUS_LOG(LOG_VERB, "Request for the list for all video rooms\n");
gboolean lock_room_list = TRUE;
if(admin_key != NULL) {
json_t *admin_key_json = json_object_get(root, "admin_key");
/* Verify admin_key if it was provided */
if(admin_key_json != NULL && json_is_string(admin_key_json) && strlen(json_string_value(admin_key_json)) > 0) {
JANUS_CHECK_SECRET(admin_key, root, "admin_key", error_code, error_cause,
JANUS_AUDIOBRIDGE_ERROR_MISSING_ELEMENT, JANUS_AUDIOBRIDGE_ERROR_INVALID_ELEMENT, JANUS_AUDIOBRIDGE_ERROR_UNAUTHORIZED);
if(error_code != 0) {
goto prepare_response;
} else {
lock_room_list = FALSE;
}
}
}
json_t *list = json_array();
janus_mutex_lock(&rooms_mutex);
GHashTableIter iter;
gpointer value;
Expand All @@ -2976,8 +2990,8 @@ static json_t *janus_audiobridge_process_synchronous_request(janus_audiobridge_s
if(!room || g_atomic_int_get(&room->destroyed))
continue;
janus_refcount_increase(&room->ref);
if(room->is_private) {
/* Skip private room */
if(room->is_private && lock_room_list) {
/* Skip private room if no valid admin_key was provided */
JANUS_LOG(LOG_VERB, "Skipping private room '%s'\n", room->room_name);
janus_refcount_decrease(&room->ref);
continue;
Expand Down
20 changes: 17 additions & 3 deletions plugins/janus_streaming.c
Original file line number Diff line number Diff line change
Expand Up @@ -2365,17 +2365,31 @@ static json_t *janus_streaming_process_synchronous_request(janus_streaming_sessi
struct ifaddrs *ifas = NULL;

if(!strcasecmp(request_text, "list")) {
json_t *list = json_array();
JANUS_LOG(LOG_VERB, "Request for the list of mountpoints\n");
gboolean lock_mp_list = TRUE;
if(admin_key != NULL) {
json_t *admin_key_json = json_object_get(root, "admin_key");
/* Verify admin_key if it was provided */
if(admin_key_json != NULL && json_is_string(admin_key_json) && strlen(json_string_value(admin_key_json)) > 0) {
JANUS_CHECK_SECRET(admin_key, root, "admin_key", error_code, error_cause,
JANUS_STREAMING_ERROR_MISSING_ELEMENT, JANUS_STREAMING_ERROR_INVALID_ELEMENT, JANUS_STREAMING_ERROR_UNAUTHORIZED);
if(error_code != 0) {
goto prepare_response;
} else {
lock_mp_list = FALSE;
}
}
}
json_t *list = json_array();
/* Return a list of all available mountpoints */
janus_mutex_lock(&mountpoints_mutex);
GHashTableIter iter;
gpointer value;
g_hash_table_iter_init(&iter, mountpoints);
while(g_hash_table_iter_next(&iter, NULL, &value)) {
janus_streaming_mountpoint *mp = value;
if(mp->is_private) {
/* Skip private stream */
if(mp->is_private && lock_mp_list) {
/* Skip private stream if no valid admin_key was provided */
JANUS_LOG(LOG_VERB, "Skipping private mountpoint '%s'\n", mp->description);
continue;
}
Expand Down
20 changes: 17 additions & 3 deletions plugins/janus_textroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1855,8 +1855,22 @@ janus_plugin_result *janus_textroom_handle_incoming_request(janus_plugin_session
}
} else if(!strcasecmp(request_text, "list")) {
/* List all rooms (but private ones) and their details (except for the secret, of course...) */
json_t *list = json_array();
JANUS_LOG(LOG_VERB, "Request for the list for all text rooms\n");
gboolean lock_room_list = TRUE;
if(admin_key != NULL) {
json_t *admin_key_json = json_object_get(root, "admin_key");
/* Verify admin_key if it was provided */
if(admin_key_json != NULL && json_is_string(admin_key_json) && strlen(json_string_value(admin_key_json)) > 0) {
JANUS_CHECK_SECRET(admin_key, root, "admin_key", error_code, error_cause,
JANUS_TEXTROOM_ERROR_MISSING_ELEMENT, JANUS_TEXTROOM_ERROR_INVALID_ELEMENT, JANUS_TEXTROOM_ERROR_UNAUTHORIZED);
if(error_code != 0) {
goto msg_response;
} else {
lock_room_list = FALSE;
}
}
}
json_t *list = json_array();
janus_mutex_lock(&rooms_mutex);
GHashTableIter iter;
gpointer value;
Expand All @@ -1867,8 +1881,8 @@ janus_plugin_result *janus_textroom_handle_incoming_request(janus_plugin_session
continue;
janus_refcount_increase(&room->ref);
janus_mutex_lock(&room->mutex);
if(room->is_private) {
/* Skip private room */
if(room->is_private && lock_room_list) {
/* Skip private room if no valid admin_key was provided */
JANUS_LOG(LOG_VERB, "Skipping private room '%s'\n", room->room_name);
janus_mutex_unlock(&room->mutex);
janus_refcount_decrease(&room->ref);
Expand Down
11 changes: 5 additions & 6 deletions plugins/janus_videoroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -3540,12 +3540,7 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
goto prepare_response;
} else if(!strcasecmp(request_text, "list")) {
/* List all rooms (but private ones) and their details (except for the secret, of course...) */
json_t *list = json_array();
JANUS_LOG(LOG_VERB, "Getting the list of VideoRoom rooms\n");
janus_mutex_lock(&rooms_mutex);
GHashTableIter iter;
gpointer value;
g_hash_table_iter_init(&iter, rooms);
gboolean lock_room_list = TRUE;
if(admin_key != NULL) {
json_t *admin_key_json = json_object_get(root, "admin_key");
Expand All @@ -3554,13 +3549,17 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi
JANUS_CHECK_SECRET(admin_key, root, "admin_key", error_code, error_cause,
JANUS_VIDEOROOM_ERROR_MISSING_ELEMENT, JANUS_VIDEOROOM_ERROR_INVALID_ELEMENT, JANUS_VIDEOROOM_ERROR_UNAUTHORIZED);
if(error_code != 0) {
janus_mutex_unlock(&rooms_mutex);
goto prepare_response;
} else {
lock_room_list = FALSE;
}
}
}
json_t *list = json_array();
janus_mutex_lock(&rooms_mutex);
GHashTableIter iter;
gpointer value;
g_hash_table_iter_init(&iter, rooms);
while(g_hash_table_iter_next(&iter, NULL, &value)) {
janus_videoroom *room = value;
if(!room)
Expand Down

0 comments on commit ee5427f

Please sign in to comment.