update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1513 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
3d6bdeed03
commit
baa257f2fe
|
@ -106,6 +106,8 @@
|
||||||
<param name="dialplan" value="XML"/>
|
<param name="dialplan" value="XML"/>
|
||||||
<param name="dtmf-duration" value="100"/>
|
<param name="dtmf-duration" value="100"/>
|
||||||
<param name="codec-prefs" value="PCMU,PCMA"/>
|
<param name="codec-prefs" value="PCMU,PCMA"/>
|
||||||
|
<!-- Payload number to bind DTMF to-->
|
||||||
|
<param name="rfc2833-pt" value="101"/>
|
||||||
<!-- disable to trade async for more calls -->
|
<!-- disable to trade async for more calls -->
|
||||||
<param name="use-rtp-timer" value="true">
|
<param name="use-rtp-timer" value="true">
|
||||||
<!-- pick one (default if not specified is 'guess'); -->
|
<!-- pick one (default if not specified is 'guess'); -->
|
||||||
|
|
|
@ -348,6 +348,13 @@ SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session);
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data);
|
SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Set the payload type to consider RFC2833 DTMF
|
||||||
|
\param rtp_session the RTP session to modify
|
||||||
|
\param te the payload type
|
||||||
|
*/
|
||||||
|
SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Retrieve the private data from a given RTP session
|
\brief Retrieve the private data from a given RTP session
|
||||||
\param rtp_session the RTP session to retrieve the data from
|
\param rtp_session the RTP session to retrieve the data from
|
||||||
|
|
|
@ -109,6 +109,7 @@ static struct {
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
switch_mutex_t *reg_mutex;
|
switch_mutex_t *reg_mutex;
|
||||||
switch_core_db_t *db;
|
switch_core_db_t *db;
|
||||||
|
switch_payload_t te;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
struct private_object {
|
struct private_object {
|
||||||
|
@ -138,6 +139,7 @@ struct private_object {
|
||||||
char *realm;
|
char *realm;
|
||||||
switch_codec_interface_t *codecs[SWITCH_MAX_CODECS];
|
switch_codec_interface_t *codecs[SWITCH_MAX_CODECS];
|
||||||
int num_codecs;
|
int num_codecs;
|
||||||
|
switch_payload_t te;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,6 +277,7 @@ static switch_status_t exosip_on_init(switch_core_session_t *session)
|
||||||
char *dest_uri;
|
char *dest_uri;
|
||||||
char *ip, *err;
|
char *ip, *err;
|
||||||
switch_port_t sdp_port;
|
switch_port_t sdp_port;
|
||||||
|
char dbuf[256];
|
||||||
|
|
||||||
/* do SIP Goodies... */
|
/* do SIP Goodies... */
|
||||||
|
|
||||||
|
@ -338,9 +341,11 @@ static switch_status_t exosip_on_init(switch_core_session_t *session)
|
||||||
tech_set_codecs(tech_pvt);
|
tech_set_codecs(tech_pvt);
|
||||||
|
|
||||||
|
|
||||||
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup("101"));
|
sprintf(dbuf, "%u", tech_pvt->te);
|
||||||
sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, 101, "telephone-event", 8000, 0);
|
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
|
||||||
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, 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) {
|
if (tech_pvt->num_codecs > 0) {
|
||||||
|
@ -552,7 +557,11 @@ static switch_status_t activate_rtp(struct private_object *tech_pvt)
|
||||||
|
|
||||||
tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
|
tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
|
||||||
switch_set_flag(tech_pvt, TFLAG_RTP);
|
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)) {
|
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_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);
|
switch_set_flag(tech_pvt, TFLAG_VAD);
|
||||||
|
@ -1017,6 +1026,7 @@ static switch_status_t exosip_outgoing_channel(switch_core_session_t *session, s
|
||||||
channel = switch_core_session_get_channel(*new_session);
|
channel = switch_core_session_get_channel(*new_session);
|
||||||
switch_core_session_set_private(*new_session, tech_pvt);
|
switch_core_session_set_private(*new_session, tech_pvt);
|
||||||
tech_pvt->session = *new_session;
|
tech_pvt->session = *new_session;
|
||||||
|
tech_pvt->te = globals.te;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
||||||
switch_core_session_destroy(new_session);
|
switch_core_session_destroy(new_session);
|
||||||
|
@ -1131,6 +1141,7 @@ static switch_status_t exosip_create_call(eXosip_event_t * event)
|
||||||
char name[128];
|
char name[128];
|
||||||
char *dpayload, *dname = NULL, *drate = NULL;
|
char *dpayload, *dname = NULL, *drate = NULL;
|
||||||
char *remote_sdp_str = NULL;
|
char *remote_sdp_str = NULL;
|
||||||
|
char dbuf[256];
|
||||||
|
|
||||||
if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
|
if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
|
||||||
struct private_object *tech_pvt;
|
struct private_object *tech_pvt;
|
||||||
|
@ -1149,6 +1160,7 @@ static switch_status_t exosip_create_call(eXosip_event_t * event)
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_core_session_set_private(session, tech_pvt);
|
switch_core_session_set_private(session, tech_pvt);
|
||||||
tech_pvt->session = session;
|
tech_pvt->session = session;
|
||||||
|
tech_pvt->te = globals.te;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
||||||
switch_core_session_destroy(&session);
|
switch_core_session_destroy(&session);
|
||||||
|
@ -1258,11 +1270,13 @@ static switch_status_t exosip_create_call(eXosip_event_t * event)
|
||||||
tech_set_codecs(tech_pvt);
|
tech_set_codecs(tech_pvt);
|
||||||
|
|
||||||
sdp_message_init(&tech_pvt->local_sdp);
|
sdp_message_init(&tech_pvt->local_sdp);
|
||||||
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup("101"));
|
sprintf(dbuf, "%u", tech_pvt->te);
|
||||||
sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup("101 telephone-event/8000"));
|
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(dbuf));
|
||||||
sdp_add_codec(tech_pvt->sdp_config, SWITCH_CODEC_TYPE_AUDIO, 101, "telephone-event", 8000, 0);
|
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) {
|
if (tech_pvt->num_codecs > 0) {
|
||||||
int i;
|
int i;
|
||||||
static const switch_codec_implementation_t *imp;
|
static const switch_codec_implementation_t *imp;
|
||||||
|
@ -1466,18 +1480,25 @@ static switch_status_t parse_sdp_media(struct private_object *tech_pvt, sdp_medi
|
||||||
if ((rate = strchr(name, '/'))) {
|
if ((rate = strchr(name, '/'))) {
|
||||||
*rate++ = '\0';
|
*rate++ = '\0';
|
||||||
}
|
}
|
||||||
pt = atoi(payload);
|
pt = (switch_payload_t)atoi(payload);
|
||||||
r = atoi(rate);
|
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++) {
|
for(i = 0; !match && i < tech_pvt->num_codecs; i++) {
|
||||||
const switch_codec_implementation_t *imp;
|
const switch_codec_implementation_t *imp;
|
||||||
|
|
||||||
if (pt < 97) {
|
if (pt < 97) {
|
||||||
match = (pt == tech_pvt->codecs[i]->ianacode) ? 1 : 0;
|
match = (pt == tech_pvt->codecs[i]->ianacode) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
match = strcasecmp(name, tech_pvt->codecs[i]->iananame) ? 0 : 1;
|
match = strcasecmp(name, tech_pvt->codecs[i]->iananame) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
match = 0;
|
match = 0;
|
||||||
|
|
||||||
|
@ -1901,6 +1922,7 @@ static int config_exosip(int reload)
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.dtmf_duration = 100;
|
globals.dtmf_duration = 100;
|
||||||
|
globals.te = 101;
|
||||||
|
|
||||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||||
|
@ -1913,6 +1935,8 @@ static int config_exosip(int reload)
|
||||||
switch_set_flag(&globals, TFLAG_TIMER);
|
switch_set_flag(&globals, TFLAG_TIMER);
|
||||||
} else if (!strcmp(var, "port")) {
|
} else if (!strcmp(var, "port")) {
|
||||||
globals.port = atoi(val);
|
globals.port = atoi(val);
|
||||||
|
} else if (!strcmp(var, "rfc2833-pt")) {
|
||||||
|
globals.te = (switch_payload_t) atoi(val);
|
||||||
} else if (!strcmp(var, "vad")) {
|
} else if (!strcmp(var, "vad")) {
|
||||||
if (!strcasecmp(val, "in")) {
|
if (!strcasecmp(val, "in")) {
|
||||||
switch_set_flag(&globals, TFLAG_VAD_IN);
|
switch_set_flag(&globals, TFLAG_VAD_IN);
|
||||||
|
|
|
@ -169,6 +169,7 @@ struct switch_rtp {
|
||||||
struct switch_rtp_vad_data vad_data;
|
struct switch_rtp_vad_data vad_data;
|
||||||
struct switch_rtp_rfc2833_data dtmf_data;
|
struct switch_rtp_rfc2833_data dtmf_data;
|
||||||
uint8_t mini;
|
uint8_t mini;
|
||||||
|
switch_payload_t te;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int global_init = 0;
|
static int global_init = 0;
|
||||||
|
@ -379,6 +380,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
|
||||||
|
|
||||||
rtp_session->pool = pool;
|
rtp_session->pool = pool;
|
||||||
rtp_session->flags = flags;
|
rtp_session->flags = flags;
|
||||||
|
rtp_session->te = 101;
|
||||||
switch_mutex_init(&rtp_session->dtmf_data.dtmf_mutex, SWITCH_MUTEX_NESTED, rtp_session->pool);
|
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);
|
switch_buffer_create(rtp_session->pool, &rtp_session->dtmf_data.dtmf_buffer, 128);
|
||||||
/* for from address on recvfrom calls */
|
/* for from address on recvfrom calls */
|
||||||
|
@ -506,6 +508,12 @@ SWITCH_DECLARE(switch_rtp_t *)switch_rtp_new(char *rx_host,
|
||||||
return rtp_session;
|
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)
|
SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin)
|
||||||
{
|
{
|
||||||
|
@ -627,7 +635,7 @@ static void do_2833(switch_rtp_t *rtp_session)
|
||||||
|
|
||||||
for (x = 0; x < loops; x++) {
|
for (x = 0; x < loops; x++) {
|
||||||
switch_rtp_write_manual(rtp_session,
|
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);
|
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",
|
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",
|
loops == 1 ? "middle" : "end",
|
||||||
|
@ -661,7 +669,7 @@ static void do_2833(switch_rtp_t *rtp_session)
|
||||||
rtp_session->dtmf_data.out_digit_packet,
|
rtp_session->dtmf_data.out_digit_packet,
|
||||||
4,
|
4,
|
||||||
1,
|
1,
|
||||||
101,
|
rtp_session->te,
|
||||||
rtp_session->dtmf_data.timestamp_dtmf,
|
rtp_session->dtmf_data.timestamp_dtmf,
|
||||||
rtp_session->dtmf_data.out_digit_seq++,
|
rtp_session->dtmf_data.out_digit_seq++,
|
||||||
&flags);
|
&flags);
|
||||||
|
@ -684,6 +692,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
||||||
switch_size_t bytes;
|
switch_size_t bytes;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
bytes = sizeof(rtp_msg_t);
|
bytes = sizeof(rtp_msg_t);
|
||||||
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
|
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
|
||||||
|
@ -813,7 +822,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RFC2833 ... TBD try harder to honor the duration etc.*/
|
/* 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;
|
unsigned char *packet = (unsigned char *) rtp_session->recv_msg.body;
|
||||||
int end = packet[1]&0x80;
|
int end = packet[1]&0x80;
|
||||||
int duration = (packet[2]<<8) + packet[3];
|
int duration = (packet[2]<<8) + packet[3];
|
||||||
|
|
Loading…
Reference in New Issue