update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@418 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1e04eb13b5
commit
0ea203849f
|
@ -1 +0,0 @@
|
|||
-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l120 -cs -T size_t -T pieces -T switch_file_t -T switch_thread_cond_t -T switch_thread -T switch_threadattr_t -T switch_thread_start_t -T switch_socket_t -T switch_sockaddr_t -T switch_memory_pool -T switch_pollfd_t -T switch_pollset_t -T switch_time_t -T switch_time_exp_t -T switch_hash -T switch_hash_index_t -T switch_strmatch_pattern -T switch_uuid_t -T switch_queue_t -T switch_mutex_t -T __int8 -T __int16 -T __int32 -T __int64 -T int8_t -T int16_t -T int32_t -T int64_t -T long -T switch_core_db -T switch_core_session_message -T switch_audio_resampler -T switch_event_header -T switch_event -T switch_event_subclass -T switch_event_node -T switch_loadable_module -T switch_frame -T switch_channel -T switch_endpoint_interface -T switch_timer_interface -T switch_dialplan_interface -T switch_codec_interface -T switch_application_interface -T switch_api_interface -T switch_file_interface -T switch_file_handle -T switch_core_session -T switch_loadable_module_interface -T switch_caller_profile -T switch_caller_step -T switch_caller_extension -T switch_caller_application -T switch_event_handler_table -T switch_timer -T switch_codec -T switch_core_thread_session -T switch_codec_implementation -T switch_io_event_hook_outgoing_channel -T switch_io_event_hook_answer_channel -T switch_io_event_hook_receive_message -T switch_io_event_hook_read_frame -T switch_io_event_hook_write_frame -T switch_io_event_hook_kill_channel -T switch_io_event_hook_waitfor_read -T switch_io_event_hook_waitfor_write -T switch_io_event_hook_send_dtmf -T switch_io_routines -T switch_io_event_hooks -T switch_buffer -T switch_codec_settings -T switch_config -T switch_lock_flag -T switch_core_session_message_t -T switch_stack_t -T switch_status -T switch_text_channel -T switch_channel_state -T switch_channel_flag -T switch_signal -T switch_codec_flag -T switch_codec_type -T switch_timer_flag -T switch_file_flag -T switch_io_flag -T switch_event_t
|
25
AUTHORS
25
AUTHORS
|
@ -1,25 +0,0 @@
|
|||
The Initial Developer of the Original Code is
|
||||
Anthony Minessale II <anthmct@yahoo.com>
|
||||
Portions created by the Initial Developer are Copyright (C)
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
The PRIMARY AUTHORS are (and/or have been):
|
||||
|
||||
Anthony Minessale II <anthmct@yahoo.com> - Primary developer of all core components
|
||||
and many of the included modules. Much of freeswitch is based on his work.
|
||||
|
||||
Michael Jerris <mike@jerris.com> - Windows porter and responsible for the
|
||||
windows\msvc build system.
|
||||
|
||||
|
||||
And here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
|
||||
people who have submitted patches, reported bugs, and generally made Freeswitch
|
||||
that much better:
|
||||
|
||||
Joshua Colp - For his help making mod_exosip possible, and for just being a swell guy!
|
||||
Brian K. West - For countless hours of work on BSD and Mac support, finding countless bugs,
|
||||
and moral support.
|
||||
|
||||
A big THANK YOU goes to:
|
||||
|
||||
|
715
COPYING
715
COPYING
|
@ -1,471 +1,340 @@
|
|||
MOZILLA PUBLIC LICENSE
|
||||
Version 1.1
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
---------------
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
1. Definitions.
|
||||
Preamble
|
||||
|
||||
1.0.1. "Commercial Use" means distribution or otherwise making the
|
||||
Covered Code available to a third party.
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
1.1. "Contributor" means each entity that creates or contributes to
|
||||
the creation of Modifications.
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
1.2. "Contributor Version" means the combination of the Original
|
||||
Code, prior Modifications used by a Contributor, and the Modifications
|
||||
made by that particular Contributor.
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
1.3. "Covered Code" means the Original Code or Modifications or the
|
||||
combination of the Original Code and Modifications, in each case
|
||||
including portions thereof.
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
1.4. "Electronic Distribution Mechanism" means a mechanism generally
|
||||
accepted in the software development community for the electronic
|
||||
transfer of data.
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
1.5. "Executable" means Covered Code in any form other than Source
|
||||
Code.
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
1.6. "Initial Developer" means the individual or entity identified
|
||||
as the Initial Developer in the Source Code notice required by Exhibit
|
||||
A.
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
1.7. "Larger Work" means a work which combines Covered Code or
|
||||
portions thereof with code not governed by the terms of this License.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
1.8. "License" means this document.
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
1.8.1. "Licensable" means having the right to grant, to the maximum
|
||||
extent possible, whether at the time of the initial grant or
|
||||
subsequently acquired, any and all of the rights conveyed herein.
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1.9. "Modifications" means any addition to or deletion from the
|
||||
substance or structure of either the Original Code or any previous
|
||||
Modifications. When Covered Code is released as a series of files, a
|
||||
Modification is:
|
||||
A. Any addition to or deletion from the contents of a file
|
||||
containing Original Code or previous Modifications.
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
B. Any new file that contains any part of the Original Code or
|
||||
previous Modifications.
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
1.10. "Original Code" means Source Code of computer software code
|
||||
which is described in the Source Code notice required by Exhibit A as
|
||||
Original Code, and which, at the time of its release under this
|
||||
License is not already Covered Code governed by this License.
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
1.10.1. "Patent Claims" means any patent claim(s), now owned or
|
||||
hereafter acquired, including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by grantor.
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
1.11. "Source Code" means the preferred form of the Covered Code for
|
||||
making modifications to it, including all modules it contains, plus
|
||||
any associated interface definition files, scripts used to control
|
||||
compilation and installation of an Executable, or source code
|
||||
differential comparisons against either the Original Code or another
|
||||
well known, available Covered Code of the Contributor's choice. The
|
||||
Source Code can be in a compressed or archival form, provided the
|
||||
appropriate decompression or de-archiving software is widely available
|
||||
for no charge.
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
1.12. "You" (or "Your") means an individual or a legal entity
|
||||
exercising rights under, and complying with all of the terms of, this
|
||||
License or a future version of this License issued under Section 6.1.
|
||||
For legal entities, "You" includes any entity which controls, is
|
||||
controlled by, or is under common control with You. For purposes of
|
||||
this definition, "control" means (a) the power, direct or indirect,
|
||||
to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (b) ownership of more than fifty percent
|
||||
(50%) of the outstanding shares or beneficial ownership of such
|
||||
entity.
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
2. Source Code License.
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
2.1. The Initial Developer Grant.
|
||||
The Initial Developer hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license, subject to third party intellectual property
|
||||
claims:
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Initial Developer to use, reproduce,
|
||||
modify, display, perform, sublicense and distribute the Original
|
||||
Code (or portions thereof) with or without Modifications, and/or
|
||||
as part of a Larger Work; and
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
(b) under Patents Claims infringed by the making, using or
|
||||
selling of Original Code, to make, have made, use, practice,
|
||||
sell, and offer for sale, and/or otherwise dispose of the
|
||||
Original Code (or portions thereof).
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
(c) the licenses granted in this Section 2.1(a) and (b) are
|
||||
effective on the date Initial Developer first distributes
|
||||
Original Code under the terms of this License.
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
(d) Notwithstanding Section 2.1(b) above, no patent license is
|
||||
granted: 1) for code that You delete from the Original Code; 2)
|
||||
separate from the Original Code; or 3) for infringements caused
|
||||
by: i) the modification of the Original Code or ii) the
|
||||
combination of the Original Code with other software or devices.
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
2.2. Contributor Grant.
|
||||
Subject to third party intellectual property claims, each Contributor
|
||||
hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Contributor, to use, reproduce, modify,
|
||||
display, perform, sublicense and distribute the Modifications
|
||||
created by such Contributor (or portions thereof) either on an
|
||||
unmodified basis, with other Modifications, as Covered Code
|
||||
and/or as part of a Larger Work; and
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
(b) under Patent Claims infringed by the making, using, or
|
||||
selling of Modifications made by that Contributor either alone
|
||||
and/or in combination with its Contributor Version (or portions
|
||||
of such combination), to make, use, sell, offer for sale, have
|
||||
made, and/or otherwise dispose of: 1) Modifications made by that
|
||||
Contributor (or portions thereof); and 2) the combination of
|
||||
Modifications made by that Contributor with its Contributor
|
||||
Version (or portions of such combination).
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
|
||||
effective on the date Contributor first makes Commercial Use of
|
||||
the Covered Code.
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
(d) Notwithstanding Section 2.2(b) above, no patent license is
|
||||
granted: 1) for any code that Contributor has deleted from the
|
||||
Contributor Version; 2) separate from the Contributor Version;
|
||||
3) for infringements caused by: i) third party modifications of
|
||||
Contributor Version or ii) the combination of Modifications made
|
||||
by that Contributor with other software (except as part of the
|
||||
Contributor Version) or other devices; or 4) under Patent Claims
|
||||
infringed by Covered Code in the absence of Modifications made by
|
||||
that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Application of License.
|
||||
The Modifications which You create or to which You contribute are
|
||||
governed by the terms of this License, including without limitation
|
||||
Section 2.2. The Source Code version of Covered Code may be
|
||||
distributed only under the terms of this License or a future version
|
||||
of this License released under Section 6.1, and You must include a
|
||||
copy of this License with every copy of the Source Code You
|
||||
distribute. You may not offer or impose any terms on any Source Code
|
||||
version that alters or restricts the applicable version of this
|
||||
License or the recipients' rights hereunder. However, You may include
|
||||
an additional document offering the additional rights described in
|
||||
Section 3.5.
|
||||
|
||||
3.2. Availability of Source Code.
|
||||
Any Modification which You create or to which You contribute must be
|
||||
made available in Source Code form under the terms of this License
|
||||
either on the same media as an Executable version or via an accepted
|
||||
Electronic Distribution Mechanism to anyone to whom you made an
|
||||
Executable version available; and if made available via Electronic
|
||||
Distribution Mechanism, must remain available for at least twelve (12)
|
||||
months after the date it initially became available, or at least six
|
||||
(6) months after a subsequent version of that particular Modification
|
||||
has been made available to such recipients. You are responsible for
|
||||
ensuring that the Source Code version remains available even if the
|
||||
Electronic Distribution Mechanism is maintained by a third party.
|
||||
|
||||
3.3. Description of Modifications.
|
||||
You must cause all Covered Code to which You contribute to contain a
|
||||
file documenting the changes You made to create that Covered Code and
|
||||
the date of any change. You must include a prominent statement that
|
||||
the Modification is derived, directly or indirectly, from Original
|
||||
Code provided by the Initial Developer and including the name of the
|
||||
Initial Developer in (a) the Source Code, and (b) in any notice in an
|
||||
Executable version or related documentation in which You describe the
|
||||
origin or ownership of the Covered Code.
|
||||
|
||||
3.4. Intellectual Property Matters
|
||||
(a) Third Party Claims.
|
||||
If Contributor has knowledge that a license under a third party's
|
||||
intellectual property rights is required to exercise the rights
|
||||
granted by such Contributor under Sections 2.1 or 2.2,
|
||||
Contributor must include a text file with the Source Code
|
||||
distribution titled "LEGAL" which describes the claim and the
|
||||
party making the claim in sufficient detail that a recipient will
|
||||
know whom to contact. If Contributor obtains such knowledge after
|
||||
the Modification is made available as described in Section 3.2,
|
||||
Contributor shall promptly modify the LEGAL file in all copies
|
||||
Contributor makes available thereafter and shall take other steps
|
||||
(such as notifying appropriate mailing lists or newsgroups)
|
||||
reasonably calculated to inform those who received the Covered
|
||||
Code that new knowledge has been obtained.
|
||||
|
||||
(b) Contributor APIs.
|
||||
If Contributor's Modifications include an application programming
|
||||
interface and Contributor has knowledge of patent licenses which
|
||||
are reasonably necessary to implement that API, Contributor must
|
||||
also include this information in the LEGAL file.
|
||||
|
||||
(c) Representations.
|
||||
Contributor represents that, except as disclosed pursuant to
|
||||
Section 3.4(a) above, Contributor believes that Contributor's
|
||||
Modifications are Contributor's original creation(s) and/or
|
||||
Contributor has sufficient rights to grant the rights conveyed by
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
3.5. Required Notices.
|
||||
You must duplicate the notice in Exhibit A in each file of the Source
|
||||
Code. If it is not possible to put such notice in a particular Source
|
||||
Code file due to its structure, then You must include such notice in a
|
||||
location (such as a relevant directory) where a user would be likely
|
||||
to look for such a notice. If You created one or more Modification(s)
|
||||
You may add your name as a Contributor to the notice described in
|
||||
Exhibit A. You must also duplicate this License in any documentation
|
||||
for the Source Code where You describe recipients' rights or ownership
|
||||
rights relating to Covered Code. You may choose to offer, and to
|
||||
charge a fee for, warranty, support, indemnity or liability
|
||||
obligations to one or more recipients of Covered Code. However, You
|
||||
may do so only on Your own behalf, and not on behalf of the Initial
|
||||
Developer or any Contributor. You must make it absolutely clear than
|
||||
any such warranty, support, indemnity or liability obligation is
|
||||
offered by You alone, and You hereby agree to indemnify the Initial
|
||||
Developer and every Contributor for any liability incurred by the
|
||||
Initial Developer or such Contributor as a result of warranty,
|
||||
support, indemnity or liability terms You offer.
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
3.6. Distribution of Executable Versions.
|
||||
You may distribute Covered Code in Executable form only if the
|
||||
requirements of Section 3.1-3.5 have been met for that Covered Code,
|
||||
and if You include a notice stating that the Source Code version of
|
||||
the Covered Code is available under the terms of this License,
|
||||
including a description of how and where You have fulfilled the
|
||||
obligations of Section 3.2. The notice must be conspicuously included
|
||||
in any notice in an Executable version, related documentation or
|
||||
collateral in which You describe recipients' rights relating to the
|
||||
Covered Code. You may distribute the Executable version of Covered
|
||||
Code or ownership rights under a license of Your choice, which may
|
||||
contain terms different from this License, provided that You are in
|
||||
compliance with the terms of this License and that the license for the
|
||||
Executable version does not attempt to limit or alter the recipient's
|
||||
rights in the Source Code version from the rights set forth in this
|
||||
License. If You distribute the Executable version under a different
|
||||
license You must make it absolutely clear that any terms which differ
|
||||
from this License are offered by You alone, not by the Initial
|
||||
Developer or any Contributor. You hereby agree to indemnify the
|
||||
Initial Developer and every Contributor for any liability incurred by
|
||||
the Initial Developer or such Contributor as a result of any such
|
||||
terms You offer.
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
3.7. Larger Works.
|
||||
You may create a Larger Work by combining Covered Code with other code
|
||||
not governed by the terms of this License and distribute the Larger
|
||||
Work as a single product. In such a case, You must make sure the
|
||||
requirements of this License are fulfilled for the Covered Code.
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation.
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Code due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description
|
||||
must be included in the LEGAL file described in Section 3.4 and must
|
||||
be included with all distributions of the Source Code. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
5. Application of this License.
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
This License applies to code to which the Initial Developer has
|
||||
attached the notice in Exhibit A and to related Covered Code.
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
6. Versions of the License.
|
||||
NO WARRANTY
|
||||
|
||||
6.1. New Versions.
|
||||
Netscape Communications Corporation ("Netscape") may publish revised
|
||||
and/or new versions of the License from time to time. Each version
|
||||
will be given a distinguishing version number.
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
6.2. Effect of New Versions.
|
||||
Once Covered Code has been published under a particular version of the
|
||||
License, You may always continue to use it under the terms of that
|
||||
version. You may also choose to use such Covered Code under the terms
|
||||
of any subsequent version of the License published by Netscape. No one
|
||||
other than Netscape has the right to modify the terms applicable to
|
||||
Covered Code created under this License.
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
6.3. Derivative Works.
|
||||
If You create or use a modified version of this License (which you may
|
||||
only do in order to apply it to code which is not already Covered Code
|
||||
governed by this License), You must (a) rename Your license so that
|
||||
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
|
||||
"MPL", "NPL" or any confusingly similar phrase do not appear in your
|
||||
license (except to note that your license differs from this License)
|
||||
and (b) otherwise make it clear that Your version of the license
|
||||
contains terms which differ from the Mozilla Public License and
|
||||
Netscape Public License. (Filling in the name of the Initial
|
||||
Developer, Original Code or Contributor in the notice described in
|
||||
Exhibit A shall not of themselves be deemed to be modifications of
|
||||
this License.)
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
7. DISCLAIMER OF WARRANTY.
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
|
||||
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
|
||||
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
|
||||
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
|
||||
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
|
||||
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
8. TERMINATION.
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
8.1. This License and the rights granted hereunder will terminate
|
||||
automatically if You fail to comply with terms herein and fail to cure
|
||||
such breach within 30 days of becoming aware of the breach. All
|
||||
sublicenses to the Covered Code which are properly granted shall
|
||||
survive any termination of this License. Provisions which, by their
|
||||
nature, must remain in effect beyond the termination of this License
|
||||
shall survive.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
8.2. If You initiate litigation by asserting a patent infringement
|
||||
claim (excluding declatory judgment actions) against Initial Developer
|
||||
or a Contributor (the Initial Developer or Contributor against whom
|
||||
You file such action is referred to as "Participant") alleging that:
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
(a) such Participant's Contributor Version directly or indirectly
|
||||
infringes any patent, then any and all rights granted by such
|
||||
Participant to You under Sections 2.1 and/or 2.2 of this License
|
||||
shall, upon 60 days notice from Participant terminate prospectively,
|
||||
unless if within 60 days after receipt of notice You either: (i)
|
||||
agree in writing to pay Participant a mutually agreeable reasonable
|
||||
royalty for Your past and future use of Modifications made by such
|
||||
Participant, or (ii) withdraw Your litigation claim with respect to
|
||||
the Contributor Version against such Participant. If within 60 days
|
||||
of notice, a reasonable royalty and payment arrangement are not
|
||||
mutually agreed upon in writing by the parties or the litigation claim
|
||||
is not withdrawn, the rights granted by Participant to You under
|
||||
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
|
||||
the 60 day notice period specified above.
|
||||
|
||||
(b) any software, hardware, or device, other than such Participant's
|
||||
Contributor Version, directly or indirectly infringes any patent, then
|
||||
any rights granted to You by such Participant under Sections 2.1(b)
|
||||
and 2.2(b) are revoked effective as of the date You first made, used,
|
||||
sold, distributed, or had made, Modifications made by that
|
||||
Participant.
|
||||
|
||||
8.3. If You assert a patent infringement claim against Participant
|
||||
alleging that such Participant's Contributor Version directly or
|
||||
indirectly infringes any patent where such claim is resolved (such as
|
||||
by license or settlement) prior to the initiation of patent
|
||||
infringement litigation, then the reasonable value of the licenses
|
||||
granted by such Participant under Sections 2.1 or 2.2 shall be taken
|
||||
into account in determining the amount or value of any payment or
|
||||
license.
|
||||
|
||||
8.4. In the event of termination under Sections 8.1 or 8.2 above,
|
||||
all end user license agreements (excluding distributors and resellers)
|
||||
which have been validly granted by You or any distributor hereunder
|
||||
prior to termination shall survive termination.
|
||||
|
||||
9. LIMITATION OF LIABILITY.
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
|
||||
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
|
||||
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
|
||||
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
|
||||
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
|
||||
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
|
||||
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
|
||||
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
|
||||
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
|
||||
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
|
||||
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
|
||||
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
10. U.S. GOVERNMENT END USERS.
|
||||
|
||||
The Covered Code is a "commercial item," as that term is defined in
|
||||
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
|
||||
software" and "commercial computer software documentation," as such
|
||||
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
|
||||
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
|
||||
all U.S. Government End Users acquire Covered Code with only those
|
||||
rights set forth herein.
|
||||
|
||||
11. MISCELLANEOUS.
|
||||
|
||||
This License represents the complete agreement concerning subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. This License shall be governed by
|
||||
California law provisions (except to the extent applicable law, if
|
||||
any, provides otherwise), excluding its conflict-of-law provisions.
|
||||
With respect to disputes in which at least one party is a citizen of,
|
||||
or an entity chartered or registered to do business in the United
|
||||
States of America, any litigation relating to this License shall be
|
||||
subject to the jurisdiction of the Federal Courts of the Northern
|
||||
District of California, with venue lying in Santa Clara County,
|
||||
California, with the losing party responsible for costs, including
|
||||
without limitation, court costs and reasonable attorneys' fees and
|
||||
expenses. The application of the United Nations Convention on
|
||||
Contracts for the International Sale of Goods is expressly excluded.
|
||||
Any law or regulation which provides that the language of a contract
|
||||
shall be construed against the drafter shall not apply to this
|
||||
License.
|
||||
|
||||
12. RESPONSIBILITY FOR CLAIMS.
|
||||
|
||||
As between Initial Developer and the Contributors, each party is
|
||||
responsible for claims and damages arising, directly or indirectly,
|
||||
out of its utilization of rights under this License and You agree to
|
||||
work with Initial Developer and Contributors to distribute such
|
||||
responsibility on an equitable basis. Nothing herein is intended or
|
||||
shall be deemed to constitute any admission of liability.
|
||||
|
||||
13. MULTIPLE-LICENSED CODE.
|
||||
|
||||
Initial Developer may designate portions of the Covered Code as
|
||||
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
|
||||
Developer permits you to utilize portions of the Covered Code under
|
||||
Your choice of the NPL or the alternative licenses, if any, specified
|
||||
by the Initial Developer in the file described in Exhibit A.
|
||||
|
||||
EXHIBIT A -Mozilla Public License.
|
||||
|
||||
``The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is ______________________________________.
|
||||
|
||||
The Initial Developer of the Original Code is ________________________.
|
||||
Portions created by ______________________ are Copyright (C) ______
|
||||
_______________________. All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the _____ license (the "[___] License"), in which case the
|
||||
provisions of [______] License are applicable instead of those
|
||||
above. If you wish to allow use of your version of this file only
|
||||
under the terms of the [____] License and not to allow others to use
|
||||
your version of this file under the MPL, indicate your decision by
|
||||
deleting the provisions above and replace them with the notice and
|
||||
other provisions required by the [___] License. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file
|
||||
under either the MPL or the [___] License."
|
||||
|
||||
[NOTE: The text of this Exhibit A may differ slightly from the text of
|
||||
the notices in the Source Code files of the Original Code. You should
|
||||
use the text of this Exhibit A rather than the text found in the
|
||||
Original Code Source Code for Your Modifications.]
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
|
12
INSTALL
12
INSTALL
|
@ -25,15 +25,3 @@ UNIX:
|
|||
|
||||
Windows 32:
|
||||
|
||||
Requires: Microsoft Visual Studio 2005 or
|
||||
Visual C++ 2005 Express Edition and Platform SDK
|
||||
Internet connectivity to download dependency libraries
|
||||
|
||||
1) Open /w32/vsnet/Freeswitch.sln
|
||||
|
||||
2) Choose Release or Debug build
|
||||
|
||||
3) Build solution or your choice of modules using the ide.
|
||||
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ IGNORE_PREFIX = switch_
|
|||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
|
@ -68,7 +68,7 @@ GENERATE_DEPRECATEDLIST= YES
|
|||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
|
@ -125,8 +125,8 @@ FILTER_SOURCE_FILES = NO
|
|||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = YES
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
|
@ -149,9 +149,9 @@ HTML_FOOTER =
|
|||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE = freeswitch.chm
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = YES
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
|
@ -186,14 +186,14 @@ RTF_EXTENSIONS_FILE =
|
|||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = YES
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = YES
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
|
@ -205,7 +205,7 @@ GENERATE_AUTOGEN_DEF = NO
|
|||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = YES
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l120 -cs -T size_t " > .indent.pro
|
||||
grep typedef src/include/*.h | grep switch_ | grep -v "\*\|{" | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> .indent.pro
|
||||
grep "} switch_" src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> .indent.pro
|
|
@ -82,8 +82,7 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
|
|||
switch_core_session_send_dtmf(session_b, dtmf);
|
||||
}
|
||||
|
||||
if (switch_core_session_read_frame(session_a, &read_frame, -1, stream_id) == SWITCH_STATUS_SUCCESS
|
||||
&& read_frame->datalen) {
|
||||
if (switch_core_session_read_frame(session_a, &read_frame, -1, stream_id) == SWITCH_STATUS_SUCCESS && read_frame->datalen) {
|
||||
if (switch_core_session_write_frame(session_b, read_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "write: Bad Frame.... Bubye!\n");
|
||||
data->running = -1;
|
||||
|
@ -116,8 +115,7 @@ static switch_status audio_bridge_on_hangup(switch_core_session *session)
|
|||
other_channel = switch_core_session_get_channel(other_session);
|
||||
assert(other_channel != NULL);
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "CUSTOM HANGUP %s kill %s\n", switch_channel_get_name(channel),
|
||||
switch_channel_get_name(other_channel));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "CUSTOM HANGUP %s kill %s\n", switch_channel_get_name(channel), switch_channel_get_name(other_channel));
|
||||
|
||||
switch_core_session_kill_channel(other_session, SWITCH_SIG_KILL);
|
||||
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
|
||||
|
@ -185,12 +183,14 @@ static void audio_bridge_function(switch_core_session *session, char *data)
|
|||
caller_caller_profile->dialplan,
|
||||
caller_caller_profile->caller_id_name,
|
||||
caller_caller_profile->caller_id_number,
|
||||
caller_caller_profile->network_addr, NULL, NULL, chan_data);
|
||||
caller_caller_profile->network_addr,
|
||||
NULL,
|
||||
NULL,
|
||||
chan_data);
|
||||
|
||||
|
||||
|
||||
if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DOH!\n");
|
||||
switch_channel_hangup(caller_channel);
|
||||
return;
|
||||
|
@ -230,7 +230,8 @@ static void audio_bridge_function(switch_core_session *session, char *data)
|
|||
time(&start);
|
||||
while(switch_channel_get_state(caller_channel) == CS_EXECUTE &&
|
||||
switch_channel_get_state(peer_channel) == CS_TRANSMIT &&
|
||||
!switch_channel_test_flag(peer_channel, CF_ANSWERED) && ((time(NULL) - start) < timelimit)) {
|
||||
!switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
|
||||
((time(NULL) - start) < timelimit)) {
|
||||
switch_yield(20000);
|
||||
}
|
||||
|
||||
|
@ -272,8 +273,7 @@ static const switch_loadable_module_interface mod_bridgecall_module_interface =
|
|||
/*.application_interface*/ &bridge_application_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &mod_bridgecall_module_interface;
|
||||
|
|
|
@ -86,12 +86,12 @@ void playback_function(switch_core_session *session, char *data)
|
|||
interval,
|
||||
fh.channels,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
|
||||
write_frame.codec = &codec;
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activation Failed %s@%dhz %d channels %dms\n",
|
||||
codec_name, fh.samplerate, fh.channels, interval);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activation Failed %s@%dhz %d channels %dms\n", codec_name, fh.samplerate, fh.channels, interval);
|
||||
switch_core_file_close(&fh);
|
||||
switch_channel_hangup(channel);
|
||||
return;
|
||||
|
@ -191,8 +191,7 @@ static const switch_loadable_module_interface mod_playback_module_interface = {
|
|||
/*.application_interface*/ &playback_application_interface
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &mod_playback_module_interface;
|
||||
|
@ -208,3 +207,7 @@ if it returns anything but SWITCH_STATUS_TERM it will be called again automaticl
|
|||
|
||||
|
||||
//switch_status switch_module_runtime(void)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ static switch_loadable_module_interface skel_module_interface = {
|
|||
/*.application_interface*/ NULL
|
||||
};
|
||||
|
||||
switch_status switch_module_load(switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
switch_status switch_module_load(switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &skel_module_interface;
|
||||
|
||||
|
@ -52,3 +51,4 @@ switch_status switch_module_load(switch_loadable_module_interface **interface, c
|
|||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,9 @@
|
|||
#define SEG_MASK (0x70) /* Segment field mask. */
|
||||
|
||||
static short seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
|
||||
0x1FF, 0x3FF, 0x7FF, 0xFFF
|
||||
};
|
||||
0x1FF, 0x3FF, 0x7FF, 0xFFF};
|
||||
static short seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
|
||||
0x3FF, 0x7FF, 0xFFF, 0x1FFF
|
||||
};
|
||||
0x3FF, 0x7FF, 0xFFF, 0x1FFF};
|
||||
|
||||
/* copy from CCITT G.711 specifications */
|
||||
unsigned char _u2a[128] = { /* u- to A-law conversions */
|
||||
|
@ -78,8 +76,7 @@ unsigned char _u2a[128] = { /* u- to A-law conversions */
|
|||
97, 98, 99, 100, 101, 102, 103, 104,
|
||||
105, 106, 107, 108, 109, 110, 111, 112,
|
||||
113, 114, 115, 116, 117, 118, 119, 120,
|
||||
121, 122, 123, 124, 125, 126, 127, 128
|
||||
};
|
||||
121, 122, 123, 124, 125, 126, 127, 128};
|
||||
|
||||
unsigned char _a2u[128] = { /* A- to u-law conversions */
|
||||
1, 3, 5, 7, 9, 11, 13, 15,
|
||||
|
@ -100,10 +97,12 @@ unsigned char _a2u[128] = { /* A- to u-law conversions */
|
|||
96, 97, 98, 99, 100, 101, 102, 103,
|
||||
104, 105, 106, 107, 108, 109, 110, 111,
|
||||
112, 113, 114, 115, 116, 117, 118, 119,
|
||||
120, 121, 122, 123, 124, 125, 126, 127
|
||||
};
|
||||
120, 121, 122, 123, 124, 125, 126, 127};
|
||||
|
||||
static short search(short val, short *table, short size)
|
||||
static short search(
|
||||
short val,
|
||||
short *table,
|
||||
short size)
|
||||
{
|
||||
short i;
|
||||
|
||||
|
@ -133,8 +132,9 @@ static short search(short val, short *table, short size)
|
|||
* For further information see John C. Bellamy's Digital Telephony, 1982,
|
||||
* John Wiley & Sons, pps 98-111 and 472-476.
|
||||
*/
|
||||
unsigned char linear2alaw(short pcm_val)
|
||||
{ /* 2's complement (16-bit range) */
|
||||
unsigned char
|
||||
linear2alaw(short pcm_val) /* 2's complement (16-bit range) */
|
||||
{
|
||||
short mask;
|
||||
short seg;
|
||||
unsigned char aval;
|
||||
|
@ -169,7 +169,9 @@ unsigned char linear2alaw(short pcm_val)
|
|||
* alaw2linear() - Convert an A-law value to 16-bit linear PCM
|
||||
*
|
||||
*/
|
||||
short alaw2linear(unsigned char a_val)
|
||||
short
|
||||
alaw2linear(
|
||||
unsigned char a_val)
|
||||
{
|
||||
short t;
|
||||
short seg;
|
||||
|
@ -224,8 +226,10 @@ short alaw2linear(unsigned char a_val)
|
|||
* For further information see John C. Bellamy's Digital Telephony, 1982,
|
||||
* John Wiley & Sons, pps 98-111 and 472-476.
|
||||
*/
|
||||
unsigned char linear2ulaw(short pcm_val)
|
||||
{ /* 2's complement (16-bit range) */
|
||||
unsigned char
|
||||
linear2ulaw(
|
||||
short pcm_val) /* 2's complement (16-bit range) */
|
||||
{
|
||||
short mask;
|
||||
short seg;
|
||||
unsigned char uval;
|
||||
|
@ -238,8 +242,7 @@ unsigned char linear2ulaw(short pcm_val)
|
|||
} else {
|
||||
mask = 0xFF;
|
||||
}
|
||||
if (pcm_val > CLIP)
|
||||
pcm_val = CLIP; /* clip the magnitude */
|
||||
if ( pcm_val > CLIP ) pcm_val = CLIP; /* clip the magnitude */
|
||||
pcm_val += (BIAS >> 2);
|
||||
|
||||
/* Convert the scaled magnitude to segment number. */
|
||||
|
@ -267,7 +270,9 @@ unsigned char linear2ulaw(short pcm_val)
|
|||
* Note that this function expects to be passed the complement of the
|
||||
* original code word. This is in keeping with ISDN conventions.
|
||||
*/
|
||||
short ulaw2linear(unsigned char u_val)
|
||||
short
|
||||
ulaw2linear(
|
||||
unsigned char u_val)
|
||||
{
|
||||
short t;
|
||||
|
||||
|
@ -285,17 +290,23 @@ short ulaw2linear(unsigned char u_val)
|
|||
}
|
||||
|
||||
/* A-law to u-law conversion */
|
||||
unsigned char alaw2ulaw(unsigned char aval)
|
||||
unsigned char
|
||||
alaw2ulaw(
|
||||
unsigned char aval)
|
||||
{
|
||||
aval &= 0xff;
|
||||
return (unsigned char) ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) : (0x7F ^ _a2u[aval ^ 0x55]));
|
||||
return (unsigned char) ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
|
||||
(0x7F ^ _a2u[aval ^ 0x55]));
|
||||
}
|
||||
|
||||
/* u-law to A-law conversion */
|
||||
unsigned char ulaw2alaw(unsigned char uval)
|
||||
unsigned char
|
||||
ulaw2alaw(
|
||||
unsigned char uval)
|
||||
{
|
||||
uval &= 0xff;
|
||||
return (unsigned char) ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) : (0x55 ^ (_u2a[0x7F ^ uval] - 1)));
|
||||
return (unsigned char) ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
|
||||
(0x55 ^ (_u2a[0x7F ^ uval] - 1)));
|
||||
}
|
||||
|
||||
/* ---------- end of g711.c ----------------------------------------------------- */
|
||||
|
|
|
@ -36,8 +36,7 @@
|
|||
static const char modname[] = "mod_g711codec";
|
||||
|
||||
|
||||
static switch_status switch_g711u_init(switch_codec *codec, switch_codec_flag flags,
|
||||
const struct switch_codec_settings *codec_settings)
|
||||
static switch_status switch_g711u_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
|
@ -58,7 +57,9 @@ static switch_status switch_g711u_encode(switch_codec *codec,
|
|||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
|
@ -82,7 +83,9 @@ static switch_status switch_g711u_decode(switch_codec *codec,
|
|||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
|
@ -111,8 +114,7 @@ static switch_status switch_g711u_destroy(switch_codec *codec)
|
|||
}
|
||||
|
||||
|
||||
static switch_status switch_g711a_init(switch_codec *codec, switch_codec_flag flags,
|
||||
const struct switch_codec_settings *codec_settings)
|
||||
static switch_status switch_g711a_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
|
||||
|
@ -133,7 +135,9 @@ static switch_status switch_g711a_encode(switch_codec *codec,
|
|||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
|
@ -157,7 +161,9 @@ static switch_status switch_g711a_decode(switch_codec *codec,
|
|||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
short *dbuf;
|
||||
unsigned char *ebuf;
|
||||
|
@ -300,11 +306,15 @@ static switch_loadable_module_interface g711_module_interface = {
|
|||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &g711_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -31,18 +31,22 @@
|
|||
*/
|
||||
#include "switch.h"
|
||||
#include "g729.h"
|
||||
|
||||
static const char modname[] = "mod_codec_g729";
|
||||
|
||||
struct g729_context {
|
||||
struct dec_state decoder_object;
|
||||
struct cod_state encoder_object;
|
||||
};
|
||||
static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag flags,
|
||||
const struct switch_codec_settings *codec_settings)
|
||||
|
||||
static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
struct g729_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
|
||||
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
|
||||
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g729_context))))) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
|
@ -52,21 +56,33 @@
|
|||
if (decoding) {
|
||||
g729_init_decoder(&context->decoder_object);
|
||||
}
|
||||
|
||||
codec->private = context;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static switch_status switch_g729_destroy(switch_codec *codec)
|
||||
{
|
||||
codec->private = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status switch_g729_encode(switch_codec *codec,
switch_codec *other_codec,
void *decoded_data,
|
||||
size_t decoded_data_len,
int decoded_rate,
void *encoded_data,
|
||||
size_t *encoded_data_len,
int *encoded_rate,
unsigned int *flag)
|
||||
|
||||
|
||||
static switch_status switch_g729_encode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *decoded_data,
|
||||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct g729_context *context = codec->private;
|
||||
int cbret = 0;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
@ -76,6 +92,7 @@
|
|||
char *edp = encoded_data;
|
||||
int x;
|
||||
int loops = (int) decoded_data_len / 160;
|
||||
|
||||
for(x = 0; x < loops && new_len < *encoded_data_len; x++) {
|
||||
g729_coder(&context->encoder_object, ddp, edp, &cbret);
|
||||
edp += 10;
|
||||
|
@ -91,14 +108,25 @@
|
|||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status switch_g729_decode(switch_codec *codec,
switch_codec *other_codec,
void *encoded_data,
|
||||
size_t encoded_data_len,
int encoded_rate,
void *decoded_data,
|
||||
size_t *decoded_data_len,
int *decoded_rate,
unsigned int *flag)
|
||||
|
||||
|
||||
static switch_status switch_g729_decode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *encoded_data,
|
||||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct g729_context *context = codec->private;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (encoded_data_len % 10 == 0) {
|
||||
int loops = (int) encoded_data_len / 10;
|
||||
char *edp = encoded_data;
|
||||
|
@ -120,11 +148,13 @@
|
|||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation g729_8k_implementation = {
|
||||
/*.samples_per_second*/ 8000,
|
||||
/*.bits_per_second*/ 64000,
|
||||
|
@ -140,6 +170,7 @@
|
|||
/*.decode*/ switch_g729_decode,
|
||||
/*.destroy*/ switch_g729_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_interface g729_codec_interface = {
|
||||
/*.interface_name*/ "g729",
|
||||
/*.codec_type*/ SWITCH_CODEC_TYPE_AUDIO,
|
||||
|
@ -147,6 +178,7 @@
|
|||
/*.iananame*/ "G729",
|
||||
/*.implementations*/ &g729_8k_implementation,
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface g729_module_interface = {
|
||||
/*.module_name*/ modname,
|
||||
/*.endpoint_interface*/ NULL,
|
||||
|
@ -155,10 +187,9 @@
|
|||
/*.codec_interface*/ &g729_codec_interface,
|
||||
/*.application_interface*/ NULL
|
||||
};
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
|
||||
char *filename)
|
||||
{
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &g729_module_interface;
|
||||
|
||||
|
@ -167,3 +198,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -31,48 +31,63 @@
|
|||
*/
|
||||
#include "switch.h"
|
||||
#include "gsm.h"
|
||||
|
||||
static const char modname[] = "mod_codec_gsm";
|
||||
|
||||
struct gsm_context {
|
||||
gsm encoder;
|
||||
gsm decoder;
|
||||
};
|
||||
static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags,
|
||||
const struct switch_codec_settings *codec_settings)
|
||||
|
||||
static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
struct gsm_context *context;
|
||||
int encoding, decoding;
|
||||
|
||||
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
|
||||
if (!(encoding || decoding)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
context = switch_core_alloc(codec->memory_pool, sizeof(*context));
|
||||
if (encoding)
|
||||
context->encoder = gsm_create();
|
||||
if (decoding)
|
||||
context->decoder = gsm_create();
|
||||
if (encoding) context->encoder = gsm_create();
|
||||
if (decoding) context->decoder = gsm_create();
|
||||
}
|
||||
|
||||
codec->private = context;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
static switch_status switch_gsm_destroy(switch_codec *codec)
|
||||
{
|
||||
struct gsm_context *context = codec->private;
|
||||
int encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
int decoding = (codec->flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
if (encoding)
|
||||
gsm_destroy(context->encoder);
|
||||
if (decoding)
|
||||
gsm_destroy(context->decoder);
|
||||
|
||||
if (encoding) gsm_destroy(context->encoder);
|
||||
if (decoding) gsm_destroy(context->decoder);
|
||||
|
||||
codec->private = NULL;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status switch_gsm_encode(switch_codec *codec,
switch_codec *other_codec,
void *decoded_data,
|
||||
size_t decoded_data_len,
int decoded_rate,
void *encoded_data,
|
||||
size_t *encoded_data_len,
int *encoded_rate,
unsigned int *flag)
|
||||
|
||||
|
||||
static switch_status switch_gsm_encode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *decoded_data,
|
||||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct gsm_context *context = codec->private;
|
||||
int cbret = 0;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
@ -95,16 +110,28 @@
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
static switch_status switch_gsm_decode(switch_codec *codec,
switch_codec *other_codec,
void *encoded_data,
|
||||
size_t encoded_data_len,
int encoded_rate,
void *decoded_data,
|
||||
size_t *decoded_data_len,
int *decoded_rate,
unsigned int *flag)
|
||||
|
||||
|
||||
static switch_status switch_gsm_decode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *encoded_data,
|
||||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct gsm_context *context = codec->private;
|
||||
|
||||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (encoded_data_len % 33 == 0) {
|
||||
int loops = (int) encoded_data_len / 33;
|
||||
gsm_byte *edp = encoded_data;
|
||||
|
@ -126,11 +153,12 @@
|
|||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Registration */
|
||||
|
||||
static const switch_codec_implementation gsm_8k_implementation = {
|
||||
/*.samples_per_second*/ 8000,
|
||||
/*.bits_per_second*/ 13200,
|
||||
|
@ -146,6 +174,7 @@
|
|||
/*.decode*/ switch_gsm_decode,
|
||||
/*.destroy*/ switch_gsm_destroy,
|
||||
};
|
||||
|
||||
static const switch_codec_interface gsm_codec_interface = {
|
||||
/*.interface_name*/ "gsm",
|
||||
/*.codec_type*/ SWITCH_CODEC_TYPE_AUDIO,
|
||||
|
@ -153,6 +182,7 @@
|
|||
/*.iananame*/ "gsm",
|
||||
/*.implementations*/ &gsm_8k_implementation,
|
||||
};
|
||||
|
||||
static switch_loadable_module_interface gsm_module_interface = {
|
||||
/*.module_name*/ modname,
|
||||
/*.endpoint_interface*/ NULL,
|
||||
|
@ -161,10 +191,9 @@
|
|||
/*.codec_interface*/ &gsm_codec_interface,
|
||||
/*.application_interface*/ NULL
|
||||
};
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
|
||||
char *filename)
|
||||
{
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &gsm_module_interface;
|
||||
|
||||
|
@ -173,3 +202,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
static const char modname[] = "mod_rawaudio";
|
||||
|
||||
|
||||
static switch_status switch_raw_init(switch_codec *codec, switch_codec_flag flags,
|
||||
const struct switch_codec_settings *codec_settings)
|
||||
static switch_status switch_raw_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
int encoding, decoding;
|
||||
struct raw_context *context = NULL;
|
||||
|
@ -57,7 +56,9 @@ static switch_status switch_raw_encode(switch_codec *codec,
|
|||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
|
||||
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.*/
|
||||
|
@ -75,7 +76,9 @@ static switch_status switch_raw_decode(switch_codec *codec,
|
|||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
if (codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||
memcpy(decoded_data, encoded_data, encoded_data_len);
|
||||
|
@ -198,11 +201,15 @@ static switch_loadable_module_interface raw_module_interface = {
|
|||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &raw_module_interface;
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -72,8 +72,7 @@ struct speex_context {
|
|||
int decoder_mode;
|
||||
};
|
||||
|
||||
static switch_status switch_speex_init(switch_codec *codec, switch_codec_flag flags,
|
||||
const struct switch_codec_settings *codec_settings)
|
||||
static switch_status switch_speex_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
|
||||
{
|
||||
struct speex_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
|
@ -111,17 +110,14 @@ static switch_status switch_speex_init(switch_codec *codec, switch_codec_flag fl
|
|||
speex_encoder_ctl(context->encoder_state, SPEEX_GET_FRAME_SIZE, &context->encoder_frame_size);
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_COMPLEXITY, &codec->codec_settings.complexity);
|
||||
if (codec->codec_settings.preproc) {
|
||||
context->pp =
|
||||
speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->samples_per_second);
|
||||
context->pp = speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->samples_per_second);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_VAD, &codec->codec_settings.pp_vad);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC, &codec->codec_settings.pp_agc);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &codec->codec_settings.pp_agc_level);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DENOISE, &codec->codec_settings.pp_denoise);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB, &codec->codec_settings.pp_dereverb);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY,
|
||||
&codec->codec_settings.pp_dereverb_decay);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL,
|
||||
&codec->codec_settings.pp_dereverb_level);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &codec->codec_settings.pp_dereverb_decay);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &codec->codec_settings.pp_dereverb_level);
|
||||
}
|
||||
|
||||
if (!codec->codec_settings.abr && !codec->codec_settings.vbr) {
|
||||
|
@ -163,7 +159,9 @@ static switch_status switch_speex_encode(switch_codec *codec,
|
|||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct speex_context *context = codec->private;
|
||||
short *buf;
|
||||
|
@ -180,8 +178,7 @@ static switch_status switch_speex_encode(switch_codec *codec,
|
|||
}
|
||||
|
||||
if (is_speech) {
|
||||
is_speech = speex_encode_int(context->encoder_state, buf, &context->encoder_bits)
|
||||
|| !context->codec->codec_settings.dtx;
|
||||
is_speech = speex_encode_int(context->encoder_state, buf, &context->encoder_bits) || ! context->codec->codec_settings.dtx;
|
||||
} else {
|
||||
speex_bits_pack(&context->encoder_bits, 0, 5);
|
||||
}
|
||||
|
@ -218,7 +215,9 @@ static switch_status switch_speex_decode(switch_codec *codec,
|
|||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
struct speex_context *context = codec->private;
|
||||
short *buf;
|
||||
|
@ -334,8 +333,7 @@ static switch_loadable_module_interface speex_module_interface = {
|
|||
/*.application_interface*/ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &speex_module_interface;
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
|
|||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
//switch_channel_set_variable(channel, "pleasework", "yay");
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name, caller_profile->destination_number);
|
||||
|
||||
if (!switch_config_open_file(&cfg, cf)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "open of %s failed\n", cf);
|
||||
|
@ -77,10 +76,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
|
|||
continue;
|
||||
}
|
||||
if (!extension) {
|
||||
if (!
|
||||
(extension =
|
||||
switch_caller_extension_new(session, caller_profile->destination_number,
|
||||
caller_profile->destination_number))) {
|
||||
if (!(extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n");
|
||||
break;
|
||||
}
|
||||
|
@ -118,8 +114,7 @@ static const switch_loadable_module_interface demo_dialplan_module_interface = {
|
|||
/*.application_interface =*/ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &demo_dialplan_module_interface;
|
||||
|
|
|
@ -60,8 +60,7 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||
channel = switch_core_session_get_channel(session);
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Processing %s->%s!\n", caller_profile->caller_id_name,
|
||||
caller_profile->destination_number);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Processing %s->%s!\n", caller_profile->caller_id_name, caller_profile->destination_number);
|
||||
|
||||
if (!switch_config_open_file(&cfg, cf)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "open of %s failed\n", cf);
|
||||
|
@ -82,7 +81,8 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||
int erroffset = 0;
|
||||
|
||||
cleanre();
|
||||
re = pcre_compile(val, /* the pattern */
|
||||
re = pcre_compile(
|
||||
val, /* the pattern */
|
||||
0, /* default options */
|
||||
&error, /* for error message */
|
||||
&erroffset, /* for error offset */
|
||||
|
@ -94,7 +94,8 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
match_count = pcre_exec(re, /* result of pcre_compile() */
|
||||
match_count = pcre_exec(
|
||||
re, /* result of pcre_compile() */
|
||||
NULL, /* we didn't study the pattern */
|
||||
caller_profile->destination_number, /* the subject string */
|
||||
strlen(caller_profile->destination_number), /* the length of the subject string */
|
||||
|
@ -104,8 +105,7 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||
sizeof(ovector) / sizeof(ovector[0])); /* number of elements (NOT size in bytes) */
|
||||
} else if (match_count > 0 && !strcasecmp(var, "match")) {
|
||||
if (!re) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "ERROR: match without regex in %s line %d\n", cfg.path,
|
||||
cfg.lineno);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "ERROR: match without regex in %s line %d\n", cfg.path, cfg.lineno);
|
||||
continue;
|
||||
} else {
|
||||
char newval[1024] = "";
|
||||
|
@ -126,9 +126,7 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||
z = 0;
|
||||
num = atoi(index);
|
||||
|
||||
if (pcre_copy_substring
|
||||
(caller_profile->destination_number, ovector, match_count, num, replace,
|
||||
sizeof(replace)) > 0) {
|
||||
if (pcre_copy_substring(caller_profile->destination_number, ovector, match_count, num, replace, sizeof(replace)) > 0) {
|
||||
int r;
|
||||
for(r = 0; r < strlen(replace); r++) {
|
||||
newval[y++] = replace[r];
|
||||
|
@ -154,9 +152,7 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||
|
||||
|
||||
if (!extension) {
|
||||
if (!
|
||||
(extension =
|
||||
switch_caller_extension_new(session, exten_name, caller_profile->destination_number))) {
|
||||
if (!(extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n");
|
||||
break;
|
||||
}
|
||||
|
@ -195,8 +191,7 @@ static const switch_loadable_module_interface dialplan_module_interface = {
|
|||
/*.application_interface =*/ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &dialplan_module_interface;
|
||||
|
|
|
@ -144,12 +144,9 @@ static switch_status exosip_on_init(switch_core_session *session);
|
|||
static switch_status exosip_on_hangup(switch_core_session *session);
|
||||
static switch_status exosip_on_loopback(switch_core_session *session);
|
||||
static switch_status exosip_on_transmit(switch_core_session *session);
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static int config_exosip(int reload);
|
||||
static switch_status parse_sdp_media(sdp_media_t *media, char **dname, char **drate, char **dpayload);
|
||||
static switch_status exosip_kill_channel(switch_core_session *session, int sig);
|
||||
|
@ -248,17 +245,14 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
/* Initialize SDP */
|
||||
sdp_message_init(&tech_pvt->local_sdp);
|
||||
sdp_message_v_version_set(tech_pvt->local_sdp, "0");
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4",
|
||||
tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4", tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
|
||||
sdp_message_c_connection_add(tech_pvt->local_sdp, -1, "IN", "IP4", tech_pvt->local_sdp_audio_ip, NULL, NULL);
|
||||
sdp_message_t_time_descr_add(tech_pvt->local_sdp, "0", "0");
|
||||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
sdp_message_m_media_add(tech_pvt->local_sdp, "audio", port, NULL, "RTP/AVP");
|
||||
/* Add in every codec we support on this outbound call */
|
||||
if ((num_codecs =
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
|
||||
sizeof(codecs) / sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
|
@ -268,12 +262,10 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
|
||||
for (imp = codecs[i]->implementations ; imp ; imp = imp->next) {
|
||||
/* Add to SDP config */
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second, x++);
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second, x++);
|
||||
/* Add to SDP message */
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%i %s/%i", codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second);
|
||||
snprintf(tmp, sizeof(tmp), "%i %s/%i", codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second);
|
||||
sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(tmp));
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
}
|
||||
|
@ -281,9 +273,7 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
}
|
||||
/* Setup our INVITE */
|
||||
eXosip_lock();
|
||||
if (!
|
||||
(dest_uri =
|
||||
(char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
|
||||
if (!(dest_uri = (char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AIEEEE!\n");
|
||||
assert(dest_uri != NULL);
|
||||
}
|
||||
|
@ -356,8 +346,7 @@ static switch_status exosip_on_hangup(switch_core_session *session)
|
|||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel),
|
||||
tech_pvt->cid, tech_pvt->did, i);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel), tech_pvt->cid, tech_pvt->did, i);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -373,16 +362,14 @@ static switch_status exosip_on_transmit(switch_core_session *session)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -470,17 +457,22 @@ static void activate_rtp(struct private_object *tech_pvt)
|
|||
tech_pvt->local_sdp_audio_ip,
|
||||
tech_pvt->local_sdp_audio_port,
|
||||
tech_pvt->remote_sdp_audio_ip,
|
||||
tech_pvt->remote_sdp_audio_port, tech_pvt->read_codec.codec_interface->ianacode, ms);
|
||||
tech_pvt->remote_sdp_audio_port,
|
||||
tech_pvt->read_codec.codec_interface->ianacode,
|
||||
ms
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
tech_pvt->rtp_session = jrtp4c_new(tech_pvt->local_sdp_audio_ip,
|
||||
tech_pvt->rtp_session = jrtp4c_new(
|
||||
tech_pvt->local_sdp_audio_ip,
|
||||
tech_pvt->local_sdp_audio_port,
|
||||
tech_pvt->remote_sdp_audio_ip,
|
||||
tech_pvt->remote_sdp_audio_port,
|
||||
tech_pvt->read_codec.codec_interface->ianacode,
|
||||
tech_pvt->read_codec.implementation->samples_per_second, &err);
|
||||
tech_pvt->read_codec.implementation->samples_per_second,
|
||||
&err);
|
||||
|
||||
if (tech_pvt->rtp_session) {
|
||||
tech_pvt->ssrc = jrtp4c_get_ssrc(tech_pvt->rtp_session);
|
||||
|
@ -529,8 +521,7 @@ static switch_status exosip_answer_channel(switch_core_session *session)
|
|||
}
|
||||
|
||||
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
struct private_object *tech_pvt = NULL;
|
||||
size_t bytes = 0, samples = 0, frames=0, ms=0;
|
||||
|
@ -562,10 +553,10 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||
assert(tech_pvt->rtp_session != NULL);
|
||||
tech_pvt->read_frame.datalen = 0;
|
||||
|
||||
while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO)
|
||||
&& tech_pvt->read_frame.datalen == 0) {
|
||||
tech_pvt->read_frame.datalen =
|
||||
jrtp4c_read(tech_pvt->rtp_session, tech_pvt->read_frame.data, sizeof(tech_pvt->read_buf));
|
||||
while(!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
|
||||
tech_pvt->read_frame.datalen = jrtp4c_read(tech_pvt->rtp_session,
|
||||
tech_pvt->read_frame.data,
|
||||
sizeof(tech_pvt->read_buf));
|
||||
|
||||
if (tech_pvt->read_frame.datalen > 0) {
|
||||
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||
|
@ -607,8 +598,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||
}
|
||||
|
||||
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel = NULL;
|
||||
|
@ -757,8 +747,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
/* NOTE: **interface is **_interface because the common lib redefines interface to struct in some situations */
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -809,7 +798,9 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
event->request->from->displayname,
|
||||
event->request->from->url->username,
|
||||
event->request->from->url->host,
|
||||
NULL, NULL, event->request->req_uri->username))) {
|
||||
NULL,
|
||||
NULL,
|
||||
event->request->req_uri->username))) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
|
@ -833,17 +824,14 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
osip_rfc3264_init(&tech_pvt->sdp_config);
|
||||
/* Add in what codecs we support locally */
|
||||
|
||||
if ((num_codecs =
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
|
||||
sizeof(codecs) / sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
int x = 0;
|
||||
for (imp = codecs[i]->implementations ; imp ; imp = imp->next) {
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second, x++);
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second, x++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -862,8 +850,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
break;
|
||||
}
|
||||
for (pos=0; audio_tab[pos]!=NULL; pos++) {
|
||||
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos],
|
||||
mline);
|
||||
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos], mline);
|
||||
if (parse_sdp_media(audio_tab[pos], &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
|
||||
tech_pvt->payload_num = atoi(dpayload);
|
||||
break;
|
||||
|
@ -872,8 +859,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
mline++;
|
||||
}
|
||||
free(remote_sdp_str);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4",
|
||||
tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4", tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
|
||||
sdp_message_c_connection_add(tech_pvt->local_sdp, -1, "IN", "IP4", tech_pvt->local_sdp_audio_ip, NULL, NULL);
|
||||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
|
@ -906,7 +892,8 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
globals.codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -917,7 +904,8 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
globals.codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -926,8 +914,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
tech_pvt->read_frame.rate = rate;
|
||||
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
||||
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate,
|
||||
ms);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate, ms);
|
||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||
switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
|
||||
switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
|
||||
|
@ -958,8 +945,7 @@ static void destroy_call_by_event(eXosip_event_t * event)
|
|||
switch_channel *channel = NULL;
|
||||
|
||||
if (!(tech_pvt = get_pvt_by_call_id(event->cid))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n",
|
||||
event->cid);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n", event->cid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1001,8 +987,7 @@ static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **d
|
|||
*dname = strdup("L16");
|
||||
*drate = strdup("8000");
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
|
||||
*dpayload, *dname, *drate);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Found negotiated codec Payload: %s Name: %s Rate: %s\n", *dpayload, *dname, *drate);
|
||||
break;
|
||||
}
|
||||
attr = NULL;
|
||||
|
@ -1072,7 +1057,8 @@ static void handle_answer(eXosip_event_t * event)
|
|||
globals.codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return;
|
||||
|
@ -1132,7 +1118,8 @@ static void log_event(eXosip_event_t * je)
|
|||
snprintf (buf, 99, "<- (%i %i) Call Closed", je->cid, je->did);
|
||||
} else if (je->type == EXOSIP_CALL_RELEASED) {
|
||||
snprintf (buf, 99, "<- (%i %i) Call released", je->cid, je->did);
|
||||
} else if (je->type == EXOSIP_MESSAGE_NEW && je->request != NULL && MSG_IS_MESSAGE(je->request)) {
|
||||
} else if (je->type == EXOSIP_MESSAGE_NEW
|
||||
&& je->request!=NULL && MSG_IS_MESSAGE(je->request)) {
|
||||
char *tmp = NULL;
|
||||
|
||||
if (je->request != NULL) {
|
||||
|
@ -1141,7 +1128,8 @@ static void log_event(eXosip_event_t * je)
|
|||
|
||||
osip_message_get_body (je->request, 0, &body);
|
||||
if (body != NULL && body->body != NULL) {
|
||||
snprintf(buf, 99, "<- (%i) from: %s TEXT: %s", je->tid, tmp, body->body);
|
||||
snprintf (buf, 99, "<- (%i) from: %s TEXT: %s",
|
||||
je->tid, tmp, body->body);
|
||||
}
|
||||
osip_free (tmp);
|
||||
} else {
|
||||
|
@ -1151,22 +1139,26 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) %s from: %s", je->tid, je->request->sip_method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) %s from: %s",
|
||||
je->tid, je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->type == EXOSIP_MESSAGE_PROCEEDING
|
||||
|| je->type == EXOSIP_MESSAGE_ANSWERED
|
||||
|| je->type == EXOSIP_MESSAGE_REDIRECTED
|
||||
|| je->type == EXOSIP_MESSAGE_REQUESTFAILURE
|
||||
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE || je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
|
||||
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE
|
||||
|| je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
|
||||
if (je->response != NULL && je->request != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_to_to_str (je->request->to, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s for %s] to: %s",
|
||||
je->tid, je->response->status_code, je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
je->tid, je->response->status_code,
|
||||
je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->request != NULL) {
|
||||
snprintf(buf, 99, "<- (%i) Error for %s request", je->tid, je->request->sip_method);
|
||||
snprintf (buf, 99, "<- (%i) Error for %s request",
|
||||
je->tid, je->request->sip_method);
|
||||
} else {
|
||||
snprintf (buf, 99, "<- (%i) Error for unknown request", je->tid);
|
||||
}
|
||||
|
@ -1174,7 +1166,8 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i %i) %s from: %s", je->cid, je->did, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i %i) %s from: %s",
|
||||
je->cid, je->did, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->cid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
@ -1188,40 +1181,46 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) %s from: %s", je->rid, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) %s from: %s",
|
||||
je->rid, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->rid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
|
||||
je->rid, je->response->status_code, je->response->reason_phrase, tmp);
|
||||
je->rid, je->response->status_code,
|
||||
je->response->reason_phrase, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response == NULL && je->request != NULL && je->sid > 0) {
|
||||
char *tmp = NULL;
|
||||
char *stat = NULL;
|
||||
osip_header_t *sub_state;
|
||||
|
||||
osip_message_header_get_byname(je->request, "subscription-state", 0, &sub_state);
|
||||
osip_message_header_get_byname (je->request, "subscription-state",
|
||||
0, &sub_state);
|
||||
if (sub_state != NULL && sub_state->hvalue != NULL)
|
||||
stat = sub_state->hvalue;
|
||||
|
||||
osip_uri_to_str (je->request->from->url, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) [%s] %s from: %s", je->sid, stat, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%s] %s from: %s",
|
||||
je->sid, stat, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->sid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_uri_to_str (je->request->to->url, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
|
||||
je->sid, je->response->status_code, je->response->reason_phrase, tmp);
|
||||
je->sid, je->response->status_code,
|
||||
je->response->reason_phrase, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response == NULL && je->request != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) %s from: %s",
|
||||
je->cid, je->did, je->sid, je->nid, je->request->sip_method, tmp);
|
||||
je->cid, je->did, je->sid, je->nid,
|
||||
je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
@ -1229,7 +1228,8 @@ static void log_event(eXosip_event_t * je)
|
|||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) [%i %s] for %s from: %s",
|
||||
je->cid, je->did, je->sid, je->nid,
|
||||
je->response->status_code, je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
je->response->status_code, je->response->reason_phrase,
|
||||
je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else {
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i|t=%i) %s",
|
||||
|
@ -1403,3 +1403,4 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,12 +145,9 @@ static switch_status exosip_on_init(switch_core_session *session);
|
|||
static switch_status exosip_on_hangup(switch_core_session *session);
|
||||
static switch_status exosip_on_loopback(switch_core_session *session);
|
||||
static switch_status exosip_on_transmit(switch_core_session *session);
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags);
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags);
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
|
||||
static int config_exosip(int reload);
|
||||
static switch_status parse_sdp_media(sdp_media_t *media, char **dname, char **drate, char **dpayload);
|
||||
static switch_status exosip_kill_channel(switch_core_session *session, int sig);
|
||||
|
@ -248,17 +245,14 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
/* Initialize SDP */
|
||||
sdp_message_init(&tech_pvt->local_sdp);
|
||||
sdp_message_v_version_set(tech_pvt->local_sdp, "0");
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4",
|
||||
tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4", tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
|
||||
sdp_message_c_connection_add(tech_pvt->local_sdp, -1, "IN", "IP4", tech_pvt->local_sdp_audio_ip, NULL, NULL);
|
||||
sdp_message_t_time_descr_add(tech_pvt->local_sdp, "0", "0");
|
||||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
sdp_message_m_media_add(tech_pvt->local_sdp, "audio", port, NULL, "RTP/AVP");
|
||||
/* Add in every codec we support on this outbound call */
|
||||
if ((num_codecs =
|
||||
loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
|
||||
sizeof(codecs) / sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
|
@ -268,12 +262,10 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
|
||||
for (imp = codecs[i]->implementations ; imp ; imp = imp->next) {
|
||||
/* Add to SDP config */
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second, x++);
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second, x++);
|
||||
/* Add to SDP message */
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%i %s/%i", codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second);
|
||||
snprintf(tmp, sizeof(tmp), "%i %s/%i", codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second);
|
||||
sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(tmp));
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
}
|
||||
|
@ -281,9 +273,7 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
}
|
||||
/* Setup our INVITE */
|
||||
eXosip_lock();
|
||||
if (!
|
||||
(dest_uri =
|
||||
(char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
|
||||
if (!(dest_uri = (char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AIEEEE!\n");
|
||||
assert(dest_uri != NULL);
|
||||
}
|
||||
|
@ -356,8 +346,7 @@ static switch_status exosip_on_hangup(switch_core_session *session)
|
|||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel),
|
||||
tech_pvt->cid, tech_pvt->did, i);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel), tech_pvt->cid, tech_pvt->did, i);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -373,8 +362,7 @@ static switch_status exosip_on_transmit(switch_core_session *session)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
|
@ -382,8 +370,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
|
|||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -470,16 +457,22 @@ static void activate_rtp(struct private_object *tech_pvt)
|
|||
tech_pvt->local_sdp_audio_ip,
|
||||
tech_pvt->local_sdp_audio_port,
|
||||
tech_pvt->remote_sdp_audio_ip,
|
||||
tech_pvt->remote_sdp_audio_port, tech_pvt->read_codec.codec_interface->ianacode, ms);
|
||||
tech_pvt->remote_sdp_audio_port,
|
||||
tech_pvt->read_codec.codec_interface->ianacode,
|
||||
ms
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
tech_pvt->rtp_session = ccrtp4c_new(tech_pvt->local_sdp_audio_ip,
|
||||
tech_pvt->rtp_session = ccrtp4c_new(
|
||||
tech_pvt->local_sdp_audio_ip,
|
||||
tech_pvt->local_sdp_audio_port,
|
||||
tech_pvt->remote_sdp_audio_ip,
|
||||
tech_pvt->remote_sdp_audio_port,
|
||||
tech_pvt->read_codec.codec_interface->ianacode, ms, ms * 15);
|
||||
tech_pvt->read_codec.codec_interface->ianacode,
|
||||
ms,
|
||||
ms * 15);
|
||||
|
||||
if (tech_pvt->rtp_session) {
|
||||
tech_pvt->ssrc = ccrtp4c_get_ssrc(tech_pvt->rtp_session);
|
||||
|
@ -524,8 +517,7 @@ static switch_status exosip_answer_channel(switch_core_session *session)
|
|||
}
|
||||
|
||||
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags)
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
|
||||
{
|
||||
struct private_object *tech_pvt = NULL;
|
||||
size_t bytes = 0, samples = 0, frames=0, ms=0;
|
||||
|
@ -555,10 +547,11 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||
assert(tech_pvt->rtp_session != NULL);
|
||||
tech_pvt->read_frame.datalen = 0;
|
||||
|
||||
while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO)
|
||||
&& tech_pvt->read_frame.datalen == 0) {
|
||||
while(!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
|
||||
if ((tech_pvt->read_frame.datalen =
|
||||
ccrtp4c_read(tech_pvt->rtp_session, tech_pvt->read_frame.data, sizeof(tech_pvt->read_buf),
|
||||
ccrtp4c_read(tech_pvt->rtp_session,
|
||||
tech_pvt->read_frame.data,
|
||||
sizeof(tech_pvt->read_buf),
|
||||
&tech_pvt->timestamp_recv))) {
|
||||
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||
frames = (tech_pvt->read_frame.datalen / bytes);
|
||||
|
@ -594,8 +587,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||
}
|
||||
|
||||
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags)
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
|
||||
{
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel = NULL;
|
||||
|
@ -747,8 +739,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
/* NOTE: **interface is **_interface because the common lib redefines interface to struct in some situations */
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -799,7 +790,8 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
event->request->from->displayname,
|
||||
event->request->from->url->username,
|
||||
event->request->from->url->username,
|
||||
NULL, event->request->req_uri->username))) {
|
||||
NULL,
|
||||
event->request->req_uri->username))) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
|
@ -823,17 +815,14 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
osip_rfc3264_init(&tech_pvt->sdp_config);
|
||||
/* Add in what codecs we support locally */
|
||||
|
||||
if ((num_codecs =
|
||||
loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
|
||||
sizeof(codecs) / sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
int x = 0;
|
||||
for (imp = codecs[i]->implementations ; imp ; imp = imp->next) {
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second, x++);
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second, x++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -852,8 +841,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
break;
|
||||
}
|
||||
for (pos=0; audio_tab[pos]!=NULL; pos++) {
|
||||
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos],
|
||||
mline);
|
||||
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos], mline);
|
||||
if (parse_sdp_media(audio_tab[pos], &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
|
||||
tech_pvt->payload_num = atoi(dpayload);
|
||||
break;
|
||||
|
@ -862,8 +850,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
mline++;
|
||||
}
|
||||
free(remote_sdp_str);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4",
|
||||
tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4", tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
|
||||
sdp_message_c_connection_add(tech_pvt->local_sdp, -1, "IN", "IP4", tech_pvt->local_sdp_audio_ip, NULL, NULL);
|
||||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
|
@ -913,8 +900,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
int ms;
|
||||
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
||||
ms = tech_pvt->write_codec.implementation->nanoseconds_per_frame / 1000;
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate,
|
||||
ms);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate, ms);
|
||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||
switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
|
||||
switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
|
||||
|
@ -940,8 +926,7 @@ static void destroy_call_by_event(eXosip_event_t * event)
|
|||
switch_channel *channel = NULL;
|
||||
|
||||
if (!(tech_pvt = get_pvt_by_call_id(event->cid))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n",
|
||||
event->cid);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n", event->cid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -983,8 +968,7 @@ static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **d
|
|||
*dname = strdup("L16");
|
||||
*drate = strdup("8000");
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
|
||||
*dpayload, *dname, *drate);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Found negotiated codec Payload: %s Name: %s Rate: %s\n", *dpayload, *dname, *drate);
|
||||
break;
|
||||
}
|
||||
attr = NULL;
|
||||
|
@ -1048,16 +1032,12 @@ static void handle_answer(eXosip_event_t * event)
|
|||
int rate = atoi(drate);
|
||||
|
||||
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->read_codec, dname, rate, globals.codec_ms, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_codec_init(&tech_pvt->read_codec, dname, rate, globals.codec_ms, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return;
|
||||
} else {
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->write_codec, dname, rate, globals.codec_ms,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_codec_init(&tech_pvt->write_codec, dname, rate, globals.codec_ms, SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return;
|
||||
|
@ -1103,7 +1083,8 @@ static void log_event(eXosip_event_t * je)
|
|||
snprintf (buf, 99, "<- (%i %i) Call Closed", je->cid, je->did);
|
||||
} else if (je->type == EXOSIP_CALL_RELEASED) {
|
||||
snprintf (buf, 99, "<- (%i %i) Call released", je->cid, je->did);
|
||||
} else if (je->type == EXOSIP_MESSAGE_NEW && je->request != NULL && MSG_IS_MESSAGE(je->request)) {
|
||||
} else if (je->type == EXOSIP_MESSAGE_NEW
|
||||
&& je->request!=NULL && MSG_IS_MESSAGE(je->request)) {
|
||||
char *tmp = NULL;
|
||||
|
||||
if (je->request != NULL) {
|
||||
|
@ -1112,7 +1093,8 @@ static void log_event(eXosip_event_t * je)
|
|||
|
||||
osip_message_get_body (je->request, 0, &body);
|
||||
if (body != NULL && body->body != NULL) {
|
||||
snprintf(buf, 99, "<- (%i) from: %s TEXT: %s", je->tid, tmp, body->body);
|
||||
snprintf (buf, 99, "<- (%i) from: %s TEXT: %s",
|
||||
je->tid, tmp, body->body);
|
||||
}
|
||||
osip_free (tmp);
|
||||
} else {
|
||||
|
@ -1122,22 +1104,26 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) %s from: %s", je->tid, je->request->sip_method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) %s from: %s",
|
||||
je->tid, je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->type == EXOSIP_MESSAGE_PROCEEDING
|
||||
|| je->type == EXOSIP_MESSAGE_ANSWERED
|
||||
|| je->type == EXOSIP_MESSAGE_REDIRECTED
|
||||
|| je->type == EXOSIP_MESSAGE_REQUESTFAILURE
|
||||
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE || je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
|
||||
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE
|
||||
|| je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
|
||||
if (je->response != NULL && je->request != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_to_to_str (je->request->to, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s for %s] to: %s",
|
||||
je->tid, je->response->status_code, je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
je->tid, je->response->status_code,
|
||||
je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->request != NULL) {
|
||||
snprintf(buf, 99, "<- (%i) Error for %s request", je->tid, je->request->sip_method);
|
||||
snprintf (buf, 99, "<- (%i) Error for %s request",
|
||||
je->tid, je->request->sip_method);
|
||||
} else {
|
||||
snprintf (buf, 99, "<- (%i) Error for unknown request", je->tid);
|
||||
}
|
||||
|
@ -1145,7 +1131,8 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i %i) %s from: %s", je->cid, je->did, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i %i) %s from: %s",
|
||||
je->cid, je->did, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->cid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
@ -1159,40 +1146,46 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) %s from: %s", je->rid, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) %s from: %s",
|
||||
je->rid, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->rid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
|
||||
je->rid, je->response->status_code, je->response->reason_phrase, tmp);
|
||||
je->rid, je->response->status_code,
|
||||
je->response->reason_phrase, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response == NULL && je->request != NULL && je->sid > 0) {
|
||||
char *tmp = NULL;
|
||||
char *stat = NULL;
|
||||
osip_header_t *sub_state;
|
||||
|
||||
osip_message_header_get_byname(je->request, "subscription-state", 0, &sub_state);
|
||||
osip_message_header_get_byname (je->request, "subscription-state",
|
||||
0, &sub_state);
|
||||
if (sub_state != NULL && sub_state->hvalue != NULL)
|
||||
stat = sub_state->hvalue;
|
||||
|
||||
osip_uri_to_str (je->request->from->url, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) [%s] %s from: %s", je->sid, stat, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%s] %s from: %s",
|
||||
je->sid, stat, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->sid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_uri_to_str (je->request->to->url, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
|
||||
je->sid, je->response->status_code, je->response->reason_phrase, tmp);
|
||||
je->sid, je->response->status_code,
|
||||
je->response->reason_phrase, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response == NULL && je->request != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) %s from: %s",
|
||||
je->cid, je->did, je->sid, je->nid, je->request->sip_method, tmp);
|
||||
je->cid, je->did, je->sid, je->nid,
|
||||
je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
@ -1200,7 +1193,8 @@ static void log_event(eXosip_event_t * je)
|
|||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) [%i %s] for %s from: %s",
|
||||
je->cid, je->did, je->sid, je->nid,
|
||||
je->response->status_code, je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
je->response->status_code, je->response->reason_phrase,
|
||||
je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else {
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i|t=%i) %s",
|
||||
|
@ -1377,3 +1371,4 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
config_exosip(0);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,12 +160,9 @@ static switch_status exosip_on_init(switch_core_session *session);
|
|||
static switch_status exosip_on_hangup(switch_core_session *session);
|
||||
static switch_status exosip_on_loopback(switch_core_session *session);
|
||||
static switch_status exosip_on_transmit(switch_core_session *session);
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags);
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags);
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
|
||||
static int config_exosip(int reload);
|
||||
static switch_status parse_sdp_media(sdp_media_t *media, char **dname, char **drate, char **dpayload);
|
||||
static switch_status exosip_kill_channel(switch_core_session *session, int sig);
|
||||
|
@ -263,17 +260,14 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
/* Initialize SDP */
|
||||
sdp_message_init(&tech_pvt->local_sdp);
|
||||
sdp_message_v_version_set(tech_pvt->local_sdp, "0");
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4",
|
||||
tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4", tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
|
||||
sdp_message_c_connection_add(tech_pvt->local_sdp, -1, "IN", "IP4", tech_pvt->local_sdp_audio_ip, NULL, NULL);
|
||||
sdp_message_t_time_descr_add(tech_pvt->local_sdp, "0", "0");
|
||||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
sdp_message_m_media_add(tech_pvt->local_sdp, "audio", port, NULL, "RTP/AVP");
|
||||
/* Add in every codec we support on this outbound call */
|
||||
if ((num_codecs =
|
||||
loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
|
||||
sizeof(codecs) / sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
|
@ -283,12 +277,10 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
sdp_message_m_payload_add(tech_pvt->local_sdp, 0, osip_strdup(tmp));
|
||||
for (imp = codecs[i]->implementations ; imp ; imp = imp->next) {
|
||||
/* Add to SDP config */
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second, x++);
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second, x++);
|
||||
/* Add to SDP message */
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%i %s/%i", codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second);
|
||||
snprintf(tmp, sizeof(tmp), "%i %s/%i", codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second);
|
||||
sdp_message_a_attribute_add(tech_pvt->local_sdp, 0, "rtpmap", osip_strdup(tmp));
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
}
|
||||
|
@ -296,9 +288,7 @@ static switch_status exosip_on_init(switch_core_session *session)
|
|||
}
|
||||
/* Setup our INVITE */
|
||||
eXosip_lock();
|
||||
if (!
|
||||
(dest_uri =
|
||||
(char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
|
||||
if (!(dest_uri = (char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AIEEEE!\n");
|
||||
assert(dest_uri != NULL);
|
||||
}
|
||||
|
@ -372,8 +362,7 @@ static switch_status exosip_on_hangup(switch_core_session *session)
|
|||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel),
|
||||
tech_pvt->cid, tech_pvt->did, i);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "EXOSIP HANGUP %s %d/%d=%d\n", switch_channel_get_name(channel), tech_pvt->cid, tech_pvt->did, i);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -389,8 +378,7 @@ static switch_status exosip_on_transmit(switch_core_session *session)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
|
@ -398,8 +386,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
|
|||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -469,6 +456,7 @@ static void rtp_event_handler(struct rtp *session, rtp_event * event)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
//switch_console_printf(SWITCH_CHANNEL_CONSOLE, "RTP EVENT (%s)\n", event_names[event->type]);
|
||||
|
||||
switch(event->type) {
|
||||
|
@ -520,7 +508,8 @@ static void activate_rtp(struct private_object *tech_pvt)
|
|||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activating RTP %d->%s:%d\n",
|
||||
tech_pvt->local_sdp_audio_port,
|
||||
tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
|
||||
tech_pvt->remote_sdp_audio_ip,
|
||||
tech_pvt->remote_sdp_audio_port);
|
||||
|
||||
|
||||
//switch_mutex_lock(tech_pvt->rtp_lock);
|
||||
|
@ -587,8 +576,7 @@ static switch_status exosip_answer_channel(switch_core_session *session)
|
|||
}
|
||||
|
||||
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags)
|
||||
static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
|
||||
{
|
||||
struct private_object *tech_pvt = NULL;
|
||||
size_t bytes = 0, samples = 0, frames, ms, x;
|
||||
|
@ -663,8 +651,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||
}
|
||||
|
||||
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags)
|
||||
static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
|
||||
{
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel = NULL;
|
||||
|
@ -708,7 +695,9 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
|
|||
|
||||
rtp_send_ctrl(tech_pvt->rtp_session, tech_pvt->timestamp_send, NULL);
|
||||
x = rtp_send_data(tech_pvt->rtp_session, tech_pvt->timestamp_send, tech_pvt->payload_num,
|
||||
0, 0, 0, (char *) frame->data, (int) frame->datalen, 0, 0, 0);
|
||||
0, 0, 0,
|
||||
(char *)frame->data, (int)frame->datalen,
|
||||
0, 0, 0);
|
||||
|
||||
|
||||
switch_clear_flag(tech_pvt, TFLAG_WRITING);
|
||||
|
@ -817,9 +806,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **_interface,
|
||||
char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **_interface, char *filename) {
|
||||
/* NOTE: **interface is **_interface because the common lib redefines interface to struct in some situations */
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -870,7 +857,8 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
event->request->from->displayname,
|
||||
event->request->from->url->username,
|
||||
event->request->from->url->username,
|
||||
NULL, event->request->req_uri->username))) {
|
||||
NULL,
|
||||
event->request->req_uri->username))) {
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
}
|
||||
|
||||
|
@ -894,17 +882,14 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
osip_rfc3264_init(&tech_pvt->sdp_config);
|
||||
/* Add in what codecs we support locally */
|
||||
|
||||
if ((num_codecs =
|
||||
loadable_module_get_codecs(switch_core_session_get_pool(session), codecs,
|
||||
sizeof(codecs) / sizeof(codecs[0]))) > 0) {
|
||||
if ((num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(session), codecs, sizeof(codecs)/sizeof(codecs[0]))) > 0) {
|
||||
int i;
|
||||
static const switch_codec_implementation *imp;
|
||||
|
||||
for (i = 0; i < num_codecs; i++) {
|
||||
int x = 0;
|
||||
for (imp = codecs[i]->implementations ; imp ; imp = imp->next) {
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame,
|
||||
imp->samples_per_second, x++);
|
||||
sdp_add_codec(tech_pvt->sdp_config, codecs[i]->codec_type, codecs[i]->ianacode, codecs[i]->iananame, imp->samples_per_second, x++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -923,8 +908,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
break;
|
||||
}
|
||||
for (pos=0; audio_tab[pos]!=NULL; pos++) {
|
||||
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos],
|
||||
mline);
|
||||
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos], mline);
|
||||
if (parse_sdp_media(audio_tab[pos], &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
|
||||
tech_pvt->payload_num = atoi(dpayload);
|
||||
break;
|
||||
|
@ -933,8 +917,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
mline++;
|
||||
}
|
||||
free(remote_sdp_str);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4",
|
||||
tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_o_origin_set(tech_pvt->local_sdp, "OpenSWITCH2", "0", "0", "IN", "IP4", tech_pvt->local_sdp_audio_ip);
|
||||
sdp_message_s_name_set(tech_pvt->local_sdp, "SIP Call");
|
||||
sdp_message_c_connection_add(tech_pvt->local_sdp, -1, "IN", "IP4", tech_pvt->local_sdp_audio_ip, NULL, NULL);
|
||||
snprintf(port, sizeof(port), "%i", tech_pvt->local_sdp_audio_port);
|
||||
|
@ -984,8 +967,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
|
|||
int ms;
|
||||
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
||||
ms = tech_pvt->write_codec.implementation->nanoseconds_per_frame / 1000;
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate,
|
||||
ms);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate, ms);
|
||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||
switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
|
||||
switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
|
||||
|
@ -1011,8 +993,7 @@ static void destroy_call_by_event(eXosip_event_t * event)
|
|||
switch_channel *channel = NULL;
|
||||
|
||||
if (!(tech_pvt = get_pvt_by_call_id(event->cid))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n",
|
||||
event->cid);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n", event->cid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1054,8 +1035,7 @@ static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **d
|
|||
*dname = strdup("L16");
|
||||
*drate = strdup("8000");
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
|
||||
*dpayload, *dname, *drate);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Found negotiated codec Payload: %s Name: %s Rate: %s\n", *dpayload, *dname, *drate);
|
||||
break;
|
||||
}
|
||||
attr = NULL;
|
||||
|
@ -1119,16 +1099,12 @@ static void handle_answer(eXosip_event_t * event)
|
|||
int rate = atoi(drate);
|
||||
|
||||
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->read_codec, dname, rate, globals.codec_ms, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_codec_init(&tech_pvt->read_codec, dname, rate, globals.codec_ms, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return;
|
||||
} else {
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->write_codec, dname, rate, globals.codec_ms,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_codec_init(&tech_pvt->write_codec, dname, rate, globals.codec_ms, SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_channel_hangup(channel);
|
||||
return;
|
||||
|
@ -1172,7 +1148,8 @@ static void log_event(eXosip_event_t * je)
|
|||
snprintf (buf, 99, "<- (%i %i) Call Closed", je->cid, je->did);
|
||||
} else if (je->type == EXOSIP_CALL_RELEASED) {
|
||||
snprintf (buf, 99, "<- (%i %i) Call released", je->cid, je->did);
|
||||
} else if (je->type == EXOSIP_MESSAGE_NEW && je->request != NULL && MSG_IS_MESSAGE(je->request)) {
|
||||
} else if (je->type == EXOSIP_MESSAGE_NEW
|
||||
&& je->request!=NULL && MSG_IS_MESSAGE(je->request)) {
|
||||
char *tmp = NULL;
|
||||
|
||||
if (je->request != NULL) {
|
||||
|
@ -1181,7 +1158,8 @@ static void log_event(eXosip_event_t * je)
|
|||
|
||||
osip_message_get_body (je->request, 0, &body);
|
||||
if (body != NULL && body->body != NULL) {
|
||||
snprintf(buf, 99, "<- (%i) from: %s TEXT: %s", je->tid, tmp, body->body);
|
||||
snprintf (buf, 99, "<- (%i) from: %s TEXT: %s",
|
||||
je->tid, tmp, body->body);
|
||||
}
|
||||
osip_free (tmp);
|
||||
} else {
|
||||
|
@ -1191,22 +1169,26 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) %s from: %s", je->tid, je->request->sip_method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) %s from: %s",
|
||||
je->tid, je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->type == EXOSIP_MESSAGE_PROCEEDING
|
||||
|| je->type == EXOSIP_MESSAGE_ANSWERED
|
||||
|| je->type == EXOSIP_MESSAGE_REDIRECTED
|
||||
|| je->type == EXOSIP_MESSAGE_REQUESTFAILURE
|
||||
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE || je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
|
||||
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE
|
||||
|| je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
|
||||
if (je->response != NULL && je->request != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_to_to_str (je->request->to, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s for %s] to: %s",
|
||||
je->tid, je->response->status_code, je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
je->tid, je->response->status_code,
|
||||
je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->request != NULL) {
|
||||
snprintf(buf, 99, "<- (%i) Error for %s request", je->tid, je->request->sip_method);
|
||||
snprintf (buf, 99, "<- (%i) Error for %s request",
|
||||
je->tid, je->request->sip_method);
|
||||
} else {
|
||||
snprintf (buf, 99, "<- (%i) Error for unknown request", je->tid);
|
||||
}
|
||||
|
@ -1214,7 +1196,8 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i %i) %s from: %s", je->cid, je->did, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i %i) %s from: %s",
|
||||
je->cid, je->did, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->cid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
@ -1228,40 +1211,46 @@ static void log_event(eXosip_event_t * je)
|
|||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) %s from: %s", je->rid, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) %s from: %s",
|
||||
je->rid, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->rid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
|
||||
je->rid, je->response->status_code, je->response->reason_phrase, tmp);
|
||||
je->rid, je->response->status_code,
|
||||
je->response->reason_phrase, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response == NULL && je->request != NULL && je->sid > 0) {
|
||||
char *tmp = NULL;
|
||||
char *stat = NULL;
|
||||
osip_header_t *sub_state;
|
||||
|
||||
osip_message_header_get_byname(je->request, "subscription-state", 0, &sub_state);
|
||||
osip_message_header_get_byname (je->request, "subscription-state",
|
||||
0, &sub_state);
|
||||
if (sub_state != NULL && sub_state->hvalue != NULL)
|
||||
stat = sub_state->hvalue;
|
||||
|
||||
osip_uri_to_str (je->request->from->url, &tmp);
|
||||
snprintf(buf, 99, "<- (%i) [%s] %s from: %s", je->sid, stat, je->request->cseq->method, tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%s] %s from: %s",
|
||||
je->sid, stat, je->request->cseq->method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL && je->sid > 0) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_uri_to_str (je->request->to->url, &tmp);
|
||||
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
|
||||
je->sid, je->response->status_code, je->response->reason_phrase, tmp);
|
||||
je->sid, je->response->status_code,
|
||||
je->response->reason_phrase, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response == NULL && je->request != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
||||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) %s from: %s",
|
||||
je->cid, je->did, je->sid, je->nid, je->request->sip_method, tmp);
|
||||
je->cid, je->did, je->sid, je->nid,
|
||||
je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else if (je->response != NULL) {
|
||||
char *tmp = NULL;
|
||||
|
@ -1269,7 +1258,8 @@ static void log_event(eXosip_event_t * je)
|
|||
osip_from_to_str (je->request->from, &tmp);
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) [%i %s] for %s from: %s",
|
||||
je->cid, je->did, je->sid, je->nid,
|
||||
je->response->status_code, je->response->reason_phrase, je->request->sip_method, tmp);
|
||||
je->response->status_code, je->response->reason_phrase,
|
||||
je->request->sip_method, tmp);
|
||||
osip_free (tmp);
|
||||
} else {
|
||||
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i|t=%i) %s",
|
||||
|
@ -1446,3 +1436,4 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
config_exosip(0);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,8 +96,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
|||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string)
|
||||
|
||||
|
||||
static char *IAXNAMES[] =
|
||||
{ "IAX_EVENT_CONNECT", "IAX_EVENT_ACCEPT", "IAX_EVENT_HANGUP", "IAX_EVENT_REJECT", "IAX_EVENT_VOICE",
|
||||
static char *IAXNAMES[] = {"IAX_EVENT_CONNECT","IAX_EVENT_ACCEPT","IAX_EVENT_HANGUP","IAX_EVENT_REJECT","IAX_EVENT_VOICE",
|
||||
"IAX_EVENT_DTMF","IAX_EVENT_TIMEOUT","IAX_EVENT_LAGRQ","IAX_EVENT_LAGRP","IAX_EVENT_RINGA",
|
||||
"IAX_EVENT_PING","IAX_EVENT_PONG","IAX_EVENT_BUSY","IAX_EVENT_ANSWER","IAX_EVENT_IMAGE",
|
||||
"IAX_EVENT_AUTHRQ","IAX_EVENT_AUTHRP","IAX_EVENT_REGREQ","IAX_EVENT_REGACK",
|
||||
|
@ -105,8 +104,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
|||
"IAX_EVENT_DPREP","IAX_EVENT_DIAL","IAX_EVENT_QUELCH","IAX_EVENT_UNQUELCH",
|
||||
"IAX_EVENT_UNLINK","IAX_EVENT_LINKREJECT","IAX_EVENT_TEXT","IAX_EVENT_REGREJ",
|
||||
"IAX_EVENT_LINKURL","IAX_EVENT_CNG","IAX_EVENT_REREQUEST","IAX_EVENT_TXREPLY",
|
||||
"IAX_EVENT_TXREJECT", "IAX_EVENT_TXACCEPT", "IAX_EVENT_TXREADY"
|
||||
};
|
||||
"IAX_EVENT_TXREJECT","IAX_EVENT_TXACCEPT","IAX_EVENT_TXREADY"};
|
||||
|
||||
|
||||
struct ast_iana {
|
||||
|
@ -116,7 +114,8 @@ struct ast_iana {
|
|||
};
|
||||
|
||||
//999 means it's wrong nad i dont know the real one
|
||||
static struct ast_iana AST_IANA[] = { {AST_FORMAT_G723_1, 4, "g723.1"},
|
||||
static struct ast_iana AST_IANA[] =
|
||||
{{AST_FORMAT_G723_1, 4, "g723.1"},
|
||||
{AST_FORMAT_GSM, 3, "gsm"},
|
||||
{AST_FORMAT_ULAW, 0, "ulaw"},
|
||||
{AST_FORMAT_ALAW, 8, "alaw"},
|
||||
|
@ -201,9 +200,7 @@ typedef enum {
|
|||
IAX_QUERY = 2
|
||||
} iax_io_t;
|
||||
|
||||
static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_session *iax_session,
|
||||
unsigned int *format, unsigned int *cababilities, unsigned short *samprate,
|
||||
iax_io_t io)
|
||||
static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_session *iax_session, unsigned int *format, unsigned int *cababilities, unsigned short *samprate, iax_io_t io)
|
||||
{
|
||||
char *dname = NULL;
|
||||
//int rate = 8000;
|
||||
|
@ -223,11 +220,7 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
} else
|
||||
if (!
|
||||
(num_codecs =
|
||||
switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs,
|
||||
SWITCH_MAX_CODECS)) > 0) {
|
||||
} else if (!(num_codecs = switch_loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS)) > 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
@ -352,7 +345,8 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
|
|||
0,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
} else {
|
||||
|
@ -362,7 +356,8 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
|
|||
0,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
|
@ -397,12 +392,9 @@ static switch_status channel_on_hangup(switch_core_session *session);
|
|||
static switch_status channel_on_ring(switch_core_session *session);
|
||||
static switch_status channel_on_loopback(switch_core_session *session);
|
||||
static switch_status channel_on_transmit(switch_core_session *session);
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_kill_channel(switch_core_session *session, int sig);
|
||||
|
||||
|
||||
|
@ -559,8 +551,7 @@ static switch_status channel_on_transmit(switch_core_session *session)
|
|||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||
*/
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
|
@ -570,8 +561,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
|||
unsigned short samprate = 0;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -612,7 +602,9 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
|||
|
||||
iax_call(tech_pvt->iax_session,
|
||||
caller_profile->caller_id_number,
|
||||
caller_profile->caller_id_name, caller_profile->destination_number, NULL, 0, req, cap);
|
||||
caller_profile->caller_id_name,
|
||||
caller_profile->destination_number,
|
||||
NULL, 0, req, cap);
|
||||
|
||||
switch_channel_set_flag(channel, CF_OUTBOUND);
|
||||
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
|
||||
|
@ -661,8 +653,7 @@ static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -696,8 +687,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -712,13 +702,13 @@ static switch_status channel_write_frame(switch_core_session *session, switch_fr
|
|||
if(!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
#ifndef BIGENDIAN
|
||||
if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
|
||||
switch_swap_linear(frame->data, (int)frame->datalen / 2);
|
||||
}
|
||||
#endif
|
||||
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen,
|
||||
tech_pvt->write_codec.implementation->samples_per_frame);
|
||||
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int)frame->datalen, tech_pvt->write_codec.implementation->samples_per_frame);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
@ -779,8 +769,7 @@ static const switch_loadable_module_interface channel_module_interface = {
|
|||
};
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
|
||||
|
@ -831,12 +820,10 @@ static switch_status load_config(void)
|
|||
set_global_dialplan(val);
|
||||
} else if (!strcmp(var, "codec_prefs")) {
|
||||
set_global_codec_string(val);
|
||||
globals.codec_order_last =
|
||||
switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
|
||||
globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
|
||||
} else if (!strcmp(var, "codec_rates")) {
|
||||
set_global_codec_rates_string(val);
|
||||
globals.codec_rates_last =
|
||||
switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
|
||||
globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -897,8 +884,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
switch (iaxevent->etype) {
|
||||
case IAX_EVENT_REGACK:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Registration completed successfully.\n");
|
||||
if (iaxevent->ies.refresh)
|
||||
refresh = iaxevent->ies.refresh;
|
||||
if (iaxevent->ies.refresh) refresh = iaxevent->ies.refresh;
|
||||
break;
|
||||
case IAX_EVENT_REGREJ:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Registration failed.\n");
|
||||
|
@ -910,10 +896,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
unsigned int cap = iax_session_get_capability(iaxevent->session);
|
||||
unsigned int format = iaxevent->ies.format;
|
||||
|
||||
if (iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF? %d %d\n", iaxevent->ies.format,
|
||||
iaxevent->ies.capability);
|
||||
if (iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF? %d %d\n",iaxevent->ies.format, iaxevent->ies.capability);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -932,11 +916,9 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
switch_channel *channel;
|
||||
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF Mutiple Answer %s?\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF Mutiple Answer %s?\n", switch_channel_get_name(channel));
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s\n", switch_channel_get_name(channel));
|
||||
switch_channel_answer(channel);
|
||||
}
|
||||
}
|
||||
|
@ -949,21 +931,20 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
"Incoming call connected %s, %s, %s %d/%d\n",
|
||||
iaxevent->ies.called_number,
|
||||
iaxevent->ies.calling_number,
|
||||
iaxevent->ies.calling_name, iaxevent->ies.format, iaxevent->ies.capability);
|
||||
iaxevent->ies.calling_name,
|
||||
iaxevent->ies.format,
|
||||
iaxevent->ies.capability);
|
||||
|
||||
if (iaxevent) {
|
||||
switch_core_session *session;
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel %s!\n",
|
||||
iaxevent->ies.calling_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
|
||||
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel;
|
||||
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(session,
|
||||
sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_core_session_set_private(session, tech_pvt);
|
||||
|
@ -981,18 +962,19 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
iaxevent->ies.calling_number,
|
||||
iax_get_peer_ip(iaxevent->session),
|
||||
iaxevent->ies.calling_ani,
|
||||
NULL, iaxevent->ies.called_number))) {
|
||||
NULL,
|
||||
iaxevent->ies.called_number))) {
|
||||
char name[128];
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
rand() & 0xffff);
|
||||
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
}
|
||||
|
||||
if (iax_set_codec(tech_pvt, iaxevent->session,
|
||||
&iaxevent->ies.format,
|
||||
&iaxevent->ies.capability,
|
||||
&iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
|
||||
&iaxevent->ies.samprate,
|
||||
IAX_SET) != SWITCH_STATUS_SUCCESS) {
|
||||
iax_reject(iaxevent->session, "Codec Error!");
|
||||
switch_core_session_destroy(&session);
|
||||
} else {
|
||||
|
@ -1022,8 +1004,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
//switch_thread_cond_signal(tech_pvt->cond);
|
||||
iaxevent->session = NULL;
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Session? %s\n",
|
||||
switch_test_flag(tech_pvt, TFLAG_VOICE) ? "yes" : "no");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Session? %s\n", switch_test_flag(tech_pvt, TFLAG_VOICE) ? "yes" : "no");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1034,8 +1015,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
case IAX_EVENT_VOICE:
|
||||
if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen)) {
|
||||
switch_channel *channel;
|
||||
if ((channel = switch_core_session_get_channel(tech_pvt->session))
|
||||
&& switch_channel_get_state(channel) <= CS_HANGUP) {
|
||||
if ((channel = switch_core_session_get_channel(tech_pvt->session)) && switch_channel_get_state(channel) <= CS_HANGUP) {
|
||||
int bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||
int frames = (int)(tech_pvt->read_frame.datalen / bytes);
|
||||
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
|
||||
|
@ -1056,8 +1036,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
|
||||
char str[2] = {iaxevent->subclass};
|
||||
if (globals.debug) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s DTMF %s\n", str,
|
||||
switch_channel_get_name(channel));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s DTMF %s\n", str, switch_channel_get_name(channel));
|
||||
}
|
||||
switch_channel_queue_dtmf(channel, str);
|
||||
}
|
||||
|
@ -1065,8 +1044,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Don't know what to do with IAX event %d.\n",
|
||||
iaxevent->etype);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1097,3 +1075,4 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,12 +65,9 @@ static switch_status channel_on_hangup(switch_core_session *session);
|
|||
static switch_status channel_on_ring(switch_core_session *session);
|
||||
static switch_status channel_on_loopback(switch_core_session *session);
|
||||
static switch_status channel_on_transmit(switch_core_session *session);
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_kill_channel(switch_core_session *session, int sig);
|
||||
|
||||
|
||||
|
@ -180,8 +177,7 @@ static switch_status channel_on_transmit(switch_core_session *session)
|
|||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||
*/
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
|
@ -189,8 +185,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
|||
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -255,8 +250,7 @@ static switch_status channel_waitfor_write(switch_core_session *session, int ms,
|
|||
|
||||
}
|
||||
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -272,8 +266,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -345,8 +338,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
}
|
||||
*/
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
switch_config cfg;
|
||||
char *var, *val;
|
||||
|
|
|
@ -106,13 +106,9 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
|
|||
static switch_status channel_on_ring(switch_core_session *session);
|
||||
static switch_status channel_on_loopback(switch_core_session *session);
|
||||
static switch_status channel_on_transmit(switch_core_session *session);
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session,
|
||||
switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status channel_kill_channel(switch_core_session *session, int sig);
|
||||
static switch_status engage_device(struct private_object *tech_pvt);
|
||||
static int dump_info(void);
|
||||
|
@ -297,8 +293,7 @@ static switch_status channel_on_transmit(switch_core_session *session)
|
|||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||
*/
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
|
@ -306,8 +301,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
|||
switch_caller_profile *caller_profile;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
@ -323,9 +317,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
|
|||
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
|
||||
switch_channel_set_caller_profile(channel, caller_profile);
|
||||
tech_pvt->caller_profile = caller_profile;
|
||||
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
|
||||
caller_profile->destination_number ? caller_profile->destination_number : modname,
|
||||
rand() & 0xffff);
|
||||
snprintf(name, sizeof(name), "PortAudio/%s-%04x", caller_profile->destination_number ? caller_profile->destination_number : modname, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
|
||||
|
@ -376,8 +368,7 @@ static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -397,9 +388,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
|
|||
|
||||
switch_mutex_lock(globals.device_lock);
|
||||
if (tech_pvt->audio_in &&
|
||||
(samples =
|
||||
ReadAudioStream(tech_pvt->audio_in, tech_pvt->read_frame.data,
|
||||
tech_pvt->read_codec.implementation->samples_per_frame))) {
|
||||
(samples = ReadAudioStream(tech_pvt->audio_in, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_frame))) {
|
||||
tech_pvt->read_frame.datalen = samples * 2;
|
||||
tech_pvt->read_frame.samples = samples;
|
||||
*frame = &tech_pvt->read_frame;
|
||||
|
@ -410,8 +399,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
|
|||
return status;
|
||||
}
|
||||
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -425,6 +413,7 @@ static switch_status channel_write_frame(switch_core_session *session, switch_fr
|
|||
if(!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
//switch_mutex_lock(globals.device_lock);
|
||||
if (tech_pvt->audio_out) {
|
||||
WriteAudioStream(tech_pvt->audio_out, (short *)frame->data, (int)(frame->datalen / sizeof(SAMPLE)));
|
||||
|
@ -527,8 +516,7 @@ static const switch_loadable_module_interface channel_module_interface = {
|
|||
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
|
||||
|
@ -661,47 +649,43 @@ static int dump_info(void)
|
|||
const PaDeviceInfo *pdi;
|
||||
PaError err;
|
||||
numDevices = Pa_CountDevices();
|
||||
if (numDevices < 0) {
|
||||
if( numDevices < 0 )
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices );
|
||||
err = numDevices;
|
||||
goto error;
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Number of devices = %d\n", numDevices );
|
||||
for (i = 0; i < numDevices; i++) {
|
||||
for( i=0; i<numDevices; i++ )
|
||||
{
|
||||
pdi = Pa_GetDeviceInfo( i );
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "---------------------------------------------- #%d", i );
|
||||
if (i == Pa_GetDefaultInputDeviceID())
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " DefaultInput");
|
||||
if (i == Pa_GetDefaultOutputDeviceID())
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " DefaultOutput");
|
||||
if( i == Pa_GetDefaultInputDeviceID() ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " DefaultInput");
|
||||
if( i == Pa_GetDefaultOutputDeviceID() ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " DefaultOutput");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "\nName = %s\n", pdi->name );
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Max Inputs = %d", pdi->maxInputChannels );
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, ", Max Outputs = %d\n", pdi->maxOutputChannels );
|
||||
if (pdi->numSampleRates == -1) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Sample Rate Range = %f to %f\n", pdi->sampleRates[0],
|
||||
pdi->sampleRates[1]);
|
||||
} else {
|
||||
if( pdi->numSampleRates == -1 )
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Sample Rates =");
|
||||
for (j = 0; j < pdi->numSampleRates; j++) {
|
||||
for( j=0; j<pdi->numSampleRates; j++ )
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " %8.2f,", pdi->sampleRates[j] );
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "\n");
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Native Sample Formats = ");
|
||||
if (pdi->nativeSampleFormats & paInt8)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt8, ");
|
||||
if (pdi->nativeSampleFormats & paUInt8)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paUInt8, ");
|
||||
if (pdi->nativeSampleFormats & paInt16)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt16, ");
|
||||
if (pdi->nativeSampleFormats & paInt32)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt32, ");
|
||||
if (pdi->nativeSampleFormats & paFloat32)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paFloat32, ");
|
||||
if (pdi->nativeSampleFormats & paInt24)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt24, ");
|
||||
if (pdi->nativeSampleFormats & paPackedInt24)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paPackedInt24, ");
|
||||
if( pdi->nativeSampleFormats & paInt8 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt8, ");
|
||||
if( pdi->nativeSampleFormats & paUInt8 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paUInt8, ");
|
||||
if( pdi->nativeSampleFormats & paInt16 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt16, ");
|
||||
if( pdi->nativeSampleFormats & paInt32 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt32, ");
|
||||
if( pdi->nativeSampleFormats & paFloat32 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paFloat32, ");
|
||||
if( pdi->nativeSampleFormats & paInt24 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt24, ");
|
||||
if( pdi->nativeSampleFormats & paPackedInt24 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paPackedInt24, ");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "\n");
|
||||
}
|
||||
|
||||
|
@ -729,7 +713,8 @@ static switch_status engage_device(struct private_object *tech_pvt)
|
|||
codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
|
@ -739,14 +724,14 @@ static switch_status engage_device(struct private_object *tech_pvt)
|
|||
codec_ms,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL,
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Loaded codec L16 %dhz %dms on %s\n", sample_rate, codec_ms,
|
||||
switch_channel_get_name(channel));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Loaded codec L16 %dhz %dms on %s\n", sample_rate, codec_ms, switch_channel_get_name(channel));
|
||||
tech_pvt->read_frame.rate = sample_rate;
|
||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
|
||||
|
@ -756,12 +741,8 @@ static switch_status engage_device(struct private_object *tech_pvt)
|
|||
tech_pvt->outdev = globals.outdev;
|
||||
|
||||
switch_mutex_lock(globals.device_lock);
|
||||
if ((tech_pvt->err =
|
||||
OpenAudioStream(&tech_pvt->audio_in, sample_rate, SAMPLE_TYPE, PABLIO_READ | PABLIO_MONO, tech_pvt->indev,
|
||||
-1)) == paNoError) {
|
||||
if ((tech_pvt->err =
|
||||
OpenAudioStream(&tech_pvt->audio_out, sample_rate, SAMPLE_TYPE, PABLIO_WRITE | PABLIO_MONO, -1,
|
||||
tech_pvt->outdev)) != paNoError) {
|
||||
if ((tech_pvt->err = OpenAudioStream( &tech_pvt->audio_in, sample_rate, SAMPLE_TYPE, PABLIO_READ | PABLIO_MONO, tech_pvt->indev, -1)) == paNoError) {
|
||||
if ((tech_pvt->err = OpenAudioStream(&tech_pvt->audio_out, sample_rate, SAMPLE_TYPE, PABLIO_WRITE | PABLIO_MONO, -1, tech_pvt->outdev)) != paNoError) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't open audio out [%d]!\n", tech_pvt->outdev);
|
||||
CloseAudioStream(tech_pvt->audio_in);
|
||||
tech_pvt->audio_in = NULL;
|
||||
|
@ -815,12 +796,14 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
|
|||
if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
|
||||
globals.dialplan,
|
||||
globals.cid_name,
|
||||
globals.cid_num, NULL, NULL, NULL, dest))) {
|
||||
globals.cid_num,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
dest))) {
|
||||
char name[128];
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
|
||||
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->
|
||||
destination_number : modname, rand() & 0xffff);
|
||||
snprintf(name, sizeof(name), "PortAudio/%s-%04x", tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
}
|
||||
tech_pvt->session = session;
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
/************************************************************************/
|
||||
/******** Prototypes ****************************************************/
|
||||
/************************************************************************/
|
||||
static int blockingIOCallback(void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
|
||||
|
||||
static int blockingIOCallback( void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
PaTimestamp outTime, void *userData );
|
||||
static PaError PABLIO_InitFIFO( RingBuffer *rbuf, long numFrames, long bytesPerFrame );
|
||||
static PaError PABLIO_TermFIFO( RingBuffer *rbuf );
|
||||
|
@ -67,7 +69,8 @@
|
|||
/* Called from PortAudio.
|
||||
* Read and write data only if there is room in FIFOs.
|
||||
*/
|
||||
static int blockingIOCallback(void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
|
||||
static int blockingIOCallback( void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
PaTimestamp outTime, void *userData )
|
||||
{
|
||||
PABLIO_Stream *data = (PABLIO_Stream*)userData;
|
||||
|
@ -83,38 +86,34 @@ static int blockingIOCallback(void *inputBuffer, void *outputBuffer,
unsigned l
|
|||
{
|
||||
int i;
|
||||
int numRead = RingBuffer_Read( &data->outFIFO, outputBuffer, numBytes );
|
||||
|
||||
/* Zero out remainder of buffer if we run out of data. */
|
||||
for( i=numRead; i<numBytes; i++ )
|
||||
{
|
||||
((char *)outputBuffer)[i] = 0;
|
||||
}
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate buffer. */
|
||||
static PaError PABLIO_InitFIFO( RingBuffer *rbuf, long numFrames, long bytesPerFrame )
|
||||
{
|
||||
long numBytes = numFrames * bytesPerFrame;
|
||||
char *buffer = (char *) malloc( numBytes );
|
||||
if (buffer == NULL)
|
||||
return paInsufficientMemory;
|
||||
if( buffer == NULL ) return paInsufficientMemory;
|
||||
memset( buffer, 0, numBytes );
|
||||
return (PaError) RingBuffer_Init( rbuf, numBytes, buffer );
|
||||
}
|
||||
|
||||
|
||||
/* Free buffer. */
|
||||
static PaError PABLIO_TermFIFO( RingBuffer *rbuf )
|
||||
{
|
||||
if (rbuf->buffer)
|
||||
free(rbuf->buffer);
|
||||
if( rbuf->buffer ) free( rbuf->buffer );
|
||||
rbuf->buffer = NULL;
|
||||
return paNoError;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Write data to ring buffer.
|
||||
* Will not return until all the data has been written.
|
||||
|
@ -129,13 +128,11 @@ long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
|
|||
bytesWritten = RingBuffer_Write( &aStream->outFIFO, p, numBytes );
|
||||
numBytes -= bytesWritten;
|
||||
p += bytesWritten;
|
||||
if (numBytes > 0)
|
||||
Pa_Sleep(10);
|
||||
if( numBytes > 0) Pa_Sleep(10);
|
||||
}
|
||||
return numFrames;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Read data from ring buffer.
|
||||
* Will not return until all the data has been read.
|
||||
|
@ -150,13 +147,11 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames)
|
|||
bytesRead = RingBuffer_Read( &aStream->inFIFO, p, numBytes );
|
||||
numBytes -= bytesRead;
|
||||
p += bytesRead;
|
||||
if (numBytes > 0)
|
||||
Pa_Sleep(10);
|
||||
if( numBytes > 0) Pa_Sleep(10);
|
||||
}
|
||||
return numFrames;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Return the number of frames that could be written to the stream without
|
||||
* having to wait.
|
||||
|
@ -167,7 +162,6 @@ long GetAudioStreamWriteable(PABLIO_Stream * aStream)
|
|||
return bytesEmpty / aStream->bytesPerFrame;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Return the number of frames that are available to be read from the
|
||||
* stream without having to wait.
|
||||
|
@ -178,13 +172,11 @@ long GetAudioStreamReadable(PABLIO_Stream * aStream)
|
|||
return bytesFull / aStream->bytesPerFrame;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************/
|
||||
static unsigned long RoundUpToNextPowerOf2( unsigned long n )
|
||||
{
|
||||
long numBits = 0;
|
||||
if (((n - 1) & n) == 0)
|
||||
return n; /* Already Power of two. */
|
||||
if( ((n-1) & n) == 0) return n; /* Already Power of two. */
|
||||
while( n > 0 )
|
||||
{
|
||||
n= n>>1;
|
||||
|
@ -193,7 +185,6 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
return (1<<numBits);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Opens a PortAudio stream with default characteristics.
|
||||
* Allocates PABLIO_Stream structure.
|
||||
|
@ -202,8 +193,8 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
* PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
|
||||
* and either PABLIO_MONO or PABLIO_STEREO
|
||||
*/
|
||||
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr, double sampleRate,
PaSampleFormat format, long flags, int indev,
|
||||
int outdev)
|
||||
PaError OpenAudioStream( PABLIO_Stream **rwblPtr, double sampleRate,
|
||||
PaSampleFormat format, long flags, int indev, int outdev )
|
||||
{
|
||||
long bytesPerSample;
|
||||
long doRead = 0;
|
||||
|
@ -215,8 +206,7 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
|
||||
/* Allocate PABLIO_Stream structure for caller. */
|
||||
aStream = (PABLIO_Stream *) malloc( sizeof(PABLIO_Stream) );
|
||||
if (aStream == NULL)
|
||||
return paInsufficientMemory;
|
||||
if( aStream == NULL ) return paInsufficientMemory;
|
||||
memset( aStream, 0, sizeof(PABLIO_Stream) );
|
||||
|
||||
/* Determine size of a sample. */
|
||||
|
@ -231,15 +221,13 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
|
||||
/* Initialize PortAudio */
|
||||
err = Pa_Initialize();
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
/* Warning: numFrames must be larger than amount of data processed per interrupt
|
||||
* inside PA to prevent glitches. Just to be safe, adjust size upwards.
|
||||
*/
|
||||
minNumBuffers = 2 * Pa_GetMinNumBuffers( FRAMES_PER_BUFFER, sampleRate );
|
||||
numFrames = minNumBuffers * FRAMES_PER_BUFFER;
|
||||
|
||||
/* The PortAudio callback runs in a high priority thread. But PABLIO
|
||||
* runs in a normal foreground thread. So we may have much worse
|
||||
* latency in PABLIO. So adjust latency to a safe level.
|
||||
|
@ -251,7 +239,8 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
{
|
||||
numFrames = (int) ((safeLatencyMSec * sampleRate) / 1000);
|
||||
}
|
||||
}
numFrames = RoundUpToNextPowerOf2(numFrames);
|
||||
}
|
||||
numFrames = RoundUpToNextPowerOf2( numFrames );
|
||||
|
||||
/* Initialize Ring Buffers */
|
||||
doRead = ((flags & PABLIO_READ) != 0);
|
||||
|
@ -259,16 +248,13 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
if(doRead)
|
||||
{
|
||||
err = PABLIO_InitFIFO( &aStream->inFIFO, numFrames, aStream->bytesPerFrame );
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
if( err != paNoError ) goto error;
|
||||
}
|
||||
if(doWrite)
|
||||
{
|
||||
long numBytes;
|
||||
err = PABLIO_InitFIFO( &aStream->outFIFO, numFrames, aStream->bytesPerFrame );
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
|
||||
if( err != paNoError ) goto error;
|
||||
/* Make Write FIFO appear full initially. */
|
||||
numBytes = RingBuffer_GetWriteAvailable( &aStream->outFIFO );
|
||||
RingBuffer_AdvanceWriteIndex( &aStream->outFIFO, numBytes );
|
||||
|
@ -276,36 +262,45 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
|
||||
/* Open a PortAudio stream that we will use to communicate with the underlying
|
||||
* audio drivers. */
|
||||
err = Pa_OpenStream(
&aStream->stream,
|
||||
err = Pa_OpenStream(
|
||||
&aStream->stream,
|
||||
(doRead ? (indev > -1) ? indev : Pa_GetDefaultInputDeviceID() : paNoDevice),
|
||||
(doRead ? aStream->samplesPerFrame : 0),
format,
NULL,
|
||||
(doRead ? aStream->samplesPerFrame : 0 ),
|
||||
format,
|
||||
NULL,
|
||||
(doWrite ? (outdev > -1) ? outdev : Pa_GetDefaultOutputDeviceID() : paNoDevice),
|
||||
(doWrite ? aStream->samplesPerFrame : 0),
format,
NULL,
sampleRate,
FRAMES_PER_BUFFER,
|
||||
minNumBuffers,
paClipOff,
|
||||
/* we won't output out of range samples so don't bother clipping them */
|
||||
blockingIOCallback,
aStream);
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
(doWrite ? aStream->samplesPerFrame : 0 ),
|
||||
format,
|
||||
NULL,
|
||||
sampleRate,
|
||||
FRAMES_PER_BUFFER,
|
||||
minNumBuffers,
|
||||
paClipOff, /* we won't output out of range samples so don't bother clipping them */
|
||||
blockingIOCallback,
|
||||
aStream );
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
err = Pa_StartStream( aStream->stream );
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
*rwblPtr = aStream;
|
||||
return paNoError;
|
||||
error:
CloseAudioStream(aStream);
|
||||
|
||||
error:
|
||||
CloseAudioStream( aStream );
|
||||
*rwblPtr = NULL;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************/
|
||||
PaError CloseAudioStream( PABLIO_Stream *aStream )
|
||||
{
|
||||
PaError err = paNoError;
|
||||
int bytesEmpty;
|
||||
int byteSize = aStream->outFIFO.bufferSize;
|
||||
|
||||
if( aStream->stream != NULL ) /* Make sure stream was opened. PLB021214 */
|
||||
{
|
||||
|
||||
/* If we are writing data, make sure we play everything written. */
|
||||
if( byteSize > 0 )
|
||||
{
|
||||
|
@ -319,15 +314,14 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
|||
}
|
||||
}
|
||||
err = Pa_StopStream( aStream->stream );
|
||||
if (err != paNoError)
|
||||
goto error;
|
||||
if( err != paNoError ) goto error;
|
||||
err = Pa_CloseStream( aStream->stream );
|
||||
}
|
||||
error:
Pa_Terminate();
|
||||
|
||||
error:
|
||||
Pa_Terminate();
|
||||
PABLIO_TermFIFO( &aStream->inFIFO );
|
||||
PABLIO_TermFIFO( &aStream->outFIFO );
|
||||
free( aStream );
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@
|
|||
*/
|
||||
long RingBuffer_Init( RingBuffer *rbuf, long numBytes, void *dataPtr )
|
||||
{
|
||||
if (((numBytes - 1) & numBytes) != 0)
|
||||
return -1; /* Not Power of two. */
|
||||
if( ((numBytes-1) & numBytes) != 0) return -1; /* Not Power of two. */
|
||||
rbuf->bufferSize = numBytes;
|
||||
rbuf->buffer = (char *)dataPtr;
|
||||
RingBuffer_Flush( rbuf );
|
||||
|
@ -54,16 +53,12 @@ long RingBuffer_Init(RingBuffer * rbuf, long numBytes, void *dataPtr)
|
|||
rbuf->smallMask = (numBytes)-1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
** Return number of bytes available for reading. */
|
||||
long RingBuffer_GetReadAvailable( RingBuffer *rbuf )
|
||||
{
|
||||
return ( (rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask );
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
** Return number of bytes available for writing. */
|
||||
long RingBuffer_GetWriteAvailable( RingBuffer *rbuf )
|
||||
|
@ -71,7 +66,6 @@ long RingBuffer_GetWriteAvailable(RingBuffer * rbuf)
|
|||
return ( rbuf->bufferSize - RingBuffer_GetReadAvailable(rbuf));
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
** Clear buffer. Should only be called when buffer is NOT being read. */
|
||||
void RingBuffer_Flush( RingBuffer *rbuf )
|
||||
|
@ -85,19 +79,17 @@ void RingBuffer_Flush(RingBuffer * rbuf)
|
|||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long RingBuffer_GetWriteRegions(RingBuffer * rbuf, long numBytes,
void **dataPtr1, long *sizePtr1,
void **dataPtr2,
|
||||
long *sizePtr2)
|
||||
long RingBuffer_GetWriteRegions( RingBuffer *rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1,
|
||||
void **dataPtr2, long *sizePtr2 )
|
||||
{
|
||||
long index;
|
||||
long available = RingBuffer_GetWriteAvailable( rbuf );
|
||||
if (numBytes > available)
|
||||
numBytes = available;
|
||||
|
||||
if( numBytes > available ) numBytes = available;
|
||||
/* Check to see if write is not contiguous. */
|
||||
index = rbuf->writeIndex & rbuf->smallMask;
|
||||
if( (index + numBytes) > rbuf->bufferSize )
|
||||
{
|
||||
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
long firstHalf = rbuf->bufferSize - index;
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
|
@ -105,7 +97,6 @@ long RingBuffer_GetWriteRegions(RingBuffer * rbuf, long numBytes,
void **dataPt
|
|||
*dataPtr2 = &rbuf->buffer[0];
|
||||
*sizePtr2 = numBytes - firstHalf;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
|
@ -124,26 +115,23 @@ long RingBuffer_AdvanceWriteIndex(RingBuffer * rbuf, long numBytes)
|
|||
return rbuf->writeIndex = (rbuf->writeIndex + numBytes) & rbuf->bigMask;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
** Get address of region(s) from which we can read data.
|
||||
** If the region is contiguous, size2 will be zero.
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or numBytes, whichever is smaller.
|
||||
*/
|
||||
long RingBuffer_GetReadRegions(RingBuffer * rbuf, long numBytes,
void **dataPtr1, long *sizePtr1,
void **dataPtr2,
|
||||
long *sizePtr2)
|
||||
long RingBuffer_GetReadRegions( RingBuffer *rbuf, long numBytes,
|
||||
void **dataPtr1, long *sizePtr1,
|
||||
void **dataPtr2, long *sizePtr2 )
|
||||
{
|
||||
long index;
|
||||
long available = RingBuffer_GetReadAvailable( rbuf );
|
||||
if (numBytes > available)
|
||||
numBytes = available;
|
||||
|
||||
if( numBytes > available ) numBytes = available;
|
||||
/* Check to see if read is not contiguous. */
|
||||
index = rbuf->readIndex & rbuf->smallMask;
|
||||
if( (index + numBytes) > rbuf->bufferSize )
|
||||
{
|
||||
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
long firstHalf = rbuf->bufferSize - index;
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
|
@ -151,7 +139,6 @@ long RingBuffer_GetReadRegions(RingBuffer * rbuf, long numBytes,
void **dataPtr
|
|||
*dataPtr2 = &rbuf->buffer[0];
|
||||
*sizePtr2 = numBytes - firstHalf;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
*dataPtr1 = &rbuf->buffer[index];
|
||||
|
@ -161,8 +148,6 @@ long RingBuffer_GetReadRegions(RingBuffer * rbuf, long numBytes,
void **dataPtr
|
|||
}
|
||||
return numBytes;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*/
|
||||
long RingBuffer_AdvanceReadIndex( RingBuffer *rbuf, long numBytes )
|
||||
|
@ -170,7 +155,6 @@ long RingBuffer_AdvanceReadIndex(RingBuffer * rbuf, long numBytes)
|
|||
return rbuf->readIndex = (rbuf->readIndex + numBytes) & rbuf->bigMask;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
** Return bytes written. */
|
||||
long RingBuffer_Write( RingBuffer *rbuf, void *data, long numBytes )
|
||||
|
@ -180,11 +164,11 @@ long RingBuffer_Write(RingBuffer * rbuf, void *data, long numBytes)
|
|||
numWritten = RingBuffer_GetWriteRegions( rbuf, numBytes, &data1, &size1, &data2, &size2 );
|
||||
if( size2 > 0 )
|
||||
{
|
||||
|
||||
memcpy( data1, data, size1 );
|
||||
data = ((char *)data) + size1;
|
||||
memcpy( data2, data, size2 );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
memcpy( data1, data, size1 );
|
||||
|
@ -193,7 +177,6 @@ long RingBuffer_Write(RingBuffer * rbuf, void *data, long numBytes)
|
|||
return numWritten;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
** Return bytes read. */
|
||||
long RingBuffer_Read( RingBuffer *rbuf, void *data, long numBytes )
|
||||
|
@ -207,7 +190,6 @@ long RingBuffer_Read(RingBuffer * rbuf, void *data, long numBytes)
|
|||
data = ((char *)data) + size1;
|
||||
memcpy( data, data2, size2 );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
memcpy( data, data1, size1 );
|
||||
|
@ -215,5 +197,3 @@ long RingBuffer_Read(RingBuffer * rbuf, void *data, long numBytes)
|
|||
RingBuffer_AdvanceReadIndex( rbuf, numRead );
|
||||
return numRead;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -153,12 +153,9 @@ static switch_status wanpipe_on_init(switch_core_session *session);
|
|||
static switch_status wanpipe_on_hangup(switch_core_session *session);
|
||||
static switch_status wanpipe_on_loopback(switch_core_session *session);
|
||||
static switch_status wanpipe_on_transmit(switch_core_session *session);
|
||||
static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
|
||||
static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
|
||||
static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
|
||||
|
@ -225,12 +222,8 @@ static switch_status wanpipe_on_hangup(switch_core_session *session)
|
|||
|
||||
switch_socket_close(&tech_pvt->socket);
|
||||
|
||||
pri_hangup(tech_pvt->spri->pri,
|
||||
tech_pvt->hangup_event.hangup.call ? tech_pvt->hangup_event.hangup.call : tech_pvt->ring_event.ring.call,
|
||||
tech_pvt->cause);
|
||||
pri_destroycall(tech_pvt->spri->pri,
|
||||
tech_pvt->hangup_event.hangup.call ? tech_pvt->hangup_event.hangup.call : tech_pvt->ring_event.ring.
|
||||
call);
|
||||
pri_hangup(tech_pvt->spri->pri, tech_pvt->hangup_event.hangup.call ? tech_pvt->hangup_event.hangup.call : tech_pvt->ring_event.ring.call, tech_pvt->cause);
|
||||
pri_destroycall(tech_pvt->spri->pri, tech_pvt->hangup_event.hangup.call ? tech_pvt->hangup_event.hangup.call : tech_pvt->ring_event.ring.call);
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WANPIPE HANGUP\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -248,8 +241,7 @@ static switch_status wanpipe_on_transmit(switch_core_session *session)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status wanpipe_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NOT IMPLEMENTED\n");
|
||||
|
||||
|
@ -274,8 +266,7 @@ static switch_status wanpipe_answer_channel(switch_core_session *session)
|
|||
|
||||
|
||||
|
||||
static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status wanpipe_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel = NULL;
|
||||
|
@ -300,9 +291,12 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((res = sangoma_readmsg_socket(tech_pvt->socket,
|
||||
if ((res = sangoma_readmsg_socket(
|
||||
tech_pvt->socket,
|
||||
&tech_pvt->hdrframe,
|
||||
sizeof(tech_pvt->hdrframe), bp, sizeof(tech_pvt->databuf) - bytes, 0)) < 0) {
|
||||
sizeof(tech_pvt->hdrframe),
|
||||
bp,
|
||||
sizeof(tech_pvt->databuf) - bytes, 0)) < 0) {
|
||||
if (errno == EBUSY) {
|
||||
continue;
|
||||
} else {
|
||||
|
@ -318,8 +312,7 @@ static switch_status wanpipe_read_frame(switch_core_session *session, switch_fra
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status wanpipe_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel = NULL;
|
||||
|
@ -336,12 +329,14 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr
|
|||
|
||||
while (bytes > 0) {
|
||||
switch_socket_waitfor(tech_pvt->socket, -1, POLLOUT | POLLERR | POLLHUP);
|
||||
res = sangoma_sendmsg_socket(tech_pvt->socket,
|
||||
&tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), bp, PACKET_LEN, 0);
|
||||
res = sangoma_sendmsg_socket(
|
||||
tech_pvt->socket,
|
||||
&tech_pvt->hdrframe,
|
||||
sizeof(tech_pvt->hdrframe),
|
||||
bp,
|
||||
PACKET_LEN, 0);
|
||||
if (res < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
|
||||
"Bad Write frame len %d write %d bytes returned %d errno %d!\n", frame->datalen,
|
||||
PACKET_LEN, res, errno);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bad Write frame len %d write %d bytes returned %d errno %d!\n", frame->datalen, PACKET_LEN, res, errno);
|
||||
if (errno == EBUSY) {
|
||||
continue;
|
||||
}
|
||||
|
@ -390,8 +385,7 @@ static const switch_loadable_module_interface wanpipe_module_interface = {
|
|||
/*.application_interface*/ NULL
|
||||
};
|
||||
|
||||
Public switch_status switch_module_load(const switch_loadable_module_interface **interface, chanr * filename)
|
||||
{
|
||||
Public switch_status switch_module_load(const switch_loadable_module_interface **interface, chanr *filename) {
|
||||
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -459,13 +453,11 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
|
|||
|
||||
chanmap = spri->private;
|
||||
if (chanmap->map[event->ring.channel]) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "--Duplicate Ring on channel %d (ignored)\n",
|
||||
event->ring.channel);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,"--Duplicate Ring on channel %d (ignored)\n", event->ring.channel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "-- Ring on channel %d (from %s to %s)\n", event->ring.channel,
|
||||
event->ring.callingnum, event->ring.callednum);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,"-- Ring on channel %d (from %s to %s)\n", event->ring.channel, event->ring.callingnum, event->ring.callednum);
|
||||
|
||||
sprintf(name, "w%dg%d", globals.span, event->ring.channel);
|
||||
if ((session = switch_core_session_request(&wanpipe_endpoint_interface, NULL))) {
|
||||
|
@ -510,6 +502,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
|
|||
if ((fd = sangoma_create_socket_intr(spri->span, event->ring.channel)) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't open fd!\n");
|
||||
}
|
||||
|
||||
//sangoma_tdm_set_hw_period(fd, &tdm_api, 480);
|
||||
|
||||
tech_pvt->socket = fd;
|
||||
|
@ -547,8 +540,7 @@ static int on_restart(struct sangoma_pri *spri, sangoma_pri_event_t event_type,
|
|||
|
||||
static int on_anything(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event)
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Caught Event %d (%s)\n", event_type,
|
||||
sangoma_pri_event_str(event_type));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,"Caught Event %d (%s)\n", event_type, sangoma_pri_event_str(event_type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -616,7 +608,13 @@ static int config_wanpipe(int reload)
|
|||
|
||||
if ((spri=switch_core_alloc(module_pool, sizeof(*spri)))) {
|
||||
memset(spri, 0, sizeof(*spri));
|
||||
sangoma_init_pri(spri, globals.span, globals.dchan, 23, globals.pswitch, globals.node, globals.debug);
|
||||
sangoma_init_pri(spri,
|
||||
globals.span,
|
||||
globals.dchan,
|
||||
23,
|
||||
globals.pswitch,
|
||||
globals.node,
|
||||
globals.debug);
|
||||
|
||||
pri_thread_run(NULL, spri);
|
||||
|
||||
|
@ -634,3 +632,4 @@ Public switch_status switch_module_runtime(void)
|
|||
config_wanpipe(0);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,20 +171,16 @@ static switch_status woomerachan_on_hangup(switch_core_session *session);
|
|||
static switch_status woomerachan_on_ring(switch_core_session *session);
|
||||
static switch_status woomerachan_on_loopback(switch_core_session *session);
|
||||
static switch_status woomerachan_on_transmit(switch_core_session *session);
|
||||
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session);
|
||||
static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id);
|
||||
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
|
||||
static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
|
||||
static switch_status woomerachan_kill_channel(switch_core_session *session, int sig);
|
||||
static void tech_destroy(private_object *tech_pvt);
|
||||
static void woomera_printf(woomera_profile *profile, switch_socket_t *socket, char *fmt, ...);
|
||||
static char *woomera_message_header(woomera_message *wmsg, char *key);
|
||||
static int woomera_enqueue_event(woomera_event_queue *event_queue, woomera_message *wmsg);
|
||||
static int woomera_dequeue_event(woomera_event_queue *event_queue, woomera_message *wmsg);
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, int timeout, woomera_profile * profile,
|
||||
woomera_event_queue * event_queue);
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message *wmsg, int timeout, woomera_profile *profile, woomera_event_queue *event_queue);
|
||||
static int connect_woomera(switch_socket_t **new_sock, woomera_profile *profile, int flags);
|
||||
static int woomera_profile_thread_running(woomera_profile *profile, int set, int new);
|
||||
static int woomera_locate_socket(woomera_profile *profile, switch_socket_t **woomera_socket);
|
||||
|
@ -212,17 +208,13 @@ static switch_status woomerachan_on_init(switch_core_session *session)
|
|||
|
||||
tech_pvt->frame.data = tech_pvt->databuf;
|
||||
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->read_codec, "L16", rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_codec_init(&tech_pvt->read_codec, "L16", rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_core_codec_init
|
||||
(&tech_pvt->write_codec, "L16", rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_core_codec_init(&tech_pvt->write_codec, "L16", rate, 30, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Cannot set read codec\n", switch_channel_get_name(channel));
|
||||
switch_channel_hangup(channel);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -330,8 +322,7 @@ static switch_status woomerachan_kill_channel(switch_core_session *session, int
|
|||
udp_socket_close(tech_pvt);
|
||||
|
||||
switch_channel_hangup(channel);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s WOOMERACHAN KILL %d\n", switch_channel_get_name(channel),
|
||||
tech_pvt->udp_socket);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s WOOMERACHAN KILL %d\n", switch_channel_get_name(channel), tech_pvt->udp_socket);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -353,16 +344,14 @@ static switch_status woomerachan_on_transmit(switch_core_session *session)
|
|||
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
|
||||
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
|
||||
*/
|
||||
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
|
||||
switch_core_session **new_session)
|
||||
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
|
||||
{
|
||||
if ((*new_session = switch_core_session_request(&woomerachan_endpoint_interface, NULL))) {
|
||||
struct private_object *tech_pvt;
|
||||
switch_channel *channel;
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
tech_pvt->profile = &default_profile;
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
|
@ -420,8 +409,7 @@ static switch_status woomerachan_waitfor_write(switch_core_session *session, int
|
|||
return switch_socket_waitfor(&tech_pvt->write_poll, ms);
|
||||
}
|
||||
|
||||
static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -446,16 +434,13 @@ static switch_status woomerachan_read_frame(switch_core_session *session, switch
|
|||
*frame = pframe;
|
||||
|
||||
pframe->datalen = sizeof(tech_pvt->databuf);
|
||||
if ((status =
|
||||
switch_socket_recvfrom(tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf,
|
||||
&pframe->datalen)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = switch_socket_recvfrom (tech_pvt->udpread, tech_pvt->udp_socket, 0, tech_pvt->databuf, &pframe->datalen)) == SWITCH_STATUS_SUCCESS) {
|
||||
pframe->samples = (int)pframe->datalen / 2;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout,
|
||||
switch_io_flag flags, int stream_id)
|
||||
static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
|
||||
{
|
||||
switch_channel *channel = NULL;
|
||||
struct private_object *tech_pvt = NULL;
|
||||
|
@ -522,10 +507,13 @@ static void tech_destroy(private_object * tech_pvt)
|
|||
}
|
||||
|
||||
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "hangup %s%s", tech_pvt->call_info.callid,
|
||||
WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "hangup %s%s", tech_pvt->call_info.callid, WOOMERA_RECORD_SEPERATOR);
|
||||
if(woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
tech_pvt->profile,
|
||||
&tech_pvt->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} Already Disconnected\n", tech_pvt->profile->name);
|
||||
}
|
||||
|
||||
|
@ -553,8 +541,7 @@ static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, c
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Out of memory\n");
|
||||
} else {
|
||||
if (profile && globals.debug) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Send Message: {%s} [%s/%d]\n%s\n%s", profile->name,
|
||||
profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, stuff);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Send Message: {%s} [%s/%d]\n%s\n%s", profile->name, profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, stuff);
|
||||
}
|
||||
len = strlen(stuff);
|
||||
switch_socket_send(socket, stuff, &len);
|
||||
|
@ -621,8 +608,7 @@ static int woomera_dequeue_event(woomera_event_queue * event_queue, woomera_mess
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, int timeout, woomera_profile * profile,
|
||||
woomera_event_queue * event_queue)
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message *wmsg, int timeout, woomera_profile *profile, woomera_event_queue *event_queue)
|
||||
{
|
||||
char *cur, *cr, *next = NULL, *eor = NULL;
|
||||
char buf[2048] = "", *ptr;
|
||||
|
@ -661,8 +647,7 @@ static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, in
|
|||
next = buf;
|
||||
|
||||
if (globals.debug) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Receive Message: {%s} [%s/%d]\n%s\n%s", profile->name,
|
||||
profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Receive Message: {%s} [%s/%d]\n%s\n%s", profile->name, profile->woomera_host, profile->woomera_port, WOOMERA_DEBUG_LINE, buf);
|
||||
}
|
||||
|
||||
while((cur = next)) {
|
||||
|
@ -824,8 +809,7 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
|
|||
if (!woomera_profile_thread_running(profile, 0, 0)) {
|
||||
break;
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n",
|
||||
profile->name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} Cannot Reconnect to Woomera! retry in 5 seconds\n", profile->name);
|
||||
switch_sleep(WOOMERA_RECONNECT_TIME);
|
||||
}
|
||||
|
||||
|
@ -833,7 +817,11 @@ static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **wo
|
|||
if (switch_test_flag(profile, PFLAG_INBOUND)) {
|
||||
woomera_printf(profile, *woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(*woomera_socket,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
profile,
|
||||
&profile->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n", profile->name);
|
||||
globals.panic = 1;
|
||||
woomera_profile_thread_running(&default_profile, 1, 0);
|
||||
|
@ -901,17 +889,26 @@ static int tech_activate(private_object * tech_pvt)
|
|||
tech_pvt->port,
|
||||
WOOMERA_LINE_SEPERATOR,
|
||||
tech_pvt->caller_profile->caller_id_name,
|
||||
tech_pvt->caller_profile->caller_id_number, WOOMERA_RECORD_SEPERATOR);
|
||||
tech_pvt->caller_profile->caller_id_number,
|
||||
WOOMERA_RECORD_SEPERATOR
|
||||
);
|
||||
|
||||
woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue);
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
tech_pvt->profile,
|
||||
&tech_pvt->event_queue
|
||||
);
|
||||
} else {
|
||||
switch_set_flag(tech_pvt, TFLAG_PARSE_INCOMING);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
tech_pvt->profile,
|
||||
&tech_pvt->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
}
|
||||
|
@ -967,13 +964,14 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
if (switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
|
||||
switch_clear_flag(tech_pvt, TFLAG_ANSWER);
|
||||
#ifdef USE_ANSWER
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "ANSWER %s%s", tech_pvt->call_info.callid,
|
||||
WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
|
||||
&tech_pvt->event_queue) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "ANSWER %s%s",tech_pvt->call_info.callid, WOOMERA_RECORD_SEPERATOR);
|
||||
if(woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
tech_pvt->profile,
|
||||
&tech_pvt->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
|
@ -983,13 +981,14 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_DTMF)) {
|
||||
switch_mutex_lock(tech_pvt->iolock);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "DTMF %s %s%s", tech_pvt->call_info.callid,
|
||||
tech_pvt->dtmfbuf, WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse
|
||||
(tech_pvt->command_channel, &wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile,
|
||||
&tech_pvt->event_queue) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
woomera_printf(tech_pvt->profile, tech_pvt->command_channel, "DTMF %s %s%s",tech_pvt->call_info.callid, tech_pvt->dtmfbuf, WOOMERA_RECORD_SEPERATOR);
|
||||
if(woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
tech_pvt->profile,
|
||||
&tech_pvt->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
|
@ -998,14 +997,13 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
memset(tech_pvt->dtmfbuf, 0, sizeof(tech_pvt->dtmfbuf));
|
||||
switch_mutex_unlock(tech_pvt->iolock);
|
||||
}
|
||||
|
||||
#if 1==0 /*convert to use switch_time_now */
|
||||
if(tech_pvt->timeout) {
|
||||
struct timeval now;
|
||||
int elapsed;
|
||||
gettimeofday(&now, NULL);
|
||||
elapsed =
|
||||
(((now.tv_sec * 1000) + now.tv_usec / 1000) -
|
||||
((tech_pvt->started.tv_sec * 1000) + tech_pvt->started.tv_usec / 1000));
|
||||
elapsed = (((now.tv_sec * 1000) + now.tv_usec / 1000) - ((tech_pvt->started.tv_sec * 1000) + tech_pvt->started.tv_usec / 1000));
|
||||
if (elapsed > tech_pvt->timeout) {
|
||||
/* call timed out! */
|
||||
switch_set_flag(tech_pvt, TFLAG_ABORT);
|
||||
|
@ -1018,7 +1016,12 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
}
|
||||
/* Check for events */
|
||||
if((res = woomera_dequeue_event(&tech_pvt->event_queue, &wmsg)) ||
|
||||
(res = woomera_message_parse(tech_pvt->command_channel, &wmsg, 100, tech_pvt->profile, NULL))) {
|
||||
(res = woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg,
|
||||
100,
|
||||
tech_pvt->profile,
|
||||
NULL
|
||||
))) {
|
||||
|
||||
if (res < 0 || !strcasecmp(wmsg.command, "HANGUP")) {
|
||||
switch_set_flag(tech_pvt, TFLAG_ABORT);
|
||||
|
@ -1067,11 +1070,15 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
|
||||
tech_pvt->profile->dialplan,
|
||||
cid_name, cid_num, ip, NULL, NULL, exten))) {
|
||||
cid_name,
|
||||
cid_num,
|
||||
ip,
|
||||
NULL,
|
||||
NULL,
|
||||
exten))) {
|
||||
char name[128];
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number,
|
||||
rand() & 0xffff);
|
||||
snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
}
|
||||
|
||||
|
@ -1081,12 +1088,17 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
MEDIA_ANSWER,
|
||||
wmsg.callid,
|
||||
WOOMERA_LINE_SEPERATOR,
|
||||
tech_pvt->profile->audio_ip, tech_pvt->port, WOOMERA_RECORD_SEPERATOR);
|
||||
tech_pvt->profile->audio_ip,
|
||||
tech_pvt->port,
|
||||
WOOMERA_RECORD_SEPERATOR);
|
||||
|
||||
if(woomera_message_parse(tech_pvt->command_channel,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, tech_pvt->profile, &tech_pvt->event_queue) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n",
|
||||
tech_pvt->profile->name);
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
tech_pvt->profile,
|
||||
&tech_pvt->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n", tech_pvt->profile->name);
|
||||
switch_set_flag(tech_pvt, TFLAG_ABORT);
|
||||
globals.panic = 1;
|
||||
continue;
|
||||
|
@ -1117,12 +1129,9 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
SWITCH_UNSPEC,
|
||||
port,
|
||||
0,
|
||||
switch_core_session_get_pool(tech_pvt->session)) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||
if (globals.debug) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
|
||||
WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n",
|
||||
tech_pvt->profile->name, ip);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, WOOMERA_DEBUG_PREFIX "{%s} Cannot resolve %s\n", tech_pvt->profile->name, ip);
|
||||
}
|
||||
switch_channel_hangup(channel);
|
||||
}
|
||||
|
@ -1130,13 +1139,11 @@ static void *woomera_channel_thread_run(switch_thread *thread, void *obj)
|
|||
}
|
||||
}
|
||||
if (globals.debug > 2) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, WOOMERA_DEBUG_PREFIX "CHECK {%s}(%d)\n",
|
||||
tech_pvt->profile->name, res);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, WOOMERA_DEBUG_PREFIX "CHECK {%s}(%d)\n", tech_pvt->profile->name, res);
|
||||
}
|
||||
}
|
||||
if (globals.debug > 1) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, WOOMERA_DEBUG_PREFIX "Monitor thread for %s done.\n",
|
||||
tech_pvt->profile->name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, WOOMERA_DEBUG_PREFIX "Monitor thread for %s done.\n", tech_pvt->profile->name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -1174,8 +1181,7 @@ static void *woomera_thread_run(void *obj)
|
|||
if (!woomera_profile_thread_running(profile, 0, 0)) {
|
||||
break;
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Woomera Thread Up {%s} %s/%d\n", profile->name,
|
||||
profile->woomera_host, profile->woomera_port);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Woomera Thread Up {%s} %s/%d\n", profile->name, profile->woomera_host, profile->woomera_port);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1191,12 +1197,15 @@ static void *woomera_thread_run(void *obj)
|
|||
}
|
||||
|
||||
if ((res = woomera_dequeue_event(&profile->event_queue, &wmsg) ||
|
||||
(res = woomera_message_parse(profile->woomera_socket, &wmsg,
|
||||
(res = woomera_message_parse(profile->woomera_socket,
|
||||
&wmsg,
|
||||
/* if we are not stingy with threads we can block forever */
|
||||
0, profile, NULL)))) {
|
||||
0,
|
||||
profile,
|
||||
NULL
|
||||
)))) {
|
||||
if (res < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! I lost my connection to woomera!\n",
|
||||
profile->name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! I lost my connection to woomera!\n", profile->name);
|
||||
woomera_socket_close(&profile->woomera_socket);
|
||||
|
||||
//global_set_flag(TFLAG_ABORT);
|
||||
|
@ -1207,16 +1216,18 @@ static void *woomera_thread_run(void *obj)
|
|||
if (switch_test_flag(profile, PFLAG_INBOUND)) {
|
||||
woomera_printf(profile, profile->woomera_socket, "LISTEN%s", WOOMERA_RECORD_SEPERATOR);
|
||||
if (woomera_message_parse(profile->woomera_socket,
|
||||
&wmsg, WOOMERA_HARD_TIMEOUT, profile, &profile->event_queue) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n",
|
||||
profile->name);
|
||||
&wmsg,
|
||||
WOOMERA_HARD_TIMEOUT,
|
||||
profile,
|
||||
&profile->event_queue
|
||||
) < 0) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "{%s} HELP! Woomera is broken!\n", profile->name);
|
||||
globals.panic = 1;
|
||||
woomera_socket_close(&profile->woomera_socket);
|
||||
}
|
||||
}
|
||||
if (profile->woomera_socket) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Woomera Thread Up {%s} %s/%d\n", profile->name,
|
||||
profile->woomera_host, profile->woomera_port);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Woomera Thread Up {%s} %s/%d\n", profile->name, profile->woomera_host, profile->woomera_port);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
@ -1237,8 +1248,7 @@ static void *woomera_thread_run(void *obj)
|
|||
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
if ((tech_pvt =
|
||||
(struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
|
||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||
tech_pvt->profile = &default_profile;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
@ -1295,8 +1305,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
switch_config cfg;
|
||||
char *var, *val;
|
||||
|
@ -1375,3 +1384,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul
|
|||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -104,8 +104,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
|||
#endif
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &event_test_module_interface;
|
||||
|
||||
|
@ -113,9 +112,9 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_inte
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't register subclass!");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
#ifdef TORTURE_ME
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *)modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
@ -131,3 +130,4 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_inte
|
|||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,8 +131,7 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_jid, globals.jid)
|
|||
|
||||
if (count == 3) {
|
||||
/* TBD use config to pick what events to bind to */
|
||||
if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind((char *)modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
@ -163,8 +162,7 @@ int on_stream(struct session *sess, int type, iks * node)
|
|||
case IKS_NODE_NORMAL:
|
||||
if (strcmp ("stream:features", iks_name (node)) == 0) {
|
||||
sess->features = iks_stream_features (node);
|
||||
if (opt_use_tls && !iks_is_secure(sess->parser))
|
||||
break;
|
||||
if (opt_use_tls && !iks_is_secure (sess->parser)) break;
|
||||
if (sess->authorized) {
|
||||
iks *t;
|
||||
if (sess->features & IKS_STREAM_BIND) {
|
||||
|
@ -195,8 +193,7 @@ int on_stream(struct session *sess, int type, iks * node)
|
|||
|
||||
pak = iks_packet (node);
|
||||
iks_filter_packet (my_filter, pak);
|
||||
if (sess->job_done == 1)
|
||||
return IKS_HOOK;
|
||||
if (sess->job_done == 1) return IKS_HOOK;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
|
@ -211,8 +208,7 @@ int on_stream(struct session *sess, int type, iks * node)
|
|||
|
||||
}
|
||||
|
||||
if (node)
|
||||
iks_delete(node);
|
||||
if (node) iks_delete (node);
|
||||
return IKS_OK;
|
||||
}
|
||||
|
||||
|
@ -246,29 +242,30 @@ int on_error(void *user_data, ikspak * pak)
|
|||
|
||||
void on_log (struct session *sess, const char *data, size_t size, int is_incoming)
|
||||
{
|
||||
if (iks_is_secure(sess->parser))
|
||||
fprintf(stderr, "Sec");
|
||||
if (is_incoming)
|
||||
fprintf(stderr, "RECV");
|
||||
else
|
||||
fprintf(stderr, "SEND");
|
||||
if (iks_is_secure (sess->parser)) fprintf (stderr, "Sec");
|
||||
if (is_incoming) fprintf (stderr, "RECV"); else fprintf (stderr, "SEND");
|
||||
fprintf (stderr, "[%s]\n", data);
|
||||
}
|
||||
|
||||
void j_setup_filter (struct session *sess)
|
||||
{
|
||||
if (my_filter)
|
||||
iks_filter_delete(my_filter);
|
||||
if (my_filter) iks_filter_delete (my_filter);
|
||||
my_filter = iks_filter_new ();
|
||||
iks_filter_add_rule (my_filter, on_msg, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_MESSAGE,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_CHAT, IKS_RULE_FROM, globals.target_jid, IKS_RULE_DONE);
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_CHAT,
|
||||
IKS_RULE_FROM, globals.target_jid,
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (my_filter, (iksFilterHook *) on_result, sess,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
|
||||
IKS_RULE_ID, "auth",
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (my_filter, on_error, sess,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_ID, "auth", IKS_RULE_DONE);
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_ERROR,
|
||||
IKS_RULE_ID, "auth",
|
||||
IKS_RULE_DONE);
|
||||
}
|
||||
|
||||
static void xmpp_connect (char *jabber_id, char *pass)
|
||||
|
@ -278,8 +275,7 @@ static void xmpp_connect(char *jabber_id, char *pass)
|
|||
|
||||
memset (&globals.session, 0, sizeof (globals.session));
|
||||
globals.session.parser = iks_stream_new (IKS_NS_CLIENT, &globals.session, (iksStreamHook *) on_stream);
|
||||
if (globals.debug)
|
||||
iks_set_log_hook(globals.session.parser, (iksLogHook *) on_log);
|
||||
if (globals.debug) iks_set_log_hook (globals.session.parser, (iksLogHook *) on_log);
|
||||
globals.session.acc = iks_id_new (iks_parser_stack (globals.session.parser), jabber_id);
|
||||
if (NULL == globals.session.acc->resource) {
|
||||
/* user gave no resource name, use the default */
|
||||
|
@ -355,8 +351,7 @@ static switch_loadable_module_interface xmpp_event_module_interface = {
|
|||
/*.application_interface*/ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &xmpp_event_module_interface;
|
||||
|
||||
|
|
|
@ -103,8 +103,7 @@ switch_status sndfile_file_open(switch_file_handle *handle, char *path)
|
|||
}
|
||||
|
||||
if (!(context->handle = sf_open(path, mode, &context->sfinfo))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error Opening File [%s] [%s]\n", path,
|
||||
sf_strerror(context->handle));
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error Opening File [%s] [%s]\n", path, sf_strerror(context->handle));
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
@ -232,8 +231,7 @@ static switch_status setup_formats(void)
|
|||
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "\nLibSndFile Version : %s Supported Formats\n", buffer) ;
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN,
|
||||
"================================================================================\n");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "================================================================================\n");
|
||||
sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
|
||||
|
||||
|
@ -275,13 +273,11 @@ static switch_status setup_formats(void)
|
|||
|
||||
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN,
|
||||
"================================================================================\n");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "================================================================================\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
|
||||
if (setup_formats() != SWITCH_STATUS_SUCCESS) {
|
||||
|
@ -295,3 +291,4 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_inte
|
|||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,7 @@ static const switch_loadable_module_interface mod_timers_module_interface = {
|
|||
/*.switch_application_interface*/ NULL
|
||||
};
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
|
||||
{
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &mod_timers_module_interface;
|
||||
|
@ -122,3 +121,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul
|
|||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
*/
|
||||
#include <switch.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
char *err = NULL;
|
||||
switch_event *event;
|
||||
|
||||
|
@ -76,3 +75,5 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@ SWITCH_DECLARE(switch_status) switch_buffer_create(switch_memory_pool *pool, swi
|
|||
{
|
||||
switch_buffer *new_buffer;
|
||||
|
||||
if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer)))
|
||||
&& (new_buffer->data = switch_core_alloc(pool, max_len))) {
|
||||
if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer))) && (new_buffer->data = switch_core_alloc(pool, max_len))) {
|
||||
new_buffer->datalen = max_len;
|
||||
*buffer = new_buffer;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -138,3 +137,4 @@ SWITCH_DECLARE(int) switch_buffer_write(switch_buffer *buffer, void *data, size_
|
|||
//printf("i %d = %d\n", datalen, buffer->used);
|
||||
return (int)buffer->used;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,9 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_se
|
|||
char *caller_id_name,
|
||||
char *caller_id_number,
|
||||
char *network_addr,
|
||||
char *ani, char *ani2, char *destination_number)
|
||||
char *ani,
|
||||
char *ani2,
|
||||
char *destination_number)
|
||||
{
|
||||
|
||||
|
||||
|
@ -73,8 +75,8 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_
|
|||
return profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix,
|
||||
switch_event *event)
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix, switch_event *event)
|
||||
|
||||
{
|
||||
char header_name[1024];
|
||||
|
||||
|
@ -110,7 +112,9 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile
|
|||
}
|
||||
|
||||
SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
|
||||
char *extension_name, char *extension_number)
|
||||
char *extension_name,
|
||||
char *extension_number
|
||||
)
|
||||
{
|
||||
switch_caller_extension *caller_extension = NULL;
|
||||
|
||||
|
@ -126,7 +130,8 @@ SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_cor
|
|||
|
||||
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
|
||||
switch_caller_extension *caller_extension,
|
||||
char *application_name, char *application_data)
|
||||
char *application_name,
|
||||
char *application_data)
|
||||
{
|
||||
switch_caller_application *caller_application = NULL;
|
||||
|
||||
|
@ -146,3 +151,6 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -71,8 +71,7 @@ SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, swi
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode(switch_channel *channel, int freq, int bits, int channels,
|
||||
int ms, int kbps)
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode (switch_channel *channel, int freq, int bits, int channels, int ms, int kbps)
|
||||
{
|
||||
|
||||
assert(channel != NULL);
|
||||
|
@ -87,8 +86,7 @@ SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode(switch_channel *channe
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode(switch_channel *channel, int *freq, int *bits, int *channels,
|
||||
int *ms, int *kbps)
|
||||
SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode (switch_channel *channel, int *freq, int *bits, int *channels, int *ms, int *kbps)
|
||||
{
|
||||
if (freq) {
|
||||
*freq = channel->freq;
|
||||
|
@ -166,7 +164,8 @@ SWITCH_DECLARE(int) switch_channel_dequeue_dtmf(switch_channel *channel, char *d
|
|||
|
||||
SWITCH_DECLARE(switch_status) switch_channel_init(switch_channel *channel,
|
||||
switch_core_session *session,
|
||||
switch_channel_state state, switch_channel_flag flags)
|
||||
switch_channel_state state,
|
||||
switch_channel_flag flags)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->state = state;
|
||||
|
@ -382,13 +381,11 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
|
|||
|
||||
|
||||
if (ok) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name,
|
||||
state_names[last_state], state_names[state]);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||
channel->state = state;
|
||||
switch_core_session_signal_state_change(channel->session);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name,
|
||||
state_names[last_state], state_names[state]);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||
|
||||
//we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee!
|
||||
if (channel->state < CS_HANGUP) {
|
||||
|
@ -410,8 +407,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
|
|||
originator_caller_profile = switch_channel_get_originator_caller_profile(channel);
|
||||
originatee_caller_profile = switch_channel_get_originatee_caller_profile(channel);
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State",
|
||||
(char *) switch_channel_state_name(channel->state));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session));
|
||||
|
||||
|
@ -432,8 +428,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
|
|||
}
|
||||
|
||||
/* Index Variables */
|
||||
for (hi = switch_hash_first(switch_core_session_get_pool(channel->session), channel->variables); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_hash_first(switch_core_session_get_pool(channel->session), channel->variables); hi; hi = switch_hash_next(hi)) {
|
||||
char buf[1024];
|
||||
switch_event_subclass *subclass;
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
|
@ -458,15 +453,13 @@ SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch
|
|||
return channel->caller_profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel,
|
||||
switch_caller_profile *caller_profile)
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->originator_caller_profile = caller_profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel,
|
||||
switch_caller_profile *caller_profile)
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->originatee_caller_profile = caller_profile;
|
||||
|
@ -484,8 +477,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_pro
|
|||
return channel->originatee_caller_profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel,
|
||||
const struct switch_event_handler_table *event_handlers)
|
||||
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel, const struct switch_event_handler_table *event_handlers)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->event_handlers = event_handlers;
|
||||
|
@ -497,8 +489,7 @@ SWITCH_DECLARE(const struct switch_event_handler_table *) switch_channel_get_eve
|
|||
return channel->event_handlers;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel,
|
||||
switch_caller_extension *caller_extension)
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel, switch_caller_extension *caller_extension)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->caller_extension = caller_extension;
|
||||
|
|
|
@ -154,3 +154,6 @@ SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char
|
|||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -54,10 +54,15 @@ static int switch_console_process(char *cmd)
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
|
||||
"\n"
|
||||
"Valid Commands:\n\n"
|
||||
"version\n" "help - umm yeah..\n" "%sshutdown - stop the program\n\n", perlhelp);
|
||||
"version\n"
|
||||
"help - umm yeah..\n"
|
||||
"%sshutdown - stop the program\n\n",
|
||||
perlhelp
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef EMBED_PERL
|
||||
if (!strncmp(cmd, "perl ", 5)) {
|
||||
cmd += 5;
|
||||
|
@ -74,16 +79,14 @@ static int switch_console_process(char *cmd)
|
|||
*arg++ = '\0';
|
||||
}
|
||||
if (switch_api_execute(cmd, arg, retbuf, sizeof(retbuf)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "",
|
||||
retbuf);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", retbuf);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Unknown Command: %s\n", cmd);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *file, const char *func, int line,
|
||||
char *fmt, ...)
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *file, const char *func, int line, char *fmt, ...)
|
||||
{
|
||||
char *data;
|
||||
int ret = 0;
|
||||
|
|
|
@ -221,10 +221,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_se
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, int rate, int ms,
|
||||
int channels, switch_codec_flag flags,
|
||||
const switch_codec_settings *codec_settings,
|
||||
switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, int rate, int ms, int channels, switch_codec_flag flags, const switch_codec_settings *codec_settings, switch_memory_pool *pool)
|
||||
{
|
||||
const switch_codec_interface *codec_interface;
|
||||
const switch_codec_implementation *iptr, *implementation = NULL;
|
||||
|
@ -266,8 +263,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
|||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s Exists but not then desired implementation.\n",
|
||||
codec_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s Exists but not then desired implementation.\n", codec_name);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_NOTIMPL;
|
||||
|
@ -280,7 +276,9 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
|||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
assert(codec != NULL);
|
||||
assert(encoded_data != NULL);
|
||||
|
@ -301,7 +299,11 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
|||
other_codec,
|
||||
decoded_data,
|
||||
decoded_data_len,
|
||||
decoded_rate, encoded_data, encoded_data_len, encoded_rate, flag);
|
||||
decoded_rate,
|
||||
encoded_data,
|
||||
encoded_data_len,
|
||||
encoded_rate,
|
||||
flag);
|
||||
|
||||
}
|
||||
|
||||
|
@ -311,7 +313,9 @@ SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
|||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
|
||||
assert(codec != NULL);
|
||||
|
@ -333,7 +337,11 @@ SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
|||
other_codec,
|
||||
encoded_data,
|
||||
encoded_data_len,
|
||||
encoded_rate, decoded_data, decoded_data_len, decoded_rate, flag);
|
||||
encoded_rate,
|
||||
decoded_data,
|
||||
decoded_data_len,
|
||||
decoded_rate,
|
||||
flag);
|
||||
|
||||
}
|
||||
|
||||
|
@ -355,8 +363,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_destroy(switch_codec *codec)
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags,
|
||||
switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags, switch_memory_pool *pool)
|
||||
{
|
||||
char *ext;
|
||||
switch_status status;
|
||||
|
@ -401,8 +408,7 @@ SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, voi
|
|||
return fh->file_interface->file_write(fh, data, (unsigned int *)len);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples,
|
||||
int whence)
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples, int whence)
|
||||
{
|
||||
return fh->file_interface->file_seek(fh, cur_pos, samples, whence);
|
||||
}
|
||||
|
@ -413,8 +419,7 @@ SWITCH_DECLARE(switch_status) switch_core_file_close(switch_file_handle *fh)
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples,
|
||||
switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples, switch_memory_pool *pool)
|
||||
{
|
||||
switch_timer_interface *timer_interface;
|
||||
switch_status status;
|
||||
|
@ -528,8 +533,7 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *
|
|||
}
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session,
|
||||
switch_core_thread_session *thread_session, int stream_id)
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session, int stream_id)
|
||||
{
|
||||
thread_session->running = 1;
|
||||
thread_session->objs[0] = session;
|
||||
|
@ -577,8 +581,7 @@ SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup)
|
|||
|
||||
assert(runtime.memory_pool != NULL);
|
||||
|
||||
if (!todup)
|
||||
return NULL;
|
||||
if (!todup) return NULL;
|
||||
|
||||
len = strlen(todup) + 1;
|
||||
if (todup && (duped = apr_palloc(runtime.memory_pool, len))) {
|
||||
|
@ -595,8 +598,7 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session,
|
|||
assert(session != NULL);
|
||||
assert(session->pool != NULL);
|
||||
|
||||
if (!todup)
|
||||
return NULL;
|
||||
if (!todup) return NULL;
|
||||
|
||||
len = strlen(todup) + 1;
|
||||
|
||||
|
@ -614,8 +616,7 @@ SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup)
|
|||
assert(pool != NULL);
|
||||
assert(todup != NULL);
|
||||
|
||||
if (!todup)
|
||||
return NULL;
|
||||
if (!todup) return NULL;
|
||||
len = strlen(todup) + 1;
|
||||
|
||||
if (todup && (duped = apr_palloc(pool, len))) {
|
||||
|
@ -670,9 +671,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_s
|
|||
}
|
||||
|
||||
if (endpoint_interface->io_routines->outgoing_channel) {
|
||||
if ((status =
|
||||
endpoint_interface->io_routines->outgoing_channel(session, caller_profile,
|
||||
new_session)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = endpoint_interface->io_routines->outgoing_channel(session, caller_profile, new_session)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.outgoing_channel; ptr ; ptr = ptr->next) {
|
||||
if ((status = ptr->outgoing_channel(session, caller_profile, *new_session)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
|
@ -730,16 +729,14 @@ SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_ses
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_session *session,
|
||||
switch_core_session_message *message)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_session *session, switch_core_session_message *message)
|
||||
{
|
||||
struct switch_io_event_hook_receive_message *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
assert(session != NULL);
|
||||
if (session->endpoint_interface->io_routines->receive_message) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->receive_message(session, message)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = session->endpoint_interface->io_routines->receive_message(session, message)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.receive_message; ptr ; ptr = ptr->next) {
|
||||
if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
|
@ -753,8 +750,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_se
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame,
|
||||
int timeout, int stream_id)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout, int stream_id)
|
||||
{
|
||||
struct switch_io_event_hook_read_frame *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
@ -768,9 +764,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
SWITCH_IO_FLAG_NOOP,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.read_frame; ptr ; ptr = ptr->next) {
|
||||
if ((status =
|
||||
ptr->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP,
|
||||
stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = ptr->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -782,8 +776,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
}
|
||||
|
||||
/* if you think this code is redundant.... too bad! I like to understand what I'm doing */
|
||||
if ((session->read_codec && (*frame)->codec
|
||||
&& session->read_codec->implementation != (*frame)->codec->implementation)) {
|
||||
if ((session->read_codec && (*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
|
||||
need_codec = TRUE;
|
||||
}
|
||||
|
||||
|
@ -807,7 +800,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
read_frame->datalen,
|
||||
session->read_codec->implementation->samples_per_second,
|
||||
session->raw_read_frame.data,
|
||||
&session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
|
||||
&session->raw_read_frame.datalen,
|
||||
&session->raw_read_frame.rate,
|
||||
&flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
|
@ -816,7 +811,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
read_frame->codec->implementation->samples_per_second,
|
||||
read_frame->codec->implementation->bytes_per_frame * 20,
|
||||
session->read_codec->implementation->samples_per_second,
|
||||
session->read_codec->implementation->bytes_per_frame * 20, session->pool);
|
||||
session->read_codec->implementation->bytes_per_frame * 20,
|
||||
session->pool);
|
||||
}
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
read_frame = &session->raw_read_frame;
|
||||
|
@ -825,8 +821,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
|
@ -834,12 +829,13 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
if (session->read_resampler) {
|
||||
short *data = read_frame->data;
|
||||
|
||||
session->read_resampler->from_len =
|
||||
switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
|
||||
session->read_resampler->to_len =
|
||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||
session->read_resampler->from_len, session->read_resampler->to,
|
||||
(int) session->read_resampler->to_size, 0);
|
||||
session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int)read_frame->datalen / 2 );
|
||||
session->read_resampler->to_len = switch_resample_process(session->read_resampler,
|
||||
session->read_resampler->from,
|
||||
session->read_resampler->from_len,
|
||||
session->read_resampler->to,
|
||||
(int)session->read_resampler->to_size,
|
||||
0);
|
||||
switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
|
||||
read_frame->samples = session->read_resampler->to_len;
|
||||
read_frame->datalen = session->read_resampler->to_len * 2;
|
||||
|
@ -869,8 +865,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
} else {
|
||||
session->raw_read_frame.datalen = switch_buffer_read(session->raw_read_buffer,
|
||||
session->raw_read_frame.data,
|
||||
session->read_codec->implementation->
|
||||
bytes_per_frame);
|
||||
session->read_codec->implementation->bytes_per_frame);
|
||||
session->raw_read_frame.rate = session->read_codec->implementation->samples_per_second;
|
||||
enc_frame = &session->raw_read_frame;
|
||||
}
|
||||
|
@ -882,7 +877,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
(*frame)->codec->implementation->samples_per_second,
|
||||
session->enc_read_frame.data,
|
||||
&session->enc_read_frame.datalen,
|
||||
&session->enc_read_frame.rate, &flag);
|
||||
&session->enc_read_frame.rate,
|
||||
&flag);
|
||||
|
||||
|
||||
switch (status) {
|
||||
|
@ -896,8 +892,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
*frame = NULL;
|
||||
status = SWITCH_STATUS_GENERR;
|
||||
break;
|
||||
|
@ -909,16 +904,12 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||
return status;
|
||||
}
|
||||
|
||||
static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags,
|
||||
int stream_id)
|
||||
{
|
||||
static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id) {
|
||||
struct switch_io_event_hook_write_frame *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (session->endpoint_interface->io_routines->write_frame) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->write_frame(session, frame, timeout, flags,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = session->endpoint_interface->io_routines->write_frame(session, frame, timeout, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.write_frame; ptr ; ptr = ptr->next) {
|
||||
if ((status = ptr->write_frame(session, frame, timeout, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
|
@ -929,8 +920,7 @@ static switch_status perform_write(switch_core_session *session, switch_frame *f
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame,
|
||||
int timeout, int stream_id)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout, int stream_id)
|
||||
{
|
||||
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
@ -960,7 +950,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
frame->datalen,
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->raw_write_frame.data,
|
||||
&session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
|
||||
&session->raw_write_frame.datalen,
|
||||
&session->raw_write_frame.rate,
|
||||
&flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
|
@ -982,8 +974,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n",
|
||||
frame->codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", frame->codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
|
@ -991,12 +982,13 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
if (session->write_resampler) {
|
||||
short *data = write_frame->data;
|
||||
|
||||
session->write_resampler->from_len =
|
||||
switch_short_to_float(data, session->write_resampler->from, (int) write_frame->datalen / 2);
|
||||
session->write_resampler->to_len =
|
||||
switch_resample_process(session->write_resampler, session->write_resampler->from,
|
||||
session->write_resampler->from_len, session->write_resampler->to,
|
||||
(int) session->write_resampler->to_size, 0);
|
||||
session->write_resampler->from_len = switch_short_to_float(data, session->write_resampler->from, (int)write_frame->datalen / 2);
|
||||
session->write_resampler->to_len = switch_resample_process(session->write_resampler,
|
||||
session->write_resampler->from,
|
||||
session->write_resampler->from_len,
|
||||
session->write_resampler->to,
|
||||
(int)session->write_resampler->to_size,
|
||||
0);
|
||||
switch_float_to_short(session->write_resampler->to, data, write_frame->datalen * 2);
|
||||
write_frame->samples = session->write_resampler->to_len;
|
||||
write_frame->datalen = session->write_resampler->to_len * 2;
|
||||
|
@ -1011,10 +1003,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
|
||||
"Engaging Write Buffer at %d bytes to accomidate %d->%d\n",
|
||||
bytes,
|
||||
write_frame->datalen, session->write_codec->implementation->bytes_per_frame);
|
||||
if ((status =
|
||||
switch_buffer_create(session->pool, &session->raw_write_buffer,
|
||||
bytes)) != SWITCH_STATUS_SUCCESS) {
|
||||
write_frame->datalen,
|
||||
session->write_codec->implementation->bytes_per_frame);
|
||||
if ((status = switch_buffer_create(session->pool, &session->raw_write_buffer, bytes)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Write Buffer Failed!\n");
|
||||
return status;
|
||||
}
|
||||
|
@ -1035,7 +1026,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
session->write_codec->implementation->samples_per_second,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate, &flag);
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
|
@ -1048,8 +1040,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
|
@ -1067,7 +1058,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
int x;
|
||||
for (x = 0; x < frames; x++) {
|
||||
if ((session->raw_write_frame.datalen =
|
||||
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes))) {
|
||||
switch_buffer_read(session->raw_write_buffer,
|
||||
session->raw_write_frame.data,
|
||||
bytes))) {
|
||||
|
||||
enc_frame = &session->raw_write_frame;
|
||||
session->raw_write_frame.rate = session->write_codec->implementation->samples_per_second;
|
||||
|
@ -1079,7 +1072,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
frame->codec->implementation->samples_per_second,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate, &flag);
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
|
||||
|
||||
|
||||
|
@ -1090,10 +1084,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
status = switch_resample_create(&session->read_resampler,
|
||||
frame->codec->implementation->samples_per_second,
|
||||
frame->codec->implementation->bytes_per_frame * 20,
|
||||
session->write_codec->implementation->
|
||||
samples_per_second,
|
||||
session->write_codec->implementation->
|
||||
bytes_per_frame * 20, session->pool);
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->write_codec->implementation->bytes_per_frame * 20,
|
||||
session->pool);
|
||||
}
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
|
@ -1104,8 +1097,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
|
@ -1116,13 +1108,13 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||
|
||||
session->read_resampler->from_len = switch_short_to_float(data,
|
||||
session->read_resampler->from,
|
||||
(int) write_frame->datalen /
|
||||
2);
|
||||
session->read_resampler->to_len =
|
||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||
(int)write_frame->datalen / 2);
|
||||
session->read_resampler->to_len = switch_resample_process(session->read_resampler,
|
||||
session->read_resampler->from,
|
||||
session->read_resampler->from_len,
|
||||
session->read_resampler->to,
|
||||
(int) session->read_resampler->to_size, 0);
|
||||
(int)session->read_resampler->to_size,
|
||||
0);
|
||||
switch_float_to_short(session->read_resampler->to, data, write_frame->datalen * 2);
|
||||
write_frame->samples = session->read_resampler->to_len;
|
||||
write_frame->datalen = session->read_resampler->to_len * 2;
|
||||
|
@ -1166,9 +1158,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_sessi
|
|||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (session->endpoint_interface->io_routines->waitfor_read) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->waitfor_read(session, timeout,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = session->endpoint_interface->io_routines->waitfor_read(session, timeout, stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.waitfor_read; ptr ; ptr = ptr->next) {
|
||||
if ((status = ptr->waitfor_read(session, timeout, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
|
@ -1181,16 +1171,13 @@ SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_sessi
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout,
|
||||
int stream_id)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout, int stream_id)
|
||||
{
|
||||
struct switch_io_event_hook_waitfor_write *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (session->endpoint_interface->io_routines->waitfor_write) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->waitfor_write(session, timeout,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = session->endpoint_interface->io_routines->waitfor_write(session, timeout, stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.waitfor_write; ptr ; ptr = ptr->next) {
|
||||
if ((status = ptr->waitfor_write(session, timeout, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
|
@ -1221,8 +1208,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_send_dtmf(switch_core_session
|
|||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session,
|
||||
switch_outgoing_channel_hook outgoing_channel)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session, switch_outgoing_channel_hook outgoing_channel)
|
||||
{
|
||||
switch_io_event_hook_outgoing_channel *hook, *ptr;
|
||||
|
||||
|
@ -1243,9 +1229,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch
|
|||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session,
|
||||
switch_answer_channel_hook
|
||||
answer_channel)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session, switch_answer_channel_hook answer_channel)
|
||||
{
|
||||
switch_io_event_hook_answer_channel *hook, *ptr;
|
||||
|
||||
|
@ -1267,8 +1251,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session,
|
||||
switch_read_frame_hook read_frame)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session, switch_read_frame_hook read_frame)
|
||||
{
|
||||
switch_io_event_hook_read_frame *hook, *ptr;
|
||||
|
||||
|
@ -1290,8 +1273,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(swit
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session,
|
||||
switch_write_frame_hook write_frame)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session, switch_write_frame_hook write_frame)
|
||||
{
|
||||
switch_io_event_hook_write_frame *hook, *ptr;
|
||||
|
||||
|
@ -1313,8 +1295,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(swi
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session,
|
||||
switch_kill_channel_hook kill_channel)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session, switch_kill_channel_hook kill_channel)
|
||||
{
|
||||
switch_io_event_hook_kill_channel *hook, *ptr;
|
||||
|
||||
|
@ -1336,8 +1317,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(sw
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session,
|
||||
switch_waitfor_read_hook waitfor_read)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session, switch_waitfor_read_hook waitfor_read)
|
||||
{
|
||||
switch_io_event_hook_waitfor_read *hook, *ptr;
|
||||
|
||||
|
@ -1359,8 +1339,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(sw
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session,
|
||||
switch_waitfor_write_hook waitfor_write)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session, switch_waitfor_write_hook waitfor_write)
|
||||
{
|
||||
switch_io_event_hook_waitfor_write *hook, *ptr;
|
||||
|
||||
|
@ -1383,8 +1362,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(s
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session,
|
||||
switch_send_dtmf_hook send_dtmf)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session, switch_send_dtmf_hook send_dtmf)
|
||||
{
|
||||
switch_io_event_hook_send_dtmf *hook, *ptr;
|
||||
|
||||
|
@ -1481,21 +1459,16 @@ static void switch_core_standard_on_execute(switch_core_session *session)
|
|||
}
|
||||
|
||||
while (switch_channel_get_state(session->channel) == CS_EXECUTE && extension->current_application) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Execute %s(%s)\n",
|
||||
extension->current_application->application_name,
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Execute %s(%s)\n", extension->current_application->application_name,
|
||||
extension->current_application->application_data);
|
||||
if (!
|
||||
(application_interface =
|
||||
switch_loadable_module_get_application_interface(extension->current_application->application_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Application %s\n",
|
||||
extension->current_application->application_name);
|
||||
if (!(application_interface = switch_loadable_module_get_application_interface(extension->current_application->application_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Application %s\n", extension->current_application->application_name);
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!application_interface->application_function) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Function for %s\n",
|
||||
extension->current_application->application_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Function for %s\n", extension->current_application->application_name);
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
return;
|
||||
}
|
||||
|
@ -1768,7 +1741,12 @@ SWITCH_DECLARE(void) switch_core_launch_thread(switch_thread_start_t func, void
|
|||
}
|
||||
ts->objs[0] = obj;
|
||||
|
||||
switch_thread_create(&thread, thd_attr, func, ts, pool);
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
func,
|
||||
ts,
|
||||
pool
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1803,21 +1781,30 @@ SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *sess
|
|||
switch_threadattr_create(&thd_attr, session->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
if (switch_thread_create(&thread, thd_attr, switch_core_session_thread, session, session->pool) != APR_SUCCESS) {
|
||||
if (switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
switch_core_session_thread,
|
||||
session,
|
||||
session->pool
|
||||
) != APR_SUCCESS) {
|
||||
switch_core_session_destroy(&session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, switch_thread_start_t func,
|
||||
void *obj)
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, switch_thread_start_t func, void *obj)
|
||||
{
|
||||
switch_thread *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
switch_threadattr_create(&thd_attr, session->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
switch_thread_create(&thread, thd_attr, func, obj, session->pool);
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
func,
|
||||
obj,
|
||||
session->pool
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1833,8 +1820,7 @@ SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool *pool, size_t memory
|
|||
return ptr;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface,
|
||||
switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface, switch_memory_pool *pool)
|
||||
{
|
||||
switch_memory_pool *usepool;
|
||||
switch_core_session *session;
|
||||
|
@ -1950,8 +1936,7 @@ SWITCH_DECLARE(switch_status) switch_core_init(void)
|
|||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error Opening DB!\n");
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Opening DB\n");
|
||||
if (switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind event handler!\n");
|
||||
}
|
||||
}
|
||||
|
@ -2015,3 +2000,4 @@ SWITCH_DECLARE(switch_status) switch_core_destroy(void)
|
|||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ static void *locked_dup(char *str)
|
|||
|
||||
return dup;
|
||||
}
|
||||
|
||||
#define ALLOC(size) locked_alloc(size)
|
||||
#define DUP(str) locked_dup(str)
|
||||
#endif
|
||||
|
@ -268,7 +267,12 @@ SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool)
|
|||
switch_mutex_init(&BLOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
|
||||
switch_mutex_init(&POOL_LOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
|
||||
switch_core_hash_init(&CUSTOM_HASH, RUNTIME_POOL);
|
||||
switch_thread_create(&thread, thd_attr, switch_event_thread, NULL, RUNTIME_POOL);
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
switch_event_thread,
|
||||
NULL,
|
||||
RUNTIME_POOL
|
||||
);
|
||||
|
||||
while(!THREAD_RUNNING) {
|
||||
switch_yield(1000);
|
||||
|
@ -277,8 +281,7 @@ SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool)
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event, switch_event_t event_id,
|
||||
char *subclass_name)
|
||||
SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event, switch_event_t event_id, char *subclass_name)
|
||||
{
|
||||
|
||||
if (event_id != SWITCH_EVENT_CUSTOM && subclass_name) {
|
||||
|
@ -288,6 +291,7 @@ SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event,
|
|||
if(!(*event = ALLOC(sizeof(switch_event)))) {
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
#ifdef MALLOC_EVENTS
|
||||
memset(*event, 0, sizeof(switch_event));
|
||||
#endif
|
||||
|
@ -314,8 +318,7 @@ SWITCH_DECLARE(char *) switch_event_get_header(switch_event *event, char *header
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name,
|
||||
char *fmt, ...)
|
||||
SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name, char *fmt, ...)
|
||||
{
|
||||
int ret = 0;
|
||||
char data[2048];
|
||||
|
@ -486,8 +489,7 @@ SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event,
|
||||
void *user_data)
|
||||
SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event, void *user_data)
|
||||
{
|
||||
|
||||
switch_time_exp_t tm;
|
||||
|
@ -533,8 +535,7 @@ SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func,
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event, char *subclass_name,
|
||||
switch_event_callback_t callback, void *user_data)
|
||||
SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event, char *subclass_name, switch_event_callback_t callback, void *user_data)
|
||||
{
|
||||
switch_event_node *event_node;
|
||||
switch_event_subclass *subclass = NULL;
|
||||
|
@ -574,3 +575,4 @@ SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event,
|
|||
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ static void *switch_loadable_module_exec(switch_thread *thread, void *obj)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static switch_status switch_loadable_module_load_file(char *filename, switch_memory_pool *pool,
|
||||
switch_loadable_module **new_module)
|
||||
static switch_status switch_loadable_module_load_file(char *filename, switch_memory_pool *pool, switch_loadable_module **new_module)
|
||||
{
|
||||
switch_loadable_module *module = NULL;
|
||||
apr_dso_handle_t *dso = NULL;
|
||||
|
@ -251,7 +250,9 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
const switch_endpoint_interface *ptr;
|
||||
for (ptr = new_module->interface->endpoint_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Endpoint '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.endpoint_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.endpoint_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,10 +266,13 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
"Adding Codec '%s' (%s) %dkhz %dms\n",
|
||||
ptr->iananame,
|
||||
ptr->interface_name,
|
||||
impl->samples_per_second, impl->microseconds_per_frame / 1000);
|
||||
impl->samples_per_second,
|
||||
impl->microseconds_per_frame / 1000);
|
||||
}
|
||||
|
||||
switch_core_hash_insert(loadable_modules.codec_hash, (char *) ptr->iananame, (void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.codec_hash,
|
||||
(char *) ptr->iananame,
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +281,9 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
|
||||
for(ptr = new_module->interface->dialplan_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Dialplan '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.dialplan_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.dialplan_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +292,9 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
|
||||
for(ptr = new_module->interface->timer_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Timer '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.timer_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.timer_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,7 +304,8 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
for(ptr = new_module->interface->application_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Application '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.application_hash,
|
||||
(char *) ptr->interface_name, (void *) ptr);
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +314,9 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
|
||||
for(ptr = new_module->interface->api_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding API Function '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.api_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.api_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +327,9 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||
int i;
|
||||
for (i = 0 ; ptr->extens[i]; i++) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding File Format '%s'\n", ptr->extens[i]);
|
||||
switch_core_hash_insert(loadable_modules.file_hash, (char *) ptr->extens[i], (void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.file_hash,
|
||||
(char *) ptr->extens[i],
|
||||
(void *) ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,8 +397,7 @@ SWITCH_DECLARE(switch_file_interface *) switch_loadable_module_get_file_interfac
|
|||
return switch_core_hash_find(loadable_modules.file_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array,
|
||||
int arraylen)
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen)
|
||||
{
|
||||
switch_hash_index_t* hi;
|
||||
void *val;
|
||||
|
@ -403,8 +415,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool,
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array,
|
||||
int arraylen, char **prefs, int preflen)
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen)
|
||||
{
|
||||
int x, i = 0;
|
||||
switch_codec_interface *codec_interface;
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
*/
|
||||
#include <switch_mutex.h>
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_mutex_init(switch_mutex_t **lock, switch_lock_flag flags, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_mutex_init(switch_mutex_t **lock,
|
||||
switch_lock_flag flags,
|
||||
switch_memory_pool *pool)
|
||||
{
|
||||
|
||||
return (apr_thread_mutex_create(lock, flags, pool) == APR_SUCCESS) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
|
||||
|
@ -56,3 +58,5 @@ SWITCH_DECLARE(switch_status) switch_mutex_trylock(switch_mutex_t *lock)
|
|||
{
|
||||
return apr_thread_mutex_trylock(lock);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
|
||||
int from_rate,
|
||||
size_t from_size,
|
||||
int to_rate, size_t to_size, switch_memory_pool *pool)
|
||||
int to_rate,
|
||||
size_t to_size,
|
||||
switch_memory_pool *pool)
|
||||
{
|
||||
switch_audio_resampler *resampler;
|
||||
|
||||
|
@ -62,8 +64,7 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
|||
resampler->factor = ((double)resampler->to_rate / (double)resampler->from_rate);
|
||||
|
||||
resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Resampler %d->%d %f\n", resampler->from_rate,
|
||||
resampler->to_rate, resampler->factor);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate, resampler->factor);
|
||||
resampler->from_size = from_size;
|
||||
resampler->from = (float *) switch_core_alloc(pool, resampler->from_size);
|
||||
resampler->to_size = to_size;
|
||||
|
@ -74,16 +75,14 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst,
|
||||
int dstlen, int last)
|
||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, int dstlen, int last)
|
||||
{
|
||||
int o=0, srcused=0, srcpos=0, out=0;
|
||||
|
||||
for(;;) {
|
||||
int srcBlock = MIN(srclen-srcpos, srclen);
|
||||
int lastFlag = (last && (srcBlock == srclen-srcpos));
|
||||
o = resample_process(resampler->resampler, resampler->factor, &src[srcpos], srcBlock, lastFlag, &srcused,
|
||||
&dst[out], dstlen - out);
|
||||
o = resample_process(resampler->resampler, resampler->factor, &src[srcpos], srcBlock, lastFlag, &srcused, &dst[out], dstlen-out);
|
||||
//printf("resampling %d/%d (%d) %d %f\n", srcpos, srclen, MIN(dstlen-out, dstlen), srcused, factor);
|
||||
|
||||
srcpos += srcused;
|
||||
|
@ -114,10 +113,8 @@ SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len)
|
|||
} else {
|
||||
s[i] = (short)(ft-0.5);
|
||||
}
|
||||
if ((float) s[i] > MAXSAMPLE)
|
||||
s[i] = (short) MAXSAMPLE;
|
||||
if (s[i] < (short) -MAXSAMPLE)
|
||||
s[i] = (short) -MAXSAMPLE;
|
||||
if ((float)s[i] > MAXSAMPLE) s[i] = (short)MAXSAMPLE;
|
||||
if (s[i] < (short)-MAXSAMPLE) s[i] = (short)-MAXSAMPLE;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
@ -133,10 +130,8 @@ SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len)
|
|||
for(i=1;i<len;i+=2) {
|
||||
f[(int)(i/2)] = (float)(((c[i])*0x100) + c[i-1]);
|
||||
f[(int)(i/2)] /= NORMFACT;
|
||||
if (f[(int) (i / 2)] > MAXSAMPLE)
|
||||
f[(int) (i / 2)] = MAXSAMPLE;
|
||||
if (f[(int) (i / 2)] < -MAXSAMPLE)
|
||||
f[(int) (i / 2)] = -MAXSAMPLE;
|
||||
if (f[(int)(i/2)] > MAXSAMPLE) f[(int)(i/2)] = MAXSAMPLE;
|
||||
if (f[(int)(i/2)] < -MAXSAMPLE) f[(int)(i/2)] = -MAXSAMPLE;
|
||||
}
|
||||
return len/2;
|
||||
}
|
||||
|
|
|
@ -82,8 +82,7 @@ SWITCH_DECLARE(char *) switch_cut_path(char *in)
|
|||
return ret;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
|
||||
unsigned int flags, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool)
|
||||
{
|
||||
switch_pollset_t *pollset;
|
||||
switch_status status;
|
||||
|
|
Loading…
Reference in New Issue