Added patch to support Asterisk 13 from Michael Kuron.

This commit is contained in:
MelwareDE 2017-01-15 17:12:14 +00:00
parent c6946a40c8
commit a054dff7ae
8 changed files with 292 additions and 72 deletions

View File

@ -8,6 +8,7 @@ HEAD
- check for bchannel information element on incoming call
- added 't' option to select in-band tones available indication as Q.931
(thanks to Maciej S. Szmigiero <mail@maciej.szmigiero.name>)
- support for Asterisk 13 (thanks to Michael Kuron <m.kuron@gmx.de>)
chan_capi-1.1.6

View File

@ -42,6 +42,11 @@
#ifdef CC_AST_HAS_VERSION_1_8
#include <asterisk/callerid.h>
#endif
#ifdef CC_AST_HAS_VERSION_13_0
#include "asterisk/smoother.h"
#include "asterisk/pickup.h"
#include "asterisk/features_config.h"
#endif
struct _diva_streaming_vector* vind;
#ifdef DIVA_STREAMING
#include "platform.h"
@ -1120,7 +1125,13 @@ static int pbx_capi_alert(struct ast_channel *c)
}
i->state = CAPI_STATE_ALERTING;
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_lock(c);
#endif
ast_setstate(c, AST_STATE_RING);
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(c);
#endif
return 0;
}
@ -1459,7 +1470,13 @@ static int pbx_capi_hangup(struct ast_channel *c)
cc_mutex_unlock(&i->lock);
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_lock(c);
#endif
ast_setstate(c, AST_STATE_DOWN);
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(c);
#endif
#ifdef CC_AST_HAS_VERSION_1_4
ast_atomic_fetchadd_int(&usecnt, -1);
@ -2180,6 +2197,7 @@ static int line_interconnect(struct capi_pvt *i0, struct capi_pvt *i1, int start
/*
* try call transfer instead of bridge
*/
#ifndef CC_AST_HAS_VERSION_13_0
static int pbx_capi_bridge_transfer(
struct ast_channel *c0,
struct ast_channel *c1,
@ -2314,6 +2332,7 @@ static int pbx_capi_bridge_transfer(
return ret;
}
#endif
/*
* activate / deactivate b-channel bridge
@ -2360,6 +2379,7 @@ static int capi_bridge(int start, struct capi_pvt *i0, struct capi_pvt *i1, int
/*
* native bridging / line interconnect
*/
#ifndef CC_AST_HAS_VERSION_13_0
static CC_BRIDGE_RETURN pbx_capi_bridge(
struct ast_channel *c0,
struct ast_channel *c1,
@ -2451,11 +2471,16 @@ static CC_BRIDGE_RETURN pbx_capi_bridge(
return ret;
}
#endif
/*
* a new channel is needed
*/
#ifdef CC_AST_HAS_VERSION_13_0
static struct ast_channel *capi_new(struct capi_pvt *i, int state, const struct ast_channel *requestor)
#else
static struct ast_channel *capi_new(struct capi_pvt *i, int state, const char *linkedid)
#endif
{
struct ast_channel *tmp;
int fmt;
@ -2464,6 +2489,9 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state, const char *l
tmp = ast_channel_alloc(0, state, i->cid, emptyid,
#ifdef CC_AST_HAS_EXT2_CHAN_ALLOC
i->accountcode, i->dnid, i->context,
#ifdef CC_AST_HAS_VERSION_13_0
NULL, requestor,
#endif
#ifdef CC_AST_HAS_LINKEDID_CHAN_ALLOC
linkedid,
#endif
@ -2605,10 +2633,17 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state, const char *l
struct ast_format_cap *cur_nativefmts = tmp->nativeformats;
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_str *format_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
#endif
cc_verbose(3, 1, VERBOSE_PREFIX_2 "%s: setting format %s - %s%s\n",
i->vname, cc_getformatname(fmt),
ast_getformatname_multiple(alloca(80), 80,
cur_nativefmts),
#ifdef CC_AST_HAS_VERSION_13_0
ast_format_cap_get_names(cur_nativefmts, &format_buf),
#else
ast_getformatname_multiple(alloca(80), 80, cur_nativefmts),
#endif
(i->bproto == CC_BPROTO_VOCODER) ? "VOCODER" : ((i->rtp) ? " (RTP)" : ""));
if (!ast_strlen_zero(i->cid)) {
@ -2690,6 +2725,10 @@ static struct ast_channel *capi_new(struct capi_pvt *i, int state, const char *l
ast_setstate(tmp, state);
#endif
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(tmp);
#endif
return tmp;
}
@ -2707,9 +2746,12 @@ pbx_capi_request(const char *type, int format, const struct ast_channel *request
#elif !defined(CC_AST_HAS_VERSION_11_0) /* } { */
static struct ast_channel *
pbx_capi_request(const char *type, struct ast_format_cap *format, const struct ast_channel *requestor, void *data, int *cause)
#else /* } { */
#elif !defined(CC_AST_HAS_VERSION_13_0) /* } { */
static struct ast_channel *
pbx_capi_request(const char *type, struct ast_format_cap *format, const struct ast_channel *requestor, const char *data, int *cause)
#else /* } { */
static struct ast_channel *
pbx_capi_request(const char *type, struct ast_format_cap *format, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
#endif /* } */
#else /* } { */
@ -2724,10 +2766,18 @@ pbx_capi_request(const char *type, int format, void *data, int *cause)
ast_group_t capigroup = 0;
unsigned int controller = 0;
unsigned int ccbsnrhandle = 0;
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_str *format_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
#endif
cc_verbose(1, 1, VERBOSE_PREFIX_4 "data = %s format=%s\n",
(char *)data,
ast_getformatname_multiple(alloca(80), 80, format));
#ifdef CC_AST_HAS_VERSION_13_0
ast_format_cap_get_names(format, &format_buf)
#else
ast_getformatname_multiple(alloca(80), 80, format)
#endif
);
cc_copy_string(buffer, (char *)data, sizeof(buffer));
capi_parse_dialstring(buffer, &interface, &dest, &param, &ocid);
@ -2814,11 +2864,13 @@ found_best_channel:
cc_mutex_unlock(&iflock);
tmp = capi_new(i, AST_STATE_RESERVED,
#ifdef CC_AST_HAS_REQUEST_REQUESTOR
#ifdef CC_AST_HAS_VERSION_11_0
#ifdef CC_AST_HAS_VERSION_13_0
requestor
#elif defined(CC_AST_HAS_VERSION_11_0)
requestor ? ast_channel_linkedid(requestor) : NULL
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
#else /* !defined(CC_AST_HAS_VERSION_13_0) */
requestor ? requestor->linkedid : NULL
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
#endif /* defined(CC_AST_HAS_REQUEST_REQUESTOR) */
#else
NULL
#endif
@ -3867,7 +3919,6 @@ static int search_did(struct ast_channel *c)
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_context = ast_channel_context(c);
char *cur_exten = (char*)ast_channel_exten(c);
const char *cur_name = ast_channel_name(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_context = c->context;
@ -3981,7 +4032,6 @@ static void start_pbx_on_match(struct capi_pvt *i, unsigned int PLCI, _cword Mes
#ifdef CC_AST_HAS_VERSION_11_0
const char *cur_name = ast_channel_name(c);
char *cur_exten = (char *)ast_channel_exten(c);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
const char *cur_name = c->name;
char *cur_exten = (char *)c->exten;
@ -3998,7 +4048,15 @@ static void start_pbx_on_match(struct capi_pvt *i, unsigned int PLCI, _cword Mes
}
/* check for internal pickup extension first */
#ifdef CC_AST_HAS_VERSION_13_0
RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
const char *pickupexten;
pickup_cfg = ast_get_chan_features_pickup_config(c);
pickupexten = ast_strdupa(pickup_cfg->pickupexten);
if (!strcmp(i->dnid, pickupexten)) {
#else
if (!strcmp(i->dnid, ast_pickup_ext())) {
#endif
i->isdnstate |= CAPI_ISDN_STATE_PBX;
cc_verbose(3, 1, VERBOSE_PREFIX_2 "%s: Pickup extension '%s' found.\n",
i->vname, i->dnid);
@ -4015,7 +4073,13 @@ static void start_pbx_on_match(struct capi_pvt *i, unsigned int PLCI, _cword Mes
switch(search_did(c)) {
case 0: /* match */
i->isdnstate |= CAPI_ISDN_STATE_PBX;
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_lock(c);
#endif
ast_setstate(c, AST_STATE_RING);
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(c);
#endif
if (ast_pbx_start(c)) {
cc_log(LOG_ERROR, "%s: Unable to start pbx on channel!\n",
i->vname);
@ -4413,7 +4477,11 @@ static void capidev_handle_info_indication(_cmsg *CMSG, unsigned int PLCI, unsig
redirecting.from.number.presentation = 0;
redirecting.from.tag = 0;
#ifdef CC_AST_HAS_VERSION_13_0
redirecting.reason.code = AST_REDIRECTING_REASON_UNKNOWN;
#else
redirecting.reason = AST_REDIRECTING_REASON_UNKNOWN;
#endif
redirecting.count = 1;
ast_channel_set_redirecting(i->owner, &redirecting, &update_redirecting);
@ -4468,7 +4536,15 @@ static void capidev_handle_info_indication(_cmsg *CMSG, unsigned int PLCI, unsig
FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_RINGING;
local_queue_frame(i, &fr);
if (i->owner)
{
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_lock(i->owner);
#endif
ast_setstate(i->owner, AST_STATE_RINGING);
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(i->owner);
#endif
}
break;
case 0x8002: /* CALL PROCEEDING */
@ -5263,7 +5339,14 @@ static void capidev_handle_connect_active_indication(_cmsg *CMSG, unsigned int P
}
if ((i->owner) && (i->FaxState & CAPI_FAX_STATE_ACTIVE)) {
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_lock(i->owner);
#endif
ast_setstate(i->owner, AST_STATE_UP);
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(i->owner);
#endif
#ifndef CC_AST_HAS_VERSION_13_0
#ifdef CC_AST_HAS_VERSION_11_0
struct ast_cdr *owner_cdr = ast_channel_cdr(i->owner);
#else /* !defined(CC_AST_HAS_VERSION_11_0) */
@ -5271,6 +5354,7 @@ static void capidev_handle_connect_active_indication(_cmsg *CMSG, unsigned int P
#endif /* defined(CC_AST_HAS_VERSION_11_0) */
if (owner_cdr)
ast_cdr_answer(owner_cdr);
#endif
return;
}
@ -8609,7 +8693,9 @@ struct ast_channel_tech capi_tech = {
.answer = pbx_capi_answer,
.read = pbx_capi_read,
.write = pbx_capi_write,
#ifndef CC_AST_HAS_VERSION_13_0
.bridge = pbx_capi_bridge,
#endif
.exception = NULL,
.indicate = pbx_capi_indicate,
.fixup = pbx_capi_fixup,
@ -8867,7 +8953,11 @@ static int conf_interface(struct cc_capi_conf *conf, struct ast_variable *v)
char faxdest[AST_MAX_EXTENSION+1];
char *p, *q;
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format_cap *cap = ast_format_cap_alloc (AST_FORMAT_CAP_FLAG_DEFAULT);
#else
struct ast_format_cap *cap = ast_format_cap_alloc ();
#endif
#endif
memset(faxdest, 0, sizeof(faxdest));
@ -8972,7 +9062,11 @@ static int conf_interface(struct cc_capi_conf *conf, struct ast_variable *v)
continue;
} else
if (!strcasecmp(v->name, "amaflags")) {
#ifdef CC_AST_HAS_VERSION_13_0
y = ast_channel_string2amaflag(v->value);
#else
y = ast_cdr_amaflags2int(v->value);
#endif
if (y < 0) {
ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n",
v->value, v->lineno);
@ -9066,10 +9160,18 @@ static int conf_interface(struct cc_capi_conf *conf, struct ast_variable *v)
v->value);
} else
if (!strcasecmp(v->name, "allow")) {
#ifdef CC_AST_HAS_VERSION_13_0
cc_parse_allow_disallow(conf->capability, v->value, 1, cap);
#else
cc_parse_allow_disallow(&conf->prefs, &conf->capability, v->value, 1, cap);
#endif
} else
if (!strcasecmp(v->name, "disallow")) {
#ifdef CC_AST_HAS_VERSION_13_0
cc_parse_allow_disallow(conf->capability, v->value, 0, cap);
#else
cc_parse_allow_disallow(&conf->prefs, &conf->capability, v->value, 0, cap);
#endif
}
cc_pbx_qsig_conf_interface_value(conf, v);
}
@ -9096,7 +9198,9 @@ static int conf_interface(struct cc_capi_conf *conf, struct ast_variable *v)
if (faxpriority < 1) faxpriority = 1;
conf->faxpriority = faxpriority;
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
ao2_ref(cap, -1);
#elif defined(CC_AST_HAS_VERSION_10_0)
ast_format_cap_destroy(cap);
#endif
@ -9281,7 +9385,9 @@ int unload_module(void)
diva_verbose_unload();
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
ao2_ref(capi_tech.capabilities, -1);
#elif defined(CC_AST_HAS_VERSION_10_0)
capi_tech.capabilities = ast_format_cap_destroy(capi_tech.capabilities);
#endif
@ -9307,14 +9413,23 @@ int load_module(void)
#endif
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
if (!(capi_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
#else
if (!(capi_tech.capabilities = ast_format_cap_alloc())) {
#endif
return AST_MODULE_LOAD_DECLINE;
} else {
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * fmt = ast_format_alaw;
ast_format_cap_append(capi_tech.capabilities, fmt, 0);
#else
struct ast_format fmt;
ast_format_clear(&fmt);
ast_format_set(&fmt, AST_FORMAT_ALAW, 0);
ast_format_cap_add(capi_tech.capabilities, &fmt);
#endif
}
#endif
@ -9334,7 +9449,9 @@ int load_module(void)
if (!cfg) {
cc_log(LOG_ERROR, "Unable to load config %s, chan_capi disabled\n", config);
diva_verbose_unload();
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
ao2_ref(capi_tech.capabilities, -1);
#elif defined(CC_AST_HAS_VERSION_10_0)
capi_tech.capabilities = ast_format_cap_destroy(capi_tech.capabilities);
#endif
return 0;
@ -9343,7 +9460,9 @@ int load_module(void)
if (cc_mutex_lock(&iflock)) {
cc_log(LOG_ERROR, "Unable to lock interface list???\n");
diva_verbose_unload();
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
ao2_ref(capi_tech.capabilities, -1);
#elif defined(CC_AST_HAS_VERSION_10_0)
capi_tech.capabilities = ast_format_cap_destroy(capi_tech.capabilities);
#endif
return -1;
@ -9352,7 +9471,9 @@ int load_module(void)
if ((res = cc_init_capi()) != 0) {
cc_mutex_unlock(&iflock);
diva_verbose_unload();
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
ao2_ref(capi_tech.capabilities, -1);
#elif defined(CC_AST_HAS_VERSION_10_0)
capi_tech.capabilities = ast_format_cap_destroy(capi_tech.capabilities);
#endif
return 0;
@ -9364,7 +9485,9 @@ int load_module(void)
if (res != 0) {
cc_mutex_unlock(&iflock);
diva_verbose_unload();
#ifdef CC_AST_HAS_VERSION_10_0
#ifdef CC_AST_HAS_VERSION_13_0
ao2_ref(capi_tech.capabilities, -1);
#elif defined(CC_AST_HAS_VERSION_10_0)
capi_tech.capabilities = ast_format_cap_destroy(capi_tech.capabilities);
#endif
return(res);

View File

@ -43,6 +43,9 @@
#ifdef CC_AST_HAS_VERSION_1_4
#include "asterisk/abstract_jb.h"
#endif
#ifdef CC_AST_HAS_VERSION_13_0
#include <asterisk/format_compatibility.h>
#endif
#include "asterisk/musiconhold.h"
#include "dlist.h"
#include "chan_capi_fmt.h"
@ -149,15 +152,18 @@ static inline unsigned int read_capi_dword(const void *m)
#define FRAME_DATA_PTR data
#endif
#ifdef CC_AST_HAS_UNION_SUBCLASS_IN_FRAME
#if defined(CC_AST_HAS_UNION_SUBCLASS_IN_FRAME) || defined(CC_AST_HAS_VERSION_13_0)
#define FRAME_SUBCLASS_INTEGER(x) x.integer
#ifndef CC_AST_HAS_VERSION_10_0
#define SET_FRAME_SUBCLASS_CODEC(__a__,__b__) do {(__a__).codec = (__b__); }while(0)
#define GET_FRAME_SUBCLASS_CODEC(__a__) (__a__).codec
#else
#elif !defined(CC_AST_HAS_VERSION_13_0)
#define SET_FRAME_SUBCLASS_CODEC(__a__,__b__) do{ ast_format_from_old_bitfield(&(__a__).format, __b__); } while(0)
#define GET_FRAME_SUBCLASS_CODEC(__a__) ast_format_to_old_bitfield(&(__a__).format)
#else
#define SET_FRAME_SUBCLASS_CODEC(__a__,__b__) do{ (__a__).format = ast_format_compatibility_bitfield2format(__b__); } while(0)
#define GET_FRAME_SUBCLASS_CODEC(__a__) ast_format_compatibility_format2bitfield((__a__).format)
#endif
#else
@ -648,7 +654,9 @@ struct cc_capi_conf {
ast_group_t transfergroup;
float rxgain;
float txgain;
#ifndef CC_AST_HAS_VERSION_13_0
struct ast_codec_pref prefs;
#endif
#ifdef CC_AST_HAS_FORMAT_T
format_t capability;
#else

View File

@ -33,62 +33,29 @@
#define CC_FORMAT_SLINEAR16 (1ULL << 15)
#define CC_FORMAT_ULAW (1ULL << 2)
#ifdef CC_AST_HAS_VERSION_13_0
#include <asterisk/format_compatibility.h>
#include <asterisk/format_cache.h>
#endif
#ifdef CC_AST_HAS_VERSION_13_0
static inline struct ast_format * ccCodec2AstCodec(int ccCodec)
{
return (ast_format_compatibility_bitfield2format(ccCodec));
}
#else
static inline enum ast_format_id ccCodec2AstCodec(int ccCodec)
{
#if 0
unsigned int ret;
switch (ccCodec) {
case CC_FORMAT_ALAW:
ret = AST_FORMAT_ALAW;
break;
case CC_FORMAT_G722:
ret = AST_FORMAT_G722;
break;
case CC_FORMAT_G723_1:
ret = AST_FORMAT_G723_1;
break;
case CC_FORMAT_G726:
ret = AST_FORMAT_G726;
break;
case CC_FORMAT_G729A:
ret = AST_FORMAT_G729A;
break;
case CC_FORMAT_GSM:
ret = AST_FORMAT_GSM;
break;
case CC_FORMAT_ILBC:
ret = AST_FORMAT_ILBC;
break;
case CC_FORMAT_SIREN14:
ret = AST_FORMAT_SIREN14;
break;
case CC_FORMAT_SIREN7:
ret = AST_FORMAT_SIREN7;
break;
case CC_FORMAT_SLINEAR:
ret = AST_FORMAT_SLINEAR;
break;
case CC_FORMAT_SLINEAR16:
ret = AST_FORMAT_SLINEAR16;
break;
case CC_FORMAT_ULAW:
ret = AST_FORMAT_ULAW;
break;
default:
ret = 0;
break;
}
return ret;
#else
return (ast_format_id_from_old_bitfield(ccCodec));
#endif
}
#endif
static inline const char* cc_getformatname(int ccCodec)
{
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * id = ccCodec2AstCodec (ccCodec);
return ast_format_get_name(id);
#else
enum ast_format_id id = ccCodec2AstCodec (ccCodec);
struct ast_format fmt;
@ -96,6 +63,7 @@ static inline const char* cc_getformatname(int ccCodec)
ast_format_set(&fmt, id, 0);
return ast_getformatname(&fmt);
#endif
}
static inline void cc_add_formats(struct ast_format_cap *fmts, unsigned int divaFormats)
@ -106,18 +74,36 @@ static inline void cc_add_formats(struct ast_format_cap *fmts, unsigned int diva
unsigned int ccCodec = (1U << i);
if ((divaFormats & ccCodec) != 0) {
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * id = ccCodec2AstCodec (ccCodec);
ast_format_cap_append(fmts, id, 0);
#else
enum ast_format_id id = ccCodec2AstCodec (ccCodec);
struct ast_format fmt;
ast_format_clear(&fmt);
ast_format_set(&fmt, id, 0);
ast_format_cap_add(fmts, &fmt);
#endif
}
}
}
static inline int cc_set_best_codec(struct ast_channel *a)
{
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * bestCodec;
bestCodec = ast_format_cap_get_format(ast_channel_nativeformats(a), 0);
if (bestCodec == ast_format_none) {
bestCodec = ast_format_alaw;
}
ast_set_read_format(a, bestCodec);
ast_set_write_format(a, bestCodec);
return (int)ast_format_compatibility_format2bitfield(bestCodec);
#else
struct ast_format bestCodec;
ast_format_clear(&bestCodec);
@ -135,36 +121,98 @@ static inline int cc_set_best_codec(struct ast_channel *a)
ast_format_copy(ast_channel_writeformat(a), &bestCodec);
return (int)ast_format_to_old_bitfield(&bestCodec);
#endif
}
static inline void cc_set_read_format(struct ast_channel* a, int ccCodec)
{
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * ccFmt;
ccFmt = ccCodec2AstCodec(ccCodec);
ast_set_read_format(a, ccFmt);
#else
struct ast_format ccFmt;
ast_format_clear(&ccFmt);
ast_format_set(&ccFmt, ccCodec, 0);
ast_set_read_format(a, &ccFmt);
#endif
}
static inline void cc_set_write_format(struct ast_channel* a, int ccCodec)
{
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * ccFmt;
ccFmt = ccCodec2AstCodec(ccCodec);
ast_set_write_format(a, ccFmt);
#else
struct ast_format ccFmt;
ast_format_clear(&ccFmt);
ast_format_set(&ccFmt, ccCodec, 0);
ast_set_write_format(a, &ccFmt);
#endif
}
#ifdef CC_AST_HAS_VERSION_13_0
#define cc_parse_allow_disallow(__capability__, __value__, __allowing__, __cap__) do{\
__capability__ = ast_format_cap_update_by_allow_disallow(__cap__, __value__, __allowing__);}while(0)
static inline uint64_t cc_get_formats_as_bits(const struct ast_format_cap *cap)
{
uint64_t bitfield = 0;
int x;
for (x = 0; x < ast_format_cap_count(cap); x++) {
struct ast_format *format = ast_format_cap_get_format(cap, x);
bitfield |= ast_format_compatibility_format2bitfield(format);
ao2_ref(format, -1);
}
return bitfield;
}
#else
#define cc_parse_allow_disallow(__prefs__, __capability__, __value__, __allowing__, __cap__) do{\
ast_parse_allow_disallow(__prefs__, __cap__, __value__, __allowing__); \
*(__capability__) = (int)ast_format_cap_to_old_bitfield(__cap__); }while(0)
#define cc_get_formats_as_bits(__a__) (int)ast_format_cap_to_old_bitfield(__a__)
#endif
static inline int cc_get_best_codec_as_bits(int src)
{
struct ast_format_cap *dst = ast_format_cap_alloc_nolock();
int ret = 0;
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format_cap *dst;
struct ast_format *bestCodec;
int bit;
dst = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
for (bit = 0; bit < 64; ++bit) {
uint64_t mask = (1ULL << bit);
if (mask & src) {
struct ast_format *format;
format = ast_format_compatibility_bitfield2format(mask);
if (format && ast_format_cap_append(dst, format, 0)) {
return 0;
}
}
}
bestCodec = ast_format_cap_get_format(dst, 0);
ao2_ref(dst, -1);
ret = (int)ast_format_compatibility_format2bitfield(bestCodec);
#else
struct ast_format_cap *dst = ast_format_cap_alloc_nolock();
if (dst != 0) {
struct ast_format bestCodec;
@ -177,26 +225,33 @@ static inline int cc_get_best_codec_as_bits(int src)
ast_format_cap_destroy(dst);
}
#endif
return (ret);
}
#define cc_set_read_format(__a__, __b__) ast_set_read_format_by_id(__a__, ccCodec2AstCodec (__b__))
#define cc_set_write_format(__a__, __b__) ast_set_write_format_by_id(__a__, ccCodec2AstCodec (__b__))
static inline int cc_getformatbyname(const char* value)
{
#ifdef CC_AST_HAS_VERSION_13_0
struct ast_format * fmt;
int ret = 0;
fmt = ast_format_cache_get(value);
if (fmt) {
ret = (int)ast_format_compatibility_format2bitfield(fmt);
}
#else
struct ast_format fmt;
int ret = 0;
if (ast_getformatbyname(value, &fmt) != NULL) {
ret = (int)ast_format_to_old_bitfield(&fmt);
}
#endif
return (ret);
}
#else /* } { */
#else /* CC_AST_HAS_VERSION_10_0 */
#define CC_FORMAT_ALAW AST_FORMAT_ALAW
#ifdef AST_FORMAT_G722

View File

@ -1550,8 +1550,13 @@ void pbx_capi_qsig_handle_info_indication(_cmsg *CMSG, unsigned int PLCI, unsign
if (ii) {
cc_qsig_verbose( 1, VERBOSE_PREFIX_4 " * QSIG_PATHREPLACEMENT_PROPOSE: trying to complete bridge...\n");
#ifdef CC_AST_HAS_VERSION_13_0
chanx = ast_channel_bridge_peer(i->owner);
ast_channel_move(ii->owner, chanx);
#else
chanx = ast_bridged_channel(i->owner);
ast_channel_masquerade(ii->owner, chanx);
#endif
}
ast_free(i->qsig_data.pr_propose_cid);

View File

@ -373,6 +373,9 @@ static void ccbsnr_remote_user_free(_cmsg *CMSG, char type, unsigned int PLCI, _
c = ast_channel_alloc(0, state, handlename, NULL,
#ifdef CC_AST_HAS_EXT2_CHAN_ALLOC
0, ccbsnr->exten, ccbsnr->context,
#ifdef CC_AST_HAS_VERSION_13_0
NULL, NULL,
#endif
#ifdef CC_AST_HAS_LINKEDID_CHAN_ALLOC
NULL,
#endif
@ -448,6 +451,10 @@ static void ccbsnr_remote_user_free(_cmsg *CMSG, char type, unsigned int PLCI, _
cc_verbose(2, 1, VERBOSE_PREFIX_2 "contr%d: started PBX for CCBS/CCNR callback (%s/%s/%d)\n",
PLCI & 0xff, ccbsnr->context, ccbsnr->exten, ccbsnr->priority);
}
#ifdef CC_AST_HAS_VERSION_13_0
ast_channel_unlock(c);
#endif
}
/*

View File

@ -43,6 +43,10 @@
#define CC_HW_STATE_OK(__x__) (1)
#endif
#ifdef CC_AST_HAS_VERSION_13_0
#include "asterisk/smoother.h"
#endif
int capidebug = 0;
char *emptyid = "\0";

View File

@ -42,6 +42,10 @@ if [ "$AVERSION" = "" ]; then
if [ $? -eq 0 ]; then
AVERSION="$(echo "$AVERSION" | sed -e 's/Asterisk //g')"
AVERSIONNUM="$(echo "$AVERSION" |sed -e 's/\.//g')"
echo $AVERSIONNUM | grep -q GIT
if [ $? -eq 0 ]; then
AVERSIONNUM=$(echo $AVERSIONNUM | awk -F '-' '{print $2}')
fi
# Set VER later automatically based on $AVERSIONNUM.
else
AVERSION="trunk"
@ -64,6 +68,15 @@ echo "#define CHAN_CAPI_CONFIG_H" >>$CONFIGFILE
echo >>$CONFIGFILE
case "$AVERSIONNUM" in
13*)
echo "#define CC_AST_HAS_VERSION_1_6" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_1_8" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_10_0" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_11_0" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_13_0" >>$CONFIGFILE
echo " * found Asterisk version 13"
VER=13_0
;;
11*)
echo "#define CC_AST_HAS_VERSION_1_6" >>$CONFIGFILE
echo "#define CC_AST_HAS_VERSION_1_8" >>$CONFIGFILE
@ -317,6 +330,10 @@ case $VER in
echo "Using Asterisk 11.0 API"
check_version_onesix
;;
13_0)
echo "Using Asterisk 13.0 API"
check_version_onesix
;;
*)
echo >&2 "Asterisk version invalid."
exit 1