[asterisk-commits] jdixon: branch jdixon/chan_usbradio-1.4 r143077 - /team/jdixon/chan_usbradio-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Sep 14 07:37:15 CDT 2008


Author: jdixon
Date: Sun Sep 14 07:37:14 2008
New Revision: 143077

URL: http://svn.digium.com/view/asterisk?view=rev&rev=143077
Log:
Allow for OLD_ASTERISK support

Modified:
    team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c

Modified: team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c?view=diff&rev=143077&r1=143076&r2=143077
==============================================================================
--- team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c (original)
+++ team/jdixon/chan_usbradio-1.4/channels/chan_echolink.c Sun Sep 14 07:37:14 2008
@@ -1,3 +1,4 @@
+/* #define	OLD_ASTERISK */
 /*
  * Asterisk -- An open source telephony toolkit.
  *
@@ -32,7 +33,7 @@
 	<depend>zlib</depend>
  ***/
 
-/* Version 0.16, 09/04/2008
+/* Version 0.17, 09/14/2008
 Echolink channel driver for Asterisk/app_rpt.
 
 I wish to thank the following people for the immeasurable amount of
@@ -87,8 +88,6 @@
 */
 
 #include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include <stdio.h>
 #include <string.h>
@@ -122,6 +121,10 @@
 #include "asterisk/translate.h"
 #include "asterisk/astdb.h"
 #include "asterisk/cli.h"
+
+#ifdef	OLD_ASTERISK
+#define	AST_MODULE_LOAD_DECLINE -1
+#endif
 
 #define	MAX_RXKEY_TIME 4
 
@@ -312,6 +315,11 @@
   } r;
 };
 
+#ifdef	OLD_ASTERISK
+static int usecnt;
+AST_MUTEX_DEFINE_STATIC(usecnt_lock);
+#endif
+
 int debug = 0;
 struct el_instance *instances[EL_MAX_INSTANCES];
 int ninstances = 0;
@@ -338,9 +346,14 @@
 static int el_hangup(struct ast_channel *ast);
 static struct ast_frame *el_xread(struct ast_channel *ast);
 static int el_xwrite(struct ast_channel *ast, struct ast_frame *frame);
+#ifdef	OLD_ASTERISK
+static int el_indicate(struct ast_channel *ast, int cond);
+static int el_digit_end(struct ast_channel *c, char digit);
+#else
 static int el_indicate(struct ast_channel *ast, int cond, const void *data, size_t datalen);
 static int el_digit_begin(struct ast_channel *c, char digit);
 static int el_digit_end(struct ast_channel *c, char digit, unsigned int duratiion);
+#endif
 static int el_text(struct ast_channel *c, const char *text);
 
 static int rtcp_make_sdes(unsigned char *pkt, int pktLen, char *call, char *name);
@@ -375,8 +388,12 @@
 	.write = el_xwrite,
 	.indicate = el_indicate,
 	.send_text = el_text,
+#ifdef	OLD_ASTERISK
+	.send_digit = el_digit_end,
+#else
 	.send_digit_begin = el_digit_begin,
 	.send_digit_end = el_digit_end,
+#endif
 };
 
 static void mythread_exit(void *nothing)
@@ -638,7 +655,13 @@
 {
 	if (p->dsp) ast_dsp_free(p->dsp);
 	if (p->xpath) ast_translator_free_path(p->xpath);
+#ifdef	OLD_ASTERISK
+	ast_mutex_lock(&usecnt_lock);
+	usecnt--;
+	ast_mutex_unlock(&usecnt_lock);
+#else
 	ast_module_user_remove(p->u);
+#endif
 	ast_free(p);
 }
 
@@ -649,21 +672,15 @@
 	/* int flags = 0; */
 	char stream[256];
         
-	AST_DECLARE_APP_ARGS(args,
-		AST_APP_ARG(idstr);
-	);
-
 	if (ast_strlen_zero(data)) return NULL;
 
-	AST_STANDARD_APP_ARGS(args,data);
-
 	for(n = 0; n < ninstances; n++)
 	{
-		if (!strcmp(instances[n]->name,args.idstr)) break;
+		if (!strcmp(instances[n]->name,(char *)data)) break;
 	}
 	if (n >= ninstances)
 	{
-		ast_log(LOG_NOTICE,"Cannot find echolink channel %s\n",args.idstr);
+		ast_log(LOG_NOTICE,"Cannot find echolink channel %s\n",(char *)data);
 		return NULL;
 	}
 
@@ -671,7 +688,7 @@
 	if (p) {
 		memset(p, 0, sizeof(struct el_pvt));
 		
-		sprintf(stream,"%s-%lu",args.idstr,instances[n]->seqno++);
+		sprintf(stream,"%s-%lu",(char *)data,instances[n]->seqno++);
 		strcpy(p->stream,stream);
 		p->rxqast.qe_forw = &p->rxqast;
 		p->rxqast.qe_back = &p->rxqast;
@@ -745,7 +762,11 @@
 	return 0;
 }
 
+#ifdef	OLD_ASTERISK
+static int el_indicate(struct ast_channel *ast, int cond)
+#else
 static int el_indicate(struct ast_channel *ast, int cond, const void *data, size_t datalen)
+#endif
 {
 	struct el_pvt *p = ast->tech_pvt;
 
@@ -765,12 +786,20 @@
 	return 0;
 }
 
+#ifndef	OLD_ASTERISK
+
 static int el_digit_begin(struct ast_channel *ast, char digit)
 {
 	return -1;
 }
 
+#endif
+
+#ifdef	OLD_ASTERISK
+static int el_digit_end(struct ast_channel *ast, char digit)
+#else
 static int el_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
+#endif
 {
 	return -1;
 }
@@ -1164,12 +1193,18 @@
 				f2 = ast_translate(p->xpath,&fr,0);
 				f1 = ast_dsp_process(NULL,p->dsp,f2);
 				ast_frfree(f2);
+#ifdef	OLD_ASTERISK
+				if (f1->frametype == AST_FRAME_DTMF)
+#else
 				if ((f1->frametype == AST_FRAME_DTMF_END) ||
 					(f1->frametype == AST_FRAME_DTMF_BEGIN))
+#endif
 				{
 					if ((f1->subclass != 'm') && (f1->subclass != 'u'))
 					{
+#ifndef	OLD_ASTERISK
 						if (f1->frametype == AST_FRAME_DTMF_END)
+#endif
 							ast_log(LOG_NOTICE,"Echolink %s Got DTMF char %c from IP %s\n",p->stream,f1->subclass,p->ip);
 						ast_queue_frame(ast,f1);
 						x = 1;
@@ -1284,8 +1319,18 @@
 	struct ast_channel *tmp;
 	struct el_instance *instp = i->instp;
 
+#ifdef	OLD_ASTERISK
+	tmp = ast_channel_alloc(1);
+	if (tmp)
+	{
+		ast_setstate(tmp,state);
+		ast_copy_string(tmp->context, instp->context, sizeof(tmp->context));
+		ast_copy_string(tmp->exten, instp->astnode, sizeof(tmp->exten));
+		snprintf(tmp->name, sizeof(tmp->name), "echolink/%s", i->stream);
+#else
 	tmp = ast_channel_alloc(1, state, 0, 0, "", instp->astnode, instp->context, 0, "echolink/%s", i->stream);
 	if (tmp) {
+#endif
 		tmp->tech = &el_tech;
 		tmp->nativeformats = prefformat;
 		tmp->rawreadformat = prefformat;
@@ -1297,7 +1342,11 @@
 		tmp->tech_pvt = i;
 		ast_copy_string(tmp->context, instp->context, sizeof(tmp->context));
 		ast_copy_string(tmp->exten, instp->astnode,  sizeof(tmp->exten));
+#ifdef	OLD_ASTERISK
+		ast_copy_string(tmp->language, "", sizeof(tmp->language));
+#else
 		ast_string_field_set(tmp, language, "");
+#endif
 		if (nodenum > 0)
 		{
 			char tmpstr[30];
@@ -1306,7 +1355,14 @@
 			ast_set_callerid(tmp,tmpstr,NULL,NULL);
 		}
 		i->owner = tmp;
+#ifdef	OLD_ASTERISK
+		ast_mutex_lock(&usecnt_lock);
+		usecnt++;
+		ast_mutex_unlock(&usecnt_lock);
+		ast_update_use_count();
+#else
 		i->u = ast_module_user_add(tmp);
+#endif
 		i->nodenum = nodenum;
 		if (state != AST_STATE_DOWN) {
 			if (ast_pbx_start(tmp)) {
@@ -1348,7 +1404,10 @@
 	return tmp;
 }
 
-static int unload_module(void)
+#ifndef	OLD_ASTERISK
+static
+#endif
+int unload_module(void)
 {
 int	n;
 
@@ -2404,8 +2463,10 @@
         ast_log(LOG_NOTICE, "Echolink/%s emailID set to %s\n", instp->name,instp->myemail);
 	return 0;
 }
-
-static int load_module(void)
+#ifndef	OLD_ASTERISK
+static
+#endif
+int load_module(void)
 {
 	struct ast_config *cfg = NULL;
         char *ctg = NULL;
@@ -2450,4 +2511,21 @@
 	return 0;
 }
 
+#ifdef	OLD_ASTERISK
+char *description()
+{
+	return (char *)el_tech.description;
+}
+
+int usecount()
+{
+	return usecnt;
+}
+
+char *key()
+{
+	return ASTERISK_GPL_KEY;
+}
+#else
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "echolink channel driver by KI4LKF");
+#endif




More information about the asterisk-commits mailing list