Wed Jan 8 2020 09:49:46

Asterisk developer's documentation


dial.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2007, Digium, Inc.
5  *
6  * Joshua Colp <jcolp@digium.com>
7  *
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.
13  *
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.
17  */
18 
19 /*! \file
20  * \brief Dialing API
21  */
22 
23 #ifndef _ASTERISK_DIAL_H
24 #define _ASTERISK_DIAL_H
25 
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29 
30 /*! \brief Main dialing structure. Contains global options, channels being dialed, and more! */
31 struct ast_dial;
32 
33 /*! \brief Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! */
34 struct ast_dial_channel;
35 
36 typedef void (*ast_dial_state_callback)(struct ast_dial *);
37 
38 /*! \brief List of options that are applicable either globally or per dialed channel */
40  AST_DIAL_OPTION_RINGING, /*!< Always indicate ringing to caller */
41  AST_DIAL_OPTION_ANSWER_EXEC, /*!< Execute application upon answer in async mode */
42  AST_DIAL_OPTION_MUSIC, /*!< Play music on hold instead of ringing to the calling channel */
43  AST_DIAL_OPTION_DISABLE_CALL_FORWARDING, /*!< Disable call forwarding on channels */
44  AST_DIAL_OPTION_MAX, /*!< End terminator -- must always remain last */
45 };
46 
47 /*! \brief List of return codes for dial run API calls */
49  AST_DIAL_RESULT_INVALID, /*!< Invalid options were passed to run function */
50  AST_DIAL_RESULT_FAILED, /*!< Attempts to dial failed before reaching critical state */
51  AST_DIAL_RESULT_TRYING, /*!< Currently trying to dial */
52  AST_DIAL_RESULT_RINGING, /*!< Dial is presently ringing */
53  AST_DIAL_RESULT_PROGRESS, /*!< Dial is presently progressing */
54  AST_DIAL_RESULT_PROCEEDING, /*!< Dial is presently proceeding */
55  AST_DIAL_RESULT_ANSWERED, /*!< A channel was answered */
56  AST_DIAL_RESULT_TIMEOUT, /*!< Timeout was tripped, nobody answered */
57  AST_DIAL_RESULT_HANGUP, /*!< Caller hung up */
58  AST_DIAL_RESULT_UNANSWERED, /*!< Nobody answered */
59 };
60 
61 /*! \brief New dialing structure
62  * \note Create a dialing structure
63  * \return Returns a calloc'd ast_dial structure, NULL on failure
64  */
65 struct ast_dial *ast_dial_create(void);
66 
67 /*! \brief Append a channel
68  * \note Appends a channel to a dialing structure
69  * \return Returns channel reference number on success, -1 on failure
70  */
71 int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device);
72 
73 /*! \brief Execute dialing synchronously or asynchronously
74  * \note Dials channels in a dial structure.
75  * \return Returns dial result code. (TRYING/INVALID/FAILED/ANSWERED/TIMEOUT/UNANSWERED).
76  */
77 enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async);
78 
79 /*! \brief Return channel that answered
80  * \note Returns the Asterisk channel that answered
81  * \param dial Dialing structure
82  */
83 struct ast_channel *ast_dial_answered(struct ast_dial *dial);
84 
85 /*! \brief Steal the channel that answered
86  * \note Returns the Asterisk channel that answered and removes it from the dialing structure
87  * \param dial Dialing structure
88  */
89 struct ast_channel *ast_dial_answered_steal(struct ast_dial *dial);
90 
91 /*! \brief Return state of dial
92  * \note Returns the state of the dial attempt
93  * \param dial Dialing structure
94  */
95 enum ast_dial_result ast_dial_state(struct ast_dial *dial);
96 
97 /*! \brief Cancel async thread
98  * \note Cancel a running async thread
99  * \param dial Dialing structure
100  */
101 enum ast_dial_result ast_dial_join(struct ast_dial *dial);
102 
103 /*! \brief Hangup channels
104  * \note Hangup all active channels
105  * \param dial Dialing structure
106  */
107 void ast_dial_hangup(struct ast_dial *dial);
108 
109 /*! \brief Destroys a dialing structure
110  * \note Cancels dialing and destroys (free's) the given ast_dial structure
111  * \param dial Dialing structure to free
112  * \return Returns 0 on success, -1 on failure
113  */
114 int ast_dial_destroy(struct ast_dial *dial);
115 
116 /*! \brief Enables an option globally
117  * \param dial Dial structure to enable option on
118  * \param option Option to enable
119  * \param data Data to pass to this option (not always needed)
120  * \return Returns 0 on success, -1 on failure
121  */
122 int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data);
123 
124 /*! \brief Enables an option per channel
125  * \param dial Dial structure
126  * \param num Channel number to enable option on
127  * \param option Option to enable
128  * \param data Data to pass to this option (not always needed)
129  * \return Returns 0 on success, -1 on failure
130  */
131 int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data);
132 
133 /*! \brief Disables an option globally
134  * \param dial Dial structure to disable option on
135  * \param option Option to disable
136  * \return Returns 0 on success, -1 on failure
137  */
138 int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option);
139 
140 /*! \brief Disables an option per channel
141  * \param dial Dial structure
142  * \param num Channel number to disable option on
143  * \param option Option to disable
144  * \return Returns 0 on success, -1 on failure
145  */
146 int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option);
147 
148 /*! \brief Set a callback for state changes
149  * \param dial The dial structure to watch for state changes
150  * \param callback the callback
151  * \return nothing
152  */
154 
155 /*! \brief Set the maximum time (globally) allowed for trying to ring phones
156  * \param dial The dial structure to apply the time limit to
157  * \param timeout Maximum time allowed in milliseconds
158  * \return nothing
159  */
160 void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout);
161 
162 /*! \brief Set the maximum time (per channel) allowed for trying to ring the phone
163  * \param dial The dial structure the channel belongs to
164  * \param num Channel number to set timeout on
165  * \param timeout Maximum time allowed in milliseconds
166  * \return nothing
167  */
168 void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout);
169 
170 #if defined(__cplusplus) || defined(c_plusplus)
171 }
172 #endif
173 
174 #endif /* _ASTERISK_DIAL_H */
Main Channel structure associated with a channel.
Definition: channel.h:742
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
Definition: dial.c:866
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
Definition: dial.c:923
Main dialing structure. Contains global options, channels being dialed, and more! ...
Definition: dial.c:47
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
Definition: dial.c:1053
void ast_dial_hangup(struct ast_dial *dial)
Hangup channels.
Definition: dial.c:842
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device)
Append a channel.
Definition: dial.c:229
const char * data
Definition: channel.h:755
int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
Enables an option per channel.
Definition: dial.c:966
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
Definition: dial.c:1043
ast_dial_result
List of return codes for dial run API calls.
Definition: dial.h:48
enum ast_dial_result ast_dial_join(struct ast_dial *dial)
Cancel async thread.
Definition: dial.c:794
int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option)
Disables an option globally.
Definition: dial.c:995
ast_dial_option
List of options that are applicable either globally or per dialed channel.
Definition: dial.h:39
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
Definition: dial.c:785
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
Definition: dial.c:714
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
Definition: dial.c:754
struct ast_dial * ast_dial_create(void)
New dialing structure.
Definition: dial.c:201
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
Definition: dial.c:766
void(* ast_dial_state_callback)(struct ast_dial *)
Definition: dial.h:36
int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option)
Disables an option per channel.
Definition: dial.c:1018
void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout)
Set the maximum time (per channel) allowed for trying to ring the phone.
Definition: dial.c:1069
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60