diff options
author | Alfred E. Heggestad <alfred.heggestad@gmail.com> | 2017-11-09 17:10:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-09 17:10:07 +0100 |
commit | a9e09b2c0a99efddfcc16f5e413e2d73aa0e1732 (patch) | |
tree | e53a738b94461189540bfe1a2c7b643b41ac488f /test/call.c | |
parent | 4d5d9a6e4e0811b52b427602261d5e0b9bc85f21 (diff) |
add support for specifying sample format (#317)
API: ausrc and auplay
- add config items for ausrc/auplay format:
ausrc_format s16|float
auplay_format s16|float
- audio.c: convert audio samples to/from signed 16-bit
Modules:
alsa
add test for sample format FLOAT
rst: add support for FLOAT sample format
audiounit: add support for FLOAT sample format
coreaudio: check for signed 16-bit audio format
oss: check for signed 16-bit sample format
winwave: check for S16LE
pulse: add support for FLOAT sample format
sndio: check for S16 format
gst1: check sample format
aufile: check sample format
aubridge: check sample format
gst: check sample format
opensles: check for S16 sample format
jack: check sample format
alsa: remove usage of local config
test: change samples to void pointer
test: change sample type to void pointer
Diffstat (limited to 'test/call.c')
-rw-r--r-- | test/call.c | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/test/call.c b/test/call.c index 0cd0394..b86ce6a 100644 --- a/test/call.c +++ b/test/call.c @@ -5,6 +5,7 @@ */ #include <string.h> #include <re.h> +#include <rem.h> #include <baresip.h> #include "test.h" @@ -721,7 +722,7 @@ int test_call_video(void) #endif -static void mock_sample_handler(const int16_t *sampv, size_t sampc, void *arg) +static void mock_sample_handler(const void *sampv, size_t sampc, void *arg) { struct fixture *fix = arg; bool got_aulevel; @@ -819,3 +820,68 @@ int test_call_progress(void) return err; } + + +static void float_sample_handler(const void *sampv, size_t sampc, void *arg) +{ + struct fixture *fix = arg; + (void)sampv; + (void)sampc; + + if (sampc && fix->a.n_established && fix->b.n_established) + re_cancel(); +} + + +int test_call_format_float(void) +{ + struct fixture fix, *f = &fix; + struct ausrc *ausrc = NULL; + struct auplay *auplay = NULL; + int err = 0; + + fixture_init(f); + + conf_config()->audio.src_fmt = AUFMT_FLOAT; + conf_config()->audio.play_fmt = AUFMT_FLOAT; + + err = mock_ausrc_register(&ausrc); + TEST_ERR(err); + err = mock_auplay_register(&auplay, float_sample_handler, f); + TEST_ERR(err); + + f->estab_action = ACTION_NOTHING; + + f->behaviour = BEHAVIOUR_ANSWER; + + /* Make a call from A to B */ + err = ua_connect(f->a.ua, 0, NULL, f->buri, NULL, VIDMODE_OFF); + TEST_ERR(err); + + /* run main-loop with timeout, wait for events */ + err = re_main_timeout(5000); + TEST_ERR(err); + TEST_ERR(fix.err); + + ASSERT_EQ(0, fix.a.n_incoming); + ASSERT_EQ(1, fix.a.n_established); + ASSERT_EQ(0, fix.a.n_closed); + ASSERT_EQ(0, fix.a.close_scode); + + ASSERT_EQ(1, fix.b.n_incoming); + ASSERT_EQ(1, fix.b.n_established); + ASSERT_EQ(0, fix.b.n_closed); + + out: + conf_config()->audio.src_fmt = AUFMT_S16LE; + conf_config()->audio.play_fmt = AUFMT_S16LE; + + fixture_close(f); + mem_deref(auplay); + mem_deref(ausrc); + + if (fix.err) + return fix.err; + + return err; +} |