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
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
32 #include "asterisk/file.h"
33 #include "asterisk/module.h"
34 #include "asterisk/channel.h"
36 static char *app
= "Echo";
38 static char *synopsis
= "Echo audio, video, or DTMF back to the calling party";
40 static char *descrip
=
41 " Echo(): This application will echo any audio, video, or DTMF frames read from\n"
42 "the calling channel back to itself. If the DTMF digit '#' is received, the\n"
43 "application will exit.\n";
46 static int echo_exec(struct ast_channel
*chan
, void *data
)
51 format
= ast_best_codec(chan
->nativeformats
);
52 ast_set_write_format(chan
, format
);
53 ast_set_read_format(chan
, format
);
55 while (ast_waitfor(chan
, -1) > -1) {
56 struct ast_frame
*f
= ast_read(chan
);
59 f
->delivery
.tv_sec
= 0;
60 f
->delivery
.tv_usec
= 0;
61 if (ast_write(chan
, f
)) {
65 if ((f
->frametype
== AST_FRAME_DTMF
) && (f
->subclass
== '#')) {
76 static int unload_module(void)
78 return ast_unregister_application(app
);
81 static int load_module(void)
83 return ast_register_application(app
, echo_exec
, synopsis
, descrip
);
86 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Simple Echo Application");