Fri Sep 25 19:28:17 2009

Asterisk developer's documentation


app_echo.c File Reference

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

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.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"
static char * descrip
static char * synopsis = "Echo audio, video, or DTMF back to the calling party"


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 54 of file app_echo.c.

References ast_best_codec(), AST_FRAME_DTMF, ast_frfree, ast_module_user_add, ast_module_user_remove, 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().

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

static int load_module ( void   )  [static]

Definition at line 99 of file app_echo.c.

References ast_register_application(), and echo_exec().

00100 {
00101    return ast_register_application(app, echo_exec, synopsis, descrip);
00102 }

static int unload_module ( void   )  [static]

Definition at line 88 of file app_echo.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00089 {
00090    int res;
00091 
00092    res = ast_unregister_application(app);
00093 
00094    ast_module_user_hangup_all();
00095 
00096    return res;
00097 }


Variable Documentation

char* app = "Echo" [static]

Definition at line 44 of file app_echo.c.

char* descrip [static]

Initial value:

 
"  Echo(): This application will echo any audio, video, or DTMF frames read from\n"
"the calling channel back to itself. If the DTMF digit '#' is received, the\n"
"application will exit.\n"

Definition at line 48 of file app_echo.c.

char* synopsis = "Echo audio, video, or DTMF back to the calling party" [static]

Definition at line 46 of file app_echo.c.


Generated on Fri Sep 25 19:28:17 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.5