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
This commit is contained in:
Torrey Searle
2017-06-26 14:52:52 +02:00
committed by George Joseph
parent c16000f201
commit 423d01cf16
10 changed files with 293 additions and 37 deletions

View File

@@ -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));
if (result == 0) {
*buf = ast_strdup(dtmf_str);
} else {
*buf = ast_strdup("none");
}
*buf = ast_strdup(*buf);
return 0;
}