2002-09-11 17:09:48 +00:00
|
|
|
/*
|
2005-09-15 15:44:26 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2002-09-11 17:09:48 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002, Christos Ricudis
|
|
|
|
*
|
2004-03-15 16:51:58 +00:00
|
|
|
* Christos Ricudis <ricudis@itc.auth.gr>
|
2002-09-11 17:09:48 +00:00
|
|
|
*
|
2005-09-15 15:44:26 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
2002-09-11 17:09:48 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-15 15:44:26 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-15 15:44:26 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief Connect to festival
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
|
|
|
* \author Christos Ricudis <ricudis@itc.auth.gr>
|
2007-02-24 19:27:50 +00:00
|
|
|
*
|
|
|
|
* \extref The Festival Speech Synthesis System - http://www.cstr.ed.ac.uk/projects/festival/
|
2017-12-22 14:23:22 +00:00
|
|
|
*
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2002-09-11 17:09:48 +00:00
|
|
|
*/
|
|
|
|
|
2012-10-14 21:45:16 +00:00
|
|
|
/*! \li \ref app_festival.c uses the configuration file \ref festival.conf
|
2012-10-01 23:22:50 +00:00
|
|
|
* \addtogroup configuration_file Configuration Files
|
|
|
|
*/
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
/*!
|
2012-10-01 23:22:50 +00:00
|
|
|
* \page festival.conf festival.conf
|
|
|
|
* \verbinclude festival.conf.sample
|
|
|
|
*/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>extended</support_level>
|
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <ctype.h>
|
2008-11-02 18:52:13 +00:00
|
|
|
#include <errno.h>
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2005-06-06 22:39:32 +00:00
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/md5.h"
|
|
|
|
#include "asterisk/config.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/lock.h"
|
2007-07-31 01:10:47 +00:00
|
|
|
#include "asterisk/app.h"
|
2010-08-30 22:30:10 +00:00
|
|
|
#include "asterisk/endian.h"
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
#include "asterisk/format_cache.h"
|
2002-09-11 17:09:48 +00:00
|
|
|
|
|
|
|
#define FESTIVAL_CONFIG "festival.conf"
|
2007-07-31 01:10:47 +00:00
|
|
|
#define MAXLEN 180
|
|
|
|
#define MAXFESTLEN 2048
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Festival" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Say text to the user.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="text" required="true" />
|
|
|
|
<parameter name="intkeys" />
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Connect to Festival, send the argument, get back the waveform, play it to the user,
|
|
|
|
allowing any given interrupt keys to immediately terminate and return the value, or
|
|
|
|
<literal>any</literal> to allow any number back (useful in dialplan).</para>
|
|
|
|
</description>
|
|
|
|
</application>
|
|
|
|
***/
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
static char *app = "Festival";
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
static char *socket_receive_file_to_buff(int fd, int *size)
|
2002-09-11 17:09:48 +00:00
|
|
|
{
|
2007-07-31 01:10:47 +00:00
|
|
|
/* Receive file (probably a waveform file) from socket using
|
|
|
|
* Festival key stuff technique, but long winded I know, sorry
|
|
|
|
* but will receive any file without closing the stream or
|
|
|
|
* using OOB data
|
|
|
|
*/
|
|
|
|
static char *file_stuff_key = "ft_StUfF_key"; /* must == Festival's key */
|
|
|
|
char *buff, *tmp;
|
|
|
|
int bufflen;
|
|
|
|
int n,k,i;
|
|
|
|
char c;
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
bufflen = 1024;
|
|
|
|
if (!(buff = ast_malloc(bufflen)))
|
|
|
|
return NULL;
|
|
|
|
*size = 0;
|
|
|
|
|
|
|
|
for (k = 0; file_stuff_key[k] != '\0';) {
|
|
|
|
n = read(fd, &c, 1);
|
|
|
|
if (n == 0)
|
|
|
|
break; /* hit stream eof before end of file */
|
|
|
|
if ((*size) + k + 1 >= bufflen) {
|
|
|
|
/* +1 so you can add a terminating NULL if you want */
|
|
|
|
bufflen += bufflen / 4;
|
|
|
|
if (!(tmp = ast_realloc(buff, bufflen))) {
|
|
|
|
ast_free(buff);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
buff = tmp;
|
|
|
|
}
|
|
|
|
if (file_stuff_key[k] == c)
|
|
|
|
k++;
|
|
|
|
else if ((c == 'X') && (file_stuff_key[k+1] == '\0')) {
|
|
|
|
/* It looked like the key but wasn't */
|
|
|
|
for (i = 0; i < k; i++, (*size)++)
|
|
|
|
buff[*size] = file_stuff_key[i];
|
|
|
|
k = 0;
|
|
|
|
/* omit the stuffed 'X' */
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < k; i++, (*size)++)
|
|
|
|
buff[*size] = file_stuff_key[i];
|
|
|
|
k = 0;
|
|
|
|
buff[*size] = c;
|
|
|
|
(*size)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return buff;
|
|
|
|
}
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
static int send_waveform_to_fd(char *waveform, int length, int fd)
|
|
|
|
{
|
|
|
|
int res;
|
2010-08-30 22:30:10 +00:00
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
2009-07-22 21:43:57 +00:00
|
|
|
int x;
|
2004-01-11 08:32:50 +00:00
|
|
|
char c;
|
|
|
|
#endif
|
2006-12-11 00:52:19 +00:00
|
|
|
|
2008-04-16 22:57:54 +00:00
|
|
|
res = ast_safe_fork(0);
|
2007-07-31 01:10:47 +00:00
|
|
|
if (res < 0)
|
|
|
|
ast_log(LOG_WARNING, "Fork failed\n");
|
|
|
|
if (res) {
|
|
|
|
return res;
|
|
|
|
}
|
2008-04-16 22:57:54 +00:00
|
|
|
dup2(fd, 0);
|
|
|
|
ast_close_fds_above_n(0);
|
2006-05-01 21:48:30 +00:00
|
|
|
if (ast_opt_high_priority)
|
|
|
|
ast_set_priority(0);
|
2010-08-30 22:30:10 +00:00
|
|
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
2007-07-31 01:10:47 +00:00
|
|
|
for (x = 0; x < length; x += 2) {
|
|
|
|
c = *(waveform + x + 1);
|
|
|
|
*(waveform + x + 1) = *(waveform + x);
|
|
|
|
*(waveform + x) = c;
|
2004-01-11 08:32:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-08-30 22:30:10 +00:00
|
|
|
|
|
|
|
if (write(0, waveform, length) < 0) {
|
|
|
|
/* Cannot log -- all FDs are already closed */
|
2008-11-02 18:52:13 +00:00
|
|
|
}
|
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
close(fd);
|
2010-08-30 22:30:10 +00:00
|
|
|
_exit(0);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys)
|
|
|
|
{
|
|
|
|
int res = 0;
|
2002-09-11 17:09:48 +00:00
|
|
|
int fds[2];
|
2003-08-14 15:58:55 +00:00
|
|
|
int needed = 0;
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
struct ast_format *owriteformat;
|
2002-09-11 17:09:48 +00:00
|
|
|
struct ast_frame *f;
|
|
|
|
struct myframe {
|
|
|
|
struct ast_frame f;
|
|
|
|
char offset[AST_FRIENDLY_OFFSET];
|
2003-08-14 15:58:55 +00:00
|
|
|
char frdata[2048];
|
2007-05-24 15:04:51 +00:00
|
|
|
} myf = {
|
|
|
|
.f = { 0, },
|
|
|
|
};
|
2007-07-31 01:10:47 +00:00
|
|
|
|
|
|
|
if (pipe(fds)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to create pipe\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-04-16 02:51:47 +00:00
|
|
|
/* Answer if it's not already going */
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_state(chan) != AST_STATE_UP)
|
2004-04-16 02:51:47 +00:00
|
|
|
ast_answer(chan);
|
2002-09-11 17:09:48 +00:00
|
|
|
ast_stopstream(chan);
|
2006-01-17 20:16:18 +00:00
|
|
|
ast_indicate(chan, -1);
|
2017-12-22 14:23:22 +00:00
|
|
|
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
owriteformat = ao2_bump(ast_channel_writeformat(chan));
|
|
|
|
res = ast_set_write_format(chan, ast_format_slin);
|
2002-09-11 17:09:48 +00:00
|
|
|
if (res < 0) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
ao2_cleanup(owriteformat);
|
2002-09-11 17:09:48 +00:00
|
|
|
return -1;
|
|
|
|
}
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
|
|
|
|
myf.f.frametype = AST_FRAME_VOICE;
|
|
|
|
myf.f.subclass.format = ast_format_slin;
|
|
|
|
myf.f.offset = AST_FRIENDLY_OFFSET;
|
|
|
|
myf.f.src = __PRETTY_FUNCTION__;
|
|
|
|
myf.f.data.ptr = myf.frdata;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
res = send_waveform_to_fd(waveform, length, fds[1]);
|
2002-09-11 17:09:48 +00:00
|
|
|
if (res >= 0) {
|
|
|
|
/* Order is important -- there's almost always going to be mp3... we want to prioritize the
|
|
|
|
user */
|
|
|
|
for (;;) {
|
2007-07-31 01:10:47 +00:00
|
|
|
res = ast_waitfor(chan, 1000);
|
2002-09-11 17:09:48 +00:00
|
|
|
if (res < 1) {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
2003-08-14 15:58:55 +00:00
|
|
|
f = ast_read(chan);
|
|
|
|
if (!f) {
|
2003-09-27 02:31:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Null frame == hangup() detected\n");
|
2003-08-14 15:58:55 +00:00
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (f->frametype == AST_FRAME_DTMF) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "User pressed a key\n");
|
2009-11-04 14:05:12 +00:00
|
|
|
if (intkeys && strchr(intkeys, f->subclass.integer)) {
|
|
|
|
res = f->subclass.integer;
|
2003-08-15 04:38:39 +00:00
|
|
|
ast_frfree(f);
|
|
|
|
break;
|
|
|
|
}
|
2003-08-14 15:58:55 +00:00
|
|
|
}
|
|
|
|
if (f->frametype == AST_FRAME_VOICE) {
|
|
|
|
/* Treat as a generator */
|
2003-08-14 16:01:25 +00:00
|
|
|
needed = f->samples * 2;
|
2003-08-14 15:58:55 +00:00
|
|
|
if (needed > sizeof(myf.frdata)) {
|
|
|
|
ast_log(LOG_WARNING, "Only able to deliver %d of %d requested samples\n",
|
2004-06-13 21:25:10 +00:00
|
|
|
(int)sizeof(myf.frdata) / 2, needed/2);
|
2003-08-14 15:58:55 +00:00
|
|
|
needed = sizeof(myf.frdata);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
2003-08-14 15:58:55 +00:00
|
|
|
res = read(fds[0], myf.frdata, needed);
|
2002-09-11 17:09:48 +00:00
|
|
|
if (res > 0) {
|
|
|
|
myf.f.datalen = res;
|
2002-11-29 02:14:13 +00:00
|
|
|
myf.f.samples = res / 2;
|
2002-09-11 17:09:48 +00:00
|
|
|
if (ast_write(chan, &myf.f) < 0) {
|
|
|
|
res = -1;
|
2006-06-11 20:46:05 +00:00
|
|
|
ast_frfree(f);
|
2002-09-11 17:09:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-12-19 21:13:41 +00:00
|
|
|
if (res < needed) { /* last frame */
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Last frame\n");
|
2007-07-31 01:10:47 +00:00
|
|
|
res = 0;
|
2006-06-11 20:46:05 +00:00
|
|
|
ast_frfree(f);
|
2002-09-11 17:09:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "No more waveform\n");
|
2002-09-11 17:09:48 +00:00
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
}
|
2003-08-14 15:58:55 +00:00
|
|
|
ast_frfree(f);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close(fds[0]);
|
|
|
|
close(fds[1]);
|
2004-12-19 21:13:41 +00:00
|
|
|
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
if (!res && owriteformat)
|
|
|
|
ast_set_write_format(chan, owriteformat);
|
|
|
|
ao2_cleanup(owriteformat);
|
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-05-21 21:13:09 +00:00
|
|
|
static int festival_exec(struct ast_channel *chan, const char *vdata)
|
2002-09-11 17:09:48 +00:00
|
|
|
{
|
|
|
|
int usecache;
|
2007-07-31 01:10:47 +00:00
|
|
|
int res = 0;
|
|
|
|
struct sockaddr_in serv_addr;
|
2002-09-11 17:09:48 +00:00
|
|
|
int fd;
|
|
|
|
FILE *fs;
|
2006-09-20 20:40:39 +00:00
|
|
|
const char *host;
|
|
|
|
const char *cachedir;
|
|
|
|
const char *temp;
|
|
|
|
const char *festivalcommand;
|
2007-07-31 01:10:47 +00:00
|
|
|
int port = 1314;
|
2002-09-11 17:09:48 +00:00
|
|
|
int n;
|
|
|
|
char ack[4];
|
|
|
|
char *waveform;
|
|
|
|
int filesize;
|
|
|
|
char bigstring[MAXFESTLEN];
|
|
|
|
int i;
|
|
|
|
struct MD5Context md5ctx;
|
|
|
|
unsigned char MD5Res[16];
|
2004-07-14 07:22:30 +00:00
|
|
|
char MD5Hex[33] = "";
|
|
|
|
char koko[4] = "";
|
|
|
|
char cachefile[MAXFESTLEN]="";
|
2007-07-31 01:10:47 +00:00
|
|
|
int readcache = 0;
|
|
|
|
int writecache = 0;
|
2002-09-11 17:09:48 +00:00
|
|
|
int strln;
|
2003-08-15 04:38:39 +00:00
|
|
|
int fdesc = -1;
|
2002-09-11 17:09:48 +00:00
|
|
|
char buffer[16384];
|
2017-12-22 14:23:22 +00:00
|
|
|
int seekpos = 0;
|
|
|
|
char *data;
|
2002-09-11 17:09:48 +00:00
|
|
|
struct ast_config *cfg;
|
2006-05-09 05:30:05 +00:00
|
|
|
char *newfestivalcommand;
|
2007-08-16 21:09:46 +00:00
|
|
|
struct ast_flags config_flags = { 0 };
|
2007-07-31 01:10:47 +00:00
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(text);
|
|
|
|
AST_APP_ARG(interrupt);
|
|
|
|
);
|
2005-10-19 18:19:02 +00:00
|
|
|
|
2005-10-26 19:48:14 +00:00
|
|
|
if (ast_strlen_zero(vdata)) {
|
2005-10-19 18:19:02 +00:00
|
|
|
ast_log(LOG_WARNING, "festival requires an argument (text)\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-16 21:09:46 +00:00
|
|
|
cfg = ast_config_load(FESTIVAL_CONFIG, config_flags);
|
2002-09-11 17:09:48 +00:00
|
|
|
if (!cfg) {
|
|
|
|
ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
|
|
|
|
return -1;
|
2008-09-12 23:30:03 +00:00
|
|
|
} else if (cfg == CONFIG_STATUS_FILEINVALID) {
|
|
|
|
ast_log(LOG_ERROR, "Config file " FESTIVAL_CONFIG " is in an invalid format. Aborting.\n");
|
|
|
|
return -1;
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
2008-09-12 23:30:03 +00:00
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
if (!(host = ast_variable_retrieve(cfg, "general", "host"))) {
|
|
|
|
host = "localhost";
|
|
|
|
}
|
|
|
|
if (!(temp = ast_variable_retrieve(cfg, "general", "port"))) {
|
|
|
|
port = 1314;
|
|
|
|
} else {
|
|
|
|
port = atoi(temp);
|
|
|
|
}
|
|
|
|
if (!(temp = ast_variable_retrieve(cfg, "general", "usecache"))) {
|
2007-07-31 01:10:47 +00:00
|
|
|
usecache = 0;
|
2002-09-11 17:09:48 +00:00
|
|
|
} else {
|
2003-06-27 23:02:52 +00:00
|
|
|
usecache = ast_true(temp);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
|
|
|
if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) {
|
|
|
|
cachedir = "/tmp/";
|
|
|
|
}
|
2008-03-18 15:43:34 +00:00
|
|
|
|
|
|
|
data = ast_strdupa(vdata);
|
|
|
|
AST_STANDARD_APP_ARGS(args, data);
|
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) {
|
2008-03-18 15:43:34 +00:00
|
|
|
const char *startcmd = "(tts_textasterisk \"";
|
|
|
|
const char *endcmd = "\" 'file)(quit)\n";
|
|
|
|
|
|
|
|
strln = strlen(startcmd) + strlen(args.text) + strlen(endcmd) + 1;
|
2012-07-31 20:21:43 +00:00
|
|
|
newfestivalcommand = ast_alloca(strln);
|
2008-03-18 15:43:34 +00:00
|
|
|
snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd);
|
|
|
|
festivalcommand = newfestivalcommand;
|
2006-05-09 05:30:05 +00:00
|
|
|
} else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */
|
2008-08-10 14:45:25 +00:00
|
|
|
int x, j;
|
2012-07-31 20:21:43 +00:00
|
|
|
newfestivalcommand = ast_alloca(strlen(festivalcommand) + strlen(args.text) + 1);
|
2006-05-09 05:30:05 +00:00
|
|
|
|
2008-08-10 14:45:25 +00:00
|
|
|
for (x = 0, j = 0; x < strlen(festivalcommand); x++) {
|
|
|
|
if (festivalcommand[x] == '\\' && festivalcommand[x + 1] == 'n') {
|
2006-05-09 05:30:05 +00:00
|
|
|
newfestivalcommand[j++] = '\n';
|
2008-08-10 14:45:25 +00:00
|
|
|
x++;
|
|
|
|
} else if (festivalcommand[x] == '\\') {
|
|
|
|
newfestivalcommand[j++] = festivalcommand[x + 1];
|
|
|
|
x++;
|
|
|
|
} else if (festivalcommand[x] == '%' && festivalcommand[x + 1] == 's') {
|
2008-03-18 15:43:34 +00:00
|
|
|
sprintf(&newfestivalcommand[j], "%s", args.text); /* we know it is big enough */
|
|
|
|
j += strlen(args.text);
|
2008-08-10 14:45:25 +00:00
|
|
|
x++;
|
2006-05-09 05:30:05 +00:00
|
|
|
} else
|
2008-08-10 14:45:25 +00:00
|
|
|
newfestivalcommand[j++] = festivalcommand[x];
|
2006-05-09 05:30:05 +00:00
|
|
|
}
|
|
|
|
newfestivalcommand[j] = '\0';
|
|
|
|
festivalcommand = newfestivalcommand;
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
if (args.interrupt && !strcasecmp(args.interrupt, "any"))
|
|
|
|
args.interrupt = AST_DIGIT_ANY;
|
|
|
|
|
|
|
|
ast_debug(1, "Text passed to festival server : %s\n", args.text);
|
2002-09-11 17:09:48 +00:00
|
|
|
/* Connect to local festival server */
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2006-10-03 15:53:07 +00:00
|
|
|
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
2002-09-11 17:09:48 +00:00
|
|
|
|
2006-10-03 15:53:07 +00:00
|
|
|
if (fd < 0) {
|
2007-07-31 01:10:47 +00:00
|
|
|
ast_log(LOG_WARNING, "festival_client: can't get socket\n");
|
2005-01-25 06:10:20 +00:00
|
|
|
ast_config_destroy(cfg);
|
2006-10-03 15:53:07 +00:00
|
|
|
return -1;
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
2006-10-03 15:53:07 +00:00
|
|
|
|
|
|
|
memset(&serv_addr, 0, sizeof(serv_addr));
|
|
|
|
|
|
|
|
if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
|
|
|
|
/* its a name rather than an ipnum */
|
2021-12-24 16:26:31 +00:00
|
|
|
struct ast_sockaddr addr = { {0,} };
|
2006-10-03 15:53:07 +00:00
|
|
|
|
2021-12-24 16:26:31 +00:00
|
|
|
if (ast_sockaddr_resolve_first_af(&addr, host, PARSE_PORT_FORBID, AF_INET)) {
|
|
|
|
ast_log(LOG_WARNING, "festival_client: ast_sockaddr_resolve_first_af() failed\n");
|
2005-01-25 06:10:20 +00:00
|
|
|
ast_config_destroy(cfg);
|
2017-12-20 06:53:17 +00:00
|
|
|
close(fd);
|
2006-10-03 15:53:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2021-12-24 16:26:31 +00:00
|
|
|
|
|
|
|
/* We'll overwrite port and family in a sec */
|
|
|
|
ast_sockaddr_to_sin(&addr, &serv_addr);
|
2006-10-03 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
serv_addr.sin_family = AF_INET;
|
|
|
|
serv_addr.sin_port = htons(port);
|
|
|
|
|
|
|
|
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {
|
2007-07-31 01:10:47 +00:00
|
|
|
ast_log(LOG_WARNING, "festival_client: connect to server failed\n");
|
2005-01-25 06:10:20 +00:00
|
|
|
ast_config_destroy(cfg);
|
2017-12-20 06:53:17 +00:00
|
|
|
close(fd);
|
2007-07-31 01:10:47 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute MD5 sum of string */
|
|
|
|
MD5Init(&md5ctx);
|
|
|
|
MD5Update(&md5ctx, (unsigned char *)args.text, strlen(args.text));
|
|
|
|
MD5Final(MD5Res, &md5ctx);
|
|
|
|
MD5Hex[0] = '\0';
|
|
|
|
|
2017-12-22 14:23:22 +00:00
|
|
|
/* Convert to HEX and look if there is any matching file in the cache
|
2007-07-31 01:10:47 +00:00
|
|
|
directory */
|
|
|
|
for (i = 0; i < 16; i++) {
|
2014-05-09 22:49:26 +00:00
|
|
|
snprintf(koko, sizeof(koko), "%X", (unsigned)MD5Res[i]);
|
2007-07-31 01:10:47 +00:00
|
|
|
strncat(MD5Hex, koko, sizeof(MD5Hex) - strlen(MD5Hex) - 1);
|
|
|
|
}
|
|
|
|
readcache = 0;
|
|
|
|
writecache = 0;
|
2022-05-03 12:57:58 +00:00
|
|
|
if (strlen(cachedir) + sizeof(MD5Hex) + 1 <= MAXFESTLEN && (usecache == -1)) {
|
2007-07-31 01:10:47 +00:00
|
|
|
snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex);
|
|
|
|
fdesc = open(cachefile, O_RDWR);
|
|
|
|
if (fdesc == -1) {
|
|
|
|
fdesc = open(cachefile, O_CREAT | O_RDWR, AST_FILE_MODE);
|
|
|
|
if (fdesc != -1) {
|
|
|
|
writecache = 1;
|
|
|
|
strln = strlen(args.text);
|
|
|
|
ast_debug(1, "line length : %d\n", strln);
|
2008-11-02 18:52:13 +00:00
|
|
|
if (write(fdesc,&strln,sizeof(int)) < 0) {
|
|
|
|
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
|
|
|
|
}
|
|
|
|
if (write(fdesc,data,strln) < 0) {
|
|
|
|
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
|
|
|
|
}
|
2007-07-31 01:10:47 +00:00
|
|
|
seekpos = lseek(fdesc, 0, SEEK_CUR);
|
|
|
|
ast_debug(1, "Seek position : %d\n", seekpos);
|
|
|
|
}
|
|
|
|
} else {
|
2008-11-02 18:52:13 +00:00
|
|
|
if (read(fdesc,&strln,sizeof(int)) != sizeof(int)) {
|
|
|
|
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
|
|
|
|
}
|
2007-07-31 01:10:47 +00:00
|
|
|
ast_debug(1, "Cache file exists, strln=%d, strlen=%d\n", strln, (int)strlen(args.text));
|
|
|
|
if (strlen(args.text) == strln) {
|
|
|
|
ast_debug(1, "Size OK\n");
|
2008-11-02 18:52:13 +00:00
|
|
|
if (read(fdesc,&bigstring,strln) != strln) {
|
|
|
|
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
|
|
|
|
}
|
2007-07-31 01:10:47 +00:00
|
|
|
bigstring[strln] = 0;
|
2017-12-22 14:23:22 +00:00
|
|
|
if (strcmp(bigstring, args.text) == 0) {
|
2007-07-31 01:10:47 +00:00
|
|
|
readcache = 1;
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_WARNING, "Strings do not match\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_WARNING, "Size mismatch\n");
|
|
|
|
}
|
|
|
|
}
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
2007-07-31 01:10:47 +00:00
|
|
|
|
|
|
|
if (readcache == 1) {
|
2002-09-11 17:09:48 +00:00
|
|
|
close(fd);
|
2007-07-31 01:10:47 +00:00
|
|
|
fd = fdesc;
|
|
|
|
ast_debug(1, "Reading from cache...\n");
|
2002-09-11 17:09:48 +00:00
|
|
|
} else {
|
2007-07-31 01:10:47 +00:00
|
|
|
ast_debug(1, "Passing text to festival...\n");
|
|
|
|
fs = fdopen(dup(fd), "wb");
|
2008-03-18 15:43:34 +00:00
|
|
|
|
|
|
|
fprintf(fs, "%s", festivalcommand);
|
2002-09-11 17:09:48 +00:00
|
|
|
fflush(fs);
|
|
|
|
fclose(fs);
|
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
/* Write to cache and then pass it down */
|
2007-07-31 01:10:47 +00:00
|
|
|
if (writecache == 1) {
|
|
|
|
ast_debug(1, "Writing result to cache...\n");
|
|
|
|
while ((strln = read(fd, buffer, 16384)) != 0) {
|
2008-11-02 18:52:13 +00:00
|
|
|
if (write(fdesc,buffer,strln) < 0) {
|
|
|
|
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
|
|
|
|
}
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
close(fdesc);
|
2007-07-31 01:10:47 +00:00
|
|
|
fd = open(cachefile, O_RDWR);
|
|
|
|
lseek(fd, seekpos, SEEK_SET);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
ast_debug(1, "Passing data to channel...\n");
|
|
|
|
|
2002-09-11 17:09:48 +00:00
|
|
|
/* Read back info from server */
|
|
|
|
/* This assumes only one waveform will come back, also LP is unlikely */
|
|
|
|
do {
|
2007-07-31 01:10:47 +00:00
|
|
|
int read_data;
|
|
|
|
for (n = 0; n < 3; ) {
|
|
|
|
read_data = read(fd, ack + n, 3 - n);
|
|
|
|
/* this avoids falling in infinite loop
|
|
|
|
* in case that festival server goes down
|
|
|
|
*/
|
|
|
|
if (read_data == -1) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to read from cache/festival fd\n");
|
|
|
|
close(fd);
|
|
|
|
ast_config_destroy(cfg);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
n += read_data;
|
|
|
|
}
|
2002-09-11 17:09:48 +00:00
|
|
|
ack[3] = '\0';
|
2007-07-31 01:10:47 +00:00
|
|
|
if (strcmp(ack, "WV\n") == 0) { /* receive a waveform */
|
|
|
|
ast_debug(1, "Festival WV command\n");
|
|
|
|
if ((waveform = socket_receive_file_to_buff(fd, &filesize))) {
|
|
|
|
res = send_waveform_to_channel(chan, waveform, filesize, args.interrupt);
|
|
|
|
ast_free(waveform);
|
|
|
|
}
|
2002-09-11 17:09:48 +00:00
|
|
|
break;
|
2007-07-31 01:10:47 +00:00
|
|
|
} else if (strcmp(ack, "LP\n") == 0) { /* receive an s-expr */
|
|
|
|
ast_debug(1, "Festival LP command\n");
|
|
|
|
if ((waveform = socket_receive_file_to_buff(fd, &filesize))) {
|
|
|
|
waveform[filesize] = '\0';
|
|
|
|
ast_log(LOG_WARNING, "Festival returned LP : %s\n", waveform);
|
|
|
|
ast_free(waveform);
|
|
|
|
}
|
|
|
|
} else if (strcmp(ack, "ER\n") == 0) { /* server got an error */
|
|
|
|
ast_log(LOG_WARNING, "Festival returned ER\n");
|
|
|
|
res = -1;
|
2002-09-11 17:09:48 +00:00
|
|
|
break;
|
2007-07-31 01:10:47 +00:00
|
|
|
}
|
|
|
|
} while (strcmp(ack, "OK\n") != 0);
|
2002-09-11 17:09:48 +00:00
|
|
|
close(fd);
|
2005-01-25 06:10:20 +00:00
|
|
|
ast_config_destroy(cfg);
|
2002-09-11 17:09:48 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2002-09-11 17:09:48 +00:00
|
|
|
{
|
2007-07-16 13:35:20 +00:00
|
|
|
return ast_unregister_application(app);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
|
|
|
|
2012-10-01 23:22:50 +00:00
|
|
|
/*!
|
|
|
|
* \brief Load the module
|
|
|
|
*
|
|
|
|
* Module loading including tests for configuration or dependencies.
|
|
|
|
* This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE,
|
|
|
|
* or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails
|
2017-12-22 14:23:22 +00:00
|
|
|
* tests return AST_MODULE_LOAD_FAILURE. If the module can not load the
|
|
|
|
* configuration file or other non-critical problem return
|
2012-10-01 23:22:50 +00:00
|
|
|
* AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
|
|
|
|
*/
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2002-09-11 17:09:48 +00:00
|
|
|
{
|
2007-08-16 21:09:46 +00:00
|
|
|
struct ast_flags config_flags = { 0 };
|
|
|
|
struct ast_config *cfg = ast_config_load(FESTIVAL_CONFIG, config_flags);
|
2006-08-31 21:00:20 +00:00
|
|
|
if (!cfg) {
|
|
|
|
ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
2008-09-12 23:30:03 +00:00
|
|
|
} else if (cfg == CONFIG_STATUS_FILEINVALID) {
|
|
|
|
ast_log(LOG_ERROR, "Config file " FESTIVAL_CONFIG " is in an invalid format. Aborting.\n");
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
2006-08-31 21:00:20 +00:00
|
|
|
}
|
|
|
|
ast_config_destroy(cfg);
|
2008-11-01 21:10:07 +00:00
|
|
|
return ast_register_application_xml(app, festival_exec);
|
2002-09-11 17:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-07-25 16:47:17 +00:00
|
|
|
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Simple Festival Interface");
|