[svn-commits] branch crichter/frame-data - r7992 in
/team/crichter/frame-data: ./ cdr/ chan...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Wed Jan 11 17:22:37 CST 2006
Author: crichter
Date: Wed Jan 11 17:22:22 2006
New Revision: 7992
URL: http://svn.digium.com/view/asterisk?rev=7992&view=rev
Log:
Merged revisions 7980-7982 via svnmerge from
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0
........
r7980 | crichter | 2006-01-11 11:27:48 +0100 (Mi, 11 Jan 2006) | 1 line
log underruns with higher debuglevel
........
r7981 | crichter | 2006-01-11 13:11:51 +0100 (Mi, 11 Jan 2006) | 1 line
merged -r 7670:7980 manually
........
r7982 | crichter | 2006-01-11 14:53:41 +0100 (Mi, 11 Jan 2006) | 1 line
fixed bug 179 from bugs.beronet.com (can't set empty options in misdn.conf)
........
Added:
team/crichter/frame-data/formats/format_h264.c
- copied unchanged from r7982, team/crichter/0.3.0/formats/format_h264.c
Modified:
team/crichter/frame-data/ (props changed)
team/crichter/frame-data/aescrypt.c
team/crichter/frame-data/aeskey.c
team/crichter/frame-data/callerid.c
team/crichter/frame-data/cdr/ (props changed)
team/crichter/frame-data/cdr/cdr_csv.c
team/crichter/frame-data/cdr/cdr_custom.c
team/crichter/frame-data/channels/chan_misdn_config.c
team/crichter/frame-data/codecs/ (props changed)
team/crichter/frame-data/codecs/ilbc/ (props changed)
team/crichter/frame-data/codecs/lpc10/ (props changed)
team/crichter/frame-data/cryptostub.c
team/crichter/frame-data/file.c
team/crichter/frame-data/formats/ (props changed)
team/crichter/frame-data/formats/Makefile
team/crichter/frame-data/formats/format_pcm.c
team/crichter/frame-data/formats/format_pcm_alaw.c
team/crichter/frame-data/privacy.c
team/crichter/frame-data/res/ (props changed)
team/crichter/frame-data/res/res_agi.c
team/crichter/frame-data/res/res_crypto.c
team/crichter/frame-data/res/res_musiconhold.c
team/crichter/frame-data/res/res_osp.c
team/crichter/frame-data/srv.c
Propchange: team/crichter/frame-data/
------------------------------------------------------------------------------
--- svnmerge-blocked (original)
+++ svnmerge-blocked Wed Jan 11 17:22:22 2006
@@ -1,1 +1,1 @@
-/branches/1.2:7497
+/branches/1.2:7497,7915,7960,7965,7970,7976
Propchange: team/crichter/frame-data/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jan 11 17:22:22 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-7942
+/team/crichter/0.3.0:1-7991
Modified: team/crichter/frame-data/aescrypt.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/aescrypt.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/aescrypt.c (original)
+++ team/crichter/frame-data/aescrypt.c Wed Jan 11 17:22:22 2006
@@ -31,12 +31,16 @@
Issue Date: 26/08/2003
*/
+
/*! \file
-\brief This file contains the code for implementing encryption and decryption
- for AES (Rijndael) for block and key sizes of 16, 24 and 32 bytes. It
- can optionally be replaced by code written in assembler using NASM. For
- further details see the file aesopt.h
-*/
+ *
+ * \brief This file contains the code for implementing encryption and decryption
+ * for AES (Rijndael) for block and key sizes of 16, 24 and 32 bytes. It
+ * can optionally be replaced by code written in assembler using NASM. For
+ * further details see the file aesopt.h
+ *
+ * \author Dr Brian Gladman <brg at gladman.me.uk>
+ */
#include "aesopt.h"
Modified: team/crichter/frame-data/aeskey.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/aeskey.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/aeskey.c (original)
+++ team/crichter/frame-data/aeskey.c Wed Jan 11 17:22:22 2006
@@ -31,11 +31,15 @@
Issue Date: 26/08/2003
*/
+
/*! \file
-\brief This file contains the code for implementing the key schedule for AES
- (Rijndael) for block and key sizes of 16, 24, and 32 bytes. See aesopt.h
- for further details including optimisation.
-*/
+ *
+ * \brief This file contains the code for implementing the key schedule for AES
+ * (Rijndael) for block and key sizes of 16, 24, and 32 bytes. See aesopt.h
+ * for further details including optimisation.
+ *
+ * \author Dr Brian Gladman <brg at gladman.me.uk>
+ */
#include "aesopt.h"
Modified: team/crichter/frame-data/callerid.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/callerid.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/callerid.c (original)
+++ team/crichter/frame-data/callerid.c Wed Jan 11 17:22:22 2006
@@ -19,7 +19,8 @@
/*! \file
*
* \brief CallerID Generation support
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
*/
#include <time.h>
@@ -56,6 +57,9 @@
int flags;
int sawflag;
int len;
+
+ int skipflag;
+ unsigned short crc;
};
@@ -250,6 +254,278 @@
gen_tones(outbuf + pos, len, codec, casdr1, casdi1, casdr2, casdi2, &cr1, &ci1, &cr2, &ci2);
return 0;
}
+
+static unsigned short calc_crc(unsigned short crc, unsigned char data)
+{
+ unsigned int i, j, org, dst;
+ org = data;
+ dst = 0;
+ for (i=0; i<CHAR_BIT; i++) {
+ org <<= 1;
+ dst >>= 1;
+ if (org & 0x100) {
+ dst |= 0x80;
+ }
+ }
+ data = (unsigned char)dst;
+ crc ^= (unsigned int)data << (16 - CHAR_BIT);
+ for ( j=0; j<CHAR_BIT; j++ ) {
+ if ( crc & 0x8000U ) crc = (crc << 1) ^ 0x1021U ;
+ else crc <<= 1 ;
+ }
+ return crc;
+}
+
+int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, int codec)
+{
+ int mylen = len;
+ int olen;
+ int b = 'X';
+ int b2 ;
+ int res;
+ int x;
+ short *buf = malloc(2 * len + cid->oldlen);
+ short *obuf = buf;
+
+ if (!buf) {
+ ast_log(LOG_WARNING, "Out of memory\n");
+ return -1;
+ }
+
+ memset(buf, 0, 2 * len + cid->oldlen);
+ memcpy(buf, cid->oldstuff, cid->oldlen);
+ mylen += cid->oldlen/2;
+
+ for (x=0;x<len;x++)
+ buf[x+cid->oldlen/2] = AST_XLAW(ubuf[x]);
+
+ while (mylen >= 160) {
+ b = b2 = 0 ;
+ olen = mylen;
+ res = fsk_serie(&cid->fskd, buf, &mylen, &b);
+
+ if (mylen < 0) {
+ ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d)\n", mylen);
+ return -1;
+ }
+
+ buf += (olen - mylen);
+
+ if (res < 0) {
+ ast_log(LOG_NOTICE, "fsk_serie failed\n");
+ return -1;
+ }
+
+ if (res == 1) {
+
+ b2 = b ;
+ b = b & 0x7f ;
+
+ /* crc checksum calculation */
+ if ( cid->sawflag > 1 ) {
+ cid->crc = calc_crc(cid->crc, (unsigned char)b2);
+ }
+
+ /* Ignore invalid bytes */
+ if (b > 0xff) {
+ continue;
+ }
+
+ /* skip DLE if needed */
+ if ( cid->sawflag > 0 ) {
+ if ( cid->sawflag != 5 && cid->skipflag == 0 && b == 0x10 ) {
+ cid->skipflag = 1 ;
+ continue ;
+ }
+ }
+ if ( cid->skipflag == 1 ) {
+ cid->skipflag = 0 ;
+ }
+
+ /* caller id retrieval */
+ switch(cid->sawflag) {
+ case 0: /* DLE */
+ if (b == 0x10) {
+ cid->sawflag = 1;
+ cid->skipflag = 0;
+ cid->crc = 0;
+ }
+ break;
+ case 1: /* SOH */
+ if (b == 0x01) {
+ cid->sawflag = 2;
+ }
+ break ;
+ case 2: /* HEADER */
+ if (b == 0x07) {
+ cid->sawflag = 3;
+ }
+ break;
+ case 3: /* STX */
+ if (b == 0x02) {
+ cid->sawflag = 4;
+ }
+ break;
+ case 4: /* SERVICE TYPE */
+ if (b == 0x40) {
+ cid->sawflag = 5;
+ }
+ break;
+ case 5: /* Frame Length */
+ cid->sawflag = 6;
+ break;
+ case 6: /* NUMBER TYPE */
+ cid->sawflag = 7;
+ cid->pos = 0;
+ cid->rawdata[cid->pos++] = b;
+ break;
+ case 7: /* NUMBER LENGTH */
+ cid->sawflag = 8;
+ cid->len = b;
+ if ( (cid->len+2) >= sizeof( cid->rawdata ) ) {
+ ast_log(LOG_WARNING, "too long caller id string\n" ) ;
+ return -1;
+ }
+ cid->rawdata[cid->pos++] = b;
+ break;
+ case 8: /* Retrieve message */
+ cid->rawdata[cid->pos++] = b;
+ cid->len--;
+ if (cid->len<=0) {
+ cid->rawdata[cid->pos] = '\0';
+ cid->sawflag = 9;
+ }
+ break;
+ case 9: /* ETX */
+ cid->sawflag = 10;
+ break;
+ case 10: /* CRC Checksum 1 */
+ cid->sawflag = 11;
+ break;
+ case 11: /* CRC Checksum 2 */
+ cid->sawflag = 12;
+ if ( cid->crc != 0 ) {
+ ast_log(LOG_WARNING, "crc checksum error\n" ) ;
+ return -1;
+ }
+ /* extract caller id data */
+ for (x=0; x<cid->pos; ) {
+ switch (cid->rawdata[x++]) {
+ case 0x02: /* caller id number */
+ cid->number[0] = '\0';
+ cid->name[0] = '\0';
+ cid->flags = 0;
+ res = cid->rawdata[x++];
+ ast_copy_string(cid->number, &cid->rawdata[x], res+1 );
+ x += res;
+ break;
+ case 0x21: /* additional information */
+ /* length */
+ x++;
+ /* number type */
+ switch (cid->rawdata[x]) {
+ case 0x00: /* unknown */
+ case 0x01: /* international number */
+ case 0x02: /* domestic number */
+ case 0x03: /* network */
+ case 0x04: /* local call */
+ case 0x06: /* short dial number */
+ case 0x07: /* reserved */
+ default: /* reserved */
+ ast_log(LOG_NOTICE, "cid info:#1=%X\n", cid->rawdata[x]);
+ break ;
+ }
+ x++;
+ /* numbering plan octed 4 */
+ x++;
+ /* numbering plan octed 5 */
+ switch (cid->rawdata[x]) {
+ case 0x00: /* unknown */
+ case 0x01: /* recommendation E.164 ISDN */
+ case 0x03: /* recommendation X.121 */
+ case 0x04: /* telex dial plan */
+ case 0x08: /* domestic dial plan */
+ case 0x09: /* private dial plan */
+ case 0x05: /* reserved */
+ default: /* reserved */
+ ast_log(LOG_NOTICE, "cid info:#2=%X\n", cid->rawdata[x]);
+ break ;
+ }
+ x++;
+ break ;
+ case 0x04: /* no callerid reason */
+ /* length */
+ x++;
+ /* no callerid reason code */
+ switch (cid->rawdata[x]) {
+ case 'P': /* caller id denied by user */
+ case 'O': /* service not available */
+ case 'C': /* pay phone */
+ case 'S': /* service congested */
+ cid->flags |= CID_UNKNOWN_NUMBER;
+ ast_log(LOG_NOTICE, "no cid reason:%c\n",cid->rawdata[x]);
+ break ;
+ }
+ x++;
+ break ;
+ case 0x09: /* dialed number */
+ /* length */
+ res = cid->rawdata[x++];
+ /* dialed number */
+ x += res;
+ break ;
+ case 0x22: /* dialed number additional information */
+ /* length */
+ x++;
+ /* number type */
+ switch (cid->rawdata[x]) {
+ case 0x00: /* unknown */
+ case 0x01: /* international number */
+ case 0x02: /* domestic number */
+ case 0x03: /* network */
+ case 0x04: /* local call */
+ case 0x06: /* short dial number */
+ case 0x07: /* reserved */
+ default: /* reserved */
+ ast_log(LOG_NOTICE, "did info:#1=%X\n", cid->rawdata[x]);
+ break ;
+ }
+ x++;
+ /* numbering plan octed 4 */
+ x++;
+ /* numbering plan octed 5 */
+ switch (cid->rawdata[x]) {
+ case 0x00: /* unknown */
+ case 0x01: /* recommendation E.164 ISDN */
+ case 0x03: /* recommendation X.121 */
+ case 0x04: /* telex dial plan */
+ case 0x08: /* domestic dial plan */
+ case 0x09: /* private dial plan */
+ case 0x05: /* reserved */
+ default: /* reserved */
+ ast_log(LOG_NOTICE, "did info:#2=%X\n", cid->rawdata[x]);
+ break ;
+ }
+ x++;
+ break ;
+ }
+ }
+ return 1;
+ break;
+ default:
+ ast_log(LOG_ERROR, "invalid value in sawflag %d\n", cid->sawflag);
+ }
+ }
+ }
+ if (mylen) {
+ memcpy(cid->oldstuff, buf, mylen * 2);
+ cid->oldlen = mylen * 2;
+ } else
+ cid->oldlen = 0;
+ free(obuf);
+ return 0;
+}
+
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int codec)
{
Propchange: team/crichter/frame-data/cdr/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan 11 17:22:22 2006
@@ -1,1 +1,3 @@
.depend
+*.a
+*.so
Modified: team/crichter/frame-data/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/cdr/cdr_csv.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/cdr/cdr_csv.c (original)
+++ team/crichter/frame-data/cdr/cdr_csv.c Wed Jan 11 17:22:22 2006
@@ -21,6 +21,8 @@
/*! \file
*
* \brief Comma Separated Value CDR records.
+ *
+ * \author Mark Spencer <markster at digium.com>
*
* \arg See also \ref AstCDR
* \ingroup cdr_drivers
Modified: team/crichter/frame-data/cdr/cdr_custom.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/cdr/cdr_custom.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/cdr/cdr_custom.c (original)
+++ team/crichter/frame-data/cdr/cdr_custom.c Wed Jan 11 17:22:22 2006
@@ -21,7 +21,9 @@
/*! \file
*
* \brief Custom Comma Separated Value CDR records.
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
+ *
* \arg See also \ref AstCDR
*
* Logs in LOG_DIR/cdr_custom
Modified: team/crichter/frame-data/channels/chan_misdn_config.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/channels/chan_misdn_config.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/channels/chan_misdn_config.c (original)
+++ team/crichter/frame-data/channels/chan_misdn_config.c Wed Jan 11 17:22:22 2006
@@ -522,8 +522,10 @@
dest->str = (char *)malloc((len + 1) * sizeof(char));
strncpy(dest->str, value, len);
dest->str[len] = 0;
- } else
- re = -1;
+ } else {
+ dest->str = (char *)malloc( sizeof(char));
+ dest->str[0] = 0;
+ }
break;
case MISDN_CTYPE_INT:
if (sscanf(value, "%d", &tmp)) {
Propchange: team/crichter/frame-data/codecs/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan 11 17:22:22 2006
@@ -1,3 +1,3 @@
-g723.1
-g723.1b
.depend
+*.a
+*.so
Propchange: team/crichter/frame-data/codecs/ilbc/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan 11 17:22:22 2006
@@ -1,0 +1,3 @@
+.depend
+*.a
+*.so
Propchange: team/crichter/frame-data/codecs/lpc10/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan 11 17:22:22 2006
@@ -1,0 +1,3 @@
+.depend
+*.a
+*.so
Modified: team/crichter/frame-data/cryptostub.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/cryptostub.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/cryptostub.c (original)
+++ team/crichter/frame-data/cryptostub.c Wed Jan 11 17:22:22 2006
@@ -14,6 +14,13 @@
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Stubs for res_crypto routines
+ *
+ * \author Mark Spencer <markster at digium.com>
*/
#include <unistd.h>
Modified: team/crichter/frame-data/file.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/file.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/file.c (original)
+++ team/crichter/frame-data/file.c Wed Jan 11 17:22:22 2006
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
@@ -19,7 +19,8 @@
/*! \file
*
* \brief Generic File Format Support.
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
*/
#include <sys/types.h>
@@ -49,48 +50,49 @@
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/pbx.h"
+#include "asterisk/linkedlists.h"
struct ast_format {
- /* Name of format */
+ /*! Name of format */
char name[80];
- /* Extensions (separated by | if more than one)
- this format can read. First is assumed for writing (e.g. .mp3) */
+ /*! Extensions (separated by | if more than one)
+ this format can read. First is assumed for writing (e.g. .mp3) */
char exts[80];
- /* Format of frames it uses/provides (one only) */
+ /*! Format of frames it uses/provides (one only) */
int format;
- /* Open an input stream, and start playback */
+ /*! Open an input stream, and start playback */
struct ast_filestream * (*open)(FILE * f);
- /* Open an output stream, of a given file descriptor and comment it appropriately if applicable */
+ /*! Open an output stream, of a given file descriptor and comment it appropriately if applicable */
struct ast_filestream * (*rewrite)(FILE *f, const char *comment);
- /* Write a frame to a channel */
+ /*! Write a frame to a channel */
int (*write)(struct ast_filestream *, struct ast_frame *);
- /* seek num samples into file, whence(think normal seek) */
+ /*! seek num samples into file, whence(think normal seek) */
int (*seek)(struct ast_filestream *, long offset, int whence);
- /* trunc file to current position */
+ /*! trunc file to current position */
int (*trunc)(struct ast_filestream *fs);
- /* tell current position */
+ /*! tell current position */
long (*tell)(struct ast_filestream *fs);
- /* Read the next frame from the filestream (if available) and report when to get next one
+ /*! Read the next frame from the filestream (if available) and report when to get next one
(in samples) */
struct ast_frame * (*read)(struct ast_filestream *, int *whennext);
- /* Close file, and destroy filestream structure */
+ /*! Close file, and destroy filestream structure */
void (*close)(struct ast_filestream *);
- /* Retrieve file comment */
+ /*! Retrieve file comment */
char * (*getcomment)(struct ast_filestream *);
- /* Link */
- struct ast_format *next;
+ /*! Link */
+ AST_LIST_ENTRY(ast_format) list;
};
struct ast_filestream {
- /* Everybody reserves a block of AST_RESERVED_POINTERS pointers for us */
+ /*! Everybody reserves a block of AST_RESERVED_POINTERS pointers for us */
struct ast_format *fmt;
int flags;
mode_t mode;
char *filename;
char *realfilename;
- /* Video file stream */
+ /*! Video file stream */
struct ast_filestream *vfs;
- /* Transparently translate from another format -- just once */
+ /*! Transparently translate from another format -- just once */
struct ast_trans_pvt *trans;
struct ast_tranlator_pvt *tr;
int lastwriteformat;
@@ -98,9 +100,7 @@
struct ast_channel *owner;
};
-AST_MUTEX_DEFINE_STATIC(formatlock);
-
-static struct ast_format *formats = NULL;
+static AST_LIST_HEAD_STATIC(formats, ast_format);
int ast_format_register(const char *name, const char *exts, int format,
struct ast_filestream * (*open)(FILE *f),
@@ -114,23 +114,21 @@
char * (*getcomment)(struct ast_filestream *))
{
struct ast_format *tmp;
- if (ast_mutex_lock(&formatlock)) {
+ if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return -1;
}
- tmp = formats;
- while(tmp) {
+ AST_LIST_TRAVERSE(&formats, tmp, list) {
if (!strcasecmp(name, tmp->name)) {
- ast_mutex_unlock(&formatlock);
+ AST_LIST_UNLOCK(&formats);
ast_log(LOG_WARNING, "Tried to register '%s' format, already registered\n", name);
return -1;
}
- tmp = tmp->next;
}
tmp = malloc(sizeof(struct ast_format));
if (!tmp) {
ast_log(LOG_WARNING, "Out of memory\n");
- ast_mutex_unlock(&formatlock);
+ AST_LIST_UNLOCK(&formats);
return -1;
}
ast_copy_string(tmp->name, name, sizeof(tmp->name));
@@ -145,9 +143,8 @@
tmp->close = close;
tmp->format = format;
tmp->getcomment = getcomment;
- tmp->next = formats;
- formats = tmp;
- ast_mutex_unlock(&formatlock);
+ AST_LIST_INSERT_HEAD(&formats, tmp, list);
+ AST_LIST_UNLOCK(&formats);
if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Registered file format %s, extension(s) %s\n", name, exts);
return 0;
@@ -155,36 +152,35 @@
int ast_format_unregister(const char *name)
{
- struct ast_format *tmp, *tmpl = NULL;
- if (ast_mutex_lock(&formatlock)) {
+ struct ast_format *tmp;
+ int res = -1;
+
+ if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return -1;
}
- tmp = formats;
- while(tmp) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) {
if (!strcasecmp(name, tmp->name)) {
- if (tmpl)
- tmpl->next = tmp->next;
- else
- formats = tmp->next;
+ AST_LIST_REMOVE_CURRENT(&formats, list);
free(tmp);
- ast_mutex_unlock(&formatlock);
- if (option_verbose > 1)
+ res = 0;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_UNLOCK(&formats);
+
+ if (tmp) {
+ if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Unregistered format %s\n", name);
- return 0;
- }
- tmpl = tmp;
- tmp = tmp->next;
- }
- ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name);
- return -1;
+ } else
+ ast_log(LOG_WARNING, "Tried to unregister format %s, already unregistered\n", name);
+
+ return res;
}
int ast_stopstream(struct ast_channel *tmp)
{
/* Stop a running stream if there is one */
- if (tmp->vstream)
- ast_closestream(tmp->vstream);
if (tmp->stream) {
ast_closestream(tmp->stream);
if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat))
@@ -202,8 +198,7 @@
if (fs->fmt->format < AST_FORMAT_MAX_AUDIO) {
/* This is the audio portion. Call the video one... */
if (!fs->vfs && fs->filename) {
- /* XXX Support other video formats XXX */
- const char *type = "h263";
+ const char *type = ast_getformatname(f->subclass & ~0x1);
fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
ast_log(LOG_DEBUG, "Opened video output file\n");
}
@@ -362,15 +357,11 @@
if (action == ACTION_OPEN)
ret = -1;
/* Check for a specific format */
- if (ast_mutex_lock(&formatlock)) {
+ if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
- if (action == ACTION_EXISTS)
- return 0;
- else
- return -1;
- }
- f = formats;
- while(f) {
+ return res;
+ }
+ AST_LIST_TRAVERSE(&formats, f, list) {
if (!fmt || exts_compare(f->exts, fmt)) {
char *stringp=NULL;
exts = ast_strdupa(f->exts);
@@ -451,9 +442,8 @@
} while(ext);
}
- f = f->next;
- }
- ast_mutex_unlock(&formatlock);
+ }
+ AST_LIST_UNLOCK(&formats);
if ((action == ACTION_EXISTS) || (action == ACTION_OPEN))
res = ret ? ret : -1;
return res;
@@ -499,10 +489,14 @@
} else
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
fmts = ast_fileexists(filename2, NULL, NULL);
+ if (fmts > 0)
+ fmts &= AST_FORMAT_AUDIO_MASK;
}
if (fmts < 1) {
ast_copy_string(filename2, filename, sizeof(filename2));
fmts = ast_fileexists(filename2, NULL, NULL);
+ if (fmts > 0)
+ fmts &= AST_FORMAT_AUDIO_MASK;
}
if (fmts < 1) {
ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
@@ -534,30 +528,35 @@
*/
int fd = -1;
int fmts = -1;
+ unsigned int format;
char filename2[256];
char lang2[MAX_LANGUAGE];
- /* XXX H.263 only XXX */
- char *fmt = "h263";
- if (!ast_strlen_zero(preflang)) {
- snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
- fmts = ast_fileexists(filename2, fmt, NULL);
+ const char *fmt;
+ for (format = AST_FORMAT_MAX_AUDIO << 1; format <= AST_FORMAT_MAX_VIDEO; format = format << 1) {
+ if (!(chan->nativeformats & format))
+ continue;
+ fmt = ast_getformatname(format);
+ if (!ast_strlen_zero(preflang)) {
+ snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
+ fmts = ast_fileexists(filename2, fmt, NULL);
+ if (fmts < 1) {
+ ast_copy_string(lang2, preflang, sizeof(lang2));
+ snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename);
+ fmts = ast_fileexists(filename2, fmt, NULL);
+ }
+ }
if (fmts < 1) {
- ast_copy_string(lang2, preflang, sizeof(lang2));
- snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename);
+ ast_copy_string(filename2, filename, sizeof(filename2));
fmts = ast_fileexists(filename2, fmt, NULL);
}
- }
- if (fmts < 1) {
- ast_copy_string(filename2, filename, sizeof(filename2));
- fmts = ast_fileexists(filename2, fmt, NULL);
- }
- if (fmts < 1) {
- return NULL;
- }
- fd = ast_filehelper(filename2, (char *)chan, fmt, ACTION_OPEN);
- if (fd >= 0)
- return chan->vstream;
- ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
+ if (fmts < 1) {
+ continue;
+ }
+ fd = ast_filehelper(filename2, (char *)chan, fmt, ACTION_OPEN);
+ if (fd >= 0)
+ return chan->vstream;
+ ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
+ }
return NULL;
}
@@ -726,6 +725,10 @@
f->realfilename = NULL;
}
f->fmt->close(f);
+ if (f->vfs) {
+ ast_closestream(f->vfs);
+ f->vfs = NULL;
+ }
return 0;
}
@@ -796,12 +799,14 @@
int ast_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)
{
struct ast_filestream *fs;
- struct ast_filestream *vfs;
+ struct ast_filestream *vfs=NULL;
+ char fmt[256];
fs = ast_openstream(chan, filename, preflang);
- vfs = ast_openvstream(chan, filename, preflang);
+ if (fs)
+ vfs = ast_openvstream(chan, filename, preflang);
if (vfs)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
+ ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
if (fs){
if (ast_applystream(chan, fs))
return -1;
@@ -817,7 +822,7 @@
#endif
return 0;
}
- ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname(chan->nativeformats), strerror(errno));
+ ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), chan->nativeformats), strerror(errno));
return -1;
}
@@ -828,12 +833,15 @@
struct ast_filestream *fs = NULL;
char *fn;
- if (ast_mutex_lock(&formatlock)) {
+ if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return NULL;
}
- for (f = formats; f && !fs; f = f->next) {
+ AST_LIST_TRAVERSE(&formats, f, list) {
+ if (fs)
+ break;
+
if (!exts_compare(f->exts, type))
continue;
@@ -860,7 +868,7 @@
free(fn);
}
- ast_mutex_unlock(&formatlock);
+ AST_LIST_UNLOCK(&formats);
if (!fs)
ast_log(LOG_WARNING, "No such format '%s'\n", type);
@@ -878,7 +886,7 @@
char *buf = NULL;
size_t size = 0;
- if (ast_mutex_lock(&formatlock)) {
+ if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return NULL;
}
@@ -893,7 +901,10 @@
myflags |= O_WRONLY | O_CREAT;
- for (f = formats; f && !fs; f = f->next) {
+ AST_LIST_TRAVERSE(&formats, f, list) {
+ if (fs)
+ break;
+
if (!exts_compare(f->exts, type))
continue;
@@ -975,7 +986,7 @@
free(fn);
}
- ast_mutex_unlock(&formatlock);
+ AST_LIST_UNLOCK(&formats);
if (!fs)
ast_log(LOG_WARNING, "No such format '%s'\n", type);
@@ -1251,18 +1262,16 @@
return RESULT_SHOWUSAGE;
ast_cli(fd, FORMAT, "Format", "Name", "Extensions");
- if (ast_mutex_lock(&formatlock)) {
+ if (AST_LIST_LOCK(&formats)) {
ast_log(LOG_WARNING, "Unable to lock format list\n");
return -1;
}
- f = formats;
- while(f) {
+ AST_LIST_TRAVERSE(&formats, f, list) {
ast_cli(fd, FORMAT2, ast_getformatname(f->format), f->name, f->exts);
- f = f->next;
count_fmt++;
- };
- ast_mutex_unlock(&formatlock);
+ }
+ AST_LIST_UNLOCK(&formats);
ast_cli(fd, "%d file formats registered.\n", count_fmt);
return RESULT_SUCCESS;
#undef FORMAT
Propchange: team/crichter/frame-data/formats/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan 11 17:22:22 2006
@@ -1,1 +1,3 @@
.depend
+*.a
+*.so
Modified: team/crichter/frame-data/formats/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/formats/Makefile?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/formats/Makefile (original)
+++ team/crichter/frame-data/formats/Makefile Wed Jan 11 17:22:22 2006
@@ -14,7 +14,7 @@
FORMAT_LIBS=format_gsm.so format_wav.so \
format_wav_gsm.so format_vox.so format_pcm.so format_g729.so \
format_pcm_alaw.so format_h263.so format_g726.so format_ilbc.so \
- format_sln.so format_au.so
+ format_sln.so format_au.so format_h264.so
FORMAT_LIBS+=format_jpeg.so
#
Modified: team/crichter/frame-data/formats/format_pcm.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/formats/format_pcm.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/formats/format_pcm.c (original)
+++ team/crichter/frame-data/formats/format_pcm.c Wed Jan 11 17:22:22 2006
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
@@ -44,6 +44,7 @@
#include "asterisk/sched.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
+#include "asterisk/ulaw.h"
#define BUF_SIZE 160 /* 160 samples */
@@ -66,6 +67,8 @@
static char *name = "pcm";
static char *desc = "Raw uLaw 8khz Audio support (PCM)";
static char *exts = "pcm|ulaw|ul|mu";
+
+static char ulaw_silence[BUF_SIZE];
static struct ast_filestream *pcm_open(FILE *f)
{
@@ -173,24 +176,46 @@
static int pcm_seek(struct ast_filestream *fs, long sample_offset, int whence)
{
- off_t offset=0,min,cur,max;
-
- min = 0;
+ long cur, max, offset = 0;
+
cur = ftell(fs->f);
fseek(fs->f, 0, SEEK_END);
max = ftell(fs->f);
- if (whence == SEEK_SET)
+
+ switch (whence) {
+ case SEEK_SET:
offset = sample_offset;
- else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
- offset = sample_offset + cur;
- else if (whence == SEEK_END)
+ break;
+ case SEEK_END:
offset = max - sample_offset;
- if (whence != SEEK_FORCECUR) {
- offset = (offset > max)?max:offset;
- }
- /* always protect against seeking past begining. */
- offset = (offset < min)?min:offset;
- return fseek(fs->f, offset, SEEK_SET);
+ break;
+ case SEEK_CUR:
+ case SEEK_FORCECUR:
+ offset = cur + sample_offset;
+ break;
+ }
+
+ switch (whence) {
+ case SEEK_FORCECUR:
+ if (offset > max) {
+ size_t left = offset - max;
+ size_t res;
+
+ while (left) {
+ res = fwrite(ulaw_silence, sizeof(ulaw_silence[0]),
+ (left > BUF_SIZE) ? BUF_SIZE : left, fs->f);
+ if (res == -1)
+ return res;
+ left -= res * sizeof(ulaw_silence[0]);
+ }
+ return offset;
+ }
+ /* fall through */
+ default:
+ offset = (offset > max) ? max : offset;
+ offset = (offset < 0) ? 0 : offset;
+ return fseek(fs->f, offset, SEEK_SET);
+ }
}
static int pcm_trunc(struct ast_filestream *fs)
@@ -212,18 +237,21 @@
int load_module()
{
+ int index;
+
+ for (index = 0; index < (sizeof(ulaw_silence) / sizeof(ulaw_silence[0])); index++)
+ ulaw_silence[index] = AST_LIN2MU(0);
+
return ast_format_register(name, exts, AST_FORMAT_ULAW,
- pcm_open,
- pcm_rewrite,
- pcm_write,
- pcm_seek,
- pcm_trunc,
- pcm_tell,
- pcm_read,
- pcm_close,
- pcm_getcomment);
-
-
+ pcm_open,
+ pcm_rewrite,
+ pcm_write,
+ pcm_seek,
+ pcm_trunc,
+ pcm_tell,
+ pcm_read,
+ pcm_close,
+ pcm_getcomment);
}
int unload_module()
Modified: team/crichter/frame-data/formats/format_pcm_alaw.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/formats/format_pcm_alaw.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/formats/format_pcm_alaw.c (original)
+++ team/crichter/frame-data/formats/format_pcm_alaw.c Wed Jan 11 17:22:22 2006
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
@@ -45,6 +45,7 @@
#include "asterisk/sched.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
+#include "asterisk/alaw.h"
#define BUF_SIZE 160 /* 160 samples */
@@ -73,6 +74,8 @@
static char *desc = "Raw aLaw 8khz PCM Audio support";
static char *exts = "alaw|al";
+static char alaw_silence[BUF_SIZE];
+
#if 0
/* Returns time in msec since system boot. */
@@ -248,24 +251,46 @@
static int pcm_seek(struct ast_filestream *fs, long sample_offset, int whence)
{
- off_t offset=0,min,cur,max;
-
- min = 0;
+ long cur, max, offset = 0;
+
cur = ftell(fs->f);
fseek(fs->f, 0, SEEK_END);
max = ftell(fs->f);
- if (whence == SEEK_SET)
+
+ switch (whence) {
+ case SEEK_SET:
offset = sample_offset;
- else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
- offset = sample_offset + cur;
- else if (whence == SEEK_END)
+ break;
+ case SEEK_END:
offset = max - sample_offset;
- if (whence != SEEK_FORCECUR) {
- offset = (offset > max)?max:offset;
- }
- /* Always protect against seeking past begining */
- offset = (offset < min)?min:offset;
- return fseek(fs->f, offset, SEEK_SET);
+ break;
+ case SEEK_CUR:
+ case SEEK_FORCECUR:
+ offset = cur + sample_offset;
+ break;
+ }
+
+ switch (whence) {
+ case SEEK_FORCECUR:
+ if (offset > max) {
+ size_t left = offset - max;
+ size_t res;
+
+ while (left) {
+ res = fwrite(alaw_silence, sizeof(alaw_silence[0]),
+ (left > BUF_SIZE) ? BUF_SIZE : left, fs->f);
+ if (res == -1)
+ return res;
+ left -= res * sizeof(alaw_silence[0]);
+ }
+ return offset;
+ }
+ /* fall through */
+ default:
+ offset = (offset > max) ? max : offset;
+ offset = (offset < 0) ? 0 : offset;
+ return fseek(fs->f, offset, SEEK_SET);
+ }
}
static int pcm_trunc(struct ast_filestream *fs)
@@ -288,16 +313,21 @@
int load_module()
{
+ int index;
+
+ for (index = 0; index < (sizeof(alaw_silence) / sizeof(alaw_silence[0])); index++)
+ alaw_silence[index] = AST_LIN2A(0);
+
return ast_format_register(name, exts, AST_FORMAT_ALAW,
- pcm_open,
- pcm_rewrite,
- pcm_write,
- pcm_seek,
- pcm_trunc,
- pcm_tell,
- pcm_read,
- pcm_close,
- pcm_getcomment);
+ pcm_open,
+ pcm_rewrite,
+ pcm_write,
+ pcm_seek,
+ pcm_trunc,
+ pcm_tell,
+ pcm_read,
+ pcm_close,
+ pcm_getcomment);
}
int unload_module()
Modified: team/crichter/frame-data/privacy.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/privacy.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/privacy.c (original)
+++ team/crichter/frame-data/privacy.c Wed Jan 11 17:22:22 2006
@@ -19,7 +19,8 @@
/*! \file
*
* \brief Privacy Routines
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
*/
#include <stdio.h>
Propchange: team/crichter/frame-data/res/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan 11 17:22:22 2006
@@ -1,1 +1,3 @@
.depend
+*.a
+*.so
Modified: team/crichter/frame-data/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/res/res_agi.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/res/res_agi.c (original)
+++ team/crichter/frame-data/res/res_agi.c Wed Jan 11 17:22:22 2006
@@ -19,7 +19,8 @@
/*! \file
*
* \brief AGI - the Asterisk Gateway Interface
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
*/
#include <sys/types.h>
Modified: team/crichter/frame-data/res/res_crypto.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/res/res_crypto.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/res/res_crypto.c (original)
+++ team/crichter/frame-data/res/res_crypto.c Wed Jan 11 17:22:22 2006
@@ -19,7 +19,8 @@
/*! \file
*
* \brief Provide Cryptographic Signature capability
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
*/
#include <sys/types.h>
Modified: team/crichter/frame-data/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/res/res_musiconhold.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/res/res_musiconhold.c (original)
+++ team/crichter/frame-data/res/res_musiconhold.c Wed Jan 11 17:22:22 2006
@@ -22,6 +22,7 @@
*
* \arg See also \ref Config_moh
*
+ * \author Mark Spencer <markster at digium.com>
*/
#include <stdlib.h>
Modified: team/crichter/frame-data/res/res_osp.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/res/res_osp.c?rev=7992&r1=7991&r2=7992&view=diff
==============================================================================
--- team/crichter/frame-data/res/res_osp.c (original)
+++ team/crichter/frame-data/res/res_osp.c Wed Jan 11 17:22:22 2006
@@ -19,7 +19,9 @@
/*! \file
*
* \brief Provide Open Settlement Protocol capability
- *
+ *
+ * \author Mark Spencer <markster at digium.com>
+ *
* \arg See also: \ref chan_sip.c
*/
@@ -514,6 +516,44 @@
return res;
}
+static int check_dest(struct ast_osp_result *result, char *token, int tokensize)
+{
+ OSPE_DEST_OSP_ENABLED enabled;
+ OSPE_DEST_PROT prot;
+ int res = 1;
+
+ /* Check destination OSP version */
+ if (!OSPPTransactionIsDestOSPEnabled(result->handle, &enabled) && (enabled == OSPE_OSP_FALSE)) {
+ result->token[0] = 0;
+ } else {
[... 198 lines stripped ...]
More information about the svn-commits
mailing list