aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authoralecdavis <alecdavis@f38db490-d61c-443f-a65b-d21fe96a405b>2011-05-12 22:56:43 +0000
committeralecdavis <alecdavis@f38db490-d61c-443f-a65b-d21fe96a405b>2011-05-12 22:56:43 +0000
commit26ed889533870367ecd4801485ecf4c0067c58a3 (patch)
tree0f9775a8aeaa78d0a6086971ea7aa08242a1bf82 /channels
parente1c744fee83c55b506dd381e824eef992319aeb1 (diff)
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines Fix directed group pickup feature code *8 with pickupsounds enabled Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues. 1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked. 2). dialplan applications for directed_pickups shouldn't beep. 3). feature code for directed pickup should beep on success/failure if configured. Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite. Moved app_directed:pickup_do() to features:ast_do_pickup(). Functions below, all now use the new ast_do_pickup() app_directed_pickup.c: pickup_by_channel() pickup_by_exten() pickup_by_mark() pickup_by_part() features.c: ast_pickup_call() (closes issue #18654) Reported by: Docent Patches: ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585) Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett Review: https://reviewboard.asterisk.org/r/1185/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@318672 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c69
1 files changed, 56 insertions, 13 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index df6ae9e28..6c3527537 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1280,6 +1280,10 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
static void check_pendings(struct sip_pvt *p);
static void *sip_park_thread(void *stuff);
static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct sip_request *req, int seqno, char *parkexten);
+
+static void *sip_pickup_thread(void *stuff);
+static int sip_pickup(struct ast_channel *chan);
+
static int sip_sipredirect(struct sip_pvt *p, const char *dest);
static int is_method_allowed(unsigned int *allowed_methods, enum sipmethod method);
@@ -20951,6 +20955,45 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
return 0;
}
+
+/*! \brief SIP pickup support function
+ * Starts in a new thread, then pickup the call
+ */
+static void *sip_pickup_thread(void *stuff)
+{
+ struct ast_channel *chan;
+ chan = stuff;
+
+ if (ast_pickup_call(chan)) {
+ chan->hangupcause = AST_CAUSE_CALL_REJECTED;
+ } else {
+ chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+ }
+ ast_hangup(chan);
+ ast_channel_unref(chan);
+ chan = NULL;
+ return NULL;
+}
+
+/*! \brief Pickup a call using the subsystem in features.c
+ * This is executed in a separate thread
+ */
+static int sip_pickup(struct ast_channel *chan)
+{
+ pthread_t threadid;
+
+ ast_channel_ref(chan);
+
+ if (ast_pthread_create_detached_background(&threadid, NULL, sip_pickup_thread, chan)) {
+ ast_debug(1, "Unable to start Group pickup thread on channel %s\n", chan->name);
+ ast_channel_unref(chan);
+ return -1;
+ }
+ ast_debug(1, "Started Group pickup thread on channel %s\n", chan->name);
+ return 0;
+}
+
+
/*! \brief Turn off generator data
XXX Does this function belong in the SIP channel?
*/
@@ -22361,29 +22404,29 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* Unlock locks so ast_hangup can do its magic */
ast_channel_unlock(c);
+ *nounlock = 1;
sip_pvt_unlock(p);
ast_hangup(c);
sip_pvt_lock(p);
c = NULL;
}
} else { /* Pickup call in call group */
- ast_channel_unlock(c);
- *nounlock = 1;
- if (ast_pickup_call(c)) {
- ast_log(LOG_NOTICE, "Nothing to pick up for %s\n", p->callid);
- transmit_response_reliable(p, "503 Unavailable", req);
+ if (sip_pickup(c)) {
+ ast_log(LOG_WARNING, "Failed to start Group pickup by %s\n", c->name);
+ transmit_response_reliable(p, "480 Temporarily Unavailable", req);
sip_alreadygone(p);
+ c->hangupcause = AST_CAUSE_FAILURE;
+
/* Unlock locks so ast_hangup can do its magic */
+ ast_channel_unlock(c);
+ *nounlock = 1;
+
+ p->invitestate = INV_COMPLETED;
sip_pvt_unlock(p);
- c->hangupcause = AST_CAUSE_CALL_REJECTED;
- } else {
- sip_pvt_unlock(p);
- c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+ ast_hangup(c);
+ sip_pvt_lock(p);
+ c = NULL;
}
- p->invitestate = INV_COMPLETED;
- ast_hangup(c);
- sip_pvt_lock(p);
- c = NULL;
}
break;
case AST_STATE_RING: