Skip to content

Commit

Permalink
fixes #67 - OnAir Crash on hangup
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Apr 2, 2019
1 parent 8cbff79 commit 8ebfe28
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/modules/webapp/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void webapp_options_set(char *key, char *value)
if (!str_cmp(key, "onair")) {
static struct call *call = NULL;
if (!str_cmp(value, "false")) {
call = webapp_get_call("sip:stream@studio-link.de");
ua_hangup(uag_current(), call, 0, NULL);
}
else {
Expand All @@ -71,8 +72,7 @@ void webapp_options_set(char *key, char *value)
system(command);

ua_connect(uag_current(), &call, NULL,
"stream", VIDMODE_ON);

"stream@studio-link.de", VIDMODE_OFF);
}
}
#endif
Expand Down
18 changes: 18 additions & 0 deletions src/modules/webapp/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,21 @@ int webapp_load_file(struct mbuf *mb, char *filename)

return err;
}


struct call* webapp_get_call(char *sid)
{
struct list *calls = ua_calls(uag_current());
struct call *call = NULL;
struct le *le;
char id[64] = {0};

for (le = list_head(calls); le; le = le->next) {
call = le->data;
re_snprintf(id, sizeof(id), "%x", call);
if (!str_cmp(id, sid))
return call;
}

return NULL;
}
1 change: 1 addition & 0 deletions src/modules/webapp/webapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void webapp_odict_add(struct odict *og, const struct odict_entry *e);
int webapp_write_file(char *string, char *filename);
int webapp_write_file_json(struct odict *json, char *filename);
int webapp_load_file(struct mbuf *mb, char *filename);
struct call* webapp_get_call(char *sid);

/*
* slrtaudio module
Expand Down
18 changes: 1 addition & 17 deletions src/modules/webapp/ws_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@

#define SIP_CLOSED "{ \"callback\": \"CLOSED\"}"

static struct call* get_call(char *sid)
{
struct list *calls = ua_calls(uag_current());
struct call *call = NULL;
struct le *le;
char id[64] = {0};

for (le = list_head(calls); le; le = le->next) {
call = le->data;
re_snprintf(id, sizeof(id), "%x", call);
if (!str_cmp(id, sid))
return call;
}

return NULL;
}

static bool active_calls(void)
{
Expand Down Expand Up @@ -59,7 +43,7 @@ void webapp_ws_calls(const struct websock_hdr *hdr,
if (!key)
goto out;

call = get_call(key->u.str);
call = webapp_get_call(key->u.str);

if (!str_cmp(e->u.str, "accept")) {
ua_answer(uag_current(), call);
Expand Down

0 comments on commit 8ebfe28

Please sign in to comment.