[asterisk-commits] kmoore: branch kmoore/bridge_construction-cel_bridging r389480 - /team/kmoore...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 22 08:52:24 CDT 2013


Author: kmoore
Date: Wed May 22 08:52:21 2013
New Revision: 389480

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389480
Log:
Add AST_CEL_PARK_START/END handling and clean things up

Modified:
    team/kmoore/bridge_construction-cel_bridging/main/cel.c

Modified: team/kmoore/bridge_construction-cel_bridging/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/bridge_construction-cel_bridging/main/cel.c?view=diff&rev=389480&r1=389479&r2=389480
==============================================================================
--- team/kmoore/bridge_construction-cel_bridging/main/cel.c (original)
+++ team/kmoore/bridge_construction-cel_bridging/main/cel.c Wed May 22 08:52:21 2013
@@ -60,6 +60,7 @@
 #include "asterisk/stasis_channels.h"
 #include "asterisk/stasis_bridging.h"
 #include "asterisk/bridging.h"
+#include "asterisk/parking.h"
 
 /*** DOCUMENTATION
 	<configInfo name="cel" language="en_US">
@@ -133,6 +134,9 @@
 /*! Subscription for forwarding the channel caching topic */
 static struct stasis_subscription *cel_bridge_forwarder;
 
+/*! Subscription for forwarding the parking topic */
+static struct stasis_subscription *cel_parking_forwarder;
+
 /*! Container for primary channel/bridge ID listing for 2 party bridges */
 static struct ao2_container *bridge_primaries;
 
@@ -1297,8 +1301,6 @@
 		}
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_MULTIMIX) {
 		report_event_id(chan_snapshot->uniqueid, AST_CEL_CONF_ENTER, NULL, NULL, NULL);
-	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_HOLDING) {
-		/* XXX AST_CEL_PARK_START refactor to parking subscription */
 	}
 }
 
@@ -1336,11 +1338,36 @@
 			remove_bridge_primary(primary);
 			report_event_snapshot(assoc->primary_snapshot, AST_CEL_BRIDGE_END, NULL, NULL, assoc->secondary_name);
 		}
-		/* AST_CEL_BRIDGE_END when all parties have left */
 	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_MULTIMIX) {
 		report_event_id(chan_snapshot->uniqueid, AST_CEL_CONF_EXIT, NULL, NULL, NULL);
-	} else if (snapshot->capabilities | AST_BRIDGE_CAPABILITY_HOLDING) {
-		/* XXX AST_CEL_PARK_END refactor to parking subscription */
+	}
+}
+
+static void cel_parking_cb(
+	void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	struct ast_parked_call_payload *parked_payload = stasis_message_data(message);
+
+	switch (parked_payload->event_type) {
+	case PARKED_CALL:
+		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_START, NULL,
+			parked_payload->parkinglot,
+			S_COR(parked_payload->parker, parked_payload->parker->name, NULL));
+		break;
+	case PARKED_CALL_TIMEOUT:
+		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallTimeOut", NULL);
+		break;
+	case PARKED_CALL_GIVEUP:
+		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallGiveUp", NULL);
+		break;
+	case PARKED_CALL_UNPARKED:
+		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallUnparked", NULL);
+		break;
+	case PARKED_CALL_FAILED:
+		report_event_snapshot(parked_payload->parkee, AST_CEL_PARK_END, NULL, "ParkedCallFailed", NULL);
+		break;
 	}
 }
 
@@ -1374,6 +1401,7 @@
 	cel_state_topic = NULL;
 	cel_channel_forwarder = stasis_unsubscribe(cel_channel_forwarder);
 	cel_bridge_forwarder = stasis_unsubscribe(cel_bridge_forwarder);
+	cel_parking_forwarder = stasis_unsubscribe(cel_parking_forwarder);
 	ao2_cleanup(linkedids);
 	linkedids = NULL;
 	ast_cli_unregister(&cli_status);
@@ -1411,6 +1439,11 @@
 		return -1;
 	}
 
+	bridge_primaries = ao2_container_alloc(BRIDGE_PRIMARY_BUCKETS, bridge_assoc_hash, bridge_assoc_cmp);
+	if (!bridge_primaries) {
+		return -1;
+	}
+
 	cel_state_topic = stasis_topic_create("cel_state_topic");
 	if (!cel_state_topic) {
 		return -1;
@@ -1430,6 +1463,13 @@
 		return -1;
 	}
 
+	cel_parking_forwarder = stasis_forward_all(
+		ast_parking_topic(),
+		cel_state_topic);
+	if (!cel_parking_forwarder) {
+		return -1;
+	}
+
 	cel_state_router = stasis_message_router_create(cel_state_topic);
 	if (!cel_state_router) {
 		return -1;
@@ -1443,6 +1483,21 @@
 	ret |= stasis_message_router_add(cel_state_router,
 		ast_channel_dial_type(),
 		cel_dial_cb,
+		NULL);
+
+	ret |= stasis_message_router_add(cel_state_router,
+		ast_channel_entered_bridge_type(),
+		cel_bridge_enter_cb,
+		NULL);
+
+	ret |= stasis_message_router_add(cel_state_router,
+		ast_channel_left_bridge_type(),
+		cel_bridge_leave_cb,
+		NULL);
+
+	ret |= stasis_message_router_add(cel_state_router,
+		ast_parked_call_type(),
+		cel_parking_cb,
 		NULL);
 
 	/* If somehow we failed to add any routes, just shut down the whole
@@ -1453,29 +1508,6 @@
 		return -1;
 	}
 
-	bridge_primaries = ao2_container_alloc(BRIDGE_PRIMARY_BUCKETS, bridge_assoc_hash, bridge_assoc_cmp);
-	if (!bridge_primaries) {
-		return -1;
-	}
-
-	ret |= stasis_message_router_add(cel_state_router,
-		ast_channel_entered_bridge_type(),
-		cel_bridge_enter_cb,
-		NULL);
-
-	ret |= stasis_message_router_add(cel_state_router,
-		ast_channel_left_bridge_type(),
-		cel_bridge_leave_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;
-	}
-
 	ast_register_atexit(ast_cel_engine_term);
 
 	return 0;




More information about the asterisk-commits mailing list