add PAUSE_BETWEEN_DTMF rtp bug for sonus to delay sending 2833 digits so their buffering is not overwhealmed

This commit is contained in:
Anthony Minessale 2011-08-24 15:36:59 -05:00
parent 2344bd05e5
commit 0e5b694c44
3 changed files with 31 additions and 1 deletions

View File

@ -644,7 +644,7 @@ typedef enum {
This flag will never send any. Sheesh....
*/
RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6)
RTP_BUG_IGNORE_DTMF_DURATION = (1 << 6),
/*
Guess Who? ... Yep, Sonus (and who know's who else) likes to interweave DTMF with the audio stream making it take
@ -652,6 +652,15 @@ typedef enum {
This flag will treat every dtmf as if it were 50ms and queue it on recipt of the leading packet rather than at the end.
*/
RTP_BUG_PAUSE_BETWEEN_DTMF = (1 << 7)
/*
Sonus says they need time to generate the dtmf so we should not send it so fast so with this flag we will wait a few clicks after each send to
start sending the next one.
*/
} switch_rtp_bug_flag_t;
#ifdef _MSC_VER

View File

@ -6542,6 +6542,14 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str
if (switch_stristr("~IGNORE_DTMF_DURATION", str)) {
*flag_pole &= ~RTP_BUG_IGNORE_DTMF_DURATION;
}
if (switch_stristr("PAUSE_BETWEEN_DTMF", str)) {
*flag_pole |= RTP_BUG_PAUSE_BETWEEN_DTMF;
}
if (switch_stristr("~PAUSE_BETWEEN_DTMF", str)) {
*flag_pole &= ~RTP_BUG_PAUSE_BETWEEN_DTMF;
}
}
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sofia_dispatch_event_t *de, sofia_nat_parse_t *np)

View File

@ -46,6 +46,9 @@
#include <datatypes.h>
#include <srtp.h>
/* number of writes to delay sending new DTMF when RTP_BUG_PAUSE_BETWEEN_DTMF flag is set */
#define BUGGY_DIGIT_DELAY_PERIOD 3
#define READ_INC(rtp_session) switch_mutex_lock(rtp_session->read_mutex); rtp_session->reading++
#define READ_DEC(rtp_session) switch_mutex_unlock(rtp_session->read_mutex); rtp_session->reading--
#define WRITE_INC(rtp_session) switch_mutex_lock(rtp_session->write_mutex); rtp_session->writing++
@ -138,6 +141,7 @@ struct switch_rtp_rfc2833_data {
switch_queue_t *dtmf_inqueue;
switch_mutex_t *dtmf_mutex;
uint8_t in_digit_queued;
uint32_t out_digit_delay;
};
struct switch_rtp {
@ -2234,6 +2238,11 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session)
switch_frame_flag_t flags = 0;
uint32_t samples = rtp_session->samples_per_interval;
if (rtp_session->dtmf_data.out_digit_delay) {
rtp_session->dtmf_data.out_digit_delay--;
return;
}
if (rtp_session->dtmf_data.out_digit_dur > 0) {
int x, loops = 1;
@ -2280,6 +2289,10 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session)
rtp_session->next_write_samplecount = rtp_session->timer.samplecount + samples * 5;
}
rtp_session->dtmf_data.out_digit_dur = 0;
if ((rtp_session->rtp_bugs & RTP_BUG_PAUSE_BETWEEN_DTMF) && switch_queue_size(rtp_session->dtmf_data.dtmf_queue)) {
rtp_session->dtmf_data.out_digit_delay = BUGGY_DIGIT_DELAY_PERIOD;
}
return;
}
}