[asterisk-commits] file: branch file/fds r57032 - in
/team/file/fds: channels/ include/asterisk/...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Feb 27 17:58:04 MST 2007
Author: file
Date: Tue Feb 27 18:58:03 2007
New Revision: 57032
URL: http://svn.digium.com/view/asterisk?view=rev&rev=57032
Log:
Introduce a new API call, ast_channel_set_fd, which is used to associate file descriptors to a channel.
Modified:
team/file/fds/channels/chan_agent.c
team/file/fds/channels/chan_alsa.c
team/file/fds/channels/chan_features.c
team/file/fds/channels/chan_gtalk.c
team/file/fds/channels/chan_h323.c
team/file/fds/channels/chan_jingle.c
team/file/fds/channels/chan_mgcp.c
team/file/fds/channels/chan_misdn.c
team/file/fds/channels/chan_nbs.c
team/file/fds/channels/chan_oss.c
team/file/fds/channels/chan_phone.c
team/file/fds/channels/chan_sip.c
team/file/fds/channels/chan_skinny.c
team/file/fds/channels/chan_zap.c
team/file/fds/include/asterisk/channel.h
team/file/fds/main/channel.c
Modified: team/file/fds/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_agent.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_agent.c (original)
+++ team/file/fds/channels/chan_agent.c Tue Feb 27 18:58:03 2007
@@ -220,9 +220,9 @@
if (p->chan) { \
for (x=0;x<AST_MAX_FDS;x++) {\
if (x != AST_TIMING_FD) \
- ast->fds[x] = p->chan->fds[x]; \
+ ast_channel_set_fd(ast, x, p->chan->fds[x]); \
} \
- ast->fds[AST_AGENT_FD] = p->chan->fds[AST_TIMING_FD]; \
+ ast_channel_set_fd(ast, AST_AGENT_FD, p->chan->fds[AST_TIMING_FD]); \
} \
} while(0)
Modified: team/file/fds/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_alsa.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_alsa.c (original)
+++ team/file/fds/channels/chan_alsa.c Tue Feb 27 18:58:03 2007
@@ -794,7 +794,7 @@
return NULL;
tmp->tech = &alsa_tech;
- tmp->fds[0] = readdev;
+ ast_channel_set_fd(tmp, 0, readdev);
tmp->nativeformats = AST_FORMAT_SLINEAR;
tmp->readformat = AST_FORMAT_SLINEAR;
tmp->writeformat = AST_FORMAT_SLINEAR;
Modified: team/file/fds/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_features.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_features.c (original)
+++ team/file/fds/channels/chan_features.c Tue Feb 27 18:58:03 2007
@@ -168,8 +168,8 @@
p->subs[index].owner->timingfd = p->subs[index].timingfdbackup;
p->subs[index].owner->alertpipe[0] = p->subs[index].alertpipebackup[0];
p->subs[index].owner->alertpipe[1] = p->subs[index].alertpipebackup[1];
- p->subs[index].owner->fds[AST_ALERT_FD] = p->subs[index].alertpipebackup[0];
- p->subs[index].owner->fds[AST_TIMING_FD] = p->subs[index].timingfdbackup;
+ ast_channel_set_fd(p->subs[index].owner, AST_ALERT_FD, p->subs[index].alertpipebackup[0]);
+ ast_channel_set_fd(p->subs[index].owner, AST_TIMING_FD, p->subs[index].timingfdbackup);
}
static void update_features(struct feature_pvt *p, int index)
@@ -178,9 +178,9 @@
if (p->subs[index].owner) {
for (x=0; x<AST_MAX_FDS; x++) {
if (index)
- p->subs[index].owner->fds[x] = -1;
+ ast_channel_set_fd(p->subs[index].owner, x, -1);
else
- p->subs[index].owner->fds[x] = p->subchan->fds[x];
+ ast_channel_set_fd(p->subs[index].owner, x, p->subchan->fds[x]);
}
if (!index) {
/* Copy timings from master channel */
Modified: team/file/fds/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_gtalk.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_gtalk.c (original)
+++ team/file/fds/channels/chan_gtalk.c Tue Feb 27 18:58:03 2007
@@ -922,13 +922,13 @@
if (i->rtp) {
ast_rtp_setstun(i->rtp, 1);
- tmp->fds[0] = ast_rtp_fd(i->rtp);
- tmp->fds[1] = ast_rtcp_fd(i->rtp);
+ ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
+ ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
}
if (i->vrtp) {
ast_rtp_setstun(i->rtp, 1);
- tmp->fds[2] = ast_rtp_fd(i->vrtp);
- tmp->fds[3] = ast_rtcp_fd(i->vrtp);
+ ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
+ ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
}
if (state == AST_STATE_RING)
tmp->rings = 1;
Modified: team/file/fds/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_h323.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_h323.c (original)
+++ team/file/fds/channels/chan_h323.c Tue Feb 27 18:58:03 2007
@@ -395,8 +395,8 @@
if (pvt->update_rtp_info > 0) {
if (pvt->rtp) {
ast_jb_configure(c, &global_jbconf);
- c->fds[0] = ast_rtp_fd(pvt->rtp);
- c->fds[1] = ast_rtcp_fd(pvt->rtp);
+ ast_channel_set_fd(c, 0, ast_rtp_fd(pvt->rtp));
+ ast_channel_set_fd(c, 1, ast_rtcp_fd(pvt->rtp));
ast_queue_frame(pvt->owner, &ast_null_frame); /* Tell Asterisk to apply changes */
}
pvt->update_rtp_info = -1;
@@ -995,8 +995,8 @@
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
ast_jb_configure(pvt->owner, &global_jbconf);
- pvt->owner->fds[0] = ast_rtp_fd(pvt->rtp);
- pvt->owner->fds[1] = ast_rtcp_fd(pvt->rtp);
+ ast_channel_set_fd(pvt->owner, 0, ast_rtp_fd(pvt->rtp));
+ ast_channel_set_fd(pvt->owner, 1, ast_rtcp_fd(pvt->rtp));
ast_queue_frame(pvt->owner, &ast_null_frame); /* Tell Asterisk to apply changes */
ast_channel_unlock(pvt->owner);
} else
@@ -1040,18 +1040,18 @@
ch->readformat = fmt;
ch->rawreadformat = fmt;
#if 0
- ch->fds[0] = ast_rtp_fd(pvt->rtp);
- ch->fds[1] = ast_rtcp_fd(pvt->rtp);
+ ast_channel_set_fd(ch, 0, ast_rtp_fd(pvt->rtp));
+ ast_channel_set_fd(ch, 1, ast_rtcp_fd(pvt->rtp));
#endif
#ifdef VIDEO_SUPPORT
if (pvt->vrtp) {
- ch->fds[2] = ast_rtp_fd(pvt->vrtp);
- ch->fds[3] = ast_rtcp_fd(pvt->vrtp);
+ ast_channel_set_fd(ch, 2, ast_rtp_fd(pvt->vrtp));
+ ast_channel_set_fd(ch, 3, ast_rtcp_fd(pvt->vrtp));
}
#endif
#ifdef T38_SUPPORT
if (pvt->udptl) {
- ch->fds[4] = ast_udptl_fd(pvt->udptl);
+ ast_channel_set_fd(ch, 4, ast_udptl_fd(pvt->udptl));
}
#endif
if (state == AST_STATE_RING) {
Modified: team/file/fds/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_jingle.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_jingle.c (original)
+++ team/file/fds/channels/chan_jingle.c Tue Feb 27 18:58:03 2007
@@ -781,12 +781,12 @@
fmt = ast_best_codec(tmp->nativeformats);
if (i->rtp) {
- tmp->fds[0] = ast_rtp_fd(i->rtp);
- tmp->fds[1] = ast_rtcp_fd(i->rtp);
+ ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
+ ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
}
if (i->vrtp) {
- tmp->fds[2] = ast_rtp_fd(i->vrtp);
- tmp->fds[3] = ast_rtcp_fd(i->vrtp);
+ ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
+ ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
}
if (state == AST_STATE_RING)
tmp->rings = 1;
Modified: team/file/fds/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_mgcp.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_mgcp.c (original)
+++ team/file/fds/channels/chan_mgcp.c Tue Feb 27 18:58:03 2007
@@ -1442,7 +1442,7 @@
fmt = ast_best_codec(tmp->nativeformats);
ast_string_field_build(tmp, name, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
if (sub->rtp)
- tmp->fds[0] = ast_rtp_fd(sub->rtp);
+ ast_channel_set_fd(tmp, 0, ast_rtp_fd(sub->rtp));
if (i->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)) {
i->dsp = ast_dsp_new();
ast_dsp_set_features(i->dsp,DSP_FEATURE_DTMF_DETECT);
@@ -2594,7 +2594,7 @@
/* Allocate the RTP now */
sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
if (sub->rtp && sub->owner)
- sub->owner->fds[0] = ast_rtp_fd(sub->rtp);
+ ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp));
if (sub->rtp)
ast_rtp_setnat(sub->rtp, sub->nat);
#if 0
Modified: team/file/fds/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_misdn.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_misdn.c (original)
+++ team/file/fds/channels/chan_misdn.c Tue Feb 27 18:58:03 2007
@@ -3173,7 +3173,7 @@
if (pipe(chlist->pipe)<0)
perror("Pipe failed\n");
- tmp->fds[0]=chlist->pipe[0];
+ ast_channel_set_fd(tmp, 0, chlist->pipe[0]);
}
Modified: team/file/fds/channels/chan_nbs.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_nbs.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_nbs.c (original)
+++ team/file/fds/channels/chan_nbs.c Tue Feb 27 18:58:03 2007
@@ -236,7 +236,7 @@
tmp = ast_channel_alloc(1, state, 0, 0, "NBS/%s", i->stream);
if (tmp) {
tmp->tech = &nbs_tech;
- tmp->fds[0] = nbs_fd(i->nbs);
+ ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
tmp->nativeformats = prefformat;
tmp->rawreadformat = prefformat;
tmp->rawwriteformat = prefformat;
Modified: team/file/fds/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_oss.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_oss.c (original)
+++ team/file/fds/channels/chan_oss.c Tue Feb 27 18:58:03 2007
@@ -692,7 +692,7 @@
return -1;
}
if (o->owner)
- o->owner->fds[0] = fd;
+ ast_channel_set_fd(o->owner, 0, fd);
#if __BYTE_ORDER == __LITTLE_ENDIAN
fmt = AFMT_S16_LE;
@@ -1027,7 +1027,7 @@
c->tech = &oss_tech;
if (o->sounddev < 0)
setformat(o, O_RDWR);
- c->fds[0] = o->sounddev; /* -1 if device closed, override later */
+ ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
c->nativeformats = AST_FORMAT_SLINEAR;
c->readformat = AST_FORMAT_SLINEAR;
c->writeformat = AST_FORMAT_SLINEAR;
Modified: team/file/fds/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_phone.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_phone.c (original)
+++ team/file/fds/channels/chan_phone.c Tue Feb 27 18:58:03 2007
@@ -868,7 +868,7 @@
tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "Phone/%s", i->dev + 5);
if (tmp) {
tmp->tech = cur_tech;
- tmp->fds[0] = i->fd;
+ ast_channel_set_fd(tmp, 0, i->fd);
/* XXX Switching formats silently causes kernel panics XXX */
if (i->mode == MODE_FXS &&
ioctl(i->fd, PHONE_QUERY_CODEC, &codec) == 0) {
Modified: team/file/fds/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_sip.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_sip.c (original)
+++ team/file/fds/channels/chan_sip.c Tue Feb 27 18:58:03 2007
@@ -4168,18 +4168,18 @@
ast_dsp_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
}
if (i->rtp) {
- tmp->fds[0] = ast_rtp_fd(i->rtp);
- tmp->fds[1] = ast_rtcp_fd(i->rtp);
+ ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
+ ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
}
if (needvideo && i->vrtp) {
- tmp->fds[2] = ast_rtp_fd(i->vrtp);
- tmp->fds[3] = ast_rtcp_fd(i->vrtp);
+ ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
+ ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
}
if (needtext && i->trtp) {
- tmp->fds[4] = ast_rtp_fd(i->trtp);
+ ast_channel_set_fd(tmp, 4, ast_rtp_fd(i->trtp));
}
if (i->udptl) {
- tmp->fds[5] = ast_udptl_fd(i->udptl);
+ ast_channel_set_fd(tmp, 5, ast_udptl_fd(i->udptl));
}
if (state == AST_STATE_RING)
tmp->rings = 1;
Modified: team/file/fds/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_skinny.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_skinny.c (original)
+++ team/file/fds/channels/chan_skinny.c Tue Feb 27 18:58:03 2007
@@ -2300,12 +2300,12 @@
sub->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
if (sub->rtp && sub->owner) {
- sub->owner->fds[0] = ast_rtp_fd(sub->rtp);
- sub->owner->fds[1] = ast_rtcp_fd(sub->rtp);
+ ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp));
+ ast_channel_set_fd(sub->owner, 1, ast_rtcp_fd(sub->rtp));
}
if (hasvideo && sub->vrtp && sub->owner) {
- sub->owner->fds[2] = ast_rtp_fd(sub->vrtp);
- sub->owner->fds[3] = ast_rtcp_fd(sub->vrtp);
+ ast_channel_set_fd(sub->owner, 2, ast_rtp_fd(sub->vrtp));
+ ast_channel_set_fd(sub->owner, 3, ast_rtcp_fd(sub->vrtp));
}
if (sub->rtp) {
ast_rtp_setnat(sub->rtp, l->nat);
@@ -2837,7 +2837,7 @@
if (skinnydebug)
ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
if (sub->rtp) {
- tmp->fds[0] = ast_rtp_fd(sub->rtp);
+ ast_channel_set_fd(tmp, 0, ast_rtp_fd(sub->rtp));
}
if (state == AST_STATE_RING) {
tmp->rings = 1;
Modified: team/file/fds/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/channels/chan_zap.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/channels/chan_zap.c (original)
+++ team/file/fds/channels/chan_zap.c Tue Feb 27 18:58:03 2007
@@ -971,9 +971,9 @@
p->subs[b].inthreeway = tinthreeway;
if (p->subs[a].owner)
- p->subs[a].owner->fds[0] = p->subs[a].zfd;
+ ast_channel_set_fd(p->subs[a].owner, 0, p->subs[a].zfd);
if (p->subs[b].owner)
- p->subs[b].owner->fds[0] = p->subs[b].zfd;
+ ast_channel_set_fd(p->subs[b].owner, 0, p->subs[b].zfd);
wakeup_sub(p, a, NULL);
wakeup_sub(p, b, NULL);
}
@@ -2516,7 +2516,7 @@
bearer->realcall = crv;
crv->subs[SUB_REAL].zfd = bearer->subs[SUB_REAL].zfd;
if (crv->subs[SUB_REAL].owner)
- crv->subs[SUB_REAL].owner->fds[0] = crv->subs[SUB_REAL].zfd;
+ ast_channel_set_fd(crv->subs[SUB_REAL].owner, 0, crv->subs[SUB_REAL].zfd);
crv->bearer = bearer;
crv->call = bearer->call;
crv->pri = pri;
@@ -5531,7 +5531,7 @@
else
deflaw = AST_FORMAT_ULAW;
}
- tmp->fds[0] = i->subs[index].zfd;
+ ast_channel_set_fd(tmp, 0, i->subs[index].zfd);
tmp->nativeformats = AST_FORMAT_SLINEAR | deflaw;
/* Start out assuming ulaw since it's smaller :) */
tmp->rawreadformat = deflaw;
@@ -8891,7 +8891,7 @@
"Zap/%d:%d-%d", pri->trunkgroup,
pri->pvts[principle]->channel, 1);
pri->pvts[principle]->owner->tech_pvt = pri->pvts[principle];
- pri->pvts[principle]->owner->fds[0] = pri->pvts[principle]->subs[SUB_REAL].zfd;
+ ast_channel_set_fd(pri->pvts[principle]->owner, 0, pri->pvts[principle]->subs[SUB_REAL].zfd);
pri->pvts[principle]->subs[SUB_REAL].owner = pri->pvts[x]->subs[SUB_REAL].owner;
} else
ast_log(LOG_WARNING, "Whoa, there's no owner, and we're having to fix up channel %d to channel %d\n", pri->pvts[x]->channel, pri->pvts[principle]->channel);
Modified: team/file/fds/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/file/fds/include/asterisk/channel.h?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/include/asterisk/channel.h (original)
+++ team/file/fds/include/asterisk/channel.h Tue Feb 27 18:58:03 2007
@@ -1174,6 +1174,9 @@
void ast_set_callerid(struct ast_channel *chan, const char *cidnum, const char *cidname, const char *ani);
+/*! Set the file descriptor on the channel */
+void ast_channel_set_fd(struct ast_channel *chan, int which, int fd);
+
/*! Start a tone going */
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);
/*! Stop a tone from playing */
Modified: team/file/fds/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/file/fds/main/channel.c?view=diff&rev=57032&r1=57031&r2=57032
==============================================================================
--- team/file/fds/main/channel.c (original)
+++ team/file/fds/main/channel.c Tue Feb 27 18:58:03 2007
@@ -1382,6 +1382,12 @@
AST_LIST_TRAVERSE_SAFE_END
spy_cleanup(chan);
+}
+
+/*! Set the file descriptor on the channel */
+void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
+{
+ chan->fds[which] = fd;
}
/*! \brief Softly hangup a channel, don't lock */
More information about the asterisk-commits
mailing list