add some options
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@372 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
c973fadc4e
commit
254c3ed2d8
|
@ -1,9 +1,16 @@
|
||||||
<configuration name="openzap.conf" description="OpenZAP Configuration">
|
<configuration name="openzap.conf" description="OpenZAP Configuration">
|
||||||
<settings>
|
<settings>
|
||||||
<param name="debug" value="0"/>
|
<param name="debug" value="0"/>
|
||||||
|
<!--<param name="hold-music" value="$${moh_uri}"/>-->
|
||||||
|
<!--<param name="enable-analog-option" value="call-swap"/>-->
|
||||||
|
<!--<param name="enable-analog-option" value="3-way"/>-->
|
||||||
</settings>
|
</settings>
|
||||||
|
<!-- one entry here per openzap span -->
|
||||||
<analog_spans>
|
<analog_spans>
|
||||||
<span id="1">
|
<span id="1">
|
||||||
|
<!--<param name="hold-music" value="$${moh_uri}"/>-->
|
||||||
|
<!--<param name="enable-analog-option" value="call-swap"/>-->
|
||||||
|
<!--<param name="enable-analog-option" value="3-way"/>-->
|
||||||
<param name="tonegroup" value="us"/>
|
<param name="tonegroup" value="us"/>
|
||||||
<param name="digit-timeout" value="2000"/>
|
<param name="digit-timeout" value="2000"/>
|
||||||
<param name="max-digits" value="11"/>
|
<param name="max-digits" value="11"/>
|
||||||
|
|
|
@ -42,6 +42,12 @@ switch_endpoint_interface_t *openzap_endpoint_interface;
|
||||||
|
|
||||||
static switch_memory_pool_t *module_pool = NULL;
|
static switch_memory_pool_t *module_pool = NULL;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ANALOG_OPTION_NONE = 0,
|
||||||
|
ANALOG_OPTION_3WAY = (1 << 0),
|
||||||
|
ANALOG_OPTION_CALL_SWAP = (1 << 1)
|
||||||
|
} analog_option_t;
|
||||||
|
|
||||||
struct span_config {
|
struct span_config {
|
||||||
zap_span_t *span;
|
zap_span_t *span;
|
||||||
char dialplan[80];
|
char dialplan[80];
|
||||||
|
@ -49,6 +55,7 @@ struct span_config {
|
||||||
char dial_regex[256];
|
char dial_regex[256];
|
||||||
char fail_dial_regex[256];
|
char fail_dial_regex[256];
|
||||||
char hold_music[256];
|
char hold_music[256];
|
||||||
|
analog_option_t analog_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct span_config SPAN_CONFIG[ZAP_MAX_SPANS_INTERFACE] = {{0}};
|
static struct span_config SPAN_CONFIG[ZAP_MAX_SPANS_INTERFACE] = {{0}};
|
||||||
|
@ -75,6 +82,7 @@ static struct {
|
||||||
int calls;
|
int calls;
|
||||||
char hold_music[256];
|
char hold_music[256];
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
|
analog_option_t analog_options;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
struct private_object {
|
struct private_object {
|
||||||
|
@ -511,6 +519,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
|
|
||||||
|
|
||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
assert(tech_pvt != NULL);
|
assert(tech_pvt != NULL);
|
||||||
|
@ -1052,6 +1061,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
|
||||||
break;
|
break;
|
||||||
case ZAP_SIGEVENT_START:
|
case ZAP_SIGEVENT_START:
|
||||||
{
|
{
|
||||||
|
zap_clear_flag_locked(sigmsg->channel, ZAP_CHANNEL_HOLD);
|
||||||
status = zap_channel_from_event(sigmsg, &session);
|
status = zap_channel_from_event(sigmsg, &session);
|
||||||
if (status != ZAP_SUCCESS) {
|
if (status != ZAP_SUCCESS) {
|
||||||
zap_set_state_locked(sigmsg->channel, ZAP_CHANNEL_STATE_BUSY);
|
zap_set_state_locked(sigmsg->channel, ZAP_CHANNEL_STATE_BUSY);
|
||||||
|
@ -1132,8 +1142,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
|
||||||
break;
|
break;
|
||||||
case ZAP_SIGEVENT_FLASH:
|
case ZAP_SIGEVENT_FLASH:
|
||||||
{
|
{
|
||||||
|
if (sigmsg->channel->token_count == 2 && (SPAN_CONFIG[sigmsg->span_id].analog_options & ANALOG_OPTION_3WAY)) {
|
||||||
if (sigmsg->channel->token_count == 2) {
|
|
||||||
if (zap_test_flag(sigmsg->channel, ZAP_CHANNEL_3WAY)) {
|
if (zap_test_flag(sigmsg->channel, ZAP_CHANNEL_3WAY)) {
|
||||||
zap_clear_flag(sigmsg->channel, ZAP_CHANNEL_3WAY);
|
zap_clear_flag(sigmsg->channel, ZAP_CHANNEL_3WAY);
|
||||||
if ((session = zap_channel_get_session(sigmsg->channel, 1))) {
|
if ((session = zap_channel_get_session(sigmsg->channel, 1))) {
|
||||||
|
@ -1150,7 +1159,9 @@ static ZIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
|
||||||
cycle_foreground(sigmsg->channel, 1, cmd);
|
cycle_foreground(sigmsg->channel, 1, cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
} else {
|
} else if ((SPAN_CONFIG[sigmsg->span_id].analog_options & ANALOG_OPTION_CALL_SWAP)
|
||||||
|
|| (SPAN_CONFIG[sigmsg->span_id].analog_options & ANALOG_OPTION_3WAY)
|
||||||
|
) {
|
||||||
cycle_foreground(sigmsg->channel, 1, NULL);
|
cycle_foreground(sigmsg->channel, 1, NULL);
|
||||||
if (sigmsg->channel->token_count == 1) {
|
if (sigmsg->channel->token_count == 1) {
|
||||||
zap_set_flag_locked(sigmsg->channel, ZAP_CHANNEL_HOLD);
|
zap_set_flag_locked(sigmsg->channel, ZAP_CHANNEL_HOLD);
|
||||||
|
@ -1315,6 +1326,20 @@ static void zap_logger(char *file, const char *func, int line, int level, char *
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t enable_analog_option(const char *str, uint32_t current_options)
|
||||||
|
{
|
||||||
|
if (!strcasecmp(str, "3-way")) {
|
||||||
|
current_options |= ANALOG_OPTION_3WAY;
|
||||||
|
current_options &= ~ANALOG_OPTION_CALL_SWAP;
|
||||||
|
} else if (!strcasecmp(str, "call-swap")) {
|
||||||
|
current_options |= ANALOG_OPTION_CALL_SWAP;
|
||||||
|
current_options &= ~ANALOG_OPTION_3WAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return current_options;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static switch_status_t load_config(void)
|
static switch_status_t load_config(void)
|
||||||
{
|
{
|
||||||
char *cf = "openzap.conf";
|
char *cf = "openzap.conf";
|
||||||
|
@ -1336,6 +1361,8 @@ static switch_status_t load_config(void)
|
||||||
globals.debug = atoi(val);
|
globals.debug = atoi(val);
|
||||||
} else if (!strcasecmp(var, "hold-music")) {
|
} else if (!strcasecmp(var, "hold-music")) {
|
||||||
switch_set_string(globals.hold_music, val);
|
switch_set_string(globals.hold_music, val);
|
||||||
|
} else if (!strcasecmp(var, "enable-analog-option")) {
|
||||||
|
globals.analog_options = enable_analog_option(val, globals.analog_options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1353,6 +1380,7 @@ static switch_status_t load_config(void)
|
||||||
char *fail_dial_regex = NULL;
|
char *fail_dial_regex = NULL;
|
||||||
uint32_t span_id = 0, to = 0, max = 0;
|
uint32_t span_id = 0, to = 0, max = 0;
|
||||||
zap_span_t *span = NULL;
|
zap_span_t *span = NULL;
|
||||||
|
analog_option_t analog_options = ANALOG_OPTION_NONE;
|
||||||
|
|
||||||
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
|
||||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||||
|
@ -1374,6 +1402,8 @@ static switch_status_t load_config(void)
|
||||||
hold_music = val;
|
hold_music = val;
|
||||||
} else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
|
} else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
|
||||||
digit_timeout = val;
|
digit_timeout = val;
|
||||||
|
} else if (!strcasecmp(var, "enable-analog-option")) {
|
||||||
|
analog_options = enable_analog_option(val, analog_options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1408,7 +1438,8 @@ static switch_status_t load_config(void)
|
||||||
SPAN_CONFIG[span->span_id].span = span;
|
SPAN_CONFIG[span->span_id].span = span;
|
||||||
switch_set_string(SPAN_CONFIG[span->span_id].context, context);
|
switch_set_string(SPAN_CONFIG[span->span_id].context, context);
|
||||||
switch_set_string(SPAN_CONFIG[span->span_id].dialplan, dialplan);
|
switch_set_string(SPAN_CONFIG[span->span_id].dialplan, dialplan);
|
||||||
|
SPAN_CONFIG[span->span_id].analog_options = analog_options | globals.analog_options;
|
||||||
|
|
||||||
if (dial_regex) {
|
if (dial_regex) {
|
||||||
switch_set_string(SPAN_CONFIG[span->span_id].dial_regex, dial_regex);
|
switch_set_string(SPAN_CONFIG[span->span_id].dial_regex, dial_regex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,6 +369,10 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||||
zap_channel_command(zchan, ZAP_COMMAND_GENERATE_RING_OFF, NULL);
|
zap_channel_command(zchan, ZAP_COMMAND_GENERATE_RING_OFF, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zchan->token_count == 1) {
|
||||||
|
zap_clear_flag(zchan, ZAP_CHANNEL_HOLD);
|
||||||
|
}
|
||||||
|
|
||||||
if (zap_test_flag(zchan, ZAP_CHANNEL_HOLD)) {
|
if (zap_test_flag(zchan, ZAP_CHANNEL_HOLD)) {
|
||||||
zap_clear_flag(zchan, ZAP_CHANNEL_HOLD);
|
zap_clear_flag(zchan, ZAP_CHANNEL_HOLD);
|
||||||
sig.event_id = ZAP_SIGEVENT_ADD_CALL;
|
sig.event_id = ZAP_SIGEVENT_ADD_CALL;
|
||||||
|
@ -519,7 +523,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zap_channel_read(zchan, frame, &len) != ZAP_SUCCESS) {
|
if (zap_channel_read(zchan, frame, &len) != ZAP_SUCCESS) {
|
||||||
zap_log(ZAP_LOG_ERROR, "READ ERROR\n");
|
zap_log(ZAP_LOG_ERROR, "READ ERROR [%s]\n", zchan->last_error);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -654,11 +654,15 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
|
||||||
static ZIO_READ_FUNCTION(zt_read)
|
static ZIO_READ_FUNCTION(zt_read)
|
||||||
{
|
{
|
||||||
zap_ssize_t r = 0;
|
zap_ssize_t r = 0;
|
||||||
//*datalen = zchan->packet_len;
|
int errs = 0;
|
||||||
|
|
||||||
r = read(zchan->sockfd, data, *datalen);
|
while (errs++ < 100) {
|
||||||
|
if ((r = read(zchan->sockfd, data, *datalen)) > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (r >= 0) {
|
if (r > 0) {
|
||||||
*datalen = r;
|
*datalen = r;
|
||||||
if (zchan->type == ZAP_CHAN_TYPE_DQ921) {
|
if (zchan->type == ZAP_CHAN_TYPE_DQ921) {
|
||||||
*datalen -= 2;
|
*datalen -= 2;
|
||||||
|
|
Loading…
Reference in New Issue