summaryrefslogtreecommitdiff
path: root/test/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/call.c')
-rw-r--r--test/call.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/call.c b/test/call.c
index f3881c6..60af1b2 100644
--- a/test/call.c
+++ b/test/call.c
@@ -703,3 +703,67 @@ int test_call_video(void)
return err;
}
#endif
+
+
+static void mock_sample_handler(const int16_t *sampv, size_t sampc, void *arg)
+{
+ struct fixture *fix = arg;
+ bool got_aulevel;
+ (void)sampv;
+ (void)sampc;
+
+ got_aulevel =
+ 0 == audio_level_get(call_audio(ua_call(fix->a.ua)), NULL) &&
+ 0 == audio_level_get(call_audio(ua_call(fix->b.ua)), NULL);
+
+ if (got_aulevel)
+ re_cancel();
+}
+
+
+int test_call_aulevel(void)
+{
+ struct fixture fix, *f = &fix;
+ struct ausrc *ausrc = NULL;
+ struct auplay *auplay = NULL;
+ double lvl;
+ int err = 0;
+
+ /* Use a low packet time, so the test completes quickly */
+ fixture_init_prm(f, ";ptime=1");
+
+ conf_config()->audio.level = true;
+
+ err = mock_ausrc_register(&ausrc);
+ TEST_ERR(err);
+ err = mock_auplay_register(&auplay, mock_sample_handler, f);
+ TEST_ERR(err);
+
+ f->estab_action = ACTION_NOTHING;
+
+ /* 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);
+
+ /* verify audio silence */
+ err = audio_level_get(call_audio(ua_call(f->a.ua)), &lvl);
+ TEST_ERR(err);
+ ASSERT_EQ(-96, lvl);
+ err = audio_level_get(call_audio(ua_call(f->b.ua)), &lvl);
+ TEST_ERR(err);
+ ASSERT_EQ(-96, lvl);
+
+ out:
+ conf_config()->audio.level = false;
+
+ fixture_close(f);
+ mem_deref(auplay);
+ mem_deref(ausrc);
+
+ return err;
+}