update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@930 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
bcb9d08d77
commit
d22db18b4b
|
@ -12,7 +12,7 @@ endif
|
||||||
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
|
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN)
|
||||||
|
|
||||||
depends:
|
depends:
|
||||||
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsangoma --prefix=$(PREFIX)
|
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsangoma --prefix=$(PREFIX) --with-libpri=/usr/src/libpri
|
||||||
|
|
||||||
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
|
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
|
||||||
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
|
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
|
||||||
|
|
|
@ -61,7 +61,8 @@ typedef enum {
|
||||||
TFLAG_DESTROY = (1 << 7),
|
TFLAG_DESTROY = (1 << 7),
|
||||||
TFLAG_ABORT = (1 << 8),
|
TFLAG_ABORT = (1 << 8),
|
||||||
TFLAG_SWITCH = (1 << 9),
|
TFLAG_SWITCH = (1 << 9),
|
||||||
TFLAG_NOSIG = (1 << 10)
|
TFLAG_NOSIG = (1 << 10),
|
||||||
|
TFLAG_BYE = (1 << 11)
|
||||||
} TFLAGS;
|
} TFLAGS;
|
||||||
|
|
||||||
|
|
||||||
|
@ -336,6 +337,7 @@ static switch_status wanpipe_on_hangup(switch_core_session *session)
|
||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
assert(tech_pvt != NULL);
|
assert(tech_pvt != NULL);
|
||||||
|
|
||||||
|
switch_set_flag(tech_pvt, TFLAG_BYE);
|
||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_NOSIG)) {
|
if (!switch_test_flag(tech_pvt, TFLAG_NOSIG)) {
|
||||||
chanmap = tech_pvt->spri->private_info;
|
chanmap = tech_pvt->spri->private_info;
|
||||||
|
@ -397,9 +399,11 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||||
switch_core_session **new_session, switch_memory_pool *pool)
|
switch_core_session **new_session, switch_memory_pool *pool)
|
||||||
{
|
{
|
||||||
char *bchan = NULL;
|
char *bchan = NULL;
|
||||||
|
char name[128] = "";
|
||||||
|
|
||||||
|
|
||||||
if (outbound_profile && outbound_profile->destination_number) {
|
if (outbound_profile && outbound_profile->destination_number) {
|
||||||
bchan = strchr(outbound_profile->destination_number, '%');
|
bchan = strchr(outbound_profile->destination_number, '=');
|
||||||
} else {
|
} else {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -434,7 +438,6 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||||
|
|
||||||
|
|
||||||
if (outbound_profile) {
|
if (outbound_profile) {
|
||||||
char name[128];
|
|
||||||
switch_caller_profile *caller_profile;
|
switch_caller_profile *caller_profile;
|
||||||
struct sangoma_pri *spri;
|
struct sangoma_pri *spri;
|
||||||
int span = 0, autospan = 0, autochan = 0;
|
int span = 0, autospan = 0, autochan = 0;
|
||||||
|
@ -496,6 +499,9 @@ static switch_status wanpipe_outgoing_channel(switch_core_session *session, swit
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
switch_set_flag(tech_pvt, TFLAG_NOSIG);
|
switch_set_flag(tech_pvt, TFLAG_NOSIG);
|
||||||
|
snprintf(name, sizeof(name), "WanPipe/%s/nosig-%04x", bchan, rand() & 0xffff);
|
||||||
|
switch_channel_set_name(channel, name);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid address\n");
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid address\n");
|
||||||
switch_core_session_destroy(new_session);
|
switch_core_session_destroy(new_session);
|
||||||
|
@ -628,7 +634,8 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
assert(tech_pvt != NULL);
|
assert(tech_pvt != NULL);
|
||||||
|
|
||||||
if (tech_pvt->socket <= 0) {
|
|
||||||
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,6 +644,9 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
||||||
*frame = NULL;
|
*frame = NULL;
|
||||||
memset(tech_pvt->databuf, 0, sizeof(tech_pvt->databuf));
|
memset(tech_pvt->databuf, 0, sizeof(tech_pvt->databuf));
|
||||||
while (bytes < globals.mtu) {
|
while (bytes < globals.mtu) {
|
||||||
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
if ((res = sangoma_socket_waitfor(tech_pvt->socket, timeout, POLLIN | POLLERR)) < 0) {
|
if ((res = sangoma_socket_waitfor(tech_pvt->socket, timeout, POLLIN | POLLERR)) < 0) {
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
|
@ -657,6 +667,11 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
||||||
bytes += res;
|
bytes += res;
|
||||||
bp += bytes;
|
bp += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
tech_pvt->read_frame.datalen = bytes;
|
tech_pvt->read_frame.datalen = bytes;
|
||||||
tech_pvt->read_frame.samples = bytes / 2;
|
tech_pvt->read_frame.samples = bytes / 2;
|
||||||
|
|
||||||
|
@ -706,11 +721,17 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr
|
||||||
|
|
||||||
|
|
||||||
while (tech_pvt->dtmf_buffer && bwrote < frame->datalen && bytes > 0 && (inuse = switch_buffer_inuse(tech_pvt->dtmf_buffer)) > 0) {
|
while (tech_pvt->dtmf_buffer && bwrote < frame->datalen && bytes > 0 && (inuse = switch_buffer_inuse(tech_pvt->dtmf_buffer)) > 0) {
|
||||||
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
if ((bread = switch_buffer_read(tech_pvt->dtmf_buffer, dtmf, globals.mtu)) < globals.mtu) {
|
if ((bread = switch_buffer_read(tech_pvt->dtmf_buffer, dtmf, globals.mtu)) < globals.mtu) {
|
||||||
while (bread < globals.mtu) {
|
while (bread < globals.mtu) {
|
||||||
dtmf[bread++] = 0;
|
dtmf[bread++] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
||||||
|
|
||||||
|
|
||||||
|
@ -737,6 +758,10 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
if (tech_pvt->skip_write_frames) {
|
if (tech_pvt->skip_write_frames) {
|
||||||
tech_pvt->skip_write_frames--;
|
tech_pvt->skip_write_frames--;
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -744,6 +769,11 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr
|
||||||
|
|
||||||
while (bytes > 0) {
|
while (bytes > 0) {
|
||||||
unsigned int towrite;
|
unsigned int towrite;
|
||||||
|
|
||||||
|
if (switch_test_flag(tech_pvt, TFLAG_BYE) || tech_pvt->socket < 0) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
sangoma_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
||||||
#ifdef DOTRACE
|
#ifdef DOTRACE
|
||||||
write(tech_pvt->fd, bp, (int) globals.mtu);
|
write(tech_pvt->fd, bp, (int) globals.mtu);
|
||||||
|
@ -823,10 +853,9 @@ static switch_status wanpipe_kill_channel(switch_core_session *session, int sig)
|
||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
assert(tech_pvt != NULL);
|
assert(tech_pvt != NULL);
|
||||||
|
|
||||||
|
switch_set_flag(tech_pvt, TFLAG_BYE);
|
||||||
switch_clear_flag(tech_pvt, TFLAG_MEDIA);
|
switch_clear_flag(tech_pvt, TFLAG_MEDIA);
|
||||||
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,12 @@
|
||||||
*/
|
*/
|
||||||
#include <switch_console.h>
|
#include <switch_console.h>
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
#define CMD_BUFLEN SWITCH_RECCOMMENDED_BUFFER_SIZE * 10
|
||||||
|
|
||||||
static int switch_console_process(char *cmd)
|
static int switch_console_process(char *cmd)
|
||||||
{
|
{
|
||||||
char *arg = NULL;
|
char *arg = NULL;
|
||||||
char *retbuf = (char *)malloc(SWITCH_RECCOMMENDED_BUFFER_SIZE * 10);
|
char *retbuf = (char *)malloc(CMD_BUFLEN);
|
||||||
|
|
||||||
#ifdef EMBED_PERL
|
#ifdef EMBED_PERL
|
||||||
const char *perlhelp = "perl - execute some perl. (print to STDERR if you want to see it.)\n";
|
const char *perlhelp = "perl - execute some perl. (print to STDERR if you want to see it.)\n";
|
||||||
|
@ -73,7 +74,7 @@ static int switch_console_process(char *cmd)
|
||||||
if ((arg = strchr(cmd, ' ')) != 0) {
|
if ((arg = strchr(cmd, ' ')) != 0) {
|
||||||
*arg++ = '\0';
|
*arg++ = '\0';
|
||||||
}
|
}
|
||||||
if (switch_api_execute(cmd, arg, retbuf, sizeof(retbuf)) == SWITCH_STATUS_SUCCESS) {
|
if (switch_api_execute(cmd, arg, retbuf, CMD_BUFLEN) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "",
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "",
|
||||||
retbuf);
|
retbuf);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue