/*! Forward a channel's topics to an app */ static struct app_forwards *forwards_create_channel(struct stasis_app *app, struct ast_channel *chan) { RAII_VAR(struct app_forwards *, forwards, NULL, ao2_cleanup); if (!app || !chan) { return NULL; } forwards = forwards_create(app, ast_channel_uniqueid(chan)); if (!forwards) { return NULL; } forwards->forward_type = FORWARD_CHANNEL; forwards->topic_forward = stasis_forward_all(ast_channel_topic(chan), app->topic); if (!forwards->topic_forward) { return NULL; } forwards->topic_cached_forward = stasis_forward_all( ast_channel_topic_cached(chan), app->topic); if (!forwards->topic_cached_forward) { /* Half-subscribed is a bad thing */ stasis_forward_cancel(forwards->topic_forward); forwards->topic_forward = NULL; return NULL; } ao2_ref(forwards, +1); return forwards; }
/*! Forward a channel's topics to an app */ static struct app_forwards *forwards_create_channel(struct stasis_app *app, struct ast_channel *chan) { struct app_forwards *forwards; if (!app) { return NULL; } forwards = forwards_create(app, chan ? ast_channel_uniqueid(chan) : CHANNEL_ALL); if (!forwards) { return NULL; } forwards->forward_type = FORWARD_CHANNEL; if (chan) { forwards->topic_forward = stasis_forward_all(ast_channel_topic(chan), app->topic); } forwards->topic_cached_forward = stasis_forward_all( chan ? ast_channel_topic_cached(chan) : ast_channel_topic_all_cached(), app->topic); if ((!forwards->topic_forward && chan) || !forwards->topic_cached_forward) { /* Half-subscribed is a bad thing */ forwards_unsubscribe(forwards); ao2_ref(forwards, -1); return NULL; } return forwards; }