summaryrefslogtreecommitdiff
path: root/res/res_pjsip/pjsip_configuration.c
diff options
context:
space:
mode:
authorTorrey Searle <torrey@voxbone.com>2017-06-26 14:52:52 +0200
committerGeorge Joseph <gjoseph@digium.com>2017-08-01 15:41:53 -0600
commit65c560894d0d53167af9c6013c7f93703ebb6722 (patch)
tree9338ffeb939a3b0b3866241d8005dd2d2bd50e45 /res/res_pjsip/pjsip_configuration.c
parentb3914df10bbb61494f3023a8a22894e4aeeadf05 (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.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 9f9de36fa..4e12b04cc 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -366,47 +366,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;
}