Mon Oct 8 12:39:07 2012

Asterisk developer's documentation


app_echo.c File Reference

Echo application -- play back what you hear to evaluate latency. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int echo_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Simple Echo Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static const char app [] = "Echo"
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

Echo application -- play back what you hear to evaluate latency.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_echo.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 102 of file app_echo.c.

static void __unreg_module ( void   )  [static]

Definition at line 102 of file app_echo.c.

static int echo_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 58 of file app_echo.c.

References ast_best_codec(), AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_MODEM, AST_FRAME_NULL, ast_frfree, ast_read(), ast_set_read_format(), ast_set_write_format(), ast_waitfor(), ast_write(), f, format, and ast_channel::nativeformats.

Referenced by load_module().

00059 {
00060    int res = -1;
00061    format_t format;
00062 
00063    format = ast_best_codec(chan->nativeformats);
00064    ast_set_write_format(chan, format);
00065    ast_set_read_format(chan, format);
00066 
00067    while (ast_waitfor(chan, -1) > -1) {
00068       struct ast_frame *f = ast_read(chan);
00069       if (!f) {
00070          break;
00071       }
00072       f->delivery.tv_sec = 0;
00073       f->delivery.tv_usec = 0;
00074       if (f->frametype != AST_FRAME_CONTROL
00075          && f->frametype != AST_FRAME_MODEM
00076          && f->frametype != AST_FRAME_NULL
00077          && ast_write(chan, f)) {
00078          ast_frfree(f);
00079          goto end;
00080       }
00081       if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
00082          res = 0;
00083          ast_frfree(f);
00084          goto end;
00085       }
00086       ast_frfree(f);
00087    }
00088 end:
00089    return res;
00090 }

static int load_module ( void   )  [static]

Definition at line 97 of file app_echo.c.

References ast_register_application_xml, and echo_exec().

00098 {
00099    return ast_register_application_xml(app, echo_exec);
00100 }

static int unload_module ( void   )  [static]

Definition at line 92 of file app_echo.c.

References ast_unregister_application().

00093 {
00094    return ast_unregister_application(app);
00095 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Simple Echo Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 102 of file app_echo.c.

const char app[] = "Echo" [static]

Definition at line 56 of file app_echo.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 102 of file app_echo.c.


Generated on Mon Oct 8 12:39:07 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7