From 9e094835897c00ee5eeb2801af5e21f2589af600 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 7 Oct 2011 10:40:30 -0500 Subject: [PATCH] add manual_rtp_bug gen_one_gen_all to prevent rtp passthru to break the *S* word.. --- src/include/switch_types.h | 17 ++++++++++++++++- src/mod/applications/mod_dptools/mod_dptools.c | 4 ++-- src/mod/endpoints/mod_sofia/sofia_glue.c | 8 ++++++++ src/switch_rtp.c | 5 +++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 21dfa51339..bcdc508408 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -685,7 +685,7 @@ typedef enum { */ - RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7) + RTP_BUG_ACCEPT_ANY_PACKETS = (1 << 7), /* Oracle's Contact Center Anywhere (CCA) likes to use a single RTP socket to send all its outbound audio. @@ -694,6 +694,21 @@ typedef enum { */ + RTP_BUG_GEN_ONE_GEN_ALL = (1 << 8) + + /* + Some RTP endpoints (and by some we mean *cough* _SONUS_!) do not like it when the timestamps jump forward or backwards in time. + So say you are generating a file that says "please wait for me to complete your call, or generating ringback" + Now you place and outbound call and you are bridging. Well, while you were playing the file, you were generating your own RTP timestamps. + But, now that you have a remote RTP stream, you'd rather send those timestamps as-is in case they will be fed to a remote jitter buffer...... + Ok, so this causes the audio to completely fade out despite the fact that we send the mark bit which should give them heads up its happening. + + Sigh, This flag will tell FreeSWITCH that if it ever generates even one RTP packet itself, to continue to generate all of them and ignore the + actual timestamps in the frames. + + */ + + } switch_rtp_bug_flag_t; #ifdef _MSC_VER diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index fe82187d6c..857a0ea968 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -3730,8 +3730,8 @@ static int next_file(switch_file_handle_t *handle) } handle->samples = context->fh.samples; - handle->samplerate = context->fh.samplerate; - handle->channels = context->fh.channels; + //handle->samplerate = context->fh.samplerate; + //handle->channels = context->fh.channels; handle->format = context->fh.format; handle->sections = context->fh.sections; handle->seekable = context->fh.seekable; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 518f1065b8..93414e29f7 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -6577,6 +6577,14 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str if (switch_stristr("~ACCEPT_ANY_PACKETS", str)) { *flag_pole &= ~RTP_BUG_ACCEPT_ANY_PACKETS; } + + if (switch_stristr("GEN_ONE_GEN_ALL", str)) { + *flag_pole |= RTP_BUG_GEN_ONE_GEN_ALL; + } + + if (switch_stristr("~GEN_ONE_GEN_ALL", str)) { + *flag_pole &= ~RTP_BUG_GEN_ONE_GEN_ALL; + } } char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sofia_dispatch_event_t *de, sofia_nat_parse_t *np) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index c8a5777c3e..0ea3a978b0 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -4175,6 +4175,11 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra fwd = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RAW_WRITE) && switch_test_flag(frame, SFF_RAW_RTP)) ? 1 : 0; + if (!fwd && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RAW_WRITE) && (rtp_session->rtp_bugs & RTP_BUG_GEN_ONE_GEN_ALL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Generating RTP locally but timestamp passthru is configured, disabling....\n"); + switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_RAW_WRITE); + } + switch_assert(frame != NULL); if (switch_test_flag(frame, SFF_CNG)) {