Asterisk - The Open Source Telephony Project GIT-master-a358458
Functions | Variables
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

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const char app [] = "Echo"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

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

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file app_echo.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 113 of file app_echo.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 113 of file app_echo.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 113 of file app_echo.c.

◆ echo_exec()

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

Definition at line 56 of file app_echo.c.

57{
58 int res = -1;
59 int fir_sent = 0;
60
61 while (ast_waitfor(chan, -1) > -1) {
62 struct ast_frame *f = ast_read(chan);
63 if (!f) {
64 break;
65 }
66 f->delivery.tv_sec = 0;
67 f->delivery.tv_usec = 0;
70 && !fir_sent) {
71 if (ast_write(chan, f) < 0) {
72 ast_frfree(f);
73 goto end;
74 }
75 fir_sent = 1;
76 }
77 if (!fir_sent && f->frametype == AST_FRAME_VIDEO) {
78 struct ast_frame frame = {
80 .subclass.integer = AST_CONTROL_VIDUPDATE,
81 };
82 ast_write(chan, &frame);
83 fir_sent = 1;
84 }
88 && ast_write(chan, f)) {
89 ast_frfree(f);
90 goto end;
91 }
92 if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
93 res = 0;
94 ast_frfree(f);
95 goto end;
96 }
97 ast_frfree(f);
98 }
99end:
100 return res;
101}
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3162
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:5144
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
char * end
Definition: eagi_proxy.c:73
#define AST_FRAME_DTMF
#define ast_frfree(fr)
@ AST_FRAME_VIDEO
@ AST_FRAME_NULL
@ AST_FRAME_MODEM
@ AST_FRAME_CONTROL
@ AST_CONTROL_VIDUPDATE
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
struct timeval delivery
enum ast_frame_type frametype

References AST_CONTROL_VIDUPDATE, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_VIDEO, ast_frfree, ast_read(), ast_waitfor(), ast_write(), ast_frame::delivery, end, ast_frame::frametype, ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 108 of file app_echo.c.

109{
111}
static int echo_exec(struct ast_channel *chan, const char *data)
Definition: app_echo.c:56
static const char app[]
Definition: app_echo.c:54
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

References app, ast_register_application_xml, and echo_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 103 of file app_echo.c.

104{
106}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ __mod_info

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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 113 of file app_echo.c.

◆ app

const char app[] = "Echo"
static

Definition at line 54 of file app_echo.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 113 of file app_echo.c.