Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Functions | Variables
parking_bridge_features.c File Reference

Parking Bridge DTMF and Interval features. More...

#include "asterisk.h"
#include "res_parking.h"
#include "asterisk/utils.h"
#include "asterisk/astobj2.h"
#include "asterisk/logger.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_internal.h"
#include "asterisk/bridge_channel.h"
#include "asterisk/bridge_features.h"
#include "asterisk/conversions.h"
#include "asterisk/features.h"
#include "asterisk/say.h"
#include "asterisk/datastore.h"
#include "asterisk/stasis.h"
#include "asterisk/module.h"
#include "asterisk/core_local.h"
#include "asterisk/causes.h"

Go to the source code of this file.

Data Structures

struct  parked_subscription_data
 
struct  parked_subscription_datastore
 

Functions

int create_parked_subscription (struct ast_channel *chan, const char *parkee_uuid, int hangup_after)
 Create a parking announcement subscription. More...
 
static int create_parked_subscription_full (struct ast_channel *chan, const char *parkee_uuid, int hangup_after, struct transfer_channel_data *parked_channel_data)
 
static int feature_park_call (struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 
static int func_get_parkingslot_channel (struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
 Dial plan function to get the parking lot channel of an occupied parking lot.
 
int load_parking_bridge_features (void)
 Register bridge features for parking. More...
 
static struct ast_channelpark_local_transfer (struct ast_channel *parker, const char *context, const char *exten, struct transfer_channel_data *parked_channel_data)
 
static void parked_subscription_datastore_destroy (void *data)
 
static void parker_parked_call_message_response (struct ast_parked_call_payload *message, struct parked_subscription_data *data, struct stasis_subscription *sub)
 
static void parker_update_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
 
static int parking_blind_transfer_park (struct ast_bridge_channel *bridge_channel, const char *context, const char *exten, transfer_channel_cb parked_channel_cb, struct transfer_channel_data *parked_channel_data)
 
static int parking_duration_callback (struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 
static int parking_is_exten_park (const char *context, const char *exten)
 
static int parking_park_bridge_channel (struct ast_bridge_channel *bridge_channel, const char *uuid_parkee, const char *uuid_parker, const char *app_data)
 
static int parking_park_call (struct ast_bridge_channel *parker, char *exten, size_t length)
 
void parking_set_duration (struct ast_bridge_features *features, struct parked_user *user)
 Setup timeout interval feature on an ast_bridge_features for parking. More...
 
static void parking_timeout_set_caller_features (struct ast_channel *chan, struct parking_lot_cfg *cfg)
 
void say_parking_space (struct ast_bridge_channel *bridge_channel, const char *payload)
 custom callback function for ast_bridge_channel_queue_playfile which plays a parking space and optionally hangs up the call afterwards based on the payload in playfile. More...
 
void unload_parking_bridge_features (void)
 Unregister features registered by load_parking_bridge_features. More...
 
static void wipe_subscription_datastore (struct ast_channel *chan)
 

Variables

static struct ast_custom_function getparkingslotchannel_function
 
static const struct ast_datastore_info parked_subscription_info
 
struct ast_parking_bridge_feature_fn_table parking_provider
 

Detailed Description

Parking Bridge DTMF and Interval features.

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file parking_bridge_features.c.

Function Documentation

int create_parked_subscription ( struct ast_channel chan,
const char *  parkee_uuid,
int  hangup_after 
)

Create a parking announcement subscription.

Since
12.3.0
Parameters
chanChannel that will receive the announcement
parkee_uuidUnique ID of the channel being parked
hangup_afterif non-zero, have the channel hangup after hearing the announcement
Return values
0on success
-1on failure

Definition at line 233 of file parking_bridge_features.c.

234 {
235  return create_parked_subscription_full(chan, parkee_uuid, hangup_after, NULL);
236 }
int load_parking_bridge_features ( void  )

Register bridge features for parking.

Since
12.0.0
Return values
0on success
-1on failure

Definition at line 800 of file parking_bridge_features.c.

References AST_BRIDGE_BUILTIN_PARKCALL, ast_bridge_features_register(), ast_custom_function_register, ast_parking_register_bridge_features(), and ast_parking_bridge_feature_fn_table::module.

801 {
802  parking_provider.module = AST_MODULE_SELF;
803 
804  ast_custom_function_register(&getparkingslotchannel_function);
805 
806  if (ast_parking_register_bridge_features(&parking_provider)) {
807  return -1;
808  }
809 
810  if (ast_bridge_features_register(AST_BRIDGE_BUILTIN_PARKCALL, feature_park_call, NULL)) {
811  return -1;
812  }
813 
814  return 0;
815 }
int ast_parking_register_bridge_features(struct ast_parking_bridge_feature_fn_table *fn_table)
Register a parking provider.
Definition: parking.c:196
struct ast_module * module
The module info for the module registering this parking provider.
Definition: parking.h:202
int ast_bridge_features_register(enum ast_bridge_builtin_feature feature, ast_bridge_hook_callback callback, const char *dtmf)
Register a handler for a built in feature.
Definition: bridge.c:3062
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
void parking_set_duration ( struct ast_bridge_features features,
struct parked_user user 
)

Setup timeout interval feature on an ast_bridge_features for parking.

Since
12.0.0
Parameters
featuresThe ast_bridge_features we are establishing the interval hook on
userThe parked_user receiving the timeout duration limits

Definition at line 703 of file parking_bridge_features.c.

References __ao2_cleanup(), ao2_ref, AST_BRIDGE_HOOK_REMOVE_ON_PULL, ast_bridge_interval_hook(), ast_remaining_ms(), parked_user::start, and parked_user::time_limit.

704 {
705  unsigned int time_limit;
706 
707  time_limit = user->time_limit * 1000;
708 
709  if (!time_limit) {
710  /* There is no duration limit that we need to apply. */
711  return;
712  }
713 
714  /* If the time limit has already been passed, set a really low time limit so we can kick them out immediately. */
715  time_limit = ast_remaining_ms(user->start, time_limit);
716  if (time_limit <= 0) {
717  time_limit = 1;
718  }
719 
720  /* The interval hook is going to need a reference to the parked_user */
721  ao2_ref(user, +1);
722 
723  if (ast_bridge_interval_hook(features, 0, time_limit,
724  parking_duration_callback, user, __ao2_cleanup, AST_BRIDGE_HOOK_REMOVE_ON_PULL)) {
725  ast_log(LOG_ERROR, "Failed to apply duration limit to the parked call.\n");
726  ao2_ref(user, -1);
727  }
728 }
void __ao2_cleanup(void *obj)
Definition: astobj2.c:677
unsigned int time_limit
Definition: res_parking.h:110
struct timeval start
Definition: res_parking.h:106
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
int ast_bridge_interval_hook(struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach an interval hook to a bridge features structure.
Definition: bridge.c:3319
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
void say_parking_space ( struct ast_bridge_channel bridge_channel,
const char *  payload 
)

custom callback function for ast_bridge_channel_queue_playfile which plays a parking space and optionally hangs up the call afterwards based on the payload in playfile.

Since
12.0.0

Definition at line 681 of file parking_bridge_features.c.

References ast_bridge_channel_leave_bridge(), ast_say_digits(), BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, and ast_bridge_channel::chan.

682 {
683  unsigned int numeric_value;
684  unsigned int hangup_after;
685 
686  if (sscanf(payload, "%u %u", &hangup_after, &numeric_value) != 2) {
687  /* If say_parking_space is called with a non-numeric string, we have a problem. */
688  ast_assert(0);
689  ast_bridge_channel_leave_bridge(bridge_channel,
690  BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, AST_CAUSE_NORMAL_CLEARING);
691  return;
692  }
693 
694  ast_say_digits(bridge_channel->chan, numeric_value, "",
695  ast_channel_language(bridge_channel->chan));
696 
697  if (hangup_after) {
698  ast_bridge_channel_leave_bridge(bridge_channel,
699  BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, AST_CAUSE_NORMAL_CLEARING);
700  }
701 }
int ast_say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang)
says digits
Definition: channel.c:8253
void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
Set bridge channel state to leave bridge (if not leaving already).
struct ast_channel * chan
void unload_parking_bridge_features ( void  )

Unregister features registered by load_parking_bridge_features.

Since
12.0.0

Definition at line 793 of file parking_bridge_features.c.

References AST_BRIDGE_BUILTIN_PARKCALL, ast_bridge_features_unregister(), ast_custom_function_unregister(), ast_parking_unregister_bridge_features(), and ast_parking_bridge_feature_fn_table::module_name.

794 {
797  ast_custom_function_unregister(&getparkingslotchannel_function);
798 }
const char * module_name
The name of the module that provides this parking functionality.
Definition: parking.h:139
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature)
Unregister a handler for a built in feature.
Definition: bridge.c:3078
int ast_parking_unregister_bridge_features(const char *module_name)
Unregister the current parking provider.
Definition: parking.c:223

Variable Documentation

struct ast_custom_function getparkingslotchannel_function
static
Initial value:
= {
.name = "PARK_GET_CHANNEL",
}
static int func_get_parkingslot_channel(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Dial plan function to get the parking lot channel of an occupied parking lot.

Definition at line 779 of file parking_bridge_features.c.

const struct ast_datastore_info parked_subscription_info
static
Initial value:
= {
.type = "park subscription",
.destroy = parked_subscription_datastore_destroy,
}

Definition at line 86 of file parking_bridge_features.c.