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.
21 * \brief Echo application -- play back what you hear to evaluate latency
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
29 <support_level>core</support_level>
34 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
36 #include "asterisk/file.h"
37 #include "asterisk/module.h"
38 #include "asterisk/channel.h"
41 <application name="Echo" language="en_US">
43 Echo media, DTMF back to the calling party
47 <para>Echos back any media or DTMF frames read from the calling
48 channel back to itself. This will not echo CONTROL, MODEM, or NULL
49 frames. Note: If '#' detected application exits.</para>
50 <para>This application does not automatically answer and should be
51 preceeded by an application such as Answer() or Progress().</para>
56 static const char app[] = "Echo";
58 static int echo_exec(struct ast_channel *chan, const char *data)
61 struct ast_format format;
63 ast_best_codec(ast_channel_nativeformats(chan), &format);
64 ast_set_write_format(chan, &format);
65 ast_set_read_format(chan, &format);
67 while (ast_waitfor(chan, -1) > -1) {
68 struct ast_frame *f = ast_read(chan);
72 f->delivery.tv_sec = 0;
73 f->delivery.tv_usec = 0;
74 if (f->frametype != AST_FRAME_CONTROL
75 && f->frametype != AST_FRAME_MODEM
76 && f->frametype != AST_FRAME_NULL
77 && ast_write(chan, f)) {
81 if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
92 static int unload_module(void)
94 return ast_unregister_application(app);
97 static int load_module(void)
99 return ast_register_application_xml(app, echo_exec);
102 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Simple Echo Application");