From e5f7fd404ea68a593432f843cb503e44e6d17752 Mon Sep 17 00:00:00 2001
From: Jeremy McNamara <jj@nufone.net>
Date: Sat, 16 Aug 2003 17:00:22 +0000
Subject: [PATCH] Add H323 to normal build process

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1355 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/Makefile               |  5 +++
 channels/{h323 => }/chan_h323.c | 80 ++++++++++++++++-----------------
 2 files changed, 45 insertions(+), 40 deletions(-)
 rename channels/{h323 => }/chan_h323.c (97%)

diff --git a/channels/Makefile b/channels/Makefile
index fb018962da..10a4c412f3 100755
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -25,6 +25,7 @@ CHANNEL_LIBS=chan_modem.so chan_iax.so chan_sip.so \
 #CHANNEL_LIBS+=chan_vofr
 
 CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
+CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
 
 CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
 CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
@@ -108,6 +109,10 @@ chan_vpb.o: chan_vpb.c
 chan_vpb.so: chan_vpb.o
 	 $(CXX) -shared -Xlinker -x -o $@ $< -lvpb -lpthread -lm -ldl
 
+chan_h323.so: chan_h323.o h323/libchanh323.a
+	$(CC) -shared -Xlinker -x -o $@ $< h323/libchanh323.a -L$(PWLIBDIR)/lib  -lpt_linux_x86_r -L$(OPENH323DIR)/lib -lh323_linux_x86_r -L/usr/lib -lpthread -ldl -lcrypto -lssl -lexpat
+
+
 #chan_modem.so : chan_modem.o
 #	$(CC) -rdynamic -shared -Xlinker -x -o $@ $<
 
diff --git a/channels/h323/chan_h323.c b/channels/chan_h323.c
similarity index 97%
rename from channels/h323/chan_h323.c
rename to channels/chan_h323.c
index 9ab65122c5..f02f00ee1f 100755
--- a/channels/h323/chan_h323.c
+++ b/channels/chan_h323.c
@@ -56,7 +56,7 @@
 #include <netinet/ip.h>
 
 
-#include "chan_h323.h"
+#include "h323/chan_h323.h"
 
 /** String variables required by ASTERISK */
 static char *type	= "H323";
@@ -617,73 +617,73 @@ static int oh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
 static struct ast_channel *oh323_new(struct oh323_pvt *i, int state, const char *host)
 {
-	struct ast_channel *tmp;
+	struct ast_channel *ch;
 	int fmt;
-	tmp = ast_channel_alloc(1);
+	ch = ast_channel_alloc(1);
 	
-	if (tmp) {
+	if (ch) {
 		
-		snprintf(tmp->name, sizeof(tmp->name)-1, "H323/%s", host);
-		tmp->nativeformats = i->capability;
-		if (!tmp->nativeformats)
-			tmp->nativeformats = capability;
-		fmt = ast_best_codec(tmp->nativeformats);
-		tmp->type = type;
-		tmp->fds[0] = ast_rtp_fd(i->rtp);
-		ast_setstate(tmp, state);
+		snprintf(ch->name, sizeof(ch->name)-1, "H323/%s", host);
+		ch->nativeformats = i->capability;
+		if (!ch->nativeformats)
+			ch->nativeformats = capability;
+		fmt = ast_best_codec(ch->nativeformats);
+		ch->type = type;
+		ch->fds[0] = ast_rtp_fd(i->rtp);
+		ast_setstate(ch, state);
 		
 		if (state == AST_STATE_RING)
-			tmp->rings = 1;
+			ch->rings = 1;
 		
-		tmp->writeformat = fmt;
-		tmp->pvt->rawwriteformat = fmt;
-		tmp->readformat = fmt;
-		tmp->pvt->rawreadformat = fmt;
+		ch->writeformat = fmt;
+		ch->pvt->rawwriteformat = fmt;
+		ch->readformat = fmt;
+		ch->pvt->rawreadformat = fmt;
 		
 		/* Allocate dsp for in-band DTMF support */
 		if (i->dtmfmode & H323_DTMF_INBAND) {
 			i->vad = ast_dsp_new();
 			ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
-        }
+        	}
 
 		/* Register the OpenH323 channel's functions. */
-		tmp->pvt->pvt = i;
-		tmp->pvt->send_digit = oh323_digit;
-		tmp->pvt->call = oh323_call;
-		tmp->pvt->hangup = oh323_hangup;
-		tmp->pvt->answer = oh323_answer;
-		tmp->pvt->read = oh323_read;
-		tmp->pvt->write = oh323_write;
-		tmp->pvt->indicate = oh323_indicate;
-		tmp->pvt->fixup = oh323_fixup;
-		tmp->pvt->bridge = ast_rtp_bridge;
+		ch->pvt->pvt = i;
+		ch->pvt->send_digit = oh323_digit;
+		ch->pvt->call = oh323_call;
+		ch->pvt->hangup = oh323_hangup;
+		ch->pvt->answer = oh323_answer;
+		ch->pvt->read = oh323_read;
+		ch->pvt->write = oh323_write;
+		ch->pvt->indicate = oh323_indicate;
+		ch->pvt->fixup = oh323_fixup;
+		ch->pvt->bridge = ast_rtp_bridge;
 
 		/*  Set the owner of this channel */
-		i->owner = tmp;
+		i->owner = ch;
 		
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;
 		ast_mutex_unlock(&usecnt_lock);
 		ast_update_use_count();
-		strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
-		strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);		
-		tmp->priority = 1;
+		strncpy(ch->context, i->context, sizeof(ch->context)-1);
+		strncpy(ch->exten, i->exten, sizeof(ch->exten)-1);		
+		ch->priority = 1;
 		if (strlen(i->callerid))
-			tmp->callerid = strdup(i->callerid);
+			ch->callerid = strdup(i->callerid);
 		if (strlen(i->accountcode))
-			strncpy(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode)-1);
+			strncpy(ch->accountcode, i->accountcode, sizeof(ch->accountcode)-1);
 		if (i->amaflags)
-			tmp->amaflags = i->amaflags;
+			ch->amaflags = i->amaflags;
 		if (state != AST_STATE_DOWN) {
-			if (ast_pbx_start(tmp)) {
-				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
-				ast_hangup(tmp);
-				tmp = NULL;
+			if (ast_pbx_start(ch)) {
+				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
+				ast_hangup(ch);
+				ch = NULL;
 			}
 		}
 	} else
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
-	return tmp;
+	return ch;
 }
 
 static struct oh323_pvt *oh323_alloc(int callid)
-- 
GitLab