[asterisk-commits] jdixon: branch jdixon/chan_usbradio-1.4 r138514 - /team/jdixon/chan_usbradio-...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Aug 17 18:35:06 CDT 2008
Author: jdixon
Date: Sun Aug 17 18:35:06 2008
New Revision: 138514
URL: http://svn.digium.com/view/asterisk?view=rev&rev=138514
Log:
Added first steps for raw digital audio
Modified:
team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c
Modified: team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c?view=diff&rev=138514&r1=138513&r2=138514
==============================================================================
--- team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c (original)
+++ team/jdixon/chan_usbradio-1.4/dev-1.0/apps/app_rpt.c Sun Aug 17 18:35:06 2008
@@ -22,7 +22,7 @@
/*! \file
*
* \brief Radio Repeater / Remote Base program
- * version 0.906 (1.0-dev4) 8/17/08
+ * version 0.907 (1.0-dev4) 8/17/08
*
* \author Jim Dixon, WB6NIL <jim at lambdatel.com>
*
@@ -376,7 +376,7 @@
/*! Stop the tones from playing */
void ast_playtones_stop(struct ast_channel *chan);
-static char *tdesc = "Radio Repeater / Remote Base version 0.906 8/17/2008";
+static char *tdesc = "Radio Repeater / Remote Base version 0.907 8/17/2008";
static char *app = "Rpt";
@@ -555,6 +555,13 @@
struct rpt;
+struct rpt_linkrx
+{
+ struct ast_frame *flin;
+ struct ast_frame *fraw;
+ AST_LIST_ENTRY(rpt_linkrx) linkrx_list;
+};
+
struct rpt_link
{
struct rpt_link *next;
@@ -601,15 +608,17 @@
int voxtotimer;
char voxtostate;
char newkey;
-#ifdef OLD_ASTERISK
- AST_LIST_HEAD(, ast_frame) linq;
-#else
- AST_LIST_HEAD_NOLOCK(, ast_frame) linq;
-#endif
+ struct ast_trans_pvt *read_path;
+ struct ast_trans_pvt *write_path;
#ifdef OLD_ASTERISK
AST_LIST_HEAD(, ast_frame) rxq;
#else
AST_LIST_HEAD_NOLOCK(, ast_frame) rxq;
+#endif
+#ifdef OLD_ASTERISK
+ AST_LIST_HEAD(, rpt_linkrx) linq;
+#else
+ AST_LIST_HEAD_NOLOCK(, rpt_linkrx) linq;
#endif
} ;
@@ -1246,6 +1255,7 @@
struct timeval now;
struct rpt_link *l,*m;
struct ast_frame *f1;
+ struct rpt_linkrx *lf;
struct rpt_rxtelem *rxtelem;
for(n = 0; n < nrpts; n++)
@@ -1292,20 +1302,24 @@
if (l->lastrx)
{
x = 0;
- AST_LIST_TRAVERSE(&l->linq, f1,frame_list) x++;
+ AST_LIST_TRAVERSE(&l->linq, lf,linkrx_list) x++;
if (x > 1)
{
- f1 = AST_LIST_REMOVE_HEAD(&l->linq,frame_list);
- rpt_mixer_put(&rpt_vars[n].conf,f1->data,&l->conf_sample);
- ast_frfree(f1);
+ lf = AST_LIST_REMOVE_HEAD(&l->linq,linkrx_list);
+ rpt_mixer_put(&rpt_vars[n].conf,lf->flin->data,&l->conf_sample);
+ ast_frfree(lf->flin);
+ ast_frfree(lf->fraw);
+ free(lf);
}
}
else
{
while(!AST_LIST_EMPTY(&l->linq))
{
- f1 = AST_LIST_REMOVE_HEAD(&l->linq,frame_list);
- ast_frfree(f1);
+ lf = AST_LIST_REMOVE_HEAD(&l->linq,linkrx_list);
+ ast_frfree(lf->flin);
+ ast_frfree(lf->fraw);
+ free(lf);
}
}
}
@@ -1471,7 +1485,9 @@
if (!l->ready) continue;
rpt_mixer_get(&rpt_vars[n].conf,fr.data,
&l->conf_sample);
- ast_write(l->chan,&fr);
+ f1 = ast_translate(l->write_path,&fr,0);
+ ast_write(l->chan,f1);
+ ast_frfree(f1);
}
#ifdef APP_RPT_LOCK_DEBUG
_rpt_mutex_unlock(&rpt_vars[n].lock,&rpt_vars[n],__LINE__);
@@ -6123,8 +6139,6 @@
*tele++ = 0;
l->chan = ast_request(deststr, AST_FORMAT_SLINEAR, tele,NULL);
if (l->chan){
- ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
- ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (l->chan->cdr)
ast_set_flag(l->chan->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -6156,6 +6170,24 @@
return -1;
}
usleep(5000);
+ ast_set_read_format(l->chan,l->chan->rawreadformat);
+ ast_set_write_format(l->chan,l->chan->rawwriteformat);
+ l->read_path = ast_translator_build_path(AST_FORMAT_SLINEAR,
+ l->chan->rawwriteformat);
+ if (!l->read_path)
+ {
+ ast_log(LOG_NOTICE,"Unable to build path for link channel %s node %s\n",
+ l->chan->name,myrpt->name);
+ return -1;
+ }
+ l->write_path = ast_translator_build_path(l->chan->rawwriteformat,
+ AST_FORMAT_SLINEAR);
+ if (!l->write_path)
+ {
+ ast_log(LOG_NOTICE,"Unable to build path for link channel %s node %s\n",
+ l->chan->name,myrpt->name);
+ return -1;
+ }
rpt_mutex_lock(&myrpt->lock);
l->reconnects = reconnects;
/* insert at end of queue */
@@ -10775,8 +10807,6 @@
AST_LIST_HEAD_INIT_NOLOCK(&l->linq);
AST_LIST_HEAD_INIT_NOLOCK(&l->rxq);
if (l->chan){
- ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
- ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
#ifndef NEW_ASTERISK
l->chan->whentohangup = 0;
#endif
@@ -10799,6 +10829,24 @@
return -1;
}
usleep(5000);
+ ast_set_read_format(l->chan,l->chan->rawreadformat);
+ ast_set_write_format(l->chan,l->chan->rawreadformat);
+ l->read_path = ast_translator_build_path(AST_FORMAT_SLINEAR,
+ l->chan->rawreadformat);
+ if (!l->read_path)
+ {
+ ast_log(LOG_NOTICE,"Unable to build path for link channel %s node %s\n",
+ l->chan->name,myrpt->name);
+ return -1;
+ }
+ l->write_path = ast_translator_build_path(l->chan->rawreadformat,
+ AST_FORMAT_SLINEAR);
+ if (!l->write_path)
+ {
+ ast_log(LOG_NOTICE,"Unable to build path for link channel %s node %s\n",
+ l->chan->name,myrpt->name);
+ return -1;
+ }
rpt_mutex_lock(&myrpt->lock);
/* put back in queue */
insque((struct qelem *)l,(struct qelem *)myrpt->links.next);
@@ -11379,6 +11427,7 @@
while (ms >= 0)
{
struct ast_frame *f,*f1,*f2;
+ struct rpt_linkrx *lf;
struct ast_channel *cs[300],*cs1[300];
int totx=0,elap=0,n,x,toexit=0;
@@ -12505,6 +12554,10 @@
rpt_mutex_lock(&myrpt->lock);
__kickshort(myrpt);
rpt_mutex_unlock(&myrpt->lock);
+ if (l->read_path)
+ ast_translator_free_path(l->read_path);
+ if (l->write_path)
+ ast_translator_free_path(l->write_path);
if ((!l->disced) && (!l->outbound))
{
if ((l->name[0] == '0') || l->isremote)
@@ -12643,18 +12696,41 @@
if (f1)
{
rpt_mutex_lock(&myrpt->lock);
- AST_LIST_INSERT_TAIL(&l->linq,f1,frame_list);
+ lf = malloc(sizeof(struct rpt_linkrx));
+ if (!lf)
+ {
+ ast_log(LOG_NOTICE,"Cannot malloc\n");
+ break;
+ }
+ memset(lf,0,sizeof(struct rpt_linkrx));
+ lf->flin = ast_frdup(f1);
+ lf->fraw = f1;
+ AST_LIST_INSERT_TAIL(&l->linq,lf,linkrx_list);
rpt_mutex_unlock(&myrpt->lock);
}
}
else
{
- if (!l->lastrx)
- memset(f->data,0,f->datalen);
- rpt_mutex_lock(&myrpt->lock);
- f1 = ast_frdup(f);
- AST_LIST_INSERT_TAIL(&l->linq,f1,frame_list);
- rpt_mutex_unlock(&myrpt->lock);
+ if (f->datalen)
+ {
+ if (!l->lastrx)
+ memset(f->data,0,f->datalen);
+ rpt_mutex_lock(&myrpt->lock);
+ lf = malloc(sizeof(struct rpt_linkrx));
+ if (!lf)
+ {
+ ast_log(LOG_NOTICE,"Cannot malloc\n");
+ break;
+ }
+ memset(lf,0,sizeof(struct rpt_linkrx));
+ lf->fraw = ast_frdup(f);
+ f1 = ast_frdup(f);
+ f2 = ast_translate(l->read_path,f1,1);
+ lf->flin = ast_frdup(f2);
+ ast_frfree(f2);
+ AST_LIST_INSERT_TAIL(&l->linq,lf,linkrx_list);
+ rpt_mutex_unlock(&myrpt->lock);
+ }
}
}
#ifndef OLD_ASTERISK
@@ -12752,6 +12828,10 @@
{
ast_frfree(f);
__kickshort(myrpt);
+ if (l->read_path)
+ ast_translator_free_path(l->read_path);
+ if (l->write_path)
+ ast_translator_free_path(l->write_path);
if ((!l->outbound) && (!l->disced))
{
if ((l->name[0] == '0') || l->isremote)
@@ -13601,6 +13681,10 @@
ast_log(LOG_WARNING, "Trying to link to self!!\n");
return -1;
}
+ if (chan->_state != AST_STATE_UP) {
+ ast_answer(chan);
+ if (!phone_mode) send_newkey(chan);
+ }
rpt_mutex_lock(&myrpt->lock);
l = myrpt->links.next;
/* try to find this one in queue */
@@ -13652,19 +13736,32 @@
voxinit_link(l,1);
AST_LIST_HEAD_INIT_NOLOCK(&l->linq);
AST_LIST_HEAD_INIT_NOLOCK(&l->rxq);
- ast_set_read_format(l->chan,AST_FORMAT_SLINEAR);
- ast_set_write_format(l->chan,AST_FORMAT_SLINEAR);
rpt_mutex_lock(&myrpt->lock);
+
+ ast_set_read_format(l->chan,l->chan->readformat);
+ ast_set_write_format(l->chan,l->chan->writeformat);
+ l->read_path = ast_translator_build_path(AST_FORMAT_SLINEAR,
+ l->chan->readformat);
+ if (!l->read_path)
+ {
+ ast_log(LOG_NOTICE,"Unable to build path for link channel %s node %s\n",
+ l->chan->name,myrpt->name);
+ return -1;
+ }
+ l->write_path = ast_translator_build_path(l->chan->writeformat,
+ AST_FORMAT_SLINEAR);
+ if (!l->write_path)
+ {
+ ast_log(LOG_NOTICE,"Unable to build path for link channel %s node %s\n",
+ l->chan->name,myrpt->name);
+ return -1;
+ }
if ((phone_mode == 2) && (!phone_vox)) l->lastrealrx = 1;
l->max_retries = MAX_RETRIES;
/* insert at end of queue */
insque((struct qelem *)l,(struct qelem *)myrpt->links.next);
__kickshort(myrpt);
rpt_mutex_unlock(&myrpt->lock);
- if (chan->_state != AST_STATE_UP) {
- ast_answer(chan);
- if (!phone_mode) send_newkey(chan);
- }
if (myrpt->p.archivedir)
{
char str[100];
@@ -13779,8 +13876,6 @@
myrpt->rxchannel = ast_request(myrpt->rxchanname,AST_FORMAT_SLINEAR,tele,NULL);
if (myrpt->rxchannel)
{
- ast_set_read_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->rxchannel->cdr)
ast_set_flag(myrpt->rxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
@@ -13818,8 +13913,6 @@
myrpt->txchannel = ast_request(myrpt->txchanname,AST_FORMAT_SLINEAR,tele,NULL);
if (myrpt->txchannel)
{
- ast_set_read_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
- ast_set_write_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
#ifdef AST_CDR_FLAG_POST_DISABLED
if (myrpt->txchannel->cdr)
ast_set_flag(myrpt->txchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
More information about the asterisk-commits
mailing list