[svn-commits] jrose: branch jrose/bridge_projects r383912 - in /team/jrose/bridge_projects:...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Mar 26 11:25:07 CDT 2013
Author: jrose
Date: Tue Mar 26 11:25:04 2013
New Revision: 383912
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383912
Log:
More docs, AMI + stasis stuff restored, ParkedCallGiveUp, and others.
Added:
team/jrose/bridge_projects/configs/res_parking.conf.sample (with props)
Modified:
team/jrose/bridge_projects/CHANGES
team/jrose/bridge_projects/include/asterisk/_private.h
team/jrose/bridge_projects/res/parking/parking_applications.c
team/jrose/bridge_projects/res/parking/parking_controller.c
team/jrose/bridge_projects/res/parking/parking_manager.c
team/jrose/bridge_projects/res/parking/res_parking.h
Modified: team/jrose/bridge_projects/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/CHANGES?view=diff&rev=383912&r1=383911&r2=383912
==============================================================================
--- team/jrose/bridge_projects/CHANGES (original)
+++ team/jrose/bridge_projects/CHANGES Tue Mar 26 11:25:04 2013
@@ -145,6 +145,13 @@
* PARKING_SPACE and PARKEDLOT channel variables will now be set for a parked
channel even when comebactoorigin=yes
+
+ * New CLI command 'parking show' allows you to inspect the currently in use
+ parking lots. 'parking show <parkinglot>' will also show the parked calls
+ in that specific parking lot.
+
+ * The CLI command 'parkedcalls' is now deprecated in favor of
+ 'parking show <parkinglot>'.
Queue
-------------------
Added: team/jrose/bridge_projects/configs/res_parking.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/configs/res_parking.conf.sample?view=auto&rev=383912
==============================================================================
--- team/jrose/bridge_projects/configs/res_parking.conf.sample (added)
+++ team/jrose/bridge_projects/configs/res_parking.conf.sample Tue Mar 26 11:25:04 2013
@@ -1,0 +1,48 @@
+[general]
+;parkeddynamic = yes ; Enables dynamically created parkinglots. (default is no)
+
+
+; A parking lot named 'default' will automatically be used when no other
+; named parking lot is indicated for use by the park application or a
+; channel's parkinglot function and PARKINGLOT channel variable.
+
+[default] ; based on the old default from features.conf.sample
+parkext => 700
+;parket_exclusive=yes
+parkpos => 701-720
+context => parkedcalls
+;parkinghints = no
+;parkingtime => 45
+;comebacktoorigin = yes
+;comebackdialtime = 30
+;comebackcontext = parkedcallstimeout
+;courtesytone = beep
+;parkedplay = caller
+;parkedcalltransfers = caller
+;parkedcallreparking = caller
+;parkedcallhangup = caller
+;findslot => next
+;parkedmusicclass = default
+
+; Parking lots can now be any named configuration category aside from
+; 'general' which is reserved for general options.
+;
+; You can set parkinglot with the CHANNEL dialplan function or by setting
+; 'parkinglot' directly in the channel configuration file.
+;
+; (Note: Leading '0's and any non-numerical characters on parkpos
+; extensions will be ignored. Parkext on the other hand can be any string.)
+;
+;[edvina2]
+;context => edvina2_park
+;parkpos => 800-850
+;findslot => next
+;comebacktoorigin = no
+;comebackdialtime = 90
+;comebackcontext = edvina2_park-timeout
+;parkedmusicclass = edvina
+;
+; Since edvina2 doesn't define parkext, extensions won't automatically be
+; created for parking to it or for retrieving calls from it. These can be
+; created manually in the dial plan by using the Park and ParkedCall
+; applications.
Propchange: team/jrose/bridge_projects/configs/res_parking.conf.sample
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jrose/bridge_projects/configs/res_parking.conf.sample
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jrose/bridge_projects/configs/res_parking.conf.sample
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/jrose/bridge_projects/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/_private.h?view=diff&rev=383912&r1=383911&r2=383912
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/_private.h (original)
+++ team/jrose/bridge_projects/include/asterisk/_private.h Tue Mar 26 11:25:04 2013
@@ -23,7 +23,6 @@
int ast_term_init(void); /*!< Provided by term.c */
int astdb_init(void); /*!< Provided by db.c */
void ast_channels_init(void); /*!< Provided by channel.c */
-void ast_parking_init(void); /*!< Provided by parking.c */
void ast_builtins_init(void); /*!< Provided by cli.c */
int ast_cli_perms_init(int reload); /*!< Provided by cli.c */
int dnsmgr_init(void); /*!< Provided by dnsmgr.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=383912&r1=383911&r2=383912
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_applications.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_applications.c Tue Mar 26 11:25:04 2013
@@ -216,11 +216,16 @@
/* Alright, now wait in the holding bridge until we get removed from it for some reason. */
reset_parked_time(pu);
ast_bridge_join(parking_bridge, chan, NULL, &chan_features, NULL, 0);
- /* XXX After this, depending on the conditions of exit we might want to return early. But that comes later. */
-
+
+ /* At this point the channel is no longer in the bridge. Start breaking things down. */
ast_bridge_features_cleanup(&chan_features);
- /* Remove the parked user from the parking lot if it is still in */
+ /* If the parked channel exits without a resolution set, it gave up. Issue a ParkedCallGiveUp message. */
+ if (pu->resolution == PARK_UNSET) {
+ pu->resolution = PARK_ABANDON;
+ publish_parked_call(pu, PARKED_CALL_GIVEUP);
+ }
+
unpark_parked_user(pu);
/* Figure out if we need to go somewhere special now that the timeout has occured */
Modified: team/jrose/bridge_projects/res/parking/parking_controller.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_controller.c?view=diff&rev=383912&r1=383911&r2=383912
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_controller.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_controller.c Tue Mar 26 11:25:04 2013
@@ -80,6 +80,22 @@
static int parking_duration_callback(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
{
struct parked_user *user = hook_pvt;
+ struct ast_channel *chan = user->chan;
+ char *peername;
+ char *dash;
+ char parking_space[AST_MAX_EXTENSION];
+
+ /* We are still in the bridge, so it's possible for other stuff to mess with the parked call before we leave the bridge
+ to deal with this, lock the parked user, check and set resolution. */
+ ao2_lock(user);
+ if (user->resolution != PARK_UNSET) {
+ /* Abandon timeout since something else has resolved the parked user before we got to it. */
+ ao2_unlock(user);
+ return 0;
+ }
+
+ user->resolution = PARK_TIMEOUT;
+ ao2_unlock(user);
ao2_lock(bridge_channel);
switch (bridge_channel->state) {
@@ -91,11 +107,21 @@
}
ao2_unlock(bridge_channel);
- /* Replace this with a more relevant event */
- ast_test_suite_event_notify("BRIDGE_TIMELIMIT", "Channel1: %s", ast_channel_name(bridge_channel->chan));
+ /* Set parking timeout channel variables */
+ snprintf(parking_space, sizeof(parking_space), "%d", user->parking_space);
+ pbx_builtin_setvar_helper(chan, "PARKING_SPACE", parking_space);
+ pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parking_space); /* Deprecated version of PARKING_SPACE */
+ pbx_builtin_setvar_helper(chan, "PARKEDLOT", user->lot_state->name);
+
+ peername = ast_strdupa(user->parker->name);
+ dash = strrchr(peername, '-');
+ if (dash) {
+ *dash = '\0';
+ }
+
+ pbx_builtin_setvar_helper(chan, "PARKER", peername);
/* Set the resolution for the user to timeout */
- user->resolution = PARK_TIMEOUT;
publish_parked_call(user, PARKED_CALL_TIMEOUT);
return -1;
@@ -256,12 +282,14 @@
if (ast_exists_extension(chan, lot_state->comebackcontext, peername, 1, NULL)) {
set_c_e_p(chan, lot_state->comebackcontext, peername, 1);
+ return 0;
}
if (ast_exists_extension(chan, lot_state->comebackcontext, "s", 1, NULL)) {
ast_verb(2, "Could not start %s at %s,%s,1. Using 's@%s' instead.\n", ast_channel_name(chan),
lot_state->comebackcontext, peername, lot_state->comebackcontext);
set_c_e_p(chan, lot_state->comebackcontext, "s", 1);
+ return 0;
}
ast_verb(2, "Can not start %s at %s,%s,1 and exten 's@%s' does not exist. Using 's at default'\n",
Modified: team/jrose/bridge_projects/res/parking/parking_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_manager.c?view=diff&rev=383912&r1=383911&r2=383912
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_manager.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_manager.c Tue Mar 26 11:25:04 2013
@@ -69,6 +69,9 @@
/*! \brief Topic for parking lots */
static struct stasis_topic *parking_topic;
+/*! \brief subscription to the parking lot topic */
+static struct stasis_subscription *parking_sub;
+
/*!
* \brief A parked call message payload
* \since 12
@@ -95,6 +98,7 @@
ast_string_field_free_memory(park_obj);
}
+/*! \brief Constructor for parked_call_payload objects */
static struct parked_call_payload *parked_call_payload_create(struct parked_user *pu, enum parked_call_event_type event_type)
{
struct parked_call_payload *payload;
@@ -139,7 +143,8 @@
return payload;
}
-static struct ast_str *manager_build_parkedcall_string(const struct parked_call_payload *payload)
+/*! \brief Builds a manager string based on the contents of a parked call payload */
+static struct ast_str *manager_build_parked_call_string(const struct parked_call_payload *payload)
{
struct ast_str *out = ast_str_create(1024);
int res = 0;
@@ -203,16 +208,16 @@
iter_users = ao2_iterator_init(curlot->parked_user_list, 0);
while ((curuser = ao2_iterator_next(&iter_users))) {
RAII_VAR(struct parked_call_payload *, payload, NULL, ao2_cleanup);
- RAII_VAR(struct ast_str *, parkedcall_string, NULL, ast_free);
+ RAII_VAR(struct ast_str *, parked_call_string, NULL, ast_free);
payload = parked_call_payload_create(curuser, PARKED_CALL);
- parkedcall_string = manager_build_parkedcall_string(payload);
+ parked_call_string = manager_build_parked_call_string(payload);
total++;
astman_append(s, "Event: ParkedCall\r\n"
"%s" /* The parked call string */
"%s" /* The action ID */
"\r\n",
- ast_str_buffer(parkedcall_string),
+ ast_str_buffer(parked_call_string),
id_text);
ao2_ref(curuser, -1);
@@ -295,12 +300,49 @@
}
if (pu->chan) {
- stasis_publish(ast_channel_topic(pu->chan), msg);
+ stasis_publish(parking_topic, msg);
+ }
+}
+
+static void parked_call_message_response(struct parked_call_payload *parked_call)
+{
+ char *event_type;
+ RAII_VAR(struct ast_str *, parked_call_string, NULL, ast_free);
+
+ switch (parked_call->event_type) {
+ case PARKED_CALL:
+ event_type = "ParkedCall";
+ break;
+ case PARKED_CALL_TIMEOUT:
+ event_type = "ParkedCallTimeOut";
+ break;
+ case PARKED_CALL_GIVEUP:
+ event_type = "ParkedCallGiveUp";
+ break;
+ case PARKED_CALL_UNPARKED:
+ event_type = "UnParkedCall";
+ break;
+ }
+
+ parked_call_string = manager_build_parked_call_string(parked_call);
+
+ manager_event(EVENT_FLAG_DIALPLAN, event_type,
+ "%s",
+ ast_str_buffer(parked_call_string)
+ );
+}
+
+static void parking_event_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message)
+{
+ if (stasis_message_type(message) == parked_call_message_type) {
+ struct parked_call_payload *parked_call_message = stasis_message_data(message);
+ parked_call_message_response(parked_call_message);
}
}
static void parking_manager_disable_stasis(void)
{
+ parking_sub = stasis_unsubscribe(parking_sub);
ao2_cleanup(parked_call_message_type);
ao2_cleanup(parking_topic);
parked_call_message_type = NULL;
@@ -317,6 +359,10 @@
parked_call_message_type = stasis_message_type_create("parked_call");
parking_topic = stasis_topic_create("ast_parking_topic");
+ if (!parking_sub) {
+ parking_sub = stasis_subscribe(parking_topic, parking_event_cb, NULL);
+ }
+
return res ? -1 : 0;
}
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=383912&r1=383911&r2=383912
==============================================================================
--- team/jrose/bridge_projects/res/parking/res_parking.h (original)
+++ team/jrose/bridge_projects/res/parking/res_parking.h Tue Mar 26 11:25:04 2013
@@ -143,7 +143,7 @@
char exten[AST_MAX_CONTEXT]; /*!< Where to go on parking timeout (extension) */
unsigned int time_limit; /*!< How long this specific channel may remain in the parking lot before timing out */
struct parking_lot_state *lot_state; /*!< Which parking lot the user is parked to */
- enum park_call_resolution resolution; /*!< How did the parking session end? */
+ enum park_call_resolution resolution; /*!< How did the parking session end? If the call is in a bridge, lock parked_user before checking/setting */
};
/*!
More information about the svn-commits
mailing list