Skip to content

Commit

Permalink
AudioBridge_List-Announcements - style
Browse files Browse the repository at this point in the history
  • Loading branch information
keremcadirci committed Jun 10, 2024
1 parent c984b53 commit 53a6bd2
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/plugins/janus_audiobridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -5480,41 +5480,41 @@ static json_t *janus_audiobridge_process_synchronous_request(janus_audiobridge_s
goto prepare_response;
#endif
} else if(!strcasecmp(request_text, "listannouncements")) {
/* List all announcements in a room */
if(!string_ids) {
JANUS_VALIDATE_JSON_OBJECT(root, room_parameters,
/* List all announcements in a room */
if(!string_ids) {
JANUS_VALIDATE_JSON_OBJECT(root, room_parameters,
error_code, error_cause, TRUE,
JANUS_AUDIOBRIDGE_ERROR_MISSING_ELEMENT, JANUS_AUDIOBRIDGE_ERROR_INVALID_ELEMENT);
} else {
JANUS_VALIDATE_JSON_OBJECT(root, roomstr_parameters,
} else {
JANUS_VALIDATE_JSON_OBJECT(root, roomstr_parameters,
error_code, error_cause, TRUE,
JANUS_AUDIOBRIDGE_ERROR_MISSING_ELEMENT, JANUS_AUDIOBRIDGE_ERROR_INVALID_ELEMENT);
}
if(error_code != 0)
goto prepare_response;
json_t *room = json_object_get(root, "room");
guint64 room_id = 0;
char room_id_num[30], *room_id_str = NULL;
if(!string_ids) {
room_id = json_integer_value(room);
g_snprintf(room_id_num, sizeof(room_id_num), "%"SCNu64, room_id);
room_id_str = room_id_num;
} else {
room_id_str = (char *)json_string_value(room);
}
janus_mutex_lock(&rooms_mutex);
janus_audiobridge_room *audiobridge = g_hash_table_lookup(rooms,
string_ids ? (gpointer)room_id_str : (gpointer)&room_id);
if(audiobridge == NULL) {
janus_mutex_unlock(&rooms_mutex);
error_code = JANUS_AUDIOBRIDGE_ERROR_NO_SUCH_ROOM;
JANUS_LOG(LOG_ERR, "No such room (%s)\n", room_id_str);
g_snprintf(error_cause, 512, "No such room (%s)", room_id_str);
goto prepare_response;
}
janus_refcount_increase(&audiobridge->ref);
/* Return a list of all announcements */
json_t *list = json_array();
}
if(error_code != 0)
goto prepare_response;
json_t *room = json_object_get(root, "room");
guint64 room_id = 0;
char room_id_num[30], *room_id_str = NULL;
if(!string_ids) {
room_id = json_integer_value(room);
g_snprintf(room_id_num, sizeof(room_id_num), "%"SCNu64, room_id);
room_id_str = room_id_num;
} else {
room_id_str = (char *)json_string_value(room);
}
janus_mutex_lock(&rooms_mutex);
janus_audiobridge_room *audiobridge = g_hash_table_lookup(rooms,
string_ids ? (gpointer)room_id_str : (gpointer)&room_id);
if(audiobridge == NULL) {
janus_mutex_unlock(&rooms_mutex);
error_code = JANUS_AUDIOBRIDGE_ERROR_NO_SUCH_ROOM;
JANUS_LOG(LOG_ERR, "No such room (%s)\n", room_id_str);
g_snprintf(error_cause, 512, "No such room (%s)", room_id_str);
goto prepare_response;
}
janus_refcount_increase(&audiobridge->ref);
/* Return a list of all announcements */
json_t *list = json_array();
GHashTableIter iter;
gpointer value;
g_hash_table_iter_init(&iter, audiobridge->anncs);
Expand All @@ -5528,14 +5528,14 @@ static json_t *janus_audiobridge_process_synchronous_request(janus_audiobridge_s
json_object_set_new(pl, "loop", p->annc->loop ? json_true() : json_false());
json_array_append_new(list, pl);
}
janus_refcount_decrease(&audiobridge->ref);
janus_mutex_unlock(&rooms_mutex);
response = json_object();
json_object_set_new(response, "audiobridge", json_string("announcements"));
json_object_set_new(response, "room", string_ids ? json_string(room_id_str) : json_integer(room_id));
json_object_set_new(response, "announcements", list);
goto prepare_response;
} else if(!strcasecmp(request_text, "stop_file")) {
janus_refcount_decrease(&audiobridge->ref);
janus_mutex_unlock(&rooms_mutex);
response = json_object();
json_object_set_new(response, "audiobridge", json_string("announcements"));
json_object_set_new(response, "room", string_ids ? json_string(room_id_str) : json_integer(room_id));
json_object_set_new(response, "announcements", list);
goto prepare_response;
} else if(!strcasecmp(request_text, "stop_file")) {
#ifndef HAVE_LIBOGG
JANUS_LOG(LOG_VERB, "Playing files unsupported in this instance\n");
error_code = JANUS_AUDIOBRIDGE_ERROR_INVALID_REQUEST;
Expand Down

0 comments on commit 53a6bd2

Please sign in to comment.