2005-09-15 20:28:23 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005, Joshua Colp
|
|
|
|
*
|
2006-04-06 17:01:47 +00:00
|
|
|
* Joshua Colp <jcolp@digium.com>
|
2005-09-15 20:28:23 +00:00
|
|
|
*
|
2008-04-25 18:32:22 +00:00
|
|
|
* Portions merged from app_pickupchan, which was
|
|
|
|
* Copyright (C) 2008, Gary Cook
|
|
|
|
*
|
2005-09-15 20:28:23 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-15 20:28:23 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief Directed Call Pickup Support
|
2005-09-15 20:28:23 +00:00
|
|
|
*
|
2006-05-22 16:08:23 +00:00
|
|
|
* \author Joshua Colp <jcolp@digium.com>
|
2008-04-25 18:32:22 +00:00
|
|
|
* \author Gary Cook
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2005-09-15 20:28:23 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2005-09-15 20:28:23 +00:00
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/lock.h"
|
|
|
|
#include "asterisk/app.h"
|
2007-08-27 20:55:36 +00:00
|
|
|
#include "asterisk/features.h"
|
2010-01-15 21:04:34 +00:00
|
|
|
#include "asterisk/manager.h"
|
2009-04-03 22:41:46 +00:00
|
|
|
#include "asterisk/callerid.h"
|
2009-06-26 15:28:53 +00:00
|
|
|
#include "asterisk/cel.h"
|
2005-09-15 20:28:23 +00:00
|
|
|
|
2006-05-22 16:08:23 +00:00
|
|
|
#define PICKUPMARK "PICKUPMARK"
|
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Pickup" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Directed extension call pickup.
|
|
|
|
</synopsis>
|
2012-04-25 23:00:26 +00:00
|
|
|
<syntax>
|
|
|
|
<parameter name="targets" argsep="&">
|
2012-04-26 03:12:44 +00:00
|
|
|
<argument name="extension" argsep="@" required="true">
|
|
|
|
<para>Specification of the pickup target.</para>
|
2012-04-25 23:00:26 +00:00
|
|
|
<argument name="extension" required="true"/>
|
|
|
|
<argument name="context" />
|
|
|
|
</argument>
|
2012-04-26 03:12:44 +00:00
|
|
|
<argument name="extension2" argsep="@" multiple="true">
|
|
|
|
<para>Additional specifications of pickup targets.</para>
|
2012-04-25 23:00:26 +00:00
|
|
|
<argument name="extension2" required="true"/>
|
|
|
|
<argument name="context2"/>
|
|
|
|
</argument>
|
2008-11-01 21:10:07 +00:00
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
2012-04-26 03:12:44 +00:00
|
|
|
<para>This application can pickup a specified ringing channel. The channel
|
|
|
|
to pickup can be specified in the following ways.</para>
|
|
|
|
<para>1) If no <replaceable>extension</replaceable> targets are specified,
|
|
|
|
the application will pickup a channel matching the pickup group of the
|
|
|
|
requesting channel.</para>
|
|
|
|
<para>2) If the <replaceable>extension</replaceable> is specified with a
|
|
|
|
<replaceable>context</replaceable> of the special string
|
|
|
|
<literal>PICKUPMARK</literal> (for example 10@PICKUPMARK), the application
|
2012-04-26 21:11:25 +00:00
|
|
|
will pickup a channel which has defined the channel variable
|
2012-04-26 03:12:44 +00:00
|
|
|
<variable>PICKUPMARK</variable> with the same value as
|
|
|
|
<replaceable>extension</replaceable> (in this example,
|
|
|
|
<literal>10</literal>).</para>
|
|
|
|
<para>3) If the <replaceable>extension</replaceable> is specified
|
2012-04-26 21:11:25 +00:00
|
|
|
with or without a <replaceable>context</replaceable>, the channel with a
|
|
|
|
matching <replaceable>extension</replaceable> and <replaceable>context</replaceable>
|
|
|
|
will be picked up. If no <replaceable>context</replaceable> is specified,
|
|
|
|
the current context will be used.</para>
|
|
|
|
<note><para>The <replaceable>extension</replaceable> is typically set on
|
|
|
|
matching channels by the dial application that created the channel. The
|
|
|
|
<replaceable>context</replaceable> is set on matching channels by the
|
|
|
|
channel driver for the device.</para></note>
|
2008-11-01 21:10:07 +00:00
|
|
|
</description>
|
|
|
|
</application>
|
|
|
|
<application name="PickupChan" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Pickup a ringing channel.
|
|
|
|
</synopsis>
|
2011-07-21 17:33:06 +00:00
|
|
|
<syntax >
|
|
|
|
<parameter name="Technology/Resource" argsep="&" required="true">
|
|
|
|
<argument name="Technology/Resource" required="true" />
|
|
|
|
<argument name="Technology2/Resource2" required="false" multiple="true" />
|
|
|
|
</parameter>
|
2010-03-02 21:58:03 +00:00
|
|
|
<parameter name="options" required="false">
|
|
|
|
<optionlist>
|
|
|
|
<option name="p">
|
|
|
|
<para>Channel name specified partial name. Used when find channel by callid.</para>
|
|
|
|
</option>
|
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
2008-11-01 21:10:07 +00:00
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This will pickup a specified <replaceable>channel</replaceable> if ringing.</para>
|
|
|
|
</description>
|
|
|
|
</application>
|
|
|
|
***/
|
2005-09-15 20:28:23 +00:00
|
|
|
|
2009-06-07 14:55:51 +00:00
|
|
|
static const char app[] = "Pickup";
|
|
|
|
static const char app2[] = "PickupChan";
|
2008-04-25 18:32:22 +00:00
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct pickup_by_name_args {
|
|
|
|
const char *name;
|
|
|
|
size_t len;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int pickup_by_name_cb(void *obj, void *arg, void *data, int flags)
|
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target = obj;/*!< Potential pickup target */
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct pickup_by_name_args *args = data;
|
|
|
|
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_lock(target);
|
2012-01-09 22:15:50 +00:00
|
|
|
if (!strncasecmp(ast_channel_name(target), args->name, args->len) && ast_can_pickup(target)) {
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
/* Return with the channel still locked on purpose */
|
|
|
|
return CMP_MATCH | CMP_STOP;
|
|
|
|
}
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_unlock(target);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-25 18:32:22 +00:00
|
|
|
/*! \brief Helper Function to walk through ALL channels checking NAME and STATE */
|
2008-11-02 02:14:19 +00:00
|
|
|
static struct ast_channel *my_ast_get_channel_by_name_locked(const char *channame)
|
2008-04-25 18:32:22 +00:00
|
|
|
{
|
2008-11-02 02:14:19 +00:00
|
|
|
char *chkchan;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct pickup_by_name_args pickup_args;
|
2008-11-02 02:14:19 +00:00
|
|
|
|
2010-10-05 19:57:31 +00:00
|
|
|
/* Check if channel name contains a '-'.
|
|
|
|
* In this case the channel name will be interpreted as full channel name.
|
2008-04-25 18:32:22 +00:00
|
|
|
*/
|
2010-10-05 19:57:31 +00:00
|
|
|
if (strchr(channame, '-')) {
|
|
|
|
/* check full channel name */
|
|
|
|
pickup_args.len = strlen(channame);
|
|
|
|
pickup_args.name = channame;
|
|
|
|
} else {
|
|
|
|
/* need to append a '-' for the comparison so we check full channel name,
|
|
|
|
* i.e SIP/hgc- , use a temporary variable so original stays the same for
|
|
|
|
* debugging.
|
|
|
|
*/
|
|
|
|
pickup_args.len = strlen(channame) + 1;
|
2012-07-31 20:21:43 +00:00
|
|
|
chkchan = ast_alloca(pickup_args.len + 1);
|
2010-10-05 19:57:31 +00:00
|
|
|
strcpy(chkchan, channame);
|
|
|
|
strcat(chkchan, "-");
|
|
|
|
pickup_args.name = chkchan;
|
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
return ast_channel_callback(pickup_by_name_cb, NULL, &pickup_args, 0);
|
2008-04-25 18:32:22 +00:00
|
|
|
}
|
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
/*! \brief Attempt to pick up named channel, does not use context */
|
2008-04-25 18:32:22 +00:00
|
|
|
static int pickup_by_channel(struct ast_channel *chan, char *pickup)
|
|
|
|
{
|
2011-05-20 15:52:20 +00:00
|
|
|
int res = -1;
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target;/*!< Potential pickup target */
|
2008-04-25 18:32:22 +00:00
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
target = my_ast_get_channel_by_name_locked(pickup);
|
|
|
|
if (target) {
|
|
|
|
/* Just check that we are not picking up the SAME as target. (i.e. ourself) */
|
|
|
|
if (chan != target) {
|
|
|
|
res = ast_do_pickup(chan, target);
|
|
|
|
}
|
|
|
|
ast_channel_unlock(target);
|
|
|
|
target = ast_channel_unref(target);
|
2008-04-25 18:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2006-10-16 16:26:23 +00:00
|
|
|
/* Attempt to pick up specified extension with context */
|
2007-06-04 17:32:41 +00:00
|
|
|
static int pickup_by_exten(struct ast_channel *chan, const char *exten, const char *context)
|
2006-10-16 16:26:23 +00:00
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target = NULL;/*!< Potential pickup target */
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct ast_channel_iterator *iter;
|
|
|
|
int res = -1;
|
|
|
|
|
2009-10-21 21:08:47 +00:00
|
|
|
if (!(iter = ast_channel_iterator_by_exten_new(exten, context))) {
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-05 22:19:22 +00:00
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
while ((target = ast_channel_iterator_next(iter))) {
|
|
|
|
ast_channel_lock(target);
|
2011-06-09 16:47:07 +00:00
|
|
|
if ((chan != target) && ast_can_pickup(target)) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_NOTICE, "%s pickup by %s\n", ast_channel_name(target), ast_channel_name(chan));
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
ast_channel_unlock(target);
|
|
|
|
target = ast_channel_unref(target);
|
|
|
|
}
|
2008-11-05 22:19:22 +00:00
|
|
|
|
2009-10-21 21:08:47 +00:00
|
|
|
ast_channel_iterator_destroy(iter);
|
|
|
|
|
2008-11-05 22:19:22 +00:00
|
|
|
if (target) {
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
res = ast_do_pickup(chan, target);
|
2006-10-16 16:26:23 +00:00
|
|
|
ast_channel_unlock(target);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
target = ast_channel_unref(target);
|
2006-10-16 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
return res;
|
2006-10-16 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
static int find_by_mark(void *obj, void *arg, void *data, int flags)
|
2008-11-09 01:59:59 +00:00
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target = obj;/*!< Potential pickup target */
|
2008-11-09 01:59:59 +00:00
|
|
|
const char *mark = data;
|
|
|
|
const char *tmp;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_lock(target);
|
|
|
|
tmp = pbx_builtin_getvar_helper(target, PICKUPMARK);
|
2011-06-09 16:47:07 +00:00
|
|
|
if (tmp && !strcasecmp(tmp, mark) && ast_can_pickup(target)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Return with the channel still locked on purpose */
|
|
|
|
return CMP_MATCH | CMP_STOP;
|
|
|
|
}
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_unlock(target);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
return 0;
|
2008-11-09 01:59:59 +00:00
|
|
|
}
|
|
|
|
|
2006-10-16 16:26:23 +00:00
|
|
|
/* Attempt to pick up specified mark */
|
2007-06-04 17:32:41 +00:00
|
|
|
static int pickup_by_mark(struct ast_channel *chan, const char *mark)
|
2006-10-16 16:26:23 +00:00
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target;/*!< Potential pickup target */
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
int res = -1;
|
2008-11-05 22:19:22 +00:00
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
/* The found channel is already locked. */
|
|
|
|
target = ast_channel_callback(find_by_mark, NULL, (char *) mark, 0);
|
|
|
|
if (target) {
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
res = ast_do_pickup(chan, target);
|
2011-05-20 15:52:20 +00:00
|
|
|
ast_channel_unlock(target);
|
|
|
|
target = ast_channel_unref(target);
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pickup_by_group(struct ast_channel *chan)
|
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target;/*!< Potential pickup target */
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
int res = -1;
|
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
/* The found channel is already locked. */
|
2012-09-20 17:22:41 +00:00
|
|
|
target = ast_pickup_find_by_group(chan);
|
2011-05-20 15:52:20 +00:00
|
|
|
if (target) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", ast_channel_name(target), ast_channel_name(chan));
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
res = ast_do_pickup(chan, target);
|
2011-05-20 15:52:20 +00:00
|
|
|
ast_channel_unlock(target);
|
|
|
|
target = ast_channel_unref(target);
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
}
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
return res;
|
2006-10-16 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 18:32:22 +00:00
|
|
|
/* application entry point for Pickup() */
|
2009-05-21 21:13:09 +00:00
|
|
|
static int pickup_exec(struct ast_channel *chan, const char *data)
|
2005-09-15 20:28:23 +00:00
|
|
|
{
|
2012-04-26 01:29:09 +00:00
|
|
|
char *tmp;
|
|
|
|
char *exten;
|
|
|
|
char *context;
|
2005-09-15 20:28:23 +00:00
|
|
|
|
2005-10-26 19:48:14 +00:00
|
|
|
if (ast_strlen_zero(data)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
return pickup_by_group(chan) ? 0 : -1;
|
2005-10-19 18:19:02 +00:00
|
|
|
}
|
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: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
|
2006-10-16 16:26:23 +00:00
|
|
|
/* Parse extension (and context if there) */
|
2012-04-26 01:29:09 +00:00
|
|
|
tmp = ast_strdupa(data);
|
2006-10-16 16:26:23 +00:00
|
|
|
while (!ast_strlen_zero(tmp) && (exten = strsep(&tmp, "&"))) {
|
|
|
|
if ((context = strchr(exten, '@')))
|
2006-01-13 17:02:15 +00:00
|
|
|
*context++ = '\0';
|
2007-06-04 17:32:41 +00:00
|
|
|
if (!ast_strlen_zero(context) && !strcasecmp(context, PICKUPMARK)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
if (!pickup_by_mark(chan, exten)) {
|
|
|
|
/* Pickup successful. Stop the dialplan this channel is a zombie. */
|
|
|
|
return -1;
|
|
|
|
}
|
2006-01-13 17:02:15 +00:00
|
|
|
} else {
|
2012-04-26 01:29:09 +00:00
|
|
|
if (ast_strlen_zero(context)) {
|
|
|
|
context = (char *) ast_channel_context(chan);
|
|
|
|
}
|
|
|
|
if (!pickup_by_exten(chan, exten, context)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Pickup successful. Stop the dialplan this channel is a zombie. */
|
|
|
|
return -1;
|
|
|
|
}
|
2005-09-15 20:28:23 +00:00
|
|
|
}
|
2012-04-26 01:29:09 +00:00
|
|
|
ast_log(LOG_NOTICE, "No target channel found for %s@%s.\n", exten, context);
|
2005-09-15 20:28:23 +00:00
|
|
|
}
|
2006-10-16 16:26:23 +00:00
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Pickup failed. Keep going in the dialplan. */
|
|
|
|
return 0;
|
2005-09-15 20:28:23 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 21:58:03 +00:00
|
|
|
/* Find channel for pick up specified by partial channel name */
|
|
|
|
static int find_by_part(void *obj, void *arg, void *data, int flags)
|
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target = obj;/*!< Potential pickup target */
|
2010-03-02 21:58:03 +00:00
|
|
|
const char *part = data;
|
|
|
|
int len = strlen(part);
|
|
|
|
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_lock(target);
|
2012-01-09 22:15:50 +00:00
|
|
|
if (len <= strlen(ast_channel_name(target)) && !strncmp(ast_channel_name(target), part, len)
|
2011-06-09 16:47:07 +00:00
|
|
|
&& ast_can_pickup(target)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Return with the channel still locked on purpose */
|
|
|
|
return CMP_MATCH | CMP_STOP;
|
2010-03-02 21:58:03 +00:00
|
|
|
}
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_unlock(target);
|
2010-03-02 21:58:03 +00:00
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
return 0;
|
2010-03-02 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to pick up specified by partial channel name */
|
|
|
|
static int pickup_by_part(struct ast_channel *chan, const char *part)
|
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target;/*!< Potential pickup target */
|
2010-03-02 21:58:03 +00:00
|
|
|
int res = -1;
|
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
/* The found channel is already locked. */
|
|
|
|
target = ast_channel_callback(find_by_part, NULL, (char *) part, 0);
|
|
|
|
if (target) {
|
|
|
|
res = ast_do_pickup(chan, target);
|
2010-03-02 21:58:03 +00:00
|
|
|
ast_channel_unlock(target);
|
|
|
|
target = ast_channel_unref(target);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-04-25 18:32:22 +00:00
|
|
|
/* application entry point for PickupChan() */
|
2009-05-21 21:13:09 +00:00
|
|
|
static int pickupchan_exec(struct ast_channel *chan, const char *data)
|
2008-04-25 18:32:22 +00:00
|
|
|
{
|
2010-03-02 21:58:03 +00:00
|
|
|
int partial_pickup = 0;
|
2008-04-25 18:32:22 +00:00
|
|
|
char *pickup = NULL;
|
2010-03-02 21:58:03 +00:00
|
|
|
char *parse = ast_strdupa(data);
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(channel);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
);
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
|
|
|
|
|
|
|
if (ast_strlen_zero(args.channel)) {
|
2008-04-25 18:32:22 +00:00
|
|
|
ast_log(LOG_WARNING, "PickupChan requires an argument (channel)!\n");
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Pickup failed. Keep going in the dialplan. */
|
|
|
|
return 0;
|
2010-03-02 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(args.options) && strchr(args.options, 'p')) {
|
|
|
|
partial_pickup = 1;
|
2008-04-25 18:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse channel */
|
2010-03-02 21:58:03 +00:00
|
|
|
while (!ast_strlen_zero(args.channel) && (pickup = strsep(&args.channel, "&"))) {
|
2012-01-09 22:15:50 +00:00
|
|
|
if (!strncasecmp(ast_channel_name(chan), pickup, strlen(pickup))) {
|
2008-04-25 18:32:22 +00:00
|
|
|
ast_log(LOG_NOTICE, "Cannot pickup your own channel %s.\n", pickup);
|
|
|
|
} else {
|
2010-03-02 21:58:03 +00:00
|
|
|
if (partial_pickup) {
|
|
|
|
if (!pickup_by_part(chan, pickup)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Pickup successful. Stop the dialplan this channel is a zombie. */
|
|
|
|
return -1;
|
2010-03-02 21:58:03 +00:00
|
|
|
}
|
|
|
|
} else if (!pickup_by_channel(chan, pickup)) {
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Pickup successful. Stop the dialplan this channel is a zombie. */
|
|
|
|
return -1;
|
2008-04-25 18:32:22 +00:00
|
|
|
}
|
|
|
|
ast_log(LOG_NOTICE, "No target channel found for %s.\n", pickup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
/* Pickup failed. Keep going in the dialplan. */
|
|
|
|
return 0;
|
2008-04-25 18:32:22 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2005-09-15 20:28:23 +00:00
|
|
|
{
|
2005-10-18 22:52:21 +00:00
|
|
|
int res;
|
|
|
|
|
|
|
|
res = ast_unregister_application(app);
|
2008-04-25 18:32:22 +00:00
|
|
|
res |= ast_unregister_application(app2);
|
2008-02-09 11:27:10 +00:00
|
|
|
|
2005-10-18 22:52:21 +00:00
|
|
|
return res;
|
2005-09-15 20:28:23 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2005-09-15 20:28:23 +00:00
|
|
|
{
|
2008-04-25 18:32:22 +00:00
|
|
|
int res;
|
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
res = ast_register_application_xml(app, pickup_exec);
|
|
|
|
res |= ast_register_application_xml(app2, pickupchan_exec);
|
2008-04-25 18:32:22 +00:00
|
|
|
|
|
|
|
return res;
|
2005-09-15 20:28:23 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Directed Call Pickup Application");
|