diff options
author | Torrey Searle <torrey@voxbone.com> | 2017-06-26 14:52:52 +0200 |
---|---|---|
committer | George Joseph <gjoseph@digium.com> | 2017-08-01 15:43:51 -0600 |
commit | 423d01cf162224ac9316ea0beaaada9cd4c162bb (patch) | |
tree | f519158effe614c4d16b5039648595d8eef28460 /res/res_pjsip/pjsip_configuration.c | |
parent | c16000f201520b398cfaaaeeff74da171fa3a2ee (diff) |
chan_pjsip: add a new function PJSIP_DTMF_MODE
This function is a replica of SIPDtmfMode, allowing the DTMF mode of a
PJSIP call to be modified on a per-call basis
ASTERISK-27085 #close
Change-Id: I20eef5da3e5d1d3e58b304416bc79683f87e7612
Diffstat (limited to 'res/res_pjsip/pjsip_configuration.c')
-rw-r--r-- | res/res_pjsip/pjsip_configuration.c | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 893c81edd..39e10c5e4 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -368,47 +368,29 @@ static int contact_acl_to_str(const void *obj, const intptr_t *args, char **buf) static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) { struct ast_sip_endpoint *endpoint = obj; + enum ast_sip_dtmf_mode dtmf = ast_sip_str_to_dtmf(var->value); - if (!strcasecmp(var->value, "rfc4733")) { - endpoint->dtmf = AST_SIP_DTMF_RFC_4733; - } else if (!strcasecmp(var->value, "inband")) { - endpoint->dtmf = AST_SIP_DTMF_INBAND; - } else if (!strcasecmp(var->value, "auto_info")) { - endpoint->dtmf = AST_SIP_DTMF_AUTO_INFO; - } else if (!strcasecmp(var->value, "info")) { - endpoint->dtmf = AST_SIP_DTMF_INFO; - } else if (!strcasecmp(var->value, "auto")) { - endpoint->dtmf = AST_SIP_DTMF_AUTO; - } else if (!strcasecmp(var->value, "none")) { - endpoint->dtmf = AST_SIP_DTMF_NONE; - } else { + if (dtmf == -1) { return -1; } + endpoint->dtmf = dtmf; return 0; } static int dtmf_to_str(const void *obj, const intptr_t *args, char **buf) { const struct ast_sip_endpoint *endpoint = obj; + char dtmf_str[20]; + int result = -1; - switch (endpoint->dtmf) { - case AST_SIP_DTMF_RFC_4733 : - *buf = "rfc4733"; break; - case AST_SIP_DTMF_INBAND : - *buf = "inband"; break; - case AST_SIP_DTMF_INFO : - *buf = "info"; break; - case AST_SIP_DTMF_AUTO : - *buf = "auto"; break; - case AST_SIP_DTMF_AUTO_INFO : - *buf = "auto_info"; - break; - default: - *buf = "none"; - } + result = ast_sip_dtmf_to_str(endpoint->dtmf, dtmf_str, sizeof(dtmf_str)); - *buf = ast_strdup(*buf); + if (result == 0) { + *buf = ast_strdup(dtmf_str); + } else { + *buf = ast_strdup("none"); + } return 0; } |