[svn-commits] tilghman: branch tilghman/codec_bits3 r226383 - in /team/tilghman/codec_bits3...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 28 15:08:02 CDT 2009


Author: tilghman
Date: Wed Oct 28 15:07:57 2009
New Revision: 226383

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=226383
Log:
IAX2 changes required to support >32 codecs

Modified:
    team/tilghman/codec_bits3/channels/chan_iax2.c
    team/tilghman/codec_bits3/channels/chan_sip.c
    team/tilghman/codec_bits3/channels/iax2-parser.c
    team/tilghman/codec_bits3/channels/iax2-parser.h
    team/tilghman/codec_bits3/channels/iax2.h
    team/tilghman/codec_bits3/configure
    team/tilghman/codec_bits3/configure.ac
    team/tilghman/codec_bits3/include/asterisk/autoconfig.h.in
    team/tilghman/codec_bits3/include/asterisk/compat.h
    team/tilghman/codec_bits3/include/asterisk/frame.h
    team/tilghman/codec_bits3/include/asterisk/unaligned.h
    team/tilghman/codec_bits3/main/frame.c
    team/tilghman/codec_bits3/main/strcompat.c

Modified: team/tilghman/codec_bits3/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/chan_iax2.c?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/channels/chan_iax2.c (original)
+++ team/tilghman/codec_bits3/channels/chan_iax2.c Wed Oct 28 15:07:57 2009
@@ -4918,6 +4918,7 @@
 		iax_ie_append(&ied, IAX_IE_AUTOANSWER);
 	}
 
+	/* WARNING: this breaks down at 190 bits! */
 	iax_ie_append_str(&ied, IAX_IE_CODEC_PREFS, cai.prefs);
 
 	if (l) {
@@ -4974,8 +4975,10 @@
 	if (pds.password)
 		ast_string_field_set(iaxs[callno], secret, pds.password);
 
-	iax_ie_append_int(&ied, IAX_IE_FORMAT, c->nativeformats);
-	iax_ie_append_int(&ied, IAX_IE_CAPABILITY, iaxs[callno]->capability);
+	iax_ie_append_int(&ied, IAX_IE_FORMAT, (int) c->nativeformats);
+	iax_ie_append_versioned_uint64(&ied, IAX_IE_FORMAT2, 0, c->nativeformats);
+	iax_ie_append_int(&ied, IAX_IE_CAPABILITY, (int) iaxs[callno]->capability);
+	iax_ie_append_versioned_uint64(&ied, IAX_IE_CAPABILITY2, 0, iaxs[callno]->capability);
 	iax_ie_append_short(&ied, IAX_IE_ADSICPE, c->adsicpe);
 	iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(cai.timezone));
 
@@ -7329,7 +7332,7 @@
 		version = ies->version;
 
 	/* Use provided preferences until told otherwise for actual preferences */
-	if(ies->codec_prefs) {
+	if (ies->codec_prefs) {
 		ast_codec_pref_convert(&iaxs[callno]->rprefs, ies->codec_prefs, 32, 0);
 		ast_codec_pref_convert(&iaxs[callno]->prefs, ies->codec_prefs, 32, 0);
 	}

Modified: team/tilghman/codec_bits3/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/chan_sip.c?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/channels/chan_sip.c (original)
+++ team/tilghman/codec_bits3/channels/chan_sip.c Wed Oct 28 15:07:57 2009
@@ -6912,7 +6912,7 @@
 	int what;
 	int video;
 	int text;
-	int needvideo = 0;
+	format_t needvideo = 0;
 	int needtext = 0;
 	char buf[SIPBUFSIZE];
 	char *decoded_exten;

Modified: team/tilghman/codec_bits3/channels/iax2-parser.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/iax2-parser.c?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/channels/iax2-parser.c (original)
+++ team/tilghman/codec_bits3/channels/iax2-parser.c Wed Oct 28 15:07:57 2009
@@ -679,6 +679,15 @@
 	return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
 }
 
+int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
+{
+	struct _local {
+		unsigned char version;
+		uint64_t value;
+	} newval = { version, htonll(value) };
+	return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
+}
+
 int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value) 
 {
 	unsigned int newval;
@@ -769,15 +778,43 @@
 			if (len != (int)sizeof(unsigned int)) {
 				snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
 				errorf(tmp);
-			} else
-				ies->capability = ntohl(get_unaligned_uint32(data + 2));
+			} else if (ies->capability == 0) { /* Don't overwrite capability2, if specified */
+				ies->capability = ntohll(get_unaligned_uint32(data + 2));
+			}
+			break;
+		case IAX_IE_CAPABILITY2:
+			{
+				int version = data[2];
+				if (version == 0) {
+					if (len != (int)sizeof(char) + sizeof(format_t)) {
+						snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int) sizeof(format_t) + sizeof(char), len);
+						errorf(tmp);
+					} else {
+						ies->capability = (format_t) ntohll(get_unaligned_uint64(data + 3));
+					}
+				} /* else unknown version */
+			}
 			break;
 		case IAX_IE_FORMAT:
 			if (len != (int)sizeof(unsigned int)) {
 				snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
 				errorf(tmp);
-			} else
+			} else if (ies->format == 0) { /* Don't overwrite format2, if specified */
 				ies->format = ntohl(get_unaligned_uint32(data + 2));
+			}
+			break;
+		case IAX_IE_FORMAT2:
+			{
+				int version = data[2];
+				if (version == 0) {
+					if (len != (int)sizeof(char) + sizeof(format_t)) {
+						snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int) sizeof(format_t) + sizeof(char), len);
+						errorf(tmp);
+					} else {
+						ies->capability = (format_t) ntohll(get_unaligned_uint64(data + 3));
+					}
+				} /* else unknown version */
+			}
 			break;
 		case IAX_IE_LANGUAGE:
 			ies->language = (char *)data + 2;

Modified: team/tilghman/codec_bits3/channels/iax2-parser.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/iax2-parser.h?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/channels/iax2-parser.h (original)
+++ team/tilghman/codec_bits3/channels/iax2-parser.h Wed Oct 28 15:07:57 2009
@@ -20,6 +20,7 @@
 
 #include "asterisk/linkedlists.h"
 #include "asterisk/aes.h"
+#include "asterisk/frame_defs.h"
 
 struct iax_ies {
 	char *called_number;
@@ -32,8 +33,8 @@
 	char *called_context;
 	char *username;
 	char *password;
-	unsigned int capability;
-	unsigned int format;
+	format_t capability;
+	format_t format;
 	char *codec_prefs;
 	char *language;
 	int version;
@@ -158,6 +159,7 @@
 
 int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
 int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
+int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value);
 int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
 int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
 int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);

Modified: team/tilghman/codec_bits3/channels/iax2.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/iax2.h?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/channels/iax2.h (original)
+++ team/tilghman/codec_bits3/channels/iax2.h Wed Oct 28 15:07:57 2009
@@ -180,6 +180,9 @@
 #define IAX_IE_OSPTOKEN				53		/*!< OSP token */
 #define IAX_IE_CALLTOKEN			54		/*!< Call number security token */
 
+#define IAX_IE_CAPABILITY2          55      /*!< Actual codec capability - u8 version + integer array */
+#define IAX_IE_FORMAT2              56      /*!< Desired codec format - u8 version + integer array */
+
 #define IAX_MAX_OSPBLOCK_SIZE		254		/*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
 #define IAX_MAX_OSPBLOCK_NUM		4
 #define IAX_MAX_OSPTOKEN_SIZE		(IAX_MAX_OSPBLOCK_SIZE * IAX_MAX_OSPBLOCK_NUM)

Modified: team/tilghman/codec_bits3/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/configure.ac?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/configure.ac (original)
+++ team/tilghman/codec_bits3/configure.ac Wed Oct 28 15:07:57 2009
@@ -390,7 +390,7 @@
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
+AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap ntohll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
 
 # NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
 # so that AC_CHECK_FUNCS can detect functions in that library.

Modified: team/tilghman/codec_bits3/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/autoconfig.h.in?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/autoconfig.h.in (original)
+++ team/tilghman/codec_bits3/include/asterisk/autoconfig.h.in Wed Oct 28 15:07:57 2009
@@ -352,6 +352,9 @@
 /* Define to the version of the Hoard Memory Allocator library. */
 #undef HAVE_HOARD_VERSION
 
+/* Define to 1 if you have the `htonll' function. */
+#undef HAVE_HTONLL
+
 /* Define to 1 if you have the ical libraries library. */
 #undef HAVE_ICAL
 
@@ -576,6 +579,9 @@
 /* Define to the version of the newt library. */
 #undef HAVE_NEWT_VERSION
 
+/* Define to 1 if you have the `ntohll' function. */
+#undef HAVE_NTOHLL
+
 /* Define to 1 if your ODBC library has wide (Unicode) types. */
 #undef HAVE_ODBC_WCHAR
 
@@ -1266,6 +1272,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
+/* Define to 1 if the C compiler supports function prototypes. */
+#undef PROTOTYPES
+
 /* Define to necessary symbol if this constant uses a non-standard name on
    your system. */
 #undef PTHREAD_CREATE_JOINABLE
@@ -1281,6 +1290,11 @@
 
 /* Define to the type of arg 5 for `select'. */
 #undef SELECT_TYPE_ARG5
+
+/* Define to 1 if the `setvbuf' function takes the buffering type as its
+   second argument and the buffer pointer as the third, as on System V before
+   release 3. */
+#undef SETVBUF_REVERSED
 
 /* The size of `int', as computed by sizeof. */
 #undef SIZEOF_INT
@@ -1302,46 +1316,50 @@
 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
 #undef TM_IN_SYS_TIME
 
-/* Enable extensions on AIX 3, Interix.  */
+/* Define to 1 if on AIX 3.
+   System headers sometimes define this.
+   We just want to avoid a redefinition error message.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
 /* Enable GNU extensions on systems that have them.  */
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
 #endif
-/* Enable threading extensions on Solaris.  */
+
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#undef _LARGEFILE_SOURCE
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Enable extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
 #ifndef _POSIX_PTHREAD_SEMANTICS
 # undef _POSIX_PTHREAD_SEMANTICS
 #endif
-/* Enable extensions on HP NonStop.  */
 #ifndef _TANDEM_SOURCE
 # undef _TANDEM_SOURCE
 #endif
-/* Enable general extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
-/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
-#undef _LARGEFILE_SOURCE
-
-/* Define for large files, on AIX-style hosts. */
-#undef _LARGE_FILES
-
-/* Define to 1 if on MINIX. */
-#undef _MINIX
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
-   this defined. */
-#undef _POSIX_1_SOURCE
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-#undef _POSIX_SOURCE
+
+/* Define like PROTOTYPES; this can be used by system headers. */
+#undef __PROTOTYPES
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const

Modified: team/tilghman/codec_bits3/include/asterisk/compat.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/compat.h?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/compat.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/compat.h Wed Oct 28 15:07:57 2009
@@ -79,6 +79,14 @@
 
 #ifndef HAVE_GETLOADAVG
 int getloadavg(double *list, int nelem);
+#endif
+
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64);
+#endif
+
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64);
 #endif
 
 #ifndef HAVE_SETENV

Modified: team/tilghman/codec_bits3/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/frame.h?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/frame.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/frame.h Wed Oct 28 15:07:57 2009
@@ -236,61 +236,63 @@
 
 /* Data formats for capabilities and frames alike */
 /*! G.723.1 compression */
-#define AST_FORMAT_G723_1	(1 << 0)
+#define AST_FORMAT_G723_1     (1ULL << 0)
 /*! GSM compression */
-#define AST_FORMAT_GSM		(1 << 1)
+#define AST_FORMAT_GSM        (1ULL << 1)
 /*! Raw mu-law data (G.711) */
-#define AST_FORMAT_ULAW		(1 << 2)
+#define AST_FORMAT_ULAW       (1ULL << 2)
 /*! Raw A-law data (G.711) */
-#define AST_FORMAT_ALAW		(1 << 3)
+#define AST_FORMAT_ALAW       (1ULL << 3)
 /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
-#define AST_FORMAT_G726_AAL2	(1 << 4)
+#define AST_FORMAT_G726_AAL2  (1ULL << 4)
 /*! ADPCM (IMA) */
-#define AST_FORMAT_ADPCM	(1 << 5)
+#define AST_FORMAT_ADPCM      (1ULL << 5)
 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
-#define AST_FORMAT_SLINEAR	(1 << 6)
+#define AST_FORMAT_SLINEAR    (1ULL << 6)
 /*! LPC10, 180 samples/frame */
-#define AST_FORMAT_LPC10	(1 << 7)
+#define AST_FORMAT_LPC10      (1ULL << 7)
 /*! G.729A audio */
-#define AST_FORMAT_G729A	(1 << 8)
+#define AST_FORMAT_G729A      (1ULL << 8)
 /*! SpeeX Free Compression */
-#define AST_FORMAT_SPEEX	(1 << 9)
+#define AST_FORMAT_SPEEX      (1ULL << 9)
 /*! iLBC Free Compression */
-#define AST_FORMAT_ILBC		(1 << 10)
+#define AST_FORMAT_ILBC       (1ULL << 10)
 /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
-#define AST_FORMAT_G726		(1 << 11)
+#define AST_FORMAT_G726       (1ULL << 11)
 /*! G.722 */
-#define AST_FORMAT_G722		(1 << 12)
+#define AST_FORMAT_G722       (1ULL << 12)
 /*! G.722.1 (also known as Siren7, 32kbps assumed) */
-#define AST_FORMAT_SIREN7	(1 << 13)
+#define AST_FORMAT_SIREN7     (1ULL << 13)
 /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
-#define AST_FORMAT_SIREN14	(1 << 14)
+#define AST_FORMAT_SIREN14    (1ULL << 14)
 /*! Raw 16-bit Signed Linear (16000 Hz) PCM */
-#define AST_FORMAT_SLINEAR16	(1 << 15)
+#define AST_FORMAT_SLINEAR16  (1ULL << 15)
 /*! Maximum audio mask */
-#define AST_FORMAT_AUDIO_MASK   0x0000FFFF0000FFFFULL
+#define AST_FORMAT_AUDIO_MASK 0xFFFF0000FFFFULL
 /*! JPEG Images */
-#define AST_FORMAT_JPEG		(1 << 16)
+#define AST_FORMAT_JPEG       (1ULL << 16)
 /*! PNG Images */
-#define AST_FORMAT_PNG		(1 << 17)
+#define AST_FORMAT_PNG        (1ULL << 17)
 /*! H.261 Video */
-#define AST_FORMAT_H261		(1 << 18)
+#define AST_FORMAT_H261       (1ULL << 18)
 /*! H.263 Video */
-#define AST_FORMAT_H263		(1 << 19)
+#define AST_FORMAT_H263       (1ULL << 19)
 /*! H.263+ Video */
-#define AST_FORMAT_H263_PLUS	(1 << 20)
+#define AST_FORMAT_H263_PLUS  (1ULL << 20)
 /*! H.264 Video */
-#define AST_FORMAT_H264		(1 << 21)
+#define AST_FORMAT_H264       (1ULL << 21)
 /*! MPEG4 Video */
-#define AST_FORMAT_MP4_VIDEO	(1 << 22)
-#define AST_FORMAT_VIDEO_MASK   (((1 << 25)-1) & ~(AST_FORMAT_AUDIO_MASK))
+#define AST_FORMAT_MP4_VIDEO  (1ULL << 22)
+#define AST_FORMAT_VIDEO_MASK ((((1ULL << 25)-1) & ~(AST_FORMAT_AUDIO_MASK)) | 0x7FFF000000000000ULL)
 /*! T.140 RED Text format RFC 4103 */
-#define AST_FORMAT_T140RED      (1 << 26)
+#define AST_FORMAT_T140RED    (1ULL << 26)
 /*! T.140 Text format - ITU T.140, RFC 4103 */
-#define AST_FORMAT_T140		(1 << 27)
+#define AST_FORMAT_T140       (1ULL << 27)
 /*! Maximum text mask */
-#define AST_FORMAT_MAX_TEXT	(1 << 28)
-#define AST_FORMAT_TEXT_MASK   (((1 << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
+#define AST_FORMAT_MAX_TEXT   (1ULL << 28)
+#define AST_FORMAT_TEXT_MASK  (((1ULL << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
+/*! Reserved bit - do not use */
+#define AST_FORMAT_RESERVED   (1ULL << 63)
 
 enum ast_control_frame_type {
 	AST_CONTROL_HANGUP = 1,		/*!< Other end has hungup */

Modified: team/tilghman/codec_bits3/include/asterisk/unaligned.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/unaligned.h?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/unaligned.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/unaligned.h Wed Oct 28 15:07:57 2009
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2009, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -29,6 +29,12 @@
 
 #ifdef __GNUC__
 /* If we just tell GCC what's going on, we can trust it to behave optimally */
+static inline uint64_t get_unaligned_uint64(const void *p)
+{
+	const struct { uint64_t d; } __attribute__((packed)) *pp = p;
+	return pp->d;
+}
+
 static inline unsigned int get_unaligned_uint32(const void *p)
 {
 	const struct { unsigned int d; } __attribute__((packed)) *pp = p;
@@ -40,6 +46,13 @@
 	const struct { unsigned short d; } __attribute__((packed)) *pp = p;
 
 	return pp->d;
+}
+
+static inline void put_unaligned_uint64(void *p, uint64_t datum)
+{
+	struct { uint64_t d; } __attribute__((packed)) *pp = p;
+
+	pp->d = datum;
 }
 
 static inline void put_unaligned_uint32(void *p, unsigned int datum)
@@ -56,6 +69,21 @@
 	pp->d = datum;
 }
 #elif defined(SOLARIS) && defined(__sparc__)
+static inline uint64_t get_unaligned_uint64(const void *p)
+{
+	const unsigned char *cp = p;
+
+	return
+		(((uint64_t) cp[0]) << 56) |
+		(((uint64_t) cp[1]) << 48) |
+		(((uint64_t) cp[2]) << 40) |
+		(((uint64_t) cp[3]) << 32) |
+		(((uint64_t) cp[4]) << 24) |
+		(((uint64_t) cp[5]) << 16) |
+		(((uint64_t) cp[6]) <<  8) |
+		(((uint64_t) cp[7]) <<  0);
+}
+
 static inline unsigned int get_unaligned_uint32(const void *p)
 {
 	const unsigned char *cp = p;
@@ -68,6 +96,20 @@
 	const unsigned char *cp = p;
 
 	return (cp[0] << 8) | cp[1] ;
+}
+
+static inline void put_unaligned_uint64(void *p, uint64_t datum)
+{
+	unsigned char *cp = p;
+
+	cp[0] = (datum >> 56) & 0xff;
+	cp[1] = (datum >> 48) & 0xff;
+	cp[2] = (datum >> 40) & 0xff;
+	cp[3] = (datum >> 32) & 0xff;
+	cp[4] = (datum >> 24) & 0xff;
+	cp[5] = (datum >> 16) & 0xff;
+	cp[6] = (datum >>  8) & 0xff;
+	cp[7] = (datum >>  0) & 0xff;
 }
 
 static inline void put_unaligned_uint32(void *p, unsigned int datum)
@@ -88,8 +130,10 @@
 	cp[1] = datum;
 }
 #else /* Not GCC, not Solaris/SPARC. Assume we can handle direct load/store. */
+#define get_unaligned_uint64(p) (*((uint64_t *)(p)))
 #define get_unaligned_uint32(p) (*((unsigned int *)(p)))
 #define get_unaligned_uint16(p) (*((unsigned short *)(p)))
+#define put_unaligned_uint64(p,d) do { uint64_t *__P = (p); *__P = d; } while(0)
 #define put_unaligned_uint32(p,d) do { unsigned int *__P = (p); *__P = d; } while(0)
 #define put_unaligned_uint16(p,d) do { unsigned short *__P = (p); *__P = d; } while(0)
 #endif

Modified: team/tilghman/codec_bits3/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/frame.c?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/main/frame.c (original)
+++ team/tilghman/codec_bits3/main/frame.c Wed Oct 28 15:07:57 2009
@@ -971,11 +971,11 @@
 	} else {
 		to = pref->order;
 		from = buf;
-		mem = 32;
+		mem = sizeof(format_t) * 8;
 	}
 
 	memset(to, 0, mem);
-	for (x = 0; x < 32 ; x++) {
+	for (x = 0; x < sizeof(format_t) * 8; x++) {
 		if (!from[x])
 			break;
 		to[x] = right ? (from[x] + differential) : (from[x] - differential);
@@ -992,7 +992,7 @@
 	total_len = size;
 	buf[0] = '(';
 	total_len--;
-	for (x = 0; x < 64; x++) {
+	for (x = 0; x < sizeof(format_t) * 8; x++) {
 		if (total_len <= 0)
 			break;
 		if (!(codec = ast_codec_pref_index(pref,x)))
@@ -1004,7 +1004,7 @@
 			strncat(buf, formatname, total_len - 1); /* safe */
 			total_len -= slen;
 		}
-		if (total_len && x < 63 && ast_codec_pref_index(pref, x + 1)) {
+		if (total_len && x < sizeof(format_t) * 8 - 1 && ast_codec_pref_index(pref, x + 1)) {
 			strncat(buf, "|", total_len - 1); /* safe */
 			total_len--;
 		}
@@ -1052,7 +1052,6 @@
 			pref->framing[y++] = size;
 		}
 	}
-	
 }
 
 /*! \brief Append codec to list */
@@ -1098,7 +1097,7 @@
 		return;
 
 	/* Now find any existing occurrence, or the end */
-	for (x = 0; x < 64; x++) {
+	for (x = 0; x < sizeof(format_t) * 8; x++) {
 		if (!pref->order[x] || pref->order[x] == newindex)
 			break;
 	}

Modified: team/tilghman/codec_bits3/main/strcompat.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/strcompat.c?view=diff&rev=226383&r1=226382&r2=226383
==============================================================================
--- team/tilghman/codec_bits3/main/strcompat.c (original)
+++ team/tilghman/codec_bits3/main/strcompat.c Wed Oct 28 15:07:57 2009
@@ -334,3 +334,55 @@
 #endif /* linux */
 #endif /* !HAVE_GETLOADAVG */
 
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+	return net64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+	union {
+		unsigned char c[8];
+		uint64_t u;
+	} number;
+	number.u = net64;
+	return
+		(((uint64_t) number.c[0]) <<  0) |
+		(((uint64_t) number.c[1]) <<  8) |
+		(((uint64_t) number.c[2]) << 16) |
+		(((uint64_t) number.c[3]) << 24) |
+		(((uint64_t) number.c[4]) << 32) |
+		(((uint64_t) number.c[5]) << 40) |
+		(((uint64_t) number.c[6]) << 48) |
+		(((uint64_t) number.c[7]) << 56);
+#else
+	#error "Unknown byte order"
+#endif
+}
+#endif
+
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+	return host64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+	union {
+		unsigned char c[8];
+		uint64_t u;
+	} number;
+	number.u = host64;
+	return
+		(((uint64_t) number.c[0]) <<  0) |
+		(((uint64_t) number.c[1]) <<  8) |
+		(((uint64_t) number.c[2]) << 16) |
+		(((uint64_t) number.c[3]) << 24) |
+		(((uint64_t) number.c[4]) << 32) |
+		(((uint64_t) number.c[5]) << 40) |
+		(((uint64_t) number.c[6]) << 48) |
+		(((uint64_t) number.c[7]) << 56);
+#else
+	#error "Unknown byte order"
+#endif
+}
+#endif
+




More information about the svn-commits mailing list