mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
bridges: Remove reliance on stasis caching
* The bridging core no longer uses the stasis cache for bridge snapshots. The latest bridge snapshot is now stored on the ast_bridge structure itself. * The following APIs are no longer available since the stasis cache is no longer used: ast_bridge_topic_cached() ast_bridge_topic_all_cached() * A topic pool is now used for individual bridge topics. * The ast_bridge_cache() function was removed since there's no longer a separate container of snapshots. * A new function "ast_bridges()" was created to retrieve the container of all bridges. Users formerly calling ast_bridge_cache() can use the new function to iterate over bridges and retrieve the latest snapshot directly from the bridge. * The ast_bridge_snapshot_get_latest() function was renamed to ast_bridge_get_snapshot_by_uniqueid(). * A new function "ast_bridge_get_snapshot()" was created to retrieve the bridge snapshot directly from the bridge structure. * The ast_bridge_topic_all() function now returns a normal topic not a cached one so you can't use stasis cache functions on it either. * The ast_bridge_snapshot_type() stasis message now has the ast_bridge_snapshot_update structure as it's data. It contains the last snapshot and the new one. * cdr, cel, manager and ari have been updated to use the new arrangement. Change-Id: I7049b80efa88676ce5c4666f818fa18ad1985369
This commit is contained in:
@@ -172,16 +172,9 @@ static struct app_forwards *forwards_create_bridge(struct stasis_app *app,
|
||||
}
|
||||
|
||||
forwards->forward_type = FORWARD_BRIDGE;
|
||||
if (bridge) {
|
||||
forwards->topic_forward = stasis_forward_all(ast_bridge_topic(bridge),
|
||||
app->topic);
|
||||
}
|
||||
forwards->topic_cached_forward = stasis_forward_all(
|
||||
bridge ? ast_bridge_topic_cached(bridge) : ast_bridge_topic_all_cached(),
|
||||
app->topic);
|
||||
forwards->topic_forward = stasis_forward_all(ast_bridge_topic(bridge), app->topic);
|
||||
|
||||
if ((!forwards->topic_forward && bridge) || !forwards->topic_cached_forward) {
|
||||
/* Half-subscribed is a bad thing */
|
||||
if (!forwards->topic_forward && bridge) {
|
||||
forwards_unsubscribe(forwards);
|
||||
ao2_ref(forwards, -1);
|
||||
return NULL;
|
||||
@@ -666,33 +659,23 @@ static void sub_bridge_update_handler(void *data,
|
||||
{
|
||||
struct ast_json *json = NULL;
|
||||
struct stasis_app *app = data;
|
||||
struct stasis_cache_update *update;
|
||||
struct ast_bridge_snapshot *new_snapshot;
|
||||
struct ast_bridge_snapshot *old_snapshot;
|
||||
struct ast_bridge_snapshot_update *update;
|
||||
const struct timeval *tv;
|
||||
|
||||
ast_assert(stasis_message_type(message) == stasis_cache_update_type());
|
||||
|
||||
update = stasis_message_data(message);
|
||||
|
||||
ast_assert(update->type == ast_bridge_snapshot_type());
|
||||
tv = stasis_message_timestamp(message);
|
||||
|
||||
new_snapshot = stasis_message_data(update->new_snapshot);
|
||||
old_snapshot = stasis_message_data(update->old_snapshot);
|
||||
tv = update->new_snapshot ?
|
||||
stasis_message_timestamp(update->new_snapshot) :
|
||||
stasis_message_timestamp(message);
|
||||
|
||||
if (!new_snapshot) {
|
||||
json = simple_bridge_event("BridgeDestroyed", old_snapshot, tv);
|
||||
} else if (!old_snapshot) {
|
||||
json = simple_bridge_event("BridgeCreated", new_snapshot, tv);
|
||||
} else if (new_snapshot && old_snapshot
|
||||
&& strcmp(new_snapshot->video_source_id, old_snapshot->video_source_id)) {
|
||||
json = simple_bridge_event("BridgeVideoSourceChanged", new_snapshot, tv);
|
||||
if (json && !ast_strlen_zero(old_snapshot->video_source_id)) {
|
||||
if (!update->new_snapshot) {
|
||||
json = simple_bridge_event("BridgeDestroyed", update->old_snapshot, tv);
|
||||
} else if (!update->old_snapshot) {
|
||||
json = simple_bridge_event("BridgeCreated", update->new_snapshot, tv);
|
||||
} else if (update->new_snapshot && update->old_snapshot
|
||||
&& strcmp(update->new_snapshot->video_source_id, update->old_snapshot->video_source_id)) {
|
||||
json = simple_bridge_event("BridgeVideoSourceChanged", update->new_snapshot, tv);
|
||||
if (json && !ast_strlen_zero(update->old_snapshot->video_source_id)) {
|
||||
ast_json_object_set(json, "old_video_source_id",
|
||||
ast_json_string_create(old_snapshot->video_source_id));
|
||||
ast_json_string_create(update->old_snapshot->video_source_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,8 +684,8 @@ static void sub_bridge_update_handler(void *data,
|
||||
ast_json_unref(json);
|
||||
}
|
||||
|
||||
if (!new_snapshot && old_snapshot) {
|
||||
unsubscribe(app, "bridge", old_snapshot->uniqueid, 1);
|
||||
if (!update->new_snapshot && update->old_snapshot) {
|
||||
unsubscribe(app, "bridge", update->old_snapshot->uniqueid, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -961,7 +944,7 @@ struct stasis_app *app_create(const char *name, stasis_app_cb handler, void *dat
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res |= stasis_message_router_add_cache_update(app->router,
|
||||
res |= stasis_message_router_add(app->router,
|
||||
ast_bridge_snapshot_type(), sub_bridge_update_handler, app);
|
||||
|
||||
res |= stasis_message_router_add(app->router,
|
||||
|
Reference in New Issue
Block a user