[asterisk-commits] tilghman: branch group/codec_bits r112067 - in /team/group/codec_bits: channe...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 31 16:46:34 CDT 2008
Author: tilghman
Date: Mon Mar 31 16:46:33 2008
New Revision: 112067
URL: http://svn.digium.com/view/asterisk?view=rev&rev=112067
Log:
Lots of changes to IAX2, not done yet, though
Modified:
team/group/codec_bits/channels/chan_iax2.c
team/group/codec_bits/main/frame.c
Modified: team/group/codec_bits/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/channels/chan_iax2.c?view=diff&rev=112067&r1=112066&r2=112067
==============================================================================
--- team/group/codec_bits/channels/chan_iax2.c (original)
+++ team/group/codec_bits/channels/chan_iax2.c Mon Mar 31 16:46:33 2008
@@ -190,29 +190,29 @@
/* T1, maybe ISDN */
const struct ast_extended_codec IAX_CAPABILITY_MEDBANDWIDTH = { { (-1 & \
- ~AST_FORMAT_SLINEAR & \
- ~AST_FORMAT_ULAW & \
- ~AST_FORMAT_ALAW & \
- ~AST_FORMAT_G722) }, };
+ ~AST_FORMAT_AUDIO_SLINEAR & \
+ ~AST_FORMAT_AUDIO_ULAW & \
+ ~AST_FORMAT_AUDIO_ALAW & \
+ ~AST_FORMAT_AUDIO_G722) }, };
/* A modem */
const struct ast_extended_codec IAX_CAPABILITY_LOWBANDWIDTH = { { (-1 & \
- ~AST_FORMAT_SLINEAR & \
- ~AST_FORMAT_ULAW & \
- ~AST_FORMAT_ALAW & \
- ~AST_FORMAT_G722 & \
- ~AST_FORMAT_G726 & \
- ~AST_FORMAT_G726_AAL2 & \
- ~AST_FORMAT_ADPCM) }, };
+ ~AST_FORMAT_AUDIO_SLINEAR & \
+ ~AST_FORMAT_AUDIO_ULAW & \
+ ~AST_FORMAT_AUDIO_ALAW & \
+ ~AST_FORMAT_AUDIO_G722 & \
+ ~AST_FORMAT_AUDIO_G726 & \
+ ~AST_FORMAT_AUDIO_G726_AAL2 & \
+ ~AST_FORMAT_AUDIO_ADPCM) }, };
const struct ast_extended_codec IAX_CAPABILITY_LOWFREE = { { (-1 & \
- ~AST_FORMAT_SLINEAR & \
- ~AST_FORMAT_ULAW & \
- ~AST_FORMAT_ALAW & \
- ~AST_FORMAT_G722 & \
- ~AST_FORMAT_G726 & \
- ~AST_FORMAT_G726_AAL2 & \
- ~AST_FORMAT_ADPCM & \
- ~AST_FORMAT_G723_1) }, };
+ ~AST_FORMAT_AUDIO_SLINEAR & \
+ ~AST_FORMAT_AUDIO_ULAW & \
+ ~AST_FORMAT_AUDIO_ALAW & \
+ ~AST_FORMAT_AUDIO_G722 & \
+ ~AST_FORMAT_AUDIO_G726 & \
+ ~AST_FORMAT_AUDIO_G726_AAL2 & \
+ ~AST_FORMAT_AUDIO_ADPCM & \
+ ~AST_FORMAT_AUDIO_G723_1) }, };
#define DEFAULT_MAXMS 2000 /* Must be faster than 2 seconds by default */
@@ -2448,17 +2448,15 @@
ast_cli(a->fd, " Defaddr->IP : %s Port %d\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
ast_cli(a->fd, " Username : %s\n", peer->username);
ast_cli(a->fd, " Codecs : ");
- ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability);
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), peer->capability);
ast_cli(a->fd, "%s\n", codec_buf);
ast_cli(a->fd, " Codec Order : (");
- for(x = 0; x < 32 ; x++) {
- codec.audio[0] = ast_codec_pref_index(&peer->prefs,x);
- if(!codec.audio[0])
+ for (x = 0; x < 32 ; x++) {
+ if (FMT_NOT(codec = ast_codec_pref_index(&peer->prefs, x))) {
break;
- ast_cli(a->fd, "%s", ast_getformatname(codec));
- if(x < 31 && ast_codec_pref_index(&peer->prefs,x+1))
- ast_cli(a->fd, "|");
+ }
+ ast_cli(a->fd, "%s%s", (x > 0 ? "|" : ""), ast_getformatname(codec));
}
if (!x)
@@ -3143,7 +3141,7 @@
}
struct create_addr_info {
- int capability;
+ struct ast_extended_codec capability;
unsigned int flags;
int maxtime;
int encmethods;
@@ -3699,12 +3697,12 @@
}
return AST_BRIDGE_FAILED_NOWARN;
}
- if (c0->nativeformats != c1->nativeformats) {
+ if (!FMT_EQ(c0->nativeformats, c1->nativeformats)) {
struct ast_str *str1 = ast_str_alloca(BITSTRING_SIZE), *str2 = ast_str_alloca(BITSTRING_SIZE);
char buf0[255];
char buf1[255];
- ast_getformatname_multiple(buf0, sizeof(buf0) -1, c0->nativeformats);
- ast_getformatname_multiple(buf1, sizeof(buf1) -1, c1->nativeformats);
+ ast_getformatname_multiple(buf0, sizeof(buf0), c0->nativeformats);
+ ast_getformatname_multiple(buf1, sizeof(buf1), c1->nativeformats);
ast_verb(3, "Operating with different codecs %s[%s] %s[%s] , can't native bridge...\n", ast_codec2bitstring(c0->nativeformats, &str1), buf0, ast_codec2bitstring(c1->nativeformats, &str2), buf1);
/* Remove from native mode */
lock_both(callno0, callno1);
@@ -4354,6 +4352,7 @@
memcpy(efh->encdata, workspace + padding, *datalen - sizeof(struct ast_iax2_full_enc_hdr));
f->frametype = fh->type;
if (f->frametype == AST_FRAME_VIDEO) {
+ /* XXX FIXME XXX */
f->subclass = uncompress_subclass(fh->csub & ~0x40) | ((fh->csub >> 6) & 0x1);
} else {
f->subclass = uncompress_subclass(fh->csub);
@@ -4501,7 +4500,7 @@
* Otherwise send a mini video frame
*/
if (((fts & 0xFFFF8000L) == (pvt->lastvsent & 0xFFFF8000L)) &&
- ((f->subclass & ~0x1) == pvt->svideoformat)
+ FMT_EQ(f->codec, pvt->svideoformat)
) {
now = 1;
sendmini = 1;
@@ -7766,6 +7765,7 @@
char caller_pref_buf[128];
struct ast_codec_pref pref;
char *using_prefs = "mine";
+ struct ast_str *str[3] = { ast_str_alloca(BITSTRING_SIZE), ast_str_alloca(BITSTRING_SIZE), ast_str_alloca(BITSTRING_SIZE) };
/* allocate an iax_frame with 4096 bytes of data buffer */
fr = alloca(sizeof(*fr) + 4096);
@@ -7808,6 +7808,7 @@
/* Retrieve the type and subclass */
f.frametype = fh->type;
if (f.frametype == AST_FRAME_VIDEO) {
+ /* XXX FIXME XXX */
f.subclass = uncompress_subclass(fh->csub & ~0x40) | ((fh->csub >> 6) & 0x1);
} else {
f.subclass = uncompress_subclass(fh->csub);
@@ -8084,7 +8085,7 @@
iaxs[fr->callno]->voiceformat = f.codec;
ast_debug(1, "Ooh, voice format changed to %s\n", ast_codec2bitstring(f.codec, &str));
if (iaxs[fr->callno]->owner) {
- int orignative;
+ struct ast_extended_codec orignative;
retryowner:
if (ast_channel_trylock(iaxs[fr->callno]->owner)) {
ast_mutex_unlock(&iaxsl[fr->callno]);
@@ -8095,9 +8096,10 @@
if (iaxs[fr->callno]) {
if (iaxs[fr->callno]->owner) {
orignative = iaxs[fr->callno]->owner->nativeformats;
- iaxs[fr->callno]->owner->nativeformats = f.subclass;
- if (iaxs[fr->callno]->owner->readformat)
+ iaxs[fr->callno]->owner->nativeformats = f.codec;
+ if (FMT_NZ(iaxs[fr->callno]->owner->readformat)) {
ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat);
+ }
iaxs[fr->callno]->owner->nativeformats = orignative;
ast_channel_unlock(iaxs[fr->callno]->owner);
}
@@ -8113,9 +8115,10 @@
}
}
if (f.frametype == AST_FRAME_VIDEO) {
- if (f.subclass != iaxs[fr->callno]->videoformat) {
- ast_debug(1, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
- iaxs[fr->callno]->videoformat = f.subclass & ~0x1;
+ if (!FMT_EQ(f.codec, iaxs[fr->callno]->videoformat)) {
+ struct ast_str *str = ast_str_alloca(BITSTRING_SIZE);
+ ast_debug(1, "Ooh, video format changed to %s\n", ast_codec2bitstring(f.codec, &str));
+ iaxs[fr->callno]->videoformat = f.codec;
}
}
if (f.frametype == AST_FRAME_IAX) {
@@ -8273,7 +8276,7 @@
} else {
using_prefs = "disabled";
}
- format = iaxs[fr->callno]->peerformat & iaxs[fr->callno]->capability;
+ format = FMT_AND(iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
memset(&pref, 0, sizeof(pref));
strcpy(caller_pref_buf, "disabled");
strcpy(host_pref_buf, "disabled");
@@ -8282,7 +8285,7 @@
/* If the information elements are in here... use them */
if (ies.codec_prefs)
ast_codec_pref_convert(&iaxs[fr->callno]->rprefs, ies.codec_prefs, 32, 0);
- if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) {
+ if (FMT_NZ(ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0))) {
/* If we are codec_first_choice we let the caller have the 1st shot at picking the codec.*/
if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) {
pref = iaxs[fr->callno]->rprefs;
@@ -8293,14 +8296,14 @@
} else
pref = iaxs[fr->callno]->prefs;
- format = ast_codec_choose(&pref, iaxs[fr->callno]->capability & iaxs[fr->callno]->peercapability, NULL, 0);
+ format = ast_codec_choose(&pref, FMT_AND(iaxs[fr->callno]->capability, iaxs[fr->callno]->peercapability), 0);
ast_codec_pref_string(&iaxs[fr->callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
ast_codec_pref_string(&iaxs[fr->callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
- if (!format) {
+ if (FMT_NOT(format)) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
- if (!format) {
+ format = FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ if (FMT_NOT(format)) {
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
@@ -8310,58 +8313,72 @@
return 1;
}
if (authdebug) {
- if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
- else
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested '%s' incompatible with our capability '%s'.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[1]));
+ } else {
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability %s/%s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->peercapability, &str[1]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[2]));
+ }
}
} else {
/* Pick one... */
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- if(!(iaxs[fr->callno]->peerformat & iaxs[fr->callno]->capability))
+ if (FMT_NOT(FMT_AND(iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability))) {
format = 0;
+ }
} else {
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOPREFS)) {
using_prefs = ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP) ? "reqonly" : "disabled";
memset(&pref, 0, sizeof(pref));
- format = ast_best_codec(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ format = ast_best_codec(FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability));
strcpy(caller_pref_buf,"disabled");
strcpy(host_pref_buf,"disabled");
} else {
using_prefs = "mine";
- if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) {
+ if (FMT_NZ(ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0))) {
/* Do the opposite of what we tried above. */
if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) {
- pref = iaxs[fr->callno]->prefs;
+ pref = iaxs[fr->callno]->prefs;
} else {
pref = iaxs[fr->callno]->rprefs;
using_prefs = "caller";
}
- format = ast_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability, NULL, 1);
+ format = ast_codec_choose(&pref, FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability), 1);
- } else /* if no codec_prefs IE do it the old way */
- format = ast_best_codec(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ } else { /* if no codec_prefs IE do it the old way */
+ format = ast_best_codec(FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability));
+ }
}
}
- if (!format) {
+ if (FMT_NZ(format)) {
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
- ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ ast_log(LOG_ERROR, "No best format in %s???\n", ast_codec2bitstring(FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability), &str[0]));
send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
if (!iaxs[fr->callno]) {
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability %s/%s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->peercapability, &str[1]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[2]));
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
break;
}
}
}
- if (format) {
+ if (FMT_NZ(format)) {
/* No authentication required, let them in */
memset(&ied1, 0, sizeof(ied1));
iax_ie_append_int(&ied1, IAX_IE_FORMAT, format);
@@ -8507,7 +8524,7 @@
iaxs[fr->callno]->peerformat = iaxs[fr->callno]->capability;
}
ast_verb(3, "Call accepted by %s (format %s)\n", ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), ast_getformatname(iaxs[fr->callno]->peerformat));
- if (!(iaxs[fr->callno]->peerformat & iaxs[fr->callno]->capability)) {
+ if (FMT_NOT(FMT_AND(iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability))) {
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
@@ -8516,8 +8533,12 @@
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
- if (authdebug)
- ast_log(LOG_NOTICE, "Rejected call to %s, format 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
+ if (authdebug) {
+ ast_log(LOG_NOTICE, "Rejected call to %s, format %s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[1]));
+ }
} else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
if (iaxs[fr->callno]->owner) {
@@ -8534,10 +8555,12 @@
if (iaxs[fr->callno] && iaxs[fr->callno]->owner) {
/* Setup read/write formats properly. */
- if (iaxs[fr->callno]->owner->writeformat)
- ast_set_write_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->writeformat);
- if (iaxs[fr->callno]->owner->readformat)
- ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat);
+ if (FMT_NZ(iaxs[fr->callno]->owner->writeformat)) {
+ ast_set_write_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->writeformat);
+ }
+ if (FMT_NZ(iaxs[fr->callno]->owner->readformat)) {
+ ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat);
+ }
ast_channel_unlock(iaxs[fr->callno]->owner);
}
}
@@ -8697,7 +8720,7 @@
} else {
using_prefs = "disabled";
}
- format = iaxs[fr->callno]->peerformat & iaxs[fr->callno]->capability;
+ format = FMT_AND(iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
memset(&pref, 0, sizeof(pref));
strcpy(caller_pref_buf, "disabled");
strcpy(host_pref_buf, "disabled");
@@ -8705,7 +8728,7 @@
using_prefs = "mine";
if (ies.codec_prefs)
ast_codec_pref_convert(&iaxs[fr->callno]->rprefs, ies.codec_prefs, 32, 0);
- if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) {
+ if (FMT_NZ(ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0))) {
if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) {
pref = iaxs[fr->callno]->rprefs;
using_prefs = "caller";
@@ -8715,21 +8738,31 @@
} else /* if no codec_prefs IE do it the old way */
pref = iaxs[fr->callno]->prefs;
- format = ast_codec_choose(&pref, iaxs[fr->callno]->capability & iaxs[fr->callno]->peercapability, NULL, 0);
+ format = ast_codec_choose(&pref, FMT_AND(iaxs[fr->callno]->capability, iaxs[fr->callno]->peercapability), 0);
ast_codec_pref_string(&iaxs[fr->callno]->rprefs, caller_pref_buf, sizeof(caller_pref_buf) - 1);
ast_codec_pref_string(&iaxs[fr->callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
- if (!format) {
+ if (FMT_NOT(format)) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- ast_debug(1, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
- format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
+ ast_debug(1, "We don't do requested format %s, falling back to peer capability %s\n", ast_getformatname(iaxs[fr->callno]->peerformat), ast_codec2bitstring(iaxs[fr->callno]->peercapability, &str[0]));
+ format = FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
}
- if (!format) {
+ if (FMT_NOT(format)) {
if (authdebug) {
- if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
- else
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, "
+ "requested %s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[1]));
+ } else {
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, "
+ "requested/capability %s/%s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->peercapability, &str[1]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[2]));
+ }
}
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -8742,38 +8775,50 @@
} else {
/* Pick one... */
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- if(!(iaxs[fr->callno]->peerformat & iaxs[fr->callno]->capability))
- format = 0;
+ if (FMT_NOT(FMT_AND(iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability))) {
+ format = AST_FMT_NULL_MASK;
+ }
} else {
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOPREFS)) {
using_prefs = ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP) ? "reqonly" : "disabled";
memset(&pref, 0, sizeof(pref));
format = ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP) ?
- iaxs[fr->callno]->peerformat : ast_best_codec(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ iaxs[fr->callno]->peerformat : ast_best_codec(FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability));
strcpy(caller_pref_buf,"disabled");
strcpy(host_pref_buf,"disabled");
} else {
using_prefs = "mine";
- if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) {
+ if (FMT_NZ(ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0))) {
/* Do the opposite of what we tried above. */
if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) {
- pref = iaxs[fr->callno]->prefs;
+ pref = iaxs[fr->callno]->prefs;
} else {
pref = iaxs[fr->callno]->rprefs;
using_prefs = "caller";
}
- format = ast_codec_choose(&pref, iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability, NULL, 1);
- } else /* if no codec_prefs IE do it the old way */
- format = ast_best_codec(iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ format = ast_codec_choose(&pref, FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability), 1);
+ } else { /* if no codec_prefs IE do it the old way */
+ format = ast_best_codec(FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability));
+ }
}
}
- if (!format) {
- ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ if (FMT_NOT(format)) {
+ ast_log(LOG_ERROR, "No best format in %s???\n", ast_codec2bitstring(FMT_AND(iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability), &str[0]));
if (authdebug) {
- if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
- else
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, "
+ "requested %s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[1]));
+ } else {
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, "
+ "requested/capability %s/%s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_codec2bitstring(iaxs[fr->callno]->peerformat, &str[0]),
+ ast_codec2bitstring(iaxs[fr->callno]->peercapability, &str[1]),
+ ast_codec2bitstring(iaxs[fr->callno]->capability, &str[2]));
+ }
}
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -8786,10 +8831,11 @@
}
}
}
- if (format) {
+ if (FMT_NZ(format)) {
/* Authentication received */
memset(&ied1, 0, sizeof(ied1));
- iax_ie_append_int(&ied1, IAX_IE_FORMAT, format);
+ /* FIXME full codec support */
+ iax_ie_append_int(&ied1, IAX_IE_FORMAT, format.audio[0]);
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACCEPT, 0, ied1.buf, ied1.pos, -1);
if (strcmp(iaxs[fr->callno]->exten, "TBD")) {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
@@ -9139,9 +9185,11 @@
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
} else if (minivid) {
f.frametype = AST_FRAME_VIDEO;
- if (iaxs[fr->callno]->videoformat > 0)
- f.subclass = iaxs[fr->callno]->videoformat | (ntohs(vh->ts) & 0x8000 ? 1 : 0);
- else {
+ if (FMT_NZ(iaxs[fr->callno]->videoformat)) {
+ /* XXX Not sure what this does XXX */
+ f.subclass = (ntohs(vh->ts) & 0x8000 ? 1 : 0);
+ f.codec = iaxs[fr->callno]->videoformat;
+ } else {
ast_log(LOG_WARNING, "Received mini frame before first full video frame\n ");
iax2_vnak(fr->callno);
ast_mutex_unlock(&iaxsl[fr->callno]);
@@ -9200,8 +9248,9 @@
if (f.datalen && (f.frametype == AST_FRAME_VOICE)) {
f.samples = ast_codec_get_samples(&f);
/* We need to byteswap incoming slinear samples from network byte order */
- if (f.subclass == AST_FORMAT_SLINEAR)
+ if (FMT_EQ(f.codec, AST_FMT_SLINEAR)) {
ast_frame_byteswap_be(&f);
+ }
} else
f.samples = 0;
iax_frame_wrap(fr, &f);
@@ -9656,7 +9705,7 @@
{
int callno;
int res;
- int fmt, native;
+ struct ast_extended_codec fmt, native;
struct sockaddr_in sin;
struct ast_channel *c;
struct parsed_dial_string pds;
@@ -9712,9 +9761,9 @@
if (c) {
/* Choose a format we can live with */
- if (c->nativeformats & format)
- c->nativeformats &= format;
- else {
+ if (FMT_NZ(FMT_AND(c->nativeformats, format))) {
+ c->nativeformats = FMT_AND(c->nativeformats, format);
+ } else {
native = c->nativeformats;
fmt = format;
res = ast_translator_best_choice(&fmt, &native);
@@ -11063,7 +11112,7 @@
ast_mutex_lock(&iaxsl[callno]);
ast_string_field_set(iaxs[callno], dproot, data);
- iaxs[callno]->capability.audio[0] = IAX_CAPABILITY_FULLBANDWIDTH;
+ iaxs[callno]->capability = IAX_CAPABILITY_FULLBANDWIDTH;
iax_ie_append_short(&ied, IAX_IE_VERSION, IAX_PROTO_VERSION);
iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, "TBD");
@@ -11074,8 +11123,9 @@
iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, pds.exten);
if (pds.username)
iax_ie_append_str(&ied, IAX_IE_USERNAME, pds.username);
- iax_ie_append_int(&ied, IAX_IE_FORMAT, IAX_CAPABILITY_FULLBANDWIDTH);
- iax_ie_append_int(&ied, IAX_IE_CAPABILITY, IAX_CAPABILITY_FULLBANDWIDTH);
+ /* XXX Add full codec support */
+ iax_ie_append_int(&ied, IAX_IE_FORMAT, IAX_CAPABILITY_FULLBANDWIDTH.audio[0]);
+ iax_ie_append_int(&ied, IAX_IE_CAPABILITY, IAX_CAPABILITY_FULLBANDWIDTH.audio[0]);
/* Keep password handy */
if (pds.password)
ast_string_field_set(iaxs[callno], secret, pds.password);
@@ -11380,7 +11430,8 @@
ast_getformatname_multiple(buf, len -1, peer->capability);
} else if (!strncasecmp(colname, "codec[", 6)) {
char *codecnum, *ptr;
- int index = 0, codec = 0;
+ int index = 0;
+ struct ast_extended_codec codec;
codecnum = strchr(colname, '[');
*codecnum = '\0';
@@ -11389,7 +11440,7 @@
*ptr = '\0';
}
index = atoi(codecnum);
- if((codec = ast_codec_pref_index(&peer->prefs, index))) {
+ if (FMT_NZ(codec = ast_codec_pref_index(&peer->prefs, index))) {
ast_copy_string(buf, ast_getformatname(codec), len);
}
}
Modified: team/group/codec_bits/main/frame.c
URL: http://svn.digium.com/view/asterisk/team/group/codec_bits/main/frame.c?view=diff&rev=112067&r1=112066&r2=112067
==============================================================================
--- team/group/codec_bits/main/frame.c (original)
+++ team/group/codec_bits/main/frame.c Mon Mar 31 16:46:33 2008
@@ -511,12 +511,12 @@
return AST_FORMAT_LIST;
}
-char* ast_getformatname(int format)
+char *ast_getformatname(struct ast_extended_codec format)
{
int x;
char *ret = "unknown";
for (x = 0; x < sizeof(AST_FORMAT_LIST) / sizeof(AST_FORMAT_LIST[0]); x++) {
- if (AST_FORMAT_LIST[x].bits == format) {
+ if (FMT_EQ(AST_FORMAT_LIST[x].bits, format)) {
ret = AST_FORMAT_LIST[x].name;
break;
}
@@ -524,14 +524,15 @@
return ret;
}
-char *ast_getformatname_multiple(char *buf, size_t size, int format)
+char *ast_getformatname_multiple(char *buf, size_t size, struct ast_extended_codec format)
{
int x;
unsigned len;
char *start, *end = buf;
- if (!size)
+ if (!size) {
return buf;
+ }
snprintf(end, size, "0x%x (", format);
len = strlen(end);
end += len;
More information about the asterisk-commits
mailing list