[asterisk-commits] kmoore: branch kmoore/microfilm r396942 - in /team/kmoore/microfilm: include/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 19 17:16:50 CDT 2013
Author: kmoore
Date: Mon Aug 19 17:16:48 2013
New Revision: 396942
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396942
Log:
It compiles
Modified:
team/kmoore/microfilm/include/asterisk/cel.h
team/kmoore/microfilm/main/cel.c
team/kmoore/microfilm/tests/test_cel.c
Modified: team/kmoore/microfilm/include/asterisk/cel.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/include/asterisk/cel.h?view=diff&rev=396942&r1=396941&r2=396942
==============================================================================
--- team/kmoore/microfilm/include/asterisk/cel.h (original)
+++ team/kmoore/microfilm/include/asterisk/cel.h Mon Aug 19 17:16:48 2013
@@ -55,10 +55,10 @@
AST_CEL_BRIDGE_START = 7,
/*! \brief a bridge is torn down */
AST_CEL_BRIDGE_END = 8,
- /*! \brief a conference is started */
- AST_CEL_CONF_START = 9,
- /*! \brief a conference is ended */
- AST_CEL_CONF_END = 10,
+ /*! \brief channel enters a bridge */
+ AST_CEL_BRIDGE_ENTER = 9,
+ /*! \brief channel exits a bridge */
+ AST_CEL_BRIDGE_EXIT = 10,
/*! \brief a channel is parked */
AST_CEL_PARK_START = 11,
/*! \brief channel out of the park */
@@ -67,28 +67,16 @@
AST_CEL_BLINDTRANSFER = 13,
/*! \brief a transfer occurs */
AST_CEL_ATTENDEDTRANSFER = 14,
- /*! \brief a 3-way conference, usually part of a transfer */
- AST_CEL_HOOKFLASH = 16,
- /*! \brief a 3-way conference, usually part of a transfer */
- AST_CEL_3WAY_START = 17,
- /*! \brief a 3-way conference, usually part of a transfer */
- AST_CEL_3WAY_END = 18,
- /*! \brief channel enters a conference */
- AST_CEL_CONF_ENTER = 19,
- /*! \brief channel exits a conference */
- AST_CEL_CONF_EXIT = 20,
/*! \brief a user-defined event, the event name field should be set */
- AST_CEL_USER_DEFINED = 21,
+ AST_CEL_USER_DEFINED = 15,
/*! \brief the last channel with the given linkedid is retired */
- AST_CEL_LINKEDID_END = 22,
+ AST_CEL_LINKEDID_END = 16,
/*! \brief a directed pickup was performed on this channel */
- AST_CEL_PICKUP = 24,
+ AST_CEL_PICKUP = 17,
/*! \brief this call was forwarded somewhere else */
- AST_CEL_FORWARD = 25,
- /*! \brief a bridge turned into a conference and will be treated as such until it is torn down */
- AST_CEL_BRIDGE_TO_CONF = 26,
+ AST_CEL_FORWARD = 18,
/*! \brief A local channel optimization occurred */
- AST_CEL_LOCAL_OPTIMIZE = 27,
+ AST_CEL_LOCAL_OPTIMIZE = 19,
};
/*!
Modified: team/kmoore/microfilm/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/main/cel.c?view=diff&rev=396942&r1=396941&r2=396942
==============================================================================
--- team/kmoore/microfilm/main/cel.c (original)
+++ team/kmoore/microfilm/main/cel.c Mon Aug 19 17:16:48 2013
@@ -98,21 +98,15 @@
<enum name="APP_END"/>
<enum name="BRIDGE_START"/>
<enum name="BRIDGE_END"/>
- <enum name="BRIDGE_TO_CONF"/>
- <enum name="CONF_START"/>
- <enum name="CONF_END"/>
<enum name="PARK_START"/>
<enum name="PARK_END"/>
<enum name="USER_DEFINED"/>
- <enum name="CONF_ENTER"/>
- <enum name="CONF_EXIT"/>
+ <enum name="BRIDGE_ENTER"/>
+ <enum name="BRIDGE_EXIT"/>
<enum name="BLINDTRANSFER"/>
<enum name="ATTENDEDTRANSFER"/>
<enum name="PICKUP"/>
<enum name="FORWARD"/>
- <enum name="3WAY_START"/>
- <enum name="3WAY_END"/>
- <enum name="HOOKFLASH"/>
<enum name="LINKEDID_END"/>
<enum name="LOCAL_OPTIMIZE"/>
</enumlist>
@@ -143,12 +137,6 @@
/*! Subscription for forwarding the CEL-specific topic */
static struct stasis_subscription *cel_cel_forwarder;
-
-/*! Container for primary channel/bridge ID listing for 2 party bridges */
-static struct ao2_container *bridge_primaries;
-
-/*! The number of buckets into which bridge primary structs will be hashed */
-#define BRIDGE_PRIMARY_BUCKETS 251
struct stasis_message_type *cel_generic_type(void);
STASIS_MESSAGE_TYPE_DEFN(cel_generic_type);
@@ -310,21 +298,15 @@
[AST_CEL_APP_END] = "APP_END",
[AST_CEL_BRIDGE_START] = "BRIDGE_START",
[AST_CEL_BRIDGE_END] = "BRIDGE_END",
- [AST_CEL_BRIDGE_TO_CONF] = "BRIDGE_TO_CONF",
- [AST_CEL_CONF_START] = "CONF_START",
- [AST_CEL_CONF_END] = "CONF_END",
[AST_CEL_PARK_START] = "PARK_START",
[AST_CEL_PARK_END] = "PARK_END",
[AST_CEL_USER_DEFINED] = "USER_DEFINED",
- [AST_CEL_CONF_ENTER] = "CONF_ENTER",
- [AST_CEL_CONF_EXIT] = "CONF_EXIT",
+ [AST_CEL_BRIDGE_ENTER] = "BRIDGE_ENTER",
+ [AST_CEL_BRIDGE_EXIT] = "BRIDGE_EXIT",
[AST_CEL_BLINDTRANSFER] = "BLINDTRANSFER",
[AST_CEL_ATTENDEDTRANSFER] = "ATTENDEDTRANSFER",
[AST_CEL_PICKUP] = "PICKUP",
[AST_CEL_FORWARD] = "FORWARD",
- [AST_CEL_3WAY_START] = "3WAY_START",
- [AST_CEL_3WAY_END] = "3WAY_END",
- [AST_CEL_HOOKFLASH] = "HOOKFLASH",
[AST_CEL_LINKEDID_END] = "LINKEDID_END",
[AST_CEL_LOCAL_OPTIMIZE] = "LOCAL_OPTIMIZE",
};
@@ -378,80 +360,6 @@
}
return !strcmp(backend1_id, backend2_id) ? CMP_MATCH | CMP_STOP : 0;
-}
-
-struct bridge_assoc {
- AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(bridge_id); /*!< UniqueID of the bridge */
- AST_STRING_FIELD(secondary_name); /*!< UniqueID of the secondary/dialed channel */
- );
- struct ast_channel_snapshot *primary_snapshot; /*!< The snapshot for the initiating channel in the bridge */
- int track_as_conf; /*!< Whether this bridge will be treated like a conference in CEL terms */
-};
-
-static void bridge_assoc_dtor(void *obj)
-{
- struct bridge_assoc *assoc = obj;
- ast_string_field_free_memory(assoc);
- ao2_cleanup(assoc->primary_snapshot);
- assoc->primary_snapshot = NULL;
-}
-
-static struct bridge_assoc *bridge_assoc_alloc(struct ast_channel_snapshot *primary, const char *bridge_id, const char *secondary_name)
-{
- RAII_VAR(struct bridge_assoc *, assoc, ao2_alloc(sizeof(*assoc), bridge_assoc_dtor), ao2_cleanup);
- if (!primary || !assoc || ast_string_field_init(assoc, 64)) {
- return NULL;
- }
-
- ast_string_field_set(assoc, bridge_id, bridge_id);
- ast_string_field_set(assoc, secondary_name, secondary_name);
-
- assoc->primary_snapshot = primary;
- ao2_ref(primary, +1);
-
- ao2_ref(assoc, +1);
- return assoc;
-}
-
-static int add_bridge_primary(struct ast_channel_snapshot *primary, const char *bridge_id, const char *secondary_name)
-{
- RAII_VAR(struct bridge_assoc *, assoc, bridge_assoc_alloc(primary, bridge_id, secondary_name), ao2_cleanup);
- if (!assoc) {
- return -1;
- }
-
- ao2_link(bridge_primaries, assoc);
- return 0;
-}
-
-static void remove_bridge_primary(const char *channel_id)
-{
- ao2_find(bridge_primaries, channel_id, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK | OBJ_KEY);
-}
-
-/*! \brief Hashing function for bridge_assoc */
-static int bridge_assoc_hash(const void *obj, int flags)
-{
- const struct bridge_assoc *assoc = obj;
- const char *uniqueid = obj;
- if (!(flags & OBJ_KEY)) {
- uniqueid = assoc->primary_snapshot->uniqueid;
- }
-
- return ast_str_hash(uniqueid);
-}
-
-/*! \brief Comparator function for bridge_assoc */
-static int bridge_assoc_cmp(void *obj, void *arg, int flags)
-{
- struct bridge_assoc *assoc1 = obj, *assoc2 = arg;
- const char *assoc2_id = arg, *assoc1_id = assoc1->primary_snapshot->uniqueid;
- if (!(flags & OBJ_KEY)) {
- assoc2_id = assoc2->primary_snapshot->uniqueid;
- }
-
- return !strcmp(assoc1_id, assoc2_id) ? CMP_MATCH | CMP_STOP : 0;
}
static const char *get_caller_uniqueid(struct ast_multi_channel_blob *blob)
@@ -733,7 +641,6 @@
struct ast_event *ev;
char *linkedid = ast_strdupa(snapshot->linkedid);
const char *peer_name = peer2_name;
- RAII_VAR(struct bridge_assoc *, assoc, NULL, ao2_cleanup);
RAII_VAR(struct cel_config *, cfg, ao2_global_obj_ref(cel_configs), ao2_cleanup);
if (!cfg || !cfg->general) {
@@ -742,13 +649,6 @@
if (!cfg->general->enable) {
return 0;
- }
-
- if (ast_strlen_zero(peer_name)) {
- assoc = ao2_find(bridge_primaries, snapshot->uniqueid, OBJ_KEY);
- if (assoc) {
- peer_name = assoc->secondary_name;
- }
}
/* Record the linkedid of new channels if we are tracking LINKEDID_END even if we aren't
@@ -1119,46 +1019,6 @@
cel_channel_linkedid_change,
};
-static void update_bridge_primary(struct ast_channel_snapshot *snapshot)
-{
- RAII_VAR(struct bridge_assoc *, assoc, NULL, ao2_cleanup);
-
- if (!snapshot) {
- return;
- }
-
- assoc = ao2_find(bridge_primaries, snapshot->uniqueid, OBJ_KEY);
- if (!assoc) {
- return;
- }
-
- ao2_cleanup(assoc->primary_snapshot);
- ao2_ref(snapshot, +1);
- assoc->primary_snapshot = snapshot;
-}
-
-static int bridge_match_cb(void *obj, void *arg, int flags)
-{
- struct bridge_assoc *assoc = obj;
- char *bridge_id = arg;
- if (!strcmp(bridge_id, assoc->bridge_id)) {
- return CMP_MATCH;
- }
- return 0;
-}
-
-static struct bridge_assoc *find_bridge_primary_by_bridge_id(const char *bridge_id)
-{
- char *dup_id = ast_strdupa(bridge_id);
- return ao2_callback(bridge_primaries, 0, bridge_match_cb, dup_id);
-}
-
-static void clear_bridge_primary(const char *bridge_id)
-{
- char *dup_id = ast_strdupa(bridge_id);
- ao2_callback(bridge_primaries, OBJ_KEY | OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, bridge_match_cb, dup_id);
-}
-
static int cel_filter_channel_snapshot(struct ast_channel_snapshot *snapshot)
{
if (!snapshot) {
@@ -1184,8 +1044,6 @@
return;
}
- update_bridge_primary(new_snapshot);
-
for (i = 0; i < ARRAY_LEN(cel_channel_monitors); ++i) {
cel_channel_monitors[i](old_snapshot, new_snapshot);
}
@@ -1201,7 +1059,6 @@
}
if (!new_snapshot) {
- clear_bridge_primary(old_snapshot->uniqueid);
return;
}
}
@@ -1215,79 +1072,18 @@
struct ast_bridge_blob *blob = stasis_message_data(message);
struct ast_bridge_snapshot *snapshot = blob->bridge;
struct ast_channel_snapshot *chan_snapshot = blob->channel;
- RAII_VAR(struct bridge_assoc *, assoc, find_bridge_primary_by_bridge_id(snapshot->uniqueid), ao2_cleanup);
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
if (cel_filter_channel_snapshot(chan_snapshot)) {
return;
}
- if (snapshot->capabilities & (AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE)) {
- if (assoc && assoc->track_as_conf) {
- RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
- extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
- if (extra) {
- cel_report_event(chan_snapshot, AST_CEL_CONF_ENTER, NULL, extra, NULL);
- }
- return;
- }
-
- if (ao2_container_count(snapshot->channels) == 2) {
- struct ao2_iterator i;
- RAII_VAR(char *, channel_id, NULL, ao2_cleanup);
- RAII_VAR(struct ast_channel_snapshot *, latest_primary, NULL, ao2_cleanup);
-
- /* get the name of the channel in the container we don't already know the name of */
- i = ao2_iterator_init(snapshot->channels, 0);
- while ((channel_id = ao2_iterator_next(&i))) {
- if (strcmp(channel_id, chan_snapshot->uniqueid)) {
- break;
- }
- ao2_cleanup(channel_id);
- channel_id = NULL;
- }
- ao2_iterator_destroy(&i);
-
- latest_primary = ast_channel_snapshot_get_latest(channel_id);
- if (!latest_primary) {
- return;
- }
-
- add_bridge_primary(latest_primary, snapshot->uniqueid, chan_snapshot->name);
- cel_report_event(latest_primary, AST_CEL_BRIDGE_START, NULL, NULL, chan_snapshot->name);
- } else if (ao2_container_count(snapshot->channels) > 2) {
- if (!assoc) {
- ast_log(LOG_ERROR, "No association found for bridge %s\n", snapshot->uniqueid);
- return;
- }
-
- /* this bridge will no longer be treated like a bridge, so mark the bridge_assoc as such */
- if (!assoc->track_as_conf) {
- RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
- assoc->track_as_conf = 1;
-
- extra = ast_json_pack("{s: s, s: s}",
- "channel_name", chan_snapshot->name,
- "bridge_id", snapshot->uniqueid);
-
- if (extra) {
- cel_report_event(assoc->primary_snapshot, AST_CEL_BRIDGE_TO_CONF, NULL,
- extra, assoc->secondary_name);
- }
-
- ast_string_field_set(assoc, secondary_name, "");
- }
- }
- } else if (snapshot->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) {
- RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
- if (!assoc) {
- add_bridge_primary(chan_snapshot, snapshot->uniqueid, "");
- return;
- }
- extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
- if (extra) {
- cel_report_event(chan_snapshot, AST_CEL_CONF_ENTER, NULL, extra, NULL);
- }
- }
+ extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
+ if (!extra) {
+ return;
+ }
+
+ cel_report_event(chan_snapshot, AST_CEL_BRIDGE_ENTER, NULL, extra, NULL);
}
static void cel_bridge_leave_cb(
@@ -1298,41 +1094,18 @@
struct ast_bridge_blob *blob = stasis_message_data(message);
struct ast_bridge_snapshot *snapshot = blob->bridge;
struct ast_channel_snapshot *chan_snapshot = blob->channel;
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
if (cel_filter_channel_snapshot(chan_snapshot)) {
return;
}
- if (snapshot->capabilities & (AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE)) {
- RAII_VAR(struct bridge_assoc *, assoc,
- find_bridge_primary_by_bridge_id(snapshot->uniqueid),
- ao2_cleanup);
-
- if (!assoc) {
- return;
- }
-
- if (assoc->track_as_conf) {
- RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
- extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
- if (extra) {
- cel_report_event(chan_snapshot, AST_CEL_CONF_EXIT, NULL, extra, NULL);
- }
- return;
- }
-
- if (ao2_container_count(snapshot->channels) == 1) {
- cel_report_event(assoc->primary_snapshot, AST_CEL_BRIDGE_END, NULL, NULL, assoc->secondary_name);
- remove_bridge_primary(assoc->primary_snapshot->uniqueid);
- return;
- }
- } else if (snapshot->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) {
- RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
- extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
- if (extra) {
- cel_report_event(chan_snapshot, AST_CEL_CONF_EXIT, NULL, extra, NULL);
- }
- }
+ extra = ast_json_pack("{s: s}", "bridge_id", snapshot->uniqueid);
+ if (extra) {
+ return;
+ }
+
+ cel_report_event(chan_snapshot, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL);
}
static void cel_parking_cb(
@@ -1570,8 +1343,6 @@
cel_bridge_forwarder = stasis_unsubscribe_and_join(cel_bridge_forwarder);
cel_parking_forwarder = stasis_unsubscribe_and_join(cel_parking_forwarder);
cel_cel_forwarder = stasis_unsubscribe_and_join(cel_cel_forwarder);
- ao2_cleanup(bridge_primaries);
- bridge_primaries = NULL;
ast_cli_unregister(&cli_status);
ao2_cleanup(cel_dialstatus_store);
cel_dialstatus_store = NULL;
@@ -1599,11 +1370,6 @@
return -1;
}
- bridge_primaries = ao2_container_alloc(BRIDGE_PRIMARY_BUCKETS, bridge_assoc_hash, bridge_assoc_cmp);
- if (!bridge_primaries) {
- return -1;
- }
-
cel_backends = ao2_container_alloc(BACKEND_BUCKETS, cel_backend_hash, cel_backend_cmp);
if (!cel_backends) {
return -1;
Modified: team/kmoore/microfilm/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/tests/test_cel.c?view=diff&rev=396942&r1=396941&r2=396942
==============================================================================
--- team/kmoore/microfilm/tests/test_cel.c (original)
+++ team/kmoore/microfilm/tests/test_cel.c Mon Aug 19 17:16:48 2013
@@ -118,30 +118,21 @@
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel, AST_CEL_CONF_EXIT, NULL, extra, NULL); \
+ APPEND_EVENT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL); \
} while (0)
#define CONF_EXIT_SNAPSHOT(channel, bridge) do { \
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT_SNAPSHOT(channel, AST_CEL_CONF_EXIT, NULL, extra, NULL); \
+ APPEND_EVENT_SNAPSHOT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL); \
} while (0)
#define CONF_ENTER_EVENT(channel, bridge) do { \
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel, AST_CEL_CONF_ENTER, NULL, extra, NULL); \
- } while (0)
-
-#define BRIDGE_TO_CONF(first, second, third, bridge) do { \
- RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
- extra = ast_json_pack("{s: s, s: s}", \
- "channel_name", ast_channel_name(third), \
- "bridge_id", bridge->uniqueid); \
- ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(first, AST_CEL_BRIDGE_TO_CONF, NULL, extra, ast_channel_name(second)); \
+ APPEND_EVENT(channel, AST_CEL_BRIDGE_ENTER, NULL, extra, NULL); \
} while (0)
#define BLINDTRANSFER_EVENT(channel, bridge, extension, context) do { \
@@ -1225,7 +1216,6 @@
ast_bridge_transfer_attended(chan_alice, chan_david);
do_sleep();
- BRIDGE_TO_CONF(chan_charlie, chan_david, chan_bob, bridge2);
CONF_EXIT_EVENT(chan_david, bridge2);
ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_david, bridge2);
@@ -1311,7 +1301,6 @@
ast_bridge_transfer_attended(chan_alice, chan_david);
do_sleep();
- BRIDGE_TO_CONF(chan_bob, chan_alice, chan_charlie, bridge1);
CONF_EXIT_EVENT(chan_alice, bridge1);
ATTENDEDTRANSFER_BRIDGE(chan_alice, bridge1, chan_david, bridge2);
@@ -1958,9 +1947,8 @@
cel_test_config->events |= 1<<AST_CEL_HANGUP;
cel_test_config->events |= 1<<AST_CEL_BRIDGE_START;
cel_test_config->events |= 1<<AST_CEL_BRIDGE_END;
- cel_test_config->events |= 1<<AST_CEL_BRIDGE_TO_CONF;
- cel_test_config->events |= 1<<AST_CEL_CONF_ENTER;
- cel_test_config->events |= 1<<AST_CEL_CONF_EXIT;
+ cel_test_config->events |= 1<<AST_CEL_BRIDGE_ENTER;
+ cel_test_config->events |= 1<<AST_CEL_BRIDGE_EXIT;
cel_test_config->events |= 1<<AST_CEL_BLINDTRANSFER;
cel_test_config->events |= 1<<AST_CEL_ATTENDEDTRANSFER;
cel_test_config->events |= 1<<AST_CEL_PICKUP;
More information about the asterisk-commits
mailing list