Debian Codegraph @

apps/app_playtones.c

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2009, Digium, Inc.
5 *
6 * Russell Bryant <[email protected]>
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 /*!
20 * \file
21 * \brief Playtones application
22 *
23 * \author Russell Bryant <[email protected]>
24 *
25 * \ingroup applications
26 */
27
28 /*** MODULEINFO
29 <support_level>core</support_level>
30 ***/
31
32 #include "asterisk.h"
33
34 #include "asterisk/module.h"
35 #include "asterisk/pbx.h"
36 #include "asterisk/channel.h"
37 #include "asterisk/indications.h"
38
39 static const char playtones_app[] = "PlayTones";
40 static const char stopplaytones_app[] = "StopPlayTones";
41
42 /*** DOCUMENTATION
43 <application name="PlayTones" language="en_US">
44 <since>
45 <version>1.6.1.0</version>
46 </since>
47 <synopsis>
48 Play a tone list.
49 </synopsis>
50 <syntax>
51 <parameter name="arg" required="true">
52 <para>Arg is either the tone name defined in the <filename>indications.conf</filename>
53 configuration file, or a directly specified list of frequencies and durations.</para>
54 </parameter>
55 </syntax>
56 <description>
57 <para>Plays a tone list. Execution will continue with the next step in the dialplan
58 immediately while the tones continue to play.</para>
59 <para>See the sample <filename>indications.conf</filename> for a description of the
60 specification of a tonelist.</para>
61 </description>
62 <see-also>
63 <ref type="application">StopPlayTones</ref>
64 </see-also>
65 </application>
66 <application name="StopPlayTones" language="en_US">
67 <since>
68 <version>1.6.1.0</version>
69 </since>
70 <synopsis>
71 Stop playing a tone list.
72 </synopsis>
73 <syntax />
74 <description>
75 <para>Stop playing a tone list, initiated by PlayTones().</para>
76 </description>
77 <see-also>
78 <ref type="application">PlayTones</ref>
79 </see-also>
80 </application>
81 ***/
82
83 static int handle_playtones(struct ast_channel *chan, const char *data)
84 {
85 struct ast_tone_zone_sound *ts;
86 int res;
87 const char *str = data;
88
89 if (ast_strlen_zero(str)) {
90 ast_log(LOG_NOTICE,"Nothing to play\n");
91 return -1;
92 }
93
94 ts = ast_get_indication_tone(ast_channel_zone(chan), str);
95
96 if (ts) {
97 res = ast_playtones_start(chan, 0, ts->data, 0);
98 ts = ast_tone_zone_sound_unref(ts);
99 } else {
100 res = ast_playtones_start(chan, 0, str, 0);
101 }
102
103 if (res) {
104 ast_log(LOG_NOTICE, "Unable to start playtones\n");
105 }
106
107 return res;
108 }
109
110 static int handle_stopplaytones(struct ast_channel *chan, const char *data)
111 {
112 ast_playtones_stop(chan);
113
114 return 0;
115 }
116
117 static int unload_module(void)
118 {
119 int res;
120
121 res = ast_unregister_application(playtones_app);
122 res |= ast_unregister_application(stopplaytones_app);
123
124 return res;
125 }
126
127 static int load_module(void)
128 {
129 int res;
130
131 res = ast_register_application_xml(playtones_app, handle_playtones);
132 res |= ast_register_application_xml(stopplaytones_app, handle_stopplaytones);
133
134 return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
135 }
136
137 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Playtones Application");