diff --git a/include/baresip.h b/include/baresip.h index 5b223f4a1..3c833533e 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -7,6 +7,7 @@ #ifndef BARESIP_H__ #define BARESIP_H__ +#include #ifdef __cplusplus extern "C" { #endif @@ -875,6 +876,16 @@ enum ua_event { }; +enum bevent_class { + BEVENT_CLASS_UA = 1, + BEVENT_CLASS_CALL = 2, + BEVENT_CLASS_SIP = 4, + BEVENT_CLASS_APP = 8, + BEVENT_CLASS_UNDEFINED = 32768, + BEVENT_CLASS_ALL = 65535, +}; + + struct bevent; @@ -1667,7 +1678,7 @@ int odict_encode_bevent(struct odict *od, struct bevent *event); int event_add_au_jb_stat(struct odict *od_parent, const struct call *call); int uag_event_register(ua_event_h *eh, void *arg); void uag_event_unregister(ua_event_h *eh); -int bevent_register(bevent_h *eh, void *arg); +int bevent_register(bevent_h *eh, void *arg, uint16_t mask); void bevent_unregister(bevent_h *eh); void ua_event(struct ua *ua, enum ua_event ev, struct call *call, const char *fmt, ...); diff --git a/src/bevent.c b/src/bevent.c index cc5231d91..ddbfe2cbd 100644 --- a/src/bevent.c +++ b/src/bevent.c @@ -48,6 +48,7 @@ static void eh_destructor(void *arg) struct ehe { struct le le; + uint16_t mask; bevent_h *h; void *arg; }; @@ -67,15 +68,6 @@ static void ehe_destructor(void *arg) } -enum bevent_class { - BEVENT_CLASS_UA, - BEVENT_CLASS_CALL, - BEVENT_CLASS_APP, - BEVENT_CLASS_SIP, - BEVENT_CLASS_UNDEFINED -}; - - static enum bevent_class bevent_class(enum ua_event ev) { switch (ev) { @@ -631,7 +623,7 @@ void uag_event_unregister(ua_event_h *h) * * @return 0 if success, otherwise errorcode */ -int bevent_register(bevent_h *eh, void *arg) +int bevent_register(bevent_h *eh, void *arg, uint16_t mask) { struct ehe *ehe; @@ -646,6 +638,7 @@ int bevent_register(bevent_h *eh, void *arg) ehe->h = eh; ehe->arg = arg; + ehe->mask = mask; list_append(&ehel, &ehe->le, ehe); @@ -791,7 +784,8 @@ static void bevent_emit_base(struct bevent *event) struct ehe *ehe = le->data; le = le->next; - ehe->h(event->ev, event, ehe->arg); + if (ehe->mask & bevent_class(event->ev)) + ehe->h(event->ev, event, ehe->arg); if (event->stop) return;