Skip to content

Commit

Permalink
Notify speaker about talk events in AudioBridge too (see #2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero committed May 26, 2020
1 parent 212d46a commit bf79fb4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugins/janus_audiobridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2313,14 +2313,14 @@ void janus_audiobridge_destroy_session(janus_plugin_session *handle, int *error)
return;
}

static void janus_audiobridge_notify_participants(janus_audiobridge_participant *participant, json_t *msg) {
static void janus_audiobridge_notify_participants(janus_audiobridge_participant *participant, json_t *msg, gboolean notify_source_participant) {
/* participant->room->participants_mutex has to be locked. */
GHashTableIter iter;
gpointer value;
g_hash_table_iter_init(&iter, participant->room->participants);
while(!participant->room->destroyed && g_hash_table_iter_next(&iter, NULL, &value)) {
janus_audiobridge_participant *p = value;
if(p && p->session && p != participant) {
if(p && p->session && (p != participant || notify_source_participant)) {
JANUS_LOG(LOG_VERB, "Notifying participant %s (%s)\n", p->user_id_str, p->display ? p->display : "??");
int ret = gateway->push_event(p->session->handle, &janus_audiobridge_plugin, NULL, msg, NULL);
JANUS_LOG(LOG_VERB, " >> %d (%s)\n", ret, janus_get_api_error(ret));
Expand Down Expand Up @@ -4298,7 +4298,7 @@ static json_t *janus_audiobridge_process_synchronous_request(janus_audiobridge_s
json_object_set_new(event, "room",
string_ids ? json_string(audiobridge->room_id_str) : json_integer(audiobridge->room_id));
json_object_set_new(event, "file_id", json_string(file_id));
janus_audiobridge_notify_participants(p, event);
janus_audiobridge_notify_participants(p, event, TRUE);
json_decref(event);
/* Also notify event handlers */
if(notify_events && gateway->events_is_enabled()) {
Expand Down Expand Up @@ -4661,7 +4661,8 @@ void janus_audiobridge_incoming_rtp(janus_plugin_session *handle, janus_plugin_r
json_integer(participant->room ? participant->room->room_id : 0));
json_object_set_new(event, "id",
string_ids ? json_string(participant->user_id_str) : json_integer(participant->user_id));
janus_audiobridge_notify_participants(participant, event);
/* Notify the speaker this event is related to as well */
janus_audiobridge_notify_participants(participant, event, TRUE);
json_decref(event);
janus_mutex_unlock(&participant->room->mutex);
/* Also notify event handlers */
Expand Down Expand Up @@ -6399,7 +6400,7 @@ static void *janus_audiobridge_mixer_thread(void *data) {
json_object_set_new(event, "room",
string_ids ? json_string(audiobridge->room_id_str) : json_integer(audiobridge->room_id));
json_object_set_new(event, "file_id", json_string(p->user_id_str));
janus_audiobridge_notify_participants(p, event);
janus_audiobridge_notify_participants(p, event, TRUE);
json_decref(event);
/* Also notify event handlers */
if(notify_events && gateway->events_is_enabled()) {
Expand Down Expand Up @@ -6427,7 +6428,7 @@ static void *janus_audiobridge_mixer_thread(void *data) {
json_object_set_new(event, "room",
string_ids ? json_string(audiobridge->room_id_str) : json_integer(audiobridge->room_id));
json_object_set_new(event, "file_id", json_string(p->user_id_str));
janus_audiobridge_notify_participants(p, event);
janus_audiobridge_notify_participants(p, event, TRUE);
json_decref(event);
janus_mutex_unlock_nodebug(&audiobridge->mutex);
/* Also notify event handlers */
Expand Down

0 comments on commit bf79fb4

Please sign in to comment.