summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-07-08 14:26:40 +0000
committerMatthew Jordan <mjordan@digium.com>2013-07-08 14:26:40 +0000
commit30d379851e2d614d1b8bcc65fdb5952feb6d62de (patch)
treeb3b42beaee73c653cc07a38ff1c85a3d9cc87091 /include
parent7fdeb52910cd267ea8837d1246712e1a06812337 (diff)
Create Local channel messages on the Stasis message bus and produce AMI events
This patch does the following: * It adds a virtual table of callbacks to core_unreal. These callbacks can be supplied by concrete implementations of "unreal" channel drivers, which lets the unreal channel driver call specific functionality when it performs some action. Currently, this is done to notify implementations when an optimization operation has begun, and when an optimization operation has succeeded. * It adds Stasis-Core messages for Local channel bridging and Local channel optimization. Local channel optimization is now two events: a Begin and an End. Some consumers of Stasis-Core may want to know when an operation is beginning so that they can 'prepare' their information; others will be more concerned about when the operation has completed, so that they can 'fix up' information. Stasis-Core allows for both, as does AMI. Review: https://reviewboard.asterisk.org/r/2552 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393801 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/bridging.h6
-rw-r--r--include/asterisk/core_local.h39
-rw-r--r--include/asterisk/core_unreal.h36
3 files changed, 75 insertions, 6 deletions
diff --git a/include/asterisk/bridging.h b/include/asterisk/bridging.h
index e03bfd0cd..08d0023e5 100644
--- a/include/asterisk/bridging.h
+++ b/include/asterisk/bridging.h
@@ -870,19 +870,23 @@ int ast_bridge_suspend(struct ast_bridge *bridge, struct ast_channel *chan);
*/
int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
+struct ast_unreal_pvt;
+
/*!
* \brief Check and optimize out the unreal channels between bridges.
* \since 12.0.0
*
* \param chan Unreal channel writing a frame into the channel driver.
* \param peer Other unreal channel in the pair.
+ * \param pvt Private data provided by an implementation of the unreal driver that
+ * contains the callbacks that should be called when optimization begins/ends
*
* \note It is assumed that chan is already locked.
*
* \retval 0 if unreal channels were not optimized out.
* \retval non-zero if unreal channels were optimized out.
*/
-int ast_bridge_unreal_optimized_out(struct ast_channel *chan, struct ast_channel *peer);
+int ast_bridge_unreal_optimize_out(struct ast_channel *chan, struct ast_channel *peer, struct ast_unreal_pvt *pvt);
/*!
* \brief Tells, if optimization is allowed, how the optimization would be performed
diff --git a/include/asterisk/core_local.h b/include/asterisk/core_local.h
index 693c93b46..491112d2b 100644
--- a/include/asterisk/core_local.h
+++ b/include/asterisk/core_local.h
@@ -37,6 +37,7 @@ extern "C" {
struct ast_channel;
struct ast_bridge;
struct ast_bridge_features;
+struct stasis_message_type;
/* ------------------------------------------------------------------- */
@@ -91,6 +92,44 @@ int ast_local_setup_masquerade(struct ast_channel *ast, struct ast_channel *masq
/* ------------------------------------------------------------------- */
+/*!
+ * \brief Message type for when two local channel halves are bridged together
+ * \since 12.0.0
+ *
+ * \note Payloads for the \ref ast_local_bridge_type are a \ref ast_multi_channel_blob.
+ * Roles for the channels in the \ref ast_multi_channel_blob are "1" and "2", reflecting
+ * the two halves. Unlike most other bridges, the 'bridge' between two local channels is
+ * not part of the bridge framework; as such, the message simply references the two local
+ * channel halves that are now bridged.
+ *
+ * \retval A \ref stasis message type
+ */
+struct stasis_message_type *ast_local_bridge_type(void);
+
+/*!
+ * \brief Message type for when a local channel optimization begins
+ * \since 12.0.0
+ *
+ * \note Payloads for the \ref ast_local_optimization_begin_type are a
+ * \ref ast_multi_channel_blob. Roles for the channels in the \ref ast_multi_channel_blob
+ * are "1" and "2", reflecting the two halves.
+ *
+ * \retval A \ref stasis message type
+ */
+struct stasis_message_type *ast_local_optimization_begin_type(void);
+
+/*!
+ * \brief Message type for when a local channel optimization completes
+ * \since 12.0.0
+ *
+ * \note Payloads for the \ref ast_local_optimization_end_type are a
+ * \ref ast_multi_channel_blob. Roles for the channels in the \ref ast_multi_channel_blob
+ * are "1" and "2", reflecting the two halves.
+ *
+ * \retval A \ref stasis message type
+ */
+struct stasis_message_type *ast_local_optimization_end_type(void);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
diff --git a/include/asterisk/core_unreal.h b/include/asterisk/core_unreal.h
index 7cb68f162..a6e98895a 100644
--- a/include/asterisk/core_unreal.h
+++ b/include/asterisk/core_unreal.h
@@ -43,6 +43,30 @@ struct ast_callid;
/* ------------------------------------------------------------------- */
+struct ast_unreal_pvt;
+
+/*!
+ * \brief Callbacks that can be provided by concrete implementations of the unreal
+ * channel driver that will be called when events occur in the unreal layer
+ */
+struct ast_unreal_pvt_callbacks {
+ /*!
+ * \brief Called when an optimization attempt has started
+ * \note p is locked when this callback is called
+ * \param p The \ref ast_unreal_pvt object
+ */
+ void (* const optimization_started)(struct ast_unreal_pvt *p);
+
+ /*!
+ * \brief Called when an optimization attempt completed successfully
+ * \note p is locked when this callback is called
+ * \param p The \ref ast_unreal_pvt object
+ * \param success Non-zero if the optimization succeeded, zero if the optimization
+ * met with fatal and permanent error
+ */
+ void (* const optimization_finished)(struct ast_unreal_pvt *p);
+};
+
/*!
* \brief The base pvt structure for local channel derivatives.
*
@@ -51,11 +75,12 @@ struct ast_callid;
* ast_chan owner -> ast_unreal_pvt -> ast_chan chan
*/
struct ast_unreal_pvt {
- struct ast_channel *owner; /*!< Master Channel - ;1 side */
- struct ast_channel *chan; /*!< Outbound channel - ;2 side */
- struct ast_format_cap *reqcap; /*!< Requested format capabilities */
- struct ast_jb_conf jb_conf; /*!< jitterbuffer configuration */
- unsigned int flags; /*!< Private option flags */
+ struct ast_unreal_pvt_callbacks *callbacks; /*!< Event callbacks */
+ struct ast_channel *owner; /*!< Master Channel - ;1 side */
+ struct ast_channel *chan; /*!< Outbound channel - ;2 side */
+ struct ast_format_cap *reqcap; /*!< Requested format capabilities */
+ struct ast_jb_conf jb_conf; /*!< jitterbuffer configuration */
+ unsigned int flags; /*!< Private option flags */
/*! Base name of the unreal channels. exten@context or other name. */
char name[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2];
};
@@ -65,6 +90,7 @@ struct ast_unreal_pvt {
#define AST_UNREAL_CARETAKER_THREAD (1 << 0) /*!< The ;2 side launched a PBX, was pushed into a bridge, or was masqueraded into an application. */
#define AST_UNREAL_NO_OPTIMIZATION (1 << 1) /*!< Do not optimize out the unreal channels */
#define AST_UNREAL_MOH_INTERCEPT (1 << 2) /*!< Intercept and act on hold/unhold control frames */
+#define AST_UNREAL_OPTIMIZE_BEGUN (1 << 3) /*!< Indicates that an optimization attempt has been started */
/*!
* \brief Send an unreal pvt in with no locks held and get all locks