[asterisk-commits] kmoore: trunk r394808 - in /trunk: apps/confbridge/ include/asterisk/ main/ r...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 19 14:23:45 CDT 2013


Author: kmoore
Date: Fri Jul 19 14:23:39 2013
New Revision: 394808

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394808
Log:
Filter channels used as internal mechanisms

This adds new flags to the channel tech properties that flag it as
different types of implementation detail used exclusively to provide a
feature. Examples of channels that would have these flags include the
announcement and recording channels used by confbridge which are the
only two marked as such by this patch.

Review: https://reviewboard.asterisk.org/r/2633/
(closes issue ASTERISK-21873)

Modified:
    trunk/apps/confbridge/conf_chan_announce.c
    trunk/apps/confbridge/conf_chan_record.c
    trunk/apps/confbridge/confbridge_manager.c
    trunk/include/asterisk/channel.h
    trunk/include/asterisk/stasis_channels.h
    trunk/main/cdr.c
    trunk/main/cel.c
    trunk/main/manager_bridging.c
    trunk/main/manager_channels.c
    trunk/main/stasis_channels.c
    trunk/res/parking/parking_manager.c

Modified: trunk/apps/confbridge/conf_chan_announce.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_chan_announce.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/apps/confbridge/conf_chan_announce.c (original)
+++ trunk/apps/confbridge/conf_chan_announce.c Fri Jul 19 14:23:39 2013
@@ -134,6 +134,7 @@
 	.send_text = ast_unreal_sendtext,
 	.queryoption = ast_unreal_queryoption,
 	.setoption = ast_unreal_setoption,
+	.properties = AST_CHAN_TP_ANNOUNCER,
 };
 
 struct ast_channel_tech *conf_announce_get_tech(void)

Modified: trunk/apps/confbridge/conf_chan_record.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_chan_record.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/apps/confbridge/conf_chan_record.c (original)
+++ trunk/apps/confbridge/conf_chan_record.c Fri Jul 19 14:23:39 2013
@@ -86,6 +86,7 @@
 	.call = rec_call,
 	.read = rec_read,
 	.write = rec_write,
+	.properties = AST_CHAN_TP_RECORDER,
 };
 
 struct ast_channel_tech *conf_record_get_tech(void)

Modified: trunk/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/confbridge_manager.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/apps/confbridge/confbridge_manager.c (original)
+++ trunk/apps/confbridge/confbridge_manager.c Fri Jul 19 14:23:39 2013
@@ -195,13 +195,16 @@
 {
 	struct ast_bridge_blob *blob = stasis_message_data(message);
 	const char *conference_name;
-	RAII_VAR(struct ast_str *, bridge_text,
-		ast_manager_build_bridge_state_string(blob->bridge, ""),
-		ast_free);
+	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
 	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
 
 	ast_assert(blob != NULL);
 	ast_assert(event != NULL);
+
+	bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+	if (!bridge_text) {
+		return;
+	}
 
 	conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));
 	ast_assert(conference_name != NULL);

Modified: trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/channel.h?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Fri Jul 19 14:23:39 2013
@@ -854,15 +854,25 @@
 /*! \brief ast_channel_tech Properties */
 enum {
 	/*!
-     * \brief Channels have this property if they can accept input with jitter;
+	 * \brief Channels have this property if they can accept input with jitter;
 	 * i.e. most VoIP channels
 	 */
 	AST_CHAN_TP_WANTSJITTER = (1 << 0),
 	/*!
-     * \brief Channels have this property if they can create jitter;
+	 * \brief Channels have this property if they can create jitter;
 	 * i.e. most VoIP channels
 	 */
 	AST_CHAN_TP_CREATESJITTER = (1 << 1),
+	/*!
+	 * \brief Channels have this property if they are an implementation detail
+	 * used for announcing messages; i.e. to a bridge
+	 */
+	AST_CHAN_TP_ANNOUNCER = (1 << 2),
+	/*!
+	 * \brief Channels have this property if they are an implementation detail
+	 * used for recording audio; i.e. from a bridge
+	 */
+	AST_CHAN_TP_RECORDER = (1 << 3),
 };
 
 /*! \brief ast_channel flags */

Modified: trunk/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis_channels.h?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/include/asterisk/stasis_channels.h (original)
+++ trunk/include/asterisk/stasis_channels.h Fri Jul 19 14:23:39 2013
@@ -84,6 +84,7 @@
 	struct ast_flags softhangup_flags;      /*!< softhangup channel flags */
 	struct varshead *manager_vars;          /*!< Variables to be appended to manager events */
 	struct varshead *channel_vars;          /*!< Variables set on the channel */
+	int tech_properties;                    /*!< Properties of the channel's technology */
 };
 
 /*!

Modified: trunk/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cdr.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Fri Jul 19 14:23:39 2013
@@ -1902,11 +1902,7 @@
 /*! \internal \brief Filter channel snapshots by technology */
 static int filter_channel_snapshot(struct ast_channel_snapshot *snapshot)
 {
-	if (!strncmp(snapshot->name, "CBAnn", 5) ||
-		!strncmp(snapshot->name, "CBRec", 5)) {
-		return 1;
-	}
-	return 0;
+	return snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER);
 }
 
 /*! \internal \brief Filter a channel cache update */

Modified: trunk/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cel.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/main/cel.c (original)
+++ trunk/main/cel.c Fri Jul 19 14:23:39 2013
@@ -1196,6 +1196,14 @@
 	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) {
+		return 0;
+	}
+	return snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER);
+}
+
 static void cel_snapshot_update_cb(void *data, struct stasis_subscription *sub,
 	struct stasis_topic *topic,
 	struct stasis_message *message)
@@ -1209,6 +1217,10 @@
 		old_snapshot = stasis_message_data(update->old_snapshot);
 		new_snapshot = stasis_message_data(update->new_snapshot);
 
+		if (cel_filter_channel_snapshot(old_snapshot) || cel_filter_channel_snapshot(new_snapshot)) {
+			return;
+		}
+
 		update_bridge_primary(new_snapshot);
 
 		for (i = 0; i < ARRAY_LEN(cel_channel_monitors); ++i) {
@@ -1241,6 +1253,10 @@
 	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);
+
+	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) {
@@ -1302,6 +1318,10 @@
 	struct ast_bridge_blob *blob = stasis_message_data(message);
 	struct ast_bridge_snapshot *snapshot = blob->bridge;
 	struct ast_channel_snapshot *chan_snapshot = blob->channel;
+
+	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,
@@ -1365,6 +1385,10 @@
 	struct stasis_message *message)
 {
 	struct ast_multi_channel_blob *blob = stasis_message_data(message);
+
+	if (cel_filter_channel_snapshot(ast_multi_channel_blob_get_channel(blob, "caller"))) {
+		return;
+	}
 
 	if (!get_caller_uniqueid(blob)) {
 		return;

Modified: trunk/main/manager_bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager_bridging.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/main/manager_bridging.c (original)
+++ trunk/main/manager_bridging.c Fri Jul 19 14:23:39 2013
@@ -140,6 +140,7 @@
 		suffix, snapshot->num_channels);
 
 	if (!res) {
+		ast_free(out);
 		return NULL;
 	}
 
@@ -239,6 +240,9 @@
 
 	to_text = ast_manager_build_bridge_state_string(merge_msg->to, "");
 	from_text = ast_manager_build_bridge_state_string(merge_msg->from, "From");
+	if (!to_text || !from_text) {
+		return;
+	}
 
 	/*** DOCUMENTATION
 		<managerEventInstance>
@@ -271,6 +275,9 @@
 
 	bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
 	channel_text = ast_manager_build_channel_state_string(blob->channel);
+	if (!bridge_text || !channel_text) {
+		return;
+	}
 
 	manager_event(EVENT_FLAG_CALL, "BridgeEnter",
 		"%s"
@@ -289,6 +296,9 @@
 
 	bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
 	channel_text = ast_manager_build_channel_state_string(blob->channel);
+	if (!bridge_text || !channel_text) {
+		return;
+	}
 
 	manager_event(EVENT_FLAG_CALL, "BridgeLeave",
 		"%s"
@@ -312,6 +322,10 @@
 	char *id_text = data;
 	RAII_VAR(struct ast_str *, bridge_info, ast_manager_build_bridge_state_string(snapshot, ""), ast_free);
 
+	if (!bridge_info) {
+		return 0;
+	}
+
 	astman_append(s,
 		"Event: BridgeListItem\r\n"
 		"%s"
@@ -367,6 +381,19 @@
 	char *uniqueid = obj;
 	struct mansession *s = arg;
 	char *id_text = data;
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+	struct ast_channel_snapshot *snapshot;
+	msg = stasis_cache_get(ast_channel_topic_all_cached(),
+		ast_channel_snapshot_type(), uniqueid);
+
+	if (!msg) {
+		return 0;
+	}
+
+	snapshot = stasis_message_data(msg);
+	if (snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER)) {
+		return 0;
+	}
 
 	astman_append(s,
 		"Event: BridgeInfoChannel\r\n"
@@ -419,7 +446,7 @@
 		"%s"
 		"%s"
 		"\r\n",
-		ast_str_buffer(bridge_info),
+		S_COR(bridge_info, ast_str_buffer(bridge_info), ""),
 		ast_str_buffer(id_text));
 
 	return 0;

Modified: trunk/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager_channels.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/main/manager_channels.c (original)
+++ trunk/main/manager_channels.c Fri Jul 19 14:23:39 2013
@@ -530,6 +530,11 @@
 	int res = 0;
 
 	if (!out) {
+		return NULL;
+	}
+
+	if (snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER)) {
+		ast_free(out);
 		return NULL;
 	}
 
@@ -560,6 +565,7 @@
 		prefix, snapshot->uniqueid);
 
 	if (!res) {
+		ast_free(out);
 		return NULL;
 	}
 
@@ -1209,6 +1215,9 @@
 	}
 
 	channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+	if (!channel_event_string) {
+		return;
+	}
 
 	if (obj->blob) {
 		musicclass = ast_json_string_get(ast_json_object_get(obj->blob, "musicclass"));
@@ -1232,6 +1241,9 @@
 	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
 
 	channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+	if (!channel_event_string) {
+		return;
+	}
 
 	manager_event(EVENT_FLAG_CALL, "Unhold",
 		"%s",

Modified: trunk/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_channels.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/main/stasis_channels.c (original)
+++ trunk/main/stasis_channels.c Fri Jul 19 14:23:39 2013
@@ -256,6 +256,7 @@
 
 	snapshot->manager_vars = ast_channel_get_manager_vars(chan);
 	snapshot->channel_vars = ast_channel_get_vars(chan);
+	snapshot->tech_properties = ast_channel_tech(chan)->properties;
 
 	ao2_ref(snapshot, +1);
 	return snapshot;

Modified: trunk/res/parking/parking_manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/parking/parking_manager.c?view=diff&rev=394808&r1=394807&r2=394808
==============================================================================
--- trunk/res/parking/parking_manager.c (original)
+++ trunk/res/parking/parking_manager.c Fri Jul 19 14:23:39 2013
@@ -266,6 +266,9 @@
 	}
 
 	parkee_string = ast_manager_build_channel_state_string_prefix(payload->parkee, "Parkee");
+	if (!parkee_string) {
+		return NULL;
+	}
 
 	if (payload->retriever) {
 		retriever_string = ast_manager_build_channel_state_string_prefix(payload->retriever, "Retriever");




More information about the asterisk-commits mailing list