Home --> Documentations --> PJMEDIA Reference
Play a file to speaker, run AEC, and record the microphone input to see if echo is coming.
This file is pjsip-apps/src/samples/aectest.c
32#include <pjlib-util.h>
35#define THIS_FILE "aectest.c"
37#define TAIL_LENGTH 200
39static const char *desc =
46" Test the AEC effectiveness. \n"
50" aectest [options] <PLAY.WAV> <REC.WAV> <OUTPUT.WAV> \n"
52" <PLAY.WAV> is the signal played to the speaker. \n"
53" <REC.WAV> is the signal captured from the microphone. \n"
54" <OUTPUT.WAV> is the output file to store the test result \n"
57" -d The delay between playback and capture in ms, at least 25 ms.\n"
58" Default is 25 ms. See note below. \n"
59" -l Set the echo tail length in ms. Default is 200 ms \n"
60" -r Set repeat count (default=1) \n"
61" -a Algorithm: 0=default, 1=speex, 2=echo suppress, 3=WebRtc \n"
64" Note that for the AEC internal buffering mechanism, it is required\n"
65" that the echoed signal (in REC.WAV) is delayed from the \n"
66" corresponding reference signal (in PLAY.WAV) at least as much as \n"
67" frame time + PJMEDIA_WSOLA_DELAY_MSEC. In this application, frame \n"
68" time is 20 ms and default PJMEDIA_WSOLA_DELAY_MSEC is 5 ms, hence \n"
69" 25 ms delay is the minimum value. \n";
77static void app_perror( const char *sender, const char *title, pj_status_t st)
82 PJ_LOG(3,(sender, "%s: %s", title, errmsg));
89int main( int argc, char *argv[])
101 unsigned latency_ms = 25;
102 unsigned tail_ms = TAIL_LENGTH;
104 int i, repeat=1, interactive=0, c;
107 while ((c=pj_getopt(argc, argv, "d:l:a:r:i")) !=-1) {
110 latency_ms = atoi(pj_optarg);
111 if (latency_ms < 25) {
112 puts( "Invalid delay");
117 tail_ms = atoi(pj_optarg);
121 int alg = atoi(pj_optarg);
136 puts( "Invalid algorithm");
143 repeat = atoi(pj_optarg);
145 puts( "Invalid repeat count");
156 if (argc - pj_optind != 3) {
157 puts( "Error: missing argument(s)");
189 app_perror(THIS_FILE, "Error opening playback WAV file", status);
198 app_perror(THIS_FILE, "Error opening recorded WAV file", status);
204 puts( "Error: clock rate mismatch in the WAV files");
210 puts( "Error: clock rate mismatch in the WAV files");
222 app_perror(THIS_FILE, "Error opening output WAV file", status);
233 app_perror(THIS_FILE, "Error creating EC", status);
242 for (i=0; i < repeat; ++i) {
271 PJ_LOG(3,(THIS_FILE, "Processed %3d.%03ds audio",
272 i / 1000, i % 1000));
300 puts( "ENTER to quit");
301 dummy = fgets(s, sizeof(s), stdin);
pj_status_t pjmedia_endpt_create(pj_pool_factory *pf, pj_ioqueue_t *ioqueue, unsigned worker_cnt, pjmedia_endpt **p_endpt) Definition: endpoint.h:127
pj_status_t pjmedia_endpt_destroy(pjmedia_endpt *endpt) Definition: endpoint.h:168
pj_status_t pj_init(void)
void pj_caching_pool_destroy(pj_caching_pool *ch_pool)
void pj_caching_pool_init(pj_caching_pool *ch_pool, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
#define PJ_LOG(level, arg)
pj_pool_factory_policy pj_pool_factory_default_policy
void * pj_pool_alloc(pj_pool_t *pool, pj_size_t size)
pj_pool_t * pj_pool_create(pj_pool_factory *factory, const char *name, pj_size_t initial_size, pj_size_t increment_size, pj_pool_callback *callback)
void pj_pool_release(pj_pool_t *pool)
pj_uint32_t pj_elapsed_msec(const pj_timestamp *start, const pj_timestamp *stop)
pj_status_t pj_get_timestamp(pj_timestamp *ts)
#define PJ_ASSERT_RETURN(expr, retval)
#define PJ_UNUSED_ARG(arg)
pj_str_t pj_strerror(pj_status_t statcode, char *buf, pj_size_t bufsize)
PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.
|