[svn-commits] bmd: branch group/newcdr r118019 - in /team/group/newcdr: include/asterisk/ m...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu May 22 19:01:04 CDT 2008
Author: bmd
Date: Thu May 22 19:01:03 2008
New Revision: 118019
URL: http://svn.digium.com/view/asterisk?view=rev&rev=118019
Log:
added CEL_LINKEDID_END event which emits when a linkedid leaves it's last channel
Modified:
team/group/newcdr/include/asterisk/cel.h
team/group/newcdr/main/cel.c
team/group/newcdr/main/channel.c
Modified: team/group/newcdr/include/asterisk/cel.h
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/include/asterisk/cel.h?view=diff&rev=118019&r1=118018&r2=118019
==============================================================================
--- team/group/newcdr/include/asterisk/cel.h (original)
+++ team/group/newcdr/include/asterisk/cel.h Thu May 22 19:01:03 2008
@@ -82,6 +82,8 @@
CEL_CONF_EXIT = 20,
/*! a user-defined event, the event name field should be set */
CEL_USER_DEFINED = 21,
+ /*! the last channel with the given linkedid is retired */
+ CEL_LINKEDID_END = 22,
};
/* there was in the early stages of design, a concept of struct ast_cel,
@@ -103,6 +105,15 @@
/*! Converts AMA flag to printable string */
char *ast_cel_flags2str(int flag);
+/*! If at least one CEL backend is looking for CEL_LINKEDID_END
+ * events, this function will check if the given channel is the last
+ * active channel with that linkedid, and if it is, emit a
+ * CEL_LINKEDID_END event.
+ *
+ * This should be called whenever a channel is freed or when a
+ * channel's linkedid is changed
+ */
+void ast_cel_check_retire_linkedid(const struct ast_channel *chan);
int ast_cel_setaccount(struct ast_channel *chan, const char *account);
Modified: team/group/newcdr/main/cel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=118019&r1=118018&r2=118019
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Thu May 22 19:01:03 2008
@@ -58,7 +58,6 @@
{
return cel_enabled;
}
-
static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
@@ -362,6 +361,8 @@
return "EV_3WAY_END";
case CEL_HOOKFLASH:
return "EV_HOOKFLASH";
+ case CEL_LINKEDID_END:
+ return "EV_LINKEDID_END";
}
return "";
}
@@ -378,6 +379,32 @@
return "DOCUMENTATION";
}
return "Unknown";
+}
+
+void ast_cel_check_retire_linkedid(const struct ast_channel *chan)
+{
+ int found=0;
+ struct ast_channel *tmp = NULL;
+ const char *linkedid = chan->linkedid;
+
+ /* make sure we need to do all this work */
+ if (!ast_strlen_zero(linkedid) && (eventset & CEL_LINKEDID_END)) {
+
+ while ((tmp = ast_channel_walk_locked(tmp))) {
+
+ if (tmp != chan && tmp->linkedid && 0==strcmp(linkedid, tmp->linkedid)) {
+ found=1;
+ ast_channel_unlock(tmp);
+ break;
+ }
+
+ ast_channel_unlock(tmp);
+ }
+
+ if (!found) {
+ ast_cel_report_event(chan, CEL_LINKEDID_END, NULL, NULL);
+ }
+ }
}
int ast_cel_setaccount(struct ast_channel *chan, const char *account)
Modified: team/group/newcdr/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/newcdr/main/channel.c?view=diff&rev=118019&r1=118018&r2=118019
==============================================================================
--- team/group/newcdr/main/channel.c (original)
+++ team/group/newcdr/main/channel.c Thu May 22 19:01:03 2008
@@ -1307,6 +1307,7 @@
headp=&chan->varshead;
ast_cel_report_event(chan, CEL_CHANNEL_END, NULL, NULL);
+ ast_cel_check_retire_linkedid(chan);
AST_RWLIST_WRLOCK(&channels);
if (!AST_RWLIST_REMOVE(&channels, chan, chan_list)) {
@@ -3881,9 +3882,21 @@
}
}
+/*! Set the channel's linkedid to the given string, and also check to
+ * see if the channel's old linkedid is now being retired */
+static void ast_channel_change_linkedid(struct ast_channel *chan, const char *linkedid)
+{
+ /* if the linkedid for this channel is being changed from something, check... */
+ if (!ast_strlen_zero(chan->linkedid) && 0 != strcmp(chan->linkedid, linkedid)) {
+ ast_cel_check_retire_linkedid(chan);
+ }
+
+ ast_string_field_set(chan, linkedid, linkedid);
+}
+
/*!
- \brief Propagate the linked id from one channel to the other
+ \brief Propagate the oldest linkedid between associated channels
*/
void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *peer)
@@ -3912,18 +3925,18 @@
/* just in case setting a stringfield to itself causes problems */
linkedid = ast_strdupa(linkedid);
- ast_string_field_set(chan, linkedid, linkedid);
- ast_string_field_set(peer, linkedid, linkedid);
+ ast_channel_change_linkedid(chan, linkedid);
+ ast_channel_change_linkedid(peer, linkedid);
if (chan->_bridge) {
bridged = ast_bridged_channel(chan);
if (bridged != peer) {
- ast_string_field_set(bridged, linkedid, linkedid);
+ ast_channel_change_linkedid(bridged, linkedid);
}
}
if (peer->_bridge) {
bridged = ast_bridged_channel(peer);
if (bridged != chan) {
- ast_string_field_set(bridged, linkedid, linkedid);
+ ast_channel_change_linkedid(bridged, linkedid);
}
}
}
More information about the svn-commits
mailing list