Commit 49a24c0f authored by Timo Teräs's avatar Timo Teräs
Browse files

testing/asterisk-chan-dongle: moved from unmaintained

and fixed to build with asterisk 14
parent fb354bed
# Contributor: Timo Teräs <timo.teras@iki.fi>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=asterisk-chan-dongle
pkgver=1.1.20160925
_commitid=e3bce3c1d43cec1e4f8e548b4d3880e289747b24
pkgrel=0
pkgdesc="GSM modem dongle channel driver"
url="https://github.com/oleg-krv/asterisk-chan-dongle/"
arch="all"
license="GPL2"
depends="asterisk"
depends_dev=""
makedepends="$depends_dev asterisk-dev automake autoconf"
install=""
subpackages=""
provides="asterisk-dongle=$pkgver"
source="$pkgname-$pkgver.tar.gz::https://github.com/oleg-krv/asterisk-chan-dongle/archive/$_commitid.tar.gz
asterisk-14.patch
"
builddir="$srcdir/$pkgname-$_commitid"
prepare() {
default_prepare || return 1
cd "$builddir"
# automake will return error due to Makefile.am missing
# the project autoconfigury foo is old and ships Makefile.in directly
aclocal && autoconf && automake -a || true
}
build() {
cd "$builddir"
./configure || return 1
make
}
package() {
cd "$builddir"
mkdir -p "$pkgdir"/usr/lib/asterisk/modules "$pkgdir"/etc/asterisk
install -m644 etc/dongle.conf "$pkgdir"/etc/asterisk/dongle.conf.sample
install -m755 chan_dongle.so "$pkgdir"/usr/lib/asterisk/modules
}
md5sums="fa96fbcba75f53865d46d8327d21a6c0 asterisk-chan-dongle-1.1.20160925.tar.gz
bbfb2435082d4284221054c9eadc0c16 asterisk-14.patch"
sha256sums="50824b72a61ffb062ee0ae49d86a635c846202030223edc960c4fd853aa94187 asterisk-chan-dongle-1.1.20160925.tar.gz
f21b0c5be6c50ae9dfe81302631a9c8d6ad31f301817f457b13a2c8297f574de asterisk-14.patch"
sha512sums="2cbd134c284f5a86b0443f459997d4965300920dbcadaf5afbc95cdf5c76e5c0e5b047def1cc590a10b4f8a8fe39575950dafa75afaa52c79e32644eb97bc95a asterisk-chan-dongle-1.1.20160925.tar.gz
de6c453f8482d9a0c4a77c607efbf058d80342d74bb1053f6f3a18d2e3b79c8fc643f7cdedcdfda414227ecc8ecd05b4cee70a260811dc75128a493b9a772c57 asterisk-14.patch"
diff -ru asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24.orig/Makefile.in asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24/Makefile.in
--- asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24.orig/Makefile.in 2016-10-02 17:35:30.000000000 +0300
+++ asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24/Makefile.in 2016-11-11 15:29:54.789991216 +0200
@@ -37,7 +37,7 @@
INSTALL = @INSTALL@
CHMOD = chmod
-DEFS = -DASTERISK_VERSION_NUM=130000
+DEFS = -DASTERISK_VERSION_NUM=130000 -DAST_MODULE_SELF_SYM=self_module
CFLAGS = @CFLAGS@ -I$(srcdir) @CPPFLAGS@ $(DEFS) @DEFS@ @AC_CFLAGS@
LDFLAGS = @LDFLAGS@
SOLINK = @SOLINK@
diff -ru asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24.orig/chan_dongle.c asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24/chan_dongle.c
--- asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24.orig/chan_dongle.c 2016-10-02 17:35:30.000000000 +0300
+++ asterisk-chan-dongle-e3bce3c1d43cec1e4f8e548b4d3880e289747b24/chan_dongle.c 2016-11-11 15:28:51.832489663 +0200
@@ -39,10 +39,7 @@
#include <config.h>
#endif /* HAVE_CONFIG_H */
-
#include <asterisk.h>
-ASTERISK_FILE_VERSION(__FILE__, "$Rev: " PACKAGE_REVISION " $")
-
#include <asterisk/ast_version.h>
#include <asterisk/stringfields.h> /* AST_DECLARE_STRING_FIELDS for asterisk/manager.h */
#include <asterisk/manager.h>
@@ -1793,8 +1790,3 @@
);
//AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY, MODULE_DESCRIPTION);
-
-EXPORT_DEF struct ast_module* self_module()
-{
- return ast_module_info->self;
-}
# Contributor: Timo Teräs <timo.teras@iki.fi>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
SVNREV=27
pkgname=asterisk-dongle
pkgver=1.1.$SVNREV
pkgrel=3
pkgdesc="GSM modem dongle channel driver"
url="http://code.google.com/p/asterisk-chan-dongle/"
arch=""
license="GPL2"
depends="asterisk"
depends_dev=""
makedepends="$depends_dev asterisk-dev subversion automake autoconf"
install=""
subpackages=""
source="issue46.patch"
_builddir="$srcdir/$pkgname-$pkgver"
prepare() {
local i
svn checkout http://asterisk-chan-dongle.googlecode.com/svn/trunk/@$REV "$_builddir"
cd "$_builddir"
for i in $source; do
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
esac
done
}
build() {
cd "$_builddir"
aclocal && autoconf && automake -a
./configure || return 1
make
}
package() {
cd "$_builddir"
mkdir -p "$pkgdir"/usr/lib/asterisk/modules "$pkgdir"/etc/asterisk
install -m644 etc/dongle.conf "$pkgdir"/etc/asterisk/dongle.conf.sample
install -m755 chan_dongle.so "$pkgdir"/usr/lib/asterisk/modules
}
md5sums="73321cca36d8f25f8de687b5600e7b73 issue46.patch"
Issue 46 from asterisk-chan-dongle bug tracker
Fixes to build with Asterisk 10+
http://asterisk-chan-dongle.googlecode.com/issues/attachment?aid=460006000&name=patch3.patch.txt&token=VQW7Irk8LNc422UzWgcczezUNaY%3A1341828783939
--- a/chan_dongle_o.c 2011-11-23 14:04:57.270633822 +0200
+++ b/chan_dongle.c 2011-11-23 14:07:05.740251209 +0200
@@ -43,6 +43,7 @@
#include <asterisk.h>
ASTERISK_FILE_VERSION(__FILE__, "$Rev: " PACKAGE_REVISION " $")
+#include <asterisk/version.h>
#include <asterisk/stringfields.h> /* AST_DECLARE_STRING_FIELDS for asterisk/manager.h */
#include <asterisk/manager.h>
#include <asterisk/dsp.h>
@@ -71,6 +72,8 @@
EXPORT_DEF const char * const dev_state_strs[4] = { "stop", "restart", "remove", "start" };
EXPORT_DEF public_state_t * gpublic;
+EXPORT_DEF struct ast_format chan_dongle_format;
+EXPORT_DEF struct ast_format_cap * chan_dongle_format_cap;
static int public_state_init(struct public_state * state);
@@ -1640,6 +1643,16 @@
rv = AST_MODULE_LOAD_FAILURE;
if(discovery_restart(state) == 0)
{
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ /* set preferred capabilities */
+ ast_format_set(&chan_dongle_format, AST_FORMAT_SLINEAR, 0);
+ if (!(channel_tech.capabilities = ast_format_cap_alloc())) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+ ast_format_cap_add(channel_tech.capabilities, &chan_dongle_format);
+ chan_dongle_format_cap = channel_tech.capabilities;
+#endif
+
/* register our channel type */
if(ast_channel_register(&channel_tech) == 0)
{
@@ -1652,6 +1665,9 @@
}
else
{
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ channel_tech.capabilities = ast_format_cap_destroy(channel_tech.capabilities);
+#endif
ast_log (LOG_ERROR, "Unable to register channel class %s\n", channel_tech.type);
}
discovery_stop(state);
@@ -1679,6 +1695,9 @@
{
/* First, take us out of the channel loop */
ast_channel_unregister (&channel_tech);
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ channel_tech.capabilities = ast_format_cap_destroy(channel_tech.capabilities);
+#endif
/* Unregister the CLI & APP & MANAGER */
--- a/han_dongle_o.h 2011-11-23 14:05:35.031639222 +0200
+++ b/chan_dongle.h 2011-11-23 14:06:24.608334634 +0200
@@ -33,6 +33,9 @@
return enum2str(state, states, ITEMS_OF(states));
}
+/* Only linear is allowed */
+EXPORT_DECL struct ast_format chan_dongle_format;
+EXPORT_DECL struct ast_format_cap * chan_dongle_format_cap;
typedef enum {
RESTATE_TIME_NOW = 0,
--- a/channel_o.c 2011-11-23 14:05:08.279344414 +0200
+++ b/channel.c 2011-11-23 14:06:24.610334645 +0200
@@ -95,20 +95,24 @@
return 0;
}
-#if ASTERISK_VERSION_NUM >= 10800
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+
+static struct ast_channel * channel_request (attribute_unused const char * type, struct ast_format_cap * cap, const struct ast_channel *requestor, void * data, int * cause)
+
+#elif ASTERISK_VERSION_NUM >= 10800 /* 1.8+ */
// TODO: simplify by move common code to functions
static struct ast_channel * channel_request (attribute_unused const char * type, format_t format, const struct ast_channel * requestor, void * data, int * cause)
-#else /* #if ASTERISK_VERSION_NUM >= 10800 */
+#else /* 1.8- */
/* TODO: add check when request 'holdother' what requestor is not on same device for 1.6 */
static struct ast_channel * channel_request (attribute_unused const char * type, int format, void * data, int * cause)
-#endif /* #if ASTERISK_VERSION_NUM >= 10800 */
+#endif
{
-#if ASTERISK_VERSION_NUM >= 10800
+#if ASTERISK_VERSION_NUM >= 10800 && ASTERISK_VERSION_NUM < 100000 /* 1.8+ .. 10- */
format_t oldformat;
-#else
+#elif ASTERISK_VERSION_NUM < 10800 /* 1.8- */
int oldformat;
const struct ast_channel * requestor = NULL;
#endif
@@ -126,11 +130,18 @@
return NULL;
}
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ if (!ast_format_cap_iscompatible(cap, &chan_dongle_format))
+#else
oldformat = format;
format &= AST_FORMAT_SLINEAR;
if (!format)
+#endif
{
-#if ASTERISK_VERSION_NUM >= 10800
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ char buf[255];
+ ast_log (LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple (buf, 255, cap));
+#elif ASTERISK_VERSION_NUM >= 10800 /* 1.8+ */
ast_log (LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname (oldformat));
#else
ast_log (LOG_WARNING, "Asked to get a channel of unsupported format '%d'\n", oldformat);
@@ -571,10 +582,12 @@
}
-#if ASTERISK_VERSION_NUM >= 10800
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+#define subclass_integer subclass.integer
+#elif ASTERISK_VERSION_NUM >= 10800 /* 1.8+ */
#define subclass_codec subclass.codec
#define subclass_integer subclass.integer
-#else
+#else /* 1.8- */
#define subclass_codec subclass
#define subclass_integer subclass
#endif
@@ -618,7 +631,11 @@
memset (&cpvt->a_read_frame, 0, sizeof (cpvt->a_read_frame));
cpvt->a_read_frame.frametype = AST_FRAME_VOICE;
- cpvt->a_read_frame.subclass_codec= AST_FORMAT_SLINEAR;
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ ast_format_copy(&cpvt->a_read_frame.subclass.format, &chan_dongle_format);
+#else
+ cpvt->a_read_frame.subclass_codec = AST_FORMAT_SLINEAR;
+#endif
cpvt->a_read_frame.data.ptr = cpvt->a_read_buf + AST_FRIENDLY_OFFSET;
cpvt->a_read_frame.offset = AST_FRIENDLY_OFFSET;
cpvt->a_read_frame.src = AST_MODULE;
@@ -732,7 +749,11 @@
size_t count;
int gains[2];
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ if (f->frametype != AST_FRAME_VOICE || f->subclass.format.id != AST_FORMAT_SLINEAR)
+#else /* 10- */
if (f->frametype != AST_FRAME_VOICE || f->subclass_codec != AST_FORMAT_SLINEAR)
+#endif
{
return 0;
}
@@ -1148,9 +1169,15 @@
channel->tech_pvt = cpvt;
channel->tech = &channel_tech;
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ ast_format_cap_add(channel->nativeformats, &chan_dongle_format);
+ ast_format_copy(&channel->writeformat, &chan_dongle_format);
+ ast_format_copy(&channel->readformat, &chan_dongle_format);
+#else /* 10- */
channel->nativeformats = AST_FORMAT_SLINEAR;
channel->writeformat = AST_FORMAT_SLINEAR;
channel->readformat = AST_FORMAT_SLINEAR;
+#endif
if (ast_state == AST_STATE_RING)
{
@@ -1238,9 +1265,11 @@
snprintf (channel_name, sizeof (channel_name), "%s@%s", exten, CONF_SHARED(pvt, context));
-#if ASTERISK_VERSION_NUM >= 10800
+#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
+ channel = ast_request ("Local", chan_dongle_format_cap, NULL, channel_name, &cause);
+#elif ASTERISK_VERSION_NUM >= 10800 /* 1.8+ */
channel = ast_request ("Local", AST_FORMAT_AUDIO_MASK, NULL, channel_name, &cause);
-#else
+#else /* 1.8- */
channel = ast_request ("Local", AST_FORMAT_AUDIO_MASK, channel_name, &cause);
#endif
if (channel)
@@ -1314,7 +1343,6 @@
static int channel_func_write(struct ast_channel* channel, const char* function, char* data, const char* value)
{
struct cpvt* cpvt = channel->tech_pvt;
- struct pvt* pvt;
call_state_t newstate, oldstate;
int ret = 0;
@@ -1323,7 +1351,6 @@
ast_log (LOG_WARNING, "call on unreferenced %s\n", channel->name);
return -1;
}
- pvt = cpvt->pvt;
if (!strcasecmp(data, "callstate"))
{
@@ -1366,11 +1393,13 @@
return ret;
}
-EXPORT_DEF const struct ast_channel_tech channel_tech =
+EXPORT_DEF struct ast_channel_tech channel_tech =
{
.type = "Dongle",
.description = MODULE_DESCRIPTION,
+#if ASTERISK_VERSION_NUM < 100000 /* 10- */
.capabilities = AST_FORMAT_SLINEAR,
+#endif
.requester = channel_request,
.call = channel_call,
.hangup = channel_hangup,
--- a/channel_o.h 2011-11-23 14:05:43.206424916 +0200
+++ b/channel.h 2011-11-23 14:06:24.611334658 +0200
@@ -19,7 +19,7 @@
struct pvt;
struct cpvt;
-EXPORT_DECL const struct ast_channel_tech channel_tech;
+EXPORT_DECL struct ast_channel_tech channel_tech;
EXPORT_DECL struct ast_channel* new_channel (struct pvt * pvt, int ast_state, const char * cid_num, int call_idx, unsigned dir, unsigned state, const char * exten, const struct ast_channel * requestor);
EXPORT_DECL int queue_control_channel (struct cpvt * cpvt, enum ast_control_frame_type control);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment