Skip to content

Commit

Permalink
event: make struct bevent private
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed May 3, 2024
1 parent d8cd089 commit af28d46
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
14 changes: 3 additions & 11 deletions include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,17 +872,7 @@ enum ua_event {
};


struct bevent {
enum ua_event ev;
const char *txt;
int err;
union {
struct ua *ua;
struct call *call;
const struct sip_msg *msg;
void *arg;
} u;
};
struct bevent;


/** SIP auto answer method */
Expand Down Expand Up @@ -1688,6 +1678,8 @@ 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);
enum ua_event bevent_get_enum(const struct bevent *event);
const char *bevent_get_text(const struct bevent *event);


/*
Expand Down
4 changes: 2 additions & 2 deletions modules/menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ static bool event_handler(struct bevent *event, void *arg)
uint32_t count;
struct pl val;
char * uri;
enum ua_event ev = event->ev;
const char *prm = event->txt;
enum ua_event ev = bevent_get_enum(event);
const char *prm = bevent_get_text(event);
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
struct account *acc = ua_account(bevent_get_ua(event));
Expand Down
25 changes: 25 additions & 0 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ enum {
};


struct bevent {
enum ua_event ev;
const char *txt;
int err;
union {
struct ua *ua;
struct call *call;
const struct sip_msg *msg;
void *arg;
} u;
};


struct ua_eh {
struct le le;
ua_event_h *h;
Expand Down Expand Up @@ -229,6 +242,18 @@ const struct sip_msg *bevent_get_msg(const struct bevent *event)
}


enum ua_event bevent_get_enum(const struct bevent *event)
{
return event ? event->ev : UA_EVENT_MAX;
}


const char *bevent_get_text(const struct bevent *event)
{
return event ? event->txt : "";
}


static int add_rtcp_stats(struct odict *od_parent, const struct rtcp_stats *rs)
{
struct odict *od = NULL, *tx = NULL, *rx = NULL;
Expand Down
8 changes: 4 additions & 4 deletions test/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ static bool event_handler(struct bevent *event, void *arg)
struct agent *ag;
struct stream *strm = NULL;
char curi[256];
enum ua_event ev = event->ev;
const char *prm = event->txt;
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
enum ua_event ev = bevent_get_enum(event);
const char *prm = bevent_get_text(event);
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
int err = 0;

#if 1
Expand Down
8 changes: 4 additions & 4 deletions test/ua.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ static bool event_handler(struct bevent *event, void *arg)
{
struct test *t = arg;
size_t i;
enum ua_event ev = event->ev;
const char *prm = event->txt;
struct call *call = bevent_get_call(event);
struct ua *ua = bevent_get_ua(event);
enum ua_event ev = bevent_get_enum(event);
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:user@127.0.0.1";
(void)call;
Expand Down

0 comments on commit af28d46

Please sign in to comment.