[svn-commits] kmoore: branch 13 r420796 - in /branches/13: ./ include/asterisk/ res/ res/ar...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Aug 11 13:37:17 CDT 2014
Author: kmoore
Date: Mon Aug 11 13:37:14 2014
New Revision: 420796
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420796
Log:
Stasis: Allow internal channels directly into bridges
The patch to catch channels being shoehorned into Stasis() via external
mechanisms also happens to catch Announcer and Recorder channels
because they aren't known to be stasis-controlled channels in the usual
sense. This marks those channels as Stasis()-internal channels and
allows them directly into bridges.
Review: https://reviewboard.asterisk.org/r/3903/
........
Merged revisions 420795 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
branches/13/ (props changed)
branches/13/include/asterisk/stasis_app.h
branches/13/res/ari/resource_bridges.c
branches/13/res/res_stasis.c
branches/13/res/stasis/stasis_bridge.c
Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: branches/13/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/branches/13/include/asterisk/stasis_app.h?view=diff&rev=420796&r1=420795&r2=420796
==============================================================================
--- branches/13/include/asterisk/stasis_app.h (original)
+++ branches/13/include/asterisk/stasis_app.h Mon Aug 11 13:37:14 2014
@@ -812,6 +812,36 @@
*/
int stasis_app_channel_is_stasis_end_published(struct ast_channel *chan);
+/*!
+ * \brief Is this channel internal to Stasis?
+ *
+ * \param chan The channel to check.
+ *
+ * \retval 0 No
+ * \retval 1 Yes
+ */
+int stasis_app_channel_is_internal(struct ast_channel *chan);
+
+/*!
+ * \brief Mark this unreal channel and it's other half as being internal to Stasis.
+ *
+ * \param chan The channel to mark.
+ *
+ * \retval zero Success
+ * \retval non-zero Failure
+ */
+int stasis_app_channel_unreal_set_internal(struct ast_channel *chan);
+
+/*!
+ * \brief Mark this channel as being internal to Stasis.
+ *
+ * \param chan The channel to mark.
+ *
+ * \retval zero Success
+ * \retval non-zero Failure
+ */
+int stasis_app_channel_set_internal(struct ast_channel *chan);
+
/*! @} */
#endif /* _ASTERISK_STASIS_APP_H */
Modified: branches/13/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/ari/resource_bridges.c?view=diff&rev=420796&r1=420795&r2=420796
==============================================================================
--- branches/13/res/ari/resource_bridges.c (original)
+++ branches/13/res/ari/resource_bridges.c Mon Aug 11 13:37:14 2014
@@ -305,6 +305,7 @@
static struct ast_channel *prepare_bridge_media_channel(const char *type)
{
RAII_VAR(struct ast_format_cap *, cap, NULL, ao2_cleanup);
+ struct ast_channel *chan;
cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (!cap) {
@@ -313,7 +314,16 @@
ast_format_cap_append(cap, ast_format_slin, 0);
- return ast_request(type, cap, NULL, NULL, "ARI", NULL);
+ chan = ast_request(type, cap, NULL, NULL, "ARI", NULL);
+ if (!chan) {
+ return NULL;
+ }
+
+ if (stasis_app_channel_unreal_set_internal(chan)) {
+ ast_channel_cleanup(chan);
+ return NULL;
+ }
+ return chan;
}
/*!
Modified: branches/13/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_stasis.c?view=diff&rev=420796&r1=420795&r2=420796
==============================================================================
--- branches/13/res/res_stasis.c (original)
+++ branches/13/res/res_stasis.c Mon Aug 11 13:37:14 2014
@@ -1901,6 +1901,74 @@
remove_masquerade_store_by_name(snapshot->name);
}
+static const struct ast_datastore_info stasis_internal_channel_info = {
+ .type = "stasis-internal-channel",
+};
+
+static int set_internal_datastore(struct ast_channel *chan)
+{
+ struct ast_datastore *datastore;
+
+ datastore = ast_channel_datastore_find(chan, &stasis_internal_channel_info, NULL);
+ if (!datastore) {
+ datastore = ast_datastore_alloc(&stasis_internal_channel_info, NULL);
+ if (!datastore) {
+ return -1;
+ }
+ ast_channel_datastore_add(chan, datastore);
+ }
+ return 0;
+}
+
+int stasis_app_channel_unreal_set_internal(struct ast_channel *chan)
+{
+ struct ast_channel *outchan = NULL, *outowner = NULL;
+ int res = 0;
+ struct ast_unreal_pvt *unreal_pvt = ast_channel_tech_pvt(chan);
+
+ ao2_ref(unreal_pvt, +1);
+ ast_unreal_lock_all(unreal_pvt, &outowner, &outchan);
+ if (outowner) {
+ res |= set_internal_datastore(outowner);
+ ast_channel_unlock(outowner);
+ ast_channel_unref(outowner);
+ }
+ if (outchan) {
+ res |= set_internal_datastore(outchan);
+ ast_channel_unlock(outchan);
+ ast_channel_unref(outchan);
+ }
+ ao2_unlock(unreal_pvt);
+ ao2_ref(unreal_pvt, -1);
+ return 0;
+}
+
+int stasis_app_channel_set_internal(struct ast_channel *chan)
+{
+ int res;
+
+ ast_channel_lock(chan);
+ res = set_internal_datastore(chan);
+ ast_channel_unlock(chan);
+
+ return res;
+}
+
+int stasis_app_channel_is_internal(struct ast_channel *chan)
+{
+ struct ast_datastore *datastore;
+ int res = 0;
+
+ ast_channel_lock(chan);
+ datastore = ast_channel_datastore_find(chan, &stasis_internal_channel_info, NULL);
+ if (datastore) {
+ res = 1;
+ }
+ ast_channel_unlock(chan);
+
+ return res;
+}
+
static int load_module(void)
{
if (STASIS_MESSAGE_TYPE_INIT(ast_stasis_end_message_type) != 0) {
Modified: branches/13/res/stasis/stasis_bridge.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/res/stasis/stasis_bridge.c?view=diff&rev=420796&r1=420795&r2=420796
==============================================================================
--- branches/13/res/stasis/stasis_bridge.c (original)
+++ branches/13/res/stasis/stasis_bridge.c Mon Aug 11 13:37:14 2014
@@ -117,7 +117,7 @@
{
struct stasis_app_control *control = stasis_app_control_find_by_channel(bridge_channel->chan);
- if (!control) {
+ if (!control && !stasis_app_channel_is_internal(bridge_channel->chan)) {
/* channel not in Stasis(), get it there */
/* Attach after-bridge callback and pass ownership of swap_app to it */
if (ast_bridge_set_after_callback(bridge_channel->chan,
More information about the svn-commits
mailing list