[asterisk-commits] jrose: branch jrose/bridge_projects r385818 - in /team/jrose/bridge_projects/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 15 15:58:44 CDT 2013


Author: jrose
Date: Mon Apr 15 15:58:41 2013
New Revision: 385818

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385818
Log:
Change how the parking lot is found for a channel when the name of a parking lot isn't explicitly stated in args.

Modified:
    team/jrose/bridge_projects/res/parking/parking_applications.c
    team/jrose/bridge_projects/res/parking/res_parking.h
    team/jrose/bridge_projects/res/res_parking.c

Modified: team/jrose/bridge_projects/res/parking/parking_applications.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_applications.c?view=diff&rev=385818&r1=385817&r2=385818
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_applications.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_applications.c Mon Apr 15 15:58:41 2013
@@ -225,30 +225,33 @@
 	int use_ringing = 0;
 	int randomize = 0;
 	int time_limit = -1;
-	int find_lot_mode = 0;
 	RAII_VAR(char *, comeback_override, NULL, ast_free);
-	RAII_VAR(char *, lot_name, NULL, ast_free);
+	RAII_VAR(char *, lot_name_app_arg, NULL, ast_free);
+	char *lot_name;
 
 	/* parse the app data if we have it */
 	if (app_data) {
-		park_app_parse_data(app_data, &silence_announcements, &use_ringing, &randomize, &time_limit, &comeback_override, &lot_name);
-	}
-
-	/* Now find out which parking lot_state we want to park it into. */
+		park_app_parse_data(app_data, &silence_announcements, &use_ringing, &randomize, &time_limit, &comeback_override, &lot_name_app_arg);
+	}
+
+	lot_name = lot_name_app_arg;
+
+	/* If the name of the aprking lot isn't specified in the arguments, find it based on the channel. */
 	if (ast_strlen_zero(lot_name)) {
-		*lot_state = channel_find_parking_lot_state(parker);
-	} else {
-		*lot_state = parking_lot_state_find_by_name(lot_name);
-		find_lot_mode = 1;
-	}
+		ast_channel_lock(parker);
+		lot_name = ast_strdupa(find_channel_parking_lot_name(parker));
+		ast_channel_unlock(parker);
+
+		/* If the name couldn't be pulled from that either, use the default parking lot name. */
+		if (ast_strlen_zero(lot_name)) {
+			lot_name = DEFAULT_PARKING_LOT;
+		}
+	}
+
+	*lot_state = parking_lot_state_find_by_name(lot_name);
 
 	if (!*lot_state) {
-		if (find_lot_mode) {
-			ast_log(LOG_ERROR, "Could not find requested parking lot: '%s'\n", lot_name);
-		} else {
-			ast_log(LOG_ERROR, "Could not find parking lot specified by channel variable PARKINGLOT "
-				"(or 'default' if that variable does not exist for channel '%s')\n", ast_channel_name(parker));
-		}
+		ast_log(LOG_ERROR, "Could not find parking lot: '%s'\n", lot_name);
 		ast_stream_and_wait(parker, "pbx-parkingfailed", "");
 		return -1;
 	}
@@ -287,6 +290,25 @@
 	return 0;
 }
 
+/* XXX BUGBUG - determining the parker when transferred to deep park priority
+ *     Currently all parking by the park application is treated as calls parking themselves.
+ *     However, it's possible for calls to be transferred here when the Park application is
+ *     set after the first priority of an extension. In that case, there used to be a variable
+ *     (BLINDTRANSFER) set indicating which channel placed that call here, but that channel may
+ *     be gone already by the time the application executes, so just knowing the name of that
+ *     channel won't be enough.
+ *
+ *     It will be necessary to find a way to handle that for the purpose of comebacktoorigin
+ *     on parked call timeouts as well as for generating proper Parker information in stasis.
+ *     One way to do this might be to store a snapshot of the transferer on the channel when
+ *     performing transfers. Then if the parker is the same as the parkee when calling
+ *     park_common_setup, the parkee's channel can be checked for that snapshot and then
+ *     referenced accordingly. Alternatively, this could simply be left as is and the parkee
+ *     could just be treated as the parkee (in many ways in these scenarios, the parkee really
+ *     is parking itself since the channel that transferred isn't really involved in executing
+ *     the park at this point) and the BLINDTRASFER variable could just be used as data for
+ *     generating the comebacktoorigin location and extensions.
+ */
 int park_app_exec(struct ast_channel *chan, const char *data)
 {
 	RAII_VAR(struct parking_lot_state *, lot_state, NULL, ao2_cleanup);
@@ -344,6 +366,7 @@
 	int target_space = -1;
 	struct ast_bridge_features chan_features;
 	char *parse;
+	char *lot_name;
 
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(lot_name);
@@ -359,12 +382,22 @@
 		ast_answer(chan);
 	}
 
-	/* Figure out which parking lot we should be retrieving from and if it exists. */
-	if (ast_strlen_zero(args.lot_name)) {
-		lot_state = channel_find_parking_lot_state(chan);
-	} else {
-		lot_state = parking_lot_state_find_by_name(args.lot_name);
-	}
+	lot_name = args.lot_name;
+
+	/* If the name of the aprking lot isn't in the arguments, find it based on the channel. */
+	if (ast_strlen_zero(lot_name)) {
+		ast_channel_lock(chan);
+		lot_name = ast_strdupa(find_channel_parking_lot_name(chan));
+		ast_channel_unlock(chan);
+	}
+
+	/* If the name couldn't be pulled from that either, use the default parking lot name. */
+	if (ast_strlen_zero(lot_name)) {
+		lot_name = DEFAULT_PARKING_LOT;
+	}
+
+	lot_state = parking_lot_state_find_by_name(lot_name);
+
 	if (!lot_state) {
 		ast_log(LOG_ERROR, "Could not find the requested parking lot\n");
 		ast_stream_and_wait(chan, "pbx-invalidpark", "");

Modified: team/jrose/bridge_projects/res/parking/res_parking.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/res_parking.h?view=diff&rev=385818&r1=385817&r2=385818
==============================================================================
--- team/jrose/bridge_projects/res/parking/res_parking.h (original)
+++ team/jrose/bridge_projects/res/parking/res_parking.h Mon Apr 15 15:58:41 2013
@@ -261,17 +261,16 @@
 
 /*!
  * \since 12
- * \brief Get the parking lot state that a channel should be parked in
- *
- * \param chan Channel which a parking lot state is sought for
- *
- * \retval The parking lot state that the channel should go into
- * \retval NULL if the parking lot state that the channel is designated to
- *         enter does not exist or can not accept parking lots
- *
- * \note ao2_cleanup this reference when you are done using it or you'll cause leaks.
- */
-struct parking_lot_state *channel_find_parking_lot_state(struct ast_channel *chan);
+ * \brief Find parking lot name from channel
+ *
+ * \param chan The channel we want the parking lot name for
+ *
+ * \retval name of the parking lot if it is defined
+ * \retval NULL if the parking lot is not defined.
+ *
+ * \note Channel needs to be locked while the returned string is in use.
+ */
+const char *find_channel_parking_lot_name(struct ast_channel *chan);
 
 /*!
  * \since 12

Modified: team/jrose/bridge_projects/res/res_parking.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/res_parking.c?view=diff&rev=385818&r1=385817&r2=385818
==============================================================================
--- team/jrose/bridge_projects/res/res_parking.c (original)
+++ team/jrose/bridge_projects/res/res_parking.c Mon Apr 15 15:58:41 2013
@@ -545,23 +545,17 @@
 	return lot;
 }
 
-struct parking_lot_state *channel_find_parking_lot_state(struct ast_channel *chan)
-{
-	struct parking_lot_state *lot;
+const char *find_channel_parking_lot_name(struct ast_channel *chan)
+{
 	const char *name;
 
 	/* The channel variable overrides everything */
-	ast_channel_lock(chan);
 	name = pbx_builtin_getvar_helper(chan, "PARKINGLOT");
-
-	if (ast_strlen_zero(name)) {
-		name = S_OR(ast_channel_parkinglot(chan), DEFAULT_PARKING_LOT);
-	}
-	ast_channel_unlock(chan);
-
-	lot = named_item_find(parking_lot_state_container, name);
-
-	return lot;
+	if (!name && !ast_strlen_zero(ast_channel_parkinglot(chan))) {
+		/* Use the channel's parking lot. */
+		name = ast_channel_parkinglot(chan);
+	}
+	return name;
 }
 
 static void parking_lot_state_destructor(void *obj)




More information about the asterisk-commits mailing list