Wed Jan 8 2020 09:49:53

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 marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

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(), ast_frame::delivery, f, format, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::nativeformats, and ast_frame::subclass.

Referenced by load_module().

59 {
60  int res = -1;
62 
63  format = ast_best_codec(chan->nativeformats);
64  ast_set_write_format(chan, format);
65  ast_set_read_format(chan, format);
66 
67  while (ast_waitfor(chan, -1) > -1) {
68  struct ast_frame *f = ast_read(chan);
69  if (!f) {
70  break;
71  }
72  f->delivery.tv_sec = 0;
73  f->delivery.tv_usec = 0;
75  && f->frametype != AST_FRAME_MODEM
76  && f->frametype != AST_FRAME_NULL
77  && ast_write(chan, f)) {
78  ast_frfree(f);
79  goto end;
80  }
81  if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
82  res = 0;
83  ast_frfree(f);
84  goto end;
85  }
86  ast_frfree(f);
87  }
88 end:
89  return res;
90 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define AST_FRAME_DTMF
Definition: frame.h:128
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
Definition: channel.c:1062
format_t nativeformats
Definition: channel.h:852
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
Definition: channel.c:5307
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
Definition: channel.c:5301
int64_t format_t
Definition: frame_defs.h:32
static struct ast_format f[]
Definition: format_g726.c:181
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:4916
struct timeval delivery
Definition: frame.h:162
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
static snd_pcm_format_t format
Definition: chan_alsa.c:93
static int load_module ( void  )
static

Definition at line 97 of file app_echo.c.

References ast_register_application_xml, and echo_exec().

98 {
100 }
static int echo_exec(struct ast_channel *chan, const char *data)
Definition: app_echo.c:58
static const char app[]
Definition: app_echo.c:56
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int unload_module ( void  )
static

Definition at line 92 of file app_echo.c.

References ast_unregister_application().

93 {
95 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static const char app[]
Definition: app_echo.c:56

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.

Definition at line 102 of file app_echo.c.