63 static void destroy_parked_user(
void *obj)
73 static int parked_user_set_parker_dial_string(
struct parked_user *pu,
const char *parker_channel_name)
75 char *dial_string =
ast_strdupa(parker_channel_name);
110 int preferred_space = -1;
112 const char *parkingexten;
115 ast_log(LOG_NOTICE,
"Tried to park in a parking lot that is no longer able to be parked to.\n");
119 new_parked_user = ao2_alloc(
sizeof(*new_parked_user), destroy_parked_user);
120 if (!new_parked_user) {
124 if (use_random_space) {
128 ast_channel_lock(chan);
132 ast_channel_unlock(chan);
134 if (!ast_strlen_zero(parkingexten)) {
135 if (sscanf(parkingexten,
"%30d", &preferred_space) != 1 || preferred_space <= 0) {
136 ast_log(LOG_WARNING,
"PARKINGEXTEN='%s' is not a valid parking space.\n", parkingexten);
147 if (parking_space == -1) {
148 ast_log(LOG_NOTICE,
"Failed to get parking space in lot '%s'. All full.\n", lot->
name);
155 new_parked_user->
chan = chan;
159 new_parked_user->
lot = lot;
165 if (parker_dial_string) {
168 if (ast_strlen_zero(parker_channel_name) || parked_user_set_parker_dial_string(new_parked_user, parker_channel_name)) {
185 return new_parked_user;
207 const char *blind_transfer;
209 const char *parker_channel_name = NULL;
214 ast_assert(self->lot != NULL);
242 if (!ast_strlen_zero(idle_mode) && !strcmp(idle_mode,
"ringing")) {
252 ast_log(LOG_WARNING,
"Failed to apply holding bridge roles to %s while joining the parking lot.\n",
253 ast_channel_name(bridge_channel->
chan));
270 ast_channel_lock(bridge_channel->
chan);
273 ast_channel_unlock(bridge_channel->
chan);
274 if (!parker || !strcmp(parker->
base->
name, ast_channel_name(bridge_channel->
chan))) {
275 if (ast_strlen_zero(blind_transfer) && parker) {
277 parker_channel_name = parker->
base->
name;
282 parker_channel_name = blind_transfer;
285 parker_channel_name = parker->
base->
name;
288 pu = generate_parked_user(self->lot, bridge_channel->
chan, parker_channel_name,
289 park_datastore->parker_dial_string, park_datastore->randomize, park_datastore->time_limit);
297 if (park_datastore->comeback_override) {
305 if (ast_strlen_zero(blind_transfer) && !park_datastore->silence_announce) {
308 snprintf(saynum_buf,
sizeof(saynum_buf),
"%d %d", 0, pu->
parking_space);
319 COLORIZE(COLOR_BRMAGENTA, 0, ast_channel_name(bridge_channel->
chan)),
320 COLORIZE(COLOR_BRMAGENTA, 0, self->lot->name),
445 self->lot = bridge_lot;
454 bridge = bridge_alloc(
sizeof(
struct ast_bridge_parking), &ast_bridge_parking_v_table);
458 bridge = ast_bridge_parking_init(bridge, bridge_lot);
int ast_bridge_channel_has_role(struct ast_bridge_channel *bridge_channel, const char *role_name)
Check to see if a bridge channel inherited a specific role from its channel.
Main Channel structure associated with a channel.
struct ast_channel_snapshot_base * base
int unpark_parked_user(struct parked_user *pu)
Pull a parked user out of its parking lot. Use this when you don't want to use the parked user afterw...
Asterisk main include file. File version handling, generic pbx functions.
struct ast_bridge_features * features
void park_common_datastore_free(struct park_common_datastore *datastore)
Free a park common datastore struct.
struct ast_bridge * bridge_register(struct ast_bridge *bridge)
Register the new bridge with the system.
void parking_notify_metermaids(int exten, const char *context, enum ast_device_state state)
Notify metermaids that we've changed an extension.
int(* ast_bridge_push_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
Push this channel into the bridge.
int parking_lot_get_space(struct parking_lot *lot, int target_override)
Get an available parking space within a parking lot.
void(* ast_bridge_dissolving_fn)(struct ast_bridge *self)
The bridge is being dissolved.
struct ao2_container * parked_users
Structure representing a snapshot of channel state.
void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parking_lot *lot, int recipient_mode)
Apply features based on the parking lot feature options.
ast_channel_state
ast_channel states
ast_bridge_dissolving_fn dissolving
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
void parking_set_duration(struct ast_bridge_features *features, struct parked_user *user)
Setup timeout interval feature on an ast_bridge_features for parking.
#define ast_strdup(str)
A wrapper for strdup()
void publish_parked_call(struct parked_user *pu, enum ast_parked_call_event_type event_type)
Publish a stasis parked call message for a given parked user.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
void publish_parked_call_failure(struct ast_channel *parkee)
Publish a stasis parked call message for the channel indicating failure to park.
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
int(* ast_bridge_merge_priority_fn)(struct ast_bridge *self)
Get the merge priority of this bridge.
int parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing)
Set necessary bridge roles on a channel that is about to enter a parking lot.
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
ast_bridge_notify_masquerade_fn notify_masquerade
char * parker_dial_string
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
enum park_call_resolution resolution
struct ast_bridge * bridge_base_init(struct ast_bridge *self, uint32_t capabilities, unsigned int flags, const char *creator, const char *name, const char *id)
Initialize the base class of the bridge.
void(* ast_bridge_pull_channel_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
Pull this channel from the bridge.
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
Structure that contains information about a bridge.
void ast_channel_name_to_dial_string(char *channel_name)
Removes the trailing identifiers from a channel name string.
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 option...
struct ast_bridge * bridge_parking_new(struct parking_lot *bridge_lot)
Create a new parking bridge.
Bridge virtual methods table definition.
ast_bridge_merge_priority_fn get_merge_priority
void(* ast_bridge_destructor_fn)(struct ast_bridge *self)
Destroy the bridge.
const ast_string_field courtesytone
Support for logging to various files, console and syslog Configuration in file logger.conf.
const ast_string_field name
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
void * bridge_pvt
Bridge class private channel data.
struct park_common_datastore * get_park_common_datastore_copy(struct ast_channel *parkee)
Get a copy of the park_common_datastore from a channel that is being parked.
enum parking_lot_modes mode
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int ast_bridge_channel_queue_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
Queue a bridge action play file frame onto the bridge channel.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Handy terminal functions for vt* terms.
ast_bridge_pull_channel_fn pull
ast_bridge_destructor_fn destroy
ast_bridge_push_channel_fn push
Call Parking Resource Internal API.
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
Say numbers and dates (maybe words one day too)
struct ast_channel_snapshot * retriever
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
const char * ast_bridge_channel_get_role_option(struct ast_bridge_channel *bridge_channel, const char *role_name, const char *option)
Retrieve the value of a requested role option from a bridge channel.
struct ast_channel * chan
void(* ast_bridge_notify_masquerade_fn)(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
Notify the bridge that this channel was just masqueraded.
const ast_string_field name
struct parking_lot_cfg * cfg
#define ao2_link(container, obj)
Add an object to a container.