diff --git a/conf/freeswitch.xml b/conf/freeswitch.xml
index 109665cfbc..074b13b8a3 100644
--- a/conf/freeswitch.xml
+++ b/conf/freeswitch.xml
@@ -106,6 +106,7 @@
+
@@ -221,6 +222,7 @@
+
diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c
index 968efedc63..0c69d9bbe6 100644
--- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c
+++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c
@@ -63,7 +63,8 @@ typedef enum {
TFLAG_DO_DESC = (1 << 15),
TFLAG_LANADDR = (1 << 16),
TFLAG_AUTO = (1 << 17),
- TFLAG_DTMF = (1 << 18)
+ TFLAG_DTMF = (1 << 18),
+ TFLAG_TIMER = ( 1 << 19)
} TFLAGS;
typedef enum {
@@ -236,6 +237,7 @@ static int activate_rtp(struct private_object *tech_pvt)
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
const char *err;
int ms = 20;
+ switch_rtp_flag_t flags;
if (tech_pvt->rtp_session) {
return 0;
@@ -246,12 +248,12 @@ static int activate_rtp(struct private_object *tech_pvt)
}
if (switch_core_codec_init(&tech_pvt->read_codec,
- tech_pvt->codec_name,
- 8000,
- ms,
- 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+ tech_pvt->codec_name,
+ 8000,
+ ms,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't load codec?\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return -1;
@@ -260,14 +262,14 @@ static int activate_rtp(struct private_object *tech_pvt)
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Read Codec to %s\n", tech_pvt->codec_name);
-
+
if (switch_core_codec_init(&tech_pvt->write_codec,
- tech_pvt->codec_name,
- 8000,
- ms,
- 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+ tech_pvt->codec_name,
+ 8000,
+ ms,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't load codec?\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return -1;
@@ -279,17 +281,23 @@ static int activate_rtp(struct private_object *tech_pvt)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip, tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
+
+ flags = SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ;
+
+ if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
+ flags |= SWITCH_RTP_FLAG_USE_TIMER;
+ }
if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip,
- tech_pvt->local_port,
- tech_pvt->remote_ip,
- tech_pvt->remote_port,
- tech_pvt->codec_num,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
- tech_pvt->read_codec.implementation->microseconds_per_frame,
- SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_GOOGLEHACK,
- NULL,
- &err, switch_core_session_get_pool(tech_pvt->session)))) {
+ tech_pvt->local_port,
+ tech_pvt->remote_ip,
+ tech_pvt->remote_port,
+ tech_pvt->codec_num,
+ tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+ tech_pvt->read_codec.implementation->microseconds_per_frame,
+ flags,
+ NULL,
+ &err, switch_core_session_get_pool(tech_pvt->session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return -1;
@@ -881,14 +889,14 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_BRIDGE:
- if (tech_pvt->rtp_session) {
+ if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
}
break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- if (tech_pvt->rtp_session) {
+ if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
//switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
@@ -1188,6 +1196,8 @@ static void set_profile_val(struct mdl_profile *profile, char *var, char *val)
profile->login = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "password")) {
profile->password = switch_core_strdup(module_pool, val);
+ } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_TIMER);
} else if (!strcasecmp(var, "dialplan")) {
profile->dialplan = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "name")) {
diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c
index b177a7794b..767eaa5232 100644
--- a/src/mod/endpoints/mod_exosip/mod_exosip.c
+++ b/src/mod/endpoints/mod_exosip/mod_exosip.c
@@ -75,7 +75,8 @@ typedef enum {
TFLAG_SECURE = (1 << 11),
TFLAG_VAD_IN = ( 1 << 12),
TFLAG_VAD_OUT = ( 1 << 13),
- TFLAG_VAD = ( 1 << 14)
+ TFLAG_VAD = ( 1 << 14),
+ TFLAG_TIMER = ( 1 << 15)
} TFLAGS;
@@ -475,6 +476,7 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
switch_channel_t *channel;
const char *err;
char *key = NULL;
+ switch_rtp_flag_t flags;
assert(tech_pvt != NULL);
@@ -511,17 +513,21 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "using Realm %s\n", tech_pvt->realm);
}
}
+ flags = SWITCH_RTP_FLAG_MINI | SWITCH_RTP_FLAG_RAW_WRITE;
+ if (switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+ flags |= SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_TIMER_RECLOCK;
+ }
tech_pvt->rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
- tech_pvt->local_sdp_audio_port,
- tech_pvt->remote_sdp_audio_ip,
- tech_pvt->remote_sdp_audio_port,
- tech_pvt->read_codec.codec_interface->ianacode,
- tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
- ms,
- SWITCH_RTP_FLAG_MINI | SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_TIMER_RECLOCK | SWITCH_RTP_FLAG_RAW_WRITE,
- key,
- &err, switch_core_session_get_pool(tech_pvt->session));
+ tech_pvt->local_sdp_audio_port,
+ tech_pvt->remote_sdp_audio_ip,
+ tech_pvt->remote_sdp_audio_port,
+ tech_pvt->read_codec.codec_interface->ianacode,
+ tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+ ms,
+ flags,
+ key,
+ &err, switch_core_session_get_pool(tech_pvt->session));
if (tech_pvt->rtp_session) {
uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
@@ -819,51 +825,51 @@ static switch_status_t exosip_receive_message(switch_core_session_t *session, sw
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_BRIDGE:
- if (tech_pvt->rtp_session) {
- switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
- }
- break;
+ if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+ switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
+ }
+ break;
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- if (tech_pvt->rtp_session) {
- switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
- }
- break;
+ if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
+ switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
+ }
+ break;
case SWITCH_MESSAGE_INDICATE_PROGRESS:
- if (msg) {
- struct private_object *tech_pvt;
- switch_channel_t *channel = NULL;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ if (msg) {
+ struct private_object *tech_pvt;
+ switch_channel_t *channel = NULL;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
- char *buf = NULL;
- osip_message_t *progress = NULL;
+ if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
+ char *buf = NULL;
+ osip_message_t *progress = NULL;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
- /* Transmit 183 Progress with SDP */
- eXosip_lock();
- eXosip_call_build_answer(tech_pvt->tid, 183, &progress);
- if (progress) {
- sdp_message_to_str(tech_pvt->local_sdp, &buf);
- osip_message_set_body(progress, buf, strlen(buf));
- osip_message_set_content_type(progress, "application/sdp");
- free(buf);
- eXosip_call_send_answer(tech_pvt->tid, 183, progress);
- switch_set_flag(tech_pvt, TFLAG_EARLY_MEDIA);
- switch_channel_set_flag(channel, CF_EARLY_MEDIA);
- }
- eXosip_unlock();
- }
- }
+ /* Transmit 183 Progress with SDP */
+ eXosip_lock();
+ eXosip_call_build_answer(tech_pvt->tid, 183, &progress);
+ if (progress) {
+ sdp_message_to_str(tech_pvt->local_sdp, &buf);
+ osip_message_set_body(progress, buf, strlen(buf));
+ osip_message_set_content_type(progress, "application/sdp");
+ free(buf);
+ eXosip_call_send_answer(tech_pvt->tid, 183, progress);
+ switch_set_flag(tech_pvt, TFLAG_EARLY_MEDIA);
+ switch_channel_set_flag(channel, CF_EARLY_MEDIA);
+ }
+ eXosip_unlock();
+ }
+ }
- break;
+ break;
default:
break;
}
@@ -1885,6 +1891,8 @@ static int config_exosip(int reload)
if (!strcmp(var, "debug")) {
globals.debug = atoi(val);
+ } else if (!strcmp(var, "use-rtp-timer") && switch_true(val)) {
+ switch_set_flag(&globals, TFLAG_TIMER);
} else if (!strcmp(var, "port")) {
globals.port = atoi(val);
} else if (!strcmp(var, "vad")) {
diff --git a/src/switch_rtp.c b/src/switch_rtp.c
index c0e2303e86..0669c29297 100644
--- a/src/switch_rtp.c
+++ b/src/switch_rtp.c
@@ -473,16 +473,16 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
}
SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host,
- switch_port_t rx_port,
- char *tx_host,
- switch_port_t tx_port,
- switch_payload_t payload,
- uint32_t packet_size,
- uint32_t ms_per_packet,
- switch_rtp_flag_t flags,
- char *crypto_key,
- const char **err,
- switch_memory_pool_t *pool)
+ switch_port_t rx_port,
+ char *tx_host,
+ switch_port_t tx_port,
+ switch_payload_t payload,
+ uint32_t packet_size,
+ uint32_t ms_per_packet,
+ switch_rtp_flag_t flags,
+ char *crypto_key,
+ const char **err,
+ switch_memory_pool_t *pool)
{
switch_rtp_t *rtp_session;