unsigned int seqno;
};
+enum ast_bridge_hook_remove_flags {
+ /*! The hook is removed when the channel is pulled from the bridge. */
+ AST_BRIDGE_HOOK_REMOVE_ON_PULL,
+};
+
/* BUGBUG Need to be able to selectively remove DTMF, hangup, and interval hooks. */
/*! \brief Structure that is the essence of a feature hook. */
struct ast_bridge_hook {
ast_bridge_hook_pvt_destructor destructor;
/*! Unique data that was passed into us */
void *hook_pvt;
- /*! TRUE if the hook is removed when the channel is pulled from the bridge. */
- unsigned int remove_on_pull:1;
+ /*! Flags determining when hooks should be removed from a bridge channel */
+ struct ast_flags remove_flags;
/*! Extra hook parameters. */
union {
/*! Extra parameters for a DTMF feature hook. */
static void cleanup_video_mode(struct ast_bridge *bridge);
static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
-static void bridge_features_remove_on_pull(struct ast_bridge_features *features);
+static void bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags);
/*! Default DTMF keys for built in features */
static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][MAXIMUM_DTMF_FEATURE_STRING];
*/
static void bridge_base_pull(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
{
- bridge_features_remove_on_pull(bridge_channel->features);
+ bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
}
/*!
hook->callback = callback;
hook->destructor = destructor;
hook->hook_pvt = hook_pvt;
- hook->remove_on_pull = remove_on_pull;
+ ast_set_flag(&hook->remove_flags, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
}
return hook;
* \since 12.0.0
*
* \param obj Feature hook object.
- * \param arg Not used
- * \param flags Not used
+ * \param arg Removal flags
+ * \param unused Not used
*
- * \retval CMP_MATCH if hook has remove_on_pull set.
+ * \retval CMP_MATCH if hook's remove_flags match the removal flags set.
* \retval 0 if not match.
*/
-static int hook_remove_on_pull_match(void *obj, void *arg, int flags)
+static int hook_remove_match(void *obj, void *arg, int unused)
{
struct ast_bridge_hook *hook = obj;
+ enum ast_bridge_hook_remove_flags *flags = arg;
- if (hook->remove_on_pull) {
+ if (ast_test_flag(&hook->remove_flags, *flags)) {
return CMP_MATCH;
} else {
return 0;
* \since 12.0.0
*
* \param hooks Hooks container to work on.
+ * \param flags Determinator for whether hook is removed
*
* \return Nothing
*/
-static void hooks_remove_on_pull_container(struct ao2_container *hooks)
+static void hooks_remove_container(struct ao2_container *hooks, enum ast_bridge_hook_remove_flags flags)
{
ao2_callback(hooks, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
- hook_remove_on_pull_match, NULL);
+ hook_remove_match, &flags);
}
/*!
* \since 12.0.0
*
* \param hooks Hooks heap to work on.
+ * \param flags Determinator for whether hook is removed
*
* \return Nothing
*/
-static void hooks_remove_on_pull_heap(struct ast_heap *hooks)
+static void hooks_remove_heap(struct ast_heap *hooks, enum ast_bridge_hook_remove_flags flags)
{
struct ast_bridge_hook *hook;
int changed;
changed = 0;
for (idx = ast_heap_size(hooks); idx; --idx) {
hook = ast_heap_peek(hooks, idx);
- if (hook->remove_on_pull) {
+ if (ast_test_flag(&hook->remove_flags, flags)) {
ast_heap_remove(hooks, hook);
ao2_ref(hook, -1);
changed = 1;
* \brief Remove marked bridge channel feature hooks.
* \since 12.0.0
*
- * \param features Bridge featues structure
+ * \param features Bridge features structure
+ * \param flags Determinator for whether hook is removed.
*
* \return Nothing
*/
-static void bridge_features_remove_on_pull(struct ast_bridge_features *features)
+static void bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags)
{
- hooks_remove_on_pull_container(features->dtmf_hooks);
- hooks_remove_on_pull_container(features->hangup_hooks);
- hooks_remove_on_pull_container(features->join_hooks);
- hooks_remove_on_pull_container(features->leave_hooks);
- hooks_remove_on_pull_heap(features->interval_hooks);
+ hooks_remove_container(features->dtmf_hooks, flags);
+ hooks_remove_container(features->hangup_hooks, flags);
+ hooks_remove_container(features->join_hooks, flags);
+ hooks_remove_container(features->leave_hooks, flags);
+ hooks_remove_heap(features->interval_hooks, flags);
}
static int interval_hook_time_cmp(void *a, void *b)