Commit Graph

362 Commits

Author SHA1 Message Date
Richard Mudgett 838ce15e20 Memory leak in connected line data when SIP blond transfer done.
The handling of the control subclass AST_CONTROL_READ_ACTION frame leaked
connected line string memory in __ast_read().

Also in __ast_read() the frame type switch should not have had a case for
AST_CONTROL_READ_ACTION.  AST_CONTROL_READ_ACTION is not a frame type.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@265608 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-25 16:23:51 +00:00
David Vossel fdb698ca2b fixes segfault when using generic plc
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@265273 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-24 16:10:09 +00:00
Richard Mudgett ba8e183938 Channel initialization failure causes crashes.
__ast_channel_alloc_ap() has several points in the initialization of a new
channel structure where it could fail.  Since the channel structure is now
an ao2 object, the destructor callback needs to be able to handle clean up
when the structure setup is incomplete.

Problems corrected:

1) Failing to setup the alertpipe would not unreference the structure but
free it directly.  Doing this to an ao2_object is very bad.

2) File descriptors need to be initialized to -1 before a construction
failure could occur so the destructor will not close unopened descriptors.

3) The destructor needs to check that the string field has been
initialized before using any string field values.  Crashes expected.

4) The destructor should not notify devstate if the device name is empty.
It is a waste of cycles and a couple ERROR log messages are generated.

Review:	https://reviewboard.asterisk.org/r/675/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@265174 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-21 22:46:52 +00:00
Mark Michelson 73e8c7572e Merged revisions 264996 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r264996 | mmichelson | 2010-05-21 11:28:34 -0500 (Fri, 21 May 2010) | 32 lines
  
  Allow ast_safe_sleep to defer specific frames until after the sleep has concluded.
  
  From reviewboard
  
  Background:
  A Digium customer discovered a somewhat odd bug. The setup is that parties A
  and B are bridged, and party A places party B on hold. While party B is 
  listening to hold music, he mashes a bunch of DTMF. Party A takes party
  B off hold while this is happening, but party B continues to hear hold
  music. I could reproduce this about 1 in 5 times.
  
  The issue:
  When DTMF features are enabled and a user presses keys, the channel that
  the DTMF is streamed to is placed in an ast_safe_sleep for 100 ms, the
  duration of the emulated tone. If an AST_CONTROL_UNHOLD frame is read
  from the channel during the sleep, the frame is dropped. Thus the
  unhold indication is never made to the channel that was originally placed
  on hold.
  
  The fix:
  Originally, I discussed with Kevin possible ways of fixing the specific
  problem reported. However, we determined that the same type of problem
  could happen in other situations where ast_safe_sleep() is used. Using
  autoservice as a model, I modified ast_safe_sleep_conditional() to
  defer specific frame types so they can be re-queued once the sleep has
  finished. I made a common function for determining if a frame should
  be deferred so that there are not two identical switch blocks to
  maintain.
  
  Review: https://reviewboard.asterisk.org/r/674/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@264997 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-21 16:44:27 +00:00
Mark Michelson 6bb45831eb Fix transcode_via_sln option with SIP calls and improve PLC usage.
From reviewboard:
The problem here is a bit complex, so try to bear with me...

It was noticed by a Digium customer that generic PLC (as configured in
codecs.conf) did not appear to actually be having any sort of benefit when
packet loss was introduced on an RTP stream. I reproduced this issue myself
by streaming a file across an RTP stream and dropping approx. 5% of the
RTP packets. I saw no real difference between when PLC was enabled or disabled
when using wireshark to analyze the RTP streams.

After analyzing what was going on, it became clear that one of the problems
faced was that when running my tests, the translation paths were being set
up in such a way that PLC could not possibly work as expected. To illustrate,
if packets are lost on channel A's read stream, then we expect that PLC will
be applied to channel B's write stream. The problem is that generic PLC can
only be done when there is a translation path that moves from some codec to
SLINEAR. When I would run my tests, I found that every single time, read
and write translation paths would be set up on channel A instead of channel
B. There appeared to be no real way to predict which channel the translation
paths would be set up on.

This is where Kevin swooped in to let me know about the transcode_via_sln
option in asterisk.conf. It is supposed to work by placing a read translation
path on both channels from the channel's rawreadformat to SLINEAR. It also
will place a write translation path on both channels from SLINEAR to the
channel's rawwriteformat. Using this option allows one to predictably set up
translation paths on all channels. There are two problems with this, though.
First and foremost, the transcode_via_sln option did not appear to be working
properly when I was placing a SIP call between two endpoints which did not
share any common formats. Second, even if this option were to work, for PLC
to be applied, there had to be a write translation path that would go from
some format to SLINEAR. It would not work properly if the starting format
of translation was SLINEAR.

The one-line change presented in this review request in chan_sip.c fixed the
first issue for me. The problem was that in sip_request_call, the
jointcapability of the outbound channel was being set to the format passed to
sip_request_call. This is nativeformats of the inbound channel. Because of this,
when ast_channel_make_compatible was called by app_dial, both channels already
had compatibly read and write formats. Thus, no translation path was set up at
the time. My change is to set the jointcapability of the sip_pvt created during
sip_request_call to the intersection of the inbound channel's nativeformats and
the configured peer capability that we determined during the earlier call to
create_addr. Doing this got the translation paths set up as expected when using
transcode_via_sln.

The changes presented in channel.c fixed the second issue for me. First and
foremost, when Asterisk is started, we'll read codecs.conf to see the value of
the genericplc option. If this option is set, and ast_write is called for a
frame with no data, then we will attempt to fill in the missing samples for
the frame. The implementation uses a channel datastore for maintaining the
PLC state and for creating a buffer to store PLC samples in. Even when we
receive a frame with data, we'll call plc_rx so that the PLC state will have
knowledge of the previous voice frame, which it can use as a basis for when
it comes time to actually do a PLC fill-in.

So, reviewers, now I ask for your help. First off, there's the one line change
in chan_sip that I have put in. Is it right? By my logic it seems correct, but
I'm sure someone can tell me why it is not going to work. This is probably the
change I'm least concerned about, though. What concerns me much more is the
set of changes in channel.c. First off, am I even doing it right? When I run
tests, I can clearly see that when PLC is activated, I see a significant increase
in RTP traffic where I would expect it to be. However, in my humble opinion, the
audio sounds kind of crappy whenever the PLC fill-in is done. It sounds worse to
me than when no PLC is used at all. I need someone to review the logic I have used
to be sure that I'm not misusing anything. As far as I can see my pointer arithmetic
is correct, and my use of AST_FRIENDLY_OFFSET should be correct as well, but I'm
sure someone can point out somewhere where I've done something incorrectly.

As I was writing this review request up, I decided to give the code a test run under
valgrind, and I find that for some reason, calls to plc_rx are causing some invalid
reads. Apparently I'm reading past the end of a buffer somehow. I'll have to dig around
a bit to see why that is the case. If it's obvious to someone reviewing, speak up!

Finally, I have one other proposal that is not reflected in my code review. Since
without transcode_via_sln set, one cannot predict or control where a translation
path will be up, it seems to me that the current practice of using PLC only when
transcoding to SLINEAR is not useful. I recommend that once it has been determined
that the method used in this code review is correct and works as expected, then
the code in translate.c that invokes PLC should be removed.

Review: https://reviewboard.asterisk.org/r/622/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@264452 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-19 21:29:08 +00:00
Mark Michelson b5d5cc565f Enhancements to connected line and redirecting work.
From reviewboard:

Digium has a commercial customer who has made extensive use of the connected party and
redirecting information present in later versions of Asterisk Business Edition and which
is to be in the upcoming 1.8 release. Through their use of the feature, new problems and solutions
have come about. This patch adds several enhancements to maximize usage of the connected party
and redirecting information functionality.

First, Asterisk trunk already had connected line interception macros. These macros allow you to
manipulate connected line information before it was sent out to its target. This patch adds the
same feature except for redirecting information instead.

Second, the ast_callerid and ast_party_id structures have been enhanced to provide a "tag." This
tag can be set with func_callerid, func_connectedline, func_redirecting, and in the case of DAHDI,
mISDN, and SIP channels, can be set in a configuration file. The idea behind the callerid tag is
that it can be set to whatever value the administrator likes. Later, when running connected line
and redirecting macros, the admin can read the tag off the appropriate structure to determine what
action to take. You can think of this sort of like a channel variable, except that instead of having
the variable associated with a channel, the variable is associated with a specific identity within
Asterisk.

Third, app_dial has two new options, s and u. The s option lets a dialplan writer force a specific
caller ID tag to be placed on the outgoing channel. The u option allows the dialplan writer to force
a specific calling presentation value on the outgoing channel.

Fourth, there is a new control frame subclass called AST_CONTROL_READ_ACTION added. This was added
to correct a very specific situation. In the case of SIP semi-attended (blond) transfers, the party
being transferred would not have the opportunity to run a connected line interception macro to
possibly alter the transfer target's connected line information. The issue here was that during a
blond transfer, the SIP transfer code has no bridged channel on which to queue the connected line
update. The way this was corrected was to add this new control frame subclass. Now, we queue an
AST_CONTROL_READ_ACTION frame on the channel on which the connected line interception macro should
be run. When ast_read is called to read the frame, ast_read responds by calling a callback function
associated with the specific read action the control frame describes. In this case, the action taken
is to run the connected line interception macro on the transferee's channel.

Review: https://reviewboard.asterisk.org/r/652/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@263541 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-17 15:36:31 +00:00
Tilghman Lesher 6a0ea1d79e Merged revisions 261093-261094 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r261093 | tilghman | 2010-05-04 18:36:53 -0500 (Tue, 04 May 2010) | 7 lines
  
  Protect against overflow, when calculating how long to wait for a frame.
  
  (closes issue #17128)
   Reported by: under
   Patches: 
         d.diff uploaded by under (license 914)
........
  r261094 | tilghman | 2010-05-04 18:47:08 -0500 (Tue, 04 May 2010) | 2 lines
  
  Add a tiny corner case to the previous commit
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@261095 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-05-04 23:51:52 +00:00
David Vossel 6722251986 Merged revisions 259858 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r259858 | dvossel | 2010-04-28 16:16:03 -0500 (Wed, 28 Apr 2010) | 33 lines
  
  resolves deadlocks in chan_local
  
  Issue_1.
  In the local_hangup() 3 locks must be held at the same time... pvt, pvt->chan,
  and pvt->owner.  Proper deadlock avoidance is done when the channel to hangup
  is the outbound chan_local channel, but when it is not the outbound channel we
  have an issue... We attempt to do deadlock avoidance only on the tech pvt, when
  both the tech pvt and the pvt->owner are locked coming into that loop.  By
  never giving up the pvt->owner channel deadlock avoidance is not entirely possible.
  This patch resolves that by doing deadlock avoidance on both the pvt->owner and the pvt
  when trying to get the pvt->chan lock.
  
  Issue_2.
  ast_prod() is used in ast_activate_generator() to queue a frame on the channel
  and make the channel's read function get called.  This function is used in
  ast_activate_generator() while the channel is locked, which mean's the channel
  will have a lock both from the generator code and the frame_queue code by the
  time it gets to chan_local.c's local_queue_frame code... local_queue_frame
  contains some of the same crazy deadlock avoidance that local_hangup requires,
  and this recursive lock prevents that deadlock avoidance from happening correctly.
  This patch removes ast_prod() from the channel lock so only one lock is held during
  the local_queue_frame function.
  
  (closes issue #17185)
  Reported by: schmoozecom
  Patches:
        issue_17185_v1.diff uploaded by dvossel (license 671)
        issue_17185_v2.diff uploaded by dvossel (license 671)
  Tested by: schmoozecom, GameGamer43
  
  Review: https://reviewboard.asterisk.org/r/631/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@259870 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-28 21:20:03 +00:00
Mark Michelson af6690ba7f Merged revisions 259104 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r259104 | mmichelson | 2010-04-26 16:44:43 -0500 (Mon, 26 Apr 2010) | 3 lines
  
  Let compilation succeed warning-free when DONT_OPTIMIZE is turned off.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@259105 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-26 21:45:13 +00:00
Mark Michelson 317a12d950 Merged revisions 259018 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r259018 | mmichelson | 2010-04-26 16:03:08 -0500 (Mon, 26 Apr 2010) | 13 lines
  
  Prevent Newchannel manager events for dummy channels.
  
  No Newchannel manager event will be fired for channels that are
  allocated to not match a registered technology type. Thus bogus
  channels allocated solely for variable substitution or CDR
  operations do not result in a Newchannel event.
  
  (closes issue #16957)
  Reported by: atis
  
  Review: https://reviewboard.asterisk.org/r/601
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@259023 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-26 21:13:35 +00:00
Matthew Nicholson 99a7b2fed0 Fix previous commit.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22 22:11:23 +00:00
Matthew Nicholson 8c41f2db82 Merged revisions 193391,258670 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r193391 | mnicholson | 2009-05-08 16:01:25 -0500 (Fri, 08 May 2009) | 8 lines
  
  Set the proper disposition on originated calls.
  
  (closes issue #14167)
  Reported by: jpt
  Patches:
        call-file-missing-cdr2.diff uploaded by mnicholson (license 96)
  Tested by: dlotina, rmartinez, mnicholson
........
  r258670 | mnicholson | 2010-04-22 16:49:07 -0500 (Thu, 22 Apr 2010) | 11 lines
  
  Fix broken CDR behavior.
  
  This change allows a CDR record previously marked with disposition ANSWERED to be set as BUSY or NO ANSWER.
  
  Additionally this change partially reverts r235635 and does not set the AST_CDR_FLAG_ORIGINATED flag on CDRs generated from ast_call().  To preserve proper CDR behavior, the AST_CDR_FLAG_DIALED flag is now cleared from all brige CDRs in ast_bridge_call().
  
  (closes issue #16797)
  Reported by: VarnishedOtter
  Tested by: mnicholson
........

(closes issue #16222)
Reported by: telles
Tested by: mnicholson



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258671 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22 21:57:59 +00:00
Eliel C. Sardanons a753e8878b Asterisk data retrieval API.
This module implements an abstraction for retrieving and exporting
asterisk data.
Developed by:
	Brett Bryant <brettbryant@gmail.com>
	Eliel C. Sardanons (LU1ALY) <eliels@gmail.com>
For the Google Summer of code 2009 Project.
Documentation can be found in doxygen format and inside the
header include/asterisk/data.h

Review: https://reviewboard.asterisk.org/r/275/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258517 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-22 18:07:02 +00:00
Mark Michelson e24661fd18 Merge Call completion support into trunk.
From Reviewboard:
CCSS stands for Call Completion Supplementary Services. An admittedly out-of-date
overview of the architecture can be found in the file doc/CCSS_architecture.pdf
in the CCSS branch. Off the top of my head, the big differences between what is
implemented and what is in the document are as follows:

1. We did not end up modifying the Hangup application at all.
2. The document states that a single call completion monitor may be used across
   multiple calls to the same device. This proved to not be such a good idea
   when implementing protocol-specific monitors, and so we ended up using one
   monitor per-device per-call.
3. There are some configuration options which were conceived after the document
   was written. These are documented in the ccss.conf.sample that is on this
   review request.
		      
For some basic understanding of terminology used throughout this code, see the
ccss.tex document that is on this review.

This implements CCBS and CCNR in several flavors.

First up is a "generic" implementation, which can work over any channel technology
provided that the channel technology can accurately report device state. Call
completion is requested using the dialplan application CallCompletionRequest and can
be canceled using CallCompletionCancel. Device state subscriptions are used in order
to monitor the state of called parties.

Next, there is a SIP-specific implementation of call completion. This method uses the
methods outlined in draft-ietf-bliss-call-completion-06 to implement call completion
using SIP signaling. There are a few things to note here:

* The agent/monitor terminology used throughout Asterisk sometimes is the reverse of
  what is defined in the referenced draft.

* Implementation of the draft required support for SIP PUBLISH. I attempted to write
  this in a generic-enough fashion such that if someone were to want to write PUBLISH
  support for other event packages, such as dialog-state or presence, most of the effort
  would be in writing callbacks specific to the event package.

* A subportion of supporting PUBLISH reception was that we had to implement a PIDF
  parser. The PIDF support added is a bit minimal. I first wrote a validation
  routine to ensure that the PIDF document is formatted properly. The rest of the
  PIDF reading is done in-line in the call-completion-specific PUBLISH-handling
  code. In other words, while there is PIDF support here, it is not in any state
  where it could easily be applied to other event packages as is.

Finally, there are a variety of ISDN-related call completion protocols supported. These
were written by Richard Mudgett, and as such I can't really say much about their
implementation. There are notes in the CHANGES file that indicate the ISDN protocols
over which call completion is supported.

Review: https://reviewboard.asterisk.org/r/523


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@256528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-09 15:31:32 +00:00
Richard Mudgett a5a0a5f867 Consolidate ast_channel.cid.cid_rdnis into ast_channel.redirecting.from.number.
SWP-1229
ABE-2161

* Ensure chan_local.c:local_call() will not leak cid.cid_dnid when
copying.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@256104 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-03 02:12:33 +00:00
Russell Bryant 37797ddd52 Merged revisions 256009 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r256009 | russell | 2010-04-02 18:30:15 -0500 (Fri, 02 Apr 2010) | 2 lines
  
  Remove extremely verbose debug message.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@256010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-04-02 23:30:58 +00:00
Kevin P. Fleming 42577406fd Improve handling of T.38 re-INVITEs that arrive before a T.38-capable
application is executing on a channel.

This patch addresses an issue found during working with end-users
using res_fax. If an incoming call is answered in the dialplan, or
jumps to the 'fax' extension due to reception of a CNG tone (with
faxdetect enabled), and then the remote endpoint sends a T.38
re-INVITE, it is possible for the channel's T.38 state to be
'T38_STATE_NEGOTIATING' when the application starts up. Unfortunately,
even if the application wants to use T.38, it can't respond to the
peer's negotiation request, because the AST_CONTROL_T38_PARAMETERS
control frame that chan_sip sent originally has been lost, and the
application needs the content of that frame to be able to formulate a
reply.

This patch adds a new 'request' type to AST_CONTROL_T38_PARAMETERS,
AST_T38_REQUEST_PARMS. If the application sends this request, chan_sip
will re-send the original control frame (with
AST_T38_REQUEST_NEGOTIATE as the request type), and the application
can respond as normal. If this occurs within the five second timeout
in chan_sip, the automatic cancellation of the peer reinvite will be
stopped, and the application will 'own' the negotiation process from
that point onwards.

This also improves the code path in chan_sip to allow sip_indicate(),
when called for AST_CONTROL_T38_PARAMETERS, to be able to return a
non-zero response, which should have been in place before since the
control frame *can* fail to be processed properly. It also modifies
ast_indicate() to return whatever result the channel driver returned
for this control frame, rather than converting all non-zero results
into '-1'. Finally, the new request type intentionally returns a
positive value, so that an application that sends
AST_T38_REQUEST_PARMS can know for certain whether the channel driver
accepted it and will be replying with a control frame of its own, or
whether it was ignored (if the sip_indicate()/ast_indicate() path had
properly supported failure responses before, this would not be
necessary).

This patch also modifies res_fax to take advantage of the new request.

In addition, this patch makes sip_t38_abort() actually lock the
private structure before doing its work... bad programmer, no donut.

This patch also enhances chan_sip's 'faxdetect' support to allow
triggering on T.38 re-INVITEs received as well as CNG tone detection.

Review: https://reviewboard.asterisk.org/r/556/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254450 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-25 15:27:31 +00:00
Jeff Peeler 48edf2c78a Exit native bridging early for greater timing accuracy with warnings
This changes native bridging to break one millisecond early so that the more
accurate timeval calculations done in the generic bridge can be performed using
the bridge config. Currently the time between exiting native bridging slightly
late can sometimes cause a large enough discrepancy for warnings to be missed.
For the record, 1.4 does not attempt to native bridge at all when warnings are
enabled.

(closes issue #15815)
Reported by: adomjan

Review: https://reviewboard.asterisk.org/r/577/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254050 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-23 21:17:23 +00:00
Terry Wilson 68d1ded8dd Only change the RTP ssrc when we see that it has changed
This change basically reverts the change reviewed in
https://reviewboard.asterisk.org/r/374/ and instead limits the
updating of the RTP synchronization source to only those times when we
detect that the other side of the conversation has changed the ssrc.

The problem is that SRCUPDATE control frames are sent many times where
we don't want a new ssrc, including whenever Asterisk has to send DTMF
in a normal bridge. This is also not the first time that this mistake
has been made. The initial implementation of the ast_rtp_new_source
function also changed the ssrc--and then it was removed because of
this same issue. Then, we put it back in again to fix a different
issue. This patch attempts to only change the ssrc when we see that
the other side of the conversation has changed the ssrc.

It also renames some functions to make their purpose more clear.

Review: https://reviewboard.asterisk.org/r/540/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@252089 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-12 22:04:51 +00:00
Richard Mudgett efea9ad922 Fix placing ISDN calls on hold preventing native bridging from being reexamined after a transfer.
Consider the following scenario:

                 /-- B
A == * == Network
                 \-- C

Party B calls party A (EuroISDN BRI phone)
Party A puts B on hold using the HOLD/RETRIEVE messages.
Party A calls party C.
Party A puts C on hold to talk with party B again.
Party A transfers B to C by hanging up.

The call does not get the opportunity to get re-transferred into the ISDN
network by the native bridge because native bridging is not being
reexamined after the initial transfer.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@247609 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-18 18:31:44 +00:00
David Vossel 091f850a58 fixes sample rate conversion issue with Monitor application
When using ast_seekstream with the read/write streams of a monitor,
the number of samples we are seeking must be of the same rate as the
stream or the jump calculation will be incorrect.  This patch adds logic
to correctly convert the number of samples to jump to the sample rate
the read/write stream is using.

For example, if the call is G722 (16khz) and the read/write stream is
recording a 8khz wav, seeking 320 samples of 16khz audio is not the
same as seeking 320 samples of 8khz audio when performing the ast_seekstream
on the stream.

ABE-2044



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246899 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-16 17:07:41 +00:00
David Vossel 7d5d0311c1 Merged revisions 246545 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r246545 | dvossel | 2010-02-12 17:30:17 -0600 (Fri, 12 Feb 2010) | 16 lines
  
  lock channel during datastore removal
  
  On channel destruction the channel's datastores are removed and
  destroyed.  Since there are public API calls to find and remove
  datastores on a channel, a lock should be held whenever datastores are
  removed and destroyed.  This resolves a crash caused by a race
  condition in app_chanspy.c.
  
  (closes issue #16678)
  Reported by: tim_ringenbach
  Patches:
        datastore_destroy_race.diff uploaded by tim ringenbach (license 540)
  Tested by: dvossel
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246546 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-12 23:32:33 +00:00
Tilghman Lesher 72c1b76038 Merged revisions 244070 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r244070 | tilghman | 2010-02-01 11:46:31 -0600 (Mon, 01 Feb 2010) | 16 lines
  
  Revert previous chan_local fix (r236981) and fix instead by destroying expired frames in the queue.
  
  (closes issue #16525)
   Reported by: kobaz
   Patches: 
         20100126__issue16525.diff.txt uploaded by tilghman (license 14)
         20100129__issue16525__1.6.0.diff.txt uploaded by tilghman (license 14)
   Tested by: kobaz, atis
  
  (closes issue #16581)
   Reported by: ZX81
  
  (closes issue #16681)
   Reported by: alexr1
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@244071 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-01 17:53:39 +00:00
Jeff Peeler c277952cea Merged revisions 243258 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r243258 | jpeeler | 2010-01-26 12:19:10 -0600 (Tue, 26 Jan 2010) | 2 lines
  
  Remove unnecessary code in ast_read as issue 16058 has been fully solved now.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 18:20:55 +00:00
Jeff Peeler 568c057c4c Extend max call limit duration from 24.8 days to 292+ million years.
If the limit was set past MAX_INT upon answering, the call was immediately
hung up due to overflow from the return of ast_tvdiff_ms (in ast_check_hangup).
The time calculation functions ast_tvdiff_sec and ast_tvdiff_ms have been
changed to return an int64_t to prevent overflow. Also the reporter suggested
adding a message indicating the reason for the call hanging up. Given that the
new limit is so much higher, the message (which would only really be useful in
the overflow scenario) has been made a debug message only.

(closes issue #16006)
Reported by: viraptor


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@241143 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-18 22:31:25 +00:00
Jeff Peeler 9228fba7d7 Fix broken call pickup
The problem was the OUTGOING flag was not getting set properly on the channel,
resulting in pickup failing as ast_read thought the call was inbound. Refer to
170393 for a more verbose description as this is the same exact change.

(closes issue #16539)
Reported by: syspert
Patches: 
      bug16539.patch uploaded by jpeeler (license 325)
Tested by: syspert


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@240179 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-14 18:03:31 +00:00
David Vossel 03529837cc add silence gen to wait apps
asterisk.conf's 'transmit_silence' option existed before
this patch, but was limited to only generating silence
while recording and sending DTMF.  Now enabling the
transmit_silence option generates silence during wait
times as well.

To achieve this, ast_safe_sleep has been modified to
generate silence anytime no other generators are present
and transmit_silence is enabled.  Wait apps not using
ast_safe_sleep now generate silence when transmit_silence
is enabled as well.

(closes issue #16524)
Reported by: kobaz

(closes issue #16523)
Reported by: kobaz
Tested by: dvossel

Review: https://reviewboard.asterisk.org/r/456/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@239712 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-13 16:31:14 +00:00
David Vossel a575a50cd5 fixes ast_transfer stall until hangup if called with a channel that doesn't support transfers
ast_transfer sets res to 0 if there is no technology transfer function,
but then tests for it to be negative before deciding to do an early exit.
As a result, it will will wait for an AST_CONTROL_TRANSFER message that
will never come.

(closes issue #16424)
Reported by: davidw
Patches:
      Issue_16424_trunk_234134.patch uploaded by davidw (license 780)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@238492 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-07 20:42:27 +00:00
Jeff Peeler cf7b67d9d3 Merged revisions 235635 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r235635 | jpeeler | 2009-12-18 16:29:51 -0600 (Fri, 18 Dec 2009) | 48 lines
  
  Correct CDR dispositions for BUSY/FAILED
  
  This patch is simple in that it reorders the disposition defines so that the fix
  for issue 12946 works properly (the default CDR disposition was changed to
  AST_CDR_NOANSWER). Also, the AST_CDR_FLAG_ORIGINATED flag was set in ast_call to
  ensure all CDR records are written.
  
  The side effects of CDR changes are scary, so I'm documenting the test cases
  performed to attempt to catch any regressions. The following tests were all
  performed using 1.4 rev 195881 vs head (235571) + patch:
  
  A calls B
  C calls B (busy)
  Hangup C
  Hangup A
  
  (Both SIP and features)
  A calls B
  A blind transfers to C
  Hangup C
  
  (Both SIP and features)
  A calls B
  A attended transfers to C
  Hangup C
  
  A calls B
  A attended transfers to C (SIP)
  C blind transfers to A (features)
  Hangup A
  
  All of the test scenario CDRs matched.
  
  The following tests were performed just with the patch to ensure proper operation
  (with unanswered=yes):
  
  exten =>s,1,Answer
  exten =>s,n,ResetCDR(w)
  exten =>s,n,ResetCDR(w)
  
  exten =>s,1,ResetCDR(w)
  exten =>s,n,ResetCDR(w)
  
  (closes issue #16180)
  Reported by: aatef
  Patches: 
        bug16180.patch uploaded by jpeeler (license 325)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@235660 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-18 22:51:37 +00:00
Jeff Peeler 473837a4ab Change match criteria existence in ast_channel_cmp_cb to use ast_strlen_zero.
(closes issue #16161)
Reported by: may213
Patches: 
      core-show-channel.patch uploaded by may213 (license 454)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@235226 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-15 23:41:20 +00:00
Russell Bryant 97bb26bf75 Merged revisions 233092 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r233092 | russell | 2009-12-04 11:12:47 -0600 (Fri, 04 Dec 2009) | 7 lines
  
  Only do frame payload check for HOLD frames.
  
  This code was added for helping to debug the source of invalid HOLD frames.
  However, a side effect of this is that it will incorrectly report errors for
  frames that have an integer payload.  Make the check for this block specific
  to the HOLD frame case.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@233100 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-04 17:18:22 +00:00
Jeff Peeler d9f37a67e1 Merged revisions 231911 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r231911 | jpeeler | 2009-12-01 15:29:31 -0600 (Tue, 01 Dec 2009) | 12 lines
  
  Fix crash with invalid frame data
  
  The crash was happening as a result of a frame containing an invalid data
  pointer, but was set with data length of zero. The few times the issue was
  reproduced it _seemed_ that the frame was queued properly, that is the data
  pointer was set to NULL. I never could reproduce the crash so as a last resort
  the crash has been fixed, but a check in __ast_read has been added to give as
  much information about the source of problematic frames in the future.
  
  (closes issue #16058)
  Reported by: atis
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@231927 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-01 21:54:21 +00:00
Tilghman Lesher f98c12a57d Merged revisions 231298 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r231298 | tilghman | 2009-11-25 16:31:57 -0600 (Wed, 25 Nov 2009) | 2 lines
  
  After a frame duplication failure, unlock the channel before returning.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@231299 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-25 22:33:02 +00:00
Tilghman Lesher 5e2aa190fe Display a list of channel variables in each channel-oriented event.
(Closes AST-33)
Reviewboard:	https://reviewboard.asterisk.org/r/368/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@230111 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-13 20:42:03 +00:00
Leif Madsen fef304e641 Merged revisions 228896 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r228896 | lmadsen | 2009-11-09 09:37:43 -0600 (Mon, 09 Nov 2009) | 6 lines
  
  Update WARNING message.
  Update a WARNING message to give a suggested fix when encountered.
  
  (closes issue #16198)
  Reported by: atis
  Tested by: atis
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228897 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-09 15:38:38 +00:00
David Vossel 10fa8fe8d0 Merged revisions 228692 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r228692 | dvossel | 2009-11-06 16:33:27 -0600 (Fri, 06 Nov 2009) | 9 lines
  
  fixes audiohook write crash occuring in chan_spy whisper mode.
  
  After writing to the audiohook list in ast_write(), frames
  were being freed incorrectly.  Under certain conditions this
  resulted in a double free crash.
  
  (closes issue #16133)
  Reported by: wetwired

  (closes issue #16045)
  Reported by: bluecrow76
  Patches:
        issue16045.diff uploaded by dvossel (license 671)
  Tested by: bluecrow76, dvossel, habile
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228693 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-06 22:35:44 +00:00
Tilghman Lesher d8e0c58437 Expand codec bitfield from 32 bits to 64 bits.
Reviewboard: https://reviewboard.asterisk.org/r/416/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@227580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-04 14:05:12 +00:00
Richard Mudgett 1174a61612 Add support for calling and called subaddress. Partial support for COLP subaddress.
The Telecom Specs in NZ suggests that SUB ADDRESS is always on, so doing
"desk to desk" between offices each with an asterisk box over the ISDN
should then be possible, without a whole load of DDI numbers required.

(closes issue #15604)
Reported by: alecdavis
Patches:
      asterisk_subaddr_trunk.diff11.txt uploaded by alecdavis (license 585)
      Some minor modificatons were made.
Tested by: alecdavis, rmudgett

Review: https://reviewboard.asterisk.org/r/405/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@225357 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-22 16:33:22 +00:00
Kevin P. Fleming cdd1f9e296 Finish implementaton of astobj2 OBJ_MULTIPLE, and convert ast_channel_iterator to use it.
This patch finishes the implementation of OBJ_MULTIPLE in astobj2 (the
case where multiple results need to be returned; OBJ_NODATA mode
already was supported). In addition, it converts ast_channel_iterators
(only the targeted versions, not the ones that iterate over all
channels) to use this method.

During this work, I removed the 'ao2_flags' arguments to the
ast_channel_iterator constructor functions; there were no uses of that
argument yet, there is only one possible flag to pass, and it made the
iterators less 'opaque'. If at some point in the future someone really
needs an ast_channel_iterator that does not lock the container, we can
provide constructor(s) for that purpose.

Review: https://reviewboard.asterisk.org/r/379/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@225244 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-21 21:08:47 +00:00
Matthew Nicholson 0d4726b0a2 Merged revisions 223225 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r223225 | mnicholson | 2009-10-09 13:20:11 -0500 (Fri, 09 Oct 2009) | 8 lines
  
  Signal timeouts by returning AST_CONTROL_RINGING when originating calls.
  (closes issue #15104)
  Reported by: nblasgen
  Patches:
        manager-timeout1.diff uploaded by mnicholson (license 96)
  Tested by: nblasgen, mnicholson
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@223273 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-09 18:34:08 +00:00
David Vossel 9456ab2724 Deadlock in channel masquerade handling
Channels are stored in an ao2_container.  When accessing an item within
an ao2_container the proper locking order is to first lock the container,
and then the items within it.

In ast_do_masquerade both the clone and original channel must be locked
for the entire duration of the function.  The problem with this is that
it attemptes to unlink and link these channels back into the ao2_container
when one of the channel's name changes.  This is invalid locking order as
the process of unlinking and linking will lock the ao2_container while
the channels are locked!!! Now, both the channels in do_masquerade are
unlinked from the ao2_container and then locked for the entire function.
At the end of the function both channels are unlocked and linked back
into the container with their new names as hash values.

This new method of requiring all channels and tech pvts to be unlocked
before ast_do_masquerade() or ast_change_name() required several
changes throughout the code base.

(closes issue #15911)
Reported by: russell
Patches:
      masq_deadlock_trunk.diff uploaded by dvossel (license 671)
Tested by: dvossel, atis

(closes issue #15618)
Reported by: lmsteffan
Patches:
      deadlock_local_attended_transfers_trunk.diff uploaded by dvossel (license 671)
Tested by: lmsteffan, dvossel

Review: https://reviewboard.asterisk.org/r/387/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@222761 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-07 22:58:38 +00:00
Tilghman Lesher a4ece92018 Merged revisions 221200 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r221200 | tilghman | 2009-09-30 11:55:21 -0500 (Wed, 30 Sep 2009) | 7 lines
  
  Avoid a potential NULL dereference.
  (closes issue #15865)
   Reported by: kobaz
   Patches: 
         20090915__issue15865.diff.txt uploaded by tilghman (license 14)
   Tested by: kobaz
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@221201 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-30 16:56:42 +00:00
Kevin P. Fleming 8c30540269 Correct sense of logic test committed in revision 220494.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@220495 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-25 14:44:40 +00:00
Kevin P. Fleming aabdc575a5 Don't use hash-based lookups for ast_channel_get_by_name_prefix().
ast_channel_get_full() tries to use OBJ_POINTER to optimize name-based
channel lookups, but this will not work properly when the channel's full
name was not supplied; for name-prefix searches, there is no value in
doing a hash-based lookup, and in fact doing so could result in many
channels being skipped.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@220494 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-25 14:38:41 +00:00
Matthew Nicholson b27a54b8de Merged revisions 219136 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r219136 | mnicholson | 2009-09-17 09:58:39 -0500 (Thu, 17 Sep 2009) | 10 lines
  
  Prevent a potential race condition and crash when hanging up a channel by removing the channel from the channel list before begining channel tear down.
  
  This fix may potentially cause problems with CDR backends that access the channel a CDR is associated with via the channel list.  This fix makes the channel unavabile at the time when the CDR backend is invoked.  This has been documented in include/asterisk/cdr.h.
  
  (closes issue #15316)
  Reported by: vmarrone
  Tested by: mnicholson
  
  Review: https://reviewboard.asterisk.org/r/362/
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@219139 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-09-17 15:18:01 +00:00
Tilghman Lesher 40c13bd1b0 Merged revisions 214701 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r214701 | tilghman | 2009-08-28 15:13:32 -0500 (Fri, 28 Aug 2009) | 8 lines
  
  Modify comment to be a bit more accurate.
  We have kept this comment around long enough, that it's pretty clear that we're
  keeping the code, because changing the code would require a pretty fundamental
  architectural shift.  We've also taken criticism in some quarters, because it
  was believed that it was referring to the code being nasty.  No, the code isn't
  nasty, just the operation itself is rather odd.  Fixed for eternity (probably
  not).
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@214702 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-28 20:14:39 +00:00
David Vossel 2794b198ce Merged revisions 214194 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r214194 | dvossel | 2009-08-26 11:36:42 -0500 (Wed, 26 Aug 2009) | 19 lines
  
  ast_write() ignores ast_audiohook_write() results
  
  In ast_write(), if a channel has a list of audiohooks, those
  lists are written to and the resulting frame is what ast_write()
  should continue with.  The problem was the returned audiohook frame
  was not being handled at all, and the original frame passed
  into it did not contain the mixed audio, so essentially audio
  was being lost.  One result of this was chan_spy's whisper
  mode no longer worked.  To complicate the issue, frames
  passed into ast_write may either be a single frame, or a list
  of frames.  So, as the list of frames is processed in the
  audiohook_write, the returned frames had to be added to a new
  list.
  
  (closes issue #15660)
  Reported by: corruptor
  Tested by: dvossel
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@214195 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-26 16:38:53 +00:00
Tilghman Lesher 642bec4d6f AST-2009-005
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@211539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-10 19:20:57 +00:00
Russell Bryant 724c1239fc Fix up some issues with getting a channel by "name".
Even though the get_channel_by_name() API advertised that you could search by
name or uniqueid (just as the old API did), searching by uniqueid was not
actually implemented.  This patch fixes that problem.

The ast_channel_get_full() function now makes a second search attempt by
uniqueid if the parameter was a name.  The channel comparison function also
now knows how to compare by unqieueid.

Finally, a bug was fixed in passing where OBJ_POINTER was being passed in some
scenarios where it should not have been.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@211390 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-10 15:46:39 +00:00
Tilghman Lesher feced6672c Merged revisions 210913 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r210913 | tilghman | 2009-08-06 16:45:01 -0500 (Thu, 06 Aug 2009) | 7 lines
  
  Because channel information can be accessed outside of the channel thread, we must lock the channel prior to modifying it.
  (closes issue #15397)
   Reported by: caspy
   Patches: 
         20090714__issue15397.diff.txt uploaded by tilghman (license 14)
   Tested by: caspy
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@210914 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-06 21:46:01 +00:00