[asterisk-commits] file: branch file/bridging r82123 - in /team/file/bridging: apps/ include/ast...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 10 11:15:47 CDT 2007
Author: file
Date: Mon Sep 10 11:15:47 2007
New Revision: 82123
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82123
Log:
Add a lil' framework for features.
Modified:
team/file/bridging/apps/app_bridgetest.c
team/file/bridging/apps/app_confbridge.c
team/file/bridging/include/asterisk/bridging.h
team/file/bridging/main/bridging.c
Modified: team/file/bridging/apps/app_bridgetest.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/apps/app_bridgetest.c?view=diff&rev=82123&r1=82122&r2=82123
==============================================================================
--- team/file/bridging/apps/app_bridgetest.c (original)
+++ team/file/bridging/apps/app_bridgetest.c Mon Sep 10 11:15:47 2007
@@ -85,16 +85,16 @@
}
/* Create a new bridge to bring the two channels into */
- if (!(bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE))) {
+ if (!(bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE, NULL))) {
ast_log(LOG_WARNING, "Failed to create bridge ;(\n");
ast_dial_destroy(dial);
return -1;
}
/* Put the dialed channel into the bridge via async */
- ast_bridge_impart(bridge, ast_dial_answered(dial));
+ ast_bridge_impart(bridge, ast_dial_answered(dial), NULL);
- ast_bridge_join(bridge, chan);
+ ast_bridge_join(bridge, chan, NULL);
ast_bridge_destroy(bridge);
Modified: team/file/bridging/apps/app_confbridge.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/apps/app_confbridge.c?view=diff&rev=82123&r1=82122&r2=82123
==============================================================================
--- team/file/bridging/apps/app_confbridge.c (original)
+++ team/file/bridging/apps/app_confbridge.c Mon Sep 10 11:15:47 2007
@@ -84,7 +84,7 @@
if (!conference_bridge && dynamic && (conference_bridge = ast_calloc(1, sizeof(*conference_bridge)))) {
conference_bridge->dynamic = 1;
conference_bridge->name = name;
- if (!(conference_bridge->bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_MULTIMIX, 0))) {
+ if (!(conference_bridge->bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_MULTIMIX, 0, NULL))) {
free(conference_bridge);
conference_bridge = NULL;
} else
@@ -131,7 +131,7 @@
}
/* Actually join the bridge */
- ast_bridge_join(conference_bridge->bridge, chan);
+ ast_bridge_join(conference_bridge->bridge, chan, NULL);
/* Drop ourselves from the conference bridge and remove it if needed */
AST_LIST_LOCK(&conference_bridges);
Modified: team/file/bridging/include/asterisk/bridging.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/bridging.h?view=diff&rev=82123&r1=82122&r2=82123
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Mon Sep 10 11:15:47 2007
@@ -66,8 +66,16 @@
AST_BRIDGE_WRITE_UNSUPPORTED, /*! Bridge technology can't write out this frame type */
};
+/*! \brief Built in features */
+enum ast_bridge_builtin_feature {
+ AST_BRIDGE_BUILTIN_BLINDTRANSFER = 0, /*! Blind transfer */
+ AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, /*! Attended transfer */
+ AST_BRIDGE_BUILTIN_END, /*! End terminator, has to be last */
+};
+
struct ast_bridge;
struct ast_bridge_channel;
+struct ast_bridge_features;
struct ast_bridge_technology {
const char *name; /*! Unique name to this bridge technology */
@@ -86,6 +94,10 @@
AST_RWLIST_ENTRY(ast_bridge_technology) list; /*! Linked list information */
};
+struct ast_bridge_features {
+ enum ast_bridge_builtin_feature builtin_features[AST_BRIDGE_BUILTIN_END]; /*! Enabled built in features */
+};
+
struct ast_bridge_channel {
enum ast_bridge_channel_state state; /*! Current bridged channel state */
struct ast_channel *chan; /*! Asterisk channel participating in this bridge */
@@ -96,6 +108,7 @@
int fds[4]; /*! Additional file descriptors to look at */
int suspended:1; /*! Is this bridged channel suspended from the bridge or not? */
int muted:1; /*! Is this bridged channel muted or not? */
+ struct ast_bridge_features *features; /*! Enabled features information */
AST_LIST_ENTRY(ast_bridge_channel) list; /*! Linked list information */
};
@@ -107,6 +120,7 @@
struct ast_bridge_technology *technology; /*! Technology in use on the bridge */
void *bridge_pvt; /*! Private information unique to the bridge technology (not always needed) */
pthread_t thread; /*! Thread running the bridge */
+ struct ast_bridge_features *features; /*! Enabled features information */
AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels; /*! Channels participating in this bridge */
};
@@ -126,7 +140,7 @@
* \param capabilities The capabilities that we require to be used on the bridge
* \return Returns bridge on success, NULL on failure
*/
-struct ast_bridge *ast_bridge_new(int capabilities, int flags);
+struct ast_bridge *ast_bridge_new(int capabilities, int flags, struct ast_bridge_features *features);
/*! \brief Destroy a bridge
* \param bridge Bridge to destroy
@@ -137,16 +151,18 @@
/*! \brief Join a channel to a bridge
* \param bridge Bridge to join
* \param chan Channel to join
+ * \param features Bridge features structure
* \return Returns state that channel exited bridge on
*/
-enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan);
+enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features);
/*! \brief Impart a channel on a bridge
* \param bridge Bridge to impart on
* \param chan Channel to impart
- * \return Returns 0 on success, -1 on failure
- */
-int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan);
+ * \param features Bridge features structure
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features);
/*! \brief Depart a channel from a bridge
* \param bridge Bridge to depart from
@@ -187,6 +203,20 @@
*/
int ast_bridge_swap(struct ast_bridge *bridge, struct ast_channel *chan0, struct ast_channel *chan1);
+/*! \brief Attach a custom hook to a bridge features structure
+ * \param features Bridge features structure
+ * \param dtmf DTMF string to be activated upon
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_bridge_features_hook(struct ast_bridge_features *features, const char *dtmf);
+
+/*! \brief Enable a built in feature on a bridge features structure
+ * \param features Bridge features structure
+ * \param feature Feature to enable
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_bridge_features_enable(struct ast_bridge_features *features, enum ast_bridge_builtin_feature feature);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=82123&r1=82122&r2=82123
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Mon Sep 10 11:15:47 2007
@@ -245,7 +245,7 @@
* \param capabilities The capabilities that we require to be used on the bridge
* \return Returns bridge on success, NULL on failure
*/
-struct ast_bridge *ast_bridge_new(int capabilities, int flags)
+struct ast_bridge *ast_bridge_new(int capabilities, int flags, struct ast_bridge_features *features)
{
struct ast_bridge *bridge = NULL;
struct ast_bridge_technology *bridge_technology = NULL;
@@ -269,6 +269,8 @@
bridge->technology = bridge_technology;
bridge->thread = AST_PTHREADT_NULL;
+
+ bridge->features = features;
ast_set_flag(&bridge->feature_flags, flags);
@@ -386,6 +388,7 @@
if (!(frame = (bridge_channel->muted ? ast_read_noaudio(chan) : ast_read(chan))) || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
/* Switch the bridged channel state to end, no need to signal it's thread... we are it! */
bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_END;
+ } else if ((frame->frametype == AST_FRAME_DTMF_BEGIN || frame->frametype == AST_FRAME_DTMF_END) && bridge_channel->features) {
} else {
/* Write out the frame to the bridge technology */
bridge->technology->write(bridge, bridge_channel, frame);
@@ -547,7 +550,7 @@
* \param chan Channel to join
* \return Returns phase that channel exited bridge on
*/
-enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan)
+enum ast_bridge_channel_state ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features)
{
struct ast_bridge_channel bridge_channel;
enum ast_bridge_channel_state state;
@@ -563,6 +566,7 @@
/* Setup the bridge channel with information about the channel and stuff */
bridge_channel.chan = chan;
bridge_channel.bridge = bridge;
+ bridge_channel.features = features;
/* Now setup our synchronization components */
bridge_channel.thread = pthread_self();
@@ -614,7 +618,7 @@
* \param chan Channel to impart
* \return Returns 0 on success, -1 on failure
*/
-int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan)
+int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features)
{
struct ast_bridge_channel *bridge_channel = NULL;
int i = 0;
@@ -630,6 +634,7 @@
/* Copy over pointers to vital information */
bridge_channel->chan = chan;
bridge_channel->bridge = bridge;
+ bridge_channel->features = features;
/* Setup synchronization for our thread */
ast_cond_init(&bridge_channel->cond, NULL);
@@ -746,3 +751,19 @@
{
return -1;
}
+
+/*! \brief Enable a built in feature on a bridge features structure
+ * \param features Bridge features structure
+ * \param feature Feature to enable
+ * \return Returns 0 on success, -1 on failure
+ */
+int ast_bridge_features_enable(struct ast_bridge_features *features, enum ast_bridge_builtin_feature feature)
+{
+ /* This is relatively easy, built in features are done using an array */
+ if (features->builtin_features[feature])
+ return -1;
+
+ features->builtin_features[feature] = 1;
+
+ return 0;
+}
More information about the asterisk-commits
mailing list