rebuffer option for chan_lcr (160 bytes per frame)
l1-link state "unknown" if not known yet. removed root user check. modified: bchannel.c modified: bchannel.h modified: chan_lcr.c modified: chan_lcr.h modified: dss1.cpp modified: lcradmin.c modified: mISDN.cpp modified: main.c
This commit is contained in:
parent
89d3a5de47
commit
a114e74299
58
bchannel.c
58
bchannel.c
|
@ -195,6 +195,7 @@ void bchannel_activate(struct bchannel *bchannel, int activate)
|
|||
CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
|
||||
|
||||
bchannel->b_state = (activate)?BSTATE_ACTIVATING:BSTATE_DEACTIVATING;
|
||||
bchannel->rebuffer_usage = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,6 +250,7 @@ void bchannel_destroy(struct bchannel *bchannel)
|
|||
{
|
||||
close(bchannel->b_sock);
|
||||
bchannel->b_sock = -1;
|
||||
bchannel->rebuffer_usage = 0;
|
||||
}
|
||||
bchannel->b_state = BSTATE_IDLE;
|
||||
}
|
||||
|
@ -346,17 +348,63 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned char *buffer, i
|
|||
/* return, because we have no audio from port */
|
||||
return;
|
||||
}
|
||||
if (bchannel->call->pipe[1] > -1)
|
||||
|
||||
if (bchannel->call->pipe[1] < 0)
|
||||
{
|
||||
/* nobody there */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (bchannel->call->rebuffer) {
|
||||
int u = bchannel->rebuffer_usage;
|
||||
unsigned char * b = bchannel->rebuffer;
|
||||
unsigned char * d = data;
|
||||
int l = len;
|
||||
int fd = bchannel->call->pipe[1];
|
||||
|
||||
if (u > 0) {
|
||||
if (u + l >= 160) {
|
||||
memcpy(b + u, d, 160 - u);
|
||||
d += 160 - u;
|
||||
l -= 160 - u;
|
||||
u = 0;
|
||||
if (write(fd, b, 160) < 0) {
|
||||
goto errout;
|
||||
}
|
||||
} else {
|
||||
memcpy(b + u, d, l);
|
||||
u += l;
|
||||
l = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while (l >= 160) {
|
||||
if (write(fd, d, 160) < 0) {
|
||||
goto errout;
|
||||
}
|
||||
d += 160;
|
||||
l -= 160;
|
||||
}
|
||||
|
||||
if (l > 0) {
|
||||
memcpy(b, d, l);
|
||||
}
|
||||
bchannel->rebuffer_usage = u + l;
|
||||
} else {
|
||||
len = write(bchannel->call->pipe[1], data, len);
|
||||
if (len < 0)
|
||||
{
|
||||
close(bchannel->call->pipe[1]);
|
||||
bchannel->call->pipe[1] = -1;
|
||||
CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
|
||||
return;
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
errout:
|
||||
close(bchannel->call->pipe[1]);
|
||||
bchannel->call->pipe[1] = -1;
|
||||
bchannel->rebuffer_usage = 0;
|
||||
CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ struct bchannel {
|
|||
int b_dtmf;
|
||||
int b_bf_len;
|
||||
unsigned char b_bf_key[128];
|
||||
int rebuffer_usage;
|
||||
unsigned char rebuffer[160];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -475,6 +475,14 @@ void apply_opt(struct chan_call *call, char *data)
|
|||
if (call->bchannel)
|
||||
bchannel_pipeline(call->bchannel, call->pipeline);
|
||||
break;
|
||||
case 'r':
|
||||
if (opt[1] == '\0') {
|
||||
CERROR(call, call->ast, "Option 'r' (re-buffer 160 bytes) expects no parameter.\n", opt);
|
||||
break;
|
||||
}
|
||||
CDEBUG(call, call->ast, "Option 'r' (re-buffer 160 bytes)");
|
||||
call->rebuffer = 1;
|
||||
break;
|
||||
#if 0
|
||||
case 's':
|
||||
if (opt[1] != '\0') {
|
||||
|
|
|
@ -53,6 +53,8 @@ struct chan_call {
|
|||
/* shall dtmf be enabled */
|
||||
int no_dtmf;
|
||||
/* dtmf disabled by option */
|
||||
int rebuffer; /* send only 160 bytes frames
|
||||
to asterisk */
|
||||
char pipeline[256];
|
||||
/* echo cancel pipeline by option */
|
||||
int tx_gain, rx_gain;
|
||||
|
|
7
dss1.cpp
7
dss1.cpp
|
@ -1193,14 +1193,17 @@ void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_m
|
|||
|
||||
l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_IND, DIRECTION_IN);
|
||||
/* in case layer 2 is down during setup, we send cause 27 loc 5 */
|
||||
if (p_state == PORT_STATE_OUT_SETUP && !p_m_mISDNport->l1link)
|
||||
if (p_state == PORT_STATE_OUT_SETUP && p_m_mISDNport->l1link == 0)
|
||||
{
|
||||
cause = 27;
|
||||
location = 5;
|
||||
} else
|
||||
{
|
||||
dec_ie_cause(l3m, &location, &cause);
|
||||
add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
|
||||
if (p_m_mISDNport->l1link < 0)
|
||||
add_trace("layer 1", NULL, "unknown");
|
||||
else
|
||||
add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
|
||||
}
|
||||
end_trace();
|
||||
if (location == LOCATION_PRIVATE_LOCAL)
|
||||
|
|
|
@ -679,8 +679,11 @@ char *admin_state(int sock, char *argv[])
|
|||
color((m[i].u.i.l2link)?green:red);
|
||||
addstr((m[i].u.i.l2link)?" L2 UP":" L2 down");
|
||||
}
|
||||
color((m[i].u.i.l1link)?green:blue);
|
||||
addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive");
|
||||
color((m[i].u.i.l1link > 0)?green:blue);
|
||||
if (m[i].u.i.l1link < 0)
|
||||
addstr(" L1 unknown");
|
||||
else
|
||||
addstr((m[i].u.i.l1link)?" L1 ACTIVE":" L1 inactive");
|
||||
if (m[i].u.i.los)
|
||||
{
|
||||
color(red);
|
||||
|
|
|
@ -2215,6 +2215,7 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
|
|||
while(*mISDNportp)
|
||||
mISDNportp = &((*mISDNportp)->next);
|
||||
mISDNport = (struct mISDNport *)MALLOC(sizeof(struct mISDNport));
|
||||
mISDNport->l1link = -1;
|
||||
pmemuse++;
|
||||
*mISDNportp = mISDNport;
|
||||
|
||||
|
|
7
main.c
7
main.c
|
@ -226,13 +226,6 @@ int main(int argc, char *argv[])
|
|||
/* init crc */
|
||||
crc_init();
|
||||
|
||||
/* check for root (real or effective) */
|
||||
if (getuid() && geteuid())
|
||||
{
|
||||
fprintf(stderr, "Please run %s as super-user.\n", NAME);
|
||||
goto free;
|
||||
}
|
||||
|
||||
/* the mutex init */
|
||||
if (pthread_mutex_init(&mutexd, NULL))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue