[svn-commits] kmoore: branch kmoore/bridge_construction-cel_channels r389042 - in /team/kmo...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 17 22:08:59 CDT 2013


Author: kmoore
Date: Fri May 17 22:08:55 2013
New Revision: 389042

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389042
Log:
svnmerge init, automerge init, and commit work up to this point

Modified:
    team/kmoore/bridge_construction-cel_channels/   (props changed)
    team/kmoore/bridge_construction-cel_channels/include/asterisk/stasis_channels.h
    team/kmoore/bridge_construction-cel_channels/include/asterisk/strings.h
    team/kmoore/bridge_construction-cel_channels/main/cel.c
    team/kmoore/bridge_construction-cel_channels/main/channel.c
    team/kmoore/bridge_construction-cel_channels/main/pbx.c
    team/kmoore/bridge_construction-cel_channels/main/stasis_channels.c

Propchange: team/kmoore/bridge_construction-cel_channels/
------------------------------------------------------------------------------
--- automerge-email (original)
+++ automerge-email Fri May 17 22:08:55 2013
@@ -1,1 +1,1 @@
-rmudgett at digium.com
+kmoore at digium.com

Propchange: team/kmoore/bridge_construction-cel_channels/
            ('automerge-propname' removed)

Propchange: team/kmoore/bridge_construction-cel_channels/
------------------------------------------------------------------------------
    svnmerge-integrated = /team/group/bridge_construction:1-389040

Modified: team/kmoore/bridge_construction-cel_channels/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_channels/include/asterisk/stasis_channels.h?view=diff&rev=389042&r1=389041&r2=389042
==============================================================================
--- team/kmoore/bridge_construction-cel_channels/include/asterisk/stasis_channels.h (original)
+++ team/kmoore/bridge_construction-cel_channels/include/asterisk/stasis_channels.h Fri May 17 22:08:55 2013
@@ -50,8 +50,13 @@
 		AST_STRING_FIELD(data);			/*!< Data passed to current application */
 		AST_STRING_FIELD(context);		/*!< Dialplan: Current extension context */
 		AST_STRING_FIELD(exten);		/*!< Dialplan: Current extension number */
+		AST_STRING_FIELD(bridged_name);		/*!< The name of the channel bridged to this one */
+		AST_STRING_FIELD(bridged_id);		/*!< The uniqueid of the channel bridged to this one */
 		AST_STRING_FIELD(caller_name);		/*!< Caller ID Name */
 		AST_STRING_FIELD(caller_number);	/*!< Caller ID Number */
+		AST_STRING_FIELD(caller_ani);		/*!< Caller ID ANI Number */
+		AST_STRING_FIELD(caller_rdnis);		/*!< Caller ID RDNIS Number */
+		AST_STRING_FIELD(caller_dnid);		/*!< Caller ID DNID Number */
 		AST_STRING_FIELD(connected_name);	/*!< Connected Line Name */
 		AST_STRING_FIELD(connected_number);	/*!< Connected Line Number */
 	);

Modified: team/kmoore/bridge_construction-cel_channels/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_channels/include/asterisk/strings.h?view=diff&rev=389042&r1=389041&r2=389042
==============================================================================
--- team/kmoore/bridge_construction-cel_channels/include/asterisk/strings.h (original)
+++ team/kmoore/bridge_construction-cel_channels/include/asterisk/strings.h Fri May 17 22:08:55 2013
@@ -1069,4 +1069,46 @@
 }
 
 
+/*!
+ * \brief Convert a string to all lower-case
+ *
+ * \param str The string to be converted to lower case
+ *
+ * \retval str for convenience
+ */
+static force_inline char *attribute_pure ast_str_to_lower(char *str)
+{
+	char *str_orig = str;
+	if (!str) {
+		return str;
+	}
+
+	for (; *str; ++str) {
+		*str = tolower(*str);
+	}
+
+	return str_orig;
+}
+
+/*!
+ * \brief Convert a string to all upper-case
+ *
+ * \param str The string to be converted to upper case
+ *
+ * \retval str for convenience
+ */
+static force_inline char *attribute_pure ast_str_to_upper(char *str)
+{
+	char *str_orig = str;
+	if (!str) {
+		return str;
+	}
+
+	for (; *str; ++str) {
+		*str = toupper(*str);
+	}
+
+	return str_orig;
+}
+
 #endif /* _ASTERISK_STRINGS_H */

Modified: team/kmoore/bridge_construction-cel_channels/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_channels/main/cel.c?view=diff&rev=389042&r1=389041&r2=389042
==============================================================================
--- team/kmoore/bridge_construction-cel_channels/main/cel.c (original)
+++ team/kmoore/bridge_construction-cel_channels/main/cel.c Fri May 17 22:08:55 2013
@@ -55,6 +55,20 @@
 #include "asterisk/config.h"
 #include "asterisk/cli.h"
 #include "asterisk/astobj2.h"
+#include "asterisk/stasis_message_router.h"
+#include "asterisk/stasis_channels.h"
+
+/*! Message router for state that CEL needs to know about */
+static struct stasis_message_router *cel_state_router;
+
+/*! Aggregation topic for all topics CEL needs to know about */
+static struct stasis_topic *cel_state_topic;
+
+/*! Subscription for forwarding the channel caching topic */
+static struct stasis_subscription *cel_channel_forwarder;
+
+/*! Container for dial end multichannel blobs for holding on to dial statuses */
+static struct ao2_container *cel_dialstatus_store;
 
 /*! Is the CEL subsystem enabled ? */
 static unsigned char cel_enabled;
@@ -84,6 +98,11 @@
  * \brief Number of buckets for the appset container
  */
 #define NUM_APP_BUCKETS		97
+
+/*!
+ * \brief Number of buckets for the dialstatus container
+ */
+#define NUM_DIALSTATUS_BUCKETS	251
 
 /*!
  * \brief Container of Asterisk application names
@@ -132,6 +151,40 @@
 	[AST_CEL_LINKEDID_END]     = "LINKEDID_END",
 };
 
+static const char *get_caller_uniqueid(struct ast_multi_channel_blob *blob)
+{
+	struct ast_channel_snapshot *caller = ast_multi_channel_blob_get_channel(blob, "caller");
+	if (!caller) {
+		return NULL;
+	}
+
+	return caller->uniqueid;
+}
+
+/*! \brief Hashing function for dialstatus container */
+static int dialstatus_hash(const void *obj, int flags)
+{
+	struct ast_multi_channel_blob *blob = (void *) obj;
+	const char *uniqueid = obj;
+	if (!(flags & OBJ_KEY)) {
+		uniqueid = get_caller_uniqueid(blob);
+	}
+
+	return ast_str_hash(uniqueid);
+}
+
+/*! \brief Comparator function for dialstatus container */
+static int dialstatus_cmp(void *obj, void *arg, int flags)
+{
+	struct ast_multi_channel_blob *blob1 = obj, *blob2 = arg;
+	const char *blob2_id = arg, *blob1_id = get_caller_uniqueid(blob1);
+	if (!(flags & OBJ_KEY)) {
+		blob2_id = get_caller_uniqueid(blob2);
+	}
+
+	return !strcmp(blob1_id, blob2_id) ? CMP_MATCH | CMP_STOP : 0;
+}
+
 /*!
  * \brief Map of ast_cel_ama_flags to strings
  */
@@ -280,21 +333,13 @@
 	}
 
 	while ((cur_app = strsep(&apps, ","))) {
-		char *app;
-
 		cur_app = ast_strip(cur_app);
 		if (ast_strlen_zero(cur_app)) {
 			continue;
 		}
 
-		if (!(app = ao2_alloc(strlen(cur_app) + 1, NULL))) {
-			continue;
-		}
-		strcpy(app, cur_app);
-
-		ao2_link(appset, app);
-		ao2_ref(app, -1);
-		app = NULL;
+		cur_app = ast_str_to_lower(cur_app);
+		ast_str_container_add(appset, cur_app);
 	}
 }
 
@@ -372,29 +417,105 @@
 	return S_OR(cel_ama_flags[flag], "Unknown");
 }
 
+static int report_event_snapshot(struct ast_channel_snapshot *snapshot,
+		enum ast_cel_event_type event_type, const char *userdefevname,
+		const char *extra)
+{
+	struct timeval eventtime;
+	struct ast_event *ev;
+	char *linkedid = ast_strdupa(snapshot->linkedid);
+
+	if (!cel_enabled) {
+		return 0;
+	}
+
+	/* Make sure a reload is not occurring while we're checking to see if this
+	 * is an event that we care about.  We could lose an important event in this
+	 * process otherwise. */
+	ast_mutex_lock(&reload_lock);
+
+	/* Record the linkedid of new channels if we are tracking LINKEDID_END even if we aren't
+	 * reporting on CHANNEL_START so we can track when to send LINKEDID_END */
+	if (ast_cel_track_event(AST_CEL_LINKEDID_END) && event_type == AST_CEL_CHANNEL_START && linkedid) {
+		if (ast_cel_linkedid_ref(linkedid)) {
+			ast_mutex_unlock(&reload_lock);
+			return -1;
+		}
+	}
+
+	if (!ast_cel_track_event(event_type)) {
+		ast_mutex_unlock(&reload_lock);
+		return 0;
+	}
+
+	if (event_type == AST_CEL_APP_START || event_type == AST_CEL_APP_END) {
+		RAII_VAR(char *, app, NULL, ao2_cleanup);
+		char *app_lower = ast_str_to_lower(ast_strdupa(snapshot->appl));
+		if (!(app = ao2_find(appset, app_lower, OBJ_POINTER))) {
+			ast_mutex_unlock(&reload_lock);
+			return 0;
+		}
+	}
+
+	ast_mutex_unlock(&reload_lock);
+
+	eventtime = ast_tvnow();
+
+	ev = ast_event_new(AST_EVENT_CEL,
+		AST_EVENT_IE_CEL_EVENT_TYPE, AST_EVENT_IE_PLTYPE_UINT, event_type,
+		AST_EVENT_IE_CEL_EVENT_TIME, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_sec,
+		AST_EVENT_IE_CEL_EVENT_TIME_USEC, AST_EVENT_IE_PLTYPE_UINT, eventtime.tv_usec,
+		AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_STR, S_OR(userdefevname, ""),
+		AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, snapshot->caller_name,
+		AST_EVENT_IE_CEL_CIDNUM, AST_EVENT_IE_PLTYPE_STR, snapshot->caller_number,
+		AST_EVENT_IE_CEL_CIDANI, AST_EVENT_IE_PLTYPE_STR, snapshot->caller_ani,
+		AST_EVENT_IE_CEL_CIDRDNIS, AST_EVENT_IE_PLTYPE_STR, snapshot->caller_rdnis,
+		AST_EVENT_IE_CEL_CIDDNID, AST_EVENT_IE_PLTYPE_STR, snapshot->caller_dnid,
+		AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_PLTYPE_STR, snapshot->exten,
+		AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_PLTYPE_STR, snapshot->context,
+		AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, snapshot->name,
+		AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, snapshot->appl,
+		AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, snapshot->data,
+		AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, snapshot->amaflags,
+		AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, snapshot->accountcode,
+		AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_PLTYPE_STR, snapshot->peeraccount,
+		AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, snapshot->uniqueid,
+		AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_PLTYPE_STR, snapshot->linkedid,
+		AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_PLTYPE_STR, snapshot->userfield,
+		AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, S_OR(extra, ""),
+		AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, snapshot->bridged_name,
+		AST_EVENT_IE_END);
+
+	if (ev && ast_event_queue(ev)) {
+		ast_event_destroy(ev);
+		return -1;
+	}
+
+	return 0;
+}
+
 /* called whenever a channel is destroyed or a linkedid is changed to
  * potentially emit a CEL_LINKEDID_END event */
-void ast_cel_check_retire_linkedid(struct ast_channel *chan)
-{
-	const char *linkedid = ast_channel_linkedid(chan);
+static void check_retire_linkedid(struct ast_channel_snapshot *snapshot)
+{
 	char *lid;
 
 	/* make sure we need to do all this work */
 
-	if (ast_strlen_zero(linkedid) || !ast_cel_track_event(AST_CEL_LINKEDID_END)) {
+	if (ast_strlen_zero(snapshot->linkedid) || !ast_cel_track_event(AST_CEL_LINKEDID_END)) {
 		return;
 	}
 
-	if (!(lid = ao2_find(linkedids, (void *) linkedid, OBJ_POINTER))) {
-		ast_log(LOG_ERROR, "Something weird happened, couldn't find linkedid %s\n", linkedid);
+	if (!(lid = ao2_find(linkedids, (void *) snapshot->linkedid, OBJ_POINTER))) {
+		ast_log(LOG_ERROR, "Something weird happened, couldn't find linkedid %s\n", snapshot->linkedid);
 		return;
 	}
 
 	/* We have a ref for each channel with this linkedid, the link and the above find, so if
 	 * before unreffing the channel we have a refcount of 3, we're done. Unlink and report. */
 	if (ao2_ref(lid, -1) == 3) {
-		ao2_unlink(linkedids, lid);
-		ast_cel_report_event(chan, AST_CEL_LINKEDID_END, NULL, NULL, NULL);
+		ast_str_container_remove(linkedids, lid);
+		report_event_snapshot(snapshot, AST_CEL_LINKEDID_END, NULL, NULL);
 	}
 	ao2_ref(lid, -1);
 }
@@ -578,12 +699,12 @@
 	}
 
 	if (event_type == AST_CEL_APP_START || event_type == AST_CEL_APP_END) {
-		char *app;
-		if (!(app = ao2_find(appset, (char *) ast_channel_appl(chan), OBJ_POINTER))) {
+		RAII_VAR(char *, app, NULL, ao2_cleanup);
+		char *app_lower = ast_str_to_lower(ast_strdupa(ast_channel_appl(chan)));
+		if (!(app = ao2_find(appset, app_lower, OBJ_POINTER))) {
 			ast_mutex_unlock(&reload_lock);
 			return 0;
 		}
-		ao2_ref(app, -1);
 	}
 
 	ast_mutex_unlock(&reload_lock);
@@ -704,49 +825,215 @@
 	return 0;
 }
 
-static int app_hash(const void *obj, const int flags)
-{
-	return ast_str_case_hash((const char *) obj);
-}
-
-static int app_cmp(void *obj, void *arg, int flags)
-{
-	const char *app1 = obj, *app2 = arg;
-
-	return !strcasecmp(app1, app2) ? CMP_MATCH | CMP_STOP : 0;
-}
-
-#define lid_hash app_hash
-#define lid_cmp app_cmp
+/*! \brief Typedef for callbacks that get called on channel snapshot updates */
+typedef void (*cel_channel_snapshot_monitor)(
+	struct ast_channel_snapshot *old_snapshot,
+	struct ast_channel_snapshot *new_snapshot);
+
+static struct ast_multi_channel_blob *get_dialstatus_blob(const char *uniqueid)
+{
+	return ao2_find(cel_dialstatus_store, uniqueid, OBJ_KEY | OBJ_UNLINK);
+}
+
+static const char *get_caller_dialstatus(struct ast_multi_channel_blob *blob)
+{
+	struct ast_json *json = ast_multi_channel_blob_get_json(blob);
+	if (!json) {
+		return NULL;
+	}
+
+	json = ast_json_object_get(json, "dialstatus");
+	if (!json) {
+		return NULL;
+	}
+
+	return ast_json_string_get(json);
+}
+
+/*! \brief Handle channel state changes */
+static void cel_channel_state_change(
+	struct ast_channel_snapshot *old_snapshot,
+	struct ast_channel_snapshot *new_snapshot)
+{
+	int is_hungup, was_hungup;
+
+	if (!new_snapshot) {
+		report_event_snapshot(old_snapshot, AST_CEL_CHANNEL_END, NULL, NULL);
+		check_retire_linkedid(old_snapshot);
+		return;
+	}
+
+	if (!old_snapshot) {
+		report_event_snapshot(new_snapshot, AST_CEL_CHANNEL_START, NULL, NULL);
+		return;
+	}
+
+	was_hungup = ast_test_flag(&old_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
+	is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
+
+	if (!was_hungup && is_hungup) {
+		RAII_VAR(struct ast_str *, extra_str, ast_str_create(128), ast_free);
+		RAII_VAR(struct ast_multi_channel_blob *, blob, get_dialstatus_blob(new_snapshot->uniqueid), ao2_cleanup);
+		const char *dialstatus = "";
+		if (blob && get_caller_dialstatus(blob)) {
+			dialstatus = get_caller_dialstatus(blob);
+		}
+		ast_str_set(&extra_str, 0, "%d,%s,%s",
+			new_snapshot->hangupcause,
+			new_snapshot->hangupsource,
+			dialstatus);
+		report_event_snapshot(new_snapshot, AST_CEL_HANGUP, NULL, ast_str_buffer(extra_str));
+		return;
+	}
+
+	if (old_snapshot->state != new_snapshot->state && new_snapshot->state == AST_STATE_UP) {
+		report_event_snapshot(new_snapshot, AST_CEL_ANSWER, NULL, NULL);
+		return;
+	}
+}
+
+static void cel_channel_linkedid_change(
+	struct ast_channel_snapshot *old_snapshot,
+	struct ast_channel_snapshot *new_snapshot)
+{
+	if (!old_snapshot || !new_snapshot) {
+		return;
+	}
+
+	if (strcmp(old_snapshot->linkedid, new_snapshot->linkedid)) {
+		check_retire_linkedid(old_snapshot);
+	}
+}
+
+static void cel_channel_app_change(
+	struct ast_channel_snapshot *old_snapshot,
+	struct ast_channel_snapshot *new_snapshot)
+{
+	if (new_snapshot && old_snapshot
+		&& !strcmp(old_snapshot->appl, new_snapshot->appl)) {
+		return;
+	}
+
+	/* old snapshot has an application, end it */
+	if (old_snapshot && !ast_strlen_zero(old_snapshot->appl)) {
+		report_event_snapshot(old_snapshot, AST_CEL_APP_END, NULL, NULL);
+	}
+
+	/* new snapshot has an application, start it */
+	if (new_snapshot && !ast_strlen_zero(new_snapshot->appl)) {
+		report_event_snapshot(new_snapshot, AST_CEL_APP_START, NULL, NULL);
+	}
+}
+
+cel_channel_snapshot_monitor cel_channel_monitors[] = {
+	cel_channel_state_change,
+	cel_channel_app_change,
+	cel_channel_linkedid_change,
+};
+
+static void cel_snapshot_update_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	struct stasis_cache_update *update = stasis_message_data(message);
+	if (ast_channel_snapshot_type() == update->type) {
+		struct ast_channel_snapshot *old_snapshot;
+		struct ast_channel_snapshot *new_snapshot;
+		size_t i;
+
+		old_snapshot = stasis_message_data(update->old_snapshot);
+		new_snapshot = stasis_message_data(update->new_snapshot);
+
+		for (i = 0; i < ARRAY_LEN(cel_channel_monitors); ++i) {
+			cel_channel_monitors[i](old_snapshot, new_snapshot);
+		}
+	}
+}
+
+static void save_dialstatus(struct ast_multi_channel_blob *blob)
+{
+	ao2_link(cel_dialstatus_store, blob);
+}
+
+static void cel_dial_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	struct ast_multi_channel_blob *blob = stasis_message_data(message);
+
+	if (!get_caller_uniqueid(blob)) {
+		return;
+	}
+
+	if (!get_caller_dialstatus(blob)) {
+		return;
+	}
+
+	save_dialstatus(blob);
+}
 
 static void ast_cel_engine_term(void)
 {
-	if (appset) {
-		ao2_ref(appset, -1);
-		appset = NULL;
-	}
-	if (linkedids) {
-		ao2_ref(linkedids, -1);
-		linkedids = NULL;
-	}
+	stasis_message_router_unsubscribe(cel_state_router);
+	cel_state_router = NULL;
+	ao2_cleanup(cel_state_topic);
+	cel_state_topic = NULL;
+	cel_channel_forwarder = stasis_unsubscribe(cel_channel_forwarder);
+	ao2_cleanup(appset);
+	appset = NULL;
+	ao2_cleanup(linkedids);
+	linkedids = NULL;
 	ast_cli_unregister(&cli_status);
 }
 
 int ast_cel_engine_init(void)
 {
-	if (!(appset = ao2_container_alloc(NUM_APP_BUCKETS, app_hash, app_cmp))) {
-		return -1;
-	}
-	if (!(linkedids = ao2_container_alloc(NUM_APP_BUCKETS, lid_hash, lid_cmp))) {
-		ao2_ref(appset, -1);
+	int ret = 0;
+	if (!(appset = ast_str_container_alloc(NUM_APP_BUCKETS))) {
+		return -1;
+	}
+	if (!(linkedids = ast_str_container_alloc(NUM_APP_BUCKETS))) {
+		return -1;
+	}
+
+	if (!(cel_dialstatus_store = ao2_container_alloc(NUM_DIALSTATUS_BUCKETS, dialstatus_hash, dialstatus_cmp))) {
 		return -1;
 	}
 
 	if (do_reload() || ast_cli_register(&cli_status)) {
-		ao2_ref(appset, -1);
-		appset = NULL;
-		ao2_ref(linkedids, -1);
-		linkedids = NULL;
+		return -1;
+	}
+
+	cel_state_topic = stasis_topic_create("cel_state_topic");
+	if (!cel_state_topic) {
+		return -1;
+	}
+
+	cel_channel_forwarder = stasis_forward_all(stasis_caching_get_topic(ast_channel_topic_all_cached()), cel_state_topic);
+	if (!cel_channel_forwarder) {
+		return -1;
+	}
+
+	cel_state_router = stasis_message_router_create(cel_state_topic);
+	if (!cel_state_router) {
+		return -1;
+	}
+
+	ret |= stasis_message_router_add(cel_state_router,
+		stasis_cache_update_type(),
+		cel_snapshot_update_cb,
+		NULL);
+
+	ret |= stasis_message_router_add(cel_state_router,
+		ast_channel_dial_type(),
+		cel_dial_cb,
+		NULL);
+
+	/* If somehow we failed to add any routes, just shut down the whole
+	 * thing and fail it.
+	 */
+	if (ret) {
+		ast_cel_engine_term();
 		return -1;
 	}
 

Modified: team/kmoore/bridge_construction-cel_channels/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_channels/main/channel.c?view=diff&rev=389042&r1=389041&r2=389042
==============================================================================
--- team/kmoore/bridge_construction-cel_channels/main/channel.c (original)
+++ team/kmoore/bridge_construction-cel_channels/main/channel.c Fri May 17 22:08:55 2013
@@ -1041,14 +1041,6 @@
 		ast_channel_timingfd_set(tmp, ast_timer_fd(ast_channel_timer(tmp)));
 	}
 
-	/*
-	 * This is the last place the channel constructor can fail.
-	 *
-	 * The destructor takes advantage of this fact to ensure that the
-	 * AST_CEL_CHANNEL_END is not posted if we have not posted the
-	 * AST_CEL_CHANNEL_START yet.
-	 */
-
 	if (needqueue && ast_channel_internal_alertpipe_init(tmp)) {
 		return ast_channel_unref(tmp);
 	}
@@ -1134,7 +1126,6 @@
 	ast_cdr_start(ast_channel_cdr(tmp));
 
 	ast_atomic_fetchadd_int(&chancount, +1);
-	ast_cel_report_event(tmp, AST_CEL_CHANNEL_START, NULL, NULL, NULL);
 
 	headp = ast_channel_varshead(tmp);
 	AST_LIST_HEAD_INIT_NOLOCK(headp);
@@ -2353,11 +2344,6 @@
 	char device_name[AST_CHANNEL_NAME];
 	struct ast_callid *callid;
 
-	if (ast_channel_internal_is_finalized(chan)) {
-		ast_cel_report_event(chan, AST_CEL_CHANNEL_END, NULL, NULL, NULL);
-		ast_cel_check_retire_linkedid(chan);
-	}
-
 	ast_pbx_hangup_handler_destroy(chan);
 
 	ast_channel_lock(chan);
@@ -2772,8 +2758,6 @@
 /*! \brief Hangup a channel */
 int ast_hangup(struct ast_channel *chan)
 {
-	char extra_str[64]; /* used for cel logging below */
-
 	ast_autoservice_stop(chan);
 
 	ast_channel_lock(chan);
@@ -2848,9 +2832,6 @@
 	ast_channel_generatordata_set(chan, NULL);
 	ast_channel_generator_set(chan, NULL);
 
-	snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", ast_channel_hangupcause(chan), ast_channel_hangupsource(chan), S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
-	ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL);
-
 	if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)) {
 		ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
 			"is blocked by thread %ld in procedure %s!  Expect a failure\n",
@@ -2916,11 +2897,9 @@
 		if (cdr_answer) {
 			ast_cdr_answer(ast_channel_cdr(chan));
 		}
-		ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
 		ast_channel_unlock(chan);
 		break;
 	case AST_STATE_UP:
-		ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
 		/* Calling ast_cdr_answer when it it has previously been called
 		 * is essentially a no-op, so it is safe.
 		 */
@@ -4066,8 +4045,6 @@
 				} else {
 					/* Answer the CDR */
 					ast_setstate(chan, AST_STATE_UP);
-					/* removed a call to ast_cdr_answer(chan->cdr) from here. */
-					ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
 				}
 			} else if (f->subclass.integer == AST_CONTROL_READ_ACTION) {
 				read_action_payload = f->data.ptr;
@@ -6636,7 +6613,6 @@
 		return;
 	}
 
-	ast_cel_check_retire_linkedid(chan);
 	ast_channel_linkedid_set(chan, linkedid);
 	ast_cel_linkedid_ref(linkedid);
 }

Modified: team/kmoore/bridge_construction-cel_channels/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_channels/main/pbx.c?view=diff&rev=389042&r1=389041&r2=389042
==============================================================================
--- team/kmoore/bridge_construction-cel_channels/main/pbx.c (original)
+++ team/kmoore/bridge_construction-cel_channels/main/pbx.c Fri May 17 22:08:55 2013
@@ -1573,14 +1573,12 @@
 
 	ast_channel_appl_set(c, app->name);
 	ast_channel_data_set(c, data);
-	ast_cel_report_event(c, AST_CEL_APP_START, NULL, NULL, NULL);
 
 	if (app->module)
 		u = __ast_module_user_add(app->module, c);
 	res = app->execute(c, S_OR(data, ""));
 	if (app->module && u)
 		__ast_module_user_remove(app->module, u);
-	ast_cel_report_event(c, AST_CEL_APP_END, NULL, NULL, NULL);
 	/* restore channel values */
 	ast_channel_appl_set(c, saved_c_appl);
 	ast_channel_data_set(c, saved_c_data);

Modified: team/kmoore/bridge_construction-cel_channels/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_channels/main/stasis_channels.c?view=diff&rev=389042&r1=389041&r2=389042
==============================================================================
--- team/kmoore/bridge_construction-cel_channels/main/stasis_channels.c (original)
+++ team/kmoore/bridge_construction-cel_channels/main/stasis_channels.c Fri May 17 22:08:55 2013
@@ -35,6 +35,7 @@
 #include "asterisk/stasis.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/stasis_channels.h"
+#include "asterisk/pbx.h"
 
 #define NUM_MULTI_CHANNEL_BLOB_BUCKETS 7
 
@@ -102,6 +103,7 @@
 struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan)
 {
 	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+	struct ast_channel *bridged;
 
 	snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor);
 	if (!snapshot || ast_string_field_init(snapshot, 1024)) {
@@ -125,10 +127,28 @@
 	ast_string_field_set(snapshot, context, ast_channel_context(chan));
 	ast_string_field_set(snapshot, exten, ast_channel_exten(chan));
 
+	bridged = ast_bridged_channel(chan);
+	if (bridged) {
+		ast_channel_ref(bridged);
+		ast_channel_lock(bridged);
+		ast_string_field_set(snapshot, bridged_name, ast_channel_name(bridged));
+		ast_string_field_set(snapshot, bridged_id, ast_channel_uniqueid(bridged));
+		ast_channel_unlock(bridged);
+		ast_channel_unref(bridged);
+		bridged = NULL;
+	}
+
 	ast_string_field_set(snapshot, caller_name,
 		S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, ""));
 	ast_string_field_set(snapshot, caller_number,
 		S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""));
+
+	ast_string_field_set(snapshot, caller_ani,
+		S_COR(ast_channel_caller(chan)->ani.number.valid, ast_channel_caller(chan)->ani.number.str, ""));
+	ast_string_field_set(snapshot, caller_rdnis,
+		S_COR(ast_channel_redirecting(chan)->from.number.valid, ast_channel_redirecting(chan)->from.number.str, ""));
+	ast_string_field_set(snapshot, caller_dnid,
+		S_OR(ast_channel_dialed(chan)->number.str, ""));
 
 	ast_string_field_set(snapshot, connected_name,
 		S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, ""));




More information about the svn-commits mailing list