2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
20 * \brief Call Parking and Pickup API
21 * Includes code and algorithms from the Zapata library.
24 #ifndef _AST_FEATURES_H
25 #define _AST_FEATURES_H
27 #include "asterisk/pbx.h"
28 #include "asterisk/linkedlists.h"
29 #include "asterisk/bridge.h"
31 #define FEATURE_MAX_LEN 11
32 #define FEATURE_APP_LEN 64
33 #define FEATURE_APP_ARGS_LEN 256
34 #define FEATURE_SNAME_LEN 32
35 #define FEATURE_EXTEN_LEN 32
36 #define FEATURE_MOH_LEN 80 /* same as MAX_MUSICCLASS from channel.h */
38 #define DEFAULT_PARKINGLOT "default" /*!< Default parking lot */
40 #define AST_FEATURE_RETURN_HANGUP -1
41 #define AST_FEATURE_RETURN_SUCCESSBREAK 0
42 #define AST_FEATURE_RETURN_PBX_KEEPALIVE AST_PBX_KEEPALIVE
43 #define AST_FEATURE_RETURN_NO_HANGUP_PEER AST_PBX_NO_HANGUP_PEER
44 #define AST_FEATURE_RETURN_PASSDIGITS 21
45 #define AST_FEATURE_RETURN_STOREDIGITS 22
46 #define AST_FEATURE_RETURN_SUCCESS 23
47 #define AST_FEATURE_RETURN_KEEPTRYING 24
48 #define AST_FEATURE_RETURN_PARKFAILED 25
50 #define FEATURE_SENSE_CHAN (1 << 0)
51 #define FEATURE_SENSE_PEER (1 << 1)
53 typedef int (*ast_feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data);
55 /*! \brief main call feature structure */
58 AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
59 AST_FEATURE_FLAG_ONPEER = (1 << 1),
60 AST_FEATURE_FLAG_ONSELF = (1 << 2),
61 AST_FEATURE_FLAG_BYCALLEE = (1 << 3),
62 AST_FEATURE_FLAG_BYCALLER = (1 << 4),
63 AST_FEATURE_FLAG_BYBOTH = (3 << 3),
67 * \brief Park a call via a masqueraded channel
69 * \param park_me Channel to be parked.
70 * \param parker Channel parking the call.
71 * \param timeout is a timeout in milliseconds
72 * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
75 * Masquerade the park_me channel into a new, empty channel which is then parked.
77 * \note Use ast_masq_park_call_exten() instead.
79 * \retval 0 on success.
80 * \retval -1 on failure.
82 int ast_masq_park_call(struct ast_channel *park_me, struct ast_channel *parker, int timeout, int *extout);
85 * \brief Park a call via a masqueraded channel
88 * \param park_me Channel to be parked.
89 * \param parker Channel parking the call.
90 * \param park_exten Parking lot access extension
91 * \param park_context Parking lot context
92 * \param timeout is a timeout in milliseconds
93 * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
96 * Masquerade the park_me channel into a new, empty channel which is then parked.
98 * \retval 0 on success.
99 * \retval -1 on failure.
101 int ast_masq_park_call_exten(struct ast_channel *park_me, struct ast_channel *parker, const char *park_exten, const char *park_context, int timeout, int *extout);
104 * \brief Determine if parking extension exists in a given context
105 * \retval 0 if extension does not exist
106 * \retval 1 if extension does exist
108 int ast_parking_ext_valid(const char *exten_str, struct ast_channel *chan, const char *context);
110 /*! \brief Bridge a call, optionally allowing redirection */
111 int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config);
114 * \brief Add an arbitrary channel to a bridge
117 * The channel that is being added to the bridge can be in any state: unbridged,
118 * bridged, answered, unanswered, etc. The channel will be added asynchronously,
119 * meaning that when this function returns once the channel has been added to
120 * the bridge, not once the channel has been removed from the bridge.
122 * In addition, a tone can optionally be played to the channel once the
123 * channel is placed into the bridge.
125 * \note When this function returns, there is no guarantee that the channel that
126 * was passed in is valid any longer. Do not attempt to operate on the channel
127 * after this function returns.
129 * \param bridge Bridge to which the channel should be added
130 * \param chan The channel to add to the bridge
131 * \param features Features for this channel in the bridge
132 * \param play_tone Indicates if a tone should be played to the channel
133 * \param xfersound Sound that should be used to indicate transfer with play_tone
137 int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
138 struct ast_bridge_features *features, int play_tone, const char *xfersound);
141 * \brief Test if a channel can be picked up.
143 * \param chan Channel to test if can be picked up.
145 * \note This function assumes that chan is locked.
147 * \return TRUE if channel can be picked up.
149 int ast_can_pickup(struct ast_channel *chan);
152 * \brief Find a pickup channel target by group.
154 * \param chan channel that initiated pickup.
156 * \retval target on success. The returned channel is locked and reffed.
157 * \retval NULL on error.
159 struct ast_channel *ast_pickup_find_by_group(struct ast_channel *chan);
161 /*! \brief Pickup a call */
162 int ast_pickup_call(struct ast_channel *chan);
165 * \brief Pickup a call target.
167 * \param chan channel that initiated pickup.
168 * \param target channel to be picked up.
170 * \note This function assumes that target is locked.
172 * \retval 0 on success.
173 * \retval -1 on failure.
175 int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target);
178 * \brief accessor for call pickup message type
181 * \retval pointer to the stasis message type
182 * \retval NULL if not initialized
184 struct stasis_message_type *ast_call_pickup_type(void);
186 /*! \brief Reload call features from features.conf */
187 int ast_features_reload(void);
190 * \brief parse L option and read associated channel variables to set warning, warning frequency, and timelimit
191 * \note caller must be aware of freeing memory for warning_sound, end_sound, and start_sound
193 int ast_bridge_timelimit(struct ast_channel *chan, struct ast_bridge_config *config, char *parse, struct timeval *calldurationlimit);
195 #endif /* _AST_FEATURES_H */