diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-11-16 15:10:23 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-11-16 15:10:23 +0000 |
commit | 39a48ea2699eeb51eefa8ed92de91258a04bc8a1 (patch) | |
tree | eb1bfcf2b2fd648c4f4ea20b3056ecb9682b9d0e /contrib/package/asterisk-xip/patches | |
parent | ce8855055915b91d6a388f9967c0244f8be8921b (diff) |
contrib: remove asterisk-xip
Diffstat (limited to 'contrib/package/asterisk-xip/patches')
11 files changed, 0 insertions, 1325 deletions
diff --git a/contrib/package/asterisk-xip/patches/011-Makefile-main.patch b/contrib/package/asterisk-xip/patches/011-Makefile-main.patch deleted file mode 100644 index dbb5c44fee..0000000000 --- a/contrib/package/asterisk-xip/patches/011-Makefile-main.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nru asterisk-1.4.22.org/main/Makefile asterisk-1.4.22/main/Makefile ---- asterisk-1.4.22.org/main/Makefile 2008-07-18 18:15:41.000000000 +0200 -+++ asterisk-1.4.22/main/Makefile 2008-11-29 14:58:13.000000000 +0100 -@@ -144,7 +144,7 @@ - ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),) - $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) - else -- $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) -+ $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) - endif - $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/strip_nonapi $@ || rm $@ - diff --git a/contrib/package/asterisk-xip/patches/013-chan_iax2-tmp_path.patch b/contrib/package/asterisk-xip/patches/013-chan_iax2-tmp_path.patch deleted file mode 100644 index 12b64d758c..0000000000 --- a/contrib/package/asterisk-xip/patches/013-chan_iax2-tmp_path.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nru asterisk-1.4.22.org/channels/chan_iax2.c asterisk-1.4.22/channels/chan_iax2.c ---- asterisk-1.4.22.org/channels/chan_iax2.c 2008-09-02 20:14:57.000000000 +0200 -+++ asterisk-1.4.22/channels/chan_iax2.c 2008-11-29 15:00:00.000000000 +0100 -@@ -1815,7 +1815,7 @@ - last++; - else - last = s; -- snprintf(s2, strlen(s) + 100, "/var/tmp/%s-%ld", last, (unsigned long)ast_random()); -+ snprintf(s2, strlen(s) + 100, "/tmp/%s-%ld", last, (unsigned long)ast_random()); - res = stat(s, &stbuf); - if (res < 0) { - ast_log(LOG_WARNING, "Failed to stat '%s': %s\n", s, strerror(errno)); diff --git a/contrib/package/asterisk-xip/patches/014-openssl-configure_ac.patch b/contrib/package/asterisk-xip/patches/014-openssl-configure_ac.patch deleted file mode 100644 index 9f3d9cd925..0000000000 --- a/contrib/package/asterisk-xip/patches/014-openssl-configure_ac.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nru asterisk-1.4.22.org/configure.ac asterisk-1.4.22/configure.ac ---- asterisk-1.4.22.org/configure.ac 2008-09-08 18:26:00.000000000 +0200 -+++ asterisk-1.4.22/configure.ac 2008-11-29 15:01:13.000000000 +0100 -@@ -1319,7 +1319,7 @@ - - AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h]) - --AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl2_connect], [openssl/ssl.h], [-lcrypto]) -+AST_EXT_LIB_CHECK([OPENSSL], [ssl], [ssl23_connect], [openssl/ssl.h], [-lcrypto]) - if test "$PBX_OPENSSL" = "1"; - then - AST_EXT_LIB_CHECK([OSPTK], [osptk], [OSPPCryptoDecrypt], [osp/osp.h], [-lcrypto -lssl]) diff --git a/contrib/package/asterisk-xip/patches/015-spandsp-app_fax.patch b/contrib/package/asterisk-xip/patches/015-spandsp-app_fax.patch deleted file mode 100644 index ce2c042b2e..0000000000 --- a/contrib/package/asterisk-xip/patches/015-spandsp-app_fax.patch +++ /dev/null @@ -1,875 +0,0 @@ -diff -Nru asterisk-1.4.22.org/apps/app_rxfax.c asterisk-1.4.22/apps/app_rxfax.c ---- asterisk-1.4.22.org/apps/app_rxfax.c 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-1.4.22/apps/app_rxfax.c 2008-11-29 15:02:27.000000000 +0100 -@@ -0,0 +1,376 @@ -+/* -+ * Asterisk -- A telephony toolkit for Linux. -+ * -+ * Trivial application to receive a TIFF FAX file -+ * -+ * Copyright (C) 2003, Steve Underwood -+ * -+ * Steve Underwood <steveu@coppice.org> -+ * -+ * This program is free software, distributed under the terms of -+ * the GNU General Public License -+ */ -+ -+/*** MODULEINFO -+ <depend>spandsp</depend> -+***/ -+ -+#include "asterisk.h" -+ -+ASTERISK_FILE_VERSION(__FILE__, "$Revision:$") -+ -+#include <string.h> -+#include <stdlib.h> -+#include <stdio.h> -+#include <inttypes.h> -+#include <pthread.h> -+#include <errno.h> -+#include <tiffio.h> -+ -+#include <spandsp.h> -+ -+#include "asterisk/lock.h" -+#include "asterisk/file.h" -+#include "asterisk/logger.h" -+#include "asterisk/channel.h" -+#include "asterisk/pbx.h" -+#include "asterisk/module.h" -+#include "asterisk/translate.h" -+#include "asterisk/dsp.h" -+#include "asterisk/manager.h" -+ -+static char *app = "RxFAX"; -+ -+static char *synopsis = "Receive a FAX to a file"; -+ -+static char *descrip = -+" RxFAX(filename[|caller][|debug]): Receives a FAX from the channel into the\n" -+"given filename. If the file exists it will be overwritten. The file\n" -+"should be in TIFF/F format.\n" -+"The \"caller\" option makes the application behave as a calling machine,\n" -+"rather than the answering machine. The default behaviour is to behave as\n" -+"an answering machine.\n" -+"Uses LOCALSTATIONID to identify itself to the remote end.\n" -+" LOCALHEADERINFO to generate a header line on each page.\n" -+"Sets REMOTESTATIONID to the sender CSID.\n" -+" FAXPAGES to the number of pages received.\n" -+" FAXBITRATE to the transmition rate.\n" -+" FAXRESOLUTION to the resolution.\n" -+"Returns -1 when the user hangs up.\n" -+"Returns 0 otherwise.\n"; -+ -+#define MAX_BLOCK_SIZE 240 -+ -+static void span_message(int level, const char *msg) -+{ -+ int ast_level; -+ -+ if (level == SPAN_LOG_WARNING) -+ ast_level = __LOG_WARNING; -+ else if (level == SPAN_LOG_WARNING) -+ ast_level = __LOG_WARNING; -+ else -+ ast_level = __LOG_DEBUG; -+ ast_log(ast_level, __FILE__, __LINE__, __PRETTY_FUNCTION__, msg); -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static void t30_flush(t30_state_t *s, int which) -+{ -+ /* TODO: */ -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static void phase_e_handler(t30_state_t *s, void *user_data, int result) -+{ -+ struct ast_channel *chan; -+ t30_stats_t t; -+ char local_ident[21]; -+ char far_ident[21]; -+ char buf[11]; -+ -+ chan = (struct ast_channel *) user_data; -+ if (result == T30_ERR_OK) -+ { -+ t30_get_transfer_statistics(s, &t); -+ t30_get_far_ident(s, far_ident); -+ t30_get_local_ident(s, local_ident); -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ ast_log(LOG_DEBUG, "Fax successfully received.\n"); -+ ast_log(LOG_DEBUG, "Remote station id: %s\n", far_ident); -+ ast_log(LOG_DEBUG, "Local station id: %s\n", local_ident); -+ ast_log(LOG_DEBUG, "Pages transferred: %i\n", t.pages_transferred); -+ ast_log(LOG_DEBUG, "Image resolution: %i x %i\n", t.x_resolution, t.y_resolution); -+ ast_log(LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate); -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ manager_event(EVENT_FLAG_CALL, -+ "FaxReceived", "Channel: %s\nExten: %s\nCallerID: %s\nRemoteStationID: %s\nLocalStationID: %s\nPagesTransferred: %i\nResolution: %i\nTransferRate: %i\nFileName: %s\n", -+ chan->name, -+ chan->exten, -+ (chan->cid.cid_num) ? chan->cid.cid_num : "", -+ far_ident, -+ local_ident, -+ t.pages_transferred, -+ t.y_resolution, -+ t.bit_rate, -+ s->rx_file); -+ pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", far_ident); -+ snprintf(buf, sizeof(buf), "%i", t.pages_transferred); -+ pbx_builtin_setvar_helper(chan, "FAXPAGES", buf); -+ snprintf(buf, sizeof(buf), "%i", t.y_resolution); -+ pbx_builtin_setvar_helper(chan, "FAXRESOLUTION", buf); -+ snprintf(buf, sizeof(buf), "%i", t.bit_rate); -+ pbx_builtin_setvar_helper(chan, "FAXBITRATE", buf); -+ } -+ else -+ { -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ ast_log(LOG_DEBUG, "Fax receive not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result)); -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ } -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static void phase_d_handler(t30_state_t *s, void *user_data, int result) -+{ -+ struct ast_channel *chan; -+ t30_stats_t t; -+ -+ chan = (struct ast_channel *) user_data; -+ if (result) -+ { -+ t30_get_transfer_statistics(s, &t); -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ ast_log(LOG_DEBUG, "Pages transferred: %i\n", t.pages_transferred); -+ ast_log(LOG_DEBUG, "Image size: %i x %i\n", t.width, t.length); -+ ast_log(LOG_DEBUG, "Image resolution %i x %i\n", t.x_resolution, t.y_resolution); -+ ast_log(LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate); -+ ast_log(LOG_DEBUG, "Bad rows %i\n", t.bad_rows); -+ ast_log(LOG_DEBUG, "Longest bad row run %i\n", t.longest_bad_row_run); -+ ast_log(LOG_DEBUG, "Compression type %i\n", t.encoding); -+ ast_log(LOG_DEBUG, "Image size (bytes) %i\n", t.image_size); -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ } -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static int rxfax_exec(struct ast_channel *chan, void *data) -+{ -+ int res = 0; -+ char template_file[256]; -+ char target_file[256]; -+ char *s; -+ char *t; -+ char *v; -+ const char *x; -+ int option; -+ int len; -+ int i; -+ fax_state_t fax; -+ int calling_party; -+ int verbose; -+ int samples; -+ -+ struct ast_module_user *u; -+ struct ast_frame *inf = NULL; -+ struct ast_frame outf; -+ -+ int original_read_fmt; -+ int original_write_fmt; -+ -+ uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*AST_FRIENDLY_OFFSET]; -+ uint8_t *buf = __buf + AST_FRIENDLY_OFFSET; -+ -+ if (chan == NULL) -+ { -+ ast_log(LOG_WARNING, "Fax receive channel is NULL. Giving up.\n"); -+ return -1; -+ } -+ -+ span_set_message_handler(span_message); -+ -+ /* The next few lines of code parse out the filename and header from the input string */ -+ if (data == NULL) -+ { -+ /* No data implies no filename or anything is present */ -+ ast_log(LOG_WARNING, "Rxfax requires an argument (filename)\n"); -+ return -1; -+ } -+ -+ calling_party = FALSE; -+ verbose = FALSE; -+ target_file[0] = '\0'; -+ -+ for (option = 0, v = s = data; v; option++, s++) -+ { -+ t = s; -+ v = strchr(s, '|'); -+ s = (v) ? v : s + strlen(s); -+ strncpy((char *) buf, t, s - t); -+ buf[s - t] = '\0'; -+ if (option == 0) -+ { -+ /* The first option is always the file name */ -+ len = s - t; -+ if (len > 255) -+ len = 255; -+ strncpy(target_file, t, len); -+ target_file[len] = '\0'; -+ /* Allow the use of %d in the file name for a wild card of sorts, to -+ create a new file with the specified name scheme */ -+ if ((x = strchr(target_file, '%')) && x[1] == 'd') -+ { -+ strcpy(template_file, target_file); -+ i = 0; -+ do -+ { -+ snprintf(target_file, 256, template_file, 1); -+ i++; -+ } -+ while (ast_fileexists(target_file, "", chan->language) != -1); -+ } -+ } -+ else if (strncmp("caller", t, s - t) == 0) -+ { -+ calling_party = TRUE; -+ } -+ else if (strncmp("debug", t, s - t) == 0) -+ { -+ verbose = TRUE; -+ } -+ } -+ -+ /* Done parsing */ -+ -+ u = ast_module_user_add(chan); -+ -+ if (chan->_state != AST_STATE_UP) -+ { -+ /* Shouldn't need this, but checking to see if channel is already answered -+ * Theoretically asterisk should already have answered before running the app */ -+ res = ast_answer(chan); -+ } -+ -+ if (!res) -+ { -+ original_read_fmt = chan->readformat; -+ if (original_read_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); -+ if (res < 0) -+ { -+ ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n"); -+ return -1; -+ } -+ } -+ original_write_fmt = chan->writeformat; -+ if (original_write_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); -+ if (res < 0) -+ { -+ ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n"); -+ res = ast_set_read_format(chan, original_read_fmt); -+ if (res) -+ ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name); -+ return -1; -+ } -+ } -+ fax_init(&fax, calling_party); -+ if (verbose) -+ fax.logging.level = SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW; -+ x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"); -+ if (x && x[0]) -+ t30_set_local_ident(&fax.t30_state, x); -+ x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO"); -+ if (x && x[0]) -+ t30_set_header_info(&fax.t30_state, x); -+ t30_set_rx_file(&fax.t30_state, target_file, -1); -+ //t30_set_phase_b_handler(&fax.t30_state, phase_b_handler, chan); -+ t30_set_phase_d_handler(&fax.t30_state, phase_d_handler, chan); -+ t30_set_phase_e_handler(&fax.t30_state, phase_e_handler, chan); -+ t30_set_ecm_capability(&fax.t30_state, TRUE); -+ t30_set_supported_compressions(&fax.t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); -+ while (ast_waitfor(chan, -1) > -1) -+ { -+ inf = ast_read(chan); -+ if (inf == NULL) -+ { -+ res = -1; -+ break; -+ } -+ if (inf->frametype == AST_FRAME_VOICE) -+ { -+ if (fax_rx(&fax, inf->data, inf->samples)) -+ break; -+ samples = (inf->samples <= MAX_BLOCK_SIZE) ? inf->samples : MAX_BLOCK_SIZE; -+ len = fax_tx(&fax, (int16_t *) &buf[AST_FRIENDLY_OFFSET], samples); -+ if (len) -+ { -+ memset(&outf, 0, sizeof(outf)); -+ outf.frametype = AST_FRAME_VOICE; -+ outf.subclass = AST_FORMAT_SLINEAR; -+ outf.datalen = len*sizeof(int16_t); -+ outf.samples = len; -+ outf.data = &buf[AST_FRIENDLY_OFFSET]; -+ outf.offset = AST_FRIENDLY_OFFSET; -+ outf.src = "RxFAX"; -+ if (ast_write(chan, &outf) < 0) -+ { -+ ast_log(LOG_WARNING, "Unable to write frame to channel; %s\n", strerror(errno)); -+ break; -+ } -+ } -+ } -+ ast_frfree(inf); -+ } -+ if (inf == NULL) -+ { -+ ast_log(LOG_DEBUG, "Got hangup\n"); -+ res = -1; -+ } -+ if (original_read_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_read_format(chan, original_read_fmt); -+ if (res) -+ ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name); -+ } -+ if (original_write_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_write_format(chan, original_write_fmt); -+ if (res) -+ ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", chan->name); -+ } -+ t30_terminate(&fax.t30_state); -+ } -+ else -+ { -+ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name); -+ } -+ ast_module_user_remove(u); -+ return res; -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static int unload_module(void) -+{ -+ int res; -+ -+ ast_module_user_hangup_all(); -+ -+ res = ast_unregister_application(app); -+ -+ -+ return res; -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static int load_module(void) -+{ -+ return ast_register_application(app, rxfax_exec, synopsis, descrip); -+} -+/*- End of function --------------------------------------------------------*/ -+ -+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Trivial FAX Receive Application"); -+ -+/*- End of file ------------------------------------------------------------*/ -diff -Nru asterisk-1.4.22.org/apps/app_txfax.c asterisk-1.4.22/apps/app_txfax.c ---- asterisk-1.4.22.org/apps/app_txfax.c 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-1.4.22/apps/app_txfax.c 2008-11-29 15:02:27.000000000 +0100 -@@ -0,0 +1,303 @@ -+/* -+ * Asterisk -- A telephony toolkit for Linux. -+ * -+ * Trivial application to send a TIFF file as a FAX -+ * -+ * Copyright (C) 2003, Steve Underwood -+ * -+ * Steve Underwood <steveu@coppice.org> -+ * -+ * This program is free software, distributed under the terms of -+ * the GNU General Public License -+ */ -+ -+/*** MODULEINFO -+ <depend>spandsp</depend> -+***/ -+ -+#include "asterisk.h" -+ -+ASTERISK_FILE_VERSION(__FILE__, "$Revision:$") -+ -+#include <string.h> -+#include <stdlib.h> -+#include <stdio.h> -+#include <inttypes.h> -+#include <pthread.h> -+#include <errno.h> -+#include <tiffio.h> -+ -+#include <spandsp.h> -+ -+#include "asterisk/lock.h" -+#include "asterisk/file.h" -+#include "asterisk/logger.h" -+#include "asterisk/channel.h" -+#include "asterisk/pbx.h" -+#include "asterisk/module.h" -+#include "asterisk/translate.h" -+ -+static char *app = "TxFAX"; -+ -+static char *synopsis = "Send a FAX file"; -+ -+static char *descrip = -+" TxFAX(filename[|caller][|debug]): Send a given TIFF file to the channel as a FAX.\n" -+"The \"caller\" option makes the application behave as a calling machine,\n" -+"rather than the answering machine. The default behaviour is to behave as\n" -+"an answering machine.\n" -+"Uses LOCALSTATIONID to identify itself to the remote end.\n" -+" LOCALHEADERINFO to generate a header line on each page.\n" -+"Sets REMOTESTATIONID to the receiver CSID.\n" -+"Returns -1 when the user hangs up, or if the file does not exist.\n" -+"Returns 0 otherwise.\n"; -+ -+#define MAX_BLOCK_SIZE 240 -+ -+static void span_message(int level, const char *msg) -+{ -+ int ast_level; -+ -+ if (level == SPAN_LOG_WARNING) -+ ast_level = __LOG_WARNING; -+ else if (level == SPAN_LOG_WARNING) -+ ast_level = __LOG_WARNING; -+ else -+ ast_level = __LOG_DEBUG; -+ ast_log(ast_level, __FILE__, __LINE__, __PRETTY_FUNCTION__, msg); -+} -+/*- End of function --------------------------------------------------------*/ -+ -+#if 0 -+static void t30_flush(t30_state_t *s, int which) -+{ -+ /* TODO: */ -+} -+/*- End of function --------------------------------------------------------*/ -+#endif -+ -+static void phase_e_handler(t30_state_t *s, void *user_data, int result) -+{ -+ struct ast_channel *chan; -+ char far_ident[21]; -+ -+ chan = (struct ast_channel *) user_data; -+ if (result == T30_ERR_OK) -+ { -+ t30_get_far_ident(s, far_ident); -+ pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", far_ident); -+ } -+ else -+ { -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ ast_log(LOG_DEBUG, "Fax send not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result)); -+ ast_log(LOG_DEBUG, "==============================================================================\n"); -+ } -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static int txfax_exec(struct ast_channel *chan, void *data) -+{ -+ int res = 0; -+ char source_file[256]; -+ char *s; -+ char *t; -+ char *v; -+ const char *x; -+ int option; -+ int len; -+ fax_state_t fax; -+ int calling_party; -+ int verbose; -+ int samples; -+ -+ struct ast_module_user *u; -+ struct ast_frame *inf = NULL; -+ struct ast_frame outf; -+ -+ int original_read_fmt; -+ int original_write_fmt; -+ -+ uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*AST_FRIENDLY_OFFSET]; -+ uint8_t *buf = __buf + AST_FRIENDLY_OFFSET; -+ -+ if (chan == NULL) -+ { -+ ast_log(LOG_WARNING, "Fax transmit channel is NULL. Giving up.\n"); -+ return -1; -+ } -+ -+ span_set_message_handler(span_message); -+ -+ /* The next few lines of code parse out the filename and header from the input string */ -+ if (data == NULL) -+ { -+ /* No data implies no filename or anything is present */ -+ ast_log(LOG_WARNING, "Txfax requires an argument (filename)\n"); -+ return -1; -+ } -+ -+ calling_party = FALSE; -+ verbose = FALSE; -+ source_file[0] = '\0'; -+ -+ for (option = 0, v = s = data; v; option++, s++) -+ { -+ t = s; -+ v = strchr(s, '|'); -+ s = (v) ? v : s + strlen(s); -+ strncpy((char *) buf, t, s - t); -+ buf[s - t] = '\0'; -+ if (option == 0) -+ { -+ /* The first option is always the file name */ -+ len = s - t; -+ if (len > 255) -+ len = 255; -+ strncpy(source_file, t, len); -+ source_file[len] = '\0'; -+ } -+ else if (strncmp("caller", t, s - t) == 0) -+ { -+ calling_party = TRUE; -+ } -+ else if (strncmp("debug", t, s - t) == 0) -+ { -+ verbose = TRUE; -+ } -+ } -+ -+ /* Done parsing */ -+ -+ u = ast_module_user_add(chan); -+ -+ if (chan->_state != AST_STATE_UP) -+ { -+ /* Shouldn't need this, but checking to see if channel is already answered -+ * Theoretically asterisk should already have answered before running the app */ -+ res = ast_answer(chan); -+ } -+ -+ if (!res) -+ { -+ original_read_fmt = chan->readformat; -+ if (original_read_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); -+ if (res < 0) -+ { -+ ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n"); -+ return -1; -+ } -+ } -+ original_write_fmt = chan->writeformat; -+ if (original_write_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_write_format(chan, AST_FORMAT_SLINEAR); -+ if (res < 0) -+ { -+ ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n"); -+ res = ast_set_read_format(chan, original_read_fmt); -+ if (res) -+ ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name); -+ return -1; -+ } -+ } -+ fax_init(&fax, calling_party); -+ if (verbose) -+ fax.logging.level = SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW; -+ -+ x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"); -+ if (x && x[0]) -+ t30_set_local_ident(&fax.t30_state, x); -+ x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO"); -+ if (x && x[0]) -+ t30_set_header_info(&fax.t30_state, x); -+ t30_set_tx_file(&fax.t30_state, source_file, -1, -1); -+ //t30_set_phase_b_handler(&fax.t30_state, phase_b_handler, chan); -+ //t30_set_phase_d_handler(&fax.t30_state, phase_d_handler, chan); -+ t30_set_phase_e_handler(&fax.t30_state, phase_e_handler, chan); -+ t30_set_ecm_capability(&fax.t30_state, TRUE); -+ t30_set_supported_compressions(&fax.t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION); -+ while (ast_waitfor(chan, -1) > -1) -+ { -+ inf = ast_read(chan); -+ if (inf == NULL) -+ { -+ res = -1; -+ break; -+ } -+ if (inf->frametype == AST_FRAME_VOICE) -+ { -+ if (fax_rx(&fax, inf->data, inf->samples)) -+ break; -+ samples = (inf->samples <= MAX_BLOCK_SIZE) ? inf->samples : MAX_BLOCK_SIZE; -+ len = fax_tx(&fax, (int16_t *) &buf[AST_FRIENDLY_OFFSET], samples); -+ if (len) -+ { -+ memset(&outf, 0, sizeof(outf)); -+ outf.frametype = AST_FRAME_VOICE; -+ outf.subclass = AST_FORMAT_SLINEAR; -+ outf.datalen = len*sizeof(int16_t); -+ outf.samples = len; -+ outf.data = &buf[AST_FRIENDLY_OFFSET]; -+ outf.offset = AST_FRIENDLY_OFFSET; -+ if (ast_write(chan, &outf) < 0) -+ { -+ ast_log(LOG_WARNING, "Unable to write frame to channel; %s\n", strerror(errno)); -+ break; -+ } -+ } -+ } -+ ast_frfree(inf); -+ } -+ if (inf == NULL) -+ { -+ ast_log(LOG_DEBUG, "Got hangup\n"); -+ res = -1; -+ } -+ if (original_read_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_read_format(chan, original_read_fmt); -+ if (res) -+ ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name); -+ } -+ if (original_write_fmt != AST_FORMAT_SLINEAR) -+ { -+ res = ast_set_write_format(chan, original_write_fmt); -+ if (res) -+ ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", chan->name); -+ } -+ t30_terminate(&fax.t30_state); -+ } -+ else -+ { -+ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name); -+ } -+ ast_module_user_remove(u); -+ return res; -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static int unload_module(void) -+{ -+ int res; -+ -+ ast_module_user_hangup_all(); -+ -+ res = ast_unregister_application(app); -+ -+ -+ return res; -+} -+/*- End of function --------------------------------------------------------*/ -+ -+static int load_module(void) -+{ -+ return ast_register_application(app, txfax_exec, synopsis, descrip); -+} -+/*- End of function --------------------------------------------------------*/ -+ -+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Trivial FAX Transmit Application"); -+ -+/*- End of file ------------------------------------------------------------*/ -diff -Nru asterisk-1.4.22.org/build_tools/menuselect-deps.in asterisk-1.4.22/build_tools/menuselect-deps.in ---- asterisk-1.4.22.org/build_tools/menuselect-deps.in 2008-08-14 04:02:15.000000000 +0200 -+++ asterisk-1.4.22/build_tools/menuselect-deps.in 2008-11-29 15:02:27.000000000 +0100 -@@ -23,6 +23,7 @@ - POPT=@PBX_POPT@ - PRI=@PBX_PRI@ - RADIUS=@PBX_RADIUS@ -+SPANDSP=@PBX_SPANDSP@ - SPEEX=@PBX_SPEEX@ - SPEEXDSP=@PBX_SPEEXDSP@ - SPEEX_PREPROCESS=@PBX_SPEEX_PREPROCESS@ -diff -Nru asterisk-1.4.22.org/configure.ac asterisk-1.4.22/configure.ac ---- asterisk-1.4.22.org/configure.ac 2008-09-08 18:26:00.000000000 +0200 -+++ asterisk-1.4.22/configure.ac 2008-11-29 15:02:27.000000000 +0100 -@@ -201,6 +201,7 @@ - AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib]) - AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323]) - AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius]) -+AST_EXT_LIB_SETUP([SPANDSP], [spandsp Library], [spandsp]) - AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex]) - AST_EXT_LIB_SETUP([SPEEXDSP], [Speexdsp], [speexdsp]) - AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite]) -@@ -1302,6 +1303,8 @@ - - AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) - -+AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [fax_init], [spandsp.h], [-ltiff -ljpeg -lz]) -+ - AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm]) - - # See if the main speex library contains the preprocess functions -diff -Nru asterisk-1.4.22.org/include/asterisk/plc.h asterisk-1.4.22/include/asterisk/plc.h ---- asterisk-1.4.22.org/include/asterisk/plc.h 2006-06-14 16:12:56.000000000 +0200 -+++ asterisk-1.4.22/include/asterisk/plc.h 2008-11-29 15:02:27.000000000 +0100 -@@ -1,18 +1,17 @@ --/*! \file -- * \brief SpanDSP - a series of DSP components for telephony -+/* -+ * SpanDSP - a series of DSP components for telephony - * - * plc.h - * -- * \author Steve Underwood <steveu@coppice.org> -+ * Written by Steve Underwood <steveu@coppice.org> - * - * Copyright (C) 2004 Steve Underwood - * - * All rights reserved. - * - * 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. -+ * it under the terms of the GNU General Public License version 2, as -+ * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of -@@ -23,37 +22,36 @@ - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * -- * This version may be optionally licenced under the GNU LGPL licence. -- * -- * A license has been granted to Digium (via disclaimer) for the use of -- * this code. -+ * $Id: plc.h,v 1.15 2007/04/08 08:16:18 steveu Exp $ - */ - -+/*! \file */ - --#if !defined(_PLC_H_) --#define _PLC_H_ -- --#ifdef SOLARIS --#include <sys/int_types.h> --#else --#if defined(__OpenBSD__) || defined( __FreeBSD__) --#include <inttypes.h> --#else --#include <stdint.h> --#endif --#endif -+#if !defined(_SPANDSP_PLC_H_) -+#define _SPANDSP_PLC_H_ - - /*! \page plc_page Packet loss concealment - \section plc_page_sec_1 What does it do? --The packet loss concealment module provides a suitable synthetic fill-in signal, --to minimise the audible effect of lost packets in VoIP applications. It is not --tied to any particular codec, and could be used with almost any codec which does not -+The packet loss concealment module provides a synthetic fill-in signal, to minimise -+the audible effect of lost packets in VoIP applications. It is not tied to any -+particular codec, and could be used with almost any codec which does not - specify its own procedure for packet loss concealment. - --Where a codec specific concealment procedure exists, the algorithm is usually built -+Where a codec specific concealment procedure exists, that algorithm is usually built - around knowledge of the characteristics of the particular codec. It will, therefore, - generally give better results for that particular codec than this generic concealer will. - -+The PLC code implements an algorithm similar to the one described in Appendix 1 of G.711. -+However, the G.711 algorithm is optimised for 10ms packets. Few people use such small -+packets. 20ms is a much more common value, and longer packets are also quite common. The -+algorithm has been adjusted with this in mind. Also, the G.711 approach causes an -+algorithmic delay, and requires significant buffer manipulation when there is no packet -+loss. The algorithm used here avoids this. It causes no delay, and achieves comparable -+quality with normal speech. -+ -+Note that both this algorithm, and the one in G.711 are optimised for speech. For most kinds -+of music a much slower decay on bursts of lost packets give better results. -+ - \section plc_page_sec_2 How does it work? - While good packets are being received, the plc_rx() routine keeps a record of the trailing - section of the known speech signal. If a packet is missed, plc_fillin() is called to produce -@@ -83,7 +81,7 @@ - correct steadily fall. Therefore, the volume of the synthesized signal is made to decay - linearly, such that after 50ms of missing audio it is reduced to silence. - --- When real speech resumes, an extra 1/4 pitch period of sythetic speech is blended with the -+- When real speech resumes, an extra 1/4 pitch period of synthetic speech is blended with the - start of the real speech. If the erasure is small, this smoothes the transition. If the erasure - is long, and the synthetic signal has faded to zero, the blending softens the start up of the - real signal, avoiding a kind of "click" or "pop" effect that might occur with a sudden onset. -@@ -110,6 +108,9 @@ - the pitch assessment. */ - #define PLC_HISTORY_LEN (CORRELATION_SPAN + PLC_PITCH_MIN) - -+/*! -+ The generic packet loss concealer context. -+*/ - typedef struct - { - /*! Consecutive erased samples */ -@@ -127,12 +128,13 @@ - } plc_state_t; - - --#ifdef __cplusplus --extern "C" { -+#if defined(__cplusplus) -+extern "C" -+{ - #endif - --/*! Process a block of received audio samples. -- \brief Process a block of received audio samples. -+/*! Process a block of received audio samples for PLC. -+ \brief Process a block of received audio samples for PLC. - \param s The packet loss concealer context. - \param amp The audio sample buffer. - \param len The number of samples in the buffer. -@@ -147,13 +149,18 @@ - \return The number of samples synthesized. */ - int plc_fillin(plc_state_t *s, int16_t amp[], int len); - --/*! Process a block of received V.29 modem audio samples. -- \brief Process a block of received V.29 modem audio samples. -+/*! Initialise a packet loss concealer context. -+ \brief Initialise a PLC context. - \param s The packet loss concealer context. -- \return A pointer to the he packet loss concealer context. */ -+ \return A pointer to the the packet loss concealer context. */ - plc_state_t *plc_init(plc_state_t *s); - --#ifdef __cplusplus -+/*! Free a packet loss concealer context. -+ \param s The packet loss concealer context. -+ \return 0 for OK. */ -+int plc_release(plc_state_t *s); -+ -+#if defined(__cplusplus) - } - #endif - -diff -Nru asterisk-1.4.22.org/makeopts.in asterisk-1.4.22/makeopts.in ---- asterisk-1.4.22.org/makeopts.in 2008-06-12 21:08:20.000000000 +0200 -+++ asterisk-1.4.22/makeopts.in 2008-11-29 15:02:27.000000000 +0100 -@@ -138,6 +138,9 @@ - RADIUS_INCLUDE=@RADIUS_INCLUDE@ - RADIUS_LIB=@RADIUS_LIB@ - -+SPANDSP_INCLUDE=@SPANDSP_INCLUDE@ -+SPANDSP_LIB=@SPANDSP_LIB@ -+ - SPEEX_INCLUDE=@SPEEX_INCLUDE@ - SPEEX_LIB=@SPEEX_LIB@ - diff --git a/contrib/package/asterisk-xip/patches/016-iksemel-configure_ac.patch b/contrib/package/asterisk-xip/patches/016-iksemel-configure_ac.patch deleted file mode 100644 index 0b0b7d5e8b..0000000000 --- a/contrib/package/asterisk-xip/patches/016-iksemel-configure_ac.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nru asterisk-1.4.22.org/configure.ac asterisk-1.4.22/configure.ac ---- asterisk-1.4.22.org/configure.ac 2008-09-08 18:26:00.000000000 +0200 -+++ asterisk-1.4.22/configure.ac 2008-11-29 15:04:09.000000000 +0100 -@@ -514,7 +514,7 @@ - fi - fi - --AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h]) -+AST_EXT_LIB_CHECK([IKSEMEL], [iksemel], [iks_start_sasl], [iksemel.h], [-lgnutls -lgcrypt -lgpg-error]) - - if test "${PBX_IKSEMEL}" = 1; then - AST_EXT_LIB_CHECK([GNUTLS], [gnutls], [gnutls_bye], [gnutls/gnutls.h], [-lz -lgcrypt -lgpg-error]) diff --git a/contrib/package/asterisk-xip/patches/017-Makefile-no_march.patch b/contrib/package/asterisk-xip/patches/017-Makefile-no_march.patch deleted file mode 100644 index 98ec1100bc..0000000000 --- a/contrib/package/asterisk-xip/patches/017-Makefile-no_march.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nru asterisk-1.4.22.org/Makefile asterisk-1.4.22/Makefile ---- asterisk-1.4.22.org/Makefile 2008-09-08 22:15:42.000000000 +0200 -+++ asterisk-1.4.22/Makefile 2008-11-29 15:05:12.000000000 +0100 -@@ -215,7 +215,7 @@ - endif - - ifneq ($(PROC),ultrasparc) -- ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) -+ #ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) - endif - - ifeq ($(PROC),ppc) diff --git a/contrib/package/asterisk-xip/patches/023-autoconf-chan_h323.patch b/contrib/package/asterisk-xip/patches/023-autoconf-chan_h323.patch deleted file mode 100644 index 629bb382a7..0000000000 --- a/contrib/package/asterisk-xip/patches/023-autoconf-chan_h323.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff -Nru asterisk-1.4.22.org/acinclude.m4 asterisk-1.4.22/acinclude.m4 ---- asterisk-1.4.22.org/acinclude.m4 2008-07-22 22:49:41.000000000 +0200 -+++ asterisk-1.4.22/acinclude.m4 2008-11-29 15:06:28.000000000 +0100 -@@ -588,6 +588,7 @@ - ;; - esac - AC_MSG_RESULT(${OPENH323_BUILD}) -+ OPENH323_SUFFIX="n_s" - - AC_SUBST([OPENH323_SUFFIX]) - AC_SUBST([OPENH323_BUILD]) -diff -Nru asterisk-1.4.22.org/configure.ac asterisk-1.4.22/configure.ac ---- asterisk-1.4.22.org/configure.ac 2008-09-08 18:26:00.000000000 +0200 -+++ asterisk-1.4.22/configure.ac 2008-11-29 15:06:28.000000000 +0100 -@@ -1259,7 +1259,7 @@ - if test "${HAS_PWLIB:-unset}" != "unset"; then - AST_CHECK_OPENH323_PLATFORM() - -- PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r" -+ PLATFORM_PWLIB="pt_${PWLIB_PLATFORM}_r_s" - - AST_CHECK_PWLIB_BUILD([PWLib], [PWLIB], - [Define if your system has the PWLib libraries.], diff --git a/contrib/package/asterisk-xip/patches/026-gsm-mips.patch b/contrib/package/asterisk-xip/patches/026-gsm-mips.patch deleted file mode 100644 index e69de29bb2..0000000000 --- a/contrib/package/asterisk-xip/patches/026-gsm-mips.patch +++ /dev/null diff --git a/contrib/package/asterisk-xip/patches/030-acinclude.patch b/contrib/package/asterisk-xip/patches/030-acinclude.patch deleted file mode 100644 index 7ca79b64ef..0000000000 --- a/contrib/package/asterisk-xip/patches/030-acinclude.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff -Nru asterisk-1.4.22.org/acinclude.m4 asterisk-1.4.22/acinclude.m4 ---- asterisk-1.4.22.org/acinclude.m4 2008-07-22 22:49:41.000000000 +0200 -+++ asterisk-1.4.22/acinclude.m4 2008-11-29 15:08:07.000000000 +0100 -@@ -664,7 +664,7 @@ - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no]) --AC_REQUIRE([AST_PROG_SED])dnl -+AC_REQUIRE([AC_PROG_SED])dnl - AC_REQUIRE([AC_PROG_CC])dnl - AC_REQUIRE([AC_CANONICAL_HOST])dnl - AC_REQUIRE([AC_CANONICAL_BUILD])dnl -@@ -769,28 +769,6 @@ - AC_SUBST([EGREP]) - ])]) # AST_PROG_EGREP - --# AST_PROG_SED --# ----------- --# Check for a fully functional sed program that truncates --# as few characters as possible. Prefer GNU sed if found. --AC_DEFUN([AST_PROG_SED], --[AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED, -- [dnl ac_script should not contain more than 99 commands (for HP-UX sed), -- dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed. -- ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ -- for ac_i in 1 2 3 4 5 6 7; do -- ac_script="$ac_script$as_nl$ac_script" -- done -- echo "$ac_script" | sed 99q >conftest.sed -- $as_unset ac_script || ac_script= -- _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed], -- [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED], -- ["$ac_path_SED" -f conftest.sed])])]) -- SED="$ac_cv_path_SED" -- AC_SUBST([SED])dnl -- rm -f conftest.sed --])# AST_PROG_SED -- - dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) - dnl - dnl @summary figure out how to build C programs using POSIX threads diff --git a/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch b/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch deleted file mode 100644 index 262bed4a74..0000000000 --- a/contrib/package/asterisk-xip/patches/035-main-asterisk-uclibc-daemon.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff -Nru asterisk-1.4.22.org/main/asterisk.c asterisk-1.4.22/main/asterisk.c ---- asterisk-1.4.22.org/main/asterisk.c 2008-07-26 17:31:21.000000000 +0200 -+++ asterisk-1.4.22/main/asterisk.c 2008-12-20 22:49:58.000000000 +0100 -@@ -2935,7 +2935,38 @@ - #if HAVE_WORKING_FORK - if (ast_opt_always_fork || !ast_opt_no_fork) { - #ifndef HAVE_SBIN_LAUNCHD -+#ifndef __UCLIBC__ - daemon(1, 0); -+#else -+/* -+ workaround for uClibc-0.9.29 mipsel bug: -+ recursive mutexes do not work if uClibc daemon() function has been called, -+ if parent thread locks a mutex -+ the child thread cannot acquire a lock with the same name -+ (same code works if daemon() is not called) -+ but duplication of uClibc daemon.c code in here does work. -+*/ -+ int fd; -+ switch (fork()) { -+ case -1: -+ exit(1); -+ case 0: -+ break; -+ default: -+ _exit(0); -+ } -+ if (setsid() == -1) -+ exit(1); -+ if (fork()) -+ _exit(0); -+ if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { -+ dup2(fd, STDIN_FILENO); -+ dup2(fd, STDOUT_FILENO); -+ dup2(fd, STDERR_FILENO); -+ if (fd > 2) -+ close(fd); -+ } -+#endif - ast_mainpid = getpid(); - /* Blindly re-write pid file since we are forking */ - unlink(ast_config_AST_PID); diff --git a/contrib/package/asterisk-xip/patches/040-pickup2.patch b/contrib/package/asterisk-xip/patches/040-pickup2.patch deleted file mode 100644 index cc665ec372..0000000000 --- a/contrib/package/asterisk-xip/patches/040-pickup2.patch +++ /dev/null @@ -1,284 +0,0 @@ -*** xx/apps/app_pickup2.c 1970-01-01 08:00:00.000000000 +0800 ---- asterisk-1.4.22/apps/app_pickup2.c 2009-01-19 17:44:07.483909506 +0900 -*************** -*** 0 **** ---- 1,279 ---- -+ /* -+ * Asterisk -- A telephony toolkit for Linux. -+ * -+ * Pickup, channel independent call pickup -+ * -+ * Copyright (C) 2005-2007, Thorsten Knabe <ast@thorsten-knabe.de> -+ * -+ * Copyright (C) 2004, Junghanns.NET GmbH -+ * -+ * Klaus-Peter Junghanns <kpj@junghanns.net> -+ * -+ * Copyright (C) 2004, Florian Overkamp <florian@obsimref.com> -+ * -+ * This program is free software, distributed under the terms of -+ * the GNU General Public License -+ */ -+ -+ /*** MODULEINFO -+ <defaultenabled>yes</defaultenabled> -+ ***/ -+ -+ #include "asterisk.h" -+ -+ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 2 $") -+ -+ #include <stdlib.h> -+ #include <unistd.h> -+ #include <string.h> -+ #include <stdio.h> -+ #include <signal.h> -+ #include <pthread.h> -+ #include "asterisk/lock.h" -+ #include "asterisk/file.h" -+ #include "asterisk/logger.h" -+ #include "asterisk/channel.h" -+ #include "asterisk/pbx.h" -+ #include "asterisk/module.h" -+ #include "asterisk/musiconhold.h" -+ #include "asterisk/features.h" -+ #include "asterisk/options.h" -+ -+ static char *app = "PickUp2"; -+ static char *synopsis = "PickUp ringing channel."; -+ static char *descrip = -+ " PickUp2(Technology/resource[&Technology2/resource2&...][|<option>]):\n" -+ "Matches the list of prefixes in the parameter list against channels in\n" -+ "state RINGING. If a match is found the channel is picked up and\n" -+ "PICKUP_CHANNEL is set to the picked up channel name. If no matching\n" -+ "channel is found PICKUP_CHANNEL is empty.\n" -+ "Possible options:\n" -+ "B: match on channel name of bridged channel.\n"; -+ -+ static char *app2 = "PickDown2"; -+ static char *synopsis2 = "Hangup ringing channel."; -+ static char *descrip2 = -+ " PickDown2(Technology/resource[&Technology2/resource2&...][|<option>]):\n" -+ "Matches the list of prefixes in the parameter list against channels in\n" -+ "state RINGING. If a match is found the channel is hung up and\n" -+ "PICKDOWN_CHANNEL is set to the hung up channel name. If no matching\n" -+ "channel is found PICKDOWN_CHANNEL is empty.\n" -+ "Possible options:\n" -+ "B: match on channel name of bridged channel.\n"; -+ -+ static char *app3 = "Steal2"; -+ static char *synopsis3 = "Steal a connected channel."; -+ -+ static char *descrip3 = -+ " Steal2(Technology/resource[&Technology2/resource2&...][|<option>]):\n" -+ "Matches the list of prefixes in the parameter list against channels in\n" -+ "state UP. If a match is found the channel is stolen and\n" -+ "STEAL_CHANNEL is set to the stolen channel name. If no matching\n" -+ "channel is found STEAL_CHANNEL is empty.\n" -+ "Possible options:\n" -+ "B: match on channel name of bridged channel.\n"; -+ -+ /* Find channel matching given pattern and state, skipping our own channel. -+ * Returns locked channel, which has to be unlocked using ast_mutex_unlock(). -+ * Returns NULL when no matching channel is found. -+ */ -+ static struct ast_channel *find_matching_channel(struct ast_channel *chan, -+ void *pattern, int chanstate) -+ { -+ struct ast_channel *cur; -+ char *pat = ""; -+ char *next_pat = NULL; -+ char *option = ""; -+ struct ast_channel *bridged; -+ -+ /* copy original pattern or use empty pattern if no pattern has been given*/ -+ if (pattern) { -+ pat = alloca(strlen(pattern) + 1); -+ strcpy(pat, pattern); -+ } -+ for (option = pat; *option; option++) { -+ if (*option == '|') { -+ *option = '\0'; -+ option++; -+ break; -+ } -+ } -+ ast_verbose(VERBOSE_PREFIX_4 -+ "find_matching_channel: pattern='%s' option='%s' state=%d\n", -+ (char *)pat, option, chanstate); -+ -+ /* match on bridged channel name */ -+ if (!strcmp("B", option)) { -+ /* Iterate over each part of the pattern */ -+ while (pat) { -+ /* find pattern for next iteration, -+ * terminate current pattern */ -+ for (next_pat = pat; -+ *next_pat && *next_pat != '&'; next_pat++); -+ if (*next_pat == '&') { -+ *next_pat = 0; -+ next_pat++; -+ } else -+ next_pat = NULL; -+ /* Iterate over all channels */ -+ cur = ast_channel_walk_locked(NULL); -+ while (cur) { -+ bridged = ast_bridged_channel(cur); -+ if (bridged) { -+ ast_verbose(VERBOSE_PREFIX_4 -+ "find_matching_channel: trying channel='%s' bridged='%s' " -+ "state=%d pattern='%s'\n", -+ cur->name, bridged->name, cur->_state, pat); -+ if ((cur != chan) && (bridged != chan) && -+ (cur->_state == chanstate) && -+ !strncmp(pat, bridged->name, strlen(pat))) { -+ ast_verbose(VERBOSE_PREFIX_4 -+ "find_matching_channel: " -+ "found channel='%s' bridged='%s'\n", -+ cur->name, bridged->name); -+ return(cur); -+ } -+ } -+ ast_mutex_unlock(&cur->lock); -+ cur = ast_channel_walk_locked(cur); -+ } -+ pat = next_pat; -+ } -+ } else { -+ /* Iterate over each part of the pattern */ -+ while (pat) { -+ /* find pattern for next iteration, -+ * terminate current pattern */ -+ for (next_pat = pat; -+ *next_pat && *next_pat != '&'; next_pat++); -+ if (*next_pat == '&') { -+ *next_pat = 0; -+ next_pat++; -+ } else -+ next_pat = NULL; -+ /* Iterate over all channels */ -+ cur = ast_channel_walk_locked(NULL); -+ while (cur) { -+ ast_verbose(VERBOSE_PREFIX_4 -+ "find_matching_channel: trying channel='%s' " -+ "state=%d pattern='%s'\n", -+ cur->name, cur->_state, pat); -+ if ((cur != chan) && -+ (cur->_state == chanstate) && -+ !strncmp(pat, cur->name, strlen(pat))) { -+ ast_verbose(VERBOSE_PREFIX_4 -+ "find_matching_channel: " -+ "found channel='%s'\n", -+ cur->name); -+ return(cur); -+ } -+ ast_mutex_unlock(&cur->lock); -+ cur = ast_channel_walk_locked(cur); -+ } -+ pat = next_pat; -+ } -+ } -+ return(NULL); -+ } -+ -+ static int pickup_channel(struct ast_channel *chan, void *pattern) -+ { -+ int ret = 0; -+ struct ast_module_user *u; -+ struct ast_channel *cur; -+ u = ast_module_user_add(chan); -+ cur = find_matching_channel(chan, pattern, AST_STATE_RINGING); -+ if (cur) { -+ ast_verbose(VERBOSE_PREFIX_3 -+ "Channel %s picked up ringing channel %s\n", -+ chan->name, cur->name); -+ pbx_builtin_setvar_helper(chan, "PICKUP_CHANNEL", cur->name); -+ if (chan->_state != AST_STATE_UP) { -+ ast_answer(chan); -+ } -+ if (ast_channel_masquerade(cur, chan)) { -+ ast_log(LOG_ERROR, "unable to masquerade\n"); -+ ret = -1; -+ } -+ ast_mutex_unlock(&cur->lock); -+ ast_mutex_unlock(&chan->lock); -+ } else { -+ pbx_builtin_setvar_helper(chan, "PICKUP_CHANNEL", ""); -+ } -+ ast_module_user_remove(u); -+ return(ret); -+ } -+ -+ static int pickdown_channel(struct ast_channel *chan, void *pattern) -+ { -+ int ret = 0; -+ struct ast_module_user *u; -+ struct ast_channel *cur; -+ u = ast_module_user_add(chan); -+ cur = find_matching_channel(chan, pattern, AST_STATE_RINGING); -+ if (cur) { -+ ast_verbose(VERBOSE_PREFIX_3 -+ "Channel %s hung up ringing channel %s\n", -+ chan->name, cur->name); -+ pbx_builtin_setvar_helper(chan, "PICKDOWN_CHANNEL", cur->name); -+ ast_softhangup_nolock(cur, AST_SOFTHANGUP_DEV); -+ ast_mutex_unlock(&cur->lock); -+ } else { -+ pbx_builtin_setvar_helper(chan, "PICKDOWN_CHANNEL", ""); -+ } -+ ast_module_user_remove(u); -+ return(ret); -+ } -+ -+ static int steal_channel(struct ast_channel *chan, void *pattern) -+ { -+ int ret = 0; -+ struct ast_module_user *u; -+ struct ast_channel *cur; -+ u = ast_module_user_add(chan); -+ cur = find_matching_channel(chan, pattern, AST_STATE_UP); -+ if (cur) { -+ ast_verbose(VERBOSE_PREFIX_3 -+ "Channel %s stole channel %s\n", -+ chan->name, cur->name); -+ pbx_builtin_setvar_helper(chan, "STEAL_CHANNEL", cur->name); -+ if (chan->_state != AST_STATE_UP) { -+ ast_answer(chan); -+ } -+ if (cur->_bridge) { -+ if (!ast_mutex_lock(&cur->_bridge->lock)) { -+ ast_moh_stop(cur->_bridge); -+ ast_mutex_unlock(&cur->_bridge->lock); -+ } -+ } -+ -+ if (ast_channel_masquerade(cur, chan)) { -+ ast_log(LOG_ERROR, "unable to masquerade\n"); -+ ret = -1; -+ } -+ ast_mutex_unlock(&cur->lock); -+ ast_mutex_unlock(&chan->lock); -+ } else { -+ pbx_builtin_setvar_helper(chan, "STEAL_CHANNEL", ""); -+ } -+ ast_module_user_remove(u); -+ return(ret); -+ } -+ -+ static int unload_module(void) -+ { -+ ast_module_user_hangup_all(); -+ ast_unregister_application(app3); -+ ast_unregister_application(app2); -+ return ast_unregister_application(app); -+ } -+ -+ static int load_module(void) -+ { -+ ast_register_application(app3, steal_channel, synopsis3, descrip3); -+ ast_register_application(app2, pickdown_channel, synopsis2, descrip2); -+ return ast_register_application(app, pickup_channel, synopsis, descrip); -+ } -+ -+ AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, -+ "PickUp2, PickDown2, Steal2 Application"); |