unsigned int flags;
switch_mutex_t *reg_mutex;
switch_core_db_t *db;
+ switch_payload_t te;
} globals;
struct private_object {
char *realm;
switch_codec_interface_t *codecs[SWITCH_MAX_CODECS];
int num_codecs;
+ switch_payload_t te;
};
char *dest_uri;
char *ip, *err;
switch_port_t sdp_port;
+ char dbuf[256];
/* do SIP Goodies... */
tech_set_codecs(tech_pvt);
- sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup("101"));
- sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, 101, "telephone-event", 8000, 0);
- sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup("101 telephone-event/8000"));
+ sprintf(dbuf, "%u", tech_pvt->te);
+ sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
+ sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, tech_pvt->te, "telephone-event", 8000, 0);
+ sprintf(dbuf, "%u telephone-event/8000", tech_pvt->te);
+ sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(dbuf));
if (tech_pvt->num_codecs > 0) {
tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
switch_set_flag(tech_pvt, TFLAG_RTP);
-
+
+ if (tech_pvt->te > 96) {
+ switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
+ }
+
if ((vad_in && inb) || (vad_out && !inb)) {
switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
switch_set_flag(tech_pvt, TFLAG_VAD);
channel = switch_core_session_get_channel(*new_session);
switch_core_session_set_private(*new_session, tech_pvt);
tech_pvt->session = *new_session;
+ tech_pvt->te = globals.te;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
switch_core_session_destroy(new_session);
char name[128];
char *dpayload, *dname = NULL, *drate = NULL;
char *remote_sdp_str = NULL;
+ char dbuf[256];
if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
struct private_object *tech_pvt;
channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt);
tech_pvt->session = session;
+ tech_pvt->te = globals.te;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
switch_core_session_destroy(&session);
tech_set_codecs(tech_pvt);
sdp_message_init(&tech_pvt->local_sdp);
- sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup("101"));
- sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup("101 telephone-event/8000"));
- sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, 101, "telephone-event", 8000, 0);
-
+ sprintf(dbuf, "%u", tech_pvt->te);
+ sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
+ sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, tech_pvt->te, "telephone-event", 8000, 0);
+ sprintf(dbuf, "%u telephone-event/8000", tech_pvt->te);
+ sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(dbuf));
+
if (tech_pvt->num_codecs > 0) {
int i;
static const switch_codec_implementation_t *imp;
if ((rate = strchr(name, '/'))) {
*rate++ = '\0';
}
- pt = atoi(payload);
+ pt = (switch_payload_t)atoi(payload);
r = atoi(rate);
+
+ if (!strcasecmp(name, "telephone-event")) {
+ tech_pvt->te = pt;
+ attr = NULL;
+ pos++;
+ continue;
+ }
for(i = 0; !match && i < tech_pvt->num_codecs; i++) {
const switch_codec_implementation_t *imp;
-
+
if (pt < 97) {
match = (pt == tech_pvt->codecs[i]->ianacode) ? 1 : 0;
} else {
match = strcasecmp(name, tech_pvt->codecs[i]->iananame) ? 0 : 1;
}
-
+
if (match) {
match = 0;
}
globals.dtmf_duration = 100;
+ globals.te = 101;
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
switch_set_flag(&globals, TFLAG_TIMER);
} else if (!strcmp(var, "port")) {
globals.port = atoi(val);
+ } else if (!strcmp(var, "rfc2833-pt")) {
+ globals.te = (switch_payload_t) atoi(val);
} else if (!strcmp(var, "vad")) {
if (!strcasecmp(val, "in")) {
switch_set_flag(&globals, TFLAG_VAD_IN);
struct switch_rtp_vad_data vad_data;
struct switch_rtp_rfc2833_data dtmf_data;
uint8_t mini;
+ switch_payload_t te;
};
static int global_init = 0;
rtp_session->pool = pool;
rtp_session->flags = flags;
+ rtp_session->te = 101;
switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
switch_buffer_create(rtp_session->pool, &rtp_session->dtmf_data.dtmf_buffer, 128);
/* for from address on recvfrom calls */
return rtp_session;
}
+SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te)
+{
+ if (te > 96) {
+ rtp_session->te = te;
+ }
+}
SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin)
{
for (x = 0; x < loops; x++) {
switch_rtp_write_manual(rtp_session,
- rtp_session->dtmf_data.out_digit_packet, 4, 0, 101, rtp_session->dtmf_data.timestamp_dtmf,
+ rtp_session->dtmf_data.out_digit_packet, 4, 0, rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf,
rtp_session->dtmf_data.out_digit_seq++, &flags);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send %s packet for [%c] ts=%d sofar=%u dur=%d\n",
loops == 1 ? "middle" : "end",
rtp_session->dtmf_data.out_digit_packet,
4,
1,
- 101,
+ rtp_session->te,
rtp_session->dtmf_data.timestamp_dtmf,
rtp_session->dtmf_data.out_digit_seq++,
&flags);
switch_size_t bytes;
switch_status_t status;
+
for(;;) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
}
/* RFC2833 ... TBD try harder to honor the duration etc.*/
- if (rtp_session->recv_msg.header.pt == 101) {
+ if (rtp_session->recv_msg.header.pt == rtp_session->te) {
unsigned char *packet = (unsigned char *) rtp_session->recv_msg.body;
int end = packet[1]&0x80;
int duration = (packet[2]<<8) + packet[3];