aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-04-21 18:11:40 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-04-21 18:11:40 +0000
commitc7b7b920afe4afccb39c7ea3c8d0bd4e56ad41f9 (patch)
tree3be8de1bbbce5eb12a63028caa39167d69b54e96 /include
parentc064284e6c7e022570158f7ac3f1b522e411007a (diff)
New HD ConfBridge conferencing application.
Includes a new highly optimized and customizable ConfBridge application capable of mixing audio at sample rates ranging from 8khz-192khz. Review: https://reviewboard.asterisk.org/r/1147/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@314598 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/bridging.h59
-rw-r--r--include/asterisk/bridging_features.h62
-rw-r--r--include/asterisk/bridging_technology.h15
-rw-r--r--include/asterisk/channel.h4
-rw-r--r--include/asterisk/dsp.h10
5 files changed, 146 insertions, 4 deletions
diff --git a/include/asterisk/bridging.h b/include/asterisk/bridging.h
index 810bc3705..58f61d6fd 100644
--- a/include/asterisk/bridging.h
+++ b/include/asterisk/bridging.h
@@ -63,6 +63,7 @@ extern "C" {
#endif
#include "asterisk/bridging_features.h"
+#include "asterisk/dsp.h"
/*! \brief Capabilities for a bridge technology */
enum ast_bridge_capability {
@@ -96,6 +97,10 @@ enum ast_bridge_channel_state {
AST_BRIDGE_CHANNEL_STATE_FEATURE,
/*! Bridged channel is sending a DTMF stream out */
AST_BRIDGE_CHANNEL_STATE_DTMF,
+ /*! Bridged channel began talking */
+ AST_BRIDGE_CHANNEL_STATE_START_TALKING,
+ /*! Bridged channel has stopped talking */
+ AST_BRIDGE_CHANNEL_STATE_STOP_TALKING,
};
/*! \brief Return values for bridge technology write function */
@@ -112,6 +117,22 @@ struct ast_bridge_technology;
struct ast_bridge;
/*!
+ * \brief Structure specific to bridge technologies capable of
+ * performing talking optimizations.
+ */
+struct ast_bridge_tech_optimizations {
+ /*! The amount of time in ms that talking must be detected before
+ * the dsp determines that talking has occurred */
+ unsigned int talking_threshold;
+ /*! The amount of time in ms that silence must be detected before
+ * the dsp determines that talking has stopped */
+ unsigned int silence_threshold;
+ /*! Whether or not the bridging technology should drop audio
+ * detected as silence from the mix. */
+ unsigned int drop_silence:1;
+};
+
+/*!
* \brief Structure that contains information regarding a channel in a bridge
*/
struct ast_bridge_channel {
@@ -137,6 +158,9 @@ struct ast_bridge_channel {
unsigned int suspended:1;
/*! Features structure for features that are specific to this channel */
struct ast_bridge_features *features;
+ /*! Technology optimization parameters used by bridging technologies capable of
+ * optimizing based upon talk detection. */
+ struct ast_bridge_tech_optimizations tech_args;
/*! Queue of DTMF digits used for DTMF streaming */
char dtmf_stream_q[8];
/*! Linked list information */
@@ -149,6 +173,13 @@ struct ast_bridge_channel {
struct ast_bridge {
/*! Number of channels participating in the bridge */
int num;
+ /*! The internal sample rate this bridge is mixed at when multiple channels are being mixed.
+ * If this value is 0, the bridge technology may auto adjust the internal mixing rate. */
+ unsigned int internal_sample_rate;
+ /*! The mixing interval indicates how quickly the bridges internal mixing should occur
+ * for bridge technologies that mix audio. When set to 0, the bridge tech must choose a
+ * default interval for itself. */
+ unsigned int internal_mixing_interval;
/*! Bit to indicate that the bridge thread is waiting on channels in the bridge array */
unsigned int waiting:1;
/*! Bit to indicate the bridge thread should stop */
@@ -236,6 +267,7 @@ int ast_bridge_destroy(struct ast_bridge *bridge);
* \param chan Channel to join
* \param swap Channel to swap out if swapping
* \param features Bridge features structure
+ * \param (Optional) Bridging tech optimization parameters for this channel.
*
* \retval state that channel exited the bridge with
*
@@ -256,7 +288,11 @@ int ast_bridge_destroy(struct ast_bridge *bridge);
* If channel specific features are enabled a pointer to the features structure
* can be specified in the features parameter.
*/
-enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features);
+enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge,
+ struct ast_channel *chan,
+ struct ast_channel *swap,
+ struct ast_bridge_features *features,
+ struct ast_bridge_tech_optimizations *tech_args);
/*! \brief Impart (non-blocking) a channel on a bridge
*
@@ -419,6 +455,27 @@ int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
*/
void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
+/*! \brief Adjust the internal mixing sample rate of a bridge used during
+ * multimix mode.
+ *
+ * \param bridge_channel Channel to change the sample rate on.
+ * \param sample rate, the sample rate to change to. If a
+ * value of 0 is passed here, the bridge will be free to pick
+ * what ever sample rate it chooses.
+ *
+ */
+void ast_bridge_set_internal_sample_rate(struct ast_bridge *bridge, unsigned int sample_rate);
+
+/*! \brief Adjust the internal mixing interval of a bridge used during
+ * multimix mode.
+ *
+ * \param bridge_channel Channel to change the sample rate on.
+ * \param mixing_interval, the sample rate to change to. If 0 is set
+ * the bridge tech is free to choose any mixing interval it uses by default.
+ */
+void ast_bridge_set_mixing_interval(struct ast_bridge *bridge, unsigned int mixing_interval);
+
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
diff --git a/include/asterisk/bridging_features.h b/include/asterisk/bridging_features.h
index ee36a561c..e377ca6b4 100644
--- a/include/asterisk/bridging_features.h
+++ b/include/asterisk/bridging_features.h
@@ -64,6 +64,31 @@ struct ast_bridge_channel;
typedef int (*ast_bridge_features_hook_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt);
/*!
+ * \brief Features hook pvt destructor callback
+ *
+ * \param hook_pvt Private data passed in when the hook was create to destroy
+ */
+typedef void (*ast_bridge_features_hook_pvt_destructor)(void *hook_pvt);
+
+/*!
+ * \brief Talking indicator callback
+ *
+ * \details This callback can be registered with the bridge in order
+ * to receive updates on when a bridge_channel has started and stopped
+ * talking
+ *
+ * \param bridge The bridge that the channel is part of
+ * \param bridge_channel Channel executing the feature
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+typedef void (*ast_bridge_talking_indicate_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *pvt_data);
+
+
+typedef void (*ast_bridge_talking_indicate_destructor)(void *pvt_data);
+
+/*!
* \brief Maximum length of a DTMF feature string
*/
#define MAXIMUM_DTMF_FEATURE_STRING 8
@@ -76,6 +101,8 @@ struct ast_bridge_features_hook {
char dtmf[MAXIMUM_DTMF_FEATURE_STRING];
/*! Callback that is called when DTMF string is matched */
ast_bridge_features_hook_callback callback;
+ /*! Callback to destroy hook_pvt data right before destruction. */
+ ast_bridge_features_hook_pvt_destructor destructor;
/*! Unique data that was passed into us */
void *hook_pvt;
/*! Linked list information */
@@ -88,12 +115,21 @@ struct ast_bridge_features_hook {
struct ast_bridge_features {
/*! Attached DTMF based feature hooks */
AST_LIST_HEAD_NOLOCK(, ast_bridge_features_hook) hooks;
+ /*! Callback to indicate when a bridge channel has started and stopped talking */
+ ast_bridge_talking_indicate_callback talker_cb;
+ /*! Callback to destroy any pvt data stored for the talker. */
+ ast_bridge_talking_indicate_destructor talker_destructor_cb;
+ /*! Talker callback pvt data */
+ void *talker_pvt_data;
/*! Feature flags that are enabled */
struct ast_flags feature_flags;
- /*! Bit to indicate that this structure is useful and should be considered when looking for features */
+ /*! Bit to indicate that the hook list is useful and should be considered when looking for DTMF features */
unsigned int usable:1;
/*! Bit to indicate whether the channel/bridge is muted or not */
unsigned int mute:1;
+ /*! Bit to indicate whether DTMF should be passed into the bridge tech or not. */
+ unsigned int dtmf_passthrough:1;
+
};
/*!
@@ -161,6 +197,7 @@ int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature);
* \param dtmf DTMF string to be activated upon
* \param callback Function to execute upon activation
* \param hook_pvt Unique data
+ * \param Optional destructor callback for hook_pvt data
*
* \retval 0 on success
* \retval -1 on failure
@@ -170,7 +207,7 @@ int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature);
* \code
* struct ast_bridge_features features;
* ast_bridge_features_init(&features);
- * ast_bridge_features_hook(&features, "#", pound_callback, NULL);
+ * ast_bridge_features_hook(&features, "#", pound_callback, NULL, NULL);
* \endcode
*
* This makes the bridging core call pound_callback if a channel that has this
@@ -180,7 +217,26 @@ int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature);
* \note It is important that the callback set the bridge channel state back to
* AST_BRIDGE_CHANNEL_STATE_WAIT or the bridge thread will not service the channel.
*/
-int ast_bridge_features_hook(struct ast_bridge_features *features, const char *dtmf, ast_bridge_features_hook_callback callback, void *hook_pvt);
+int ast_bridge_features_hook(struct ast_bridge_features *features,
+ const char *dtmf,
+ ast_bridge_features_hook_callback callback,
+ void *hook_pvt,
+ ast_bridge_features_hook_pvt_destructor destructor);
+
+/*! \brief Set a callback on the features structure to receive talking notifications on.
+ *
+ * \param features Bridge features structure
+ * \param talker_cb, Callback function to execute when talking events occur in the bridge core.
+ * \param pvt_data Optional unique data that will be passed with the talking events.
+ * \param Optional destructor callback for pvt data.
+ *
+ * \retval 0, success
+ * \retval -1, failure
+ */
+int ast_bridge_features_set_talk_detector(struct ast_bridge_features *features,
+ ast_bridge_talking_indicate_callback talker_cb,
+ ast_bridge_talking_indicate_destructor talker_destructor,
+ void *pvt_data);
/*! \brief Enable a built in feature on a bridge features structure
*
diff --git a/include/asterisk/bridging_technology.h b/include/asterisk/bridging_technology.h
index c3e22975c..3d2e870b6 100644
--- a/include/asterisk/bridging_technology.h
+++ b/include/asterisk/bridging_technology.h
@@ -143,6 +143,21 @@ int ast_bridge_technology_unregister(struct ast_bridge_technology *technology);
*/
void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd);
+/*! \brief Lets the bridging indicate when a bridge channel has stopped or started talking.
+ *
+ * \note All DSP functionality on the bridge has been pushed down to the lowest possible
+ * layer, which in this case is the specific bridging technology being used. Since it
+ * is necessary for the knowledge of which channels are talking to make its way up to the
+ * application, this function has been created to allow the bridging technology to communicate
+ * that information with the bridging core.
+ *
+ * \param bridge The bridge that the channel is a part of.
+ * \param bridge_channel The bridge channel that has either started or stopped talking.
+ * \param started_talking, set to 1 when this indicates the channel has started talking, set to 0
+ * when this indicates the channel has stopped talking.
+ */
+void ast_bridge_notify_talking(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int started_talking);
+
/*! \brief Suspend a bridge technology from consideration
*
* \param technology The bridge technology to suspend
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 88e9db4bb..46039ac85 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -178,6 +178,7 @@ typedef unsigned long long ast_group_t;
*/
struct ast_generator {
void *(*alloc)(struct ast_channel *chan, void *params);
+ /*! Channel is locked during this function callback. */
void (*release)(struct ast_channel *chan, void *data);
/*! This function gets called with the channel unlocked, but is called in
* the context of the channel thread so we know the channel is not going
@@ -186,6 +187,9 @@ struct ast_generator {
int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
/*! This gets called when DTMF_END frames are read from the channel */
void (*digit)(struct ast_channel *chan, char digit);
+ /*! This gets called when the write format on a channel is changed while
+ * generating. The channel is locked during this callback. */
+ void (*write_format_change)(struct ast_channel *chan, void *data);
};
/*! Party name character set enumeration values (values from Q.SIG) */
diff --git a/include/asterisk/dsp.h b/include/asterisk/dsp.h
index 10ada9955..79e4da695 100644
--- a/include/asterisk/dsp.h
+++ b/include/asterisk/dsp.h
@@ -73,9 +73,19 @@ enum threshold {
THRESHOLD_MAX = 1,
};
+/*! \brief Allocates a new dsp with a specific internal sample rate used
+ * during processing. */
+struct ast_dsp *ast_dsp_new_with_rate(unsigned int sample_rate);
+
+/*! \brief Allocates a new dsp, assumes 8khz for internal sample rate */
struct ast_dsp *ast_dsp_new(void);
+
void ast_dsp_free(struct ast_dsp *dsp);
+/*! \brief Retrieve the sample rate this DSP structure was
+ * created with */
+unsigned int ast_dsp_get_sample_rate(const struct ast_dsp *dsp);
+
/*! \brief Set threshold value for silence */
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold);