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 {
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;
}
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;
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;
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;
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);
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")) {
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;
switch_channel_t *channel;
const char *err;
char *key = NULL;
+ switch_rtp_flag_t flags;
assert(tech_pvt != NULL);
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;
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);
-
- 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;
-
- 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();
- }
- }
+ 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);
+
+ 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);
+
+ /* 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;
}
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")) {