Skip to content

Commit

Permalink
test: use bevent API
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Aug 12, 2024
1 parent 0a753af commit 5643830
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
22 changes: 10 additions & 12 deletions test/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ struct fixture {
f->a.peer = &f->b; \
f->b.peer = &f->a; \
\
err = uag_event_register(event_handler, f); \
err = bevent_register(event_handler, f); \
TEST_ERR(err); \
\
err = sip_transp_laddr(uag_sip(), &f->laddr_udp, \
Expand Down Expand Up @@ -187,7 +187,7 @@ struct fixture {
\
module_unload("g711"); \
\
uag_event_unregister(event_handler); \
bevent_unregister(event_handler); \
\
ua_stop_all(true); \
ua_close(); \
Expand Down Expand Up @@ -433,7 +433,7 @@ static void check_ack(void *arg)
ag->gotack = !call_ack_pending(ua_call(ag->ua));

if (ag->gotack)
ua_event(ag->ua, UA_EVENT_CUSTOM, ua_call(ag->ua), "gotack");
bevent_ua_emit(UA_EVENT_CUSTOM, ag->ua, "gotack");

else
tmr_start(&ag->tmr_ack, 1, check_ack, ag);
Expand Down Expand Up @@ -607,16 +607,17 @@ static void process_rules(struct agent *ag, enum ua_event ev, const char *prm)
}


static void event_handler(struct ua *ua, enum ua_event ev,
struct call *call, const char *prm, void *arg)
static void event_handler(enum ua_event ev, struct bevent *event, void *arg)
{
struct fixture *f = arg;
struct call *call2 = NULL;
struct agent *ag;
struct stream *strm = NULL;
char curi[256];
const char *prm = bevent_get_text(event);
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
int err = 0;
(void)prm;

#if 1
info("test: [ %s ] event: %s (%s)\n",
Expand Down Expand Up @@ -1286,8 +1287,7 @@ static void mock_vidisp_handler(const struct vidframe *frame,

++ag->n_vidframe;
ua = ag->ua;
ua_event(ua, UA_EVENT_CUSTOM, ua_call(ua), "vidframe %u",
ag->n_vidframe);
bevent_ua_emit(UA_EVENT_CUSTOM, ua, "vidframe %u", ag->n_vidframe);

out:
if (err)
Expand Down Expand Up @@ -1599,8 +1599,7 @@ static void auframe_handler(struct auframe *af, const char *dev, void *arg)
++ag->n_auframe;
(void)audio_level_get(call_audio(ua_call(ua)), &ag->aulvl);

ua_event(ua, UA_EVENT_CUSTOM, ua_call(ua), "auframe %u",
ag->n_auframe);
bevent_ua_emit(UA_EVENT_CUSTOM, ua, "auframe %u", ag->n_auframe);

out:
if (err)
Expand Down Expand Up @@ -2388,8 +2387,7 @@ static void delayed_audio_debug(void *arg)

++ag->n_audebug;

ua_event(ag->ua, UA_EVENT_CUSTOM, ua_call(ag->ua), "audebug %u",
ag->n_audebug);
bevent_ua_emit(UA_EVENT_CUSTOM, ag->ua, "audebug %u", ag->n_audebug);

tmr_start(&ag->tmr, 2, delayed_audio_debug, ag);
out:
Expand Down
26 changes: 14 additions & 12 deletions test/ua.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ static void test_abort(struct test *t, int err)
}


static void ua_event_handler(struct ua *ua, enum ua_event ev,
struct call *call, const char *prm, void *arg)
static void event_handler(enum ua_event ev, struct bevent *event, void *arg)
{
struct test *t = arg;
size_t i;
const char *prm = bevent_get_text(event);
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
int err = 0;
const char referto[] = "sip:[email protected]";
(void)call;
Expand Down Expand Up @@ -135,7 +137,7 @@ static int reg(enum sip_transp tp)
err = ua_register(t.ua);
TEST_ERR(err);

err = uag_event_register(ua_event_handler, &t);
err = bevent_register(event_handler, &t);
if (err)
goto out;

Expand All @@ -155,7 +157,7 @@ static int reg(enum sip_transp tp)
if (err) {
warning("selftest: ua_register test failed (%m)\n", err);
}
uag_event_unregister(ua_event_handler);
bevent_unregister(event_handler);
test_reset(&t);

return err;
Expand Down Expand Up @@ -363,7 +365,7 @@ static int reg_dns(enum sip_transp tp)
err = ua_register(t.ua);
TEST_ERR(err);

err = uag_event_register(ua_event_handler, &t);
err = bevent_register(event_handler, &t);
if (err)
goto out;

Expand All @@ -386,7 +388,7 @@ static int reg_dns(enum sip_transp tp)
if (err) {
warning("selftest: ua_register test failed (%m)\n", err);
}
uag_event_unregister(ua_event_handler);
bevent_unregister(event_handler);

test_reset(&t);

Expand Down Expand Up @@ -469,7 +471,7 @@ static int reg_auth(enum sip_transp tp)
err = ua_register(t.ua);
TEST_ERR(err);

err = uag_event_register(ua_event_handler, &t);
err = bevent_register(event_handler, &t);
if (err)
goto out;

Expand All @@ -491,7 +493,7 @@ static int reg_auth(enum sip_transp tp)
if (err) {
warning("selftest: ua_register test failed (%m)\n", err);
}
uag_event_unregister(ua_event_handler);
bevent_unregister(event_handler);
test_reset(&t);

return err;
Expand Down Expand Up @@ -640,7 +642,7 @@ static int reg_auth_dns(enum sip_transp tp)
err = ua_register(t.ua);
TEST_ERR(err);

err = uag_event_register(ua_event_handler, &t);
err = bevent_register(event_handler, &t);
if (err)
goto out;

Expand Down Expand Up @@ -672,7 +674,7 @@ static int reg_auth_dns(enum sip_transp tp)
if (err) {
warning("selftest: ua_register test failed (%m)\n", err);
}
uag_event_unregister(ua_event_handler);
bevent_unregister(event_handler);

test_reset(&t);

Expand Down Expand Up @@ -903,7 +905,7 @@ static int test_ua_refer_base(enum sip_transp transp)

test_init(&t);

err = uag_event_register(ua_event_handler, &t);
err = bevent_register(event_handler, &t);
TEST_ERR(err);

err = ua_init("test",
Expand Down Expand Up @@ -950,7 +952,7 @@ static int test_ua_refer_base(enum sip_transp transp)
out:
test_reset(&t);

uag_event_unregister(ua_event_handler);
bevent_unregister(event_handler);
ua_stop_all(true);
ua_close();

Expand Down

0 comments on commit 5643830

Please sign in to comment.