From 86262a6fc17e19e2be82eb8a2a05ec0f884d3d38 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 26 Sep 2015 16:19:07 +0200 Subject: ua: add UA_EVENT_CALL_DTMF_START/END the patch was written by Gary Metalle, thanks a lot! --- include/baresip.h | 2 ++ src/ua.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 59cc140..8474642 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -469,6 +469,8 @@ enum ua_event { UA_EVENT_CALL_ESTABLISHED, UA_EVENT_CALL_CLOSED, UA_EVENT_CALL_TRANSFER_FAILED, + UA_EVENT_CALL_DTMF_START, + UA_EVENT_CALL_DTMF_END, UA_EVENT_MAX, }; diff --git a/src/ua.c b/src/ua.c index 44834c4..8585309 100644 --- a/src/ua.c +++ b/src/ua.c @@ -368,11 +368,32 @@ static void call_event_handler(struct call *call, enum call_event ev, } +static void call_dtmf_handler(struct call *call, char key, void *arg) +{ + struct ua *ua = arg; + char key_str[2]; + + MAGIC_CHECK(ua); + + if (key != '\0') { + + key_str[0] = key; + key_str[1] = '\0'; + + ua_event(ua, UA_EVENT_CALL_DTMF_START, call, key_str); + } + else { + ua_event(ua, UA_EVENT_CALL_DTMF_END, call, NULL); + } +} + + static int ua_call_alloc(struct call **callp, struct ua *ua, enum vidmode vidmode, const struct sip_msg *msg, struct call *xcall, const char *local_uri) { struct call_prm cprm; + int err; if (*callp) { warning("ua: call_alloc: call is already allocated\n"); @@ -382,11 +403,17 @@ static int ua_call_alloc(struct call **callp, struct ua *ua, cprm.vidmode = vidmode; cprm.af = ua->af; - return call_alloc(callp, conf_config(), &ua->calls, - ua->acc->dispname, - local_uri ? local_uri : ua->acc->aor, - ua->acc, ua, &cprm, - msg, xcall, call_event_handler, ua); + err = call_alloc(callp, conf_config(), &ua->calls, + ua->acc->dispname, + local_uri ? local_uri : ua->acc->aor, + ua->acc, ua, &cprm, + msg, xcall, call_event_handler, ua); + if (err) + return err; + + call_set_handlers(*callp, NULL, call_dtmf_handler, ua); + + return 0; } @@ -1455,6 +1482,8 @@ const char *uag_event_str(enum ua_event ev) case UA_EVENT_CALL_ESTABLISHED: return "CALL_ESTABLISHED"; case UA_EVENT_CALL_CLOSED: return "CALL_CLOSED"; case UA_EVENT_CALL_TRANSFER_FAILED: return "TRANSFER_FAILED"; + case UA_EVENT_CALL_DTMF_START: return "CALL_DTMF_START"; + case UA_EVENT_CALL_DTMF_END: return "CALL_DTMF_END"; default: return "?"; } } -- cgit v1.2.3