diff --git a/conf/sofia.conf.xml b/conf/sofia.conf.xml index 17ea7804fa..b279540e9c 100644 --- a/conf/sofia.conf.xml +++ b/conf/sofia.conf.xml @@ -56,6 +56,10 @@ + + + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 4b7fba9c79..ebe7b578a4 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -275,6 +275,8 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) private_object_t *tech_pvt; switch_channel_t *channel = NULL; switch_status_t status; + uint32_t session_timeout = 0; + char *val; assert(session != NULL); @@ -322,7 +324,16 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) } } + + if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) { + int v_session_timeout = atoi(val); + if (v_session_timeout >= 0) { + session_timeout = v_session_timeout; + } + } + nua_respond(tech_pvt->nh, SIP_200_OK, + NUTAG_SESSION_TIMER(session_timeout), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); @@ -1064,6 +1075,8 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "CODECS \t%s\n", switch_str_nil(profile->codec_string)); stream->write_function(stream, "TEL-EVENT \t%d\n", profile->te); stream->write_function(stream, "CNG \t%d\n", profile->cng_pt); + stream->write_function(stream, "SESSION-TO \t%d\n", profile->session_timeout); + stream->write_function(stream, "MAX-DIALOG \t%d\n", profile->max_proceeding); stream->write_function(stream, "\nRegistrations:\n%s\n", line); @@ -1376,7 +1389,7 @@ SWITCH_STANDARD_API(sofia_function) stream->write_function(stream, "%s", usage_string); goto done; } - + if (!strcasecmp(argv[0], "profile")) { func = cmd_profile; } else if (!strcasecmp(argv[0], "status")) { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index a882993072..1a0fa2ca8b 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -61,6 +61,7 @@ struct private_object; typedef struct private_object private_object_t; #define NUA_HMAGIC_T sofia_private_t +#define SOFIA_SESSION_TIMEOUT "sofia_session_timeout" #define MY_EVENT_REGISTER "sofia::register" #define MY_EVENT_EXPIRE "sofia::expire" #define MULTICAST_EVENT "multicast::event" @@ -255,6 +256,8 @@ struct sofia_profile { uint32_t inuse; uint32_t soft_max; time_t started; + uint32_t session_timeout; + uint32_t max_proceeding; #ifdef SWITCH_HAVE_ODBC char *odbc_dsn; char *odbc_user; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8efd9744d9..7e3ba94267 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -351,6 +351,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void NUTAG_ALLOW("INFO"), NUTAG_ALLOW("NOTIFY"), NUTAG_ALLOW_EVENTS("talk"), + NUTAG_SESSION_TIMER(profile->session_timeout), + NTATAG_MAX_PROCEEDING(profile->max_proceeding), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")), //TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("NOTIFY")), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("SUBSCRIBE")), @@ -358,7 +360,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence")), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence.winfo")), TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("message-summary")), - SIPTAG_SUPPORTED_STR("100rel, precondition"), SIPTAG_USER_AGENT_STR(SOFIA_USER_AGENT), TAG_END()); + SIPTAG_SUPPORTED_STR("100rel, precondition, timer"), SIPTAG_USER_AGENT_STR(SOFIA_USER_AGENT), TAG_END()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name); @@ -856,6 +858,16 @@ switch_status_t config_sofia(int reload, char *profile_name) profile->timer_name = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "hold-music")) { profile->hold_music = switch_core_strdup(profile->pool, val); + } else if (!strcasecmp(var, "session-timeout")) { + int v_session_timeout = atoi(val); + if (v_session_timeout >= 0) { + profile->session_timeout = v_session_timeout; + } + } else if (!strcasecmp(var, "max-proceeding")) { + int v_max_proceeding = atoi(val); + if (v_max_proceeding >= 0) { + profile->max_proceeding = v_max_proceeding; + } } 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 5aa63bdd84..55ac60d8da 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -479,6 +479,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) switch_event_header_t *hi; char *extra_headers = NULL; switch_status_t status = SWITCH_STATUS_FALSE; + uint32_t session_timeout = 0; + char *val; char *rep; channel = switch_core_session_get_channel(session); @@ -623,8 +625,16 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) if (stream.data) { extra_headers = stream.data; } + + if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) { + int v_session_timeout = atoi(val); + if (v_session_timeout >= 0) { + session_timeout = v_session_timeout; + } + } nua_invite(tech_pvt->nh, + NUTAG_SESSION_TIMER(session_timeout), TAG_IF(!switch_strlen_zero(rpid), SIPTAG_HEADER_STR(rpid)), TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)), TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)), diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 311716fa26..cde67a1ce0 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -43,8 +43,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(session->channel, event); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", "%s", codec->implementation->iananame); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-rate", "%d", codec->implementation->samples_per_second); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-actual-read-codec-rate", "%d", codec->implementation->actual_samples_per_second); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-rate", "%d", codec->implementation->actual_samples_per_second); + if (codec->implementation->actual_samples_per_second != codec->implementation->samples_per_second) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-read-codec-rate", "%d", codec->implementation->samples_per_second); + } switch_event_fire(&event); } @@ -70,8 +72,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_ if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(session->channel, event); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-rate", "%d", codec->implementation->samples_per_second); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-actual-write-codec-rate", "%d", codec->implementation->actual_samples_per_second); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-rate", "%d", codec->implementation->actual_samples_per_second); + if (codec->implementation->actual_samples_per_second != codec->implementation->samples_per_second) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-reported-write-codec-rate", "%d", codec->implementation->actual_samples_per_second); + } switch_event_fire(&event); }