Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
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 = ASTERISK_GPL_KEY , .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 116 of file app_echo.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 116 of file app_echo.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 116 of file app_echo.c.

◆ echo_exec()

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

Definition at line 59 of file app_echo.c.

60{
61 int res = -1;
62 int fir_sent = 0;
63
64 while (ast_waitfor(chan, -1) > -1) {
65 struct ast_frame *f = ast_read(chan);
66 if (!f) {
67 break;
68 }
69 f->delivery.tv_sec = 0;
70 f->delivery.tv_usec = 0;
73 && !fir_sent) {
74 if (ast_write(chan, f) < 0) {
75 ast_frfree(f);
76 goto end;
77 }
78 fir_sent = 1;
79 }
80 if (!fir_sent && f->frametype == AST_FRAME_VIDEO) {
81 struct ast_frame frame = {
83 .subclass.integer = AST_CONTROL_VIDUPDATE,
84 };
85 ast_write(chan, &frame);
86 fir_sent = 1;
87 }
91 && ast_write(chan, f)) {
92 ast_frfree(f);
93 goto end;
94 }
95 if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
96 res = 0;
97 ast_frfree(f);
98 goto end;
99 }
100 ast_frfree(f);
101 }
102end:
103 return res;
104}
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition channel.c:3159
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:5139
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition channel.c:4250
char * end
Definition eagi_proxy.c:73
#define AST_FRAME_DTMF
#define ast_frfree(fr)
@ 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 111 of file app_echo.c.

112{
114}
static int echo_exec(struct ast_channel *chan, const char *data)
Definition app_echo.c:59
static const char app[]
Definition app_echo.c:57
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition module.h:640

References app, ast_register_application_xml, and echo_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 106 of file app_echo.c.

107{
109}
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 = ASTERISK_GPL_KEY , .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 116 of file app_echo.c.

◆ app

const char app[] = "Echo"
static

Definition at line 57 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 116 of file app_echo.c.