Skip to content

Commit

Permalink
bevent: add core bevent API (baresip#3090)
Browse files Browse the repository at this point in the history
* bevent: add new bevent API

* test: rename test/event.c -> test/bevent.c

* test: add bevent test

* bevent: rename bevent_get_enum() to bevent_get_type()
  • Loading branch information
cspiel1 authored Aug 5, 2024
1 parent 8fbb8e9 commit 57e5d6d
Show file tree
Hide file tree
Showing 7 changed files with 669 additions and 62 deletions.
23 changes: 23 additions & 0 deletions include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,15 @@ enum ua_event {
UA_EVENT_MODULE,
UA_EVENT_END_OF_FILE,
UA_EVENT_CUSTOM,
UA_EVENT_SIPSESS_CONN,

UA_EVENT_MAX,
};


struct bevent;


/** SIP auto answer method */
enum answer_method {
ANSM_NONE = 0,
Expand All @@ -884,6 +889,7 @@ enum answer_method {
/** Defines the User-Agent event handler */
typedef void (ua_event_h)(struct ua *ua, enum ua_event ev,
struct call *call, const char *prm, void *arg);
typedef void (bevent_h)(enum ua_event ev, struct bevent *event, void *arg);
typedef void (options_resp_h)(int err, const struct sip_msg *msg, void *arg);
typedef void (refer_resp_h)(int err, const struct sip_msg *msg, void *arg);

Expand Down Expand Up @@ -1657,14 +1663,31 @@ void module_app_unload(void);

int event_encode_dict(struct odict *od, struct ua *ua, enum ua_event ev,
struct call *call, const char *prm);
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);
void bevent_unregister(bevent_h *eh);
void ua_event(struct ua *ua, enum ua_event ev, struct call *call,
const char *fmt, ...);
int bevent_app_emit(enum ua_event ev, void *arg, const char *fmt, ...);
int bevent_ua_emit(enum ua_event ev, struct ua *ua, const char *fmt, ...);
int bevent_call_emit(enum ua_event ev, struct call *call,
const char *fmt, ...);
int bevent_sip_msg_emit(enum ua_event ev, const struct sip_msg *msg,
const char *fmt, ...);
void module_event(const char *module, const char *event, struct ua *ua,
struct call *call, const char *fmt, ...);
const char *uag_event_str(enum ua_event ev);
struct call *bevent_get_call(const struct bevent *event);
struct ua *bevent_get_ua(const struct bevent *event);
const struct sip_msg *bevent_get_msg(const struct bevent *event);
void *bevent_get_apparg(const struct bevent *event);
enum ua_event bevent_get_type(const struct bevent *event);
const char *bevent_get_text(const struct bevent *event);
void bevent_set_error(struct bevent *event, int err);
void bevent_stop(struct bevent *event);


/*
Expand Down
Loading

0 comments on commit 57e5d6d

Please sign in to comment.