[svn-commits] kmoore: branch kmoore/cel_cleanup r392830 - in /team/kmoore/cel_cleanup: incl...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 25 08:04:05 CDT 2013


Author: kmoore
Date: Tue Jun 25 08:04:03 2013
New Revision: 392830

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392830
Log:
Break out CEL event creation

Modified:
    team/kmoore/cel_cleanup/include/asterisk/cel.h
    team/kmoore/cel_cleanup/main/cel.c

Modified: team/kmoore/cel_cleanup/include/asterisk/cel.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/include/asterisk/cel.h?view=diff&rev=392830&r1=392829&r2=392830
==============================================================================
--- team/kmoore/cel_cleanup/include/asterisk/cel.h (original)
+++ team/kmoore/cel_cleanup/include/asterisk/cel.h Tue Jun 25 08:04:03 2013
@@ -301,6 +301,27 @@
  */
 void ast_cel_set_config(struct ast_cel_config *config);
 
+struct ast_channel_snapshot;
+/*!
+ * \brief Allocate and populate a CEL event structure
+ *
+ * \param snapshot An ast_channel_snapshot of the primary channel associated
+ *        with this channel event.
+ * \param event_type The type of call event being reported.
+ * \param userdefevname Custom name for the call event. (optional)
+ * \param extra An opaque field that will go into the "CEL_EXTRA" information
+ *        element of the call event. (optional)
+ * \param peer_name The peer name to be placed into the event. (optional)
+ *
+ * \since 12
+ *
+ * \retval The created ast_event structure
+ * \retval NULL on failure
+ */
+struct ast_event *ast_cel_create_event(struct ast_channel_snapshot *snapshot,
+		enum ast_cel_event_type event_type, const char *userdefevname,
+		const char *extra, const char *peer_name);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/kmoore/cel_cleanup/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_cleanup/main/cel.c?view=diff&rev=392830&r1=392829&r2=392830
==============================================================================
--- team/kmoore/cel_cleanup/main/cel.c (original)
+++ team/kmoore/cel_cleanup/main/cel.c Tue Jun 25 08:04:03 2013
@@ -632,52 +632,13 @@
 }
 
 static int cel_linkedid_ref(const char *linkedid);
-static int report_event_snapshot(struct ast_channel_snapshot *snapshot,
+struct ast_event *ast_cel_create_event(struct ast_channel_snapshot *snapshot,
 		enum ast_cel_event_type event_type, const char *userdefevname,
-		const char *extra, const char *peer2_name)
-{
-	struct timeval eventtime;
-	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) {
-		return 0;
-	}
-
-	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
-	 * 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 (cel_linkedid_ref(linkedid)) {
-			return -1;
-		}
-	}
-
-	if (!ast_cel_track_event(event_type)) {
-		return 0;
-	}
-
-	if ((event_type == AST_CEL_APP_START || event_type == AST_CEL_APP_END)
-		&& !cel_track_app(snapshot->appl)) {
-		return 0;
-	}
-
-	eventtime = ast_tvnow();
-
-	ev = ast_event_new(AST_EVENT_CEL,
+		const char *extra, const char *peer_name)
+{
+	struct timeval eventtime = ast_tvnow();
+	ast_log(LOG_ERROR, "Creating %d event with extra: %s\n", event_type, S_OR(extra, ""));
+	return 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,
@@ -701,7 +662,51 @@
 		AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, S_OR(extra, ""),
 		AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, S_OR(peer_name, ""),
 		AST_EVENT_IE_END);
-
+}
+
+static int report_event_snapshot(struct ast_channel_snapshot *snapshot,
+		enum ast_cel_event_type event_type, const char *userdefevname,
+		const char *extra, const char *peer2_name)
+{
+	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) {
+		return 0;
+	}
+
+	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
+	 * 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 (cel_linkedid_ref(linkedid)) {
+			return -1;
+		}
+	}
+
+	if (!ast_cel_track_event(event_type)) {
+		return 0;
+	}
+
+	if ((event_type == AST_CEL_APP_START || event_type == AST_CEL_APP_END)
+		&& !cel_track_app(snapshot->appl)) {
+		return 0;
+	}
+
+	ev = ast_cel_create_event(snapshot, event_type, userdefevname, extra, peer_name);
 	if (ev && ast_event_queue(ev)) {
 		ast_event_destroy(ev);
 		return -1;




More information about the svn-commits mailing list