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$")
37 #include "asterisk/lock.h"
38 #include "asterisk/file.h"
39 #include "asterisk/logger.h"
40 #include "asterisk/channel.h"
41 #include "asterisk/pbx.h"
42 #include "asterisk/module.h"
44 static char *app
= "Echo";
46 static char *synopsis
= "Echo audio, video, or DTMF back to the calling party";
48 static char *descrip
=
49 " Echo(): This application will echo any audio, video, or DTMF frames read from\n"
50 "the calling channel back to itself. If the DTMF digit '#' is received, the\n"
51 "application will exit.\n";
54 static int echo_exec(struct ast_channel
*chan
, void *data
)
58 struct ast_module_user
*u
;
60 u
= ast_module_user_add(chan
);
62 format
= ast_best_codec(chan
->nativeformats
);
63 ast_set_write_format(chan
, format
);
64 ast_set_read_format(chan
, format
);
66 while (ast_waitfor(chan
, -1) > -1) {
67 struct ast_frame
*f
= ast_read(chan
);
70 f
->delivery
.tv_sec
= 0;
71 f
->delivery
.tv_usec
= 0;
72 switch (f
->frametype
) {
74 if (f
->subclass
== '#') {
81 if (ast_write(chan
, f
)) {
89 ast_module_user_remove(u
);
93 static int unload_module(void)
97 res
= ast_unregister_application(app
);
99 ast_module_user_hangup_all();
104 static int load_module(void)
106 return ast_register_application(app
, echo_exec
, synopsis
, descrip
);
109 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Simple Echo Application");