app_confbridge: Use bridge join hook to send join and leave events

The first attempt at publishing confbridge events to participants
involved publishing them at the same time stasis events were
created.  This caused issues with bridge and channel locks.  The
second attempt involved publishing them when the stasis events
were received by the code that published the confbridge AMI events.
This caused timing issues because, depending on resources available,
the event could be received before channels actually joined the
bridge and would therefore fail to send messages to the participant.

This attempt reverts to the original mechanism with one exception.
The join and leave events are published via bridge join and leave
hooks.  This guarantees the states of the channels and bridge and
provides deterministic timing for event publishing.

Change-Id: I2660074f8a30a5224cb953d5e047ee84484a9036
This commit is contained in:
George Joseph
2018-09-27 12:19:28 -06:00
parent 94ef074cc7
commit b4ab26e72f
3 changed files with 75 additions and 14 deletions

View File

@@ -395,6 +395,9 @@ static void set_media_labels(struct confbridge_conference *conference,
struct ast_stream *stream;
struct ast_channel *chan = dir == LABEL_DIRECTION_SRC ? dest_chan : src_chan;
if (!chan) {
return;
}
topology = ast_channel_get_stream_topology(chan);
stream = get_stream(topology, AST_MEDIA_TYPE_VIDEO);
if (stream) {
@@ -458,8 +461,8 @@ static void send_message(const char *msg_name, char *conf_name, struct ast_json
ast_json_free(json);
}
static void send_event_to_participants(struct confbridge_conference *conference,
struct ast_channel *chan, struct stasis_message * msg)
void conf_send_event_to_participants(struct confbridge_conference *conference,
struct ast_channel *chan, struct stasis_message *msg)
{
struct ast_bridge_blob *obj = stasis_message_data(msg);
struct ast_json *extras = obj->blob;
@@ -597,13 +600,6 @@ static void confbridge_publish_manager_event(
struct confbridge_conference *conference = conf_find_bridge(conference_name);
channel_text = ast_manager_build_channel_state_string(blob->channel);
if (conference && ast_test_flag(&conference->b_profile, BRIDGE_OPT_ENABLE_EVENTS)) {
struct ast_channel *chan = ast_channel_get_by_name(blob->channel->name);
send_event_to_participants(conference, chan, message);
ast_channel_cleanup(chan);
}
ao2_cleanup(conference);
}