[asterisk-commits] kmoore: branch kmoore/stasis-bridging_events-rework r390429 - in /team/kmoore...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 4 13:37:18 CDT 2013


Author: kmoore
Date: Tue Jun  4 13:37:16 2013
New Revision: 390429

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390429
Log:
Address David's comments

Modified:
    team/kmoore/stasis-bridging_events-rework/include/asterisk/stasis_app.h
    team/kmoore/stasis-bridging_events-rework/res/res_stasis.c
    team/kmoore/stasis-bridging_events-rework/res/stasis_http/resource_bridges.c

Modified: team/kmoore/stasis-bridging_events-rework/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging_events-rework/include/asterisk/stasis_app.h?view=diff&rev=390429&r1=390428&r2=390429
==============================================================================
--- team/kmoore/stasis-bridging_events-rework/include/asterisk/stasis_app.h (original)
+++ team/kmoore/stasis-bridging_events-rework/include/asterisk/stasis_app.h Tue Jun  4 13:37:16 2013
@@ -199,7 +199,7 @@
 /*!
  * \brief Returns the bridge with the given id.
  * \param bridge_id Uniqueid of the bridge.
- * \return NULL bridge not in Stasis application, or bridge does not exist.
+ * \return NULL bridge not created by a Stasis application, or bridge does not exist.
  * \return Pointer to bridge.
  */
 struct ast_bridge *stasis_app_bridge_find_by_id(

Modified: team/kmoore/stasis-bridging_events-rework/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging_events-rework/res/res_stasis.c?view=diff&rev=390429&r1=390428&r2=390429
==============================================================================
--- team/kmoore/stasis-bridging_events-rework/res/res_stasis.c (original)
+++ team/kmoore/stasis-bridging_events-rework/res/res_stasis.c Tue Jun  4 13:37:16 2013
@@ -413,20 +413,19 @@
 struct ast_bridge *stasis_app_bridge_create(const char *type)
 {
 	struct ast_bridge *bridge;
-	int flags;
-	if (ast_strlen_zero(type)) {
-		flags = AST_BRIDGE_CAPABILITY_MULTIMIX;
-	} else if (!strcmp(type, "two-party")) {
-		flags = AST_BRIDGE_CAPABILITY_1TO1MIX;
-	} else if (!strcmp(type, "multi-party")) {
-		flags = AST_BRIDGE_CAPABILITY_MULTIMIX;
+	int capabilities, flags = 0;
+	if (ast_strlen_zero(type) || !strcmp(type, "mixing")) {
+		capabilities = AST_BRIDGE_CAPABILITY_1TO1MIX |
+			AST_BRIDGE_CAPABILITY_MULTIMIX |
+			AST_BRIDGE_CAPABILITY_NATIVE;
+		flags = AST_BRIDGE_FLAG_SMART;
 	} else if (!strcmp(type, "holding")) {
-		flags = AST_BRIDGE_CAPABILITY_HOLDING;
+		capabilities = AST_BRIDGE_CAPABILITY_HOLDING;
 	} else {
 		return NULL;
 	}
 
-	bridge = ast_bridge_base_new(flags, 0);
+	bridge = ast_bridge_base_new(capabilities, flags);
 	if (bridge) {
 		ao2_link(app_bridges, bridge);
 	}

Modified: team/kmoore/stasis-bridging_events-rework/res/stasis_http/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging_events-rework/res/stasis_http/resource_bridges.c?view=diff&rev=390429&r1=390428&r2=390429
==============================================================================
--- team/kmoore/stasis-bridging_events-rework/res/stasis_http/resource_bridges.c (original)
+++ team/kmoore/stasis-bridging_events-rework/res/stasis_http/resource_bridges.c Tue Jun  4 13:37:16 2013
@@ -57,6 +57,14 @@
 
 	bridge = stasis_app_bridge_find_by_id(bridge_id);
 	if (bridge == NULL) {
+		RAII_VAR(struct ast_bridge_snapshot *, snapshot,
+			ast_bridge_snapshot_get_latest(bridge_id), ao2_cleanup);
+		if (!snapshot) {
+			stasis_http_response_error(response, 404, "Not found",
+				"Bridge not found");
+			return NULL;
+		}
+
 		stasis_http_response_error(response, 409, "Conflict",
 			"Bridge not in Stasis application");
 		return NULL;
@@ -84,16 +92,7 @@
 
 	control = stasis_app_control_find_by_channel_id(channel_id);
 	if (control == NULL) {
-		/* Distinguish between 404 and 409 errors */
-		RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
-		chan = ast_channel_get_by_name(channel_id);
-		if (chan == NULL) {
-			stasis_http_response_error(response, 404, "Not Found",
-				"Channel not found");
-			return NULL;
-		}
-
-		stasis_http_response_error(response, 409, "Conflict",
+		stasis_http_response_error(response, 422, "Unprocessable Entity",
 			"Channel not in Stasis application");
 		return NULL;
 	}
@@ -106,7 +105,6 @@
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
-	struct ast_channel *channel;
 	if (!bridge) {
 		return;
 	}
@@ -116,13 +114,6 @@
 		return;
 	}
 
-	channel = ast_channel_get_by_name(args->channel);
-	if (!channel) {
-		stasis_http_response_error(response, 404, "Not Found",
-			"Could not acquire channel structure");
-		return;
-	}
-
 	stasis_app_control_add_channel_to_bridge(control, bridge);
 	stasis_http_response_no_content(response);
 }
@@ -131,7 +122,6 @@
 {
 	RAII_VAR(struct ast_bridge *, bridge, find_bridge(response, args->bridge_id), ao2_cleanup);
 	RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
-	struct ast_channel *channel;
 	if (!bridge) {
 		return;
 	}
@@ -141,14 +131,10 @@
 		return;
 	}
 
-	/* channel reference is consumed by the remove channel call */
-	channel = ast_channel_get_by_name(args->channel);
-	if (!channel) {
-		stasis_http_response_error(response, 404, "Not Found",
-			"Could not acquire channel structure");
-		return;
-	}
-
+	/* BUGBUG this should make sure the bridge requested for removal is actually
+	 * the bridge the channel is in. This will be possible once the bridge uniqueid
+	 * is added to the channel snapshot. A 409 response should be issued if the bridge
+	 * uniqueids don't match */
 	if (stasis_app_control_remove_channel_from_bridge(control, bridge)) {
 		stasis_http_response_error(response, 500, "Internal Error",
 			"Could not remove channel from bridge");
@@ -242,21 +228,14 @@
 		return;
 	}
 
-	snapshot = ast_bridge_snapshot_get_latest(bridge->uniqueid);
-	if (snapshot) {
-		stasis_http_response_ok(response,
-			ast_bridge_snapshot_to_json(snapshot));
-		return;
-	}
-
 	snapshot = ast_bridge_snapshot_create(bridge);
-	if (snapshot) {
-		stasis_http_response_ok(response,
-			ast_bridge_snapshot_to_json(snapshot));
-		return;
-	}
-
-	stasis_http_response_error(
-		response, 500, "Internal Error",
-		"Unable to get snapshot for new bridge");
-}
+	if (!snapshot) {
+		stasis_http_response_error(
+			response, 500, "Internal Error",
+			"Unable to create snapshot for new bridge");
+		return;
+	}
+
+	stasis_http_response_ok(response,
+		ast_bridge_snapshot_to_json(snapshot));
+}




More information about the asterisk-commits mailing list