From c731ed53a774dae0fb066d78eea51848d6406dac Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 21 Jan 2008 00:35:33 +0000 Subject: [PATCH] add optional var/param for seperately setting the rtp timeout when on hold git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7309 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 ++ src/mod/endpoints/mod_sofia/sofia.c | 5 +++++ src/mod/endpoints/mod_sofia/sofia_glue.c | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index e07f5e1499..1bf680fe98 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -288,6 +288,7 @@ struct sofia_profile { uint32_t session_timeout; uint32_t max_proceeding; uint32_t rtp_timeout_sec; + uint32_t rtp_hold_timeout_sec; char *odbc_dsn; char *odbc_user; char *odbc_pass; @@ -374,6 +375,7 @@ struct private_object { uint32_t owner_id; uint32_t session_id; uint32_t max_missed_packets; + uint32_t max_missed_hold_packets; /** VIDEO **/ switch_frame_t video_read_frame; switch_codec_t video_read_codec; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 980cf186c0..fabaa71b57 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1011,6 +1011,11 @@ switch_status_t config_sofia(int reload, char *profile_name) if (v >= 0) { profile->rtp_timeout_sec = v; } + } else if (!strcasecmp(var, "rtp-hold-timeout-sec")) { + int v = atoi(val); + if (v >= 0) { + profile->rtp_hold_timeout_sec = v; + } } else if (!strcasecmp(var, "manage-presence")) { if (switch_true(val)) { profile->pflags |= PFLAG_PRESENCE; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 43e1679e0f..ac58ca1a51 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1226,6 +1226,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f switch_status_t status; char tmp[50]; uint32_t rtp_timeout_sec = tech_pvt->profile->rtp_timeout_sec; + uint32_t rtp_hold_timeout_sec = tech_pvt->profile->rtp_hold_timeout_sec; switch_assert(tech_pvt != NULL); @@ -1370,12 +1371,27 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f rtp_timeout_sec = v; } } + + if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_hold_timeout_sec"))) { + int v = atoi(val); + if (v >= 0) { + rtp_hold_timeout_sec = v; + } + } if (rtp_timeout_sec) { tech_pvt->max_missed_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_timeout_sec) / tech_pvt->read_codec.implementation->samples_per_frame; switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets); + if (!rtp_hold_timeout_sec) { + rtp_hold_timeout_sec = rtp_timeout_sec * 10; + } + } + + if (rtp_hold_timeout_sec) { + tech_pvt->max_missed_hold_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_hold_timeout_sec) / + tech_pvt->read_codec.implementation->samples_per_frame; } if (tech_pvt->te) { @@ -1540,7 +1556,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t * switch_channel_presence(tech_pvt->channel, "unknown", "hold"); if (tech_pvt->max_missed_packets) { - switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets * 10); + switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets); } if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {