190 if (!parkee_snapshot) {
203 const char *lot_name = pu->
lot->
name;
208 if (!parkee_snapshot) {
213 duration = now.tv_sec - pu->
start.tv_sec;
231 if (!parkee_string) {
238 if (!retriever_string) {
247 "ParkerDialString: %s\r\n"
249 "ParkingSpace: %u\r\n"
250 "ParkingTimeout: %lu\r\n"
251 "ParkingDuration: %lu\r\n",
291 if (!parked_call_string) {
324 if (!lot_container) {
325 ast_log(
LOG_ERROR,
"Failed to obtain parking lot list. Action canceled.\n");
348 if (!parked_call_string) {
385 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
438 if (!lot_container) {
439 ast_log(
LOG_ERROR,
"Failed to obtain parking lot list. Action canceled.\n");
458 struct ast_channel *chan,
const char *parkinglot,
int timeout_override)
461 chan, parkinglot,
NULL, 0, 0, timeout_override, 1);
463 if (!parking_bridge) {
480 const char *parkinglot,
int timeout_override)
485 if (timeout_override != -1) {
501 if (!bridge_channel) {
533 int timeout_override = -1;
544 if (sscanf(timeout,
"%30d", &timeout_override) != 1 || timeout_override < 0) {
549 if (timeout_override) {
551 timeout_override =
MAX(1, timeout_override / 1000);
556 snprintf(
buf,
sizeof(
buf),
"Channel does not exist: %s", channel);
572 if (!parker_chan || strcmp(
ast_channel_name(parker_chan), timeout_channel)) {
575 if (!announce_channel) {
588 if (!
ast_strlen_zero(announce_channel) && strcmp(announce_channel, timeout_channel)) {
592 if (!announce_channel) {
651 char *event_type =
"";
656 event_type =
"ParkedCall";
659 event_type =
"ParkedCallTimeOut";
662 event_type =
"ParkedCallGiveUp";
665 event_type =
"UnParkedCall";
668 event_type =
"ParkedCallSwap";
676 if (!parked_call_string) {
677 ast_log(
LOG_ERROR,
"Failed to issue an AMI event of '%s' in response to a stasis message.\n", event_type);
Asterisk main include file. File version handling, generic pbx functions.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ao2_iterator_next(iter)
#define ao2_callback_data(container, flags, cb_fn, arg, data)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
void ast_bridge_set_transfer_variables(struct ast_channel *chan, const char *value, int is_attended)
Set the relevant transfer variables for a single channel.
int ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
Have a bridge channel park a channel in the bridge.
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
#define ast_channel_lock(chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
#define ast_channel_unlock(chan)
Standard Command Line Interface.
Configuration option-handling.
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_bridge_features *features, int play_tone, const char *xfersound)
Add an arbitrary channel to a bridge.
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
void astman_append(struct mansession *s, const char *fmt,...)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
struct stasis_topic * ast_parking_topic(void)
accessor for the parking stasis topic
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
struct ast_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate.
Configuration File Parser.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
Asterisk module definitions.
struct ast_parked_call_payload * ast_parked_call_payload_create(enum ast_parked_call_event_type event_type, struct ast_channel_snapshot *parkee_snapshot, const char *parker_dial_string, struct ast_channel_snapshot *retriever_snapshot, const char *parkinglot, unsigned int parkingspace, unsigned long int timeout, unsigned long int duration)
Constructor for parked_call_payload objects.
ast_parked_call_event_type
Defines the type of parked call message being published.
struct ast_bridge * park_common_setup(struct ast_channel *parkee, struct ast_channel *parker, const char *lot_name, const char *comeback_override, int use_ringing, int randomize, int time_limit, int silence_announcements)
Setup a parked call on a parking bridge without needing to parse appdata.
int create_parked_subscription(struct ast_channel *chan, const char *parkee_uuid, int hangup_after)
Create a parking announcement subscription.
static void manager_park_bridged(struct mansession *s, const struct message *m, struct ast_channel *chan, struct ast_channel *parker_chan, const char *parkinglot, int timeout_override)
int load_parking_manager(void)
Register manager actions and setup subscriptions for stasis events.
void unload_parking_manager(void)
Unregister manager actions and remove subscriptions for stasis events.
static struct stasis_subscription * parking_sub
subscription to the parking lot topic
static void manager_park_unbridged(struct mansession *s, const struct message *m, struct ast_channel *chan, const char *parkinglot, int timeout_override)
static int manager_park(struct mansession *s, const struct message *m)
static struct ast_parked_call_payload * parked_call_payload_from_failure(struct ast_channel *chan)
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.
static void parking_manager_disable_stasis(void)
static void manager_parking_status_single_lot(struct mansession *s, const struct message *m, const char *id_text, const char *lot_name)
static struct ast_str * manager_build_parked_call_string(const struct ast_parked_call_payload *payload)
Builds a manager string based on the contents of a parked call payload.
static void manager_parking_status_all_lots(struct mansession *s, const struct message *m, const char *id_text)
static void parked_call_message_response(struct ast_parked_call_payload *parked_call)
static void parking_manager_enable_stasis(void)
static int manager_parking_status(struct mansession *s, const struct message *m)
static void parking_event_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
void publish_parked_call_failure(struct ast_channel *parkee)
Publish a stasis parked call message for the channel indicating failure to park.
static int manager_append_event_parking_lot_data_cb(void *obj, void *arg, void *data, int flags)
static struct ast_parked_call_payload * parked_call_payload_from_parked_user(struct parked_user *pu, enum ast_parked_call_event_type event_type)
static int manager_parking_lot_list(struct mansession *s, const struct message *m)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
struct stasis_forward * sub
Call Parking Resource Internal API.
struct ao2_container * get_parking_lot_container(void)
Get a pointer to the parking lot container for purposes such as iteration.
struct parking_lot * parking_lot_find_by_name(const char *lot_name)
Find a parking lot based on its name.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
#define stasis_subscribe(topic, callback, data)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
Structure that contains information about a bridge.
Structure representing a snapshot of channel state.
Main Channel structure associated with a channel.
const ast_string_field parkinglot
A parked call message payload.
unsigned int parkingspace
long unsigned int duration
const ast_string_field parkinglot
struct ast_channel_snapshot * retriever
long unsigned int timeout
struct ast_channel_snapshot * parkee
enum ast_parked_call_event_type event_type
const ast_string_field parker_dial_string
Support for dynamic strings.
In case you didn't read that giant block of text above the mansession_session struct,...
char * parker_dial_string
struct ast_channel * chan
struct ast_channel_snapshot * retriever
struct parking_lot_cfg * cfg
const ast_string_field name
struct ao2_container * parked_users
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.