- a little bit cleanup. The internal capi functions shall not use
the asterisk channel structure.
This commit is contained in:
parent
4c9b279ed0
commit
d02004dabc
51
chan_capi.c
51
chan_capi.c
|
@ -279,7 +279,8 @@ int capi_wait_for_b3_up(struct capi_pvt *i)
|
|||
int ret = 1;
|
||||
|
||||
cc_mutex_lock(&i->lock);
|
||||
if (!(i->isdnstate & CAPI_ISDN_STATE_B3_UP)) {
|
||||
if ((!(i->isdnstate & CAPI_ISDN_STATE_B3_UP)) &&
|
||||
(i->PLCI != 0)) {
|
||||
i->waitevent = CAPI_WAITEVENT_B3_UP;
|
||||
abstime.tv_sec = time(NULL) + 2;
|
||||
abstime.tv_nsec = 0;
|
||||
|
@ -460,7 +461,6 @@ static void capi_channel_task(struct ast_channel *c, int task)
|
|||
*/
|
||||
static void capi_echo_canceller(struct capi_pvt *i, int function)
|
||||
{
|
||||
struct ast_channel *c = i->owner;
|
||||
int ecAvail = 0;
|
||||
|
||||
if ((i->isdnstate & CAPI_ISDN_STATE_DISCONNECT))
|
||||
|
@ -493,7 +493,7 @@ static void capi_echo_canceller(struct capi_pvt *i, int function)
|
|||
return;
|
||||
}
|
||||
|
||||
if (capi_tcap_is_digital(c->transfercapability)) {
|
||||
if (capi_tcap_is_digital(i->transfercapability)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_2 "%s: No echo canceller in digital mode (PLCI=%#x)\n",
|
||||
i->vname, i->PLCI);
|
||||
return;
|
||||
|
@ -525,7 +525,6 @@ static void capi_echo_canceller(struct capi_pvt *i, int function)
|
|||
*/
|
||||
static int capi_detect_dtmf(struct capi_pvt *i, int flag)
|
||||
{
|
||||
struct ast_channel *c = i->owner;
|
||||
MESSAGE_EXCHANGE_ERROR error;
|
||||
|
||||
if ((i->isdnstate & CAPI_ISDN_STATE_DISCONNECT))
|
||||
|
@ -535,7 +534,7 @@ static int capi_detect_dtmf(struct capi_pvt *i, int flag)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (capi_tcap_is_digital(c->transfercapability)) {
|
||||
if (capi_tcap_is_digital(i->transfercapability)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_2 "%s: No dtmf-detect in digital mode (PLCI=%#x)\n",
|
||||
i->vname, i->PLCI);
|
||||
return 0;
|
||||
|
@ -580,16 +579,9 @@ static int capi_detect_dtmf(struct capi_pvt *i, int flag)
|
|||
*/
|
||||
static int local_queue_frame(struct capi_pvt *i, struct ast_frame *f)
|
||||
{
|
||||
struct ast_channel *chan = i->owner;
|
||||
unsigned char *wbuf;
|
||||
int wbuflen;
|
||||
|
||||
if (chan == NULL) {
|
||||
cc_log(LOG_WARNING, "No owner in local_queue_frame for %s\n",
|
||||
i->vname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(i->isdnstate & CAPI_ISDN_STATE_PBX)) {
|
||||
/* if there is no PBX running yet,
|
||||
we don't need any frames sent */
|
||||
|
@ -642,7 +634,9 @@ static void update_channel_name(struct capi_pvt *i)
|
|||
|
||||
snprintf(name, sizeof(name) - 1, "CAPI/%s/%s-%x",
|
||||
i->vname, i->dnid, capi_counter++);
|
||||
ast_change_name(i->owner, name);
|
||||
if (i->owner) {
|
||||
ast_change_name(i->owner, name);
|
||||
}
|
||||
cc_verbose(3, 0, VERBOSE_PREFIX_3 "%s: Updated channel name: %s\n",
|
||||
i->vname, name);
|
||||
}
|
||||
|
@ -1139,6 +1133,7 @@ static int pbx_capi_call(struct ast_channel *c, char *idest, int timeout)
|
|||
|
||||
i->peer = cc_get_peer_link_id(pbx_builtin_getvar_helper(c, "CAPIPEERLINKID"));
|
||||
i->outgoing = 1;
|
||||
i->transfercapability = c->transfercapability;
|
||||
i->isdnstate |= CAPI_ISDN_STATE_PBX;
|
||||
i->state = CAPI_STATE_CONNECTPENDING;
|
||||
ast_setstate(c, AST_STATE_DIALING);
|
||||
|
@ -1146,7 +1141,7 @@ static int pbx_capi_call(struct ast_channel *c, char *idest, int timeout)
|
|||
|
||||
/* if this is a CCBS/CCNR callback call */
|
||||
if (i->ccbsnrhandle) {
|
||||
_cword cip = (_cword)tcap2cip(c->transfercapability);
|
||||
_cword cip = (_cword)tcap2cip(i->transfercapability);
|
||||
_cword rbref;
|
||||
|
||||
i->doOverlap = 0;
|
||||
|
@ -1202,7 +1197,7 @@ static int pbx_capi_call(struct ast_channel *c, char *idest, int timeout)
|
|||
dsa = calledsubaddress;
|
||||
}
|
||||
|
||||
if (capi_tcap_is_digital(c->transfercapability)) {
|
||||
if (capi_tcap_is_digital(i->transfercapability)) {
|
||||
i->bproto = CC_BPROTO_TRANSPARENT;
|
||||
cc_verbose(4, 0, VERBOSE_PREFIX_2 "%s: is digital call, set proto to TRANSPARENT\n",
|
||||
i->vname);
|
||||
|
@ -1242,7 +1237,7 @@ static int pbx_capi_call(struct ast_channel *c, char *idest, int timeout)
|
|||
|
||||
error = capi_sendf(NULL, 0, CAPI_CONNECT_REQ, i->controller, i->MessageNumber,
|
||||
"wssss(wwwsss())()()()((w)()()s)",
|
||||
tcap2cip(c->transfercapability), /* CIP value */
|
||||
tcap2cip(i->transfercapability), /* CIP value */
|
||||
called, /* called party number */
|
||||
calling, /* calling party number */
|
||||
dsa, /* called party subaddress */
|
||||
|
@ -1347,7 +1342,7 @@ static int pbx_capi_answer(struct ast_channel *c)
|
|||
i->bproto = CC_BPROTO_TRANSPARENT;
|
||||
|
||||
if (i->rtp) {
|
||||
if (!capi_tcap_is_digital(c->transfercapability))
|
||||
if (!capi_tcap_is_digital(i->transfercapability))
|
||||
i->bproto = CC_BPROTO_RTP;
|
||||
}
|
||||
|
||||
|
@ -2126,7 +2121,7 @@ static void capi_handle_dtmf_fax(struct capi_pvt *i)
|
|||
struct ast_channel *c = i->owner;
|
||||
|
||||
if (!c) {
|
||||
cc_log(LOG_ERROR, "No channel!\n");
|
||||
/* no channel, ignore */
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2812,7 +2807,6 @@ static void capidev_handle_facility_indication(_cmsg *CMSG, unsigned int PLCI, u
|
|||
*/
|
||||
static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, unsigned int NCCI, struct capi_pvt *i)
|
||||
{
|
||||
struct ast_channel *chan;
|
||||
struct ast_frame fr = { AST_FRAME_NULL, };
|
||||
unsigned char *b3buf = NULL;
|
||||
int b3len = 0;
|
||||
|
@ -2834,8 +2828,6 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
|
||||
return_on_no_interface("DATA_B3_IND");
|
||||
|
||||
chan = i->owner;
|
||||
|
||||
if (i->fFax) {
|
||||
/* we are in fax mode and have a file open */
|
||||
cc_verbose(6, 1, VERBOSE_PREFIX_3 "%s: DATA_B3_IND (len=%d) Fax\n",
|
||||
|
@ -2872,7 +2864,7 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
i->B3q += b3len;
|
||||
}
|
||||
|
||||
if ((i->doES == 1) && (!capi_tcap_is_digital(chan->transfercapability))) {
|
||||
if ((i->doES == 1) && (!capi_tcap_is_digital(i->transfercapability))) {
|
||||
for (j = 0; j < b3len; j++) {
|
||||
*(b3buf + j) = capi_reversebits[*(b3buf + j)];
|
||||
if (capi_capability == AST_FORMAT_ULAW) {
|
||||
|
@ -2897,7 +2889,7 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
i->vname, rxavg, txavg);
|
||||
}
|
||||
} else {
|
||||
if ((i->rxgain == 1.0) || (capi_tcap_is_digital(chan->transfercapability))) {
|
||||
if ((i->rxgain == 1.0) || (capi_tcap_is_digital(i->transfercapability))) {
|
||||
for (j = 0; j < b3len; j++) {
|
||||
*(b3buf + j) = capi_reversebits[*(b3buf + j)];
|
||||
}
|
||||
|
@ -3088,12 +3080,6 @@ static void capidev_handle_connect_b3_active_indication(_cmsg *CMSG, unsigned in
|
|||
return;
|
||||
}
|
||||
|
||||
if (!i->owner) {
|
||||
cc_log(LOG_ERROR, "%s: No channel for interface!\n",
|
||||
i->vname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (i->FaxState & CAPI_FAX_STATE_ACTIVE) {
|
||||
i->FaxState |= CAPI_FAX_STATE_CONN;
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: Fax connection, no EC/DTMF\n",
|
||||
|
@ -3371,8 +3357,9 @@ static void capidev_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
interface_cleanup(i);
|
||||
break;
|
||||
}
|
||||
i->owner->transfercapability = cip2tcap(i->cip);
|
||||
if (capi_tcap_is_digital(i->owner->transfercapability)) {
|
||||
i->transfercapability = cip2tcap(i->cip);
|
||||
i->owner->transfercapability = i->transfercapability;
|
||||
if (capi_tcap_is_digital(i->transfercapability)) {
|
||||
i->bproto = CC_BPROTO_TRANSPARENT;
|
||||
}
|
||||
i->owner->cid.cid_pres = callpres;
|
||||
|
@ -3383,7 +3370,7 @@ static void capidev_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, un
|
|||
cc_mutex_unlock(&iflock);
|
||||
cc_mutex_lock(&i->lock);
|
||||
|
||||
pbx_builtin_setvar_helper(i->owner, "TRANSFERCAPABILITY", transfercapability2str(i->owner->transfercapability));
|
||||
pbx_builtin_setvar_helper(i->owner, "TRANSFERCAPABILITY", transfercapability2str(i->transfercapability));
|
||||
pbx_builtin_setvar_helper(i->owner, "BCHANNELINFO", bchannelinfo);
|
||||
sprintf(buffer, "%d", callednplan);
|
||||
pbx_builtin_setvar_helper(i->owner, "CALLEDTON", buffer);
|
||||
|
|
|
@ -318,7 +318,7 @@ struct capi_pvt {
|
|||
|
||||
/* which b-protocol is active */
|
||||
int bproto;
|
||||
|
||||
|
||||
char context[AST_MAX_EXTENSION];
|
||||
/*! Multiple Subscriber Number we listen to (, seperated list) */
|
||||
char incomingmsn[CAPI_MAX_STRING];
|
||||
|
@ -379,6 +379,7 @@ struct capi_pvt {
|
|||
|
||||
/* Common ISDN Profile (CIP) */
|
||||
int cip;
|
||||
unsigned short transfercapability;
|
||||
|
||||
/* if not null, receiving a fax */
|
||||
FILE *fFax;
|
||||
|
|
|
@ -47,6 +47,12 @@ static void update_capi_mixer(int remove, unsigned int roomnumber, struct capi_p
|
|||
unsigned int found = 0;
|
||||
_cword j = 0;
|
||||
|
||||
if (i->PLCI == 0) {
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_3 "capi mixer: %s: PLCI is unset, abort.\n",
|
||||
i->vname);
|
||||
return;
|
||||
}
|
||||
|
||||
cc_mutex_lock(&chat_lock);
|
||||
room = chat_list;
|
||||
while (room) {
|
||||
|
@ -206,6 +212,7 @@ static void chat_handle_events(struct ast_channel *chan, struct capi_pvt *i)
|
|||
waitfds[0] = i->readerfd;
|
||||
if (i->channeltype == CAPI_CHANNELTYPE_NULL) {
|
||||
nfds = 1;
|
||||
ast_indicate(chan, -1);
|
||||
ast_set_read_format(chan, capi_capability);
|
||||
ast_set_write_format(chan, capi_capability);
|
||||
}
|
||||
|
@ -356,9 +363,18 @@ int pbxcli_capi_chatinfo(int fd, int argc, char *argv[])
|
|||
room = chat_list;
|
||||
while (room) {
|
||||
c = room->i->owner;
|
||||
ast_cli(fd, "%3d %-12s%-30s\"%s\" <%s>\n",
|
||||
room->number, room->name, c->name,
|
||||
(c->cid.cid_name) ? c->cid.cid_name:"", c->cid.cid_num);
|
||||
if (!c) {
|
||||
c = room->i->used;
|
||||
}
|
||||
if (!c) {
|
||||
ast_cli(fd, "%3d %-12s%-30s\"%s\" <%s>\n",
|
||||
room->number, room->name, room->i->vname,
|
||||
"?", "?");
|
||||
} else {
|
||||
ast_cli(fd, "%3d %-12s%-30s\"%s\" <%s>\n",
|
||||
room->number, room->name, c->name,
|
||||
(c->cid.cid_name) ? c->cid.cid_name:"", c->cid.cid_num);
|
||||
}
|
||||
room = room->next;
|
||||
}
|
||||
cc_mutex_unlock(&chat_lock);
|
||||
|
|
|
@ -188,9 +188,8 @@ int capi_alloc_rtp(struct capi_pvt *i)
|
|||
/*
|
||||
* write rtp for a channel
|
||||
*/
|
||||
int capi_write_rtp(struct ast_channel *c, struct ast_frame *f)
|
||||
int capi_write_rtp(struct capi_pvt *i, struct ast_frame *f)
|
||||
{
|
||||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
struct sockaddr_in us;
|
||||
int len;
|
||||
socklen_t uslen;
|
||||
|
@ -243,7 +242,7 @@ int capi_write_rtp(struct ast_channel *c, struct ast_frame *f)
|
|||
i->vname, i->NCCI, len, f->datalen, ast_getformatname(f->subclass),
|
||||
i->timestamp);
|
||||
|
||||
capi_sendf (NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
|
||||
capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
|
||||
"dwww",
|
||||
buf,
|
||||
len,
|
||||
|
@ -313,7 +312,7 @@ void voice_over_ip_profile(struct cc_capi_controller *cp)
|
|||
unsigned short info = 0;
|
||||
unsigned int payload1, payload2;
|
||||
|
||||
capi_sendf (NULL, 0, CAPI_FACILITY_REQ, cp->controller, get_capi_MessageNumber(),
|
||||
capi_sendf(NULL, 0, CAPI_FACILITY_REQ, cp->controller, get_capi_MessageNumber(),
|
||||
"ws",
|
||||
FACILITYSELECTOR_VOICE_OVER_IP,
|
||||
&fac
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
extern int capi_alloc_rtp(struct capi_pvt *i);
|
||||
extern void voice_over_ip_profile(struct cc_capi_controller *cp);
|
||||
extern int capi_write_rtp(struct ast_channel *c, struct ast_frame *f);
|
||||
extern int capi_write_rtp(struct capi_pvt *i, struct ast_frame *f);
|
||||
extern struct ast_frame *capi_read_rtp(struct capi_pvt *i, unsigned char *buf, int len);
|
||||
extern _cstruct capi_rtp_ncpi(struct capi_pvt *i);
|
||||
|
||||
|
|
|
@ -88,6 +88,9 @@ int capi_remove_nullif(struct capi_pvt *i)
|
|||
return 0;
|
||||
}
|
||||
|
||||
cc_mutex_destroy(&i->lock);
|
||||
ast_cond_destroy(&i->event_trigger);
|
||||
|
||||
cc_mutex_lock(&nullif_lock);
|
||||
ii = nulliflist;
|
||||
while (ii) {
|
||||
|
@ -133,10 +136,11 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned int controller)
|
|||
|
||||
tmp->channeltype = CAPI_CHANNELTYPE_NULL;
|
||||
|
||||
tmp->owner = c;
|
||||
tmp->used = c;
|
||||
tmp->peer = c;
|
||||
|
||||
tmp->cip = CAPI_CIPI_SPEECH;
|
||||
tmp->transfercapability = PRI_TRANS_CAP_SPEECH;
|
||||
tmp->controller = controller;
|
||||
tmp->doEC = 1;
|
||||
tmp->doEC_global = 1;
|
||||
|
@ -166,7 +170,8 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned int controller)
|
|||
tmp->outgoing = 1;
|
||||
tmp->state = CAPI_STATE_CONNECTPENDING;
|
||||
tmp->MessageNumber = get_capi_MessageNumber();
|
||||
capi_sendf (NULL, 0, CAPI_CONNECT_REQ, controller, tmp->MessageNumber,
|
||||
|
||||
capi_sendf(NULL, 0, CAPI_CONNECT_REQ, controller, tmp->MessageNumber,
|
||||
"w()()()()(www()()()())()()()((wwbbb)()()())",
|
||||
0, 1,1,0, 3,0,0,0,0);
|
||||
|
||||
|
@ -849,7 +854,7 @@ unsigned capi_ListenOnController(unsigned int CIPmask, unsigned controller)
|
|||
int waitcount = 50;
|
||||
_cmsg CMSG;
|
||||
|
||||
error = capi_sendf (NULL, 0, CAPI_LISTEN_REQ, controller, get_capi_MessageNumber(),
|
||||
error = capi_sendf(NULL, 0, CAPI_LISTEN_REQ, controller, get_capi_MessageNumber(),
|
||||
"ddd()()",
|
||||
0x0000ffff,
|
||||
CIPmask,
|
||||
|
@ -1080,7 +1085,6 @@ struct ast_frame *capi_read_pipeframe(struct capi_pvt *i)
|
|||
*/
|
||||
int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
||||
{
|
||||
struct ast_channel *c;
|
||||
MESSAGE_EXCHANGE_ERROR error;
|
||||
int j = 0;
|
||||
unsigned char *buf;
|
||||
|
@ -1092,7 +1096,6 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
cc_log(LOG_ERROR, "channel has no interface\n");
|
||||
return -1;
|
||||
}
|
||||
c = i->owner;
|
||||
|
||||
if ((!(i->isdnstate & CAPI_ISDN_STATE_B3_UP)) || (!i->NCCI) ||
|
||||
((i->isdnstate & (CAPI_ISDN_STATE_B3_CHANGE | CAPI_ISDN_STATE_LI)))) {
|
||||
|
@ -1120,7 +1123,7 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
return 0;
|
||||
}
|
||||
if ((!f->data) || (!f->datalen)) {
|
||||
cc_log(LOG_DEBUG, "No data for FRAME_VOICE %s\n", c->name);
|
||||
cc_log(LOG_DEBUG, "No data for FRAME_VOICE %s\n", i->vname);
|
||||
return 0;
|
||||
}
|
||||
if (i->isdnstate & CAPI_ISDN_STATE_RTP) {
|
||||
|
@ -1130,7 +1133,7 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
ast_getformatname(f->subclass), f->subclass);
|
||||
return 0;
|
||||
}
|
||||
return capi_write_rtp(c, f);
|
||||
return capi_write_rtp(i, f);
|
||||
}
|
||||
if (i->B3count >= CAPI_MAX_B3_BLOCKS) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_4 "%s: B3count is full, dropping packet.\n",
|
||||
|
@ -1150,7 +1153,7 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
(CAPI_MAX_B3_BLOCK_SIZE + AST_FRIENDLY_OFFSET)]);
|
||||
i->send_buffer_handle++;
|
||||
|
||||
if ((i->doES == 1) && (!capi_tcap_is_digital(c->transfercapability))) {
|
||||
if ((i->doES == 1) && (!capi_tcap_is_digital(i->transfercapability))) {
|
||||
for (j = 0; j < fsmooth->datalen; j++) {
|
||||
buf[j] = capi_reversebits[ ((unsigned char *)fsmooth->data)[j] ];
|
||||
if (capi_capability == AST_FORMAT_ULAW) {
|
||||
|
@ -1165,7 +1168,7 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
|
|||
}
|
||||
i->txavg[ECHO_TX_COUNT - 1] = txavg;
|
||||
} else {
|
||||
if ((i->txgain == 1.0) || (capi_tcap_is_digital(c->transfercapability))) {
|
||||
if ((i->txgain == 1.0) || (capi_tcap_is_digital(i->transfercapability))) {
|
||||
for (j = 0; j < fsmooth->datalen; j++) {
|
||||
buf[j] = capi_reversebits[((unsigned char *)fsmooth->data)[j]];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue