[asterisk-commits] root: branch file/bridging r81605 - in /team/file/bridging: ./ apps/ include/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 5 16:28:56 CDT 2007
Author: root
Date: Wed Sep 5 16:28:55 2007
New Revision: 81605
URL: http://svn.digium.com/view/asterisk?view=rev&rev=81605
Log:
automerge commit
Modified:
team/file/bridging/ (props changed)
team/file/bridging/apps/app_zapateller.c
team/file/bridging/include/asterisk/channel.h
team/file/bridging/include/asterisk/file.h
team/file/bridging/main/file.c
team/file/bridging/main/say.c
team/file/bridging/res/res_features.c
Propchange: team/file/bridging/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/file/bridging/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Sep 5 16:28:55 2007
@@ -1,1 +1,1 @@
-/trunk:1-81572
+/trunk:1-81604
Modified: team/file/bridging/apps/app_zapateller.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/apps/app_zapateller.c?view=diff&rev=81605&r1=81604&r2=81605
==============================================================================
--- team/file/bridging/apps/app_zapateller.c (original)
+++ team/file/bridging/apps/app_zapateller.c Wed Sep 5 16:28:55 2007
@@ -50,10 +50,14 @@
" Zapateller(options): Generates special information tone to block\n"
"telemarketers from calling you. Options is a pipe-delimited list of\n"
"options. The following options are available:\n"
-"'answer' causes the line to be answered before playing the tone,\n"
-"'nocallerid' causes Zapateller to only play the tone if there\n"
-"is no callerid information available. Options should be separated by |\n"
-"characters\n";
+" 'answer' - causes the line to be answered before playing the tone,\n"
+" 'nocallerid' - causes Zapateller to only play the tone if there is no\n"
+" callerid information available. Options should be\n"
+" separated by | characters\n\n"
+" This application will set the following channel variable upon completion:\n"
+" ZAPATELLERSTATUS - This will contain the last action accomplished by the\n"
+" Zapateller application. Possible values include:\n"
+" NOTHING | ANSWERED | ZAPPED\n\n";
static int zapateller_exec(struct ast_channel *chan, void *data)
@@ -74,10 +78,13 @@
nocallerid = 1;
}
+ pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING");
ast_stopstream(chan);
if (chan->_state != AST_STATE_UP) {
- if (answer)
+ if (answer) {
res = ast_answer(chan);
+ pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED");
+ }
if (!res)
res = ast_safe_sleep(chan, 500);
}
@@ -93,7 +100,8 @@
res = ast_tonepair(chan, 1800, 0, 330, 0);
if (!res)
res = ast_tonepair(chan, 0, 0, 1000, 0);
-
+
+ pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ZAPPED");
return res;
}
Modified: team/file/bridging/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/channel.h?view=diff&rev=81605&r1=81604&r2=81605
==============================================================================
--- team/file/bridging/include/asterisk/channel.h (original)
+++ team/file/bridging/include/asterisk/channel.h Wed Sep 5 16:28:55 2007
@@ -546,6 +546,9 @@
/*! Flag to show channels that this call is hangup due to the fact that the call
was indeed anwered, but in another channel */
AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15),
+ /*! This flag indicates that on a masquerade, an active stream should not
+ * be carried over */
+ AST_FLAG_MASQ_NOSTREAM = (1 << 16),
};
/*! \brief ast_bridge_config flags */
Modified: team/file/bridging/include/asterisk/file.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/file.h?view=diff&rev=81605&r1=81604&r2=81605
==============================================================================
--- team/file/bridging/include/asterisk/file.h (original)
+++ team/file/bridging/include/asterisk/file.h Wed Sep 5 16:28:55 2007
@@ -133,6 +133,7 @@
int lastwriteformat;
int lasttimeout;
struct ast_channel *owner;
+ const char *orig_chan_name;
FILE *f;
struct ast_frame fr; /*!< frame produced by read, typically */
char *buf; /*!< buffer pointed to by ast_frame; */
Modified: team/file/bridging/main/file.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/file.c?view=diff&rev=81605&r1=81604&r2=81605
==============================================================================
--- team/file/bridging/main/file.c (original)
+++ team/file/bridging/main/file.c Wed Sep 5 16:28:55 2007
@@ -603,39 +603,68 @@
return f;
}
-static int ast_readaudio_callback(void *data)
-{
- struct ast_filestream *s = data;
+enum fsread_res {
+ FSREAD_FAILURE,
+ FSREAD_SUCCESS_SCHED,
+ FSREAD_SUCCESS_NOSCHED,
+};
+
+static int ast_fsread_audio(void *data);
+
+static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
+{
int whennext = 0;
while (!whennext) {
- struct ast_frame *fr = s->fmt->read(s, &whennext);
+ struct ast_frame *fr;
+
+ if (s->orig_chan_name && strcasecmp(s->owner->name, s->orig_chan_name))
+ goto return_failure;
+
+ fr = s->fmt->read(s, &whennext);
if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
if (fr)
ast_log(LOG_WARNING, "Failed to write frame\n");
- s->owner->streamid = -1;
-#ifdef HAVE_ZAPTEL
- ast_settimeout(s->owner, 0, NULL, NULL);
-#endif
- return 0;
+ goto return_failure;
}
}
if (whennext != s->lasttimeout) {
#ifdef HAVE_ZAPTEL
if (s->owner->timingfd > -1)
- ast_settimeout(s->owner, whennext, ast_readaudio_callback, s);
+ ast_settimeout(s->owner, whennext, ast_fsread_audio, s);
else
#endif
- s->owner->streamid = ast_sched_add(s->owner->sched, whennext/8, ast_readaudio_callback, s);
+ s->owner->streamid = ast_sched_add(s->owner->sched, whennext/8, ast_fsread_audio, s);
s->lasttimeout = whennext;
- return 0;
- }
- return 1;
-}
-
-static int ast_readvideo_callback(void *data)
-{
- struct ast_filestream *s = data;
+ return FSREAD_SUCCESS_NOSCHED;
+ }
+ return FSREAD_SUCCESS_SCHED;
+
+return_failure:
+ s->owner->streamid = -1;
+#ifdef HAVE_ZAPTEL
+ ast_settimeout(s->owner, 0, NULL, NULL);
+#endif
+ return FSREAD_FAILURE;
+}
+
+static int ast_fsread_audio(void *data)
+{
+ struct ast_filestream *fs = data;
+ enum fsread_res res;
+
+ res = ast_readaudio_callback(fs);
+
+ if (res == FSREAD_SUCCESS_SCHED)
+ return 1;
+
+ return 0;
+}
+
+static int ast_fsread_video(void *data);
+
+static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
+{
int whennext = 0;
while (!whennext) {
@@ -644,15 +673,31 @@
if (fr)
ast_log(LOG_WARNING, "Failed to write frame\n");
s->owner->vstreamid = -1;
- return 0;
- }
- }
+ return FSREAD_FAILURE;
+ }
+ }
+
if (whennext != s->lasttimeout) {
- s->owner->vstreamid = ast_sched_add(s->owner->sched, whennext/8, ast_readvideo_callback, s);
+ s->owner->vstreamid = ast_sched_add(s->owner->sched, whennext / 8,
+ ast_fsread_video, s);
s->lasttimeout = whennext;
- return 0;
- }
- return 1;
+ return FSREAD_SUCCESS_NOSCHED;
+ }
+
+ return FSREAD_SUCCESS_SCHED;
+}
+
+static int ast_fsread_video(void *data)
+{
+ struct ast_filestream *fs = data;
+ enum fsread_res res;
+
+ res = ast_readvideo_callback(fs);
+
+ if (res == FSREAD_SUCCESS_SCHED)
+ return 1;
+
+ return 0;
}
int ast_applystream(struct ast_channel *chan, struct ast_filestream *s)
@@ -663,11 +708,14 @@
int ast_playstream(struct ast_filestream *s)
{
+ enum fsread_res res;
+
if (s->fmt->format < AST_FORMAT_MAX_AUDIO)
- ast_readaudio_callback(s);
+ res = ast_readaudio_callback(s);
else
- ast_readvideo_callback(s);
- return 0;
+ res = ast_readvideo_callback(s);
+
+ return (res == FSREAD_FAILURE) ? -1 : 0;
}
int ast_seekstream(struct ast_filestream *fs, off_t sample_offset, int whence)
@@ -737,6 +785,8 @@
fclose(f->f);
if (f->vfs)
ast_closestream(f->vfs);
+ if (f->orig_chan_name)
+ free((void *) f->orig_chan_name);
ast_module_unref(f->fmt->module);
ast_free(f);
return 0;
@@ -788,16 +838,19 @@
ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
}
if (fs){
+ int res;
+ if (ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM))
+ fs->orig_chan_name = ast_strdup(chan->name);
if (ast_applystream(chan, fs))
return -1;
if (vfs && ast_applystream(chan, vfs))
return -1;
- ast_playstream(fs);
- if (vfs)
- ast_playstream(vfs);
+ res = ast_playstream(fs);
+ if (!res && vfs)
+ res = ast_playstream(vfs);
ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", chan->name, filename, ast_getformatname(chan->writeformat), preflang ? preflang : "default");
- return 0;
+ return res;
}
ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), chan->nativeformats), strerror(errno));
return -1;
@@ -980,6 +1033,9 @@
const char *forward, const char *rewind, int skip_ms,
int audiofd, int cmdfd, const char *context)
{
+ const char *orig_chan_name = NULL;
+ int err = 0;
+
if (!breakon)
breakon = "";
if (!forward)
@@ -989,10 +1045,22 @@
/* Switch the channel to end DTMF frame only. waitstream_core doesn't care about the start of DTMF. */
ast_set_flag(c, AST_FLAG_END_DTMF_ONLY);
-
+
+ if (ast_test_flag(c, AST_FLAG_MASQ_NOSTREAM))
+ orig_chan_name = ast_strdupa(c->name);
+
while (c->stream) {
int res;
- int ms = ast_sched_wait(c->sched);
+ int ms;
+
+ if (orig_chan_name && strcasecmp(orig_chan_name, c->name)) {
+ ast_stopstream(c);
+ err = 1;
+ break;
+ }
+
+ ms = ast_sched_wait(c->sched);
+
if (ms < 0 && !c->timingfunc) {
ast_stopstream(c);
break;
@@ -1087,7 +1155,7 @@
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
- return (c->_softhangup ? -1 : 0);
+ return (err || c->_softhangup) ? -1 : 0;
}
int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms)
Modified: team/file/bridging/main/say.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/say.c?view=diff&rev=81605&r1=81604&r2=81605
==============================================================================
--- team/file/bridging/main/say.c (original)
+++ team/file/bridging/main/say.c Wed Sep 5 16:28:55 2007
@@ -260,9 +260,9 @@
res = ast_streamfile(chan, fn, lang);
if (!res) {
if ((audiofd > -1) && (ctrlfd > -1))
- res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
- else
- res = ast_waitstream(chan, ints);
+ res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
+ else
+ res = ast_waitstream(chan, ints);
}
ast_stopstream(chan);
}
Modified: team/file/bridging/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/res/res_features.c?view=diff&rev=81605&r1=81604&r2=81605
==============================================================================
--- team/file/bridging/res/res_features.c (original)
+++ team/file/bridging/res/res_features.c Wed Sep 5 16:28:55 2007
@@ -491,8 +491,12 @@
if (!con) /* Still no context? Bad */
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
/* Tell the peer channel the number of the parking space */
- if (peer && pu->parkingnum != -1) /* Only say number if it's a number */
+ if (peer && pu->parkingnum != -1) { /* Only say number if it's a number */
+ /* Make sure we don't start saying digits to the channel being parked */
+ ast_set_flag(peer, AST_FLAG_MASQ_NOSTREAM);
ast_say_digits(peer, pu->parkingnum, "", peer->language);
+ ast_clear_flag(peer, AST_FLAG_MASQ_NOSTREAM);
+ }
if (con) {
if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free, registrar))
notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_INUSE);
More information about the asterisk-commits
mailing list