res_pjsip: Add DTMF INFO Failback mode

The existing auto dtmf mode reverts to inband if 4733 fails to be
negotiated.  This patch adds a new mode auto_info which will
switch to INFO instead of inband if 4733 is not available.

ASTERISK-27066 #close

Change-Id: Id185b11e84afd9191a2f269e8443019047765e91
This commit is contained in:
Torrey Searle
2017-06-15 10:12:41 +02:00
parent 764d04fa87
commit 9fbc34d2bd
7 changed files with 121 additions and 18 deletions

View File

@@ -1708,14 +1708,20 @@ static int chan_pjsip_digit_begin(struct ast_channel *chan, char digit)
}
ast_rtp_instance_dtmf_begin(media->rtp, digit);
break;
break;
case AST_SIP_DTMF_AUTO:
if (!media || !media->rtp || (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_INBAND)) {
return -1;
}
if (!media || !media->rtp || (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_INBAND)) {
return -1;
}
ast_rtp_instance_dtmf_begin(media->rtp, digit);
break;
ast_rtp_instance_dtmf_begin(media->rtp, digit);
break;
case AST_SIP_DTMF_AUTO_INFO:
if (!media || !media->rtp || (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_NONE)) {
return -1;
}
ast_rtp_instance_dtmf_begin(media->rtp, digit);
break;
case AST_SIP_DTMF_NONE:
break;
case AST_SIP_DTMF_INBAND:
@@ -1816,6 +1822,20 @@ static int chan_pjsip_digit_end(struct ast_channel *ast, char digit, unsigned in
int res = 0;
switch (channel->session->endpoint->dtmf) {
case AST_SIP_DTMF_AUTO_INFO:
{
if (!media || !media->rtp) {
return -1;
}
if (ast_rtp_instance_dtmf_mode_get(media->rtp) != AST_RTP_DTMF_MODE_NONE) {
ast_debug(3, "Told to send end of digit on Auto-Info channel %s RFC4733 negotiated so using it.\n", ast_channel_name(ast));
ast_rtp_instance_dtmf_end_with_duration(media->rtp, digit, duration);
break;
}
/* If RFC_4733 was not negotiated, fail through to the DTMF_INFO processing */
ast_debug(3, "Told to send end of digit on Auto-Info channel %s RFC4733 NOT negotiated using INFO instead.\n", ast_channel_name(ast));
}
case AST_SIP_DTMF_INFO:
{
struct info_dtmf_data *dtmf_data = info_dtmf_data_alloc(channel->session, digit, duration);
@@ -1848,14 +1868,15 @@ static int chan_pjsip_digit_end(struct ast_channel *ast, char digit, unsigned in
}
ast_rtp_instance_dtmf_end_with_duration(media->rtp, digit, duration);
break;
case AST_SIP_DTMF_AUTO:
if (!media || !media->rtp || (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_INBAND)) {
return -1;
}
break;
case AST_SIP_DTMF_AUTO:
if (!media || !media->rtp || (ast_rtp_instance_dtmf_mode_get(media->rtp) == AST_RTP_DTMF_MODE_INBAND)) {
return -1;
}
ast_rtp_instance_dtmf_end_with_duration(media->rtp, digit, duration);
break;
ast_rtp_instance_dtmf_end_with_duration(media->rtp, digit, duration);
break;
case AST_SIP_DTMF_NONE:
break;