diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-11-19 14:48:48 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-11-19 14:48:48 +0000 |
commit | 9b44f51f9e162f47a951d3e933e0b0e462db576b (patch) | |
tree | 2209f4291b023ca1fb3307cfa18ca308cfbd80bf /pjsip-apps/src/samples | |
parent | 79c94381fbd13ef276a89f3a823cb5262a5c650b (diff) |
Small modifications to level.c sample to print out the timeline and linear level
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2369 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/samples')
-rw-r--r-- | pjsip-apps/src/samples/level.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/pjsip-apps/src/samples/level.c b/pjsip-apps/src/samples/level.c index 4d4d7ee0..2183675c 100644 --- a/pjsip-apps/src/samples/level.c +++ b/pjsip-apps/src/samples/level.c @@ -72,7 +72,7 @@ static int app_perror( const char *sender, const char *title, */ int main(int argc, char *argv[]) { - enum { NSAMPLES = 160, COUNT=100 }; + enum { NSAMPLES = 640, COUNT=100 }; pj_caching_pool cp; pjmedia_endpt *med_endpt; pj_pool_t *pool; @@ -123,10 +123,19 @@ int main(int argc, char *argv[]) return 1; } + if (file_port->info.samples_per_frame > NSAMPLES) { + app_perror(THIS_FILE, "WAV clock rate is too big", PJ_EINVAL); + return 1; + } + + puts("Time\tPCMU\tLinear"); + puts("------------------------"); + for (i=0; i<COUNT; ++i) { pj_int16_t framebuf[NSAMPLES]; pjmedia_frame frm; pj_int32_t level32; + unsigned ms; int level; frm.buf = framebuf; @@ -134,10 +143,14 @@ int main(int argc, char *argv[]) pjmedia_port_get_frame(file_port, &frm); - level32 = pjmedia_calc_avg_signal( framebuf, NSAMPLES ); + level32 = pjmedia_calc_avg_signal(framebuf, + file_port->info.samples_per_frame); level = pjmedia_linear2ulaw(level32) ^ 0xFF; - printf("%d ", level); + ms = i * 1000 * file_port->info.samples_per_frame / + file_port->info.clock_rate; + printf("%03d.%03d\t%7d\t%7d\n", + ms/1000, ms%1000, level, level32); } puts(""); |