summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-12-13 06:00:17 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-12-13 06:00:17 +0000
commitb7b2317d81f1f59fbc9bdb8257b2808d4eda17a3 (patch)
tree63d30fa6775847935ef9a59966b61fabb8b6d3f7
parentd37857c208ae7c9c8a4d882e4cde5577a873883f (diff)
Merged revisions 7448-7449,7451,7453 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r7448 | kpfleming | 2005-12-12 22:25:14 -0600 (Mon, 12 Dec 2005) | 2 lines use the stream's current point when pausing/unpausing, instead of elapsed time (which doesn't work when the stream has been skipped forward or backward) (issue #5897) ........ r7449 | kpfleming | 2005-12-12 22:43:38 -0600 (Mon, 12 Dec 2005) | 2 lines only report AGENT_IDLE for callback mode agents when they are actually idle (issue #5902) ........ r7451 | kpfleming | 2005-12-12 23:14:27 -0600 (Mon, 12 Dec 2005) | 2 lines ensure that hangups while incoming calls are in early state are handled properly (issue #5919) ........ r7453 | kpfleming | 2005-12-12 23:53:00 -0600 (Mon, 12 Dec 2005) | 2 lines restore ability of caller to hangup calls that are still ringing (issue #5839) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7457 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--app.c52
-rw-r--r--apps/app_dial.c2
-rw-r--r--channels/chan_agent.c2
-rw-r--r--channels/chan_sip.c3
-rw-r--r--pbx.c2
5 files changed, 26 insertions, 35 deletions
diff --git a/app.c b/app.c
index cd3c23fcb..30dcc3b8b 100644
--- a/app.c
+++ b/app.c
@@ -430,11 +430,11 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
const char *stop, const char *pause,
const char *restart, int skipms)
{
- long elapsed = 0, last_elapsed = 0;
char *breaks = NULL;
char *end = NULL;
int blen = 2;
int res;
+ long pause_restart_point = 0;
if (stop)
blen += strlen(stop);
@@ -456,9 +456,6 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
- if (chan)
- ast_stopstream(chan);
-
if (file) {
if ((end = strchr(file,':'))) {
if (!strcasecmp(end, ":end")) {
@@ -469,25 +466,18 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
}
for (;;) {
- struct timeval started = ast_tvnow();
-
- if (chan)
- ast_stopstream(chan);
+ ast_stopstream(chan);
res = ast_streamfile(chan, file, chan->language);
if (!res) {
- if (end) {
- ast_seekstream(chan->stream, 0, SEEK_END);
- end=NULL;
- }
- res = 1;
- if (elapsed) {
- ast_stream_fastforward(chan->stream, elapsed);
- last_elapsed = elapsed - 200;
+ if (pause_restart_point) {
+ ast_seekstream(chan->stream, pause_restart_point, SEEK_SET);
+ pause_restart_point = 0;
}
- if (res)
- res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms);
- else
- break;
+ else if (end) {
+ ast_seekstream(chan->stream, 0, SEEK_END);
+ end = NULL;
+ };
+ res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms);
}
if (res < 1)
@@ -496,17 +486,16 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
/* We go at next loop if we got the restart char */
if (restart && strchr(restart, res)) {
ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
- elapsed=0; /* To make sure the next stream will start at beginning */
+ pause_restart_point = 0;
continue;
}
- if (pause != NULL && strchr(pause, res)) {
- elapsed = ast_tvdiff_ms(ast_tvnow(), started) + last_elapsed;
- for(;;) {
- if (chan)
- ast_stopstream(chan);
+ if (pause && strchr(pause, res)) {
+ pause_restart_point = ast_tellstream(chan->stream);
+ for (;;) {
+ ast_stopstream(chan);
res = ast_waitfordigit(chan, 1000);
- if (res == 0)
+ if (!res)
continue;
else if (res == -1 || strchr(pause, res) || (stop && strchr(stop, res)))
break;
@@ -516,17 +505,16 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
continue;
}
}
+
if (res == -1)
break;
/* if we get one of our stop chars, return it to the calling function */
- if (stop && strchr(stop, res)) {
- /* res = 0; */
+ if (stop && strchr(stop, res))
break;
- }
}
- if (chan)
- ast_stopstream(chan);
+
+ ast_stopstream(chan);
return res;
}
diff --git a/apps/app_dial.c b/apps/app_dial.c
index c224a9a95..51cc17e0a 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -962,7 +962,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
/* If a channel group has been specified, get it for use when we create peer channels */
outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
- ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID);
+ ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP);
cur = args.peers;
do {
/* Remember where to start next time */
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index dfde90f0f..69d775c9a 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1417,7 +1417,7 @@ static int action_agents(struct mansession *s, struct message *m)
/* Set a default status. It 'should' get changed. */
status = "AGENT_UNKNOWN";
- if (!ast_strlen_zero(p->loginchan)) {
+ if (!ast_strlen_zero(p->loginchan) && !p->chan) {
loginChan = p->loginchan;
talkingtoChan = "n/a";
status = "AGENT_IDLE";
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index b0108bd19..2f9e0958e 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2279,6 +2279,7 @@ static int hangup_sip2cause(int cause)
/* Possible values taken from causes.h */
switch(cause) {
+ case 603: /* Declined */
case 403: /* Not found */
return AST_CAUSE_CALL_REJECTED;
case 404: /* Not found */
@@ -2458,7 +2459,7 @@ static int sip_hangup(struct ast_channel *ast)
if (ast->hangupcause && ((res = hangup_cause2sip(ast->hangupcause)))) {
transmit_response_reliable(p, res, &p->initreq, 1);
} else
- transmit_response_reliable(p, "403 Forbidden", &p->initreq, 1);
+ transmit_response_reliable(p, "603 Declined", &p->initreq, 1);
}
} else { /* Call is in UP state, send BYE */
if (!p->pendinginvite) {
diff --git a/pbx.c b/pbx.c
index 3ecf07067..05315495f 100644
--- a/pbx.c
+++ b/pbx.c
@@ -5443,6 +5443,8 @@ static int pbx_builtin_setamaflags(struct ast_channel *chan, void *data)
static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
{
/* Just return non-zero and it will hang up */
+ if (!chan->hangupcause)
+ chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
return -1;
}