提交 01fd1c3a authored 作者: Anthony Minessale's avatar Anthony Minessale

More PRI/SIP gateway stuff

**ATTENTION** you will need to libs/jrtplib/.complete ; make installall 
to get it to compile on existing builds as the jrtplib required changes.

Added teletone DTMF to mod_wanpipe and rfc2933 DTMF to mod_exosip
Added temporary poor man's daemon
freeswitch -nc > /var/log/freeswitch.log

then it will await a HUP




git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@659 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 4c9d54d4
...@@ -156,6 +156,11 @@ extern "C" { ...@@ -156,6 +156,11 @@ extern "C" {
return jrtp4c->session->SendPacket(data, datalen, jrtp4c->payload, false, ts); return jrtp4c->session->SendPacket(data, datalen, jrtp4c->payload, false, ts);
} }
int jrtp4c_write_payload(struct jrtp4c *jrtp4c, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq)
{
return jrtp4c->session->SendPacket(data, datalen, payload, false, ts, mseq);
}
uint32_t jrtp4c_start(struct jrtp4c *jrtp4c) uint32_t jrtp4c_start(struct jrtp4c *jrtp4c)
{ {
//jrtp4c->session->BeginDataAccess(); //jrtp4c->session->BeginDataAccess();
......
...@@ -51,6 +51,7 @@ extern "C" { ...@@ -51,6 +51,7 @@ extern "C" {
void jrtp4c_destroy(struct jrtp4c **jrtp4c); void jrtp4c_destroy(struct jrtp4c **jrtp4c);
int jrtp4c_read(struct jrtp4c *jrtp4c, void *data, int datalen, int *payload_type); int jrtp4c_read(struct jrtp4c *jrtp4c, void *data, int datalen, int *payload_type);
int jrtp4c_write(struct jrtp4c *jrtp4c, void *data, int datalen, uint32_t ts); int jrtp4c_write(struct jrtp4c *jrtp4c, void *data, int datalen, uint32_t ts);
int jrtp4c_write_payload(struct jrtp4c *jrtp4c, void *data, int datalen, int payload, uint32_t ts, uint32_t mseq);
uint32_t jrtp4c_start(struct jrtp4c *jrtp4c); uint32_t jrtp4c_start(struct jrtp4c *jrtp4c);
uint32_t jrtp4c_get_ssrc(struct jrtp4c *jrtp4c); uint32_t jrtp4c_get_ssrc(struct jrtp4c *jrtp4c);
void jrtp4c_killread(struct jrtp4c *jrtp4c); void jrtp4c_killread(struct jrtp4c *jrtp4c);
......
...@@ -44,6 +44,8 @@ extern "C" { ...@@ -44,6 +44,8 @@ extern "C" {
#define SWITCH_RECCOMMENDED_BUFFER_SIZE 131072 #define SWITCH_RECCOMMENDED_BUFFER_SIZE 131072
#define SWITCH_MAX_CODECS 30 #define SWITCH_MAX_CODECS 30
#define SWITCH_MAX_STATE_HANDLERS 30 #define SWITCH_MAX_STATE_HANDLERS 30
#define SWITCH_TRUE 1
#define SWITCH_FALSE 0
/*! /*!
\enum switch_ivr_option_t \enum switch_ivr_option_t
......
...@@ -44,6 +44,8 @@ extern "C" { ...@@ -44,6 +44,8 @@ extern "C" {
#include <switch.h> #include <switch.h>
#ifndef snprintf #ifndef snprintf
#define snprintf apr_snprintf #define snprintf apr_snprintf
#endif #endif
...@@ -51,6 +53,34 @@ extern "C" { ...@@ -51,6 +53,34 @@ extern "C" {
#define vsnprintf apr_vsnprintf #define vsnprintf apr_vsnprintf
#endif #endif
/*!
\brief Evaluate the truthfullness of a string expression
\param expr a string expression
\return true or false
*/
#define switch_true(expr)\
(expr && ( !strcasecmp(expr, "yes") ||\
!strcasecmp(expr, "on") ||\
!strcasecmp(expr, "true") ||\
atoi(expr))) ? SWITCH_TRUE : SWITCH_FALSE
/*!
\brief Return the RFC2833 character based on an event id
\param event the event id to convert
\return the character represented by the event or null for an invalid event
*/
SWITCH_DECLARE(char) switch_rfc2833_to_char(int event);
/*!
\brief Return the RFC2833 event based on an key character
\param the charecter to encode
\return the event id for the specified character or -1 on an invalid input
*/
SWITCH_DECLARE(int) switch_char_to_rfc2833(char key);
/*! /*!
\brief Duplicate a string \brief Duplicate a string
*/ */
......
...@@ -72,6 +72,7 @@ static struct { ...@@ -72,6 +72,7 @@ static struct {
int mtu; int mtu;
int dtmf_on; int dtmf_on;
int dtmf_off; int dtmf_off;
int supress_dtmf_tone;
char *dialplan; char *dialplan;
} globals; } globals;
...@@ -572,6 +573,9 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra ...@@ -572,6 +573,9 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
if (globals.debug) { if (globals.debug) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DTMF DETECTED: [%s]\n", digit_str); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DTMF DETECTED: [%s]\n", digit_str);
} }
if (globals.supress_dtmf_tone) {
memset(tech_pvt->read_frame.data, 0, tech_pvt->read_frame.datalen);
}
} }
*frame = &tech_pvt->read_frame; *frame = &tech_pvt->read_frame;
...@@ -1093,6 +1097,8 @@ static int config_wanpipe(int reload) ...@@ -1093,6 +1097,8 @@ static int config_wanpipe(int reload)
globals.dtmf_on = atoi(val); globals.dtmf_on = atoi(val);
} else if (!strcmp(var, "dtmf_off")) { } else if (!strcmp(var, "dtmf_off")) {
globals.dtmf_off = atoi(val); globals.dtmf_off = atoi(val);
} else if (!strcmp(var, "supress_dtmf_tone")) {
globals.supress_dtmf_tone = switch_true(val);
} }
} else if (!strcasecmp(cfg.category, "span")) { } else if (!strcasecmp(cfg.category, "span")) {
if (!strcmp(var, "span")) { if (!strcmp(var, "span")) {
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
*/ */
#include <switch.h> #include <switch.h>
static int RUNNING = 0;
static int handle_SIGHUP(int sig)
{
RUNNING = 0;
return 0;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *err = NULL; char *err = NULL;
...@@ -60,8 +68,16 @@ int main(int argc, char *argv[]) ...@@ -60,8 +68,16 @@ int main(int argc, char *argv[])
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_VERSION_FULL); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_VERSION_FULL);
/* wait for console input */ if (argv[1] && !strcmp(argv[1], "-nc")) {
switch_console_loop(); (void) signal(SIGHUP, (void *) handle_SIGHUP);
RUNNING = 1;
while(RUNNING) {
switch_yield(10000);
}
} else {
/* wait for console input */
switch_console_loop();
}
if (switch_event_create(&event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Shutting Down"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Shutting Down");
......
...@@ -31,6 +31,25 @@ ...@@ -31,6 +31,25 @@
*/ */
#include <switch_utils.h> #include <switch_utils.h>
static char RFC2833_CHARS[] = "0123456789*#ABCDF";
SWITCH_DECLARE(char) switch_rfc2833_to_char(int event)
{
return (event > -1 && event < sizeof(RFC2833_CHARS)) ? RFC2833_CHARS[event] : '\0';
}
SWITCH_DECLARE(int) switch_char_to_rfc2833(char key)
{
char *c;
for (c = RFC2833_CHARS; *c ; c++) {
if (*c == key) {
return (c - RFC2833_CHARS);
}
}
return -1;
}
SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen) SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen)
{ {
int argc; int argc;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论