提交 3f4bf6f6 authored 作者: Michael Jerris's avatar Michael Jerris

(OPENZAP-7) inital checkin of E&M support from John Wehle

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@561 a93c3328-9c30-0410-af19-c9cd2b2d52af
上级 f0b27688
......@@ -181,7 +181,7 @@ PIKA_LIB=$(shell ls /usr/lib/libpikahmpapi.so 2>/dev/null)
#endif
#endif
all: $(MYLIB) analogmod isdnmod boostmod ztmod wpmod
all: $(MYLIB) analogmod analog_emmod isdnmod boostmod ztmod wpmod
$(MYLIB): $(OBJS) $(HEADERS) $(SOURCES)
$(LINK) $(SOLINK) -o $(MYLIB) $(OBJS) $(ADD_OBJS) $(LIBS)
......@@ -274,6 +274,10 @@ $(SRC)/ozmod/ozmod_analog/ozmod_analog.$(DYNAMIC_LIB_EXTEN): $(MYLIB) $(SRC)/ozm
$(LINK) $(SOLINK) $(SRC)/ozmod/ozmod_analog/ozmod_analog.o $(MYLIB) -rpath $(libdir)
analogmod: $(SRC)/ozmod/ozmod_analog/ozmod_analog.$(DYNAMIC_LIB_EXTEN)
$(SRC)/ozmod/ozmod_analog_em/ozmod_analog_em.$(DYNAMIC_LIB_EXTEN): $(MYLIB) $(ANALOG_EM_OBJS) $(SRC)/ozmod/ozmod_analog_em/ozmod_analog_em.o
$(LINK) $(SOLINK) $(SRC)/ozmod/ozmod_analog_em/ozmod_analog_em.o $(MYLIB) -rpath $(libdir)
analog_emmod: $(SRC)/ozmod/ozmod_analog_em/ozmod_analog_em.$(DYNAMIC_LIB_EXTEN)
$(SRC)/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.$(DYNAMIC_LIB_EXTEN): $(MYLIB) $(BOOST_OBJS)
$(LINK) $(SOLINK) $(BOOST_OBJS) $(MYLIB) -rpath $(libdir)
boostmod: $(SRC)/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.$(DYNAMIC_LIB_EXTEN)
......
......@@ -417,6 +417,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
switch (tech_pvt->zchan->type) {
case ZAP_CHAN_TYPE_FXO:
case ZAP_CHAN_TYPE_EM:
{
zap_set_state_locked(tech_pvt->zchan, ZAP_CHANNEL_STATE_HANGUP);
......@@ -806,6 +807,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
switch (tech_pvt->zchan->type) {
case ZAP_CHAN_TYPE_FXS:
case ZAP_CHAN_TYPE_EM:
status = channel_receive_message_fxs(session, msg);
break;
case ZAP_CHAN_TYPE_FXO:
......@@ -1445,6 +1447,7 @@ static ZIO_SIGNAL_CB_FUNCTION(on_analog_signal)
switch (sigmsg->channel->type) {
case ZAP_CHAN_TYPE_FXO:
case ZAP_CHAN_TYPE_EM:
{
status = on_fxo_signal(sigmsg);
}
......@@ -1616,6 +1619,100 @@ static switch_status_t load_config(void)
}
}
if ((spans = switch_xml_child(cfg, "analog_em_spans"))) {
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
char *id = (char *) switch_xml_attr_soft(myspan, "id");
char *context = "default";
char *dialplan = "XML";
char *tonegroup = NULL;
char *digit_timeout = NULL;
char *max_digits = NULL;
char *dial_regex = NULL;
char *hold_music = NULL;
char *fail_dial_regex = NULL;
uint32_t span_id = 0, to = 0, max = 0;
zap_span_t *span = NULL;
analog_option_t analog_options = ANALOG_OPTION_NONE;
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "tonegroup")) {
tonegroup = val;
} else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) {
digit_timeout = val;
} else if (!strcasecmp(var, "context")) {
context = val;
} else if (!strcasecmp(var, "dialplan")) {
dialplan = val;
} else if (!strcasecmp(var, "dial-regex")) {
dial_regex = val;
} else if (!strcasecmp(var, "fail-dial-regex")) {
fail_dial_regex = val;
} else if (!strcasecmp(var, "hold-music")) {
hold_music = val;
} else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
max_digits = val;
} else if (!strcasecmp(var, "enable-analog-option")) {
analog_options = enable_analog_option(val, analog_options);
}
}
if (!id) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required param 'id'\n");
continue;
}
span_id = atoi(id);
if (!tonegroup) {
tonegroup = "us";
}
if (digit_timeout) {
to = atoi(digit_timeout);
}
if (max_digits) {
max = atoi(max_digits);
}
if (zap_span_find(span_id, &span) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_ERROR, "Error finding OpenZAP span %d\n", span_id);
continue;
}
if (zap_configure_span("analog_em", span, on_analog_signal,
"tonemap", tonegroup,
"digit_timeout", &to,
"max_dialstr", &max,
TAG_END) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id);
continue;
}
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].dialplan, dialplan);
SPAN_CONFIG[span->span_id].analog_options = analog_options | globals.analog_options;
if (dial_regex) {
switch_set_string(SPAN_CONFIG[span->span_id].dial_regex, dial_regex);
}
if (fail_dial_regex) {
switch_set_string(SPAN_CONFIG[span->span_id].fail_dial_regex, fail_dial_regex);
}
if (hold_music) {
switch_set_string(SPAN_CONFIG[span->span_id].hold_music, hold_music);
}
switch_copy_string(SPAN_CONFIG[span->span_id].type, "analog_em", sizeof(SPAN_CONFIG[span->span_id].type));
zap_span_start(span);
}
}
if ((spans = switch_xml_child(cfg, "pri_spans"))) {
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
char *id = (char *) switch_xml_attr_soft(myspan, "id");
......
......@@ -123,18 +123,20 @@ typedef enum {
ZAP_TRUNK_BRI_PTMP,
ZAP_TRUNK_FXO,
ZAP_TRUNK_FXS,
ZAP_TRUNK_EM,
ZAP_TRUNK_NONE
} zap_trunk_type_t;
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "NONE"
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "NONE"
ZAP_STR2ENUM_P(zap_str2zap_trunk_type, zap_trunk_type2str, zap_trunk_type_t)
typedef enum {
ZAP_ANALOG_START_KEWL,
ZAP_ANALOG_START_LOOP,
ZAP_ANALOG_START_GROUND,
ZAP_ANALOG_START_WINK,
ZAP_ANALOG_START_NA
} zap_analog_start_type_t;
#define START_TYPE_STRINGS "KEWL", "LOOP", "GROUND", "NA"
#define START_TYPE_STRINGS "KEWL", "LOOP", "GROUND", "WINK", "NA"
ZAP_STR2ENUM_P(zap_str2zap_analog_start_type, zap_analog_start_type2str, zap_analog_start_type_t)
typedef enum {
......@@ -284,10 +286,11 @@ typedef enum {
ZAP_CHAN_TYPE_DQ931,
ZAP_CHAN_TYPE_FXS,
ZAP_CHAN_TYPE_FXO,
ZAP_CHAN_TYPE_EM,
ZAP_CHAN_TYPE_COUNT
} zap_chan_type_t;
#define CHAN_TYPE_STRINGS "B", "DQ921", "DQ931", "FXS", "FXO", "INVALID"
#define CHAN_TYPE_STRINGS "B", "DQ921", "DQ931", "FXS", "FXO", "EM", "INVALID"
ZAP_STR2ENUM_P(zap_str2zap_chan_type, zap_chan_type2str, zap_chan_type_t)
typedef enum {
......
/*
* Copyright (c) 2008, Anthony Minessale II
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Contributor(s):
*
* John Wehle (john@feith.com)
*
*/
#ifndef ZAP_ANALOG_EM_H
#define ZAP_ANALOG_EM_H
#include "openzap.h"
typedef enum {
ZAP_ANALOG_EM_RUNNING = (1 << 0)
} zap_analog_em_flag_t;
static void *zap_analog_em_run(zap_thread_t *me, void *obj);
typedef struct zap_analog_data zap_analog_em_data_t;
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/
......@@ -173,7 +173,7 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
zchan->physical_span_id = ztp.span_no;
zchan->physical_chan_id = ztp.chan_no;
if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO || type == ZAP_CHAN_TYPE_B) {
if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO || type == ZAP_CHAN_TYPE_EM || type == ZAP_CHAN_TYPE_B) {
if (ztp.g711_type == ZT_G711_ALAW) {
zchan->native_codec = zchan->effective_codec = ZAP_CODEC_ALAW;
} else if (ztp.g711_type == ZT_G711_MULAW) {
......@@ -343,7 +343,7 @@ static ZIO_OPEN_FUNCTION(zt_open)
zap_log(ZAP_LOG_ERROR, "%s\n", zchan->last_error);
return ZAP_FAIL;
}
} else if (zchan->type == ZAP_CHAN_TYPE_FXS || zchan->type == ZAP_CHAN_TYPE_FXO) {
} else if (zchan->type == ZAP_CHAN_TYPE_FXS || zchan->type == ZAP_CHAN_TYPE_FXO || zchan->type == ZAP_CHAN_TYPE_EM) {
int len = zt_globals.eclevel;
if (ioctl(zchan->sockfd, ZT_ECHOCANCEL, &len)) {
zap_log(ZAP_LOG_WARNING, "Echo cancel not available for %d:%d\n", zchan->span_id, zchan->chan_id);
......@@ -636,7 +636,7 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
break;
case ZT_EVENT_WINKFLASH:
{
if (span->channels[i]->state == ZAP_CHANNEL_STATE_DOWN) {
if (span->channels[i]->state == ZAP_CHANNEL_STATE_DOWN || span->channels[i]->state == ZAP_CHANNEL_STATE_DIALING) {
event_id = ZAP_OOB_WINK;
} else {
event_id = ZAP_OOB_FLASH;
......@@ -645,7 +645,7 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
break;
case ZT_EVENT_RINGOFFHOOK:
{
if (span->channels[i]->type == ZAP_CHAN_TYPE_FXS) {
if (span->channels[i]->type == ZAP_CHAN_TYPE_FXS || (span->channels[i]->type == ZAP_CHAN_TYPE_EM && span->channels[i]->state != ZAP_CHANNEL_STATE_UP)) {
zap_set_flag_locked(span->channels[i], ZAP_CHANNEL_OFFHOOK);
event_id = ZAP_OOB_OFFHOOK;
} else if (span->channels[i]->type == ZAP_CHAN_TYPE_FXO) {
......
......@@ -2032,7 +2032,7 @@ static zap_status_t load_config(void)
zap_copy_string(number, val, sizeof(number));
}
} else if (!strcasecmp(var, "analog-start-type")) {
if (span->trunk_type == ZAP_TRUNK_FXS || span->trunk_type == ZAP_TRUNK_FXO) {
if (span->trunk_type == ZAP_TRUNK_FXS || span->trunk_type == ZAP_TRUNK_FXO || span->trunk_type == ZAP_TRUNK_EM) {
if ((tmp = zap_str2zap_analog_start_type(val)) != ZAP_ANALOG_START_NA) {
span->start_type = tmp;
zap_log(ZAP_LOG_DEBUG, "changing start type to '%s'\n", zap_analog_start_type2str(span->start_type));
......@@ -2062,6 +2062,17 @@ static zap_status_t load_config(void)
} else {
zap_log(ZAP_LOG_WARNING, "Cannot add FXS channels to an FXO trunk!\n");
}
} else if (!strcasecmp(var, "em-channel")) {
if (span->trunk_type == ZAP_TRUNK_NONE) {
span->trunk_type = ZAP_TRUNK_EM;
zap_log(ZAP_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", zap_trunk_type2str(span->trunk_type),
zap_analog_start_type2str(span->start_type));
}
if (span->trunk_type == ZAP_TRUNK_EM) {
configured += zio->configure_span(span, val, ZAP_CHAN_TYPE_EM, name, number);
} else {
zap_log(ZAP_LOG_WARNING, "Cannot add EM channels to a non-EM trunk!\n");
}
} else if (!strcasecmp(var, "b-channel")) {
configured += zio->configure_span(span, val, ZAP_CHAN_TYPE_B, name, number);
} else if (!strcasecmp(var, "d-channel")) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论