Tue Aug 24 20:34:43 2010

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"
Include dependency graph for app_echo.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Simple Echo Application")
static int echo_exec (struct ast_channel *chan, void *data)
static int load_module (void)
static int unload_module (void)

Variables

static char * app = "Echo"

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

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Simple Echo Application"   
)
static int echo_exec ( struct ast_channel *  chan,
void *  data 
) [static]

Definition at line 51 of file app_echo.c.

References ast_best_codec(), AST_FRAME_DTMF, ast_frfree, ast_read(), ast_set_read_format(), ast_set_write_format(), ast_waitfor(), ast_write(), ast_frame::delivery, f, format, ast_frame::frametype, ast_channel::nativeformats, and ast_frame::subclass.

Referenced by load_module().

00052 {
00053    int res = -1;
00054    int format;
00055 
00056    format = ast_best_codec(chan->nativeformats);
00057    ast_set_write_format(chan, format);
00058    ast_set_read_format(chan, format);
00059 
00060    while (ast_waitfor(chan, -1) > -1) {
00061       struct ast_frame *f = ast_read(chan);
00062       if (!f) {
00063          break;
00064       }
00065       f->delivery.tv_sec = 0;
00066       f->delivery.tv_usec = 0;
00067       if (ast_write(chan, f)) {
00068          ast_frfree(f);
00069          goto end;
00070       }
00071       if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) {
00072          res = 0;
00073          ast_frfree(f);
00074          goto end;
00075       }
00076       ast_frfree(f);
00077    }
00078 end:
00079    return res;
00080 }

static int load_module ( void   )  [static]

Definition at line 87 of file app_echo.c.

References ast_register_application_xml, and echo_exec().

00088 {
00089    return ast_register_application_xml(app, echo_exec);
00090 }

static int unload_module ( void   )  [static]

Definition at line 82 of file app_echo.c.

References ast_unregister_application().

00083 {
00084    return ast_unregister_application(app);
00085 }


Variable Documentation

char* app = "Echo" [static]

Definition at line 49 of file app_echo.c.


Generated on 24 Aug 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1