summaryrefslogtreecommitdiff
path: root/main/parking.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-08-01 20:55:17 +0000
committerMatthew Jordan <mjordan@digium.com>2013-08-01 20:55:17 +0000
commit5c4b482471edb8a839d754dd654dc72605caac66 (patch)
treed164a3ebd03e7101a39929283b75d2318a2f6761 /main/parking.c
parentc8a91b5b013c568f3f99e8fb7abc662775c60520 (diff)
Support externally initiated parking requests; remove some dead code
This patch does the following: * It adds support for externally initiated parking requests. In particular, chan_skinny has a protocol level message that initiates a call park. This patch now supports that option, as well as the protocol specific mechanisms in chan_dahdi/sig_analog and chan_mgcp. * A parking bridge features virtual table has been added that provides access to the parking functionality that the Bridging API needs. This includes requests to park an entire 'call' (with little or no additional information, thank you chan_skinny), perform a blind transfer to a parking extension, determine if an extension is a parking extension, as well as the actual "do the parking" request from the Bridging API. * Refactoring in chan_mgcp, chan_skinny, and chan_dahdi to make use of the new functions * The removal of some - but not all - dead parking code from features.c This also fixed blind transferring a multi-party bridge to a parking lot (which was implemented, but had at least one code path where using the parking features kK might not have worked) Review: https://reviewboard.asterisk.org/r/2710 (closes issue ASTERISK-22134) Reported by: Matt Jordan git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396028 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/parking.c')
-rw-r--r--main/parking.c88
1 files changed, 38 insertions, 50 deletions
diff --git a/main/parking.c b/main/parking.c
index 710a3c8c7..83c599ba0 100644
--- a/main/parking.c
+++ b/main/parking.c
@@ -41,11 +41,8 @@ STASIS_MESSAGE_TYPE_DEFN(ast_parked_call_type);
/*! \brief Topic for parking lots */
static struct stasis_topic *parking_topic;
-/*! \brief Function Callback for handling blind transfers to park applications */
-static ast_park_blind_xfer_fn ast_park_blind_xfer_func = NULL;
-
-/*! \brief Function Callback for handling a bridge channel trying to park itself */
-static ast_bridge_channel_park_fn ast_bridge_channel_park_func = NULL;
+/*! \brief The container for the parking provider */
+static AO2_GLOBAL_OBJ_STATIC(parking_provider);
static void parking_stasis_cleanup(void)
{
@@ -127,67 +124,58 @@ struct ast_parked_call_payload *ast_parked_call_payload_create(enum ast_parked_c
return payload;
}
-void ast_install_park_blind_xfer_func(ast_park_blind_xfer_fn park_blind_xfer_func)
-{
- ast_park_blind_xfer_func = park_blind_xfer_func;
-}
-
-void ast_install_bridge_channel_park_func(ast_bridge_channel_park_fn bridge_channel_park_func)
+struct ast_parking_bridge_feature_fn_table *ast_parking_get_bridge_features(void)
{
- ast_bridge_channel_park_func = bridge_channel_park_func;
+ return (struct ast_parking_bridge_feature_fn_table*)ao2_global_obj_ref(parking_provider);
}
-void ast_uninstall_park_blind_xfer_func(void)
-{
- ast_park_blind_xfer_func = NULL;
-}
+/*! \brief A wrapper around the fn_table to ao2-ify it */
+struct parking_provider_wrapper {
+ struct ast_parking_bridge_feature_fn_table fn_table;
+};
-void ast_uninstall_bridge_channel_park_func(void)
+int ast_parking_register_bridge_features(struct ast_parking_bridge_feature_fn_table *fn_table)
{
- ast_bridge_channel_park_func = NULL;
-}
+ RAII_VAR(struct parking_provider_wrapper *, wrapper,
+ ao2_global_obj_ref(parking_provider), ao2_cleanup);
-int ast_park_blind_xfer(struct ast_bridge_channel *parker, struct ast_exten *park_exten)
-{
- static int warned = 0;
+ if (fn_table->module_version != PARKING_MODULE_VERSION) {
+ ast_log(AST_LOG_WARNING, "Parking module provided incorrect parking module "
+ "version: %d (expected: %d)\n", fn_table->module_version, PARKING_MODULE_VERSION);
+ return -1;
+ }
- if (ast_park_blind_xfer_func) {
- return ast_park_blind_xfer_func(parker, park_exten);
+ if (wrapper) {
+ ast_log(AST_LOG_WARNING, "Parking provider already registered by %s!\n",
+ wrapper->fn_table.module_name);
+ return -1;
}
- if (warned++ % 10 == 0) {
- ast_verb(3, "%s attempted to blind transfer to a parking extension, but no parking blind transfer function is loaded.\n",
- ast_channel_name(parker->chan));
+ wrapper = ao2_alloc(sizeof(*wrapper), NULL);
+ if (!wrapper) {
+ return -1;
}
+ wrapper->fn_table = *fn_table;
- return -1;
+ ao2_global_obj_replace(parking_provider, wrapper);
+ return 0;
}
-struct ast_exten *ast_get_parking_exten(const char *exten_str, struct ast_channel *chan, const char *context)
+int ast_parking_unregister_bridge_features(const char *module_name)
{
- struct ast_exten *exten;
- struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
- const char *app_at_exten;
-
- ast_debug(4, "Checking if %s@%s is a parking exten\n", exten_str, context);
- exten = pbx_find_extension(chan, NULL, &q, context, exten_str, 1, NULL, NULL,
- E_MATCH);
- if (!exten) {
- return NULL;
- }
+ RAII_VAR(struct parking_provider_wrapper *, wrapper,
+ ao2_global_obj_ref(parking_provider), ao2_cleanup);
- app_at_exten = ast_get_extension_app(exten);
- if (!app_at_exten || strcasecmp(PARK_APPLICATION, app_at_exten)) {
- return NULL;
+ if (!wrapper) {
+ ast_log(AST_LOG_WARNING, "No parking provider to unregister\n");
+ return -1;
}
- return exten;
-}
-
-void ast_bridge_channel_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
-{
- /* Run installable function */
- if (ast_bridge_channel_park_func) {
- return ast_bridge_channel_park_func(bridge_channel, parkee_uuid, parker_uuid, app_data);
+ if (strcmp(wrapper->fn_table.module_name, module_name)) {
+ ast_log(AST_LOG_WARNING, "%s has not registered the parking provider\n", module_name);
+ return -1;
}
+
+ ao2_global_obj_replace_unref(parking_provider, NULL);
+ return 0;
}