/ working on pstn->sip half duplex bug
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3021 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
61ce929656
commit
2bc871a62e
|
@ -188,34 +188,34 @@ static struct vpb_pvt {
|
||||||
|
|
||||||
int group; /* Which group this port belongs to */
|
int group; /* Which group this port belongs to */
|
||||||
|
|
||||||
char dev[256];
|
char dev[256]; /* Device name, eg vpb/1-1 */
|
||||||
vpb_model_t vpb_model;
|
vpb_model_t vpb_model; /* card model */
|
||||||
|
|
||||||
struct ast_frame f, fr;
|
struct ast_frame f, fr; /* Asterisk frame interface */
|
||||||
char buf[VPB_MAX_BUF]; /* Static buffer for reading frames */
|
char buf[VPB_MAX_BUF]; /* Static buffer for reading frames */
|
||||||
|
|
||||||
int dialtone;
|
int dialtone; /* NOT USED */
|
||||||
float txgain, rxgain; /* Hardware gain control */
|
float txgain, rxgain; /* Hardware gain control */
|
||||||
float txswgain, rxswgain; /* Software gain control */
|
float txswgain, rxswgain; /* Software gain control */
|
||||||
|
|
||||||
int wantdtmf; /* Waiting for DTMF. */
|
int wantdtmf; /* Waiting for DTMF. */
|
||||||
char context[AST_MAX_EXTENSION];
|
char context[AST_MAX_EXTENSION]; /* The context for this channel */
|
||||||
|
|
||||||
char ext[AST_MAX_EXTENSION];
|
char ext[AST_MAX_EXTENSION]; /* DTMF buffer for the ext[ens] */
|
||||||
char language[MAX_LANGUAGE];
|
char language[MAX_LANGUAGE]; /* language being used */
|
||||||
char callerid[AST_MAX_EXTENSION]; /* CallerId used for directly connected phone */
|
char callerid[AST_MAX_EXTENSION]; /* CallerId used for directly connected phone */
|
||||||
|
|
||||||
int lastoutput;
|
int lastoutput; /* Holds the last Audio format output'ed */
|
||||||
int lastinput;
|
int lastinput; /* Holds the last Audio format input'ed */
|
||||||
int last_ignore_dtmf;
|
int last_ignore_dtmf;
|
||||||
|
|
||||||
void *busy_timer;
|
void *busy_timer; /* Void pointer for busy vpb_timer */
|
||||||
int busy_timer_id;
|
int busy_timer_id; /* unique timer ID for busy timer */
|
||||||
|
|
||||||
void *ringback_timer;
|
void *ringback_timer; /* Void pointer for ringback vpb_timer */
|
||||||
int ringback_timer_id;
|
int ringback_timer_id; /* unique timer ID for ringback timer */
|
||||||
|
|
||||||
double lastgrunt;
|
double lastgrunt; /* time stamp (secs since epoc) of last grunt event */
|
||||||
|
|
||||||
ast_mutex_t lock; /* This one just protects bridge ptr below */
|
ast_mutex_t lock; /* This one just protects bridge ptr below */
|
||||||
vpb_bridge_t *bridge;
|
vpb_bridge_t *bridge;
|
||||||
|
@ -1128,7 +1128,6 @@ static int vpb_digit(struct ast_channel *ast, char digit)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int vpb_call(struct ast_channel *ast, char *dest, int timeout)
|
static int vpb_call(struct ast_channel *ast, char *dest, int timeout)
|
||||||
{
|
{
|
||||||
struct vpb_pvt *p = (struct vpb_pvt *)ast->pvt->pvt;
|
struct vpb_pvt *p = (struct vpb_pvt *)ast->pvt->pvt;
|
||||||
|
@ -1230,14 +1229,19 @@ static int vpb_hangup(struct ast_channel *ast)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(option_verbose>3)
|
||||||
|
ast_verbose( VERBOSE_PREFIX_4 "%s: Setting state down\n",ast->name);
|
||||||
ast_setstate(ast,AST_STATE_DOWN);
|
ast_setstate(ast,AST_STATE_DOWN);
|
||||||
|
|
||||||
p = (struct vpb_pvt *)ast->pvt->pvt;
|
p = (struct vpb_pvt *)ast->pvt->pvt;
|
||||||
|
|
||||||
/* Stop record */
|
/* Stop record */
|
||||||
p->stopreads = 1;
|
p->stopreads = 1;
|
||||||
if( p->readthread )
|
if( p->readthread ){
|
||||||
pthread_join(p->readthread, NULL);
|
pthread_join(p->readthread, NULL);
|
||||||
|
if(option_verbose>3)
|
||||||
|
ast_verbose( VERBOSE_PREFIX_4 "%s: stopped record thread on %s\n",ast->name,p->dev);
|
||||||
|
}
|
||||||
|
|
||||||
/* Stop play */
|
/* Stop play */
|
||||||
if (p->lastoutput != -1) {
|
if (p->lastoutput != -1) {
|
||||||
|
@ -1306,6 +1310,7 @@ static int vpb_answer(struct ast_channel *ast)
|
||||||
VPB_EVENT je;
|
VPB_EVENT je;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (ast->_state != AST_STATE_UP) {
|
||||||
if (p->mode == MODE_FXO){
|
if (p->mode == MODE_FXO){
|
||||||
vpb_sethook_sync(p->handle, VPB_OFFHOOK);
|
vpb_sethook_sync(p->handle, VPB_OFFHOOK);
|
||||||
p->state=VPB_STATE_OFFHOOK;
|
p->state=VPB_STATE_OFFHOOK;
|
||||||
|
@ -1318,12 +1323,24 @@ static int vpb_answer(struct ast_channel *ast)
|
||||||
vpb_put_event(&je);
|
vpb_put_event(&je);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ast_setstate(ast, AST_STATE_UP);
|
||||||
|
|
||||||
if(option_verbose>1)
|
if(option_verbose>1)
|
||||||
ast_verbose( VERBOSE_PREFIX_2 "Answered call from %s on %s [%s]\n", p->owner->callerid, ast->name,(p->mode == MODE_FXO)?"FXO":"FXS");
|
ast_verbose( VERBOSE_PREFIX_2 "Answered call from %s on %s [%s]\n",
|
||||||
|
p->owner->callerid, ast->name,(p->mode == MODE_FXO)?"FXO":"FXS");
|
||||||
|
|
||||||
ast->rings = 0;
|
ast->rings = 0;
|
||||||
|
if( !p->readthread ){
|
||||||
pthread_create(&p->readthread, NULL, do_chanreads, (void *)p);
|
pthread_create(&p->readthread, NULL, do_chanreads, (void *)p);
|
||||||
|
} else {
|
||||||
|
if(option_verbose>3)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_4 "Record thread already running!!\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(option_verbose>3) {
|
||||||
|
ast_verbose(VERBOSE_PREFIX_4 "Answered state is up\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1369,7 +1386,8 @@ static inline int astformatbits(int ast_format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gain_vector(float g, short *v, int n) {
|
int gain_vector(float g, short *v, int n)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
float tmp;
|
float tmp;
|
||||||
for ( i = 0; i<n; i++) {
|
for ( i = 0; i<n; i++) {
|
||||||
|
@ -1395,6 +1413,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
|
||||||
} else if (ast->_state != AST_STATE_UP) {
|
} else if (ast->_state != AST_STATE_UP) {
|
||||||
if(option_verbose>3)
|
if(option_verbose>3)
|
||||||
ast_verbose( VERBOSE_PREFIX_4 "%s: Writing frame type [%d,%d] on chan %s not up\n",ast->name, frame->frametype, frame->subclass, ast->name);
|
ast_verbose( VERBOSE_PREFIX_4 "%s: Writing frame type [%d,%d] on chan %s not up\n",ast->name, frame->frametype, frame->subclass, ast->name);
|
||||||
|
p->lastoutput = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1592,6 +1611,7 @@ static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context)
|
||||||
if (state == AST_STATE_RING)
|
if (state == AST_STATE_RING)
|
||||||
tmp->rings = 1;
|
tmp->rings = 1;
|
||||||
tmp->pvt->pvt = i;
|
tmp->pvt->pvt = i;
|
||||||
|
/* set Call backs */
|
||||||
tmp->pvt->send_digit = vpb_digit;
|
tmp->pvt->send_digit = vpb_digit;
|
||||||
tmp->pvt->call = vpb_call;
|
tmp->pvt->call = vpb_call;
|
||||||
tmp->pvt->hangup = vpb_hangup;
|
tmp->pvt->hangup = vpb_hangup;
|
||||||
|
|
Loading…
Reference in New Issue