Update chan_ooh323 to support the expanded codec bitfield from 227580.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@227914 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jeff Peeler
2009-11-04 22:22:51 +00:00
parent 9530310954
commit f999554af7

View File

@@ -60,7 +60,7 @@ static struct ast_jb_conf default_jbconf =
static struct ast_jb_conf global_jbconf; static struct ast_jb_conf global_jbconf;
/* Channel Definition */ /* Channel Definition */
static struct ast_channel *ooh323_request(const char *type, int format, static struct ast_channel *ooh323_request(const char *type, format_t format,
const struct ast_channel *requestor, void *data, int *cause); const struct ast_channel *requestor, void *data, int *cause);
static int ooh323_digit_begin(struct ast_channel *ast, char digit); static int ooh323_digit_begin(struct ast_channel *ast, char digit);
static int ooh323_digit_end(struct ast_channel *ast, char digit, unsigned int duration); static int ooh323_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
@@ -76,7 +76,7 @@ static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan
static enum ast_rtp_glue_result ooh323_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp); static enum ast_rtp_glue_result ooh323_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp);
static enum ast_rtp_glue_result ooh323_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp); static enum ast_rtp_glue_result ooh323_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **rtp);
static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp,
struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active); struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active);
static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan); static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan);
static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl); static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
@@ -195,7 +195,7 @@ struct ooh323_user{
unsigned inUse; unsigned inUse;
char accountcode[20]; char accountcode[20];
int amaflags; int amaflags;
int capability; format_t capability;
struct ast_codec_pref prefs; struct ast_codec_pref prefs;
int dtmfmode; int dtmfmode;
int dtmfcodec; int dtmfcodec;
@@ -214,7 +214,7 @@ struct ooh323_peer{
char name[256]; char name[256];
unsigned outgoinglimit; unsigned outgoinglimit;
unsigned outUse; unsigned outUse;
int capability; format_t capability;
struct ast_codec_pref prefs; struct ast_codec_pref prefs;
char accountcode[20]; char accountcode[20];
int amaflags; int amaflags;
@@ -273,7 +273,7 @@ static int gPort = 1720;
static char gIP[20]; static char gIP[20];
static char gCallerID[AST_MAX_EXTENSION] = ""; static char gCallerID[AST_MAX_EXTENSION] = "";
static struct ooAliases *gAliasList; static struct ooAliases *gAliasList;
static int gCapability = AST_FORMAT_ULAW; static format_t gCapability = AST_FORMAT_ULAW;
static struct ast_codec_pref gPrefs; static struct ast_codec_pref gPrefs;
static int gDTMFMode = H323_DTMF_RFC2833; static int gDTMFMode = H323_DTMF_RFC2833;
static int gDTMFCodec = 101; static int gDTMFCodec = 101;
@@ -530,7 +530,7 @@ static struct ooh323_pvt *ooh323_alloc(int callref, char *callToken)
/* /*
Possible data values - peername, exten/peername, exten@ip Possible data values - peername, exten/peername, exten@ip
*/ */
static struct ast_channel *ooh323_request(const char *type, int format, static struct ast_channel *ooh323_request(const char *type, format_t format,
const struct ast_channel *requestor, void *data, int *cause) const struct ast_channel *requestor, void *data, int *cause)
{ {
@@ -551,8 +551,7 @@ static struct ast_channel *ooh323_request(const char *type, int format,
oldformat = format; oldformat = format;
format &= AST_FORMAT_AUDIO_MASK; format &= AST_FORMAT_AUDIO_MASK;
if (!format) { if (!format) {
ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format " ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%Ld'\n", (long long) format);
"'%d'\n", format);
return NULL; return NULL;
} }
@@ -1070,13 +1069,14 @@ static int ooh323_write(struct ast_channel *ast, struct ast_frame *f)
{ {
struct ooh323_pvt *p = ast->tech_pvt; struct ooh323_pvt *p = ast->tech_pvt;
int res = 0; int res = 0;
char buf[256];
if (p) { if (p) {
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
if (f->frametype == AST_FRAME_MODEM) { if (f->frametype == AST_FRAME_MODEM) {
ast_debug(1, "Send UDPTL %d/%d len %d for %s\n", ast_debug(1, "Send UDPTL %d/%d len %d for %s\n",
f->frametype, f->subclass, f->datalen, ast->name); f->frametype, f->subclass.integer, f->datalen, ast->name);
if (p->udptl) if (p->udptl)
res = ast_udptl_write(p->udptl, f); res = ast_udptl_write(p->udptl, f);
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
@@ -1093,14 +1093,16 @@ static int ooh323_write(struct ast_channel *ast, struct ast_frame *f)
} }
if (!(f->subclass & ast->nativeformats)) { if (!(f->subclass.codec & ast->nativeformats)) {
if (ast->nativeformats != 0) { if (ast->nativeformats != 0) {
ast_log(LOG_WARNING, "Asked to transmit frame type %d," ast_log(LOG_WARNING,
" while native " "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
"formats is %d (read/write = %d/%d)\n", ast_getformatname(f->subclass.codec),
f->subclass, ast->nativeformats, ast->readformat, ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
ast->writeformat); ast_getformatname(ast->readformat),
ast_set_write_format(ast, f->subclass); ast_getformatname(ast->writeformat));
ast_set_write_format(ast, f->subclass.codec);
} else { } else {
/* ast_set_write_format(ast, f->subclass); /* ast_set_write_format(ast, f->subclass);
ast->nativeformats = f->subclass; */ ast->nativeformats = f->subclass; */
@@ -1560,7 +1562,7 @@ int ooh323_onReceivedDigit(OOH323CallData *call, const char *digit)
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
memset(&f, 0, sizeof(f)); memset(&f, 0, sizeof(f));
f.frametype = AST_FRAME_DTMF; f.frametype = AST_FRAME_DTMF;
f.subclass = digit[0]; f.subclass.integer = digit[0];
f.datalen = 0; f.datalen = 0;
f.samples = 800; f.samples = 800;
f.offset = 0; f.offset = 0;
@@ -3705,7 +3707,7 @@ int ooh323_convertAsteriskCapToH323Cap(int cap)
} }
static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp,
struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active) struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
{ {
/* XXX Deal with Video */ /* XXX Deal with Video */
struct ooh323_pvt *p; struct ooh323_pvt *p;
@@ -4058,7 +4060,7 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
case 5: case 5:
f = ast_udptl_read(p->udptl); /* UDPTL t.38 data */ f = ast_udptl_read(p->udptl); /* UDPTL t.38 data */
if (gH323Debug) ast_debug(1, "Got UDPTL %d/%d len %d for %s\n", if (gH323Debug) ast_debug(1, "Got UDPTL %d/%d len %d for %s\n",
f->frametype, f->subclass, f->datalen, ast->name); f->frametype, f->subclass.integer, f->datalen, ast->name);
break; break;
default: default:
@@ -4068,19 +4070,19 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
if (p->owner) { if (p->owner) {
/* We already hold the channel lock */ /* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE && !p->faxmode) { if (f->frametype == AST_FRAME_VOICE && !p->faxmode) {
if (f->subclass != p->owner->nativeformats) { if (f->subclass.codec != p->owner->nativeformats) {
ast_debug(1, "Oooh, format changed to %d\n", f->subclass); ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(f->subclass.codec));
p->owner->nativeformats = f->subclass; p->owner->nativeformats = f->subclass.codec;
ast_set_read_format(p->owner, p->owner->readformat); ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat); ast_set_write_format(p->owner, p->owner->writeformat);
} }
if ((p->dtmfmode & H323_DTMF_INBAND) && p->vad && if ((p->dtmfmode & H323_DTMF_INBAND) && p->vad &&
(f->subclass == AST_FORMAT_SLINEAR || f->subclass == AST_FORMAT_ALAW || (f->subclass.codec == AST_FORMAT_SLINEAR || f->subclass.codec == AST_FORMAT_ALAW ||
f->subclass == AST_FORMAT_ULAW)) { f->subclass.codec == AST_FORMAT_ULAW)) {
f = ast_dsp_process(p->owner, p->vad, f); f = ast_dsp_process(p->owner, p->vad, f);
if (f && (f->frametype == AST_FRAME_DTMF)) if (f && (f->frametype == AST_FRAME_DTMF))
ast_debug(1, "* Detected inband DTMF '%c'\n",f->subclass); ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass.integer);
} }
} }
} }