[Asterisk-bsd] Brand new FreeBSD-5.4 install
Dinesh Nair
dinesh at alphaque.com
Wed Oct 12 13:34:57 CDT 2005
On 10/13/05 01:50 Luigi Rizzo said the following:
> does any of you have a skeleton for a port of asterisk-head to
> FreeBSD ? Mostly minor things but there are some paths in
it's not a port skeleton, but the attached diff file will cleanly compile
asterisk CVS HEAD on freebsd 4.11 and install it in the correct places
under /usr/local. you may need to change some of the paths, especially for
the makefile variables referencing openh323 and pwlib. i've also turned off
the -g flag to gcc as that produces binaries which are too large. i'm not
sure if the ports best practices is to keep this turned on.
additionally, the makefile causes asterisk to be built linked to
linuxthreads instead of pthreads.
--
Regards, /\_/\ "All dogs go to heaven."
dinesh at alphaque.com (0 0) http://www.alphaque.com/
+==========================----oOO--(_)--OOo----==========================+
| for a in past present future; do |
| for b in clients employers associates relatives neighbours pets; do |
| echo "The opinions here in no way reflect the opinions of my $a $b." |
| done; done |
+=========================================================================+
-------------- next part --------------
--- channels/Makefile.orig Thu Oct 6 12:01:20 2005
+++ channels/Makefile Sat Oct 8 20:23:55 2005
@@ -43,7 +43,10 @@
ifeq (${OSARCH},FreeBSD)
PTLIB=-lpt_FreeBSD_x86_r
H323LIB=-lh323_FreeBSD_x86_r
- CHANH323LIB=-pthread
+ CHANH323LIB=-llthread
+ SOLINK+=-L/usr/local/lib
+ CFLAGS+=-D__USE_UNIX98 -D_REENTRANT -D_THREAD_SAFE
+ CFLAGS+=-I/usr/local/include/pthread/linuxthreads
endif
ifeq (${OSARCH},NetBSD)
@@ -120,11 +123,11 @@
endif
ifndef OPENH323DIR
- OPENH323DIR=$(HOME)/openh323
+ OPENH323DIR=/usr/home/dinesh/m0n0/src/openh323.bsd
endif
ifndef PWLIBDIR
- PWLIBDIR=$(HOME)/pwlib
+ PWLIBDIR=/usr/home/dinesh/m0n0/src/pwlib.bsd
endif
#CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
@@ -162,6 +165,10 @@
chan_alsa.o: chan_alsa.c busy.h ringtone.h
+ifeq (${OSARCH},FreeBSD)
+chan_oss.so: chan_oss.o
+ $(CC) $(SOLINK) -o $@ chan_oss.o
+endif
ifeq (${OSARCH},OpenBSD)
chan_oss.so: chan_oss.o
$(CC) $(SOLINK) -o $@ chan_oss.o -lossaudio
@@ -195,7 +202,7 @@
$(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
chan_vpb.so: chan_vpb.o
- $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
+ $(CXX) $(SOLINK) -o $@ $< -lvpb -llthread -lm -ldl
ifeq (${OSARCH},Linux)
chan_h323.so: chan_h323.o h323/libchanh323.a h323/Makefile.ast
@@ -205,6 +212,8 @@
$(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
endif
+h323/ast_h323.o:
+ $(MAKE) -C h323 ast_h323.o
#chan_modem.so : chan_modem.o
# $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
--- channels/chan_h323.c.orig Fri Sep 16 01:08:52 2005
+++ channels/chan_h323.c Thu Oct 6 12:35:33 2005
@@ -27,6 +27,7 @@
*
*/
+#include <sys/types.h>
#include <sys/socket.h>
#include <sys/signal.h>
#include <sys/param.h>
--- channels/chan_sip.c.orig Thu Oct 6 12:01:52 2005
+++ channels/chan_sip.c Thu Oct 6 12:35:33 2005
@@ -325,7 +325,7 @@
static char default_language[MAX_LANGUAGE] = "";
-#define DEFAULT_CALLERID "asterisk"
+#define DEFAULT_CALLERID "Unknown"
static char default_callerid[AST_MAX_EXTENSION] = DEFAULT_CALLERID;
static char default_fromdomain[AST_MAX_EXTENSION] = "";
@@ -464,6 +464,7 @@
struct sip_route {
struct sip_route *next;
char hop[0];
+ int lr;
};
enum domain_mode {
@@ -2414,8 +2415,9 @@
char *res;
if (ast->hangupcause && ((res = hangup_cause2sip(ast->hangupcause)))) {
transmit_response_reliable(p, res, &p->initreq, 1);
- } else
+ } else {
transmit_response_reliable(p, "403 Forbidden", &p->initreq, 1);
+ }
}
} else { /* Call is in UP state, send BYE */
if (!p->pendinginvite) {
@@ -2913,7 +2915,7 @@
if (p->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != p->owner->nativeformats) {
+ if (f->subclass & p->owner->nativeformats) {
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats = f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
@@ -5914,6 +5916,10 @@
/* Make a struct route */
thishop = malloc(sizeof(*thishop) + len);
if (thishop) {
+ if(strnstr(rr, ";lr", len) != NULL)
+ thishop->lr = 1;
+ else
+ thishop->lr = 0;
ast_copy_string(thishop->hop, rr, len);
ast_log(LOG_DEBUG, "build_route: Record-Route hop: <%s>\n", thishop->hop);
/* Link in */
@@ -10318,6 +10324,13 @@
transmit_response(p, "180 Ringing", req);
break;
case AST_STATE_UP:
+ /* Assuming this to be reinvite, process new SDP portion */
+ if(!ast_strlen_zero(get_header(req, "Content-Type"))) {
+ process_sdp(p, req) ;
+ } else {
+ p->jointcapability - p->capability ;
+ ast_log(LOG_DEBUG, "Hmm.... No SDP for the moment\n") ;
+ }
transmit_response_with_sdp(p, "200 OK", req, 1);
break;
default:
--- codecs/codec_g723_1_dummy.c.orig Thu Oct 6 12:35:33 2005
+++ codecs/codec_g723_1_dummy.c Thu Oct 6 12:35:33 2005
@@ -0,0 +1,308 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Translate between signed linear and G.723.1 (dummy!)
+ *
+ * The G.723.1 code is not included in the Asterisk distribution because
+ * it is covered with patents, and in spite of statements to the contrary,
+ * the "technology" is extremely expensive to license.
+ *
+ * Copyright (C) 1999, Mark Spencer
+ *
+ * Mark Spencer <markster at linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#define TYPE_HIGH 0x0
+#define TYPE_LOW 0x1
+#define TYPE_SILENCE 0x2
+#define TYPE_DONTSEND 0x3
+#define TYPE_MASK 0x3
+
+#include <sys/types.h>
+#include <asterisk/translate.h>
+#include <asterisk/module.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <stdio.h>
+
+/* Sample frame data */
+#include "slin_g723_ex.h"
+#include "g723_slin_ex.h"
+
+AST_MUTEX_DEFINE_STATIC(localuser_lock);
+static int localusecnt=0;
+
+static char *tdesc = "Dummy G.723.1/PCM16 Codec Translator";
+
+struct g723_encoder_pvt {
+ struct ast_frame f;
+ /* Space to build offset */
+ char offset[AST_FRIENDLY_OFFSET];
+ /* Buffer for our outgoing frame */
+ char outbuf[8000];
+ /* Enough to store a full second */
+ short buf[8000];
+ int tail;
+};
+
+struct g723_decoder_pvt {
+ struct ast_frame f;
+ /* Space to build offset */
+ char offset[AST_FRIENDLY_OFFSET];
+ /* Enough to store a full second */
+ short buf[8000];
+ int tail;
+};
+
+static struct ast_translator_pvt *g723tolin_new()
+{
+ struct g723_decoder_pvt *tmp;
+ tmp = malloc(sizeof(struct g723_decoder_pvt));
+ if (tmp) {
+ tmp->tail = 0;
+ localusecnt++;
+ ast_update_use_count();
+ }
+ return (struct ast_translator_pvt *)tmp;
+}
+
+static struct ast_frame *lintog723_sample()
+{
+ static struct ast_frame f;
+ f.frametype = AST_FRAME_VOICE;
+ f.subclass = AST_FORMAT_SLINEAR;
+ f.datalen = sizeof(slin_g723_ex);
+ /* Assume 8000 Hz */
+ f.samples = sizeof(slin_g723_ex)/16;
+ f.mallocd = 0;
+ f.offset = 0;
+ f.src = __PRETTY_FUNCTION__;
+ f.data = slin_g723_ex;
+ return &f;
+}
+
+static struct ast_frame *g723tolin_sample()
+{
+ static struct ast_frame f;
+ f.frametype = AST_FRAME_VOICE;
+ f.subclass = AST_FORMAT_G723_1;
+ f.datalen = sizeof(g723_slin_ex);
+ /* All frames are 30 ms long */
+ f.samples = 30;
+ f.mallocd = 0;
+ f.offset = 0;
+ f.src = __PRETTY_FUNCTION__;
+ f.data = g723_slin_ex;
+ return &f;
+}
+
+static struct ast_translator_pvt *lintog723_new()
+{
+ struct g723_encoder_pvt *tmp;
+ tmp = malloc(sizeof(struct g723_encoder_pvt));
+ if (tmp) {
+ localusecnt++;
+ ast_update_use_count();
+ tmp->tail = 0;
+ }
+ return (struct ast_translator_pvt *)tmp;
+}
+
+static struct ast_frame *g723tolin_frameout(struct ast_translator_pvt *pvt)
+{
+ struct g723_decoder_pvt *tmp = (struct g723_decoder_pvt *)pvt;
+ if (!tmp->tail)
+ return NULL;
+ /* Signed linear is no particular frame size, so just send whatever
+ we have in the buffer in one lump sum */
+ tmp->f.frametype = AST_FRAME_VOICE;
+ tmp->f.subclass = AST_FORMAT_SLINEAR;
+ tmp->f.datalen = tmp->tail * 2;
+ /* Assume 8000 Hz */
+ tmp->f.samples = tmp->tail / 8;
+ tmp->f.mallocd = 0;
+ tmp->f.offset = AST_FRIENDLY_OFFSET;
+ tmp->f.src = __PRETTY_FUNCTION__;
+ tmp->f.data = tmp->buf;
+ /* Reset tail pointer */
+ tmp->tail = 0;
+
+ return &tmp->f;
+}
+
+static int g723_len(unsigned char buf)
+{
+ switch(buf & TYPE_MASK) {
+ case TYPE_DONTSEND:
+ return 2;
+ break;
+ case TYPE_SILENCE:
+ return 4;
+ break;
+ case TYPE_HIGH:
+ return 24;
+ break;
+ case TYPE_LOW:
+ return 20;
+ break;
+ default:
+ ast_log(LOG_WARNING, "Badly encoded frame (%d)\n", buf & TYPE_MASK);
+ }
+ return -1;
+}
+
+static int g723tolin_framein(struct ast_translator_pvt *pvt, struct ast_frame *f)
+{
+ struct g723_decoder_pvt *tmp = (struct g723_decoder_pvt *)pvt;
+ int len = 0;
+ int res;
+ while(len < f->datalen) {
+ /* Assuming there's space left, decode into the current buffer at
+ the tail location */
+ res = g723_len(((unsigned char *)f->data + len)[0]);
+ if (res < 0) {
+ ast_log(LOG_WARNING, "Invalid data\n");
+ return -1;
+ }
+ if (res + len > f->datalen) {
+ ast_log(LOG_WARNING, "Measured length exceeds frame length\n");
+ return -1;
+ }
+ if (tmp->tail + 480 < sizeof(tmp->buf)/2) {
+ memset(tmp->buf + tmp->tail, 0, 480);
+ tmp->tail+=480;
+ } else {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return -1;
+ }
+ len += res;
+ }
+ return 0;
+}
+
+static int lintog723_framein(struct ast_translator_pvt *pvt, struct ast_frame *f)
+{
+ /* Just add the frames to our stream */
+ /* XXX We should look at how old the rest of our stream is, and if it
+ is too old, then we should overwrite it entirely, otherwise we can
+ get artifacts of earlier talk that do not belong */
+ struct g723_encoder_pvt *tmp = (struct g723_encoder_pvt *)pvt;
+ if (tmp->tail + f->datalen/2 < sizeof(tmp->buf) / 2) {
+ memcpy(&tmp->buf[tmp->tail], f->data, f->datalen);
+ tmp->tail += f->datalen/2;
+ } else {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return -1;
+ }
+ return 0;
+}
+
+static struct ast_frame *lintog723_frameout(struct ast_translator_pvt *pvt)
+{
+ struct g723_encoder_pvt *tmp = (struct g723_encoder_pvt *)pvt;
+ int cnt=0;
+ /* We can't work on anything less than a frame in size */
+ if (tmp->tail < 480)
+ return NULL;
+ tmp->f.frametype = AST_FRAME_VOICE;
+ tmp->f.subclass = AST_FORMAT_G723_1;
+ tmp->f.offset = AST_FRIENDLY_OFFSET;
+ tmp->f.src = __PRETTY_FUNCTION__;
+ tmp->f.samples = 0;
+ tmp->f.mallocd = 0;
+ while(tmp->tail >= 480) {
+ /* Encode a frame of data */
+ if (cnt + 24 >= sizeof(tmp->outbuf)) {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return NULL;
+ }
+ memset(tmp->outbuf + cnt, 0, 24);
+ /* Assume 8000 Hz */
+ tmp->f.samples += 30;
+ cnt += 24;
+ tmp->tail -= 480;
+ /* Move the data at the end of the buffer to the front */
+ if (tmp->tail)
+ memmove(tmp->buf, tmp->buf + 480, tmp->tail * 2);
+ }
+ tmp->f.datalen = cnt;
+ tmp->f.data = tmp->outbuf;
+ return &tmp->f;
+}
+
+static void g723_destroy(struct ast_translator_pvt *pvt)
+{
+ free(pvt);
+ localusecnt--;
+ ast_update_use_count();
+}
+
+static struct ast_translator g723tolin =
+ { "g723tolin_dummy",
+ AST_FORMAT_G723_1, AST_FORMAT_SLINEAR,
+ g723tolin_new,
+ g723tolin_framein,
+ g723tolin_frameout,
+ g723_destroy,
+ g723tolin_sample
+ };
+
+static struct ast_translator lintog723 =
+ { "lintog723_dummy",
+ AST_FORMAT_SLINEAR, AST_FORMAT_G723_1,
+ lintog723_new,
+ lintog723_framein,
+ lintog723_frameout,
+ g723_destroy,
+ lintog723_sample
+ };
+
+int unload_module(void)
+{
+ int res;
+ ast_mutex_lock(&localuser_lock);
+ res = ast_unregister_translator(&lintog723);
+ if (!res)
+ res = ast_unregister_translator(&g723tolin);
+ if (localusecnt)
+ res = -1;
+ ast_mutex_unlock(&localuser_lock);
+ return res;
+}
+
+int load_module(void)
+{
+ int res;
+ res=ast_register_translator(&g723tolin);
+ if (!res)
+ res=ast_register_translator(&lintog723);
+ else
+ ast_unregister_translator(&g723tolin);
+ return res;
+}
+
+char *description(void)
+{
+ return tdesc;
+}
+
+int usecount(void)
+{
+ int res;
+ STANDARD_USECOUNT(res);
+ return res;
+}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}
--- codecs/Makefile.orig Mon Sep 5 23:48:47 2005
+++ codecs/Makefile Thu Oct 6 12:35:33 2005
@@ -11,15 +11,8 @@
# the GNU General Public License
#
-ifneq ($(wildcard g723.1/coder.c),)
- MODG723=codec_g723_1.so
- LIBG723=g723.1/libg723.a
-endif
-
-ifneq ($(wildcard g723.1b/coder2.c),)
- MODG723+=codec_g723_1b.so
- LIBG723B=g723.1b/libg723b.a
-endif
+MODG723=codec_g723_1_dummy.so
+MODG729=codec_g729_1_dummy.so
UI_SPEEX=$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/speex.h)
UIS_SPEEX=$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/speex/speex.h)
@@ -62,7 +55,7 @@
CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
endif
-CODECS+=$(MODG723) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_lpc10.so \
+CODECS+=$(MODG723) $(MODG729) $(MODSPEEX) $(MODILBC) codec_gsm.so codec_lpc10.so \
codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \
codec_g726.so
@@ -111,6 +104,9 @@
codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
$(CC) $(SOLINK) -o $@ $< $(LIBLPC10) -lm
+
+$(MODG729): codec_g729_dummy.o
+ $(CC) $(SOLINK) -o $@ $<
%.so : %.o
$(CC) $(SOLINK) -o $@ $<
--- codecs/codec_g729_dummy.c.orig Thu Oct 6 12:35:33 2005
+++ codecs/codec_g729_dummy.c Thu Oct 6 12:35:33 2005
@@ -0,0 +1,275 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Translate between signed linear and G.729 (dummy!)
+ *
+ * The G.729 code is not included in the Asterisk distribution because
+ * it is covered with patents, and in spite of statements to the contrary,
+ * the "technology" is extremely expensive to license.
+ *
+ * Copyright (C) 1999, Mark Spencer
+ *
+ * Mark Spencer <markster at linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <sys/types.h>
+#include <asterisk/translate.h>
+#include <asterisk/module.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <stdio.h>
+
+/* Sample frame data */
+#include "slin_g729_ex.h"
+#include "g729_slin_ex.h"
+
+AST_MUTEX_DEFINE_STATIC(localuser_lock);
+static int localusecnt=0;
+
+static char *tdesc = "Dummy G.729/PCM16 Codec Translator";
+
+struct g729_encoder_pvt {
+ struct ast_frame f;
+ /* Space to build offset */
+ char offset[AST_FRIENDLY_OFFSET];
+ /* Buffer for our outgoing frame */
+ char outbuf[8000];
+ /* Enough to store a full second */
+ short buf[8000];
+ int tail;
+};
+
+struct g729_decoder_pvt {
+ struct ast_frame f;
+ /* Space to build offset */
+ char offset[AST_FRIENDLY_OFFSET];
+ /* Enough to store a full second */
+ short buf[8000];
+ int tail;
+};
+
+static struct ast_translator_pvt *g729tolin_new()
+{
+ struct g729_decoder_pvt *tmp;
+ tmp = malloc(sizeof(struct g729_decoder_pvt));
+ if (tmp) {
+ tmp->tail = 0;
+ localusecnt++;
+ ast_update_use_count();
+ }
+ return (struct ast_translator_pvt *)tmp;
+}
+
+static struct ast_frame *lintog729_sample()
+{
+ static struct ast_frame f;
+ f.frametype = AST_FRAME_VOICE;
+ f.subclass = AST_FORMAT_SLINEAR;
+ f.datalen = sizeof(slin_g729_ex);
+ /* Assume 8000 Hz */
+ f.samples = sizeof(slin_g729_ex)/16;
+ f.mallocd = 0;
+ f.offset = 0;
+ f.src = __PRETTY_FUNCTION__;
+ f.data = slin_g729_ex;
+ return &f;
+}
+
+static struct ast_frame *g729tolin_sample()
+{
+ static struct ast_frame f;
+ f.frametype = AST_FRAME_VOICE;
+ f.subclass = AST_FORMAT_G729A;
+ f.datalen = sizeof(g729_slin_ex);
+ /* All frames are 10 ms long */
+ f.samples = 10;
+ f.mallocd = 0;
+ f.offset = 0;
+ f.src = __PRETTY_FUNCTION__;
+ f.data = g729_slin_ex;
+ return &f;
+}
+
+static struct ast_translator_pvt *lintog729_new()
+{
+ struct g729_encoder_pvt *tmp;
+ tmp = malloc(sizeof(struct g729_encoder_pvt));
+ if (tmp) {
+ localusecnt++;
+ ast_update_use_count();
+ tmp->tail = 0;
+ }
+ return (struct ast_translator_pvt *)tmp;
+}
+
+static struct ast_frame *g729tolin_frameout(struct ast_translator_pvt *pvt)
+{
+ struct g729_decoder_pvt *tmp = (struct g729_decoder_pvt *)pvt;
+ if (!tmp->tail)
+ return NULL;
+ /* Signed linear is no particular frame size, so just send whatever
+ we have in the buffer in one lump sum */
+ tmp->f.frametype = AST_FRAME_VOICE;
+ tmp->f.subclass = AST_FORMAT_SLINEAR;
+ tmp->f.datalen = tmp->tail * 2;
+ /* Assume 8000 Hz */
+ tmp->f.samples = tmp->tail / 8;
+ tmp->f.mallocd = 0;
+ tmp->f.offset = AST_FRIENDLY_OFFSET;
+ tmp->f.src = __PRETTY_FUNCTION__;
+ tmp->f.data = tmp->buf;
+ /* Reset tail pointer */
+ tmp->tail = 0;
+
+ return &tmp->f;
+}
+
+static int g729tolin_framein(struct ast_translator_pvt *pvt, struct ast_frame *f)
+{
+ struct g729_decoder_pvt *tmp = (struct g729_decoder_pvt *)pvt;
+ int len = 0;
+ while(len < f->datalen) {
+ /* Assuming there's space left, decode into the current buffer at
+ the tail location */
+ if (10 + len > f->datalen) {
+ ast_log(LOG_WARNING, "Measured length exceeds frame length\n");
+ return -1;
+ }
+ if (tmp->tail + 160 < sizeof(tmp->buf)/2) {
+ memset(tmp->buf + tmp->tail, 0, 160);
+ tmp->tail+=160;
+ } else {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return -1;
+ }
+ len += 10;
+ }
+ return 0;
+}
+
+static int lintog729_framein(struct ast_translator_pvt *pvt, struct ast_frame *f)
+{
+ /* Just add the frames to our stream */
+ /* XXX We should look at how old the rest of our stream is, and if it
+ is too old, then we should overwrite it entirely, otherwise we can
+ get artifacts of earlier talk that do not belong */
+ struct g729_encoder_pvt *tmp = (struct g729_encoder_pvt *)pvt;
+ if (tmp->tail + f->datalen/2 < sizeof(tmp->buf) / 2) {
+ memcpy(&tmp->buf[tmp->tail], f->data, f->datalen);
+ tmp->tail += f->datalen/2;
+ } else {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return -1;
+ }
+ return 0;
+}
+
+static struct ast_frame *lintog729_frameout(struct ast_translator_pvt *pvt)
+{
+ struct g729_encoder_pvt *tmp = (struct g729_encoder_pvt *)pvt;
+ int cnt=0;
+ /* We can't work on anything less than a frame in size */
+ if (tmp->tail < 160)
+ return NULL;
+ tmp->f.frametype = AST_FRAME_VOICE;
+ tmp->f.subclass = AST_FORMAT_G729A;
+ tmp->f.offset = AST_FRIENDLY_OFFSET;
+ tmp->f.src = __PRETTY_FUNCTION__;
+ tmp->f.samples = 0;
+ tmp->f.mallocd = 0;
+ while(tmp->tail >= 160) {
+ /* Encode a frame of data */
+ if (cnt + 10 >= sizeof(tmp->outbuf)) {
+ ast_log(LOG_WARNING, "Out of buffer space\n");
+ return NULL;
+ }
+ memset(tmp->outbuf + cnt, 0, 10);
+ /* Assume 8000 Hz */
+ tmp->f.samples += 10;
+ cnt += 10;
+ tmp->tail -= 160;
+ /* Move the data at the end of the buffer to the front */
+ if (tmp->tail)
+ memmove(tmp->buf, tmp->buf + 160, tmp->tail * 2);
+ }
+ tmp->f.datalen = cnt;
+ tmp->f.data = tmp->outbuf;
+ return &tmp->f;
+}
+
+static void g729_destroy(struct ast_translator_pvt *pvt)
+{
+ free(pvt);
+ localusecnt--;
+ ast_update_use_count();
+}
+
+static struct ast_translator g729tolin =
+ { "g729tolin_dummy",
+ AST_FORMAT_G729A, AST_FORMAT_SLINEAR,
+ g729tolin_new,
+ g729tolin_framein,
+ g729tolin_frameout,
+ g729_destroy,
+ g729tolin_sample
+ };
+
+static struct ast_translator lintog729 =
+ { "lintog729_dummy",
+ AST_FORMAT_SLINEAR, AST_FORMAT_G729A,
+ lintog729_new,
+ lintog729_framein,
+ lintog729_frameout,
+ g729_destroy,
+ lintog729_sample
+ };
+
+int unload_module(void)
+{
+ int res;
+ ast_mutex_lock(&localuser_lock);
+ res = ast_unregister_translator(&lintog729);
+ if (!res)
+ res = ast_unregister_translator(&g729tolin);
+ if (localusecnt)
+ res = -1;
+ ast_mutex_unlock(&localuser_lock);
+ return res;
+}
+
+int load_module(void)
+{
+ int res;
+ res=ast_register_translator(&g729tolin);
+ if (!res)
+ res=ast_register_translator(&lintog729);
+ else
+ ast_unregister_translator(&g729tolin);
+ return res;
+}
+
+char *description(void)
+{
+ return tdesc;
+}
+
+int usecount(void)
+{
+ int res;
+ STANDARD_USECOUNT(res);
+ return res;
+}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}
--- codecs/g729_slin_ex.h.orig Thu Oct 6 12:35:33 2005
+++ codecs/g729_slin_ex.h Thu Oct 6 12:35:33 2005
@@ -0,0 +1,14 @@
+/*
+ * g729_slin_ex.h --
+ *
+ * 8-bit G.729 data, 10 milliseconds worth at 8 kHz.
+ *
+ * Copyright (C) 2004, Maxim Sobolev <sobomax at FreeBSD.org>
+ *
+ * Distributed under the terms of the GNU General Public License
+ *
+ */
+
+static unsigned char g729_slin_ex[] = {
+120,82,175,64,0,250,219,0,7,214
+};
--- codecs/slin_g729_ex.h.orig Thu Oct 6 12:35:33 2005
+++ codecs/slin_g729_ex.h Thu Oct 6 12:35:33 2005
@@ -0,0 +1,25 @@
+/*
+ * slin_g729_ex.h --
+ *
+ * Signed 16-bit audio data, 10 milliseconds worth at 8 kHz.
+ *
+ * Source: g723.example
+ *
+ * Copyright (C) 2001, Linux Support Services, Inc.
+ *
+ * Distributed under the terms of the GNU General Public License
+ *
+ */
+
+static signed short slin_g729_ex[] = {
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
--- utils/Makefile.orig Thu Sep 15 02:47:54 2005
+++ utils/Makefile Thu Oct 6 12:35:33 2005
@@ -54,10 +54,10 @@
$(CC) $(CFLAGS) -o stereorize stereorize.o frame.o -lm
ast_expr2.o: ../ast_expr2.c
- gcc -g -c -o $@ $<
+ gcc -c -o $@ $<
ast_expr2f.o: ../ast_expr2f.c
- gcc -g -c -DSTANDALONE -o $@ $<
+ gcc -c -DSTANDALONE -o $@ $<
check_expr: check_expr.c ast_expr2.o ast_expr2f.o
$(CC) $(CFLAGS) -o $@ $^
--- Makefile.orig Fri Sep 30 22:48:41 2005
+++ Makefile Thu Oct 6 12:35:33 2005
@@ -46,10 +46,10 @@
OVERWRITE=y
#Tell gcc to optimize the code
-OPTIMIZE+=-O6
+# OPTIMIZE+=-O6
#Include debug symbols in the executables (-g) and profiling info (-pg)
-DEBUG=-g #-pg
+# DEBUG=-g #-pg
# If you are running a radio application, define RADIO_RELAX so that the DTMF
# will be received more reliably
@@ -77,7 +77,7 @@
# Where to install asterisk after compiling
# Default -> leave empty
-INSTALL_PREFIX?=
+INSTALL_PREFIX=/usr/local
# Staging directory
# Files are copied here temporarily during the install process
@@ -98,17 +98,17 @@
BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
ifneq (${OSARCH},SunOS)
- ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
- ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
+ ASTLIBDIR=$(INSTALL_PREFIX)/lib/asterisk
+ ASTVARLIBDIR=$(INSTALL_PREFIX)/share/asterisk
ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
- ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
- ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
- ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
+ ASTSPOOLDIR=/var/spool/asterisk
+ ASTLOGDIR=/var/log/asterisk
+ ASTHEADERDIR=$(INSTALL_PREFIX)/include/asterisk
ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
- ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
- ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
- ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
- ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
+ ASTBINDIR=$(INSTALL_PREFIX)/bin
+ ASTSBINDIR=$(INSTALL_PREFIX)/sbin
+ ASTVARRUNDIR=/var/run
+ ASTMANDIR=$(INSTALL_PREFIX)/man
MODULES_DIR=$(ASTLIBDIR)/modules
AGI_DIR=$(ASTVARLIBDIR)/agi-bin
else
@@ -236,8 +236,9 @@
ifeq (${OSARCH},FreeBSD)
BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
- ASTCFLAGS+=$(shell if test ${BSDVERSION} -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
- LIBS+=$(shell if test ${BSDVERSION} -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
+ ASTCFLAGS+=$(shell if test ${BSDVERSION} -lt 500016 ; then echo "-D__USE_UNIX98 -D_REENTRANT -D_THREAD_SAFE"; fi)
+ ASTCFLAGS+=$(shell if test ${BSDVERSION} -lt 500016 ; then echo "-I/usr/local/include/pthread/linuxthreads"; fi)
+ LIBS+=$(shell if test ${BSDVERSION} -lt 502102 ; then echo "-L/usr/local/lib -llthread -llgcc_r"; else echo "-pthread"; fi)
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),)
ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp
endif
@@ -488,7 +489,7 @@
$(MAKE) -C stdtime clean
datafiles: all
- if test $$(id -u) = 0; then sh mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
+ # if test $$(id -u) = 0; then sh mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros
for x in sounds/digits/*.gsm; do \
More information about the Asterisk-BSD
mailing list