aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-11-04 14:05:12 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-11-04 14:05:12 +0000
commit3bacd4082e2d3a2dd5b8b13635df956aa4f415cd (patch)
treedd3bc244b8a45aacb932109dc8c12d1f21769d55
parent1d3ce2ae5f81e30ec0704efe840bc2c9a24c7e8a (diff)
Expand codec bitfield from 32 bits to 64 bits.
Reviewboard: https://reviewboard.asterisk.org/r/416/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@227580 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_alarmreceiver.c6
-rw-r--r--apps/app_amd.c2
-rw-r--r--apps/app_chanspy.c2
-rw-r--r--apps/app_dahdibarge.c8
-rw-r--r--apps/app_dial.c36
-rw-r--r--apps/app_dictate.c8
-rw-r--r--apps/app_disa.c4
-rw-r--r--apps/app_echo.c4
-rw-r--r--apps/app_externalivr.c4
-rw-r--r--apps/app_fax.c20
-rw-r--r--apps/app_festival.c6
-rw-r--r--apps/app_followme.c8
-rw-r--r--apps/app_jack.c10
-rw-r--r--apps/app_meetme.c18
-rw-r--r--apps/app_milliwatt.c2
-rw-r--r--apps/app_mp3.c2
-rw-r--r--apps/app_nbscat.c2
-rw-r--r--apps/app_queue.c16
-rw-r--r--apps/app_record.c2
-rw-r--r--apps/app_sms.c2
-rw-r--r--apps/app_speech_utils.c6
-rw-r--r--apps/app_talkdetect.c6
-rw-r--r--apps/app_test.c2
-rw-r--r--apps/app_url.c4
-rw-r--r--apps/app_waitforring.c4
-rw-r--r--bridges/bridge_softmix.c8
-rw-r--r--channels/chan_agent.c27
-rw-r--r--channels/chan_alsa.c31
-rw-r--r--channels/chan_bridge.c4
-rw-r--r--channels/chan_console.c31
-rw-r--r--channels/chan_dahdi.c106
-rw-r--r--channels/chan_gtalk.c55
-rw-r--r--channels/chan_h323.c59
-rw-r--r--channels/chan_iax2.c348
-rw-r--r--channels/chan_jingle.c61
-rw-r--r--channels/chan_local.c18
-rw-r--r--channels/chan_mgcp.c83
-rw-r--r--channels/chan_misdn.c30
-rw-r--r--channels/chan_multicast_rtp.c6
-rw-r--r--channels/chan_oss.c33
-rw-r--r--channels/chan_phone.c59
-rw-r--r--channels/chan_sip.c164
-rw-r--r--channels/chan_skinny.c53
-rw-r--r--channels/chan_unistim.c75
-rw-r--r--channels/chan_vpb.cc75
-rw-r--r--channels/h323/chan_h323.h3
-rw-r--r--channels/iax2-parser.c65
-rw-r--r--channels/iax2-parser.h6
-rw-r--r--channels/iax2.h5
-rw-r--r--channels/sig_analog.c40
-rw-r--r--channels/sig_pri.c26
-rw-r--r--codecs/codec_dahdi.c12
-rw-r--r--codecs/codec_ulaw.c29
-rw-r--r--codecs/ex_adpcm.h2
-rw-r--r--codecs/ex_alaw.h2
-rw-r--r--codecs/ex_g722.h2
-rw-r--r--codecs/ex_g726.h2
-rw-r--r--codecs/ex_gsm.h2
-rw-r--r--codecs/ex_ilbc.h2
-rw-r--r--codecs/ex_lpc10.h2
-rw-r--r--codecs/ex_speex.h2
-rw-r--r--codecs/ex_ulaw.h2
-rwxr-xr-xconfigure6
-rw-r--r--configure.ac2
-rw-r--r--doc/codec-64bit.txt47
-rw-r--r--formats/format_g723.c4
-rw-r--r--formats/format_g726.c8
-rw-r--r--formats/format_g729.c6
-rw-r--r--formats/format_gsm.c6
-rw-r--r--formats/format_h263.c14
-rw-r--r--formats/format_h264.c10
-rw-r--r--formats/format_ilbc.c6
-rw-r--r--formats/format_jpeg.c4
-rw-r--r--formats/format_ogg_vorbis.c8
-rw-r--r--formats/format_pcm.c6
-rw-r--r--formats/format_siren14.c6
-rw-r--r--formats/format_siren7.c6
-rw-r--r--formats/format_sln.c6
-rw-r--r--formats/format_sln16.c6
-rw-r--r--formats/format_vox.c6
-rw-r--r--formats/format_wav.c6
-rw-r--r--formats/format_wav_gsm.c6
-rw-r--r--funcs/func_volume.c4
-rw-r--r--include/asterisk/abstract_jb.h4
-rw-r--r--include/asterisk/audiohook.h4
-rw-r--r--include/asterisk/autoconfig.h.in6
-rw-r--r--include/asterisk/bridging.h4
-rw-r--r--include/asterisk/bridging_technology.h4
-rw-r--r--include/asterisk/channel.h32
-rw-r--r--include/asterisk/compat.h8
-rw-r--r--include/asterisk/frame.h104
-rw-r--r--include/asterisk/frame_defs.h38
-rw-r--r--include/asterisk/pbx.h4
-rw-r--r--include/asterisk/rtp_engine.h28
-rw-r--r--include/asterisk/slin.h4
-rw-r--r--include/asterisk/slinfactory.h4
-rw-r--r--include/asterisk/translate.h58
-rw-r--r--include/asterisk/unaligned.h46
-rw-r--r--main/abstract_jb.c6
-rw-r--r--main/app.c16
-rw-r--r--main/asterisk.exports2
-rw-r--r--main/audiohook.c24
-rw-r--r--main/autoservice.c2
-rw-r--r--main/bridging.c53
-rw-r--r--main/channel.c203
-rw-r--r--main/dial.c4
-rw-r--r--main/dsp.c21
-rw-r--r--main/features.c34
-rw-r--r--main/file.c26
-rw-r--r--main/frame.c153
-rw-r--r--main/indications.c2
-rw-r--r--main/manager.c8
-rw-r--r--main/pbx.c8
-rw-r--r--main/rtp_engine.c103
-rw-r--r--main/slinfactory.c10
-rw-r--r--main/strcompat.c52
-rw-r--r--main/translate.c73
-rw-r--r--main/udptl.c8
-rw-r--r--pbx/pbx_spool.c2
-rw-r--r--res/res_adsi.c12
-rw-r--r--res/res_agi.c10
-rw-r--r--res/res_musiconhold.c12
-rw-r--r--res/res_rtp_asterisk.c62
-rw-r--r--res/res_rtp_multicast.c2
124 files changed, 1777 insertions, 1366 deletions
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index 6589ec36d..22dd4af67 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -191,7 +191,7 @@ static int send_tone_burst(struct ast_channel *chan, float freq, int duration, i
if (f->frametype == AST_FRAME_VOICE) {
wf.frametype = AST_FRAME_VOICE;
- wf.subclass = AST_FORMAT_ULAW;
+ wf.subclass.codec = AST_FORMAT_ULAW;
wf.offset = AST_FRIENDLY_OFFSET;
wf.mallocd = 0;
wf.data.ptr = tone_block.buf;
@@ -260,7 +260,7 @@ static int receive_dtmf_digits(struct ast_channel *chan, char *digit_string, int
}
/* If they hung up, leave */
- if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) {
+ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
if (f->data.uint32) {
chan->hangupcause = f->data.uint32;
}
@@ -275,7 +275,7 @@ static int receive_dtmf_digits(struct ast_channel *chan, char *digit_string, int
continue;
}
- digit_string[i++] = f->subclass; /* save digit */
+ digit_string[i++] = f->subclass.integer; /* save digit */
ast_frfree(f);
diff --git a/apps/app_amd.c b/apps/app_amd.c
index c5f08aba6..bb656cc39 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -188,7 +188,7 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
AST_APP_ARG(argMaximumWordLength);
);
- ast_verb(3, "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat);
+ ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name, chan->cid.cid_ani, chan->cid.cid_rdnis, ast_getformatname(chan->readformat));
/* Lets parse the arguments. */
if (!ast_strlen_zero(parse)) {
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index ad5ed7013..3f0944fc9 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -611,7 +611,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
continue;
}
- res = (f->frametype == AST_FRAME_DTMF) ? f->subclass : 0;
+ res = (f->frametype == AST_FRAME_DTMF) ? f->subclass.integer : 0;
ast_frfree(f);
if (!res)
continue;
diff --git a/apps/app_dahdibarge.c b/apps/app_dahdibarge.c
index 424ba3609..d9dd59054 100644
--- a/apps/app_dahdibarge.c
+++ b/apps/app_dahdibarge.c
@@ -208,17 +208,17 @@ dahdiretry:
f = ast_read(c);
if (!f)
break;
- if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) {
+ if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
ret = 0;
ast_frfree(f);
break;
} else if (fd != chan->fds[0]) {
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass == AST_FORMAT_ULAW) {
+ if (f->subclass.codec == AST_FORMAT_ULAW) {
/* Carefully write */
careful_write(fd, f->data.ptr, f->datalen);
} else
- ast_log(LOG_WARNING, "Huh? Got a non-ulaw (%d) frame in the conference\n", f->subclass);
+ ast_log(LOG_WARNING, "Huh? Got a non-ulaw (%s) frame in the conference\n", ast_getformatname(f->subclass.codec));
}
}
ast_frfree(f);
@@ -227,7 +227,7 @@ dahdiretry:
if (res > 0) {
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_VOICE;
- fr.subclass = AST_FORMAT_ULAW;
+ fr.subclass.codec = AST_FORMAT_ULAW;
fr.datalen = res;
fr.samples = res;
fr.data.ptr = buf;
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 910143d30..68a0b042c 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1004,7 +1004,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
continue;
}
if (f->frametype == AST_FRAME_CONTROL) {
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_ANSWER:
/* This is our guy if someone answered. */
if (!peer) {
@@ -1145,7 +1145,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
}
break;
default:
- ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer);
}
} else if (single) {
switch (f->frametype) {
@@ -1157,7 +1157,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
}
break;
case AST_FRAME_HTML:
- if (!ast_test_flag64(outgoing, DIAL_NOFORWARDHTML) && ast_channel_sendhtml(in, f->subclass, f->data.ptr, f->datalen) == -1) {
+ if (!ast_test_flag64(outgoing, DIAL_NOFORWARDHTML) && ast_channel_sendhtml(in, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
ast_log(LOG_WARNING, "Unable to send URL\n");
}
break;
@@ -1175,7 +1175,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
else if (!f || (f->frametype != AST_FRAME_VOICE))
printf("Hangup received on %s\n", in->name);
#endif
- if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
+ if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
/* Got hung up */
*to = -1;
strcpy(pa->status, "CANCEL");
@@ -1195,11 +1195,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
const char *context;
ast_channel_lock(in);
context = pbx_builtin_getvar_helper(in, "EXITCONTEXT");
- if (onedigit_goto(in, context, (char) f->subclass, 1)) {
- ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
+ if (onedigit_goto(in, context, (char) f->subclass.integer, 1)) {
+ ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
*to = 0;
ast_cdr_noanswer(in->cdr);
- *result = f->subclass;
+ *result = f->subclass.integer;
strcpy(pa->status, "CANCEL");
ast_frfree(f);
ast_channel_unlock(in);
@@ -1209,7 +1209,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
}
if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
- detect_disconnect(in, f->subclass, featurecode)) {
+ detect_disconnect(in, f->subclass.integer, featurecode)) {
ast_verb(3, "User requested call disconnect.\n");
*to = 0;
strcpy(pa->status, "CANCEL");
@@ -1221,7 +1221,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
/* Forward HTML stuff */
if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag64(outgoing, DIAL_NOFORWARDHTML))
- if (ast_channel_sendhtml(outgoing->chan, f->subclass, f->data.ptr, f->datalen) == -1)
+ if (ast_channel_sendhtml(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen) == -1)
ast_log(LOG_WARNING, "Unable to send URL\n");
if (single && ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF_BEGIN) || (f->frametype == AST_FRAME_DTMF_END))) {
@@ -1229,16 +1229,16 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
ast_log(LOG_WARNING, "Unable to forward voice or dtmf\n");
}
if (single && (f->frametype == AST_FRAME_CONTROL)) {
- if ((f->subclass == AST_CONTROL_HOLD) ||
- (f->subclass == AST_CONTROL_UNHOLD) ||
- (f->subclass == AST_CONTROL_VIDUPDATE) ||
- (f->subclass == AST_CONTROL_SRCUPDATE) ||
- (f->subclass == AST_CONTROL_REDIRECTING)) {
- ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
- ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
- } else if (f->subclass == AST_CONTROL_CONNECTED_LINE) {
+ if ((f->subclass.integer == AST_CONTROL_HOLD) ||
+ (f->subclass.integer == AST_CONTROL_UNHOLD) ||
+ (f->subclass.integer == AST_CONTROL_VIDUPDATE) ||
+ (f->subclass.integer == AST_CONTROL_SRCUPDATE) ||
+ (f->subclass.integer == AST_CONTROL_REDIRECTING)) {
+ ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass.integer, outgoing->chan->name);
+ ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
+ } else if (f->subclass.integer == AST_CONTROL_CONNECTED_LINE) {
if (ast_channel_connected_line_macro(in, outgoing->chan, f, 0, 1)) {
- ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
}
}
}
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index 816f15a14..e9e5f0d53 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -165,7 +165,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
samples = 0;
while (!done && ((res = ast_waitfor(chan, -1)) > -1) && fs && (f = ast_read(chan))) {
if (digit) {
- struct ast_frame fr = {AST_FRAME_DTMF, digit};
+ struct ast_frame fr = {AST_FRAME_DTMF, { .integer = digit } };
ast_queue_frame(chan, &fr);
digit = 0;
}
@@ -173,7 +173,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
int got = 1;
switch(mode) {
case DMODE_PLAY:
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case '1':
ast_set_flag(&flags, DFLAG_PAUSE);
mode = DMODE_RECORD;
@@ -202,7 +202,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
}
break;
case DMODE_RECORD:
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case '1':
ast_set_flag(&flags, DFLAG_PAUSE);
mode = DMODE_PLAY;
@@ -219,7 +219,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
got = 0;
}
if (!got) {
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case '#':
done = 1;
continue;
diff --git a/apps/app_disa.c b/apps/app_disa.c
index 49c7ad554..a64d05371 100644
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -220,7 +220,7 @@ static int disa_exec(struct ast_channel *chan, const char *data)
return -1;
}
- if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) {
+ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
if (f->data.uint32)
chan->hangupcause = f->data.uint32;
ast_frfree(f);
@@ -234,7 +234,7 @@ static int disa_exec(struct ast_channel *chan, const char *data)
continue;
}
- j = f->subclass; /* save digit */
+ j = f->subclass.integer; /* save digit */
ast_frfree(f);
if (!i) {
diff --git a/apps/app_echo.c b/apps/app_echo.c
index ac718b8b9..1c7211060 100644
--- a/apps/app_echo.c
+++ b/apps/app_echo.c
@@ -51,7 +51,7 @@ static const char app[] = "Echo";
static int echo_exec(struct ast_channel *chan, const char *data)
{
int res = -1;
- int format;
+ format_t format;
format = ast_best_codec(chan->nativeformats);
ast_set_write_format(chan, format);
@@ -68,7 +68,7 @@ static int echo_exec(struct ast_channel *chan, const char *data)
ast_frfree(f);
goto end;
}
- if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) {
+ if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) {
res = 0;
ast_frfree(f);
goto end;
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index 1dd1fc43e..725818175 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -627,7 +627,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- send_eivr_event(eivr_events, f->subclass, NULL, chan);
+ send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) {
if (!u->abort_current_sound && !u->playing_silence)
send_eivr_event(eivr_events, 'T', NULL, chan);
@@ -640,7 +640,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
u->abort_current_sound = 1;
AST_LIST_UNLOCK(&u->playlist);
}
- } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) {
+ } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
ast_chan_log(LOG_NOTICE, chan, "Got AST_CONTROL_HANGUP\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
if (f->data.uint32) {
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 39e00641a..6f6111639 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -180,7 +180,7 @@ static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uin
struct ast_frame outf = {
.frametype = AST_FRAME_MODEM,
- .subclass = AST_MODEM_T38,
+ .subclass.integer = AST_MODEM_T38,
.src = __FUNCTION__,
};
@@ -327,7 +327,7 @@ static int fax_generator_generate(struct ast_channel *chan, void *data, int len,
struct ast_frame outf = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.src = __FUNCTION__,
};
@@ -413,7 +413,7 @@ static int transmit_audio(fax_session *s)
return -1;
}
if ((inf->frametype == AST_FRAME_CONTROL) &&
- (inf->subclass == AST_CONTROL_T38_PARAMETERS) &&
+ (inf->subclass.integer == AST_CONTROL_T38_PARAMETERS) &&
(inf->datalen == sizeof(t38_parameters))) {
struct ast_control_t38_parameters *parameters = inf->data.ptr;
@@ -517,12 +517,12 @@ static int transmit_audio(fax_session *s)
break;
}
- ast_debug(10, "frame %d/%d, len=%d\n", inf->frametype, inf->subclass, inf->datalen);
+ ast_debug(10, "frame %d/%llu, len=%d\n", inf->frametype, (unsigned long long) inf->subclass.codec, inf->datalen);
/* Check the frame type. Format also must be checked because there is a chance
that a frame in old format was already queued before we set channel format
to slinear so it will still be received by ast_read */
- if (inf->frametype == AST_FRAME_VOICE && inf->subclass == AST_FORMAT_SLINEAR) {
+ if (inf->frametype == AST_FRAME_VOICE && inf->subclass.codec == AST_FORMAT_SLINEAR) {
if (fax_rx(&fax, inf->data.ptr, inf->samples) < 0) {
/* I know fax_rx never returns errors. The check here is for good style only */
ast_log(LOG_WARNING, "fax_rx returned error\n");
@@ -534,7 +534,7 @@ static int transmit_audio(fax_session *s)
last_state = t30state->state;
}
} else if ((inf->frametype == AST_FRAME_CONTROL) &&
- (inf->subclass == AST_CONTROL_T38_PARAMETERS)) {
+ (inf->subclass.integer == AST_CONTROL_T38_PARAMETERS)) {
struct ast_control_t38_parameters *parameters = inf->data.ptr;
if (parameters->request_response == AST_T38_NEGOTIATED) {
@@ -678,15 +678,15 @@ static int transmit_t38(fax_session *s)
break;
}
- ast_debug(10, "frame %d/%d, len=%d\n", inf->frametype, inf->subclass, inf->datalen);
+ ast_debug(10, "frame %d/%d, len=%d\n", inf->frametype, inf->subclass.integer, inf->datalen);
- if (inf->frametype == AST_FRAME_MODEM && inf->subclass == AST_MODEM_T38) {
+ if (inf->frametype == AST_FRAME_MODEM && inf->subclass.integer == AST_MODEM_T38) {
t38_core_rx_ifp_packet(t38state, inf->data.ptr, inf->datalen, inf->seqno);
if (last_state != t30state->state) {
state_change = ast_tvnow();
last_state = t30state->state;
}
- } else if (inf->frametype == AST_FRAME_CONTROL && inf->subclass == AST_CONTROL_T38_PARAMETERS) {
+ } else if (inf->frametype == AST_FRAME_CONTROL && inf->subclass.integer == AST_CONTROL_T38_PARAMETERS) {
struct ast_control_t38_parameters *parameters = inf->data.ptr;
if (parameters->request_response == AST_T38_TERMINATED) {
ast_debug(1, "T38 down, finishing\n");
@@ -733,7 +733,7 @@ disable_t38:
return -1;
}
if ((inf->frametype == AST_FRAME_CONTROL) &&
- (inf->subclass == AST_CONTROL_T38_PARAMETERS) &&
+ (inf->subclass.integer == AST_CONTROL_T38_PARAMETERS) &&
(inf->datalen == sizeof(t38_parameters))) {
struct ast_control_t38_parameters *parameters = inf->data.ptr;
diff --git a/apps/app_festival.c b/apps/app_festival.c
index 0b917a725..c547cfc6b 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -211,8 +211,8 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
}
if (f->frametype == AST_FRAME_DTMF) {
ast_debug(1, "User pressed a key\n");
- if (intkeys && strchr(intkeys, f->subclass)) {
- res = f->subclass;
+ if (intkeys && strchr(intkeys, f->subclass.integer)) {
+ res = f->subclass.integer;
ast_frfree(f);
break;
}
@@ -228,7 +228,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
res = read(fds[0], myf.frdata, needed);
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
- myf.f.subclass = AST_FORMAT_SLINEAR;
+ myf.f.subclass.codec = AST_FORMAT_SLINEAR;
myf.f.datalen = res;
myf.f.samples = res / 2;
myf.f.offset = AST_FRIENDLY_OFFSET;
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 363abb52a..db2d984b7 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -643,7 +643,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
f = ast_read(winner);
if (f) {
if (f->frametype == AST_FRAME_CONTROL) {
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
ast_verb(3, "%s received a hangup frame.\n", winner->name);
if (f->data.uint32) {
@@ -718,7 +718,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
ast_verb(3, "%s stopped sounds\n", winner->name);
break;
default:
- ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer);
break;
}
}
@@ -726,8 +726,8 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
if (winner->stream)
ast_stopstream(winner);
tmpuser->digts = 0;
- ast_debug(1, "DTMF received: %c\n",(char) f->subclass);
- tmpuser->yn[tmpuser->ynidx] = (char) f->subclass;
+ ast_debug(1, "DTMF received: %c\n", (char) f->subclass.integer);
+ tmpuser->yn[tmpuser->ynidx] = (char) f->subclass.integer;
tmpuser->ynidx++;
ast_debug(1, "DTMF string: %s\n", tmpuser->yn);
if (tmpuser->ynidx >= ynlongest) {
diff --git a/apps/app_jack.c b/apps/app_jack.c
index 8d8c1f8cc..e8f717b3f 100644
--- a/apps/app_jack.c
+++ b/apps/app_jack.c
@@ -604,7 +604,7 @@ static void handle_jack_audio(struct ast_channel *chan, struct jack_data *jack_d
short buf[160];
struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.src = "JACK",
.data.ptr = buf,
.datalen = sizeof(buf),
@@ -781,7 +781,7 @@ static int jack_exec(struct ast_channel *chan, const char *data)
switch (f->frametype) {
case AST_FRAME_CONTROL:
- if (f->subclass == AST_CONTROL_HANGUP)
+ if (f->subclass.integer == AST_CONTROL_HANGUP)
jack_data->stop = 1;
break;
case AST_FRAME_VOICE:
@@ -827,9 +827,9 @@ static int jack_hook_callback(struct ast_audiohook *audiohook, struct ast_channe
if (frame->frametype != AST_FRAME_VOICE)
return 0;
- if (frame->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Expected frame in SLINEAR for the audiohook, but got format %d\n",
- frame->subclass);
+ if (frame->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Expected frame in SLINEAR for the audiohook, but got format %s\n",
+ ast_getformatname(frame->subclass.codec));
return 0;
}
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 7636836f9..dedb7d14b 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -2931,11 +2931,11 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- dtmfstr[0] = f->subclass;
+ dtmfstr[0] = f->subclass.integer;
dtmfstr[1] = '\0';
}
- if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
+ if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.codec == AST_FORMAT_SLINEAR)) {
if (user->talk.actual) {
ast_frame_adjust_volume(f, user->talk.actual);
}
@@ -2987,7 +2987,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
careful_write(fd, f->data.ptr, f->datalen, 0);
}
}
- } else if (((f->frametype == AST_FRAME_DTMF) && (f->subclass == '*') && (confflags & CONFFLAG_STARMENU)) || ((f->frametype == AST_FRAME_DTMF) && menu_active)) {
+ } else if (((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '*') && (confflags & CONFFLAG_STARMENU)) || ((f->frametype == AST_FRAME_DTMF) && menu_active)) {
if (confflags & CONFFLAG_PASS_DTMF) {
conf_queue_dtmf(conf, user, f);
}
@@ -3020,7 +3020,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
dtmf = 0;
}
} else {
- dtmf = f->subclass;
+ dtmf = f->subclass.integer;
}
if (dtmf) {
switch(dtmf) {
@@ -3121,7 +3121,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
dtmf = 0;
}
} else {
- dtmf = f->subclass;
+ dtmf = f->subclass.integer;
}
if (dtmf) {
switch (dtmf) {
@@ -3211,7 +3211,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
} else {
ast_debug(2, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", dtmfstr, exitcontext);
}
- } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_KEYEXIT) && (strchr(exitkeys, f->subclass))) {
+ } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_KEYEXIT) && (strchr(exitkeys, f->subclass.integer))) {
pbx_builtin_setvar_helper(chan, "MEETME_EXIT_KEY", dtmfstr);
if (confflags & CONFFLAG_PASS_DTMF) {
@@ -3224,7 +3224,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
&& confflags & CONFFLAG_PASS_DTMF) {
conf_queue_dtmf(conf, user, f);
} else if ((confflags & CONFFLAG_SLA_STATION) && f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HOLD:
sla_queue_event_conf(SLA_EVENT_HOLD, chan, conf);
break;
@@ -3236,7 +3236,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
} else {
ast_debug(1,
"Got unrecognized frame on channel %s, f->frametype=%d,f->subclass=%d\n",
- chan->name, f->frametype, f->subclass);
+ chan->name, f->frametype, f->subclass.integer);
}
ast_frfree(f);
} else if (outfd > -1) {
@@ -3244,7 +3244,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
if (res > 0) {
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_VOICE;
- fr.subclass = AST_FORMAT_SLINEAR;
+ fr.subclass.codec = AST_FORMAT_SLINEAR;
fr.datalen = res;
fr.samples = res / 2;
fr.data.ptr = buf;
diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c
index b6d940384..24137606d 100644
--- a/apps/app_milliwatt.c
+++ b/apps/app_milliwatt.c
@@ -78,7 +78,7 @@ static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int
int i, *indexp = (int *) data;
struct ast_frame wf = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ULAW,
+ .subclass.codec = AST_FORMAT_ULAW,
.offset = AST_FRIENDLY_OFFSET,
.src = __FUNCTION__,
};
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 1cea8e329..b177fb027 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -169,7 +169,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata), timeout);
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
- myf.f.subclass = AST_FORMAT_SLINEAR;
+ myf.f.subclass.codec = AST_FORMAT_SLINEAR;
myf.f.datalen = res;
myf.f.samples = res / 2;
myf.f.mallocd = 0;
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index ec9347803..dd7637a83 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -148,7 +148,7 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
res = timed_read(fds[0], myf.frdata, sizeof(myf.frdata));
if (res > 0) {
myf.f.frametype = AST_FRAME_VOICE;
- myf.f.subclass = AST_FORMAT_SLINEAR;
+ myf.f.subclass.codec = AST_FORMAT_SLINEAR;
myf.f.datalen = res;
myf.f.samples = res / 2;
myf.f.mallocd = 0;
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 883b3d660..bdbb91560 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3299,7 +3299,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
f = ast_read(winner);
if (f) {
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_ANSWER:
/* This is our guy if someone answered. */
if (!peer) {
@@ -3389,7 +3389,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
}
break;
default:
- ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer);
break;
}
}
@@ -3413,7 +3413,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
/* If we received an event from the caller, deal with it. */
if (winner == in) {
f = ast_read(in);
- if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
+ if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
/* Got hung up */
*to = -1;
if (f) {
@@ -3424,16 +3424,16 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
}
return NULL;
}
- if ((f->frametype == AST_FRAME_DTMF) && caller_disconnect && (f->subclass == '*')) {
- ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
+ if ((f->frametype == AST_FRAME_DTMF) && caller_disconnect && (f->subclass.integer == '*')) {
+ ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
*to = 0;
ast_frfree(f);
return NULL;
}
- if ((f->frametype == AST_FRAME_DTMF) && valid_exit(qe, f->subclass)) {
- ast_verb(3, "User pressed digit: %c\n", f->subclass);
+ if ((f->frametype == AST_FRAME_DTMF) && valid_exit(qe, f->subclass.integer)) {
+ ast_verb(3, "User pressed digit: %c\n", f->subclass.integer);
*to = 0;
- *digit = f->subclass;
+ *digit = f->subclass.integer;
ast_frfree(f);
return NULL;
}
diff --git a/apps/app_record.c b/apps/app_record.c
index f6e067c84..ce4181d6a 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -372,7 +372,7 @@ static int record_exec(struct ast_channel *chan, const char *data)
break;
}
} else if ((f->frametype == AST_FRAME_DTMF) &&
- (f->subclass == terminator)) {
+ (f->subclass.integer == terminator)) {
ast_frfree(f);
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "DTMF");
break;
diff --git a/apps/app_sms.c b/apps/app_sms.c
index bed9f5c7e..6a2b0c03f 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1603,7 +1603,7 @@ static int sms_generate(struct ast_channel *chan, void *data, int len, int sampl
buf = alloca(len);
f.frametype = AST_FRAME_VOICE;
- f.subclass = __OUT_FMT;
+ f.subclass.codec = __OUT_FMT;
f.datalen = samples * sizeof(*buf);
f.offset = AST_FRIENDLY_OFFSET;
f.mallocd = 0;
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index cd1c4d106..28c37a31d 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -824,7 +824,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
/* Free the frame we received */
switch (f->frametype) {
case AST_FRAME_DTMF:
- if (dtmf_terminator != '\0' && f->subclass == dtmf_terminator) {
+ if (dtmf_terminator != '\0' && f->subclass.integer == dtmf_terminator) {
done = 1;
} else {
if (chan->stream != NULL) {
@@ -836,7 +836,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
started = 1;
}
start = ast_tvnow();
- snprintf(tmp, sizeof(tmp), "%c", f->subclass);
+ snprintf(tmp, sizeof(tmp), "%c", f->subclass.integer);
strncat(dtmf, tmp, sizeof(dtmf) - strlen(dtmf) - 1);
/* If the maximum length of the DTMF has been reached, stop now */
if (max_dtmf_len && strlen(dtmf) == max_dtmf_len)
@@ -844,7 +844,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
}
break;
case AST_FRAME_CONTROL:
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
/* Since they hung up we should destroy the speech structure */
done = 3;
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 83b8886cf..0db0012bc 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -173,15 +173,15 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
break;
} else if (fr->frametype == AST_FRAME_DTMF) {
char t[2];
- t[0] = fr->subclass;
+ t[0] = fr->subclass.integer;
t[1] = '\0';
if (ast_canmatch_extension(chan, chan->context, t, 1, chan->cid.cid_num)) {
/* They entered a valid extension, or might be anyhow */
- res = fr->subclass;
+ res = fr->subclass.integer;
ast_frfree(fr);
break;
}
- } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass == AST_FORMAT_SLINEAR) && continue_analysis) {
+ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass.codec == AST_FORMAT_SLINEAR) && continue_analysis) {
int totalsilence;
int ms;
res = ast_dsp_silence(dsp, fr, &totalsilence);
diff --git a/apps/app_test.c b/apps/app_test.c
index 64ce7b43f..a7aa7b657 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -106,7 +106,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
res = -1;
break;
}
- if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
+ if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.codec == AST_FORMAT_SLINEAR)) {
foo = (short *)f->data.ptr;
for (x=0;x<f->samples;x++) {
noise += abs(foo[x]);
diff --git a/apps/app_url.c b/apps/app_url.c
index a36daa26b..533c11212 100644
--- a/apps/app_url.c
+++ b/apps/app_url.c
@@ -139,7 +139,7 @@ static int sendurl_exec(struct ast_channel *chan, const char *data)
break;
}
if (f->frametype == AST_FRAME_HTML) {
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_HTML_LDCOMPLETE:
res = 0;
ast_frfree(f);
@@ -154,7 +154,7 @@ static int sendurl_exec(struct ast_channel *chan, const char *data)
goto out;
break;
default:
- ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass);
+ ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer);
};
}
ast_frfree(f);
diff --git a/apps/app_waitforring.c b/apps/app_waitforring.c
index dfe33db51..1df60795f 100644
--- a/apps/app_waitforring.c
+++ b/apps/app_waitforring.c
@@ -78,7 +78,7 @@ static int waitforring_exec(struct ast_channel *chan, const char *data)
res = -1;
break;
}
- if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) {
+ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) {
ast_verb(3, "Got a ring but still waiting for timeout\n");
}
ast_frfree(f);
@@ -99,7 +99,7 @@ static int waitforring_exec(struct ast_channel *chan, const char *data)
res = -1;
break;
}
- if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) {
+ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) {
ast_verb(3, "Got a ring after the timeout\n");
ast_frfree(f);
break;
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index a98038660..3cddc42e4 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -123,9 +123,9 @@ static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chan
/* Setup frame parameters */
sc->frame.frametype = AST_FRAME_VOICE;
#ifdef SOFTMIX_16_SUPPORT
- sc->frame.subclass = AST_FORMAT_SLINEAR16;
+ sc->frame.subclass.codec = AST_FORMAT_SLINEAR16;
#else
- sc->frame.subclass = AST_FORMAT_SLINEAR;
+ sc->frame.subclass.codec = AST_FORMAT_SLINEAR;
#endif
sc->frame.data.ptr = sc->final_buf;
sc->frame.datalen = SOFTMIX_DATALEN;
@@ -168,9 +168,9 @@ static enum ast_bridge_write_result softmix_bridge_write(struct ast_bridge *brid
/* If a frame was provided add it to the smoother */
#ifdef SOFTMIX_16_SUPPORT
- if (frame->frametype == AST_FRAME_VOICE && frame->subclass == AST_FORMAT_SLINEAR16) {
+ if (frame->frametype == AST_FRAME_VOICE && frame->subclass.codec == AST_FORMAT_SLINEAR16) {
#else
- if (frame->frametype == AST_FRAME_VOICE && frame->subclass == AST_FORMAT_SLINEAR) {
+ if (frame->frametype == AST_FRAME_VOICE && frame->subclass.codec == AST_FORMAT_SLINEAR) {
#endif
ast_slinfactory_feed(&sc->factory, frame);
}
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 0d0159cae..0bc35c0bf 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -280,10 +280,11 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (l
#define CHECK_FORMATS(ast, p) do { \
if (p->chan) {\
if (ast->nativeformats != p->chan->nativeformats) { \
- ast_debug(1, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
+ char tmp1[256], tmp2[256]; \
+ ast_debug(1, "Native formats changing from '%s' to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast->nativeformats), ast_getformatname_multiple(tmp2, sizeof(tmp2), p->chan->nativeformats)); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- ast_debug(1, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast->readformat), ast_getformatname_multiple(tmp2, sizeof(tmp2), ast->writeformat));\
ast_set_read_format(ast, ast->readformat); \
ast_set_write_format(ast, ast->writeformat); \
} \
@@ -310,7 +311,7 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (l
} while(0)
/*--- Forward declarations */
-static struct ast_channel *agent_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *agent_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int agent_devicestate(void *data);
static int agent_digit_begin(struct ast_channel *ast, char digit);
static int agent_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
@@ -529,7 +530,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
{
struct agent_pvt *p = ast->tech_pvt;
struct ast_frame *f = NULL;
- static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
+ static struct ast_frame answer_frame = { AST_FRAME_CONTROL, { AST_CONTROL_ANSWER } };
int cur_time = time(NULL);
ast_mutex_lock(&p->lock);
CHECK_FORMATS(ast, p);
@@ -566,7 +567,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
}
switch (f->frametype) {
case AST_FRAME_CONTROL:
- if (f->subclass == AST_CONTROL_ANSWER) {
+ if (f->subclass.integer == AST_CONTROL_ANSWER) {
if (p->ackcall) {
ast_verb(3, "%s answered, waiting for '%c' to acknowledge\n", p->chan->name, p->acceptdtmf);
/* Don't pass answer along */
@@ -583,18 +584,18 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
break;
case AST_FRAME_DTMF_BEGIN:
/*ignore DTMF begin's as it can cause issues with queue announce files*/
- if((!p->acknowledged && f->subclass == p->acceptdtmf) || (f->subclass == p->enddtmf && endcall)){
+ if((!p->acknowledged && f->subclass.integer == p->acceptdtmf) || (f->subclass.integer == p->enddtmf && endcall)){
ast_frfree(f);
f = &ast_null_frame;
}
break;
case AST_FRAME_DTMF_END:
- if (!p->acknowledged && (f->subclass == p->acceptdtmf)) {
+ if (!p->acknowledged && (f->subclass.integer == p->acceptdtmf)) {
ast_verb(3, "%s acknowledged\n", p->chan->name);
p->acknowledged = 1;
ast_frfree(f);
f = &answer_frame;
- } else if (f->subclass == p->enddtmf && endcall) {
+ } else if (f->subclass.integer == p->enddtmf && endcall) {
/* terminates call */
ast_frfree(f);
f = NULL;
@@ -660,7 +661,7 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
else {
if ((f->frametype != AST_FRAME_VOICE) ||
(f->frametype != AST_FRAME_VIDEO) ||
- (f->subclass == p->chan->writeformat)) {
+ (f->subclass.codec == p->chan->writeformat)) {
res = ast_write(p->chan, f);
} else {
ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n",
@@ -951,7 +952,7 @@ static int agent_ack_sleep(void *data)
if (!f)
return -1;
if (f->frametype == AST_FRAME_DTMF)
- res = f->subclass;
+ res = f->subclass.integer;
else
res = 0;
ast_frfree(f);
@@ -1334,7 +1335,7 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
}
/*! \brief Part of the Asterisk PBX interface */
-static struct ast_channel *agent_request(const char *type, int format, const struct ast_channel* requestor, void *data, int *cause)
+static struct ast_channel *agent_request(const char *type, format_t format, const struct ast_channel* requestor, void *data, int *cause)
{
struct agent_pvt *p;
struct ast_channel *chan = NULL;
@@ -1958,12 +1959,12 @@ static int login_exec(struct ast_channel *chan, const char *data)
if (!res) {
res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats));
if (res)
- ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats));
+ ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(chan->nativeformats)));
}
if (!res) {
res = ast_set_write_format(chan, ast_best_codec(chan->nativeformats));
if (res)
- ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats));
+ ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(chan->nativeformats)));
}
/* Check once more just in case */
if (p->chan)
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index ffc62c8b1..ca6c07897 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -130,7 +130,7 @@ static int writedev = -1;
static int autoanswer = 1;
-static struct ast_channel *alsa_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *alsa_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int alsa_digit(struct ast_channel *c, char digit, unsigned int duration);
static int alsa_text(struct ast_channel *c, const char *text);
static int alsa_hangup(struct ast_channel *c);
@@ -312,7 +312,7 @@ static int alsa_call(struct ast_channel *c, char *dest, int timeout)
ast_verbose(" << Auto-answered >> \n");
grab_owner();
if (alsa.owner) {
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
ast_queue_frame(alsa.owner, &f);
ast_channel_unlock(alsa.owner);
}
@@ -320,7 +320,7 @@ static int alsa_call(struct ast_channel *c, char *dest, int timeout)
ast_verbose(" << Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
grab_owner();
if (alsa.owner) {
- f.subclass = AST_CONTROL_RINGING;
+ f.subclass.integer = AST_CONTROL_RINGING;
ast_queue_frame(alsa.owner, &f);
ast_channel_unlock(alsa.owner);
ast_indicate(alsa.owner, AST_CONTROL_RINGING);
@@ -426,7 +426,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
ast_mutex_lock(&alsalock);
f.frametype = AST_FRAME_NULL;
- f.subclass = 0;
+ f.subclass.integer = 0;
f.samples = 0;
f.datalen = 0;
f.data.ptr = NULL;
@@ -471,7 +471,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
return &f;
}
f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
+ f.subclass.codec = AST_FORMAT_SLINEAR;
f.samples = FRAME_SIZE;
f.datalen = FRAME_SIZE * 2;
f.data.ptr = buf;
@@ -565,13 +565,14 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state, const ch
return tmp;
}
-static struct ast_channel *alsa_request(const char *type, int fmt, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *alsa_request(const char *type, format_t fmt, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat = fmt;
+ format_t oldformat = fmt;
+ char buf[256];
struct ast_channel *tmp = NULL;
if (!(fmt &= AST_FORMAT_SLINEAR)) {
- ast_log(LOG_NOTICE, "Asked to get a channel of format '%d'\n", oldformat);
+ ast_log(LOG_NOTICE, "Asked to get a channel of format '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), oldformat));
return NULL;
}
@@ -669,9 +670,7 @@ static char *console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
hookstate = 1;
grab_owner();
if (alsa.owner) {
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
-
- ast_queue_frame(alsa.owner, &f);
+ ast_queue_control(alsa.owner, AST_CONTROL_ANSWER);
ast_channel_unlock(alsa.owner);
}
}
@@ -709,7 +708,7 @@ static char *console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_a
ast_cli(a->fd, "No channel active\n");
res = CLI_FAILURE;
} else {
- struct ast_frame f = { AST_FRAME_TEXT, 0 };
+ struct ast_frame f = { AST_FRAME_TEXT };
char text2send[256] = "";
while (tmparg < a->argc) {
@@ -723,11 +722,7 @@ static char *console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_a
grab_owner();
if (alsa.owner) {
ast_queue_frame(alsa.owner, &f);
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_ANSWER;
- f.data.ptr = NULL;
- f.datalen = 0;
- ast_queue_frame(alsa.owner, &f);
+ ast_queue_control(alsa.owner, AST_CONTROL_ANSWER);
ast_channel_unlock(alsa.owner);
}
}
@@ -802,7 +797,7 @@ static char *console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_args
if (a->argc == 3) {
if (alsa.owner) {
for (d = a->argv[2]; *d; d++) {
- struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass = *d };
+ struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = *d };
ast_queue_frame(alsa.owner, &f);
}
diff --git a/channels/chan_bridge.c b/channels/chan_bridge.c
index be823cd32..db2646654 100644
--- a/channels/chan_bridge.c
+++ b/channels/chan_bridge.c
@@ -46,7 +46,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/bridging.h"
-static struct ast_channel *bridge_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *bridge_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int bridge_call(struct ast_channel *ast, char *dest, int timeout);
static int bridge_hangup(struct ast_channel *ast);
static struct ast_frame *bridge_read(struct ast_channel *ast);
@@ -189,7 +189,7 @@ static int bridge_hangup(struct ast_channel *ast)
}
/*! \brief Called when we want to place a call somewhere, but not actually call it... yet */
-static struct ast_channel *bridge_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *bridge_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct bridge_pvt *p = NULL;
diff --git a/channels/chan_console.c b/channels/chan_console.c
index ead0b1231..9141c3d1d 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -182,7 +182,7 @@ static struct ast_jb_conf default_jbconf = {
static struct ast_jb_conf global_jbconf;
/*! Channel Technology Callbacks @{ */
-static struct ast_channel *console_request(const char *type, int format,
+static struct ast_channel *console_request(const char *type, format_t format,
const struct ast_channel *requestor, void *data, int *cause);
static int console_digit_begin(struct ast_channel *c, char digit);
static int console_digit_end(struct ast_channel *c, char digit, unsigned int duration);
@@ -264,7 +264,7 @@ static void *stream_monitor(void *data)
PaError res;
struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR16,
+ .subclass.codec = AST_FORMAT_SLINEAR16,
.src = "console_stream_monitor",
.data.ptr = buf,
.datalen = sizeof(buf),
@@ -440,11 +440,12 @@ static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext,
return chan;
}
-static struct ast_channel *console_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *console_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat = format;
+ format_t oldformat = format;
struct ast_channel *chan = NULL;
struct console_pvt *pvt;
+ char buf[512];
if (!(pvt = find_pvt(data))) {
ast_log(LOG_ERROR, "Console device '%s' not found\n", (char *) data);
@@ -453,7 +454,7 @@ static struct ast_channel *console_request(const char *type, int format, const s
format &= SUPPORTED_FORMATS;
if (!format) {
- ast_log(LOG_NOTICE, "Channel requested with unsupported format(s): '%d'\n", oldformat);
+ ast_log(LOG_NOTICE, "Channel requested with unsupported format(s): '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), oldformat));
goto return_unref;
}
@@ -553,8 +554,8 @@ static struct ast_frame *console_read(struct ast_channel *chan)
static int console_call(struct ast_channel *c, char *dest, int timeout)
{
- struct ast_frame f = { 0, };
struct console_pvt *pvt = c->tech_pvt;
+ enum ast_control_frame_type ctrl;
ast_verb(1, V_BEGIN "Call to device '%s' on console from '%s' <%s>" V_END,
dest, c->cid.cid_name, c->cid.cid_num);
@@ -565,18 +566,16 @@ static int console_call(struct ast_channel *c, char *dest, int timeout)
pvt->hookstate = 1;
console_pvt_unlock(pvt);
ast_verb(1, V_BEGIN "Auto-answered" V_END);
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_ANSWER;
+ ctrl = AST_CONTROL_ANSWER;
} else {
console_pvt_unlock(pvt);
ast_verb(1, V_BEGIN "Type 'console answer' to answer, or use the 'autoanswer' option "
"for future calls" V_END);
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_RINGING;
+ ctrl = AST_CONTROL_RINGING;
ast_indicate(c, AST_CONTROL_RINGING);
}
- ast_queue_frame(c, &f);
+ ast_queue_control(c, ctrl);
return start_stream(pvt);
}
@@ -729,7 +728,6 @@ static char *cli_console_autoanswer(struct ast_cli_entry *e, int cmd,
static char *cli_console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
struct console_pvt *pvt = get_active_pvt();
if (cmd == CLI_INIT) {
@@ -757,7 +755,7 @@ static char *cli_console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_
pvt->hookstate = 0;
- ast_queue_frame(pvt->owner, &f);
+ ast_queue_control(pvt->owner, AST_CONTROL_FLASH);
unref_pvt(pvt);
@@ -789,7 +787,7 @@ static char *cli_console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_a
if (pvt->owner) { /* already in a call */
int i;
- struct ast_frame f = { AST_FRAME_DTMF, 0 };
+ struct ast_frame f = { AST_FRAME_DTMF };
const char *s;
if (a->argc == e->args) { /* argument is mandatory here */
@@ -800,7 +798,7 @@ static char *cli_console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_a
s = a->argv[e->args];
/* send the string one char at a time */
for (i = 0; i < strlen(s); i++) {
- f.subclass = s[i];
+ f.subclass.integer = s[i];
ast_queue_frame(pvt->owner, &f);
}
unref_pvt(pvt);
@@ -1024,7 +1022,6 @@ static char *cli_list_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_a
*/
static char *cli_console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
struct console_pvt *pvt = get_active_pvt();
switch (cmd) {
@@ -1059,7 +1056,7 @@ static char *cli_console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli
ast_indicate(pvt->owner, -1);
- ast_queue_frame(pvt->owner, &f);
+ ast_queue_control(pvt->owner, AST_CONTROL_ANSWER);
unref_pvt(pvt);
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index b81c7a8ef..77caff836 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -1411,7 +1411,7 @@ static struct dahdi_chan_conf dahdi_chan_conf_default(void)
}
-static struct ast_channel *dahdi_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *dahdi_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int dahdi_digit_begin(struct ast_channel *ast, char digit);
static int dahdi_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int dahdi_sendtext(struct ast_channel *c, const char *text);
@@ -1936,9 +1936,9 @@ static void my_handle_dtmfup(void *pvt, struct ast_channel *ast, enum analog_sub
struct dahdi_pvt *p = pvt;
int idx = analogsub_to_dahdisub(analog_index);
- ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name);
+ ast_debug(1, "DTMF digit: %c on %s\n", f->subclass.integer, ast->name);
- if (f->subclass == 'f') {
+ if (f->subclass.integer == 'f') {
/* Fax tone -- Handle and return NULL */
if ((p->callprogress & CALLPROGRESS_FAX) && !p->faxhandled) {
/* If faxbuffers are configured, use them for the fax transmission */
@@ -1987,7 +1987,7 @@ static void my_handle_dtmfup(void *pvt, struct ast_channel *ast, enum analog_sub
}
dahdi_confmute(p, 0);
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
*dest = &p->subs[idx].f;
}
}
@@ -5327,7 +5327,7 @@ static int dahdi_accept_r2_call_exec(struct ast_channel *chan, const char *data)
res = -1;
break;
}
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
ast_log(LOG_DEBUG, "Got HANGUP frame on channel %s, going out ...\n", chan->name);
ast_frfree(f);
res = -1;
@@ -6856,19 +6856,19 @@ static void dahdi_handle_dtmfup(struct ast_channel *ast, int idx, struct ast_fra
struct dahdi_pvt *p = ast->tech_pvt;
struct ast_frame *f = *dest;
- ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name);
+ ast_debug(1, "DTMF digit: %c on %s\n", (int) f->subclass.integer, ast->name);
if (p->confirmanswer) {
ast_debug(1, "Confirm answer on %s!\n", ast->name);
/* Upon receiving a DTMF digit, consider this an answer confirmation instead
of a DTMF digit */
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
*dest = &p->subs[idx].f;
/* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
p->confirmanswer = 0;
} else if (p->callwaitcas) {
- if ((f->subclass == 'A') || (f->subclass == 'D')) {
+ if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
ast_debug(1, "Got some DTMF, but it's for the CAS\n");
if (p->cidspill)
ast_free(p->cidspill);
@@ -6876,9 +6876,9 @@ static void dahdi_handle_dtmfup(struct ast_channel *ast, int idx, struct ast_fra
}
p->callwaitcas = 0;
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
*dest = &p->subs[idx].f;
- } else if (f->subclass == 'f') {
+ } else if (f->subclass.integer == 'f') {
/* Fax tone -- Handle and return NULL */
if ((p->callprogress & CALLPROGRESS_FAX) && !p->faxhandled) {
/* If faxbuffers are configured, use them for the fax transmission */
@@ -6931,7 +6931,7 @@ static void dahdi_handle_dtmfup(struct ast_channel *ast, int idx, struct ast_fra
}
dahdi_confmute(p, 0);
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
*dest = &p->subs[idx].f;
}
}
@@ -6962,7 +6962,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
if (p->outsigmod > -1)
mysig = p->outsigmod;
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
p->subs[idx].f.datalen = 0;
p->subs[idx].f.samples = 0;
p->subs[idx].f.mallocd = 0;
@@ -6994,7 +6994,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
#endif
dahdi_confmute(p, 0);
p->subs[idx].f.frametype = AST_FRAME_DTMF_END;
- p->subs[idx].f.subclass = res & 0xff;
+ p->subs[idx].f.subclass.integer = res & 0xff;
#ifdef HAVE_PRI
}
#endif
@@ -7007,7 +7007,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
/* Mute conference */
dahdi_confmute(p, 1);
p->subs[idx].f.frametype = AST_FRAME_DTMF_BEGIN;
- p->subs[idx].f.subclass = res & 0xff;
+ p->subs[idx].f.subclass.integer = res & 0xff;
return &p->subs[idx].f;
}
@@ -7075,7 +7075,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
if (ast->_state == AST_STATE_DIALING_OFFHOOK) {
ast_setstate(ast, AST_STATE_UP);
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
break;
} else { /* if to state wait for offhook to dial rest */
/* we now wait for off hook */
@@ -7098,7 +7098,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
} else if (!p->answeronpolarityswitch) {
ast_setstate(ast, AST_STATE_UP);
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
/* If aops=0 and hops=1, this is necessary */
p->polarity = POLARITY_REV;
} else {
@@ -7140,7 +7140,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
case DAHDI_EVENT_ONHOOK:
if (p->radio) {
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_RADIO_UNKEY;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_RADIO_UNKEY;
break;
}
if (p->oprmode < 0)
@@ -7274,7 +7274,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
if (p->radio)
{
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_RADIO_KEY;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_RADIO_KEY;
break;
}
/* for E911, its supposed to wait for offhook then dial
@@ -7315,7 +7315,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
dahdi_enable_ec(p);
dahdi_train_ec(p);
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
/* Make sure it stops ringing */
dahdi_set_hook(p->subs[idx].dfd, DAHDI_OFFHOOK);
ast_debug(1, "channel %d answered\n", p->channel);
@@ -7329,7 +7329,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
if (p->confirmanswer) {
/* Ignore answer if "confirm answer" is enabled */
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
} else if (!ast_strlen_zero(p->dop.dialstr)) {
/* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop);
@@ -7340,7 +7340,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
} else {
ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
p->dialing = 1;
}
p->dop.dialstr[0] = '\0';
@@ -7352,7 +7352,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
ast_setstate(ast, AST_STATE_RING);
ast->rings = 1;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_OFFHOOK;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_OFFHOOK;
ast_debug(1, "channel %d picked up\n", p->channel);
return &p->subs[idx].f;
case AST_STATE_UP:
@@ -7409,15 +7409,15 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
ast_debug(1, "Ring detected\n");
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_RING;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_RING;
} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
ast_debug(1, "Line answered\n");
if (p->confirmanswer) {
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
} else {
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
}
} else if (ast->_state != AST_STATE_RING)
@@ -7815,7 +7815,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
p->subs[idx].f.samples = 0;
p->subs[idx].f.mallocd = 0;
p->subs[idx].f.offset = 0;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
p->subs[idx].f.delivery = ast_tv(0,0);
p->subs[idx].f.src = "dahdi_exception";
p->subs[idx].f.data.ptr = NULL;
@@ -7957,7 +7957,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
p->subs[idx].f.samples = 0;
p->subs[idx].f.mallocd = 0;
p->subs[idx].f.offset = 0;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
p->subs[idx].f.delivery = ast_tv(0,0);
p->subs[idx].f.src = "dahdi_read";
p->subs[idx].f.data.ptr = NULL;
@@ -7977,11 +7977,11 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
if (ps.rxisoffhook)
{
- p->subs[idx].f.subclass = AST_CONTROL_RADIO_KEY;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_RADIO_KEY;
}
else
{
- p->subs[idx].f.subclass = AST_CONTROL_RADIO_UNKEY;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_RADIO_UNKEY;
}
ast_mutex_unlock(&p->lock);
return &p->subs[idx].f;
@@ -8003,7 +8003,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send ringing frame if requested */
p->subs[idx].needringing = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_RINGING;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_RINGING;
ast_setstate(ast, AST_STATE_RINGING);
ast_mutex_unlock(&p->lock);
return &p->subs[idx].f;
@@ -8013,7 +8013,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send busy frame if requested */
p->subs[idx].needbusy = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_BUSY;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_BUSY;
ast_mutex_unlock(&p->lock);
return &p->subs[idx].f;
}
@@ -8022,7 +8022,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send congestion frame if requested */
p->subs[idx].needcongestion = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_CONGESTION;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_CONGESTION;
ast_mutex_unlock(&p->lock);
return &p->subs[idx].f;
}
@@ -8031,7 +8031,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send answer frame if requested */
p->subs[idx].needanswer = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
ast_mutex_unlock(&p->lock);
return &p->subs[idx].f;
}
@@ -8050,7 +8050,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send answer frame if requested */
p->subs[idx].needflash = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_FLASH;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_FLASH;
ast_mutex_unlock(&p->lock);
return &p->subs[idx].f;
}
@@ -8059,7 +8059,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send answer frame if requested */
p->subs[idx].needhold = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_HOLD;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_HOLD;
ast_mutex_unlock(&p->lock);
ast_debug(1, "Sending hold on '%s'\n", ast->name);
return &p->subs[idx].f;
@@ -8069,7 +8069,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Send answer frame if requested */
p->subs[idx].needunhold = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
- p->subs[idx].f.subclass = AST_CONTROL_UNHOLD;
+ p->subs[idx].f.subclass.integer = AST_CONTROL_UNHOLD;
ast_mutex_unlock(&p->lock);
ast_debug(1, "Sending unhold on '%s'\n", ast->name);
return &p->subs[idx].f;
@@ -8141,7 +8141,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
return NULL;
}
if (c) { /* if a char to return */
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
p->subs[idx].f.frametype = AST_FRAME_TEXT;
p->subs[idx].f.mallocd = 0;
p->subs[idx].f.offset = AST_FRIENDLY_OFFSET;
@@ -8179,7 +8179,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
}
p->subs[idx].f.frametype = AST_FRAME_VOICE;
- p->subs[idx].f.subclass = ast->rawreadformat;
+ p->subs[idx].f.subclass.codec = ast->rawreadformat;
p->subs[idx].f.samples = READ_SIZE;
p->subs[idx].f.mallocd = 0;
p->subs[idx].f.offset = AST_FRIENDLY_OFFSET;
@@ -8194,7 +8194,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
/* Whoops, we're still dialing, or in a state where we shouldn't transmit....
don't send anything */
p->subs[idx].f.frametype = AST_FRAME_NULL;
- p->subs[idx].f.subclass = 0;
+ p->subs[idx].f.subclass.integer = 0;
p->subs[idx].f.samples = 0;
p->subs[idx].f.mallocd = 0;
p->subs[idx].f.offset = 0;
@@ -8215,7 +8215,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
}
if (f) {
- if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_BUSY)) {
+ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_BUSY)) {
if ((ast->_state == AST_STATE_UP) && !p->outgoing) {
/* Treat this as a "hangup" instead of a "busy" on the assumption that
a busy */
@@ -8230,7 +8230,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
|| (p->outgoing && (p->pri->overlapdial & DAHDI_OVERLAPDIAL_OUTGOING)))) {
/* Don't accept in-band DTMF when in overlap dial mode */
f->frametype = AST_FRAME_NULL;
- f->subclass = 0;
+ f->subclass.integer = 0;
}
#endif
/* DSP clears us of being pulse */
@@ -8242,7 +8242,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
f=NULL;
} else if (f->frametype == AST_FRAME_VOICE) {
f->frametype = AST_FRAME_NULL;
- f->subclass = 0;
+ f->subclass.integer = 0;
if ((ast_dsp_get_tstate(p->dsp) == DSP_TONE_STATE_DIALTONE || ast_dsp_get_tstate(p->dsp) == DSP_TONE_STATE_RINGING) && ast_dsp_get_tcount(p->dsp) > 9) {
p->waitingfordt.tv_sec = 0;
p->dsp_features &= ~DSP_FEATURE_WAITDIALTONE;
@@ -8324,10 +8324,10 @@ static int dahdi_write(struct ast_channel *ast, struct ast_frame *frame)
ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
return 0;
}
- if ((frame->subclass != AST_FORMAT_SLINEAR) &&
- (frame->subclass != AST_FORMAT_ULAW) &&
- (frame->subclass != AST_FORMAT_ALAW)) {
- ast_log(LOG_WARNING, "Cannot handle frames in %d format\n", frame->subclass);
+ if ((frame->subclass.codec != AST_FORMAT_SLINEAR) &&
+ (frame->subclass.codec != AST_FORMAT_ULAW) &&
+ (frame->subclass.codec != AST_FORMAT_ALAW)) {
+ ast_log(LOG_WARNING, "Cannot handle frames in %s format\n", ast_getformatname(frame->subclass.codec));
return -1;
}
if (p->dialing) {
@@ -8346,7 +8346,7 @@ static int dahdi_write(struct ast_channel *ast, struct ast_frame *frame)
if (!frame->data.ptr || !frame->datalen)
return 0;
- if (frame->subclass == AST_FORMAT_SLINEAR) {
+ if (frame->subclass.codec == AST_FORMAT_SLINEAR) {
if (!p->subs[idx].linear) {
p->subs[idx].linear = 1;
res = dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear);
@@ -9410,8 +9410,8 @@ static void *analog_ss_thread(void *data)
if (!f)
break;
if (f->frametype == AST_FRAME_DTMF) {
- dtmfbuf[k++] = f->subclass;
- ast_debug(1, "CID got digit '%c'\n", f->subclass);
+ dtmfbuf[k++] = f->subclass.integer;
+ ast_debug(1, "CID got digit '%c'\n", f->subclass.integer);
res = 2000;
}
ast_frfree(f);
@@ -9648,8 +9648,8 @@ static void *analog_ss_thread(void *data)
}
f = ast_read(chan);
if (f->frametype == AST_FRAME_DTMF) {
- dtmfbuf[k++] = f->subclass;
- ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass);
+ dtmfbuf[k++] = f->subclass.integer;
+ ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass.integer);
res = 2000;
}
ast_frfree(f);
@@ -11991,7 +11991,7 @@ static struct dahdi_pvt *duplicate_pseudo(struct dahdi_pvt *src)
return p;
}
-static struct ast_channel *dahdi_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *dahdi_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
ast_group_t groupmatch = 0;
int channelmatch = -1;
@@ -14986,7 +14986,7 @@ static int action_dahdidialoffhook(struct mansession *s, const struct message *m
return 0;
}
for (i = 0; i < strlen(number); i++) {
- struct ast_frame f = { AST_FRAME_DTMF, number[i] };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = number[i] };
dahdi_queue_frame(p, &f, NULL);
}
astman_send_ack(s, m, "DAHDIDialOffhook");
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index 25fdc2c63..8655806b0 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -115,8 +115,8 @@ struct gtalk_pvt {
struct ast_channel *owner; /*!< Master Channel */
struct ast_rtp_instance *rtp; /*!< RTP audio session */
struct ast_rtp_instance *vrtp; /*!< RTP video session */
- int jointcapability; /*!< Supported capability at both ends (codecs ) */
- int peercapability;
+ format_t jointcapability; /*!< Supported capability at both ends (codecs ) */
+ format_t peercapability;
struct gtalk_pvt *next; /* Next entity */
};
@@ -146,7 +146,7 @@ struct gtalk {
char context[AST_MAX_CONTEXT];
char parkinglot[AST_MAX_CONTEXT]; /*!< Parkinglot */
char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */
- int capability;
+ format_t capability;
ast_group_t callgroup; /*!< Call group */
ast_group_t pickupgroup; /*!< Pickup group */
int callingpres; /*!< Calling presentation */
@@ -161,12 +161,12 @@ struct gtalk_container {
static const char desc[] = "Gtalk Channel";
-static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
+static format_t global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
AST_MUTEX_DEFINE_STATIC(gtalklock); /*!< Protect the interface list (of gtalk_pvt's) */
/* Forward declarations */
-static struct ast_channel *gtalk_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *gtalk_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int gtalk_digit(struct ast_channel *ast, char digit, unsigned int duration);
static int gtalk_sendtext(struct ast_channel *ast, const char *text);
static int gtalk_digit_begin(struct ast_channel *ast, char digit);
@@ -393,7 +393,7 @@ static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, in
iks_insert_attrib(dcodecs, "xmlns", "http://www.google.com/session/phone");
iks_insert_attrib(dcodecs, "xml:lang", "en");
- for (x = 0; x < 32; x++) {
+ for (x = 0; x < 64; x++) {
if (!(pref_codec = ast_codec_pref_index(&client->prefs, x)))
break;
if (!(client->capability & pref_codec))
@@ -532,13 +532,13 @@ static enum ast_rtp_glue_result gtalk_get_rtp_peer(struct ast_channel *chan, str
return res;
}
-static int gtalk_get_codec(struct ast_channel *chan)
+static format_t gtalk_get_codec(struct ast_channel *chan)
{
struct gtalk_pvt *p = chan->tech_pvt;
return p->peercapability;
}
-static int gtalk_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)
+static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
{
struct gtalk_pvt *p;
@@ -701,19 +701,19 @@ static int gtalk_handle_dtmf(struct gtalk *client, ikspak *pak)
if((dtmf = iks_find_attrib(dtmfnode, "code"))) {
if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-up")) {
struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("GOOGLE! DTMF-relay event received: %c\n", (int) f.subclass.integer);
} else if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-down")) {
struct ast_frame f = {AST_FRAME_DTMF_END, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("GOOGLE! DTMF-relay event received: %c\n", (int) f.subclass.integer);
} else if(iks_find_attrib(pak->x, "dtmf")) { /* 250 millasecond default */
struct ast_frame f = {AST_FRAME_DTMF, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("GOOGLE! DTMF-relay event received: %c\n", (int) f.subclass.integer);
}
}
} else if ((dtmfnode = iks_find_with_attrib(pak->x, "gtalk", "action", "session-info"))) {
@@ -721,14 +721,14 @@ static int gtalk_handle_dtmf(struct gtalk *client, ikspak *pak)
if((dtmf = iks_find_attrib(dtmfchild, "code"))) {
if(iks_find_with_attrib(dtmfnode, "dtmf", "action", "button-up")) {
struct ast_frame f = {AST_FRAME_DTMF_END, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("GOOGLE! DTMF-relay event received: %c\n", (int) f.subclass.integer);
} else if(iks_find_with_attrib(dtmfnode, "dtmf", "action", "button-down")) {
struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("GOOGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("GOOGLE! DTMF-relay event received: %c\n", (int) f.subclass.integer);
}
}
}
@@ -1395,10 +1395,10 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
if (p->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
+ if (f->subclass.codec != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+ ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(f->subclass.codec));
p->owner->nativeformats =
- (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
+ (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass.codec;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
@@ -1428,14 +1428,17 @@ static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
{
struct gtalk_pvt *p = ast->tech_pvt;
int res = 0;
+ char buf[256];
switch (frame->frametype) {
case AST_FRAME_VOICE:
- if (!(frame->subclass & ast->nativeformats)) {
+ if (!(frame->subclass.codec & ast->nativeformats)) {
ast_log(LOG_WARNING,
- "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
- frame->subclass, ast->nativeformats, ast->readformat,
- ast->writeformat);
+ "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
return 0;
}
if (p) {
@@ -1655,7 +1658,7 @@ static int gtalk_hangup(struct ast_channel *ast)
}
/*! \brief Part of PBX interface */
-static struct ast_channel *gtalk_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *gtalk_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct gtalk_pvt *p = NULL;
struct gtalk *client = NULL;
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 897416a42..3ccfde2d3 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -172,9 +172,9 @@ static struct oh323_pvt {
int newcontrol; /*!< Pending control to send */
int newdigit; /*!< Pending DTMF digit to send */
int newduration; /*!< Pending DTMF digit duration to send */
- int pref_codec; /*!< Preferred codec */
- int peercapability; /*!< Capabilities learned from peer */
- int jointcapability; /*!< Common capabilities for local and remote side */
+ format_t pref_codec; /*!< Preferred codec */
+ format_t peercapability; /*!< Capabilities learned from peer */
+ format_t jointcapability; /*!< Common capabilities for local and remote side */
struct ast_codec_pref peer_prefs; /*!< Preferenced list of codecs which remote side supports */
int dtmf_pt[2]; /*!< Payload code used for RFC2833/CISCO messages */
int curDTMF; /*!< DTMF tone being generated to Asterisk side */
@@ -230,7 +230,7 @@ static void delete_users(void);
static void delete_aliases(void);
static void prune_peers(void);
-static struct ast_channel *oh323_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *oh323_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int oh323_digit_begin(struct ast_channel *c, char digit);
static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int duration);
static int oh323_call(struct ast_channel *c, char *dest, int timeout);
@@ -312,7 +312,7 @@ static int oh323_simulate_dtmf_end(const void *data)
if (pvt->owner) {
struct ast_frame f = {
.frametype = AST_FRAME_DTMF_END,
- .subclass = pvt->curDTMF,
+ .subclass.integer = pvt->curDTMF,
.samples = 0,
.src = "SIMULATE_DTMF_END",
};
@@ -357,13 +357,13 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
if (pvt->newdigit >= 0) {
struct ast_frame f = {
.frametype = AST_FRAME_DTMF_END,
- .subclass = pvt->newdigit,
+ .subclass.integer = pvt->newdigit,
.samples = pvt->newduration * 8,
.len = pvt->newduration,
.src = "UPDATE_INFO",
};
if (pvt->newdigit == ' ') { /* signalUpdate message */
- f.subclass = pvt->curDTMF;
+ f.subclass.integer = pvt->curDTMF;
if (pvt->DTMFsched >= 0) {
AST_SCHED_DEL(sched, pvt->DTMFsched);
}
@@ -761,16 +761,16 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
if (pvt->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != pvt->owner->nativeformats) {
+ if (f->subclass.codec != pvt->owner->nativeformats) {
/* Try to avoid deadlock */
if (ast_channel_trylock(pvt->owner)) {
ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
return &ast_null_frame;
}
if (h323debug)
- ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
- pvt->owner->nativeformats = f->subclass;
- pvt->nativeformats = f->subclass;
+ ast_debug(1, "Oooh, format changed to '%s'\n", ast_getformatname(f->subclass.codec));
+ pvt->owner->nativeformats = f->subclass.codec;
+ pvt->nativeformats = f->subclass.codec;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
ast_set_write_format(pvt->owner, pvt->owner->writeformat);
ast_channel_unlock(pvt->owner);
@@ -785,12 +785,12 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
else
ast_log(LOG_NOTICE, "Unable to process inband DTMF while channel is locked\n");
} else if (pvt->nativeformats && !pvt->noInbandDtmf) {
- ast_log(LOG_NOTICE, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(f->subclass));
+ ast_log(LOG_NOTICE, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(f->subclass.codec));
pvt->noInbandDtmf = 1;
}
if (f &&(f->frametype == AST_FRAME_DTMF)) {
if (h323debug)
- ast_log(LOG_DTMF, "Received in-band digit %c.\n", f->subclass);
+ ast_log(LOG_DTMF, "Received in-band digit %c.\n", f->subclass.integer);
}
}
}
@@ -835,9 +835,10 @@ static int oh323_write(struct ast_channel *c, struct ast_frame *frame)
return 0;
}
} else {
- if (!(frame->subclass & c->nativeformats)) {
- ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
- frame->subclass, c->nativeformats, c->readformat, c->writeformat);
+ if (!(frame->subclass.codec & c->nativeformats)) {
+ char tmp[256];
+ ast_log(LOG_WARNING, "Asked to transmit frame type '%s', while native formats is '%s' (read/write = %s/%s)\n",
+ ast_getformatname(frame->subclass.codec), ast_getformatname_multiple(tmp, sizeof(tmp), c->nativeformats), ast_getformatname(c->readformat), ast_getformatname(c->writeformat));
return 0;
}
}
@@ -1717,9 +1718,9 @@ static int create_addr(struct oh323_pvt *pvt, char *opeer)
return 0;
}
}
-static struct ast_channel *oh323_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *oh323_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct oh323_pvt *pvt;
struct ast_channel *tmpc = NULL;
char *dest = (char *)data;
@@ -1728,7 +1729,7 @@ static struct ast_channel *oh323_request(const char *type, int format, const str
char tmp[256], tmp1[256];
if (h323debug)
- ast_debug(1, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
+ ast_debug(1, "type=%s, format=%s, data=%s.\n", type, ast_getformatname_multiple(tmp, sizeof(tmp), format), (char *)data);
pvt = oh323_alloc(0);
if (!pvt) {
@@ -1738,7 +1739,7 @@ static struct ast_channel *oh323_request(const char *type, int format, const str
oldformat = format;
format &= AST_FORMAT_AUDIO_MASK;
if (!format) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), format));
oh323_destroy(pvt);
if (cause)
*cause = AST_CAUSE_INCOMPATIBLE_DESTINATION;
@@ -1841,23 +1842,23 @@ static int receive_digit(unsigned call_reference, char digit, const char *token,
else {
struct ast_frame f = {
.frametype = AST_FRAME_DTMF_END,
- .subclass = digit,
+ .subclass.integer = digit,
.samples = duration * 8,
.len = duration,
.src = "SEND_DIGIT",
};
if (digit == ' ') { /* signalUpdate message */
- f.subclass = pvt->curDTMF;
+ f.subclass.integer = pvt->curDTMF;
AST_SCHED_DEL(sched, pvt->DTMFsched);
} else { /* Regular input or signal message */
if (pvt->DTMFsched >= 0) {
/* We still don't send DTMF END from previous event, send it now */
AST_SCHED_DEL(sched, pvt->DTMFsched);
- f.subclass = pvt->curDTMF;
+ f.subclass.integer = pvt->curDTMF;
f.samples = f.len = 0;
ast_queue_frame(pvt->owner, &f);
/* Restore values */
- f.subclass = digit;
+ f.subclass.integer = digit;
f.samples = duration * 8;
f.len = duration;
}
@@ -1983,7 +1984,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
struct ast_rtp_payload_type rtptype = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(pvt->rtp), pt);
if (h323debug)
- ast_debug(1, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
+ ast_debug(1, "Native format is set to %llu from %d by RTP payload type %d\n", (unsigned long long) rtptype.code, pvt->nativeformats, pt);
if (pvt->nativeformats != rtptype.code) {
pvt->nativeformats = rtptype.code;
nativeformats_changed = 1;
@@ -1996,8 +1997,10 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
/* Re-build translation path only if native format(s) has been changed */
if (pvt->owner->nativeformats != pvt->nativeformats) {
- if (h323debug)
- ast_debug(1, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
+ if (h323debug) {
+ char tmp[256], tmp2[256];
+ ast_debug(1, "Native format changed to '%s' from '%s', read format is %s, write format is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), pvt->nativeformats), ast_getformatname_multiple(tmp2, sizeof(tmp2), pvt->owner->nativeformats), ast_getformatname(pvt->owner->readformat), ast_getformatname(pvt->owner->writeformat));
+ }
pvt->owner->nativeformats = pvt->nativeformats;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
ast_set_write_format(pvt->owner, pvt->owner->writeformat);
@@ -3178,7 +3181,7 @@ static char *convertcap(int cap)
}
}
-static int oh323_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)
+static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
{
/* XXX Deal with Video */
struct oh323_pvt *pvt;
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index d6deac779..1948bc51f 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -352,7 +352,7 @@ static int (*iax2_regfunk)(const char *username, int onoff) = NULL;
static struct io_context *io;
static struct ast_sched_thread *sched;
-static int iax2_capability = IAX_CAPABILITY_FULLBANDWIDTH;
+static format_t iax2_capability = IAX_CAPABILITY_FULLBANDWIDTH;
static int iaxdebug = 0;
@@ -461,7 +461,7 @@ struct iax2_user {
int amaflags;
int adsi;
uint64_t flags;
- int capability;
+ format_t capability;
int maxauthreq; /*!< Maximum allowed outstanding AUTHREQs */
int curauthreq; /*!< Current number of outstanding AUTHREQs */
struct ast_codec_pref prefs;
@@ -508,7 +508,7 @@ struct iax2_peer {
int expire; /*!< Schedule entry for expiry */
int expiry; /*!< How soon to expire */
- int capability; /*!< Capability */
+ format_t capability; /*!< Capability */
/* Qualification */
int callno; /*!< Call number of POKE request */
@@ -639,15 +639,15 @@ struct chan_iax2_pvt {
/*! Socket to send/receive on for this call */
int sockfd;
/*! Last received voice format */
- int voiceformat;
+ format_t voiceformat;
/*! Last received video format */
- int videoformat;
+ format_t videoformat;
/*! Last sent voice format */
- int svoiceformat;
+ format_t svoiceformat;
/*! Last sent video format */
- int svideoformat;
+ format_t svideoformat;
/*! What we are capable of sending */
- int capability;
+ format_t capability;
/*! Last received timestamp */
unsigned int last;
/*! Last sent timestamp - never send the same timestamp twice in a single call */
@@ -681,11 +681,11 @@ struct chan_iax2_pvt {
/*! Negotiated format, this is only used to remember what format was
chosen for an unauthenticated call so that the channel can get
created later using the right format */
- int chosenformat;
+ format_t chosenformat;
/*! Peer selected format */
- int peerformat;
+ format_t peerformat;
/*! Peer capability */
- int peercapability;
+ format_t peercapability;
/*! timeval that we base our transmission on */
struct timeval offset;
/*! timeval that we base our delivery on */
@@ -1178,7 +1178,7 @@ static int send_command_final(struct chan_iax2_pvt *, char, int, unsigned int, c
static int send_command_immediate(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int, int);
static int send_command_locked(unsigned short callno, char, int, unsigned int, const unsigned char *, int, int);
static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int);
-static struct ast_channel *iax2_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *iax2_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static struct ast_frame *iax2_read(struct ast_channel *c);
static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
@@ -1506,18 +1506,18 @@ static int send_lagrq(const void *data)
return 0;
}
-static unsigned char compress_subclass(int subclass)
+static unsigned char compress_subclass(format_t subclass)
{
int x;
int power=-1;
- /* If it's 128 or smaller, just return it */
+ /* If it's 64 or smaller, just return it */
if (subclass < IAX_FLAG_SC_LOG)
return subclass;
/* Otherwise find its power */
for (x = 0; x < IAX_MAX_SHIFT; x++) {
- if (subclass & (1 << x)) {
+ if (subclass & (1LL << x)) {
if (power > -1) {
- ast_log(LOG_WARNING, "Can't compress subclass %d\n", subclass);
+ ast_log(LOG_WARNING, "Can't compress subclass %Ld\n", subclass);
return 0;
} else
power = x;
@@ -1526,7 +1526,7 @@ static unsigned char compress_subclass(int subclass)
return power | IAX_FLAG_SC_LOG;
}
-static int uncompress_subclass(unsigned char csub)
+static format_t uncompress_subclass(unsigned char csub)
{
/* If the SC_LOG flag is set, return 2^csub otherwise csub */
if (csub & IAX_FLAG_SC_LOG) {
@@ -1534,7 +1534,7 @@ static int uncompress_subclass(unsigned char csub)
if (csub == 0xff)
return -1;
else
- return 1 << (csub & ~IAX_FLAG_SC_LOG & IAX_MAX_SHIFT);
+ return 1LL << (csub & ~IAX_FLAG_SC_LOG & IAX_MAX_SHIFT);
}
else
return csub;
@@ -3370,10 +3370,10 @@ static void __attempt_transmit(const void *data)
iax2_destroy(callno);
} else {
if (iaxs[callno]->owner)
- ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno);
+ ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %u, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass.integer, f->ts, f->oseqno);
iaxs[callno]->error = ETIMEDOUT;
if (iaxs[callno]->owner) {
- struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .data.uint32 = AST_CAUSE_DESTINATION_OUT_OF_ORDER };
+ struct ast_frame fr = { AST_FRAME_CONTROL, { AST_CONTROL_HANGUP }, .data.uint32 = AST_CAUSE_DESTINATION_OUT_OF_ORDER };
/* Hangup the fd */
iax2_queue_frame(callno, &fr); /* XXX */
/* Remember, owner could disappear */
@@ -3965,7 +3965,7 @@ static void __get_from_jb(const void *p)
/* create an interpolation frame */
af.frametype = AST_FRAME_VOICE;
- af.subclass = pvt->voiceformat;
+ af.subclass.codec = pvt->voiceformat;
af.samples = frame.ms * (ast_format_rate(pvt->voiceformat) / 1000);
af.src = "IAX2 JB interpolation";
af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
@@ -4038,7 +4038,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
if(fr->af.frametype == AST_FRAME_VOICE) {
type = JB_TYPE_VOICE;
- len = ast_codec_get_samples(&fr->af) / (ast_format_rate(fr->af.subclass) / 1000);
+ len = ast_codec_get_samples(&fr->af) / (ast_format_rate(fr->af.subclass.codec) / 1000);
} else if(fr->af.frametype == AST_FRAME_CNG) {
type = JB_TYPE_SILENCE;
}
@@ -4149,7 +4149,7 @@ static int iax2_sendtext(struct ast_channel *c, const char *text)
static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img)
{
- return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_IMAGE, img->subclass, 0, img->data.ptr, img->datalen, -1);
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_IMAGE, img->subclass.integer, 0, img->data.ptr, img->datalen, -1);
}
static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen)
@@ -4384,7 +4384,7 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin,
}
struct create_addr_info {
- int capability;
+ format_t capability;
uint64_t flags;
int maxtime;
int encmethods;
@@ -4450,7 +4450,7 @@ static int create_addr(const char *peername, struct ast_channel *c, struct socka
memcpy(&ourprefs, &peer->prefs, sizeof(ourprefs));
/* Move the calling channel's native codec to the top of the preference list */
if (c) {
- ast_debug(1, "prepending %x to prefs\n", c->nativeformats);
+ ast_debug(1, "prepending %llx to prefs\n", (unsigned long long) c->nativeformats);
ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
}
ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
@@ -4498,7 +4498,7 @@ return_unref:
static void __auto_congest(const void *nothing)
{
int callno = PTR_TO_CALLNO(nothing);
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_CONGESTION };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_CONGESTION } };
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
iaxs[callno]->initid = -1;
@@ -4583,7 +4583,7 @@ static void resend_with_token(int callno, struct iax_frame *f, const char *newto
{
struct chan_iax2_pvt *pvt = iaxs[callno];
int frametype = f->af.frametype;
- int subclass = f->af.subclass;
+ int subclass = f->af.subclass.integer;
struct {
struct ast_iax2_full_hdr fh;
struct iax_ie_data ied;
@@ -4917,6 +4917,7 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
iax_ie_append(&ied, IAX_IE_AUTOANSWER);
}
+ /* WARNING: this breaks down at 190 bits! */
iax_ie_append_str(&ied, IAX_IE_CODEC_PREFS, cai.prefs);
if (l) {
@@ -4973,8 +4974,10 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
if (pds.password)
ast_string_field_set(iaxs[callno], secret, pds.password);
- iax_ie_append_int(&ied, IAX_IE_FORMAT, c->nativeformats);
- iax_ie_append_int(&ied, IAX_IE_CAPABILITY, iaxs[callno]->capability);
+ iax_ie_append_int(&ied, IAX_IE_FORMAT, (int) c->nativeformats);
+ iax_ie_append_versioned_uint64(&ied, IAX_IE_FORMAT2, 0, c->nativeformats);
+ iax_ie_append_int(&ied, IAX_IE_CAPABILITY, (int) iaxs[callno]->capability);
+ iax_ie_append_versioned_uint64(&ied, IAX_IE_CAPABILITY2, 0, iaxs[callno]->capability);
iax_ie_append_short(&ied, IAX_IE_ADSICPE, c->adsicpe);
iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(cai.timezone));
@@ -5293,11 +5296,11 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
return AST_BRIDGE_FAILED_NOWARN;
}
if (c0->nativeformats != c1->nativeformats) {
- 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_verb(3, "Operating with different codecs %d[%s] %d[%s] , can't native bridge...\n", c0->nativeformats, buf0, c1->nativeformats, buf1);
+ char buf0[256];
+ char buf1[256];
+ 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] , can't native bridge...\n", buf0, buf1);
/* Remove from native mode */
lock_both(callno0, callno1);
if (iaxs[callno0])
@@ -5354,7 +5357,7 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
res = AST_BRIDGE_COMPLETE;
break;
}
- if ((f->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS) && (f->subclass != AST_CONTROL_SRCUPDATE)) {
+ if ((f->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS) && (f->subclass.integer != AST_CONTROL_SRCUPDATE)) {
*fo = f;
*rc = who;
res = AST_BRIDGE_COMPLETE;
@@ -5493,7 +5496,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
}
/*! \brief Create new call, interface with the PBX core */
-static struct ast_channel *ast_iax2_new(int callno, int state, int capability, const char *linkedid)
+static struct ast_channel *ast_iax2_new(int callno, int state, format_t capability, const char *linkedid)
{
struct ast_channel *tmp;
struct chan_iax2_pvt *i;
@@ -5660,7 +5663,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
int voice = 0;
int genuine = 0;
int adjust;
- int rate = ast_format_rate(f->subclass) / 1000;
+ int rate = ast_format_rate(f->subclass.codec) / 1000;
struct timeval *delivery = NULL;
@@ -6033,9 +6036,11 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh,
memcpy(efh->encdata, workspace + padding, *datalen - sizeof(struct ast_iax2_full_enc_hdr));
f->frametype = fh->type;
if (f->frametype == AST_FRAME_VIDEO) {
- f->subclass = uncompress_subclass(fh->csub & ~0x40) | ((fh->csub >> 6) & 0x1);
+ f->subclass.codec = uncompress_subclass(fh->csub & ~0x40) | ((fh->csub >> 6) & 0x1);
+ } else if (f->frametype == AST_FRAME_VOICE) {
+ f->subclass.codec = uncompress_subclass(fh->csub);
} else {
- f->subclass = uncompress_subclass(fh->csub);
+ f->subclass.integer = uncompress_subclass(fh->csub);
}
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
@@ -6176,7 +6181,7 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in
/* High two bytes are the same on timestamp, or sending on a trunk */ &&
(f->frametype == AST_FRAME_VOICE)
/* is a voice frame */ &&
- (f->subclass == pvt->svoiceformat)
+ (f->subclass.codec == pvt->svoiceformat)
/* is the same type */ ) {
/* Force immediate rather than delayed transmission */
now = 1;
@@ -6190,7 +6195,7 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in
* Otherwise send a mini video frame
*/
if (((fts & 0xFFFF8000L) == (pvt->lastvsent & 0xFFFF8000L)) &&
- ((f->subclass & ~0x1) == pvt->svideoformat)
+ ((f->subclass.codec & ~0x1LL) == pvt->svideoformat)
) {
now = 1;
sendmini = 1;
@@ -6202,7 +6207,7 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in
}
if (f->frametype == AST_FRAME_IAX) {
/* 0x8000 marks this message as TX:, this bit will be stripped later */
- pvt->last_iax_message = f->subclass | MARK_IAX_SUBCLASS_TX;
+ pvt->last_iax_message = f->subclass.integer | MARK_IAX_SUBCLASS_TX;
if (!pvt->first_iax_message) {
pvt->first_iax_message = pvt->last_iax_message;
}
@@ -6244,9 +6249,9 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in
pvt->aseqno = fr->iseqno;
fh->type = fr->af.frametype & 0xFF;
if (fr->af.frametype == AST_FRAME_VIDEO)
- fh->csub = compress_subclass(fr->af.subclass & ~0x1) | ((fr->af.subclass & 0x1) << 6);
+ fh->csub = compress_subclass(fr->af.subclass.codec & ~0x1LL) | ((fr->af.subclass.codec & 0x1LL) << 6);
else
- fh->csub = compress_subclass(fr->af.subclass);
+ fh->csub = compress_subclass(fr->af.subclass.codec);
if (transfer) {
fr->dcallno = pvt->transfercallno;
} else
@@ -6262,12 +6267,12 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in
if (fr->retrytime > MAX_RETRY_TIME)
fr->retrytime = MAX_RETRY_TIME;
/* Acks' don't get retried */
- if ((f->frametype == AST_FRAME_IAX) && (f->subclass == IAX_COMMAND_ACK))
+ if ((f->frametype == AST_FRAME_IAX) && (f->subclass.integer == IAX_COMMAND_ACK))
fr->retries = -1;
else if (f->frametype == AST_FRAME_VOICE)
- pvt->svoiceformat = f->subclass;
+ pvt->svoiceformat = f->subclass.codec;
else if (f->frametype == AST_FRAME_VIDEO)
- pvt->svideoformat = f->subclass & ~0x1;
+ pvt->svideoformat = f->subclass.codec & ~0x1LL;
if (ast_test_flag64(pvt, IAX_ENCRYPTED)) {
if (ast_test_flag64(pvt, IAX_KEYPOPULATED)) {
if (fr->transfer)
@@ -6298,11 +6303,11 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in
vh = (struct ast_iax2_video_hdr *)(fr->af.data.ptr - sizeof(struct ast_iax2_video_hdr));
vh->zeros = 0;
vh->callno = htons(0x8000 | fr->callno);
- vh->ts = htons((fr->ts & 0x7FFF) | (fr->af.subclass & 0x1 ? 0x8000 : 0));
+ vh->ts = htons((fr->ts & 0x7FFF) | (fr->af.subclass.codec & 0x1LL ? 0x8000 : 0));
fr->datalen = fr->af.datalen + sizeof(struct ast_iax2_video_hdr);
fr->data = vh;
fr->retries = -1;
- res = send_packet(fr);
+ res = send_packet(fr);
} else {
/* Mini-frames have no sequence number */
fr->oseqno = -1;
@@ -7213,7 +7218,7 @@ static int __send_command(struct chan_iax2_pvt *i, char type, int command, unsig
int res = 0;
f.frametype = type;
- f.subclass = command;
+ f.subclass.integer = command;
f.datalen = datalen;
f.src = __FUNCTION__;
f.data.ptr = (void *) data;
@@ -7328,7 +7333,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
version = ies->version;
/* Use provided preferences until told otherwise for actual preferences */
- if(ies->codec_prefs) {
+ if (ies->codec_prefs) {
ast_codec_pref_convert(&iaxs[callno]->rprefs, ies->codec_prefs, 32, 0);
ast_codec_pref_convert(&iaxs[callno]->prefs, ies->codec_prefs, 32, 0);
}
@@ -9407,7 +9412,7 @@ static int socket_process_meta(int packet_len, struct ast_iax2_meta_hdr *meta, s
ast_log(LOG_WARNING, "Received trunked frame before first full voice frame\n");
iax2_vnak(fr->callno);
} else {
- f.subclass = iaxs[fr->callno]->voiceformat;
+ f.subclass.codec = iaxs[fr->callno]->voiceformat;
f.datalen = len;
if (f.datalen >= 0) {
if (f.datalen)
@@ -9568,7 +9573,7 @@ static int socket_process(struct iax2_thread *thread)
struct iax2_peer *peer;
struct iax_ies ies;
struct iax_ie_data ied0, ied1;
- int format;
+ format_t format;
int fd;
int exists;
int minivid = 0;
@@ -9639,17 +9644,19 @@ static int socket_process(struct iax2_thread *thread)
/* Retrieve the type and subclass */
f.frametype = fh->type;
if (f.frametype == AST_FRAME_VIDEO) {
- f.subclass = uncompress_subclass(fh->csub & ~0x40) | ((fh->csub >> 6) & 0x1);
+ f.subclass.codec = uncompress_subclass(fh->csub & ~0x40) | ((fh->csub >> 6) & 0x1);
+ } else if (f.frametype == AST_FRAME_VOICE) {
+ f.subclass.codec = uncompress_subclass(fh->csub);
} else {
- f.subclass = uncompress_subclass(fh->csub);
+ f.subclass.integer = uncompress_subclass(fh->csub);
}
/* Deal with POKE/PONG without allocating a callno */
- if (f.frametype == AST_FRAME_IAX && f.subclass == IAX_COMMAND_POKE) {
+ if (f.frametype == AST_FRAME_IAX && f.subclass.integer == IAX_COMMAND_POKE) {
/* Reply back with a PONG, but don't care about the result. */
send_apathetic_reply(1, ntohs(fh->scallno), &sin, IAX_COMMAND_PONG, ntohl(fh->ts), fh->iseqno + 1, fd, NULL);
return 1;
- } else if (f.frametype == AST_FRAME_IAX && f.subclass == IAX_COMMAND_ACK && dcallno == 1) {
+ } else if (f.frametype == AST_FRAME_IAX && f.subclass.integer == IAX_COMMAND_ACK && dcallno == 1) {
/* Ignore */
return 1;
}
@@ -9675,7 +9682,7 @@ static int socket_process(struct iax2_thread *thread)
memset(&ies, 0, sizeof(ies));
}
- if (!dcallno && iax2_allow_new(f.frametype, f.subclass, 1)) {
+ if (!dcallno && iax2_allow_new(f.frametype, f.subclass.integer, 1)) {
/* only set NEW_ALLOW if calltoken checks out */
if (handle_call_token(fh, &ies, &sin, fd)) {
return 1;
@@ -9694,7 +9701,7 @@ static int socket_process(struct iax2_thread *thread)
} else {
/* Don't know anything about it yet */
f.frametype = AST_FRAME_NULL;
- f.subclass = 0;
+ f.subclass.integer = 0;
}
if (!fr->callno) {
@@ -9708,14 +9715,14 @@ static int socket_process(struct iax2_thread *thread)
* http://lists.digium.com/pipermail/asterisk-dev/2008-May/033217.html
*/
- if ((ntohs(mh->callno) & IAX_FLAG_FULL) && ((f.frametype == AST_FRAME_IAX) && (f.subclass == IAX_COMMAND_ACK))) {
+ if ((ntohs(mh->callno) & IAX_FLAG_FULL) && ((f.frametype == AST_FRAME_IAX) && (f.subclass.integer == IAX_COMMAND_ACK))) {
check_dcallno = 1;
}
if (!(fr->callno = find_callno(ntohs(mh->callno) & ~IAX_FLAG_FULL, dcallno, &sin, new, fd, check_dcallno))) {
- if (f.frametype == AST_FRAME_IAX && f.subclass == IAX_COMMAND_NEW) {
+ if (f.frametype == AST_FRAME_IAX && f.subclass.integer == IAX_COMMAND_NEW) {
send_apathetic_reply(1, ntohs(fh->scallno), &sin, IAX_COMMAND_REJECT, ntohl(fh->ts), fh->iseqno + 1, fd, NULL);
- } else if (f.frametype == AST_FRAME_IAX && (f.subclass == IAX_COMMAND_REGREQ || f.subclass == IAX_COMMAND_REGREL)) {
+ } else if (f.frametype == AST_FRAME_IAX && (f.subclass.integer == IAX_COMMAND_REGREQ || f.subclass.integer == IAX_COMMAND_REGREL)) {
send_apathetic_reply(1, ntohs(fh->scallno), &sin, IAX_COMMAND_REGREJ, ntohl(fh->ts), fh->iseqno + 1, fd, NULL);
}
return 1;
@@ -9730,10 +9737,10 @@ static int socket_process(struct iax2_thread *thread)
frame, reply with an inval */
if (ntohs(mh->callno) & IAX_FLAG_FULL) {
/* We can only raw hangup control frames */
- if (((f.subclass != IAX_COMMAND_INVAL) &&
- (f.subclass != IAX_COMMAND_TXCNT) &&
- (f.subclass != IAX_COMMAND_TXACC) &&
- (f.subclass != IAX_COMMAND_FWDOWNL))||
+ if (((f.subclass.integer != IAX_COMMAND_INVAL) &&
+ (f.subclass.integer != IAX_COMMAND_TXCNT) &&
+ (f.subclass.integer != IAX_COMMAND_TXACC) &&
+ (f.subclass.integer != IAX_COMMAND_FWDOWNL))||
(f.frametype != AST_FRAME_IAX))
raw_hangup(&sin, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, ntohs(mh->callno) & ~IAX_FLAG_FULL,
fd);
@@ -9762,8 +9769,8 @@ static int socket_process(struct iax2_thread *thread)
iaxs[fr->callno]->frames_received++;
if (!inaddrcmp(&sin, &iaxs[fr->callno]->addr) && !minivid &&
- f.subclass != IAX_COMMAND_TXCNT && /* for attended transfer */
- f.subclass != IAX_COMMAND_TXACC) { /* for attended transfer */
+ f.subclass.integer != IAX_COMMAND_TXCNT && /* for attended transfer */
+ f.subclass.integer != IAX_COMMAND_TXACC) { /* for attended transfer */
unsigned short new_peercallno;
new_peercallno = (unsigned short) (ntohs(mh->callno) & ~IAX_FLAG_FULL);
@@ -9777,7 +9784,7 @@ static int socket_process(struct iax2_thread *thread)
}
if (ntohs(mh->callno) & IAX_FLAG_FULL) {
if (iaxdebug)
- ast_debug(1, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
+ ast_debug(1, "Received packet %d, (%d, %u)\n", fh->oseqno, f.frametype, f.subclass.integer);
/* Check if it's out of order (and not an ACK or INVAL) */
fr->oseqno = fh->oseqno;
fr->iseqno = fh->iseqno;
@@ -9800,31 +9807,31 @@ static int socket_process(struct iax2_thread *thread)
updatehistory = 0;
if ((iaxs[fr->callno]->iseqno != fr->oseqno) &&
(iaxs[fr->callno]->iseqno ||
- ((f.subclass != IAX_COMMAND_TXCNT) &&
- (f.subclass != IAX_COMMAND_TXREADY) && /* for attended transfer */
- (f.subclass != IAX_COMMAND_TXREL) && /* for attended transfer */
- (f.subclass != IAX_COMMAND_UNQUELCH ) && /* for attended transfer */
- (f.subclass != IAX_COMMAND_TXACC)) ||
+ ((f.subclass.integer != IAX_COMMAND_TXCNT) &&
+ (f.subclass.integer != IAX_COMMAND_TXREADY) && /* for attended transfer */
+ (f.subclass.integer != IAX_COMMAND_TXREL) && /* for attended transfer */
+ (f.subclass.integer != IAX_COMMAND_UNQUELCH ) && /* for attended transfer */
+ (f.subclass.integer != IAX_COMMAND_TXACC)) ||
(f.frametype != AST_FRAME_IAX))) {
if (
- ((f.subclass != IAX_COMMAND_ACK) &&
- (f.subclass != IAX_COMMAND_INVAL) &&
- (f.subclass != IAX_COMMAND_TXCNT) &&
- (f.subclass != IAX_COMMAND_TXREADY) && /* for attended transfer */
- (f.subclass != IAX_COMMAND_TXREL) && /* for attended transfer */
- (f.subclass != IAX_COMMAND_UNQUELCH ) && /* for attended transfer */
- (f.subclass != IAX_COMMAND_TXACC) &&
- (f.subclass != IAX_COMMAND_VNAK)) ||
+ ((f.subclass.integer != IAX_COMMAND_ACK) &&
+ (f.subclass.integer != IAX_COMMAND_INVAL) &&
+ (f.subclass.integer != IAX_COMMAND_TXCNT) &&
+ (f.subclass.integer != IAX_COMMAND_TXREADY) && /* for attended transfer */
+ (f.subclass.integer != IAX_COMMAND_TXREL) && /* for attended transfer */
+ (f.subclass.integer != IAX_COMMAND_UNQUELCH ) && /* for attended transfer */
+ (f.subclass.integer != IAX_COMMAND_TXACC) &&
+ (f.subclass.integer != IAX_COMMAND_VNAK)) ||
(f.frametype != AST_FRAME_IAX)) {
/* If it's not an ACK packet, it's out of order. */
ast_debug(1, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
- iaxs[fr->callno]->iseqno, fr->oseqno, f.frametype, f.subclass);
+ iaxs[fr->callno]->iseqno, fr->oseqno, f.frametype, f.subclass.integer);
/* Check to see if we need to request retransmission,
* and take sequence number wraparound into account */
if ((unsigned char) (iaxs[fr->callno]->iseqno - fr->oseqno) < 128) {
/* If we've already seen it, ack it XXX There's a border condition here XXX */
if ((f.frametype != AST_FRAME_IAX) ||
- ((f.subclass != IAX_COMMAND_ACK) && (f.subclass != IAX_COMMAND_INVAL))) {
+ ((f.subclass.integer != IAX_COMMAND_ACK) && (f.subclass.integer != IAX_COMMAND_INVAL))) {
ast_debug(1, "Acking anyway\n");
/* XXX Maybe we should handle its ack to us, but then again, it's probably outdated anyway, and if
we have anything to send, we'll retransmit and get an ACK back anyway XXX */
@@ -9839,11 +9846,11 @@ static int socket_process(struct iax2_thread *thread)
}
} else {
/* Increment unless it's an ACK or VNAK */
- if (((f.subclass != IAX_COMMAND_ACK) &&
- (f.subclass != IAX_COMMAND_INVAL) &&
- (f.subclass != IAX_COMMAND_TXCNT) &&
- (f.subclass != IAX_COMMAND_TXACC) &&
- (f.subclass != IAX_COMMAND_VNAK)) ||
+ if (((f.subclass.integer != IAX_COMMAND_ACK) &&
+ (f.subclass.integer != IAX_COMMAND_INVAL) &&
+ (f.subclass.integer != IAX_COMMAND_TXCNT) &&
+ (f.subclass.integer != IAX_COMMAND_TXACC) &&
+ (f.subclass.integer != IAX_COMMAND_VNAK)) ||
(f.frametype != AST_FRAME_IAX))
iaxs[fr->callno]->iseqno++;
}
@@ -9858,7 +9865,7 @@ static int socket_process(struct iax2_thread *thread)
/* Handle implicit ACKing unless this is an INVAL, and only if this is
from the real peer, not the transfer peer */
if (!inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
- ((f.subclass != IAX_COMMAND_INVAL) ||
+ ((f.subclass.integer != IAX_COMMAND_INVAL) ||
(f.frametype != AST_FRAME_IAX))) {
unsigned char x;
int call_to_destroy;
@@ -9906,8 +9913,8 @@ static int socket_process(struct iax2_thread *thread)
}
if (inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
((f.frametype != AST_FRAME_IAX) ||
- ((f.subclass != IAX_COMMAND_TXACC) &&
- (f.subclass != IAX_COMMAND_TXCNT)))) {
+ ((f.subclass.integer != IAX_COMMAND_TXACC) &&
+ (f.subclass.integer != IAX_COMMAND_TXCNT)))) {
/* Only messages we accept from a transfer host are TXACC and TXCNT */
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
@@ -9987,16 +9994,16 @@ static int socket_process(struct iax2_thread *thread)
/* once we receive our first IAX Full Frame that is not CallToken related, send all
* queued signaling frames that were being held. */
- if ((f.frametype == AST_FRAME_IAX) && (f.subclass != IAX_COMMAND_CALLTOKEN) && iaxs[fr->callno]->hold_signaling) {
+ if ((f.frametype == AST_FRAME_IAX) && (f.subclass.integer != IAX_COMMAND_CALLTOKEN) && iaxs[fr->callno]->hold_signaling) {
send_signaling(iaxs[fr->callno]);
}
if (f.frametype == AST_FRAME_VOICE) {
- if (f.subclass != iaxs[fr->callno]->voiceformat) {
- iaxs[fr->callno]->voiceformat = f.subclass;
- ast_debug(1, "Ooh, voice format changed to %d\n", f.subclass);
+ if (f.subclass.codec != iaxs[fr->callno]->voiceformat) {
+ iaxs[fr->callno]->voiceformat = f.subclass.codec;
+ ast_debug(1, "Ooh, voice format changed to '%s'\n", ast_getformatname(f.subclass.codec));
if (iaxs[fr->callno]->owner) {
- int orignative;
+ format_t orignative;
retryowner:
if (ast_channel_trylock(iaxs[fr->callno]->owner)) {
DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);
@@ -10005,7 +10012,7 @@ retryowner:
if (iaxs[fr->callno]) {
if (iaxs[fr->callno]->owner) {
orignative = iaxs[fr->callno]->owner->nativeformats;
- iaxs[fr->callno]->owner->nativeformats = f.subclass;
+ iaxs[fr->callno]->owner->nativeformats = f.subclass.codec;
if (iaxs[fr->callno]->owner->readformat)
ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat);
iaxs[fr->callno]->owner->nativeformats = orignative;
@@ -10026,15 +10033,15 @@ retryowner:
}
}
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 (f.subclass.codec != iaxs[fr->callno]->videoformat) {
+ ast_debug(1, "Ooh, video format changed to %s\n", ast_getformatname(f.subclass.codec & ~0x1LL));
+ iaxs[fr->callno]->videoformat = f.subclass.codec & ~0x1LL;
}
}
if (f.frametype == AST_FRAME_CONTROL && iaxs[fr->callno]->owner) {
- if (f.subclass == AST_CONTROL_BUSY) {
+ if (f.subclass.integer == AST_CONTROL_BUSY) {
iaxs[fr->callno]->owner->hangupcause = AST_CAUSE_BUSY;
- } else if (f.subclass == AST_CONTROL_CONGESTION) {
+ } else if (f.subclass.integer == AST_CONTROL_CONGESTION) {
iaxs[fr->callno]->owner->hangupcause = AST_CAUSE_CONGESTION;
}
}
@@ -10042,22 +10049,22 @@ retryowner:
ast_sched_thread_del(sched, iaxs[fr->callno]->initid);
/* Handle the IAX pseudo frame itself */
if (iaxdebug)
- ast_debug(1, "IAX subclass %d received\n", f.subclass);
+ ast_debug(1, "IAX subclass %d received\n", f.subclass.integer);
/* Update last ts unless the frame's timestamp originated with us. */
if (iaxs[fr->callno]->last < fr->ts &&
- f.subclass != IAX_COMMAND_ACK &&
- f.subclass != IAX_COMMAND_PONG &&
- f.subclass != IAX_COMMAND_LAGRP) {
+ f.subclass.integer != IAX_COMMAND_ACK &&
+ f.subclass.integer != IAX_COMMAND_PONG &&
+ f.subclass.integer != IAX_COMMAND_LAGRP) {
iaxs[fr->callno]->last = fr->ts;
if (iaxdebug)
ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
}
- iaxs[fr->callno]->last_iax_message = f.subclass;
+ iaxs[fr->callno]->last_iax_message = f.subclass.integer;
if (!iaxs[fr->callno]->first_iax_message) {
- iaxs[fr->callno]->first_iax_message = f.subclass;
+ iaxs[fr->callno]->first_iax_message = f.subclass.integer;
}
- switch(f.subclass) {
+ switch(f.subclass.integer) {
case IAX_COMMAND_ACK:
/* Do nothing */
break;
@@ -10237,10 +10244,19 @@ retryowner:
return 1;
}
if (authdebug) {
- if(ast_test_flag64(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);
+ char tmp[256], tmp2[256], tmp3[256];
+ if (ast_test_flag64(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_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->capability));
+ } 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_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->peercapability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), iaxs[fr->callno]->capability));
+ }
}
} else {
/* Pick one... */
@@ -10271,17 +10287,23 @@ retryowner:
}
if (!format) {
+ char tmp[256], tmp2[256], tmp3[256];
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_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability));
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);
+ if (authdebug) {
+ 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_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->peercapability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), iaxs[fr->callno]->capability));
+ }
ast_set_flag64(iaxs[fr->callno], IAX_ALREADYGONE);
break;
}
@@ -10456,8 +10478,13 @@ retryowner:
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) {
+ char tmp1[256], tmp2[256];
+ ast_log(LOG_NOTICE, "Rejected call to %s, format %s incompatible with our capability %s.\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->capability));
+ }
} else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
if (iaxs[fr->callno]->owner) {
@@ -10565,9 +10592,9 @@ retryowner2:
f.offset = 0;
f.samples = 0;
iax_frame_wrap(fr, &f);
- if(f.subclass == IAX_COMMAND_LAGRQ) {
+ if (f.subclass.integer == IAX_COMMAND_LAGRQ) {
/* Received a LAGRQ - echo back a LAGRP */
- fr->af.subclass = IAX_COMMAND_LAGRP;
+ fr->af.subclass.integer = IAX_COMMAND_LAGRP;
iax2_send(iaxs[fr->callno], &fr->af, fr->ts, -1, 0, 0, 0);
} else {
/* Received LAGRP in response to our LAGRQ */
@@ -10587,7 +10614,7 @@ retryowner2:
}
if (authenticate_reply(iaxs[fr->callno], &iaxs[fr->callno]->addr, &ies, iaxs[fr->callno]->secret, iaxs[fr->callno]->outkey)) {
struct ast_frame hangup_fr = { .frametype = AST_FRAME_CONTROL,
- .subclass = AST_CONTROL_HANGUP,
+ .subclass.integer = AST_CONTROL_HANGUP,
};
ast_log(LOG_WARNING,
"I don't know how to authenticate %s to %s\n",
@@ -10661,16 +10688,26 @@ retryowner2:
ast_codec_pref_string(&iaxs[fr->callno]->prefs, host_pref_buf, sizeof(host_pref_buf) - 1);
}
if (!format) {
+ char tmp1[256], tmp2[256], tmp3[256];
if(!ast_test_flag64(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);
+ ast_debug(1, "We don't do requested format %s, falling back to peer capability '%s'\n",
+ ast_getformatname(iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peercapability));
format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
}
if (!format) {
if (authdebug) {
- if(ast_test_flag64(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_flag64(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_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->capability));
+ } 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_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->peercapability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), iaxs[fr->callno]->capability));
+ }
}
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -10709,12 +10746,22 @@ retryowner2:
}
}
if (!format) {
- ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
+ char tmp1[256], tmp2[256], tmp3[256];
+ ast_log(LOG_ERROR, "No best format in %s???\n",
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability));
if (authdebug) {
- if(ast_test_flag64(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_flag64(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_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->capability));
+ } 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_getformatname_multiple(tmp1, sizeof(tmp1), iaxs[fr->callno]->peerformat),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), iaxs[fr->callno]->peercapability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), iaxs[fr->callno]->capability));
+ }
}
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -10818,8 +10865,11 @@ immediatedial:
return 1;
}
} else {
+ char tmp[256];
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
- ast_verb(3, "Accepting DIAL from %s, formats = 0x%x\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat);
+ ast_verb(3, "Accepting DIAL from %s, formats = %s\n",
+ ast_inet_ntoa(sin.sin_addr),
+ ast_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->peerformat));
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1);
if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat, NULL)))
@@ -10894,7 +10944,7 @@ immediatedial:
if ((ast_strlen_zero(iaxs[fr->callno]->secret) && ast_strlen_zero(iaxs[fr->callno]->inkeys)) ||
ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_AUTHENTICATED)) {
- if (f.subclass == IAX_COMMAND_REGREL)
+ if (f.subclass.integer == IAX_COMMAND_REGREL)
memset(&sin, 0, sizeof(sin));
if (update_registry(&sin, fr->callno, ies.devicetype, fd, ies.refresh))
ast_log(LOG_WARNING, "Registry error\n");
@@ -11085,9 +11135,9 @@ immediatedial:
break;
}
default:
- ast_debug(1, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
+ ast_debug(1, "Unknown IAX command %d on %d/%d\n", f.subclass.integer, fr->callno, iaxs[fr->callno]->peercallno);
memset(&ied0, 0, sizeof(ied0));
- iax_ie_append_byte(&ied0, IAX_IE_IAX_UNKNOWN, f.subclass);
+ iax_ie_append_byte(&ied0, IAX_IE_IAX_UNKNOWN, f.subclass.integer);
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_UNSUPPORT, 0, ied0.buf, ied0.pos, -1);
}
/* Free remote variables (if any) */
@@ -11098,11 +11148,11 @@ immediatedial:
}
/* Don't actually pass these frames along */
- if ((f.subclass != IAX_COMMAND_ACK) &&
- (f.subclass != IAX_COMMAND_TXCNT) &&
- (f.subclass != IAX_COMMAND_TXACC) &&
- (f.subclass != IAX_COMMAND_INVAL) &&
- (f.subclass != IAX_COMMAND_VNAK)) {
+ if ((f.subclass.integer != IAX_COMMAND_ACK) &&
+ (f.subclass.integer != IAX_COMMAND_TXCNT) &&
+ (f.subclass.integer != IAX_COMMAND_TXACC) &&
+ (f.subclass.integer != IAX_COMMAND_INVAL) &&
+ (f.subclass.integer != IAX_COMMAND_VNAK)) {
if (iaxs[fr->callno] && iaxs[fr->callno]->aseqno != iaxs[fr->callno]->iseqno)
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
}
@@ -11115,7 +11165,7 @@ immediatedial:
} 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);
+ f.subclass.codec = iaxs[fr->callno]->videoformat | (ntohs(vh->ts) & 0x8000LL ? 1 : 0);
else {
ast_log(LOG_WARNING, "Received mini frame before first full video frame\n");
iax2_vnak(fr->callno);
@@ -11137,7 +11187,7 @@ immediatedial:
/* A mini frame */
f.frametype = AST_FRAME_VOICE;
if (iaxs[fr->callno]->voiceformat > 0)
- f.subclass = iaxs[fr->callno]->voiceformat;
+ f.subclass.codec = iaxs[fr->callno]->voiceformat;
else {
ast_debug(1, "Received mini frame before first full voice frame\n");
iax2_vnak(fr->callno);
@@ -11168,7 +11218,7 @@ immediatedial:
return 1;
}
/* Don't allow connected line updates unless we are configured to */
- if (f.frametype == AST_FRAME_CONTROL && f.subclass == AST_CONTROL_CONNECTED_LINE) {
+ if (f.frametype == AST_FRAME_CONTROL && f.subclass.integer == AST_CONTROL_CONNECTED_LINE) {
struct ast_party_connected_line connected;
if (!ast_test_flag64(iaxs[fr->callno], IAX_RECVCONNECTEDLINE)) {
@@ -11200,7 +11250,7 @@ immediatedial:
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 (f.subclass.codec == AST_FORMAT_SLINEAR)
ast_frame_byteswap_be(&f);
} else
f.samples = 0;
@@ -11212,7 +11262,7 @@ immediatedial:
fr->outoforder = 0;
} else {
if (iaxdebug && iaxs[fr->callno])
- ast_debug(1, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
+ ast_debug(1, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass.integer, fr->ts, iaxs[fr->callno]->last);
fr->outoforder = -1;
}
fr->cacheable = ((f.frametype == AST_FRAME_VOICE) || (f.frametype == AST_FRAME_VIDEO));
@@ -11670,11 +11720,11 @@ static void free_context(struct iax2_context *con)
}
}
-static struct ast_channel *iax2_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *iax2_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
int callno;
int res;
- int fmt, native;
+ format_t fmt, native;
struct sockaddr_in sin;
struct ast_channel *c;
struct parsed_dial_string pds;
@@ -12579,7 +12629,7 @@ static void set_config_destroy(void)
static int set_config(const char *config_file, int reload)
{
struct ast_config *cfg, *ucfg;
- int capability=iax2_capability;
+ format_t capability = iax2_capability;
struct ast_variable *v;
char *cat;
const char *utype;
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 1461b83c7..c1181dbfe 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -103,7 +103,7 @@ struct jingle_pvt {
iksrule *ringrule; /*!< Rule for matching RING request */
int initiator; /*!< If we're the initiator */
int alreadygone;
- int capability;
+ format_t capability;
struct ast_codec_pref prefs;
struct jingle_candidate *theircandidates;
struct jingle_candidate *ourcandidates;
@@ -115,8 +115,8 @@ struct jingle_pvt {
struct ast_rtp_instance *rtp; /*!< RTP audio session */
char video_content_name[100]; /*!< name attribute of content tag */
struct ast_rtp_instance *vrtp; /*!< RTP video session */
- int jointcapability; /*!< Supported capability at both ends (codecs ) */
- int peercapability;
+ format_t jointcapability; /*!< Supported capability at both ends (codecs ) */
+ format_t peercapability;
struct jingle_pvt *next; /* Next entity */
};
@@ -146,7 +146,7 @@ struct jingle {
char user[100];
char context[100];
char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */
- int capability;
+ format_t capability;
ast_group_t callgroup; /*!< Call group */
ast_group_t pickupgroup; /*!< Pickup group */
int callingpres; /*!< Calling presentation */
@@ -163,12 +163,12 @@ struct jingle_container {
static const char desc[] = "Jingle Channel";
static const char channel_type[] = "Jingle";
-static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
+static format_t global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
AST_MUTEX_DEFINE_STATIC(jinglelock); /*!< Protect the interface list (of jingle_pvt's) */
/* Forward declarations */
-static struct ast_channel *jingle_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *jingle_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int jingle_sendtext(struct ast_channel *ast, const char *text);
static int jingle_digit_begin(struct ast_channel *ast, char digit);
static int jingle_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
@@ -300,7 +300,7 @@ static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
struct aji_client *c = client->connection;
iks *iq, *jingle, *dcodecs, *payload_red, *payload_audio, *payload_cn;
int x;
- int pref_codec = 0;
+ format_t pref_codec = 0;
int alreadysent = 0;
if (p->initiator)
@@ -312,7 +312,7 @@ static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
if (iq && jingle && dcodecs) {
iks_insert_attrib(dcodecs, "xmlns", JINGLE_AUDIO_RTP_NS);
- for (x = 0; x < 32; x++) {
+ for (x = 0; x < 64; x++) {
if (!(pref_codec = ast_codec_pref_index(&client->prefs, x)))
break;
if (!(client->capability & pref_codec))
@@ -404,13 +404,13 @@ static enum ast_rtp_glue_result jingle_get_rtp_peer(struct ast_channel *chan, st
return res;
}
-static int jingle_get_codec(struct ast_channel *chan)
+static format_t jingle_get_codec(struct ast_channel *chan)
{
struct jingle_pvt *p = chan->tech_pvt;
return p->peercapability;
}
-static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, int codecs, int nat_active)
+static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, format_t codecs, int nat_active)
{
struct jingle_pvt *p;
@@ -511,19 +511,19 @@ static int jingle_handle_dtmf(struct jingle *client, ikspak *pak)
if((dtmf = iks_find_attrib(dtmfnode, "code"))) {
if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-up")) {
struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass.integer);
} else if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-down")) {
struct ast_frame f = {AST_FRAME_DTMF_END, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass.integer);
} else if(iks_find_attrib(pak->x, "dtmf")) { /* 250 millasecond default */
struct ast_frame f = {AST_FRAME_DTMF, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass.integer);
}
}
} else if ((dtmfnode = iks_find_with_attrib(pak->x, JINGLE_NODE, "action", "session-info"))) {
@@ -531,14 +531,14 @@ static int jingle_handle_dtmf(struct jingle *client, ikspak *pak)
if((dtmf = iks_find_attrib(dtmfchild, "code"))) {
if(iks_find_with_attrib(dtmfnode, "dtmf", "action", "button-up")) {
struct ast_frame f = {AST_FRAME_DTMF_END, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass.integer);
} else if(iks_find_with_attrib(dtmfnode, "dtmf", "action", "button-down")) {
struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
- f.subclass = dtmf[0];
+ f.subclass.integer = dtmf[0];
ast_queue_frame(tmp->owner, &f);
- ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("JINGLE! DTMF-relay event received: %c\n", f.subclass.integer);
}
}
}
@@ -1169,17 +1169,17 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
if (p->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
+ if (f->subclass.codec != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+ ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(f->subclass.codec));
p->owner->nativeformats =
- (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
+ (p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass.codec;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
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.codec);
} */
}
}
@@ -1202,14 +1202,17 @@ static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
{
struct jingle_pvt *p = ast->tech_pvt;
int res = 0;
+ char buf[256];
switch (frame->frametype) {
case AST_FRAME_VOICE:
- if (!(frame->subclass & ast->nativeformats)) {
+ if (!(frame->subclass.codec & ast->nativeformats)) {
ast_log(LOG_WARNING,
- "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
- frame->subclass, ast->nativeformats, ast->readformat,
- ast->writeformat);
+ "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
return 0;
}
if (p) {
@@ -1479,7 +1482,7 @@ static int jingle_hangup(struct ast_channel *ast)
}
/*! \brief Part of PBX interface */
-static struct ast_channel *jingle_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *jingle_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct jingle_pvt *p = NULL;
struct jingle *client = NULL;
diff --git a/channels/chan_local.c b/channels/chan_local.c
index c699a5cba..f26084b49 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -60,7 +60,7 @@ static struct ast_jb_conf g_jb_conf = {
.impl = "",
};
-static struct ast_channel *local_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *local_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int local_digit_begin(struct ast_channel *ast, char digit);
static int local_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int local_call(struct ast_channel *ast, char *dest, int timeout);
@@ -273,7 +273,7 @@ static int local_answer(struct ast_channel *ast)
isoutbound = IS_OUTBOUND(ast, p);
if (isoutbound) {
/* Pass along answer since somebody answered us */
- struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
+ struct ast_frame answer = { AST_FRAME_CONTROL, { AST_CONTROL_ANSWER } };
res = local_queue_frame(p, isoutbound, &answer, ast, 1);
} else
ast_log(LOG_WARNING, "Huh? Local is being asked to answer?\n");
@@ -443,7 +443,7 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da
} else {
f.datalen = ast_redirecting_build_data(frame_data, sizeof(frame_data), &this_channel->redirecting);
}
- f.subclass = condition;
+ f.subclass.integer = condition;
f.data.ptr = frame_data;
if (!(res = local_queue_frame(p, isoutbound, &f, ast, 1))) {
ast_mutex_unlock(&p->lock);
@@ -455,7 +455,7 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da
/* Queue up a frame representing the indication as a control frame */
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
- f.subclass = condition;
+ f.subclass.integer = condition;
f.data.ptr = (void*)data;
f.datalen = datalen;
if (!(res = local_queue_frame(p, isoutbound, &f, ast, 1)))
@@ -477,7 +477,7 @@ static int local_digit_begin(struct ast_channel *ast, char digit)
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
- f.subclass = digit;
+ f.subclass.integer = digit;
if (!(res = local_queue_frame(p, isoutbound, &f, ast, 0)))
ast_mutex_unlock(&p->lock);
@@ -496,7 +496,7 @@ static int local_digit_end(struct ast_channel *ast, char digit, unsigned int dur
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
- f.subclass = digit;
+ f.subclass.integer = digit;
f.len = duration;
if (!(res = local_queue_frame(p, isoutbound, &f, ast, 0)))
ast_mutex_unlock(&p->lock);
@@ -535,7 +535,7 @@ static int local_sendhtml(struct ast_channel *ast, int subclass, const char *dat
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
- f.subclass = subclass;
+ f.subclass.integer = subclass;
f.data.ptr = (char *)data;
f.datalen = datalen;
if (!(res = local_queue_frame(p, isoutbound, &f, ast, 0)))
@@ -646,7 +646,7 @@ static int local_hangup(struct ast_channel *ast)
{
struct local_pvt *p = ast->tech_pvt;
int isoutbound;
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .data.uint32 = ast->hangupcause };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_HANGUP }, .data.uint32 = ast->hangupcause };
struct ast_channel *ochan = NULL;
int glaredetect = 0, res = 0;
@@ -857,7 +857,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
}
/*! \brief Part of PBX interface */
-static struct ast_channel *local_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *local_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct local_pvt *p = NULL;
struct ast_channel *chan = NULL;
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index a03de42c3..e3cc64e98 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -216,7 +216,7 @@ static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
-static int capability = AST_FORMAT_ULAW;
+static format_t capability = AST_FORMAT_ULAW;
static int nonCodecCapability = AST_RTP_DTMF;
static char ourhost[MAXHOSTNAMELEN];
@@ -355,7 +355,7 @@ struct mgcp_endpoint {
int iseq; /*!< Not used? */
int lastout; /*!< tracking this on the subchannels. Is it needed here? */
int needdestroy; /*!< Not used? */
- int capability;
+ format_t capability;
int nonCodecCapability;
int onhooktime;
int msgstate; /*!< voicemail message state */
@@ -423,7 +423,7 @@ static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone);
static int transmit_modify_request(struct mgcp_subchannel *sub);
static int transmit_connect(struct mgcp_subchannel *sub);
static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callernum, char *callername);
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, int codecs);
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, format_t codecs);
static int transmit_connection_del(struct mgcp_subchannel *sub);
static int transmit_audit_endpoint(struct mgcp_endpoint *p);
static void start_rtp(struct mgcp_subchannel *sub);
@@ -433,7 +433,7 @@ static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
static char *mgcp_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static int reload_config(int reload);
-static struct ast_channel *mgcp_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *mgcp_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int mgcp_call(struct ast_channel *ast, char *dest, int timeout);
static int mgcp_hangup(struct ast_channel *ast);
static int mgcp_answer(struct ast_channel *ast);
@@ -639,8 +639,7 @@ static void mgcp_queue_hangup(struct mgcp_subchannel *sub)
static void mgcp_queue_control(struct mgcp_subchannel *sub, int control)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = control;
+ struct ast_frame f = { AST_FRAME_CONTROL, { control } };
return mgcp_queue_frame(sub, &f);
}
@@ -1194,9 +1193,9 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
if (sub->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != sub->owner->nativeformats) {
- ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
- sub->owner->nativeformats = f->subclass;
+ if (f->subclass.codec != sub->owner->nativeformats) {
+ ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(f->subclass.codec));
+ sub->owner->nativeformats = f->subclass.codec;
ast_set_read_format(sub->owner, sub->owner->readformat);
ast_set_write_format(sub->owner, sub->owner->writeformat);
}
@@ -1227,6 +1226,8 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
{
struct mgcp_subchannel *sub = ast->tech_pvt;
int res = 0;
+ char buf[256];
+
if (frame->frametype != AST_FRAME_VOICE) {
if (frame->frametype == AST_FRAME_IMAGE)
return 0;
@@ -1235,9 +1236,12 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
return 0;
}
} else {
- if (!(frame->subclass & ast->nativeformats)) {
- ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
- frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
+ if (!(frame->subclass.codec & ast->nativeformats)) {
+ ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
/* return -1; */
}
}
@@ -1911,13 +1915,15 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
char host[258];
int len;
int portno;
- int peercapability, peerNonCodecCapability;
+ format_t peercapability;
+ int peerNonCodecCapability;
struct sockaddr_in sin;
char *codecs;
struct ast_hostent ahp; struct hostent *hp;
int codec, codec_count=0;
int iterator;
struct mgcp_endpoint *p = sub->parent;
+ char tmp1[256], tmp2[256], tmp3[256];
/* Get codec and RTP info from SDP */
m = get_sdp(req, "m");
@@ -1975,8 +1981,10 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
/* Now gather all of the codecs that were asked for: */
ast_rtp_codecs_payload_formats(ast_rtp_instance_get_codecs(sub->rtp), &peercapability, &peerNonCodecCapability);
p->capability = capability & peercapability;
- ast_debug(1, "Capabilities: us - %d, them - %d, combined - %d\n",
- capability, peercapability, p->capability);
+ ast_debug(1, "Capabilities: us - %s, them - %s, combined - %s\n",
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), capability),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), peercapability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), p->capability));
ast_debug(1, "Non-codec capabilities: us - %d, them - %d, combined - %d\n",
nonCodecCapability, peerNonCodecCapability, p->nonCodecCapability);
if (!p->capability) {
@@ -2131,7 +2139,7 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
char t[256];
char m[256] = "";
char a[1024] = "";
- int x;
+ format_t x;
struct sockaddr_in dest = { 0, };
struct mgcp_endpoint *p = sub->parent;
/* XXX We break with the "recommendation" and send our IP, in order that our
@@ -2162,9 +2170,13 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr));
ast_copy_string(t, "t=0 0\r\n", sizeof(t));
snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port));
- for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+ for (x = 1LL; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+ if (!(x & AST_FORMAT_AUDIO_MASK)) {
+ /* Audio is now discontiguous */
+ continue;
+ }
if (p->capability & x) {
- ast_debug(1, "Answering with capability %d\n", x);
+ ast_debug(1, "Answering with capability %s\n", ast_getformatname(x));
codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, x);
if (codec > -1) {
snprintf(costr, sizeof(costr), " %d", codec);
@@ -2174,9 +2186,9 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
}
}
}
- for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
+ for (x = 1LL; x <= AST_RTP_MAX; x <<= 1) {
if (p->nonCodecCapability & x) {
- ast_debug(1, "Answering with non-codec capability %d\n", x);
+ ast_debug(1, "Answering with non-codec capability %d\n", (int) x);
codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 0, x);
if (codec > -1) {
snprintf(costr, sizeof(costr), " %d", codec);
@@ -2205,13 +2217,13 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
return 0;
}
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, int codecs)
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, format_t codecs)
{
struct mgcp_request resp;
char local[256];
char tmp[80];
struct mgcp_endpoint *p = sub->parent;
- int x;
+ format_t x;
if (ast_strlen_zero(sub->cxident) && rtp) {
/* We don't have a CXident yet, store the destination and
@@ -2221,6 +2233,10 @@ static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_
}
ast_copy_string(local, "e:on, s:off, p:20", sizeof(local));
for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+ if (!(x & AST_FORMAT_AUDIO_MASK)) {
+ /* No longer contiguous */
+ continue;
+ }
if (p->capability & x) {
snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
@@ -2270,6 +2286,10 @@ static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp
ast_copy_string(local, "e:on, s:off, p:20", sizeof(local));
for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+ if (!(x & AST_FORMAT_AUDIO_MASK)) {
+ /* No longer contiguous */
+ continue;
+ }
if (p->capability & x) {
snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
@@ -2352,12 +2372,12 @@ static int transmit_connect(struct mgcp_subchannel *sub)
struct mgcp_request resp;
char local[256];
char tmp[80];
- int x;
+ format_t x;
struct mgcp_endpoint *p = sub->parent;
ast_copy_string(local, "p:20, s:off, e:on", sizeof(local));
- for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
+ for (x = 1LL; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
if (p->capability & x) {
snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
@@ -2455,7 +2475,8 @@ static int transmit_modify_request(struct mgcp_subchannel *sub)
{
struct mgcp_request resp;
struct mgcp_endpoint *p = sub->parent;
- int x, fc;
+ format_t x;
+ int fc = 1;
char local[256];
char tmp[80];
@@ -3468,7 +3489,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
(ev[0] == '*') || (ev[0] == '#'))) {
if (sub && sub->owner && (sub->owner->_state >= AST_STATE_UP)) {
f.frametype = AST_FRAME_DTMF;
- f.subclass = ev[0];
+ f.subclass.integer = ev[0];
f.src = "mgcp";
/* XXX MUST queue this frame to all subs in threeway call if threeway call is active */
mgcp_queue_frame(sub, &f);
@@ -3825,9 +3846,9 @@ static int restart_monitor(void)
return 0;
}
-static struct ast_channel *mgcp_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *mgcp_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct mgcp_subchannel *sub;
struct ast_channel *tmpc = NULL;
char tmp[256];
@@ -3836,7 +3857,7 @@ static struct ast_channel *mgcp_request(const char *type, int format, const stru
oldformat = format;
format &= capability;
if (!format) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), format));
/*return NULL;*/
}
ast_copy_string(tmp, dest, sizeof(tmp));
@@ -4315,7 +4336,7 @@ static enum ast_rtp_glue_result mgcp_get_rtp_peer(struct ast_channel *chan, stru
return AST_RTP_GLUE_RESULT_LOCAL;
}
-static int mgcp_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)
+static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
{
/* XXX Is there such thing as video support with MGCP? XXX */
struct mgcp_subchannel *sub;
@@ -4327,7 +4348,7 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *
return -1;
}
-static int mgcp_get_codec(struct ast_channel *chan)
+static format_t mgcp_get_codec(struct ast_channel *chan)
{
struct mgcp_subchannel *sub = chan->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 3adcf7b75..fdf4cf2fd 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -6977,9 +6977,9 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
return frame;
}
- ast_debug(1, "Detected inband DTMF digit: %c\n", f->subclass);
+ ast_debug(1, "Detected inband DTMF digit: %c\n", f->subclass.integer);
- if (tmp->faxdetect && (f->subclass == 'f')) {
+ if (tmp->faxdetect && (f->subclass.integer == 'f')) {
/* Fax tone -- Handle and return NULL */
if (!tmp->faxhandled) {
struct ast_channel *ast = tmp->ast;
@@ -7028,8 +7028,8 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
}
}
- if (tmp->ast_dsp && (f->subclass != 'f')) {
- chan_misdn_log(2, tmp->bc->port, " --> * SEND: DTMF (AST_DSP) :%c\n", f->subclass);
+ if (tmp->ast_dsp && (f->subclass.integer != 'f')) {
+ chan_misdn_log(2, tmp->bc->port, " --> * SEND: DTMF (AST_DSP) :%c\n", f->subclass.integer);
}
return f;
@@ -7084,7 +7084,7 @@ static struct ast_frame *misdn_read(struct ast_channel *ast)
}
tmp->frame.frametype = AST_FRAME_VOICE;
- tmp->frame.subclass = AST_FORMAT_ALAW;
+ tmp->frame.subclass.codec = AST_FORMAT_ALAW;
tmp->frame.datalen = len;
tmp->frame.samples = len;
tmp->frame.mallocd = 0;
@@ -7150,13 +7150,13 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
}
- if (!frame->subclass) {
+ if (!frame->subclass.codec) {
chan_misdn_log(4, ch->bc->port, "misdn_write: * prods us\n");
return 0;
}
- if (!(frame->subclass & prefformat)) {
- chan_misdn_log(-1, ch->bc->port, "Got Unsupported Frame with Format:%d\n", frame->subclass);
+ if (!(frame->subclass.codec & prefformat)) {
+ chan_misdn_log(-1, ch->bc->port, "Got Unsupported Frame with Format:%s\n", ast_getformatname(frame->subclass.codec));
return 0;
}
@@ -7301,7 +7301,7 @@ static enum ast_bridge_result misdn_bridge(struct ast_channel *c0,
if (!f) {
chan_misdn_log(4, ch1->bc->port, "Read Null Frame\n");
} else {
- chan_misdn_log(4, ch1->bc->port, "Read Frame Control class:%d\n", f->subclass);
+ chan_misdn_log(4, ch1->bc->port, "Read Frame Control class:%d\n", f->subclass.integer);
}
*fo = f;
@@ -7310,7 +7310,7 @@ static enum ast_bridge_result misdn_bridge(struct ast_channel *c0,
}
if (f->frametype == AST_FRAME_DTMF) {
- chan_misdn_log(1, 0, "Read DTMF %d from %s\n", f->subclass, who->exten);
+ chan_misdn_log(1, 0, "Read DTMF %d from %s\n", f->subclass.integer, who->exten);
*fo = f;
*rc = who;
@@ -7437,7 +7437,7 @@ static struct chan_list *init_chan_list(int orig)
return cl;
}
-static struct ast_channel *misdn_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *misdn_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct ast_channel *ast;
char group[BUFFERSIZE + 1] = "";
@@ -8280,7 +8280,7 @@ static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch,
while (!ast_strlen_zero(predial)) {
fr.frametype = AST_FRAME_DTMF;
- fr.subclass = *predial;
+ fr.subclass.integer = *predial;
fr.src = NULL;
fr.data.ptr = NULL;
fr.datalen = 0;
@@ -9547,7 +9547,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_DTMF;
- fr.subclass = bc->dtmf ;
+ fr.subclass.integer = bc->dtmf ;
fr.src = NULL;
fr.data.ptr = NULL;
fr.datalen = 0;
@@ -9647,7 +9647,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_DTMF;
- fr.subclass = bc->info_dad[0] ;
+ fr.subclass.integer = bc->info_dad[0] ;
fr.src = NULL;
fr.data.ptr = NULL;
fr.datalen = 0;
@@ -10304,7 +10304,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
/* In Data Modes we queue frames */
frame.frametype = AST_FRAME_VOICE; /* we have no data frames yet */
- frame.subclass = AST_FORMAT_ALAW;
+ frame.subclass.codec = AST_FORMAT_ALAW;
frame.datalen = bc->bframe_len;
frame.samples = bc->bframe_len;
frame.mallocd = 0;
diff --git a/channels/chan_multicast_rtp.c b/channels/chan_multicast_rtp.c
index d2bbc6875..24c073215 100644
--- a/channels/chan_multicast_rtp.c
+++ b/channels/chan_multicast_rtp.c
@@ -52,7 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static const char tdesc[] = "Multicast RTP Paging Channel Driver";
/* Forward declarations */
-static struct ast_channel *multicast_rtp_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *multicast_rtp_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int multicast_rtp_call(struct ast_channel *ast, char *dest, int timeout);
static int multicast_rtp_hangup(struct ast_channel *ast);
static struct ast_frame *multicast_rtp_read(struct ast_channel *ast);
@@ -107,13 +107,13 @@ static int multicast_rtp_hangup(struct ast_channel *ast)
}
/*! \brief Function called when we should prepare to call the destination */
-static struct ast_channel *multicast_rtp_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *multicast_rtp_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
char *tmp = ast_strdupa(data), *multicast_type = tmp, *destination, *control;
struct ast_rtp_instance *instance;
struct sockaddr_in control_address = { .sin_family = AF_INET, }, destination_address = { .sin_family = AF_INET, };
struct ast_channel *chan;
- int fmt = ast_best_codec(format);
+ format_t fmt = ast_best_codec(format);
/* If no type was given we can't do anything */
if (ast_strlen_zero(multicast_type)) {
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index d7b6cc3f4..6e1fff8aa 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -325,7 +325,7 @@ static struct chan_oss_pvt oss_default = {
static int setformat(struct chan_oss_pvt *o, int mode);
-static struct ast_channel *oss_request(const char *type, int format, const struct ast_channel *requestor,
+static struct ast_channel *oss_request(const char *type, format_t format, const struct ast_channel *requestor,
void *data, int *cause);
static int oss_digit_begin(struct ast_channel *c, char digit);
static int oss_digit_end(struct ast_channel *c, char digit, unsigned int duration);
@@ -591,7 +591,7 @@ static int oss_text(struct ast_channel *c, const char *text)
static int oss_call(struct ast_channel *c, char *dest, int timeout)
{
struct chan_oss_pvt *o = c->tech_pvt;
- struct ast_frame f = { 0, };
+ struct ast_frame f = { AST_FRAME_CONTROL, };
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(name);
AST_APP_ARG(flags);
@@ -602,24 +602,20 @@ static int oss_call(struct ast_channel *c, char *dest, int timeout)
ast_verbose(" << Call to device '%s' dnid '%s' rdnis '%s' on console from '%s' <%s> >>\n", dest, c->cid.cid_dnid, c->cid.cid_rdnis, c->cid.cid_name, c->cid.cid_num);
if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "answer") == 0) {
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
ast_queue_frame(c, &f);
} else if (!ast_strlen_zero(args.flags) && strcasecmp(args.flags, "noanswer") == 0) {
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_RINGING;
+ f.subclass.integer = AST_CONTROL_RINGING;
ast_queue_frame(c, &f);
ast_indicate(c, AST_CONTROL_RINGING);
} else if (o->autoanswer) {
ast_verbose(" << Auto-answered >> \n");
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
ast_queue_frame(c, &f);
o->hookstate = 1;
} else {
ast_verbose("<< Type 'answer' to answer, or use 'autoanswer' for future calls >> \n");
- f.frametype = AST_FRAME_CONTROL;
- f.subclass = AST_CONTROL_RINGING;
+ f.subclass.integer = AST_CONTROL_RINGING;
ast_queue_frame(c, &f);
ast_indicate(c, AST_CONTROL_RINGING);
}
@@ -717,7 +713,7 @@ static struct ast_frame *oss_read(struct ast_channel *c)
return f;
/* ok we can build and deliver the frame to the caller */
f->frametype = AST_FRAME_VOICE;
- f->subclass = AST_FORMAT_SLINEAR;
+ f->subclass.codec = AST_FORMAT_SLINEAR;
f->samples = FRAME_SIZE;
f->datalen = FRAME_SIZE * 2;
f->data.ptr = o->oss_read_buf + AST_FRIENDLY_OFFSET;
@@ -824,7 +820,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
return c;
}
-static struct ast_channel *oss_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *oss_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct ast_channel *c;
struct chan_oss_pvt *o;
@@ -833,6 +829,7 @@ static struct ast_channel *oss_request(const char *type, int format, const struc
AST_APP_ARG(flags);
);
char *parse = ast_strdupa(data);
+ char buf[256];
AST_NONSTANDARD_APP_ARGS(args, parse, '/');
o = find_desc(args.name);
@@ -844,7 +841,7 @@ static struct ast_channel *oss_request(const char *type, int format, const struc
return NULL;
}
if ((format & AST_FORMAT_SLINEAR) == 0) {
- ast_log(LOG_NOTICE, "Format 0x%x unsupported\n", format);
+ ast_log(LOG_NOTICE, "Format %s unsupported\n", ast_getformatname_multiple(buf, sizeof(buf), format));
return NULL;
}
if (o->owner) {
@@ -942,7 +939,7 @@ static char *console_autoanswer(struct ast_cli_entry *e, int cmd, struct ast_cli
/*! \brief helper function for the answer key/cli command */
static char *console_do_answer(int fd)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_ANSWER } };
struct chan_oss_pvt *o = find_desc(oss_active);
if (!o->owner) {
if (fd > -1)
@@ -1007,7 +1004,7 @@ static char *console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_a
int i = strlen(buf);
buf[i] = '\n';
f.frametype = AST_FRAME_TEXT;
- f.subclass = 0;
+ f.subclass.integer = 0;
f.data.ptr = buf;
f.datalen = i + 1;
ast_queue_frame(o->owner, &f);
@@ -1043,7 +1040,7 @@ static char *console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
static char *console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH } };
struct chan_oss_pvt *o = find_desc(oss_active);
if (cmd == CLI_INIT) {
@@ -1086,7 +1083,7 @@ static char *console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return CLI_SHOWUSAGE;
if (o->owner) { /* already in a call */
int i;
- struct ast_frame f = { AST_FRAME_DTMF, 0 };
+ struct ast_frame f = { AST_FRAME_DTMF, { 0 } };
const char *s;
if (a->argc == e->args) { /* argument is mandatory here */
@@ -1096,7 +1093,7 @@ static char *console_dial(struct ast_cli_entry *e, int cmd, struct ast_cli_args
s = a->argv[e->args];
/* send the string one char at a time */
for (i = 0; i < strlen(s); i++) {
- f.subclass = s[i];
+ f.subclass.integer = s[i];
ast_queue_frame(o->owner, &f);
}
return CLI_SUCCESS;
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 736fb2708..b84c39c9f 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -125,8 +125,8 @@ static struct phone_pvt {
int fd; /* Raw file descriptor for this device */
struct ast_channel *owner; /* Channel we belong to, possibly NULL */
int mode; /* Is this in the */
- int lastformat; /* Last output format */
- int lastinput; /* Last input format */
+ format_t lastformat; /* Last output format */
+ format_t lastinput; /* Last input format */
int ministate; /* Miniature state, for dialtone mode */
char dev[256]; /* Device name */
struct phone_pvt *next; /* Next channel in list */
@@ -150,7 +150,7 @@ static struct phone_pvt {
static char cid_num[AST_MAX_EXTENSION];
static char cid_name[AST_MAX_EXTENSION];
-static struct ast_channel *phone_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *phone_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int phone_digit_begin(struct ast_channel *ast, char digit);
static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int phone_call(struct ast_channel *ast, char *dest, int timeout);
@@ -433,8 +433,8 @@ static int phone_setup(struct ast_channel *ast)
if (p->lastinput != ast->rawreadformat) {
p->lastinput = ast->rawreadformat;
if (ioctl(p->fd, PHONE_REC_CODEC, ast->rawreadformat)) {
- ast_log(LOG_WARNING, "Failed to set codec to %d\n",
- ast->rawreadformat);
+ ast_log(LOG_WARNING, "Failed to set codec to %s\n",
+ ast_getformatname(ast->rawreadformat));
return -1;
}
}
@@ -506,7 +506,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
/* We've got a digit -- Just handle this nicely and easily */
digit = ioctl(p->fd, PHONE_GET_DTMF_ASCII);
- p->fr.subclass = digit;
+ p->fr.subclass.integer = digit;
p->fr.frametype = AST_FRAME_DTMF;
return &p->fr;
}
@@ -521,7 +521,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
if (ast->_state == AST_STATE_RINGING) {
/* They've picked up the phone */
p->fr.frametype = AST_FRAME_CONTROL;
- p->fr.subclass = AST_CONTROL_ANSWER;
+ p->fr.subclass.integer = AST_CONTROL_ANSWER;
phone_setup(ast);
ast_setstate(ast, AST_STATE_UP);
return &p->fr;
@@ -540,7 +540,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
#endif
/* Strange -- nothing there.. */
p->fr.frametype = AST_FRAME_NULL;
- p->fr.subclass = 0;
+ p->fr.subclass.integer = 0;
return &p->fr;
}
@@ -594,10 +594,10 @@ static struct ast_frame *phone_read(struct ast_channel *ast)
AST_FRAME_VOICE :
p->lastinput <= AST_FORMAT_PNG ? AST_FRAME_IMAGE
: AST_FRAME_VIDEO;
- p->fr.subclass = p->lastinput;
+ p->fr.subclass.codec = p->lastinput;
p->fr.offset = AST_FRIENDLY_OFFSET;
/* Byteswap from little-endian to native-endian */
- if (p->fr.subclass == AST_FORMAT_SLINEAR)
+ if (p->fr.subclass.codec == AST_FORMAT_SLINEAR)
ast_frame_byteswap_le(&p->fr);
return &p->fr;
}
@@ -659,10 +659,10 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
return 0;
}
- if (!(frame->subclass &
+ if (!(frame->subclass.codec &
(AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_G729A)) &&
p->mode != MODE_FXS) {
- ast_log(LOG_WARNING, "Cannot handle frames in %d format\n", frame->subclass);
+ ast_log(LOG_WARNING, "Cannot handle frames in %s format\n", ast_getformatname(frame->subclass.codec));
return -1;
}
#if 0
@@ -677,7 +677,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
return 0;
}
#endif
- if (frame->subclass == AST_FORMAT_G729A) {
+ if (frame->subclass.codec == AST_FORMAT_G729A) {
if (p->lastformat != AST_FORMAT_G729A) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
@@ -700,7 +700,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
return -1;
}
maxfr = 80;
- } else if (frame->subclass == AST_FORMAT_G723_1) {
+ } else if (frame->subclass.codec == AST_FORMAT_G723_1) {
if (p->lastformat != AST_FORMAT_G723_1) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
@@ -723,7 +723,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
return -1;
}
maxfr = 24;
- } else if (frame->subclass == AST_FORMAT_SLINEAR) {
+ } else if (frame->subclass.codec == AST_FORMAT_SLINEAR) {
if (p->lastformat != AST_FORMAT_SLINEAR) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
@@ -742,7 +742,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
p->obuflen = 0;
}
maxfr = 480;
- } else if (frame->subclass == AST_FORMAT_ULAW) {
+ } else if (frame->subclass.codec == AST_FORMAT_ULAW) {
if (p->lastformat != AST_FORMAT_ULAW) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
@@ -762,21 +762,21 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
}
maxfr = 240;
} else {
- if (p->lastformat != frame->subclass) {
+ if (p->lastformat != frame->subclass.codec) {
ioctl(p->fd, PHONE_PLAY_STOP);
ioctl(p->fd, PHONE_REC_STOP);
- if (ioctl(p->fd, PHONE_PLAY_CODEC, frame->subclass)) {
- ast_log(LOG_WARNING, "Unable to set %d mode\n",
- frame->subclass);
+ if (ioctl(p->fd, PHONE_PLAY_CODEC, (int) frame->subclass.codec)) {
+ ast_log(LOG_WARNING, "Unable to set %s mode\n",
+ ast_getformatname(frame->subclass.codec));
return -1;
}
- if (ioctl(p->fd, PHONE_REC_CODEC, frame->subclass)) {
- ast_log(LOG_WARNING, "Unable to set %d mode\n",
- frame->subclass);
+ if (ioctl(p->fd, PHONE_REC_CODEC, (int) frame->subclass.codec)) {
+ ast_log(LOG_WARNING, "Unable to set %s mode\n",
+ ast_getformatname(frame->subclass.codec));
return -1;
}
- p->lastformat = frame->subclass;
- p->lastinput = frame->subclass;
+ p->lastformat = frame->subclass.codec;
+ p->lastinput = frame->subclass.codec;
codecset = 1;
/* Reset output buffer */
p->obuflen = 0;
@@ -816,7 +816,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
} else {
int swap = 0;
#if __BYTE_ORDER == __BIG_ENDIAN
- if (frame->subclass == AST_FORMAT_SLINEAR)
+ if (frame->subclass.codec == AST_FORMAT_SLINEAR)
swap = 1; /* Swap big-endian samples to little-endian as we copy */
#endif
res = phone_write_buf(p, pos, expected, maxfr, swap);
@@ -1211,9 +1211,9 @@ static struct phone_pvt *mkif(const char *iface, int mode, int txgain, int rxgai
return tmp;
}
-static struct ast_channel *phone_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *phone_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct phone_pvt *p;
struct ast_channel *tmp = NULL;
char *name = data;
@@ -1245,7 +1245,8 @@ static struct ast_channel *phone_request(const char *type, int format, const str
oldformat = format;
format &= (AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW);
if (!format) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
+ char buf[256];
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), oldformat));
return NULL;
}
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 8934c1a97..438df8f33 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1146,7 +1146,7 @@ static const char *sip_reason_code_to_str(enum AST_REDIRECTING_REASON code)
#define DEFAULT_SDPSESSION "Asterisk PBX" /*!< Default SDP session name, (s=) header unless re-defined in sip.conf */
#define DEFAULT_SDPOWNER "root" /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */
#define DEFAULT_ENGINE "asterisk" /*!< Default RTP engine to use for sessions */
-#define DEFAULT_CAPABILITY (AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263);
+#define DEFAULT_CAPABILITY (AST_FORMAT_ULAW | AST_FORMAT_TESTLAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263);
#endif
/*@}*/
@@ -1215,7 +1215,7 @@ struct sip_settings {
char default_context[AST_MAX_CONTEXT];
char default_subscribecontext[AST_MAX_CONTEXT];
struct ast_ha *contact_ha; /*! \brief Global list of addresses dynamic peers are not allowed to use */
- int capability; /*!< Supported codecs */
+ format_t capability; /*!< Supported codecs */
};
static struct sip_settings sip_cfg; /*!< SIP configuration data.
@@ -1767,13 +1767,13 @@ struct sip_pvt {
unsigned int sipoptions; /*!< Supported SIP options on the other end */
unsigned int reqsipoptions; /*!< Required SIP options on the other end */
struct ast_codec_pref prefs; /*!< codec prefs */
- int capability; /*!< Special capability (codec) */
- int jointcapability; /*!< Supported capability at both ends (codecs) */
- int peercapability; /*!< Supported peer capability */
- int prefcodec; /*!< Preferred codec (outbound only) */
+ format_t capability; /*!< Special capability (codec) */
+ format_t jointcapability; /*!< Supported capability at both ends (codecs) */
+ format_t peercapability; /*!< Supported peer capability */
+ format_t prefcodec; /*!< Preferred codec (outbound only) */
int noncodeccapability; /*!< DTMF RFC2833 telephony-event */
int jointnoncodeccapability; /*!< Joint Non codec capability */
- int redircodecs; /*!< Redirect codecs */
+ format_t redircodecs; /*!< Redirect codecs */
int maxcallbitrate; /*!< Maximum Call Bitrate for Video Calls */
int t38_maxdatagram; /*!< T.38 FaxMaxDatagram override */
int request_queue_sched_id; /*!< Scheduler ID of any scheduled action to process queued requests */
@@ -2038,7 +2038,7 @@ struct sip_peer {
int maxcallbitrate; /*!< Maximum Bitrate for a video call */
int expire; /*!< When to expire this peer registration */
- int capability; /*!< Codec capability */
+ format_t capability; /*!< Codec capability */
int rtptimeout; /*!< RTP timeout */
int rtpholdtimeout; /*!< RTP Hold Timeout */
int rtpkeepalive; /*!< Send RTP packets for keepalive */
@@ -2408,7 +2408,7 @@ enum t38_action_flag {
in coming releases. */
/*--- PBX interface functions */
-static struct ast_channel *sip_request_call(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *sip_request_call(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int sip_devicestate(void *data);
static int sip_sendtext(struct ast_channel *ast, const char *text);
static int sip_call(struct ast_channel *ast, char *dest, int timeout);
@@ -2501,7 +2501,7 @@ static const char* get_sdp_iterate(int* start, struct sip_request *req, const ch
static const char *get_sdp(struct sip_request *req, const char *name);
static int find_sdp(struct sip_request *req);
static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action);
-static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
+static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
struct ast_str **m_buf, struct ast_str **a_buf,
int debug, int *min_packet_size);
static void add_noncodec_to_sdp(const struct sip_pvt *p, int format,
@@ -2769,7 +2769,7 @@ static enum st_mode st_get_mode(struct sip_pvt *);
static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p);
/*------- RTP Glue functions -------- */
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active);
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active);
/*!--- SIP MWI Subscription support */
static int sip_subscribe_mwi(const char *value, int lineno);
@@ -6459,7 +6459,7 @@ static int sip_hangup(struct ast_channel *ast)
/*! \brief Try setting codec suggested by the SIP_CODEC channel variable */
static void try_suggested_sip_codec(struct sip_pvt *p)
{
- int fmt;
+ format_t fmt;
const char *codec;
struct ast_channel* chan;
@@ -6526,16 +6526,13 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
switch (frame->frametype) {
case AST_FRAME_VOICE:
- if (!(frame->subclass & ast->nativeformats)) {
+ if (!(frame->subclass.codec & ast->nativeformats)) {
char s1[512], s2[512], s3[512];
- ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %s(%d) read/write = %s(%d)/%s(%d)\n",
- frame->subclass,
- ast_getformatname_multiple(s1, sizeof(s1) - 1, ast->nativeformats & AST_FORMAT_AUDIO_MASK),
- ast->nativeformats & AST_FORMAT_AUDIO_MASK,
- ast_getformatname_multiple(s2, sizeof(s2) - 1, ast->readformat),
- ast->readformat,
- ast_getformatname_multiple(s3, sizeof(s3) - 1, ast->writeformat),
- ast->writeformat);
+ ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(s1, sizeof(s1), ast->nativeformats & AST_FORMAT_AUDIO_MASK),
+ ast_getformatname_multiple(s2, sizeof(s2), ast->readformat),
+ ast_getformatname_multiple(s3, sizeof(s3), ast->writeformat));
return 0;
}
if (p) {
@@ -6917,11 +6914,11 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
{
struct ast_channel *tmp;
struct ast_variable *v = NULL;
- int fmt;
- int what;
- int video;
- int text;
- int needvideo = 0;
+ format_t fmt;
+ format_t what;
+ format_t video;
+ format_t text;
+ format_t needvideo = 0;
int needtext = 0;
char buf[SIPBUFSIZE];
char *decoded_exten;
@@ -7285,7 +7282,7 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
/* Don't forward RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) &&
(ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833)) {
- ast_debug(1, "Ignoring DTMF (%c) RTP frame because dtmfmode is not RFC2833\n", f->subclass);
+ ast_debug(1, "Ignoring DTMF (%c) RTP frame because dtmfmode is not RFC2833\n", f->subclass.integer);
return &ast_null_frame;
}
@@ -7293,15 +7290,15 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
if (!p->owner || (f && f->frametype != AST_FRAME_VOICE))
return f;
- if (f && f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (!(f->subclass & p->jointcapability)) {
+ if (f && f->subclass.codec != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+ if (!(f->subclass.codec & p->jointcapability)) {
ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
- ast_getformatname(f->subclass), p->owner->name);
+ ast_getformatname(f->subclass.codec), p->owner->name);
return &ast_null_frame;
}
- ast_debug(1, "Oooh, format changed to %d %s\n",
- f->subclass, ast_getformatname(f->subclass));
- p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass;
+ ast_debug(1, "Oooh, format changed to %s\n",
+ ast_getformatname(f->subclass.codec));
+ p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass.codec;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
@@ -7309,11 +7306,11 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
if (f && p->dsp) {
f = ast_dsp_process(p->owner, p->dsp, f);
if (f && f->frametype == AST_FRAME_DTMF) {
- if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && f->subclass == 'f') {
+ if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && f->subclass.integer == 'f') {
ast_debug(1, "Fax CNG detected on %s\n", ast->name);
*faxdetect = 1;
} else {
- ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass.integer);
}
}
}
@@ -8367,9 +8364,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
int old = 0;
/* Peer capability is the capability in the SDP, non codec is RFC2833 DTMF (101) */
- int peercapability = 0, peernoncodeccapability = 0;
- int vpeercapability = 0, vpeernoncodeccapability = 0;
- int tpeercapability = 0, tpeernoncodeccapability = 0;
+ format_t peercapability = 0, vpeercapability = 0, tpeercapability = 0;
+ int peernoncodeccapability = 0, vpeernoncodeccapability = 0, tpeernoncodeccapability = 0;
struct sockaddr_in sin; /*!< media socket address */
struct sockaddr_in vsin; /*!< Video socket address */
struct sockaddr_in tsin; /*!< Text socket address */
@@ -8387,8 +8383,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
int sendonly = -1;
int numberofports;
struct ast_rtp_codecs newaudiortp, newvideortp, newtextrtp;
- int newjointcapability; /* Negotiated capability */
- int newpeercapability;
+ format_t newjointcapability; /* Negotiated capability */
+ format_t newpeercapability;
int newnoncodeccapability;
int numberofmediastreams = 0;
int debug = sip_debug_test_pvt(p);
@@ -8781,7 +8777,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (!format.asterisk_format || !format.code) /* non-codec or not found */
continue;
if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format.code, framing);
+ ast_log(LOG_DEBUG, "Setting framing for %s to %ld\n", ast_getformatname(format.code), framing);
ast_codec_pref_setsize(pref, format.code, framing);
}
ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, pref);
@@ -10189,7 +10185,7 @@ static int add_vidupdate(struct sip_request *req)
}
/*! \brief Add codec offer to SDP offer/answer body in INVITE or 200 OK */
-static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
+static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
struct ast_str **m_buf, struct ast_str **a_buf,
int debug, int *min_packet_size)
{
@@ -10198,7 +10194,7 @@ static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
if (debug)
- ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
+ ast_verbose("Adding codec 0x%Lx (%s) to SDP\n", codec, ast_getformatname(codec));
if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->rtp), 1, codec)) == -1)
return;
@@ -10396,7 +10392,7 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext
static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
{
int len = 0;
- int alreadysent = 0;
+ format_t alreadysent = 0;
struct sockaddr_in sin = { 0, };
struct sockaddr_in vsin = { 0, };
@@ -10424,8 +10420,8 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
struct ast_str *a_text = ast_str_alloca(1024); /* Attributes for text */
struct ast_str *a_modem = ast_str_alloca(1024); /* Attributes for modem */
- int x;
- int capability = 0;
+ format_t x;
+ format_t capability = 0;
int needaudio = FALSE;
int needvideo = FALSE;
int needtext = FALSE;
@@ -10547,15 +10543,15 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
Note that p->prefcodec can include video codecs, so mask them out
*/
if (capability & p->prefcodec) {
- int codec = p->prefcodec & AST_FORMAT_AUDIO_MASK;
+ format_t codec = p->prefcodec & AST_FORMAT_AUDIO_MASK;
add_codec_to_sdp(p, codec, &m_audio, &a_audio, debug, &min_audio_packet_size);
alreadysent |= codec;
}
/* Start by sending our preferred audio/video codecs */
- for (x = 0; x < 32; x++) {
- int codec;
+ for (x = 0; x < 64; x++) {
+ format_t codec;
if (!(codec = ast_codec_pref_index(&p->prefs, x)))
break;
@@ -10571,7 +10567,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
}
/* Now send any other common audio and video codecs, and non-codec formats: */
- for (x = 1; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
+ for (x = 1LL; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
if (!(capability & x)) /* Codec not requested */
continue;
@@ -10587,7 +10583,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
}
/* Now add DTMF RFC2833 telephony-event as a codec */
- for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
+ for (x = 1LL; x <= AST_RTP_MAX; x <<= 1) {
if (!(p->jointnoncodeccapability & x))
continue;
@@ -14807,7 +14803,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req)
ast_verbose("SIP Text message received: '%s'\n", buf);
memset(&f, 0, sizeof(f));
f.frametype = AST_FRAME_TEXT;
- f.subclass = 0;
+ f.subclass.integer = 0;
f.offset = 0;
f.data.ptr = buf;
f.datalen = strlen(buf);
@@ -15669,9 +15665,10 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli
/*! \brief Print codec list from preference to CLI/manager */
static void print_codec_to_cli(int fd, struct ast_codec_pref *pref)
{
- int x, codec;
+ int x;
+ format_t codec;
- for(x = 0; x < 32 ; x++) {
+ for(x = 0; x < 64 ; x++) {
codec = ast_codec_pref_index(pref, x);
if (!codec)
break;
@@ -15864,7 +15861,8 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
struct ast_codec_pref *pref;
struct ast_variable *v;
struct sip_auth *auth;
- int x = 0, codec = 0, load_realtime;
+ int x = 0, load_realtime;
+ format_t codec = 0;
int realtimepeers;
realtimepeers = ast_check_realtime("sippeers");
@@ -16071,12 +16069,12 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
astman_append(s, "%s\r\n", codec_buf);
astman_append(s, "CodecOrder: ");
pref = &peer->prefs;
- for(x = 0; x < 32 ; x++) {
+ for(x = 0; x < 64 ; x++) {
codec = ast_codec_pref_index(pref, x);
if (!codec)
break;
astman_append(s, "%s", ast_getformatname(codec));
- if (x < 31 && ast_codec_pref_index(pref, x+1))
+ if (x < 63 && ast_codec_pref_index(pref, x+1))
astman_append(s, ",");
}
@@ -16965,10 +16963,10 @@ static char *sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_a
ast_cli(a->fd, " Curr. trans. direction: %s\n", ast_test_flag(&cur->flags[0], SIP_OUTGOING) ? "Outgoing" : "Incoming");
ast_cli(a->fd, " Call-ID: %s\n", cur->callid);
ast_cli(a->fd, " Owner channel ID: %s\n", cur->owner ? cur->owner->name : "<none>");
- ast_cli(a->fd, " Our Codec Capability: %d\n", cur->capability);
+ ast_cli(a->fd, " Our Codec Capability: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->capability));
ast_cli(a->fd, " Non-Codec Capability (DTMF): %d\n", cur->noncodeccapability);
- ast_cli(a->fd, " Their Codec Capability: %d\n", cur->peercapability);
- ast_cli(a->fd, " Joint Codec Capability: %d\n", cur->jointcapability);
+ ast_cli(a->fd, " Their Codec Capability: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->peercapability));
+ ast_cli(a->fd, " Joint Codec Capability: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->jointcapability));
ast_cli(a->fd, " Format: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->owner ? cur->owner->nativeformats : 0) );
ast_cli(a->fd, " T.38 support %s\n", cli_yesno(cur->udptl != NULL));
ast_cli(a->fd, " Video support %s\n", cli_yesno(cur->vrtp != NULL));
@@ -17178,7 +17176,7 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
event = atoi(buf);
if (event == 16) {
/* send a FLASH event */
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH, };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH, } };
ast_queue_frame(p->owner, &f);
if (sipdebug)
ast_verbose("* DTMF-relay event received: FLASH\n");
@@ -17186,18 +17184,18 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
/* send a DTMF event */
struct ast_frame f = { AST_FRAME_DTMF, };
if (event < 10) {
- f.subclass = '0' + event;
- } else if (event < 11) {
- f.subclass = '*';
- } else if (event < 12) {
- f.subclass = '#';
+ f.subclass.integer = '0' + event;
+ } else if (event == 10) {
+ f.subclass.integer = '*';
+ } else if (event == 11) {
+ f.subclass.integer = '#';
} else if (event < 16) {
- f.subclass = 'A' + (event - 12);
+ f.subclass.integer = 'A' + (event - 12);
}
f.len = duration;
ast_queue_frame(p->owner, &f);
if (sipdebug)
- ast_verbose("* DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("* DTMF-relay event received: %c\n", (int) f.subclass.integer);
}
transmit_response(p, "200 OK", req);
return;
@@ -17221,7 +17219,7 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
event = atoi(buf);
if (event == 16) {
/* send a FLASH event */
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH, };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH }, };
ast_queue_frame(p->owner, &f);
if (sipdebug)
ast_verbose("* DTMF-relay event received: FLASH\n");
@@ -17229,18 +17227,18 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
/* send a DTMF event */
struct ast_frame f = { AST_FRAME_DTMF, };
if (event < 10) {
- f.subclass = '0' + event;
- } else if (event < 11) {
- f.subclass = '*';
- } else if (event < 12) {
- f.subclass = '#';
+ f.subclass.integer = '0' + event;
+ } else if (event == 10) {
+ f.subclass.integer = '*';
+ } else if (event == 11) {
+ f.subclass.integer = '#';
} else if (event < 16) {
- f.subclass = 'A' + (event - 12);
+ f.subclass.integer = 'A' + (event - 12);
}
f.len = duration;
ast_queue_frame(p->owner, &f);
if (sipdebug)
- ast_verbose("* DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("* DTMF-relay event received: %c\n", (int) f.subclass.integer);
}
transmit_response(p, "200 OK", req);
return;
@@ -17287,10 +17285,10 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
/* Send the feature code to the PBX as DTMF, just like the handset had sent it */
f.len = 100;
for (j=0; j < strlen(feat->exten); j++) {
- f.subclass = feat->exten[j];
+ f.subclass.integer = feat->exten[j];
ast_queue_frame(p->owner, &f);
if (sipdebug)
- ast_verbose("* DTMF-relay event faked: %c\n", f.subclass);
+ ast_verbose("* DTMF-relay event faked: %c\n", f.subclass.integer);
}
ast_unlock_call_features();
@@ -17866,7 +17864,7 @@ static int function_sippeer(struct ast_channel *chan, const char *cmd, char *dat
}
} else if (!strncasecmp(colname, "codec[", 6)) {
char *codecnum;
- int codec = 0;
+ format_t codec = 0;
codecnum = colname + 6; /* move past the '[' */
codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */
@@ -23955,7 +23953,7 @@ static int sip_devicestate(void *data)
* or SIP/host!dnid
* \endverbatim
*/
-static struct ast_channel *sip_request_call(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *sip_request_call(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct sip_pvt *p;
struct ast_channel *tmpc = NULL;
@@ -23968,7 +23966,7 @@ static struct ast_channel *sip_request_call(const char *type, int format, const
char *authname = NULL;
char *trans = NULL;
enum sip_transport transport = 0;
- int oldformat = format;
+ format_t oldformat = format;
/* mask request with some set of allowed formats.
* XXX this needs to be fixed.
@@ -26251,7 +26249,7 @@ static enum ast_rtp_glue_result sip_get_trtp_peer(struct ast_channel *chan, stru
return res;
}
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active)
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active)
{
struct sip_pvt *p;
int changed = 0;
@@ -26321,7 +26319,7 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *i
return 0;
}
-static int sip_get_codec(struct ast_channel *chan)
+static format_t sip_get_codec(struct ast_channel *chan)
{
struct sip_pvt *p = chan->tech_pvt;
return p->peercapability ? p->peercapability : p->capability;
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 011db2046..354414e23 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -141,7 +141,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static const char tdesc[] = "Skinny Client Control Protocol (Skinny)";
static const char config[] = "skinny.conf";
-static int default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW;
+static format_t default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW;
static struct ast_codec_pref default_prefs;
enum skinny_codecs {
@@ -1229,9 +1229,9 @@ struct skinny_subchannel {
int instance; \
int group; \
int needdestroy; \
- int confcapability; \
+ format_t confcapability; \
struct ast_codec_pref confprefs; \
- int capability; \
+ format_t capability; \
struct ast_codec_pref prefs; \
int nonCodecCapability; \
int onhooktime; \
@@ -1309,9 +1309,9 @@ struct skinny_addon {
int registered; \
int lastlineinstance; \
int lastcallreference; \
- int confcapability; \
+ format_t confcapability; \
struct ast_codec_pref confprefs; \
- int capability; \
+ format_t capability; \
int earlyrtp; \
int transfer; \
int callwaiting; \
@@ -1371,7 +1371,7 @@ struct skinnysession {
AST_LIST_ENTRY(skinnysession) list;
};
-static struct ast_channel *skinny_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *skinny_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static AST_LIST_HEAD_STATIC(sessions, skinnysession);
static int skinny_devicestate(void *data);
@@ -2704,7 +2704,7 @@ static enum ast_rtp_glue_result skinny_get_rtp_peer(struct ast_channel *c, struc
}
-static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active)
+static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
{
struct skinny_subchannel *sub;
struct skinny_line *l;
@@ -2748,7 +2748,7 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *r
fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
if (skinnydebug)
- ast_verb(1, "Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
+ ast_verb(1, "Setting payloadType to '%s' (%d ms)\n", ast_getformatname(fmt.bits), fmt.cur_ms);
req->data.startmedia.conferenceId = htolel(sub->callid);
req->data.startmedia.passThruPartyId = htolel(sub->callid);
@@ -4021,9 +4021,9 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
if (ast) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != ast->nativeformats) {
- ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
- ast->nativeformats = f->subclass;
+ if (f->subclass.codec != ast->nativeformats) {
+ ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(f->subclass.codec));
+ ast->nativeformats = f->subclass.codec;
ast_set_read_format(ast, ast->readformat);
ast_set_write_format(ast, ast->writeformat);
}
@@ -4054,9 +4054,13 @@ static int skinny_write(struct ast_channel *ast, struct ast_frame *frame)
return 0;
}
} else {
- if (!(frame->subclass & ast->nativeformats)) {
- ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
- frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
+ if (!(frame->subclass.codec & ast->nativeformats)) {
+ char buf[256];
+ ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
return -1;
}
}
@@ -4400,8 +4404,12 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state, const ch
// Should throw an error
tmp->nativeformats = default_capability;
fmt = ast_best_codec(tmp->nativeformats);
- if (skinnydebug)
- ast_verb(1, "skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
+ if (skinnydebug) {
+ char buf[256];
+ ast_verb(1, "skinny_new: tmp->nativeformats=%s fmt=%s\n",
+ ast_getformatname_multiple(buf, sizeof(buf), tmp->nativeformats),
+ ast_getformatname(fmt));
+ }
if (sub->rtp) {
ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
}
@@ -4746,7 +4754,7 @@ static int handle_keypad_button_message(struct skinny_req *req, struct skinnyses
ast_log(LOG_WARNING, "Unsupported digit %d\n", digit);
}
- f.subclass = dgt;
+ f.subclass.integer = dgt;
f.src = "skinny";
@@ -5301,6 +5309,7 @@ static int handle_capabilities_res_message(struct skinny_req *req, struct skinny
uint32_t count = 0;
int codecs = 0;
int i;
+ char buf[256];
count = letohl(req->data.caps.count);
if (count > SKINNY_MAX_CAPABILITIES) {
@@ -5319,7 +5328,7 @@ static int handle_capabilities_res_message(struct skinny_req *req, struct skinny
}
d->capability = d->confcapability & codecs;
- ast_verb(0, "Device capability set to '%d'\n", d->capability);
+ ast_verb(0, "Device capability set to '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), d->capability));
AST_LIST_TRAVERSE(&d->lines, l, list) {
ast_mutex_lock(&l->lock);
l->capability = l->confcapability & d->capability;
@@ -5646,7 +5655,7 @@ static int handle_open_receive_channel_ack_message(struct skinny_req *req, struc
fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
if (skinnydebug)
- ast_verb(1, "Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
+ ast_verb(1, "Setting payloadType to '%s' (%d ms)\n", ast_getformatname(fmt.bits), fmt.cur_ms);
req->data.startmedia.conferenceId = htolel(sub->callid);
req->data.startmedia.passThruPartyId = htolel(sub->callid);
@@ -6576,9 +6585,9 @@ static int skinny_devicestate(void *data)
return get_devicestate(l);
}
-static struct ast_channel *skinny_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *skinny_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct skinny_line *l;
struct ast_channel *tmpc = NULL;
@@ -6588,7 +6597,7 @@ static struct ast_channel *skinny_request(const char *type, int format, const st
oldformat = format;
if (!(format &= AST_FORMAT_AUDIO_MASK)) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), format));
return NULL;
}
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 8de4ada33..53ac9f94e 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -676,7 +676,7 @@ static int reload(void);
static int unload_module(void);
static int reload_config(void);
static void show_main_page(struct unistimsession *pte);
-static struct ast_channel *unistim_request(const char *type, int format, const struct ast_channel *requestor,
+static struct ast_channel *unistim_request(const char *type, format_t format, const struct ast_channel *requestor,
void *data, int *cause);
static int unistim_call(struct ast_channel *ast, char *dest, int timeout);
static int unistim_hangup(struct ast_channel *ast);
@@ -2035,7 +2035,7 @@ static void start_rtp(struct unistim_subchannel *sub)
struct sockaddr_in us = { 0, };
struct sockaddr_in public = { 0, };
struct sockaddr_in sin = { 0, };
- int codec;
+ format_t codec;
struct sockaddr_in sout = { 0, };
/* Sanity checks */
@@ -2085,13 +2085,14 @@ static void start_rtp(struct unistim_subchannel *sub)
sin.sin_port = htons(sub->parent->parent->rtp_port);
ast_rtp_instance_set_remote_address(sub->rtp, &sin);
if (!(sub->owner->nativeformats & sub->owner->readformat)) {
- int fmt;
+ format_t fmt;
+ char tmp[256];
fmt = ast_best_codec(sub->owner->nativeformats);
ast_log(LOG_WARNING,
- "Our read/writeformat has been changed to something incompatible : %s (%d), using %s (%d) best codec from %d\n",
+ "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
ast_getformatname(sub->owner->readformat),
- sub->owner->readformat, ast_getformatname(fmt), fmt,
- sub->owner->nativeformats);
+ ast_getformatname(fmt),
+ ast_getformatname_multiple(tmp, sizeof(tmp), sub->owner->nativeformats));
sub->owner->readformat = fmt;
sub->owner->writeformat = fmt;
}
@@ -2102,20 +2103,19 @@ static void start_rtp(struct unistim_subchannel *sub)
else
memcpy(&public, &public_ip, sizeof(public)); /* override */
if (unistimdebug) {
- ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s (%d)\n",
+ ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s\n",
ast_inet_ntoa(us.sin_addr),
- htons(us.sin_port), ast_getformatname(sub->owner->readformat),
- sub->owner->readformat);
+ htons(us.sin_port), ast_getformatname(sub->owner->readformat));
ast_verb(0, "Starting phone RTP stack. Our public IP is %s\n",
ast_inet_ntoa(public.sin_addr));
}
if ((sub->owner->readformat == AST_FORMAT_ULAW) ||
(sub->owner->readformat == AST_FORMAT_ALAW)) {
if (unistimdebug)
- ast_verb(0, "Sending packet_send_rtp_packet_size for codec %d\n", codec);
+ ast_verb(0, "Sending packet_send_rtp_packet_size for codec %s\n", ast_getformatname(codec));
memcpy(buffsend + SIZE_HEADER, packet_send_rtp_packet_size,
sizeof(packet_send_rtp_packet_size));
- buffsend[10] = codec;
+ buffsend[10] = (int) codec & 0xffffffffLL;
send_client(SIZE_HEADER + sizeof(packet_send_rtp_packet_size), buffsend,
sub->parent->parent->session);
}
@@ -2214,8 +2214,8 @@ static void start_rtp(struct unistim_subchannel *sub)
else if (sub->owner->readformat == AST_FORMAT_G729A)
buffsend[42] = 2; /* 1 = 10ms (10 bytes), 2 = 20ms (20 bytes) */
else
- ast_log(LOG_WARNING, "Unsupported codec %s (%d) !\n",
- ast_getformatname(sub->owner->readformat), sub->owner->readformat);
+ ast_log(LOG_WARNING, "Unsupported codec %s!\n",
+ ast_getformatname(sub->owner->readformat));
/* Source port for transmit RTP and Destination port for receiving RTP */
buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;
buffsend[46] = (htons(sin.sin_port) & 0x00ff);
@@ -2474,7 +2474,7 @@ static void HandleCallIncoming(struct unistimsession *s)
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
{
- struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass = digit, .src = "unistim" };
+ struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = digit, .src = "unistim" };
struct unistim_subchannel *sub;
sub = pte->device->lines->subs[SUB_REAL];
if (!sub->owner || sub->alreadygone) {
@@ -3936,14 +3936,13 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
if (sub->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != sub->owner->nativeformats) {
+ if (f->subclass.codec != sub->owner->nativeformats) {
ast_debug(1,
- "Oooh, format changed from %s (%d) to %s (%d)\n",
+ "Oooh, format changed from %s to %s\n",
ast_getformatname(sub->owner->nativeformats),
- sub->owner->nativeformats, ast_getformatname(f->subclass),
- f->subclass);
+ ast_getformatname(f->subclass.codec));
- sub->owner->nativeformats = f->subclass;
+ sub->owner->nativeformats = f->subclass.codec;
ast_set_read_format(sub->owner, sub->owner->readformat);
ast_set_write_format(sub->owner, sub->owner->writeformat);
}
@@ -3979,13 +3978,14 @@ static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
return 0;
}
} else {
- if (!(frame->subclass & ast->nativeformats)) {
+ if (!(frame->subclass.codec & ast->nativeformats)) {
+ char tmp[256];
ast_log(LOG_WARNING,
- "Asked to transmit frame type %s (%d), while native formats is %s (%d) (read/write = %s (%d)/%d)\n",
- ast_getformatname(frame->subclass), frame->subclass,
- ast_getformatname(ast->nativeformats), ast->nativeformats,
- ast_getformatname(ast->readformat), ast->readformat,
- ast->writeformat);
+ "Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(tmp, sizeof(tmp), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
return -1;
}
}
@@ -4240,7 +4240,7 @@ static int unistim_senddigit_end(struct ast_channel *ast, char digit, unsigned i
send_tone(pte, 0, 0);
f.frametype = AST_FRAME_DTMF;
- f.subclass = digit;
+ f.subclass.integer = digit;
f.src = "unistim";
ast_queue_frame(sub->owner, &f);
@@ -4450,9 +4450,14 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
if (!tmp->nativeformats)
tmp->nativeformats = CAPABILITY;
fmt = ast_best_codec(tmp->nativeformats);
- if (unistimdebug)
- ast_verb(0, "Best codec = %d from nativeformats %d (line cap=%d global=%d)\n", fmt,
- tmp->nativeformats, l->capability, CAPABILITY);
+ if (unistimdebug) {
+ char tmp1[256], tmp2[256], tmp3[256];
+ ast_verb(0, "Best codec = %s from nativeformats %s (line cap=%s global=%s)\n",
+ ast_getformatname(fmt),
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), tmp->nativeformats),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), l->capability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), CAPABILITY));
+ }
if ((sub->rtp) && (sub->subtype == 0)) {
if (unistimdebug)
ast_verb(0, "New unistim channel with a previous rtp handle ?\n");
@@ -4617,10 +4622,10 @@ static int restart_monitor(void)
/*--- unistim_request: PBX interface function ---*/
/* UNISTIM calls initiated by the PBX arrive here */
-static struct ast_channel *unistim_request(const char *type, int format, const struct ast_channel *requestor, void *data,
+static struct ast_channel *unistim_request(const char *type, format_t format, const struct ast_channel *requestor, void *data,
int *cause)
{
- int oldformat;
+ format_t oldformat;
struct unistim_subchannel *sub;
struct ast_channel *tmpc = NULL;
char tmp[256];
@@ -4629,12 +4634,14 @@ static struct ast_channel *unistim_request(const char *type, int format, const s
oldformat = format;
format &= CAPABILITY;
ast_log(LOG_NOTICE,
- "Asked to get a channel of format %s while capability is %d result : %s (%d) \n",
- ast_getformatname(oldformat), CAPABILITY, ast_getformatname(format), format);
+ "Asked to get a channel of format %s while capability is %s result : %s\n",
+ ast_getformatname(oldformat),
+ ast_getformatname_multiple(tmp, sizeof(tmp), CAPABILITY),
+ ast_getformatname(format));
if (!format) {
ast_log(LOG_NOTICE,
"Asked to get a channel of unsupported format %s while capability is %s\n",
- ast_getformatname(oldformat), ast_getformatname(CAPABILITY));
+ ast_getformatname(oldformat), ast_getformatname_multiple(tmp, sizeof(tmp), CAPABILITY));
return NULL;
}
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index c9875008c..960207de3 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -331,7 +331,7 @@ static struct vpb_pvt {
static struct ast_channel *vpb_new(struct vpb_pvt *i, enum ast_channel_state state, const char *context, const char *linkedid);
static void *do_chanreads(void *pvt);
-static struct ast_channel *vpb_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *vpb_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int vpb_digit_begin(struct ast_channel *ast, char digit);
static int vpb_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int vpb_call(struct ast_channel *ast, char *dest, int timeout);
@@ -565,7 +565,7 @@ static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_
/* Check if we need to break */
if (break_for_dtmf) {
break;
- } else if ((f->frametype == AST_FRAME_DTMF) && ((f->subclass == '#') || (f->subclass == '*'))) {
+ } else if ((f->frametype == AST_FRAME_DTMF) && ((f->subclass.integer == '#') || (f->subclass.integer == '*'))) {
break;
}
} else {
@@ -838,7 +838,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
switch (e->type) {
case VPB_RING:
if (p->mode == MODE_FXO) {
- f.subclass = AST_CONTROL_RING;
+ f.subclass.integer = AST_CONTROL_RING;
vpb_timer_stop(p->ring_timer);
vpb_timer_start(p->ring_timer);
} else
@@ -866,7 +866,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
if (p->owner->_state != AST_STATE_UP) {
/* Assume caller has hung up */
vpb_timer_stop(p->ring_timer);
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
vpb_timer_stop(p->ring_timer);
f.frametype = AST_FRAME_NULL;
@@ -883,7 +883,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
f.frametype = AST_FRAME_NULL;
} else if (p->owner->_state == AST_STATE_UP) {
f.frametype = AST_FRAME_DTMF;
- f.subclass = e->data;
+ f.subclass.integer = e->data;
} else
f.frametype = AST_FRAME_NULL;
break;
@@ -892,9 +892,9 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
if (e->data == VPB_BUSY || e->data == VPB_BUSY_308 || e->data == VPB_BUSY_AUST ) {
ast_debug(4, "%s: handle_owned: got event: BUSY\n", p->dev);
if (p->owner->_state == AST_STATE_UP) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
- f.subclass = AST_CONTROL_BUSY;
+ f.subclass.integer = AST_CONTROL_BUSY;
}
} else if (e->data == VPB_FAX) {
if (!p->faxhandled) {
@@ -923,7 +923,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
* Timeout connection */
ast_verb(3, "grunt timeout\n");
ast_log(LOG_NOTICE, "%s: Line hangup due of lack of conversation\n", p->dev);
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
p->lastgrunt = ast_tvnow();
f.frametype = AST_FRAME_NULL;
@@ -936,13 +936,13 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
case VPB_CALLEND:
#ifdef DIAL_WITH_CALL_PROGRESS
if (e->data == VPB_CALL_CONNECTED) {
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
} else if (e->data == VPB_CALL_NO_DIAL_TONE || e->data == VPB_CALL_NO_RING_BACK) {
- f.subclass = AST_CONTROL_CONGESTION;
+ f.subclass.integer = AST_CONTROL_CONGESTION;
} else if (e->data == VPB_CALL_NO_ANSWER || e->data == VPB_CALL_BUSY) {
- f.subclass = AST_CONTROL_BUSY;
+ f.subclass.integer = AST_CONTROL_BUSY;
} else if (e->data == VPB_CALL_DISCONNECTED) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
}
#else
ast_log(LOG_NOTICE, "%s: Got call progress callback but blind dialing \n", p->dev);
@@ -951,13 +951,13 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
break;
case VPB_STATION_OFFHOOK:
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
break;
case VPB_DROP:
if ((p->mode == MODE_FXO) && (UseLoopDrop)) { /* ignore loop drop on stations */
if (p->owner->_state == AST_STATE_UP) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
f.frametype = AST_FRAME_NULL;
}
@@ -965,17 +965,17 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
break;
case VPB_LOOP_ONHOOK:
if (p->owner->_state == AST_STATE_UP) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
f.frametype = AST_FRAME_NULL;
}
break;
case VPB_STATION_ONHOOK:
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
break;
case VPB_STATION_FLASH:
- f.subclass = AST_CONTROL_FLASH;
+ f.subclass.integer = AST_CONTROL_FLASH;
break;
/* Called when dialing has finished and ringing starts
@@ -983,7 +983,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
*/
case VPB_DIALEND:
if (p->state < 5) {
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
ast_verb(2, "%s: Dialend\n", p->dev);
} else {
f.frametype = AST_FRAME_NULL;
@@ -1063,7 +1063,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
}
ast_verb(4, "%s: handle_owned: Prepared frame type[%d]subclass[%d], bridge=%p owner=[%s]\n",
- p->dev, f.frametype, f.subclass, (void *)p->bridge, p->owner->name);
+ p->dev, f.frametype, f.subclass.integer, (void *)p->bridge, p->owner->name);
/* Trylock used here to avoid deadlock that can occur if we
* happen to be in here handling an event when hangup is called
@@ -1076,7 +1076,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
ast_verb(4, "%s: handled_owned: Queued Frame to [%s]\n", p->dev, p->owner->name);
} else {
ast_verbose("%s: handled_owned: Missed event %d/%d \n",
- p->dev, f.frametype, f.subclass);
+ p->dev, f.frametype, f.subclass.integer);
}
}
res = ast_mutex_unlock(&p->lock);
@@ -2097,7 +2097,7 @@ static struct ast_frame *vpb_read(struct ast_channel *ast)
return &f;
}
-static inline AudioCompress ast2vpbformat(int ast_format)
+static inline AudioCompress ast2vpbformat(format_t ast_format)
{
switch (ast_format) {
case AST_FORMAT_ALAW:
@@ -2113,7 +2113,7 @@ static inline AudioCompress ast2vpbformat(int ast_format)
}
}
-static inline const char * ast2vpbformatname(int ast_format)
+static inline const char * ast2vpbformatname(format_t ast_format)
{
switch(ast_format) {
case AST_FORMAT_ALAW:
@@ -2129,7 +2129,7 @@ static inline const char * ast2vpbformatname(int ast_format)
}
}
-static inline int astformatbits(int ast_format)
+static inline int astformatbits(format_t ast_format)
{
switch (ast_format) {
case AST_FORMAT_SLINEAR:
@@ -2175,7 +2175,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
/* ast_mutex_unlock(&p->lock); */
return 0;
} else if (ast->_state != AST_STATE_UP) {
- ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%d] on not up chan(state[%d])\n",ast->name, frame->frametype, frame->subclass,ast->_state);
+ ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%s] on not up chan(state[%d])\n", ast->name, frame->frametype, ast_getformatname(frame->subclass.codec), ast->_state);
p->lastoutput = -1;
/* ast_mutex_unlock(&p->lock); */
return 0;
@@ -2183,9 +2183,9 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
/* ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */
- fmt = ast2vpbformat(frame->subclass);
+ fmt = ast2vpbformat(frame->subclass.codec);
if (fmt < 0) {
- ast_log(LOG_WARNING, "%s: vpb_write: Cannot handle frames of %d format!\n", ast->name, frame->subclass);
+ ast_log(LOG_WARNING, "%s: vpb_write: Cannot handle frames of %s format!\n", ast->name, ast_getformatname(frame->subclass.codec));
return -1;
}
@@ -2209,7 +2209,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
/* Check if we have set up the play_buf */
if (p->lastoutput == -1) {
vpb_play_buf_start(p->handle, fmt);
- ast_verb(2, "%s: vpb_write: Starting play mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(frame->subclass));
+ ast_verb(2, "%s: vpb_write: Starting play mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(frame->subclass.codec));
p->lastoutput = fmt;
ast_mutex_unlock(&p->play_lock);
return 0;
@@ -2259,7 +2259,8 @@ static void *do_chanreads(void *pvt)
struct ast_frame *fr = &p->fr;
char *readbuf = ((char *)p->buf) + AST_FRIENDLY_OFFSET;
int bridgerec = 0;
- int afmt, readlen, res, trycnt=0;
+ format_t afmt;
+ int readlen, res, trycnt=0;
AudioCompress fmt;
int ignore_dtmf;
const char * getdtmf_var = NULL;
@@ -2363,7 +2364,7 @@ static void *do_chanreads(void *pvt)
}
fmt = ast2vpbformat(afmt);
if (fmt < 0) {
- ast_log(LOG_WARNING, "%s: Record failure (unsupported format %d)\n", p->dev, afmt);
+ ast_log(LOG_WARNING, "%s: Record failure (unsupported format %s)\n", p->dev, ast_getformatname(afmt));
return NULL;
}
readlen = VPB_SAMPLES * astformatbits(afmt) / 8;
@@ -2391,16 +2392,16 @@ static void *do_chanreads(void *pvt)
a_gain_vector(p->rxswgain - MAX_VPB_GAIN, (short *)readbuf, readlen / sizeof(short));
ast_verb(6, "%s: chanreads: applied gain\n", p->dev);
- fr->subclass = afmt;
+ fr->subclass.codec = afmt;
fr->data.ptr = readbuf;
fr->datalen = readlen;
fr->frametype = AST_FRAME_VOICE;
- if ((use_ast_dtmfdet)&&(p->vad)) {
- fr = ast_dsp_process(p->owner,p->vad,fr);
+ if ((use_ast_dtmfdet) && (p->vad)) {
+ fr = ast_dsp_process(p->owner, p->vad, fr);
if (fr && (fr->frametype == AST_FRAME_DTMF)) {
- ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n", p->dev, fr->subclass);
- } else if (fr->subclass == 'f') {
+ ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n", p->dev, fr->subclass.integer);
+ } else if (fr->subclass.integer == 'f') {
}
}
/* Using trylock here to prevent deadlock when channel is hungup
@@ -2541,9 +2542,9 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
return tmp;
}
-static struct ast_channel *vpb_request(const char *type, int format, const struct ast_channel *requestor, void *vdata, int *cause)
+static struct ast_channel *vpb_request(const char *type, format_t format, const struct ast_channel *requestor, void *vdata, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct vpb_pvt *p;
struct ast_channel *tmp = NULL;
char *sepstr, *data = (char *)vdata, *name;
@@ -2553,7 +2554,7 @@ static struct ast_channel *vpb_request(const char *type, int format, const struc
oldformat = format;
format &= prefformat;
if (!format) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname(oldformat));
return NULL;
}
diff --git a/channels/h323/chan_h323.h b/channels/h323/chan_h323.h
index b17fe5bed..2ae2c84c4 100644
--- a/channels/h323/chan_h323.h
+++ b/channels/h323/chan_h323.h
@@ -30,6 +30,7 @@
#define CHAN_H323_H
#include <arpa/inet.h>
+#include "asterisk/frame_defs.h"
/*
* Enable support for sending/reception of tunnelled Q.SIG messages and
@@ -64,7 +65,7 @@ typedef struct call_options {
int progress_audio;
int dtmfcodec[2];
int dtmfmode;
- int capability;
+ format_t capability;
int bridge;
int nat;
int tunnelOptions;
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index 24c3c57bb..9a105168c 100644
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -214,6 +214,21 @@ static void dump_samprate(char *output, int maxlen, void *value, int len)
}
+static void dump_versioned_codec(char *output, int maxlen, void *value, int len)
+{
+ char *version = (char *) value;
+ if (version[0] == 0) {
+ if (len == (int) (sizeof(format_t) + sizeof(char))) {
+ format_t codec = ntohll(get_unaligned_uint64(value + 1));
+ ast_copy_string(output, ast_getformatname(codec), maxlen);
+ } else {
+ ast_copy_string(output, "Invalid length!", maxlen);
+ }
+ } else {
+ ast_copy_string(output, "Unknown version!", maxlen);
+ }
+}
+
static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int len);
static void dump_prov(char *output, int maxlen, void *value, int len)
{
@@ -233,7 +248,9 @@ static struct iax2_ie {
{ IAX_IE_USERNAME, "USERNAME", dump_string },
{ IAX_IE_PASSWORD, "PASSWORD", dump_string },
{ IAX_IE_CAPABILITY, "CAPABILITY", dump_int },
+ { IAX_IE_CAPABILITY2, "CAPABILITY2", dump_versioned_codec },
{ IAX_IE_FORMAT, "FORMAT", dump_int },
+ { IAX_IE_FORMAT2, "FORMAT2", dump_versioned_codec },
{ IAX_IE_LANGUAGE, "LANGUAGE", dump_string },
{ IAX_IE_VERSION, "VERSION", dump_short },
{ IAX_IE_ADSICPE, "ADSICPE", dump_short },
@@ -679,6 +696,16 @@ int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct s
return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
}
+int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
+{
+ struct _local {
+ unsigned char version;
+ uint64_t value;
+ } __attribute__((packed)) newval = { version, };
+ put_unaligned_uint64(&newval.value, htonll(value));
+ return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
+}
+
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
{
unsigned int newval;
@@ -769,15 +796,43 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
- } else
- ies->capability = ntohl(get_unaligned_uint32(data + 2));
+ } else if (ies->capability == 0) { /* Don't overwrite capability2, if specified */
+ ies->capability = ntohll(get_unaligned_uint32(data + 2));
+ }
+ break;
+ case IAX_IE_CAPABILITY2:
+ {
+ int version = data[2];
+ if (version == 0) {
+ if (len != (int)sizeof(char) + sizeof(format_t)) {
+ snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int) (sizeof(format_t) + sizeof(char)), len);
+ errorf(tmp);
+ } else {
+ ies->capability = (format_t) ntohll(get_unaligned_uint64(data + 3));
+ }
+ } /* else unknown version */
+ }
break;
case IAX_IE_FORMAT:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
- } else
+ } else if (ies->format == 0) { /* Don't overwrite format2, if specified */
ies->format = ntohl(get_unaligned_uint32(data + 2));
+ }
+ break;
+ case IAX_IE_FORMAT2:
+ {
+ int version = data[2];
+ if (version == 0) {
+ if (len != (int)sizeof(char) + sizeof(format_t)) {
+ snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int) (sizeof(format_t) + sizeof(char)), len);
+ errorf(tmp);
+ } else {
+ ies->format = (format_t) ntohll(get_unaligned_uint64(data + 3));
+ }
+ } /* else unknown version */
+ }
break;
case IAX_IE_LANGUAGE:
ies->language = (char *)data + 2;
@@ -1083,7 +1138,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
{
fr->af.frametype = f->frametype;
- fr->af.subclass = f->subclass;
+ fr->af.subclass.codec = f->subclass.codec;
fr->af.mallocd = 0; /* Our frame is static relative to the container */
fr->af.datalen = f->datalen;
fr->af.samples = f->samples;
@@ -1102,7 +1157,7 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
}
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* We need to byte-swap slinear samples from network byte order */
- if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass == AST_FORMAT_SLINEAR)) {
+ if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass.codec == AST_FORMAT_SLINEAR)) {
/* 2 bytes / sample for SLINEAR */
ast_swapcopy_samples(fr->af.data.ptr, f->data.ptr, copy_len / 2);
} else
diff --git a/channels/iax2-parser.h b/channels/iax2-parser.h
index ca10bc7ae..ec6472e87 100644
--- a/channels/iax2-parser.h
+++ b/channels/iax2-parser.h
@@ -20,6 +20,7 @@
#include "asterisk/linkedlists.h"
#include "asterisk/aes.h"
+#include "asterisk/frame_defs.h"
struct iax_ies {
char *called_number;
@@ -32,8 +33,8 @@ struct iax_ies {
char *called_context;
char *username;
char *password;
- unsigned int capability;
- unsigned int format;
+ format_t capability;
+ format_t format;
char *codec_prefs;
char *language;
int version;
@@ -158,6 +159,7 @@ const char *iax_ie2str(int ie);
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
+int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value);
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
diff --git a/channels/iax2.h b/channels/iax2.h
index 710271096..825efb8cb 100644
--- a/channels/iax2.h
+++ b/channels/iax2.h
@@ -39,7 +39,7 @@
#define IAX_FLAG_SC_LOG 0x80
-#define IAX_MAX_SHIFT 0x1F
+#define IAX_MAX_SHIFT 0x3F
#define IAX_WINDOW 64
@@ -180,6 +180,9 @@ enum iax_frame_subclass {
#define IAX_IE_OSPTOKEN 53 /*!< OSP token */
#define IAX_IE_CALLTOKEN 54 /*!< Call number security token */
+#define IAX_IE_CAPABILITY2 55 /*!< Actual codec capability - u8 version + integer array */
+#define IAX_IE_FORMAT2 56 /*!< Desired codec format - u8 version + integer array */
+
#define IAX_MAX_OSPBLOCK_SIZE 254 /*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
#define IAX_MAX_OSPBLOCK_NUM 4
#define IAX_MAX_OSPTOKEN_SIZE (IAX_MAX_OSPBLOCK_SIZE * IAX_MAX_OSPBLOCK_NUM)
diff --git a/channels/sig_analog.c b/channels/sig_analog.c
index 29ea11680..aa0d441c9 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -1331,7 +1331,7 @@ int analog_answer(struct analog_pvt *p, struct ast_channel *ast)
static int analog_handles_digit(struct ast_frame *f)
{
- char subclass = toupper(f->subclass);
+ char subclass = toupper(f->subclass.integer);
switch (subclass) {
case '1':
@@ -1363,13 +1363,13 @@ void analog_handle_dtmfup(struct analog_pvt *p, struct ast_channel *ast, enum an
/* Upon receiving a DTMF digit, consider this an answer confirmation instead
of a DTMF digit */
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
*dest = &p->subs[index].f;
/* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
analog_set_confirmanswer(p, 0);
}
if (p->callwaitcas) {
- if ((f->subclass == 'A') || (f->subclass == 'D')) {
+ if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
ast_log(LOG_ERROR, "Got some DTMF, but it's for the CAS\n");
p->cid.cid_name = p->callwait_name;
p->cid.cid_num = p->callwait_num;
@@ -1378,7 +1378,7 @@ void analog_handle_dtmfup(struct analog_pvt *p, struct ast_channel *ast, enum an
if (analog_handles_digit(f))
p->callwaitcas = 0;
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
*dest = &p->subs[index].f;
} else {
analog_cb_handle_dtmfup(p, ast, index, dest);
@@ -2117,8 +2117,8 @@ static void *__analog_ss_thread(void *data)
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- dtmfbuf[i++] = f->subclass;
- ast_debug(1, "CID got digit '%c'\n", f->subclass);
+ dtmfbuf[i++] = f->subclass.integer;
+ ast_debug(1, "CID got digit '%c'\n", f->subclass.integer);
res = 2000;
}
ast_frfree(f);
@@ -2354,7 +2354,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
mysig = p->outsigmod;
}
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
p->subs[index].f.datalen = 0;
p->subs[index].f.samples = 0;
p->subs[index].f.mallocd = 0;
@@ -2380,7 +2380,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
ast_debug(1, "Detected %sdigit '%c'\n", (res & ANALOG_EVENT_PULSEDIGIT) ? "pulse ": "", res & 0xff);
analog_confmute(p, 0);
p->subs[index].f.frametype = AST_FRAME_DTMF_END;
- p->subs[index].f.subclass = res & 0xff;
+ p->subs[index].f.subclass.integer = res & 0xff;
analog_handle_dtmfup(p, ast, index, &f);
return f;
}
@@ -2390,7 +2390,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
/* Mute conference */
analog_confmute(p, 1);
p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
- p->subs[index].f.subclass = res & 0xff;
+ p->subs[index].f.subclass.integer = res & 0xff;
return f;
}
@@ -2438,7 +2438,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
if (ast->_state == AST_STATE_DIALING_OFFHOOK) {
ast_setstate(ast, AST_STATE_UP);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
break;
} else { /* if to state wait for offhook to dial rest */
/* we now wait for off hook */
@@ -2451,7 +2451,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
} else if (!p->answeronpolarityswitch) {
ast_setstate(ast, AST_STATE_UP);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
/* If aops=0 and hops=1, this is necessary */
p->polarity = POLARITY_REV;
} else {
@@ -2623,7 +2623,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
analog_set_echocanceller(p, 1);
analog_train_echocanceller(p);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
/* Make sure it stops ringing */
analog_off_hook(p);
ast_debug(1, "channel %d answered\n", p->channel);
@@ -2633,7 +2633,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
if (analog_check_confirmanswer(p)) {
/* Ignore answer if "confirm answer" is enabled */
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
} else if (!ast_strlen_zero(p->dop.dialstr)) {
/* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
res = analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop);
@@ -2644,7 +2644,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
} else {
ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
analog_set_dialing(p, 1);
}
p->dop.dialstr[0] = '\0';
@@ -2657,7 +2657,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
ast_setstate(ast, AST_STATE_RING);
ast->rings = 1;
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
+ p->subs[index].f.subclass.integer = AST_CONTROL_OFFHOOK;
ast_debug(1, "channel %d picked up\n", p->channel);
return &p->subs[index].f;
case AST_STATE_UP:
@@ -2709,15 +2709,15 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
ast_debug(1, "Ring detected\n");
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_RING;
+ p->subs[index].f.subclass.integer = AST_CONTROL_RING;
} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
ast_debug(1, "Line answered\n");
if (analog_check_confirmanswer(p)) {
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
} else {
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
}
} else if (ast->_state != AST_STATE_RING) {
@@ -2753,7 +2753,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
p->callwaitcas = 0;
}
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_RINGING;
+ p->subs[index].f.subclass.integer = AST_CONTROL_RINGING;
break;
case ANALOG_EVENT_RINGERON:
break;
@@ -3160,7 +3160,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
p->subs[index].f.samples = 0;
p->subs[index].f.mallocd = 0;
p->subs[index].f.offset = 0;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
p->subs[index].f.delivery = ast_tv(0,0);
p->subs[index].f.src = "dahdi_exception";
p->subs[index].f.data.ptr = NULL;
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index dbbeccf78..ee4f9353d 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -840,7 +840,7 @@ static void pri_queue_control(struct sig_pri_chan *p, int subclass, struct sig_p
p->calls->queue_control(p->chan_pvt, subclass);
}
- f.subclass = subclass;
+ f.subclass.integer = subclass;
pri_queue_frame(p, &f, pri);
}
@@ -1200,7 +1200,7 @@ static void *do_idle_thread(void *vchan)
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_ANSWER:
/* Launch the PBX */
ast_copy_string(chan->exten, pvt->pri->idleext, sizeof(chan->exten));
@@ -1777,7 +1777,7 @@ static int sig_pri_handle_hold(struct sig_pri_pri *pri, pri_event *ev)
} else {
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_HOLD;
+ f.subclass.integer = AST_CONTROL_HOLD;
ast_queue_frame(owner, &f);
retval = 0;
}
@@ -1848,7 +1848,7 @@ static void sig_pri_handle_retrieve(struct sig_pri_pri *pri, pri_event *ev)
{
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_UNHOLD;
+ f.subclass.integer = AST_CONTROL_UNHOLD;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
sig_pri_unlock_private(pri->pvts[chanpos]);
@@ -2192,7 +2192,7 @@ static void *pri_dchannel(void *vpri)
int i;
for (i = 0; i < digitlen; i++) {
- struct ast_frame f = { AST_FRAME_DTMF, e->digit.digits[i], };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = e->digit.digits[i], };
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
@@ -2222,7 +2222,7 @@ static void *pri_dchannel(void *vpri)
int i;
for (i = 0; i < digitlen; i++) {
- struct ast_frame f = { AST_FRAME_DTMF, e->ring.callednum[i], };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = e->ring.callednum[i], };
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
@@ -2685,7 +2685,7 @@ static void *pri_dchannel(void *vpri)
|| (e->proceeding.progress == 8)
#endif
) {
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_PROGRESS, };
if (e->proceeding.cause > -1) {
ast_verb(3, "PROGRESS with cause code %d received\n", e->proceeding.cause);
@@ -2696,7 +2696,7 @@ static void *pri_dchannel(void *vpri)
ast_verb(3, "PROGRESS with 'user busy' received, signaling AST_CONTROL_BUSY instead of AST_CONTROL_PROGRESS\n");
pri->pvts[chanpos]->owner->hangupcause = e->proceeding.cause;
- f.subclass = AST_CONTROL_BUSY;
+ f.subclass.integer = AST_CONTROL_BUSY;
}
}
}
@@ -2712,7 +2712,7 @@ static void *pri_dchannel(void *vpri)
#endif
) {
/* Bring voice path up */
- f.subclass = AST_CONTROL_PROGRESS;
+ f.subclass.integer = AST_CONTROL_PROGRESS;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
pri->pvts[chanpos]->progress = 1;
@@ -2728,7 +2728,7 @@ static void *pri_dchannel(void *vpri)
sig_pri_handle_subcmds(pri, chanpos, e->e, e->proceeding.channel,
e->proceeding.subcmds, e->proceeding.call);
if (!pri->pvts[chanpos]->proceeding) {
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_PROCEEDING, };
ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
@@ -2741,7 +2741,7 @@ static void *pri_dchannel(void *vpri)
#endif
) {
/* Bring voice path up */
- f.subclass = AST_CONTROL_PROGRESS;
+ f.subclass.integer = AST_CONTROL_PROGRESS;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
pri->pvts[chanpos]->proceeding = 1;
@@ -3103,7 +3103,7 @@ static void *pri_dchannel(void *vpri)
if (!pri->discardremoteholdretrieval) {
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_HOLD;
+ f.subclass.integer = AST_CONTROL_HOLD;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
break;
@@ -3111,7 +3111,7 @@ static void *pri_dchannel(void *vpri)
if (!pri->discardremoteholdretrieval) {
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_UNHOLD;
+ f.subclass.integer = AST_CONTROL_UNHOLD;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
break;
diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c
index eada4c2fd..506c038e4 100644
--- a/codecs/codec_dahdi.c
+++ b/codecs/codec_dahdi.c
@@ -181,7 +181,7 @@ static int dahdi_encoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
struct codec_dahdi_pvt *dahdip = pvt->pvt;
- if (!f->subclass) {
+ if (!f->subclass.codec) {
/* We're just faking a return for calculation purposes. */
dahdip->fake = 2;
pvt->samples = f->samples;
@@ -229,7 +229,7 @@ static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt)
if (2 == dahdip->fake) {
dahdip->fake = 1;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 0;
+ pvt->f.subclass.codec = 0;
pvt->f.samples = dahdip->required_samples;
pvt->f.data.ptr = NULL;
pvt->f.offset = 0;
@@ -257,7 +257,7 @@ static struct ast_frame *dahdi_encoder_frameout(struct ast_trans_pvt *pvt)
pvt->f.datalen = res;
pvt->f.samples = dahdip->required_samples;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 1 << (pvt->t->dstfmt);
+ pvt->f.subclass.codec = 1 << (pvt->t->dstfmt);
pvt->f.mallocd = 0;
pvt->f.offset = AST_FRIENDLY_OFFSET;
pvt->f.src = pvt->t->name;
@@ -276,7 +276,7 @@ static int dahdi_decoder_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
struct codec_dahdi_pvt *dahdip = pvt->pvt;
- if (!f->subclass) {
+ if (!f->subclass.codec) {
/* We're just faking a return for calculation purposes. */
dahdip->fake = 2;
pvt->samples = f->samples;
@@ -302,7 +302,7 @@ static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt)
if (2 == dahdip->fake) {
dahdip->fake = 1;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 0;
+ pvt->f.subclass.codec = 0;
pvt->f.samples = dahdip->required_samples;
pvt->f.data.ptr = NULL;
pvt->f.offset = 0;
@@ -340,7 +340,7 @@ static struct ast_frame *dahdi_decoder_frameout(struct ast_trans_pvt *pvt)
}
pvt->datalen = 0;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 1 << (pvt->t->dstfmt);
+ pvt->f.subclass.codec = 1 << (pvt->t->dstfmt);
pvt->f.mallocd = 0;
pvt->f.offset = AST_FRIENDLY_OFFSET;
pvt->f.src = pvt->t->name;
diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c
index 4d1c8a1ae..9ed9d550d 100644
--- a/codecs/codec_ulaw.c
+++ b/codecs/codec_ulaw.c
@@ -87,6 +87,17 @@ static struct ast_translator ulawtolin = {
.plc_samples = 160,
};
+static struct ast_translator testlawtolin = {
+ .name = "testlawtolin",
+ .srcfmt = AST_FORMAT_TESTLAW,
+ .dstfmt = AST_FORMAT_SLINEAR,
+ .framein = ulawtolin_framein,
+ .sample = ulaw_sample,
+ .buffer_samples = BUFFER_SAMPLES,
+ .buf_size = BUFFER_SAMPLES * 2,
+ .plc_samples = 160,
+};
+
/*!
* \brief The complete translator for LinToulaw.
*/
@@ -101,6 +112,16 @@ static struct ast_translator lintoulaw = {
.buffer_samples = BUFFER_SAMPLES,
};
+static struct ast_translator lintotestlaw = {
+ .name = "lintotestlaw",
+ .srcfmt = AST_FORMAT_SLINEAR,
+ .dstfmt = AST_FORMAT_TESTLAW,
+ .framein = lintoulaw_framein,
+ .sample = slin8_sample,
+ .buf_size = BUFFER_SAMPLES,
+ .buffer_samples = BUFFER_SAMPLES,
+};
+
static int parse_config(int reload)
{
struct ast_variable *var;
@@ -131,6 +152,8 @@ static int unload_module(void)
res = ast_unregister_translator(&lintoulaw);
res |= ast_unregister_translator(&ulawtolin);
+ res |= ast_unregister_translator(&testlawtolin);
+ res |= ast_unregister_translator(&lintotestlaw);
return res;
}
@@ -142,9 +165,11 @@ static int load_module(void)
if (parse_config(0))
return AST_MODULE_LOAD_DECLINE;
res = ast_register_translator(&ulawtolin);
- if (!res)
+ if (!res) {
res = ast_register_translator(&lintoulaw);
- else
+ res |= ast_register_translator(&lintotestlaw);
+ res |= ast_register_translator(&testlawtolin);
+ } else
ast_unregister_translator(&ulawtolin);
if (res)
return AST_MODULE_LOAD_FAILURE;
diff --git a/codecs/ex_adpcm.h b/codecs/ex_adpcm.h
index e1db64c83..8a1a5eea9 100644
--- a/codecs/ex_adpcm.h
+++ b/codecs/ex_adpcm.h
@@ -19,7 +19,7 @@ static struct ast_frame *adpcm_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ADPCM,
+ .subclass.codec = AST_FORMAT_ADPCM,
.datalen = sizeof(ex_adpcm),
.samples = ARRAY_LEN(ex_adpcm) * 2,
.mallocd = 0,
diff --git a/codecs/ex_alaw.h b/codecs/ex_alaw.h
index 66a904ca2..5a03111fa 100644
--- a/codecs/ex_alaw.h
+++ b/codecs/ex_alaw.h
@@ -24,7 +24,7 @@ static struct ast_frame *alaw_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ALAW,
+ .subclass.codec = AST_FORMAT_ALAW,
.datalen = sizeof(ex_alaw),
.samples = ARRAY_LEN(ex_alaw),
.mallocd = 0,
diff --git a/codecs/ex_g722.h b/codecs/ex_g722.h
index 8b0b0ff92..61146909e 100644
--- a/codecs/ex_g722.h
+++ b/codecs/ex_g722.h
@@ -34,7 +34,7 @@ static struct ast_frame *g722_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G722,
+ .subclass.codec = AST_FORMAT_G722,
.datalen = sizeof(ex_g722),
.samples = ARRAY_LEN(ex_g722),
.mallocd = 0,
diff --git a/codecs/ex_g726.h b/codecs/ex_g726.h
index d74844d0a..622418a27 100644
--- a/codecs/ex_g726.h
+++ b/codecs/ex_g726.h
@@ -19,7 +19,7 @@ static struct ast_frame *g726_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G726,
+ .subclass.codec = AST_FORMAT_G726,
.datalen = sizeof(ex_g726),
.samples = ARRAY_LEN(ex_g726) * 2, /* 2 samples per byte */
.mallocd = 0,
diff --git a/codecs/ex_gsm.h b/codecs/ex_gsm.h
index c9180135e..0e4cffab0 100644
--- a/codecs/ex_gsm.h
+++ b/codecs/ex_gsm.h
@@ -18,7 +18,7 @@ static struct ast_frame *gsm_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_GSM,
+ .subclass.codec = AST_FORMAT_GSM,
.datalen = sizeof(ex_gsm),
/* All frames are 20 ms long */
.samples = GSM_SAMPLES,
diff --git a/codecs/ex_ilbc.h b/codecs/ex_ilbc.h
index c72b1f27f..376aa37ec 100644
--- a/codecs/ex_ilbc.h
+++ b/codecs/ex_ilbc.h
@@ -19,7 +19,7 @@ static struct ast_frame *ilbc_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ILBC,
+ .subclass.codec = AST_FORMAT_ILBC,
.datalen = sizeof(ex_ilbc),
/* All frames are 30 ms long */
.samples = ILBC_SAMPLES,
diff --git a/codecs/ex_lpc10.h b/codecs/ex_lpc10.h
index a44791bb3..9c2ded88b 100644
--- a/codecs/ex_lpc10.h
+++ b/codecs/ex_lpc10.h
@@ -15,7 +15,7 @@ static struct ast_frame *lpc10_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_LPC10,
+ .subclass.codec = AST_FORMAT_LPC10,
.datalen = sizeof(ex_lpc10),
/* All frames are 22 ms long (maybe a little more -- why did he choose
LPC10_SAMPLES_PER_FRAME sample frames anyway?? */
diff --git a/codecs/ex_speex.h b/codecs/ex_speex.h
index 61bd4ca4f..36c91ae4c 100644
--- a/codecs/ex_speex.h
+++ b/codecs/ex_speex.h
@@ -18,7 +18,7 @@ static struct ast_frame *speex_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SPEEX,
+ .subclass.codec = AST_FORMAT_SPEEX,
.datalen = sizeof(ex_speex),
/* All frames are 20 ms long */
.samples = SPEEX_SAMPLES,
diff --git a/codecs/ex_ulaw.h b/codecs/ex_ulaw.h
index a34c2702b..b3970f5f8 100644
--- a/codecs/ex_ulaw.h
+++ b/codecs/ex_ulaw.h
@@ -24,7 +24,7 @@ static struct ast_frame *ulaw_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ULAW,
+ .subclass.codec = AST_FORMAT_ULAW,
.datalen = sizeof(ex_ulaw),
.samples = ARRAY_LEN(ex_ulaw),
.mallocd = 0,
diff --git a/configure b/configure
index e20d86987..3a883e936 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.ac Revision: 226018 .
+# From configure.ac Revision: 227579 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6.
#
@@ -16713,7 +16713,9 @@ done
-for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl
+
+
+for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap ntohll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.ac b/configure.ac
index 9b45e4cd7..3cd4268ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -390,7 +390,7 @@ AC_FUNC_STRNLEN
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
+AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap ntohll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
# NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
# so that AC_CHECK_FUNCS can detect functions in that library.
diff --git a/doc/codec-64bit.txt b/doc/codec-64bit.txt
new file mode 100644
index 000000000..8f2ceec59
--- /dev/null
+++ b/doc/codec-64bit.txt
@@ -0,0 +1,47 @@
+CODEC BIT EXPANSION
+-------------------
+
+The code base up to and including Asterisk 1.6.2 has a basic limit of 32 codecs
+recognizable, due to the use of a 32-bit integer for the codec bitmask. We
+have expanded the number of available codecs from 32 to 64, through the use of
+an immutable type, called format_t. This should make future expansion to even
+more bits more easily done.
+
+The design of this expansion has made some changes to the architecture of codecs
+in order to accomplish this task. I will attempt to enumerate them here.
+
+The initial set of 32-bits were allocated as the first 16 to audio codecs, the
+next 8 to video codecs, and the remaining to text codecs (which are used for
+fax capabilities). Initially, there is an assumption in the code that all
+audio codecs are contiguous, followed by a contiguous set of video codecs.
+After the conversion, this assumption will no longer be true. The codec bits
+for the existing codecs will continue to be allocated as-is, and the additional
+codec bits should be allocated on an as-needed basis, with audio codecs
+occupying slots 32-47 and video codecs occupying slots 48-62 (with a 0-based
+offset). Slot 63 is reserved and should not be allocated; it is used in code
+as an end condition for iterating through the entire set of codecs.
+
+The frame structure has been altered. Initially, the subclass held an integer
+whose meaning was specified by the frametype. If the frametype was
+AST_FRAME_VOICE, the subclass specified the audio codec. If the frametype was
+AST_FRAME_VIDEO, the subclass specified the video codec, with the 0-bit set to
+specify a key frame. This was done with a union on the subclass, where the
+"integer" union member specifies the traditional 32-bit subclass and the "codec"
+union member specifies the new 64-bit codec bitmask. This additionally
+guarantees that code compiled under the old scheme will need to be altered to
+compile under the new scheme, which helps avoid incorrect assumptions about the
+state of code which might otherwise compile without errors.
+
+The IAX2 code initially used a 32-bit integer IE to specify both the codec as
+well as the preferred format. An additional IE has been added, which specifies
+a single byte version number as the initial part of the data. This version
+number is initially specified as 00 and requires 8 bytes to follow, specifying
+the 64-bit codec bitmask, in network-byte order. This schema should allow
+further codec expansion in the future without allocation of any additional IEs.
+
+Little changes are required to support further codec expansion in the future,
+though the majority of the work has already been accomplished. Specifically,
+the bitwise operations that are immutable operations in the gcc compiler will
+need to be altered to handle larger bitmasks. Additionally, the constants that
+define specific codecs will need to be changed from integers to structures.
+
diff --git a/formats/format_g723.c b/formats/format_g723.c
index 7b527da8c..c7d84c216 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -61,7 +61,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
}
/* Read the data into the buffer */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_G723_1;
+ s->fr.subclass.codec = AST_FORMAT_G723_1;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != size) {
@@ -82,7 +82,7 @@ static int g723_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_G723_1) {
+ if (f->subclass.codec != AST_FORMAT_G723_1) {
ast_log(LOG_WARNING, "Asked to write non-g723 frame!\n");
return -1;
}
diff --git a/formats/format_g726.c b/formats/format_g726.c
index d54b52d2c..4394328fb 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -119,7 +119,7 @@ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_G726;
+ s->fr.subclass.codec = AST_FORMAT_G726;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
s->fr.samples = 8 * FRAME_TIME;
@@ -141,9 +141,9 @@ static int g726_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_G726) {
- ast_log(LOG_WARNING, "Asked to write non-G726 frame (%d)!\n",
- f->subclass);
+ if (f->subclass.codec != AST_FORMAT_G726) {
+ ast_log(LOG_WARNING, "Asked to write non-G726 frame (%s)!\n",
+ ast_getformatname(f->subclass.codec));
return -1;
}
if (f->datalen % frame_size[fs->rate]) {
diff --git a/formats/format_g729.c b/formats/format_g729.c
index cf7e20be7..6a676e1c0 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -46,7 +46,7 @@ static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
int res;
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_G729A;
+ s->fr.subclass.codec = AST_FORMAT_G729A;
s->fr.mallocd = 0;
s->fr.samples = G729A_SAMPLES;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
@@ -66,8 +66,8 @@ static int g729_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_G729A) {
- ast_log(LOG_WARNING, "Asked to write non-G729 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_G729A) {
+ ast_log(LOG_WARNING, "Asked to write non-G729 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (f->datalen % 10) {
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index 480c63bd6..39526b4e8 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -53,7 +53,7 @@ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
int res;
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_GSM;
+ s->fr.subclass.codec = AST_FORMAT_GSM;
AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
s->fr.mallocd = 0;
if ((res = fread(s->fr.data.ptr, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
@@ -74,8 +74,8 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_GSM) {
- ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_GSM) {
+ ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (!(f->datalen % 65)) {
diff --git a/formats/format_h263.c b/formats/format_h263.c
index 9b6ac6764..13377f4ed 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -64,7 +64,7 @@ static int h263_open(struct ast_filestream *s)
static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
{
int res;
- int mark;
+ format_t mark;
unsigned short len;
unsigned int ts;
struct h263_desc *fs = (struct h263_desc *)s->_private;
@@ -80,7 +80,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
return NULL;
}
s->fr.frametype = AST_FRAME_VIDEO;
- s->fr.subclass = AST_FORMAT_H263;
+ s->fr.subclass.codec = AST_FORMAT_H263;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -90,7 +90,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
}
s->fr.samples = fs->lastts; /* XXX what ? */
s->fr.datalen = len;
- s->fr.subclass |= mark;
+ s->fr.subclass.codec |= mark;
s->fr.delivery.tv_sec = 0;
s->fr.delivery.tv_usec = 0;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
@@ -106,18 +106,18 @@ static int h263_write(struct ast_filestream *fs, struct ast_frame *f)
int res;
unsigned int ts;
unsigned short len;
- int subclass;
- int mark=0;
+ format_t subclass;
+ format_t mark=0;
if (f->frametype != AST_FRAME_VIDEO) {
ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
return -1;
}
- subclass = f->subclass;
+ subclass = f->subclass.codec;
if (subclass & 0x1)
mark=0x8000;
subclass &= ~0x1;
if (subclass != AST_FORMAT_H263) {
- ast_log(LOG_WARNING, "Asked to write non-h263 frame (%d)!\n", f->subclass);
+ ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
ts = htonl(f->samples);
diff --git a/formats/format_h264.c b/formats/format_h264.c
index fa938a8c6..1fbad01ba 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -72,7 +72,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
len = BUF_SIZE; /* XXX truncate */
}
s->fr.frametype = AST_FRAME_VIDEO;
- s->fr.subclass = AST_FORMAT_H264;
+ s->fr.subclass.codec = AST_FORMAT_H264;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -82,7 +82,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
}
s->fr.samples = fs->lastts;
s->fr.datalen = len;
- s->fr.subclass |= mark;
+ s->fr.subclass.codec |= mark;
s->fr.delivery.tv_sec = 0;
s->fr.delivery.tv_usec = 0;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
@@ -104,9 +104,9 @@ static int h264_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
return -1;
}
- mark = (f->subclass & 0x1) ? 0x8000 : 0;
- if ((f->subclass & ~0x1) != AST_FORMAT_H264) {
- ast_log(LOG_WARNING, "Asked to write non-h264 frame (%d)!\n", f->subclass);
+ mark = (f->subclass.codec & 0x1) ? 0x8000 : 0;
+ if ((f->subclass.codec & ~0x1) != AST_FORMAT_H264) {
+ ast_log(LOG_WARNING, "Asked to write non-h264 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
ts = htonl(f->samples);
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index 439219305..6e34fb4cd 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -45,7 +45,7 @@ static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
int res;
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_ILBC;
+ s->fr.subclass.codec = AST_FORMAT_ILBC;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -64,8 +64,8 @@ static int ilbc_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_ILBC) {
- ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_ILBC) {
+ ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (f->datalen % 50) {
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 92117fce1..98b98c268 100644
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -48,7 +48,7 @@ static struct ast_frame *jpeg_read_image(int fd, int len)
}
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_IMAGE;
- fr.subclass = AST_FORMAT_JPEG;
+ fr.subclass.codec = AST_FORMAT_JPEG;
fr.data.ptr = buf;
fr.src = "JPEG Read";
fr.datalen = len;
@@ -74,7 +74,7 @@ static int jpeg_write_image(int fd, struct ast_frame *fr)
ast_log(LOG_WARNING, "Not an image\n");
return -1;
}
- if (fr->subclass != AST_FORMAT_JPEG) {
+ if (fr->subclass.codec != AST_FORMAT_JPEG) {
ast_log(LOG_WARNING, "Not a jpeg image\n");
return -1;
}
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index e3b81eff1..29d5ad50f 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -291,9 +291,9 @@ static int ogg_vorbis_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n",
- f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%s)!\n",
+ ast_getformatname(f->subclass.codec));
return -1;
}
if (!f->datalen)
@@ -438,7 +438,7 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *fs,
short *buf; /* SLIN data buffer */
fs->fr.frametype = AST_FRAME_VOICE;
- fs->fr.subclass = AST_FORMAT_SLINEAR;
+ fs->fr.subclass.codec = AST_FORMAT_SLINEAR;
fs->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
buf = (short *)(fs->fr.data.ptr); /* SLIN data buffer */
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 1a5637f3a..b8517af6e 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -80,7 +80,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = s->fmt->format;
+ s->fr.subclass.codec = s->fmt->format;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -163,8 +163,8 @@ static int pcm_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != fs->fmt->format) {
- ast_log(LOG_WARNING, "Asked to write incompatible format frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != fs->fmt->format) {
+ ast_log(LOG_WARNING, "Asked to write incompatible format frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
diff --git a/formats/format_siren14.c b/formats/format_siren14.c
index 0ac0174cf..8fdd4aa1f 100644
--- a/formats/format_siren14.c
+++ b/formats/format_siren14.c
@@ -41,7 +41,7 @@ static struct ast_frame *siren14read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SIREN14;
+ s->fr.subclass.codec = AST_FORMAT_SIREN14;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -61,8 +61,8 @@ static int siren14write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SIREN14) {
- ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SIREN14) {
+ ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
diff --git a/formats/format_siren7.c b/formats/format_siren7.c
index 0b61a72b2..44d4da751 100644
--- a/formats/format_siren7.c
+++ b/formats/format_siren7.c
@@ -41,7 +41,7 @@ static struct ast_frame *siren7read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SIREN7;
+ s->fr.subclass.codec = AST_FORMAT_SIREN7;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
@@ -61,8 +61,8 @@ static int siren7write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SIREN7) {
- ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SIREN7) {
+ ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
diff --git a/formats/format_sln.c b/formats/format_sln.c
index c78a4fdcb..9c4cce75b 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -39,7 +39,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SLINEAR;
+ s->fr.subclass.codec = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -59,8 +59,8 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-slinear frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-slinear frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
diff --git a/formats/format_sln16.c b/formats/format_sln16.c
index 78260f337..15991f854 100644
--- a/formats/format_sln16.c
+++ b/formats/format_sln16.c
@@ -40,7 +40,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SLINEAR16;
+ s->fr.subclass.codec = AST_FORMAT_SLINEAR16;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -61,8 +61,8 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR16) {
- ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR16) {
+ ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
diff --git a/formats/format_vox.c b/formats/format_vox.c
index a9aef6070..546777752 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -41,7 +41,7 @@ static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_ADPCM;
+ s->fr.subclass.codec = AST_FORMAT_ADPCM;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
@@ -61,8 +61,8 @@ static int vox_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_ADPCM) {
- ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_ADPCM) {
+ ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
diff --git a/formats/format_wav.c b/formats/format_wav.c
index b458442e2..ab02a5d15 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -361,7 +361,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
bytes = 0;
/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SLINEAR;
+ s->fr.subclass.codec = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
@@ -397,8 +397,8 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (!f->datalen)
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index aa3dd2eee..5796e28a6 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -395,7 +395,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
struct wavg_desc *fs = (struct wavg_desc *)s->_private;
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_GSM;
+ s->fr.subclass.codec = AST_FORMAT_GSM;
s->fr.offset = AST_FRIENDLY_OFFSET;
s->fr.samples = GSM_SAMPLES;
s->fr.mallocd = 0;
@@ -432,8 +432,8 @@ static int wav_write(struct ast_filestream *s, struct ast_frame *f)
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_GSM) {
- ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_GSM) {
+ ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
/* XXX this might fail... if the input is a multiple of MSGSM_FRAME_SIZE
diff --git a/funcs/func_volume.c b/funcs/func_volume.c
index 06bc38a42..88153f603 100644
--- a/funcs/func_volume.c
+++ b/funcs/func_volume.c
@@ -100,10 +100,10 @@ static int volume_callback(struct ast_audiohook *audiohook, struct ast_channel *
/* Only use DTMF coming from the source... not going to it */
if (direction != AST_AUDIOHOOK_DIRECTION_READ)
return 0;
- if (frame->subclass == '*') {
+ if (frame->subclass.integer == '*') {
vi->tx_gain += 1;
vi->rx_gain += 1;
- } else if (frame->subclass == '#') {
+ } else if (frame->subclass.integer == '#') {
vi->tx_gain -= 1;
vi->rx_gain -= 1;
}
diff --git a/include/asterisk/abstract_jb.h b/include/asterisk/abstract_jb.h
index 804cbe8a9..5827787c5 100644
--- a/include/asterisk/abstract_jb.h
+++ b/include/asterisk/abstract_jb.h
@@ -32,6 +32,8 @@
#include <sys/time.h>
+#include "asterisk/frame_defs.h"
+
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
@@ -92,7 +94,7 @@ struct ast_jb
/*! \brief The time the next frame should be played. */
long next;
/*! \brief Voice format of the last frame in. */
- int last_format;
+ format_t last_format;
/*! \brief File for frame timestamp tracing. */
FILE *logfile;
/*! \brief Jitterbuffer internal state flags. */
diff --git a/include/asterisk/audiohook.h b/include/asterisk/audiohook.h
index b5e147d98..eadea3a29 100644
--- a/include/asterisk/audiohook.h
+++ b/include/asterisk/audiohook.h
@@ -30,7 +30,7 @@ extern "C" {
/* these two are used in struct ast_audiohook */
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
-
+#include "asterisk/frame_defs.h"
#include "asterisk/slinfactory.h"
enum ast_audiohook_type {
@@ -133,7 +133,7 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo
* \param format Format of frame remote side wants back
* \return Returns frame on success, NULL on failure
*/
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format);
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format);
/*! \brief Attach audiohook to channel
* \param chan Channel
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index e3fba92f7..fb38adc6f 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -352,6 +352,9 @@
/* Define to the version of the Hoard Memory Allocator library. */
#undef HAVE_HOARD_VERSION
+/* Define to 1 if you have the `htonll' function. */
+#undef HAVE_HTONLL
+
/* Define to 1 if you have the ical libraries library. */
#undef HAVE_ICAL
@@ -576,6 +579,9 @@
/* Define to the version of the newt library. */
#undef HAVE_NEWT_VERSION
+/* Define to 1 if you have the `ntohll' function. */
+#undef HAVE_NTOHLL
+
/* Define to 1 if your ODBC library has wide (Unicode) types. */
#undef HAVE_ODBC_WCHAR
diff --git a/include/asterisk/bridging.h b/include/asterisk/bridging.h
index 33fe041ca..3e3476002 100644
--- a/include/asterisk/bridging.h
+++ b/include/asterisk/bridging.h
@@ -193,7 +193,7 @@ struct ast_bridge {
* This creates a simple two party bridge that will be destroyed once one of
* the channels hangs up.
*/
-struct ast_bridge *ast_bridge_new(int capabilities, int flags);
+struct ast_bridge *ast_bridge_new(format_t capabilities, int flags);
/*! \brief See if it is possible to create a bridge
*
@@ -211,7 +211,7 @@ struct ast_bridge *ast_bridge_new(int capabilities, int flags);
* This sees if it is possible to create a bridge capable of bridging two channels
* together.
*/
-int ast_bridge_check(int capabilities);
+int ast_bridge_check(format_t capabilities);
/*! \brief Destroy a bridge
*
diff --git a/include/asterisk/bridging_technology.h b/include/asterisk/bridging_technology.h
index 58b27a4b4..a22af0e9e 100644
--- a/include/asterisk/bridging_technology.h
+++ b/include/asterisk/bridging_technology.h
@@ -45,7 +45,7 @@ struct ast_bridge_technology {
/*! Unique name to this bridge technology */
const char *name;
/*! The capabilities that this bridge technology is capable of */
- int capabilities;
+ format_t capabilities;
/*! Preference level that should be used when determining whether to use this bridge technology or not */
enum ast_bridge_preference preference;
/*! Callback for when a bridge is being created */
@@ -71,7 +71,7 @@ struct ast_bridge_technology {
/*! Callback for poking a bridge thread */
int (*poke)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
/*! Formats that the bridge technology supports */
- int formats;
+ format_t formats;
/*! Bit to indicate whether the bridge technology is currently suspended or not */
unsigned int suspended:1;
/*! Module this bridge technology belongs to. Is used for reference counting when creating/destroying a bridge. */
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index bade468a8..c42eb88ea 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -417,12 +417,12 @@ struct ast_channel_tech {
const char * const type;
const char * const description;
- int capabilities; /*!< Bitmap of formats this channel can handle */
+ format_t capabilities; /*!< Bitmap of formats this channel can handle */
- int properties; /*!< Technology Properties */
+ int properties; /*!< Technology Properties */
/*! \brief Requester - to set up call data structures (pvt's) */
- struct ast_channel *(* const requester)(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+ struct ast_channel *(* const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
int (* const devicestate)(void *data); /*!< Devicestate call back */
@@ -731,7 +731,7 @@ struct ast_channel {
int fdno; /*!< Which fd had an event detected on */
int streamid; /*!< For streaming playback, the schedule ID */
int vstreamid; /*!< For streaming video playback, the schedule ID */
- int oldwriteformat; /*!< Original writer format */
+ format_t oldwriteformat; /*!< Original writer format */
int timingfd; /*!< Timing fd */
enum ast_channel_state _state; /*!< State of line -- Don't write directly, use ast_setstate() */
int rings; /*!< Number of rings so far */
@@ -746,11 +746,11 @@ struct ast_channel {
int hangupcause; /*!< Why is the channel hanged up. See causes.h */
unsigned int flags; /*!< channel flags of AST_FLAG_ type */
int alertpipe[2];
- int nativeformats; /*!< Kinds of data this channel can natively handle */
- int readformat; /*!< Requested read format */
- int writeformat; /*!< Requested write format */
- int rawreadformat; /*!< Raw read format */
- int rawwriteformat; /*!< Raw write format */
+ format_t nativeformats; /*!< Kinds of data this channel can natively handle */
+ format_t readformat; /*!< Requested read format */
+ format_t writeformat; /*!< Requested write format */
+ format_t rawreadformat; /*!< Raw read format */
+ format_t rawwriteformat; /*!< Raw write format */
unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
#ifdef HAVE_EPOLL
int epfd;
@@ -1139,7 +1139,7 @@ struct ast_channel *ast_channel_release(struct ast_channel *chan);
* \retval NULL failure
* \retval non-NULL channel on success
*/
-struct ast_channel *ast_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *status);
+struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status);
/*!
* \brief Request a channel of a given type, with data as optional information used
@@ -1156,7 +1156,7 @@ struct ast_channel *ast_request(const char *type, int format, const struct ast_c
* \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
* to know if the call was answered or not.
*/
-struct ast_channel *ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data,
+struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
int timeout, int *reason, const char *cid_num, const char *cid_name);
/*!
@@ -1173,7 +1173,7 @@ struct ast_channel *ast_request_and_dial(const char *type, int format, const str
* \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
* to know if the call was answered or not.
*/
-struct ast_channel *__ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data,
+struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
/*!
@@ -1186,7 +1186,7 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s
* \param outstate reason why unsuccessful (if uncuccessful)
* \return Returns the forwarded call's ast_channel on success or NULL on failure
*/
-struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate);
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate);
/*!
* \brief Register a channel technology (a new channel driver)
@@ -1591,7 +1591,7 @@ int ast_prod(struct ast_channel *chan);
* \param format format to change to
* \return Returns 0 on success, -1 on failure
*/
-int ast_set_read_format(struct ast_channel *chan, int format);
+int ast_set_read_format(struct ast_channel *chan, format_t format);
/*!
* \brief Sets write format on channel chan
@@ -1600,7 +1600,7 @@ int ast_set_read_format(struct ast_channel *chan, int format);
* \param format new format for writing
* \return Returns 0 on success, -1 on failure
*/
-int ast_set_write_format(struct ast_channel *chan, int format);
+int ast_set_write_format(struct ast_channel *chan, format_t format);
/*!
* \brief Sends text to a channel
@@ -1821,7 +1821,7 @@ int ast_channel_setoption(struct ast_channel *channel, int option, void *data, i
/*! Pick the best codec
* Choose the best codec... Uhhh... Yah. */
-int ast_best_codec(int fmts);
+format_t ast_best_codec(format_t fmts);
/*!
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h
index fac1079c8..8f2512a28 100644
--- a/include/asterisk/compat.h
+++ b/include/asterisk/compat.h
@@ -81,6 +81,14 @@ int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt,
int getloadavg(double *list, int nelem);
#endif
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64);
+#endif
+
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64);
+#endif
+
#ifndef HAVE_SETENV
int setenv(const char *name, const char *value, int overwrite);
#endif
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 30de19a5f..c493b8114 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -31,12 +31,13 @@ extern "C" {
#include <sys/time.h>
+#include "asterisk/frame_defs.h"
#include "asterisk/endian.h"
#include "asterisk/linkedlists.h"
struct ast_codec_pref {
- char order[32];
- char framing[32];
+ char order[sizeof(format_t) * 8];
+ char framing[sizeof(format_t) * 8];
};
/*!
@@ -136,7 +137,10 @@ struct ast_frame {
/*! Kind of frame */
enum ast_frame_type frametype;
/*! Subclass, frame dependent */
- int subclass;
+ union {
+ int integer;
+ format_t codec;
+ } subclass;
/*! Length of data */
int datalen;
/*! Number of samples in this frame */
@@ -232,61 +236,65 @@ extern struct ast_frame ast_null_frame;
/* Data formats for capabilities and frames alike */
/*! G.723.1 compression */
-#define AST_FORMAT_G723_1 (1 << 0)
+#define AST_FORMAT_G723_1 (1ULL << 0)
/*! GSM compression */
-#define AST_FORMAT_GSM (1 << 1)
+#define AST_FORMAT_GSM (1ULL << 1)
/*! Raw mu-law data (G.711) */
-#define AST_FORMAT_ULAW (1 << 2)
+#define AST_FORMAT_ULAW (1ULL << 2)
/*! Raw A-law data (G.711) */
-#define AST_FORMAT_ALAW (1 << 3)
+#define AST_FORMAT_ALAW (1ULL << 3)
/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
-#define AST_FORMAT_G726_AAL2 (1 << 4)
+#define AST_FORMAT_G726_AAL2 (1ULL << 4)
/*! ADPCM (IMA) */
-#define AST_FORMAT_ADPCM (1 << 5)
+#define AST_FORMAT_ADPCM (1ULL << 5)
/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
-#define AST_FORMAT_SLINEAR (1 << 6)
+#define AST_FORMAT_SLINEAR (1ULL << 6)
/*! LPC10, 180 samples/frame */
-#define AST_FORMAT_LPC10 (1 << 7)
+#define AST_FORMAT_LPC10 (1ULL << 7)
/*! G.729A audio */
-#define AST_FORMAT_G729A (1 << 8)
+#define AST_FORMAT_G729A (1ULL << 8)
/*! SpeeX Free Compression */
-#define AST_FORMAT_SPEEX (1 << 9)
+#define AST_FORMAT_SPEEX (1ULL << 9)
/*! iLBC Free Compression */
-#define AST_FORMAT_ILBC (1 << 10)
+#define AST_FORMAT_ILBC (1ULL << 10)
/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
-#define AST_FORMAT_G726 (1 << 11)
+#define AST_FORMAT_G726 (1ULL << 11)
/*! G.722 */
-#define AST_FORMAT_G722 (1 << 12)
+#define AST_FORMAT_G722 (1ULL << 12)
/*! G.722.1 (also known as Siren7, 32kbps assumed) */
-#define AST_FORMAT_SIREN7 (1 << 13)
+#define AST_FORMAT_SIREN7 (1ULL << 13)
/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
-#define AST_FORMAT_SIREN14 (1 << 14)
+#define AST_FORMAT_SIREN14 (1ULL << 14)
/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
-#define AST_FORMAT_SLINEAR16 (1 << 15)
+#define AST_FORMAT_SLINEAR16 (1ULL << 15)
/*! Maximum audio mask */
-#define AST_FORMAT_AUDIO_MASK ((1 << 16)-1)
+#define AST_FORMAT_AUDIO_MASK 0xFFFF0000FFFFULL
/*! JPEG Images */
-#define AST_FORMAT_JPEG (1 << 16)
+#define AST_FORMAT_JPEG (1ULL << 16)
/*! PNG Images */
-#define AST_FORMAT_PNG (1 << 17)
+#define AST_FORMAT_PNG (1ULL << 17)
/*! H.261 Video */
-#define AST_FORMAT_H261 (1 << 18)
+#define AST_FORMAT_H261 (1ULL << 18)
/*! H.263 Video */
-#define AST_FORMAT_H263 (1 << 19)
+#define AST_FORMAT_H263 (1ULL << 19)
/*! H.263+ Video */
-#define AST_FORMAT_H263_PLUS (1 << 20)
+#define AST_FORMAT_H263_PLUS (1ULL << 20)
/*! H.264 Video */
-#define AST_FORMAT_H264 (1 << 21)
+#define AST_FORMAT_H264 (1ULL << 21)
/*! MPEG4 Video */
-#define AST_FORMAT_MP4_VIDEO (1 << 22)
-#define AST_FORMAT_VIDEO_MASK (((1 << 25)-1) & ~(AST_FORMAT_AUDIO_MASK))
+#define AST_FORMAT_MP4_VIDEO (1ULL << 22)
+#define AST_FORMAT_VIDEO_MASK ((((1ULL << 25)-1) & ~(AST_FORMAT_AUDIO_MASK)) | 0x7FFF000000000000ULL)
/*! T.140 RED Text format RFC 4103 */
-#define AST_FORMAT_T140RED (1 << 26)
+#define AST_FORMAT_T140RED (1ULL << 26)
/*! T.140 Text format - ITU T.140, RFC 4103 */
-#define AST_FORMAT_T140 (1 << 27)
+#define AST_FORMAT_T140 (1ULL << 27)
/*! Maximum text mask */
-#define AST_FORMAT_MAX_TEXT (1 << 28))
-#define AST_FORMAT_TEXT_MASK (((1 << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
+#define AST_FORMAT_MAX_TEXT (1ULL << 28)
+#define AST_FORMAT_TEXT_MASK (((1ULL << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
+/*! Raw mu-law data (G.711) */
+#define AST_FORMAT_TESTLAW (1ULL << 47)
+/*! Reserved bit - do not use */
+#define AST_FORMAT_RESERVED (1ULL << 63)
enum ast_control_frame_type {
AST_CONTROL_HANGUP = 1, /*!< Other end has hungup */
@@ -444,7 +452,7 @@ struct ast_option_header {
/*! \brief Definition of supported media formats (codecs) */
struct ast_format_list {
- int bits; /*!< bitmask value */
+ format_t bits; /*!< bitmask value */
char *name; /*!< short name */
int samplespersecond; /*!< Number of samples per second (8000/16000) */
char *desc; /*!< Description */
@@ -517,7 +525,7 @@ void ast_swapcopy_samples(void *dst, const void *src, int samples);
* \param format id of format
* \return A static string containing the name of the format or "unknown" if unknown.
*/
-char* ast_getformatname(int format);
+char* ast_getformatname(format_t format);
/*! \brief Get the names of a set of formats
* \param buf a buffer for the output string
@@ -527,21 +535,21 @@ char* ast_getformatname(int format);
* ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
* \return The return value is buf.
*/
-char* ast_getformatname_multiple(char *buf, size_t size, int format);
+char* ast_getformatname_multiple(char *buf, size_t size, format_t format);
/*!
* \brief Gets a format from a name.
* \param name string of format
* \return This returns the form of the format in binary on success, 0 on error.
*/
-int ast_getformatbyname(const char *name);
+format_t ast_getformatbyname(const char *name);
/*! \brief Get a name from a format
* Gets a name from a format
* \param codec codec number (1,2,4,8,16,etc.)
* \return This returns a static string identifying the format on success, 0 on error.
*/
-char *ast_codec2str(int codec);
+char *ast_codec2str(format_t codec);
/*! \name AST_Smoother
*/
@@ -617,38 +625,38 @@ void ast_codec_pref_init(struct ast_codec_pref *pref);
* \brief Codec located at a particular place in the preference index.
* \arg \ref AudioCodecPref
*/
-int ast_codec_pref_index(struct ast_codec_pref *pref, int index);
+format_t ast_codec_pref_index(struct ast_codec_pref *pref, int index);
/*! \brief Remove audio a codec from a preference list */
-void ast_codec_pref_remove(struct ast_codec_pref *pref, int format);
+void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format);
/*! \brief Append a audio codec to a preference list, removing it first if it was already there
*/
-int ast_codec_pref_append(struct ast_codec_pref *pref, int format);
+int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format);
/*! \brief Prepend an audio codec to a preference list, removing it first if it was already there
*/
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing);
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing);
/*! \brief Select the best audio format according to preference list from supplied options.
If "find_best" is non-zero then if nothing is found, the "Best" format of
the format list is selected, otherwise 0 is returned. */
-int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best);
+format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best);
/*! \brief Set packet size for codec
*/
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems);
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems);
/*! \brief Get packet size for codec
*/
-struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format);
+struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format);
/*! \brief Parse an "allow" or "deny" line in a channel or device configuration
and update the capabilities mask and pref if provided.
Video codecs are not added to codec preference lists, since we can not transcode
\return Returns number of errors encountered during parsing
*/
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing);
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing);
/*! \brief Dump audio codec preference list into a string */
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size);
@@ -660,14 +668,14 @@ void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size,
int ast_codec_get_samples(struct ast_frame *f);
/*! \brief Returns the number of bytes for the number of samples of the given format */
-int ast_codec_get_len(int format, int samples);
+int ast_codec_get_len(format_t format, int samples);
/*! \brief Appends a frame to the end of a list of frames, truncating the maximum length of the list */
struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe);
/*! \brief Gets duration in ms of interpolation frame for a format */
-static inline int ast_codec_interp_len(int format)
+static inline int ast_codec_interp_len(format_t format)
{
return (format == AST_FORMAT_ILBC) ? 30 : 20;
}
@@ -694,7 +702,7 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2);
/*!
* \brief Get the sample rate for a given format.
*/
-static force_inline int ast_format_rate(int format)
+static force_inline int ast_format_rate(format_t format)
{
switch (format) {
case AST_FORMAT_G722:
diff --git a/include/asterisk/frame_defs.h b/include/asterisk/frame_defs.h
new file mode 100644
index 000000000..829572d19
--- /dev/null
+++ b/include/asterisk/frame_defs.h
@@ -0,0 +1,38 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2009, Digium, Inc.
+ *
+ * Mark Spencer <markster@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Asterisk internal frame definitions.
+ * \arg For an explanation of frames, see \ref Def_Frame
+ * \arg Frames are send of Asterisk channels, see \ref Def_Channel
+ */
+
+#ifndef _ASTERISK_FRAME_DEFS_H
+#define _ASTERISK_FRAME_DEFS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+typedef int64_t format_t;
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_FRAME_DEFS_H */
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index b8f01a2bd..88479519c 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -879,11 +879,11 @@ int ast_async_goto_by_name(const char *chan, const char *context, const char *ex
/*! Synchronously or asynchronously make an outbound call and send it to a
particular extension */
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
/*! Synchronously or asynchronously make an outbound call and send it to a
particular application with given extension */
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
/*!
* \brief Evaluate a condition
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index 8f4292a98..731c807ed 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -221,7 +221,7 @@ struct ast_rtp_payload_type {
/*! Is this an Asterisk value */
int asterisk_format;
/*! Actual internal value of the payload */
- int code;
+ format_t code;
};
/*! Structure that represents statistics from an RTP instance */
@@ -328,7 +328,7 @@ struct ast_rtp_engine {
/*! Callback for setting an RTP property */
void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
/*! Callback for setting a payload */
- void (*payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, int format);
+ void (*payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, format_t format);
/*! Callback for setting packetization preferences */
void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
/*! Callback for setting the remote address that RTP is to be sent to */
@@ -352,9 +352,9 @@ struct ast_rtp_engine {
/*! Callback to locally bridge two RTP instances */
int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
/*! Callback to set the read format */
- int (*set_read_format)(struct ast_rtp_instance *instance, int format);
+ int (*set_read_format)(struct ast_rtp_instance *instance, format_t format);
/*! Callback to set the write format */
- int (*set_write_format)(struct ast_rtp_instance *instance, int format);
+ int (*set_write_format)(struct ast_rtp_instance *instance, format_t format);
/*! Callback to make two instances compatible */
int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
/*! Callback to see if two instances are compatible with DTMF */
@@ -399,9 +399,9 @@ struct ast_rtp_glue {
*/
enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
/*! Callback for updating the destination that the remote side should send RTP to */
- int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active);
+ int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active);
/*! Callback for retrieving codecs that the channel can do */
- int (*get_codec)(struct ast_channel *chan);
+ format_t (*get_codec)(struct ast_channel *chan);
/*! Linked list information */
AST_RWLIST_ENTRY(ast_rtp_glue) entry;
};
@@ -994,7 +994,7 @@ struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs
*
* \since 1.6.3
*/
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code);
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code);
/*!
* \brief Retrieve all formats that were found
@@ -1015,7 +1015,7 @@ unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code);
*
* \since 1.6.3
*/
-void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astformats, int *nonastformats);
+void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats);
/*!
* \brief Retrieve a payload based on whether it is an Asterisk format and the code
@@ -1036,7 +1036,7 @@ void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astforma
*
* \since 1.6.3
*/
-int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const int code);
+int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code);
/*!
* \brief Retrieve mime subtype information on a payload
@@ -1058,7 +1058,7 @@ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asteris
*
* \since 1.6.3
*/
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int code, enum ast_rtp_options options);
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options);
/*!
* \brief Convert formats into a string and put them into a buffer
@@ -1082,7 +1082,7 @@ const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int co
*
* \since 1.6.3
*/
-char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const int capability, const int asterisk_format, enum ast_rtp_options options);
+char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options);
/*!
* \brief Set codec packetization preferences
@@ -1464,7 +1464,7 @@ char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_r
*
* \since 1.6.3
*/
-int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, int format);
+int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format);
/*!
* \brief Tell underlying RTP engine that audio frames will be provided in a specific format
@@ -1485,7 +1485,7 @@ int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, int form
*
* \since 1.6.3
*/
-int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, int format);
+int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format);
/*!
* \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
@@ -1527,7 +1527,7 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
*
* \since 1.6.3
*/
-int ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
+format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
/*!
* \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
diff --git a/include/asterisk/slin.h b/include/asterisk/slin.h
index c1f33b910..5ba5af580 100644
--- a/include/asterisk/slin.h
+++ b/include/asterisk/slin.h
@@ -86,7 +86,7 @@ static inline struct ast_frame *slin8_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.datalen = sizeof(ex_slin8),
.samples = ARRAY_LEN(ex_slin8) / 2,
.mallocd = 0,
@@ -102,7 +102,7 @@ static inline struct ast_frame *slin16_sample(void)
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR16,
+ .subclass.codec = AST_FORMAT_SLINEAR16,
.datalen = sizeof(ex_slin16),
.samples = ARRAY_LEN(ex_slin16) / 2,
.mallocd = 0,
diff --git a/include/asterisk/slinfactory.h b/include/asterisk/slinfactory.h
index 4309af789..78d432193 100644
--- a/include/asterisk/slinfactory.h
+++ b/include/asterisk/slinfactory.h
@@ -37,8 +37,8 @@ struct ast_slinfactory {
short *offset; /*!< Offset into the hold where audio begins */
size_t holdlen; /*!< Number of samples currently in the hold */
unsigned int size; /*!< Number of samples currently in the factory */
- unsigned int format; /*!< Current format the translation path is converting from */
- unsigned int output_format; /*!< The output format desired */
+ format_t format; /*!< Current format the translation path is converting from */
+ format_t output_format; /*!< The output format desired */
};
/*!
diff --git a/include/asterisk/translate.h b/include/asterisk/translate.h
index 0e0eae1ec..8a5ac2106 100644
--- a/include/asterisk/translate.h
+++ b/include/asterisk/translate.h
@@ -24,8 +24,8 @@
#ifndef _ASTERISK_TRANSLATE_H
#define _ASTERISK_TRANSLATE_H
-#define MAX_AUDIO_FORMAT 15 /* Do not include video here */
-#define MAX_FORMAT 32 /* Do include video here */
+#define MAX_AUDIO_FORMAT 47 /* Do not include video here */
+#define MAX_FORMAT 64 /* Do include video here */
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@@ -69,51 +69,51 @@ struct ast_trans_pvt; /* declared below */
* Generic plc is only available for dstfmt = SLINEAR
*/
struct ast_translator {
- const char name[80]; /*!< Name of translator */
- int srcfmt; /*!< Source format (note: bit position,
- converted to index during registration) */
- int dstfmt; /*!< Destination format (note: bit position,
- converted to index during registration) */
+ const char name[80]; /*!< Name of translator */
+ format_t srcfmt; /*!< Source format (note: bit position,
+ * converted to index during registration) */
+ format_t dstfmt; /*!< Destination format (note: bit position,
+ * converted to index during registration) */
int (*newpvt)(struct ast_trans_pvt *); /*!< initialize private data
- associated with the translator */
+ * associated with the translator */
int (*framein)(struct ast_trans_pvt *pvt, struct ast_frame *in);
- /*!< Input frame callback. Store
- (and possibly convert) input frame. */
+ /*!< Input frame callback. Store
+ * (and possibly convert) input frame. */
struct ast_frame * (*frameout)(struct ast_trans_pvt *pvt);
- /*!< Output frame callback. Generate a frame
- with outbuf content. */
+ /*!< Output frame callback. Generate a frame
+ * with outbuf content. */
void (*destroy)(struct ast_trans_pvt *pvt);
- /*!< cleanup private data, if needed
- (often unnecessary). */
+ /*!< cleanup private data, if needed
+ * (often unnecessary). */
- struct ast_frame * (*sample)(void); /*!< Generate an example frame */
+ struct ast_frame * (*sample)(void); /*!< Generate an example frame */
- /*! \brief size of outbuf, in samples. Leave it 0 if you want the framein
+ /*!\brief size of outbuf, in samples. Leave it 0 if you want the framein
* callback deal with the frame. Set it appropriately if you
* want the code to checks if the incoming frame fits the
* outbuf (this is e.g. required for plc).
*/
- int buffer_samples; /*< size of outbuf, in samples */
+ int buffer_samples; /*< size of outbuf, in samples */
/*! \brief size of outbuf, in bytes. Mandatory. The wrapper code will also
* allocate an AST_FRIENDLY_OFFSET space before.
*/
int buf_size;
- int desc_size; /*!< size of private descriptor in pvt->pvt, if any */
- int plc_samples; /*!< set to the plc block size if used, 0 otherwise */
- int useplc; /*!< current status of plc, changed at runtime */
- int native_plc; /*!< true if the translator can do native plc */
+ int desc_size; /*!< size of private descriptor in pvt->pvt, if any */
+ int plc_samples; /*!< set to the plc block size if used, 0 otherwise */
+ int useplc; /*!< current status of plc, changed at runtime */
+ int native_plc; /*!< true if the translator can do native plc */
- struct ast_module *module; /* opaque reference to the parent module */
+ struct ast_module *module; /*!< opaque reference to the parent module */
- int cost; /*!< Cost in milliseconds for encoding/decoding 1 second of sound */
- int active; /*!< Whether this translator should be used or not */
- AST_LIST_ENTRY(ast_translator) list; /*!< link field */
+ int cost; /*!< Cost in milliseconds for encoding/decoding 1 second of sound */
+ int active; /*!< Whether this translator should be used or not */
+ AST_LIST_ENTRY(ast_translator) list; /*!< link field */
};
/*! \brief
@@ -205,7 +205,7 @@ void ast_translator_deactivate(struct ast_translator *t);
* \return Returns 0 on success, -1 if no path could be found.
* \note Modifies dests and srcs in place
*/
-int ast_translator_best_choice(int *dsts, int *srcs);
+format_t ast_translator_best_choice(format_t *dsts, format_t *srcs);
/*!
* \brief Builds a translator path
@@ -214,7 +214,7 @@ int ast_translator_best_choice(int *dsts, int *srcs);
* \param source source format
* \return ast_trans_pvt on success, NULL on failure
* */
-struct ast_trans_pvt *ast_translator_build_path(int dest, int source);
+struct ast_trans_pvt *ast_translator_build_path(format_t dest, format_t source);
/*!
* \brief Frees a translator path
@@ -240,7 +240,7 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, i
* \param src source format
* \return the number of translation steps required, or -1 if no path is available
*/
-unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src);
+unsigned int ast_translate_path_steps(format_t dest, format_t src);
/*!
* \brief Mask off unavailable formats from a format bitmask
@@ -254,7 +254,7 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src);
* \note Only a single audio format and a single video format can be
* present in 'src', or the function will produce unexpected results.
*/
-unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src);
+format_t ast_translate_available_formats(format_t dest, format_t src);
#if defined(__cplusplus) || defined(c_plusplus)
}
diff --git a/include/asterisk/unaligned.h b/include/asterisk/unaligned.h
index c502efede..9ca2177a1 100644
--- a/include/asterisk/unaligned.h
+++ b/include/asterisk/unaligned.h
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2009, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
@@ -29,6 +29,12 @@ extern "C" {
#ifdef __GNUC__
/* If we just tell GCC what's going on, we can trust it to behave optimally */
+static inline uint64_t get_unaligned_uint64(const void *p)
+{
+ const struct { uint64_t d; } __attribute__((packed)) *pp = p;
+ return pp->d;
+}
+
static inline unsigned int get_unaligned_uint32(const void *p)
{
const struct { unsigned int d; } __attribute__((packed)) *pp = p;
@@ -42,6 +48,13 @@ static inline unsigned short get_unaligned_uint16(const void *p)
return pp->d;
}
+static inline void put_unaligned_uint64(void *p, uint64_t datum)
+{
+ struct { uint64_t d; } __attribute__((packed)) *pp = p;
+
+ pp->d = datum;
+}
+
static inline void put_unaligned_uint32(void *p, unsigned int datum)
{
struct { unsigned int d; } __attribute__((packed)) *pp = p;
@@ -56,6 +69,21 @@ static inline void put_unaligned_uint16(void *p, unsigned short datum)
pp->d = datum;
}
#elif defined(SOLARIS) && defined(__sparc__)
+static inline uint64_t get_unaligned_uint64(const void *p)
+{
+ const unsigned char *cp = p;
+
+ return
+ (((uint64_t) cp[0]) << 56) |
+ (((uint64_t) cp[1]) << 48) |
+ (((uint64_t) cp[2]) << 40) |
+ (((uint64_t) cp[3]) << 32) |
+ (((uint64_t) cp[4]) << 24) |
+ (((uint64_t) cp[5]) << 16) |
+ (((uint64_t) cp[6]) << 8) |
+ (((uint64_t) cp[7]) << 0);
+}
+
static inline unsigned int get_unaligned_uint32(const void *p)
{
const unsigned char *cp = p;
@@ -70,6 +98,20 @@ static inline unsigned short get_unaligned_uint16(const void *p)
return (cp[0] << 8) | cp[1] ;
}
+static inline void put_unaligned_uint64(void *p, uint64_t datum)
+{
+ unsigned char *cp = p;
+
+ cp[0] = (datum >> 56) & 0xff;
+ cp[1] = (datum >> 48) & 0xff;
+ cp[2] = (datum >> 40) & 0xff;
+ cp[3] = (datum >> 32) & 0xff;
+ cp[4] = (datum >> 24) & 0xff;
+ cp[5] = (datum >> 16) & 0xff;
+ cp[6] = (datum >> 8) & 0xff;
+ cp[7] = (datum >> 0) & 0xff;
+}
+
static inline void put_unaligned_uint32(void *p, unsigned int datum)
{
unsigned char *cp = p;
@@ -88,8 +130,10 @@ static inline void put_unaligned_uint16(void *p, unsigned int datum)
cp[1] = datum;
}
#else /* Not GCC, not Solaris/SPARC. Assume we can handle direct load/store. */
+#define get_unaligned_uint64(p) (*((uint64_t *)(p)))
#define get_unaligned_uint32(p) (*((unsigned int *)(p)))
#define get_unaligned_uint16(p) (*((unsigned short *)(p)))
+#define put_unaligned_uint64(p,d) do { uint64_t *__P = (p); *__P = d; } while(0)
#define put_unaligned_uint32(p,d) do { unsigned int *__P = (p); *__P = d; } while(0)
#define put_unaligned_uint16(p,d) do { unsigned short *__P = (p); *__P = d; } while(0)
#endif
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index cda9a6dca..7ebbb628b 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -409,14 +409,14 @@ static void jb_get_and_deliver(struct ast_channel *chan)
case JB_IMPL_DROP:
jb_framelog("\tJB_GET {now=%ld}: %s frame with ts=%ld and len=%ld\n",
now, jb_get_actions[res], f->ts, f->len);
- jb->last_format = f->subclass;
+ jb->last_format = f->subclass.codec;
ast_frfree(f);
break;
case JB_IMPL_INTERP:
/* interpolate a frame */
f = &finterp;
f->frametype = AST_FRAME_VOICE;
- f->subclass = jb->last_format;
+ f->subclass.codec = jb->last_format;
f->datalen = 0;
f->samples = interpolation_len * 8;
f->mallocd = 0;
@@ -480,7 +480,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
jb->next = jbimpl->next(jbobj);
/* Init last format for a first time. */
- jb->last_format = frr->subclass;
+ jb->last_format = frr->subclass.codec;
/* Create a frame log file */
if (ast_test_flag(jbconf, AST_JB_LOG)) {
diff --git a/main/app.c b/main/app.c
index e33fb03ab..881f99dad 100644
--- a/main/app.c
+++ b/main/app.c
@@ -429,7 +429,7 @@ static int linear_generator(struct ast_channel *chan, void *data, int len, int s
struct linear_state *ls = data;
struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf + AST_FRIENDLY_OFFSET / 2,
.offset = AST_FRIENDLY_OFFSET,
};
@@ -851,20 +851,20 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
} else if (f->frametype == AST_FRAME_DTMF) {
if (prepend) {
/* stop recording with any digit */
- ast_verb(3, "User ended message by pressing %c\n", f->subclass);
+ ast_verb(3, "User ended message by pressing %c\n", f->subclass.integer);
res = 't';
outmsg = 2;
break;
}
- if (strchr(acceptdtmf, f->subclass)) {
- ast_verb(3, "User ended message by pressing %c\n", f->subclass);
- res = f->subclass;
+ if (strchr(acceptdtmf, f->subclass.integer)) {
+ ast_verb(3, "User ended message by pressing %c\n", f->subclass.integer);
+ res = f->subclass.integer;
outmsg = 2;
break;
}
- if (strchr(canceldtmf, f->subclass)) {
- ast_verb(3, "User cancelled message by pressing %c\n", f->subclass);
- res = f->subclass;
+ if (strchr(canceldtmf, f->subclass.integer)) {
+ ast_verb(3, "User cancelled message by pressing %c\n", f->subclass.integer);
+ res = f->subclass.integer;
outmsg = 0;
break;
}
diff --git a/main/asterisk.exports b/main/asterisk.exports
index 2a26061b2..284bf36f2 100644
--- a/main/asterisk.exports
+++ b/main/asterisk.exports
@@ -38,6 +38,8 @@
asprintf;
strtoq;
getloadavg;
+ ntohll;
+ htonll;
local:
*;
};
diff --git a/main/audiohook.c b/main/audiohook.c
index 950b0eb2d..19de2be02 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -40,7 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
struct ast_audiohook_translate {
struct ast_trans_pvt *trans_pvt;
- int format;
+ format_t format;
};
struct ast_audiohook_list {
@@ -173,7 +173,7 @@ static struct ast_frame *audiohook_read_frame_single(struct ast_audiohook *audio
short buf[samples];
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf,
.datalen = sizeof(buf),
.samples = samples,
@@ -200,7 +200,7 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho
short buf1[samples], buf2[samples], *read_buf = NULL, *write_buf = NULL, *final_buf = NULL, *data1 = NULL, *data2 = NULL;
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = NULL,
.datalen = sizeof(buf1),
.samples = samples,
@@ -292,7 +292,7 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho
* \param format Format of frame remote side wants back
* \return Returns frame on success, NULL on failure
*/
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format)
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format)
{
struct ast_frame *read_frame = NULL, *final_frame = NULL;
@@ -576,13 +576,13 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st
int samples = frame->samples;
/* If the frame coming in is not signed linear we have to send it through the in_translate path */
- if (frame->subclass != AST_FORMAT_SLINEAR) {
- if (in_translate->format != frame->subclass) {
+ if (frame->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (in_translate->format != frame->subclass.codec) {
if (in_translate->trans_pvt)
ast_translator_free_path(in_translate->trans_pvt);
- if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass)))
+ if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass.codec)))
return frame;
- in_translate->format = frame->subclass;
+ in_translate->format = frame->subclass.codec;
}
if (!(middle_frame = ast_translate(in_translate->trans_pvt, frame, 0)))
return frame;
@@ -660,16 +660,16 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st
/* Now we figure out what to do with our end frame (whether to transcode or not) */
if (middle_frame == end_frame) {
/* Middle frame was modified and became the end frame... let's see if we need to transcode */
- if (end_frame->subclass != start_frame->subclass) {
- if (out_translate->format != start_frame->subclass) {
+ if (end_frame->subclass.codec != start_frame->subclass.codec) {
+ if (out_translate->format != start_frame->subclass.codec) {
if (out_translate->trans_pvt)
ast_translator_free_path(out_translate->trans_pvt);
- if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass, AST_FORMAT_SLINEAR))) {
+ if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass.codec, AST_FORMAT_SLINEAR))) {
/* We can't transcode this... drop our middle frame and return the original */
ast_frfree(middle_frame);
return start_frame;
}
- out_translate->format = start_frame->subclass;
+ out_translate->format = start_frame->subclass.codec;
}
/* Transcode from our middle (signed linear) frame to new format of the frame that came in */
if (!(end_frame = ast_translate(out_translate->trans_pvt, middle_frame, 0))) {
diff --git a/main/autoservice.c b/main/autoservice.c
index 4e1cd5203..8e3465417 100644
--- a/main/autoservice.c
+++ b/main/autoservice.c
@@ -74,7 +74,7 @@ static void *autoservice_run(void *ign)
{
struct ast_frame hangup_frame = {
.frametype = AST_FRAME_CONTROL,
- .subclass = AST_CONTROL_HANGUP,
+ .subclass.integer = AST_CONTROL_HANGUP,
};
for (;;) {
diff --git a/main/bridging.c b/main/bridging.c
index 2f5afa2cb..6c2a66804 100644
--- a/main/bridging.c
+++ b/main/bridging.c
@@ -250,7 +250,7 @@ static struct ast_frame *bridge_handle_dtmf(struct ast_bridge *bridge, struct as
/* See if this DTMF matches the beginnings of any feature hooks, if so we switch to the feature state to either execute the feature or collect more DTMF */
AST_LIST_TRAVERSE(&features->hooks, hook, entry) {
- if (hook->dtmf[0] == frame->subclass) {
+ if (hook->dtmf[0] == frame->subclass.integer) {
ast_frfree(frame);
frame = NULL;
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
@@ -285,10 +285,10 @@ void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel
struct ast_frame *frame = (((bridge->features.mute) || (bridge_channel->features && bridge_channel->features->mute)) ? ast_read_noaudio(chan) : ast_read(chan));
/* This is pretty simple... see if they hung up */
- if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
+ if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass.integer == AST_CONTROL_HANGUP)) {
/* Signal the thread that is handling the bridged channel that it should be ended */
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
- } else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass)) {
+ } else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass.integer)) {
ast_debug(1, "Dropping control frame from bridge channel %p\n", bridge_channel);
} else {
if (frame->frametype == AST_FRAME_DTMF_BEGIN) {
@@ -382,13 +382,16 @@ static void *bridge_thread(void *data)
}
/*! \brief Helper function used to find the "best" bridge technology given a specified capabilities */
-static struct ast_bridge_technology *find_best_technology(int capabilities)
+static struct ast_bridge_technology *find_best_technology(format_t capabilities)
{
struct ast_bridge_technology *current = NULL, *best = NULL;
AST_RWLIST_RDLOCK(&bridge_technologies);
AST_RWLIST_TRAVERSE(&bridge_technologies, current, entry) {
- ast_debug(1, "Bridge technology %s has capabilities %d and we want %d\n", current->name, current->capabilities, capabilities);
+ char tmp1[256], tmp2[256];
+ ast_debug(1, "Bridge technology %s has capabilities %s and we want %s\n", current->name,
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), current->capabilities),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), capabilities));
if (current->suspended) {
ast_debug(1, "Bridge technology %s is suspended. Skipping.\n", current->name);
continue;
@@ -445,7 +448,7 @@ static void destroy_bridge(void *obj)
return;
}
-struct ast_bridge *ast_bridge_new(int capabilities, int flags)
+struct ast_bridge *ast_bridge_new(format_t capabilities, int flags)
{
struct ast_bridge *bridge = NULL;
struct ast_bridge_technology *bridge_technology = NULL;
@@ -467,7 +470,9 @@ struct ast_bridge *ast_bridge_new(int capabilities, int flags)
/* If no bridge technology was found we can't possibly do bridging so fail creation of the bridge */
if (!bridge_technology) {
- ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %d\n", capabilities);
+ char codec_buf[256];
+ ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %s\n",
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), capabilities));
return NULL;
}
@@ -498,7 +503,7 @@ struct ast_bridge *ast_bridge_new(int capabilities, int flags)
return bridge;
}
-int ast_bridge_check(int capabilities)
+int ast_bridge_check(format_t capabilities)
{
struct ast_bridge_technology *bridge_technology = NULL;
@@ -537,26 +542,27 @@ int ast_bridge_destroy(struct ast_bridge *bridge)
static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
- int formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
+ format_t formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
/* Are the formats currently in use something ths bridge can handle? */
if (!(bridge->technology->formats & bridge_channel->chan->readformat)) {
- int best_format = ast_best_codec(bridge->technology->formats);
+ format_t best_format = ast_best_codec(bridge->technology->formats);
/* Read format is a no go... */
if (option_debug) {
char codec_buf[512];
- ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats);
- ast_debug(1, "Bridge technology %s wants to read any of formats %s(%d) but channel has %s(%d)\n", bridge->technology->name, codec_buf, bridge->technology->formats, ast_getformatname(formats[0]), formats[0]);
+ ast_debug(1, "Bridge technology %s wants to read any of formats %s but channel has %s\n", bridge->technology->name,
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats),
+ ast_getformatname(formats[0]));
}
/* Switch read format to the best one chosen */
if (ast_set_read_format(bridge_channel->chan, best_format)) {
- ast_log(LOG_WARNING, "Failed to set channel %s to read format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_log(LOG_WARNING, "Failed to set channel %s to read format %s\n", bridge_channel->chan->name, ast_getformatname(best_format));
return -1;
}
- ast_debug(1, "Bridge %p put channel %s into read format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_debug(1, "Bridge %p put channel %s into read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format));
} else {
- ast_debug(1, "Bridge %p is happy that channel %s already has read format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[0]), formats[0]);
+ ast_debug(1, "Bridge %p is happy that channel %s already has read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[0]));
}
if (!(bridge->technology->formats & formats[1])) {
@@ -565,17 +571,18 @@ static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_c
/* Write format is a no go... */
if (option_debug) {
char codec_buf[512];
- ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats);
- ast_debug(1, "Bridge technology %s wants to write any of formats %s(%d) but channel has %s(%d)\n", bridge->technology->name, codec_buf, bridge->technology->formats, ast_getformatname(formats[1]), formats[1]);
+ ast_debug(1, "Bridge technology %s wants to write any of formats %s but channel has %s\n", bridge->technology->name,
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats),
+ ast_getformatname(formats[1]));
}
/* Switch write format to the best one chosen */
if (ast_set_write_format(bridge_channel->chan, best_format)) {
- ast_log(LOG_WARNING, "Failed to set channel %s to write format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_log(LOG_WARNING, "Failed to set channel %s to write format %s\n", bridge_channel->chan->name, ast_getformatname(best_format));
return -1;
}
- ast_debug(1, "Bridge %p put channel %s into write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_debug(1, "Bridge %p put channel %s into write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format));
} else {
- ast_debug(1, "Bridge %p is happy that channel %s already has write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[1]), formats[1]);
+ ast_debug(1, "Bridge %p is happy that channel %s already has write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[1]));
}
return 0;
@@ -584,7 +591,7 @@ static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_c
/*! \brief Perform the smart bridge operation. Basically sees if a new bridge technology should be used instead of the current one. */
static int smart_bridge_operation(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int count)
{
- int new_capabilities = 0;
+ format_t new_capabilities = 0;
struct ast_bridge_technology *new_technology = NULL, *old_technology = bridge->technology;
struct ast_bridge temp_bridge = {
.technology = bridge->technology,
@@ -614,7 +621,9 @@ static int smart_bridge_operation(struct ast_bridge *bridge, struct ast_bridge_c
/* Attempt to find a new bridge technology to satisfy the capabilities */
if (!(new_technology = find_best_technology(new_capabilities))) {
- ast_debug(1, "Smart bridge operation was unable to find new bridge technology with capabilities %d to satisfy bridge %p\n", new_capabilities, bridge);
+ char codec_buf[256];
+ ast_debug(1, "Smart bridge operation was unable to find new bridge technology with capabilities %s to satisfy bridge %p\n",
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), new_capabilities), bridge);
return -1;
}
diff --git a/main/channel.c b/main/channel.c
index 946288ebf..ce74b3f26 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -280,6 +280,7 @@ static char *complete_channeltypes(struct ast_cli_args *a)
static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct chanlist *cl = NULL;
+ char buf[512];
switch (cmd) {
case CLI_INIT:
@@ -314,7 +315,7 @@ static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd,
" Device State: %s\n"
" Indication: %s\n"
" Transfer : %s\n"
- " Capabilities: %d\n"
+ " Capabilities: %s\n"
" Digit Begin: %s\n"
" Digit End: %s\n"
" Send HTML : %s\n"
@@ -324,7 +325,7 @@ static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd,
(cl->tech->devicestate) ? "yes" : "no",
(cl->tech->indicate) ? "yes" : "no",
(cl->tech->transfer) ? "yes" : "no",
- (cl->tech->capabilities) ? cl->tech->capabilities : -1,
+ ast_getformatname_multiple(buf, sizeof(buf), (cl->tech->capabilities) ? cl->tech->capabilities : -1),
(cl->tech->send_digit_begin) ? "yes" : "no",
(cl->tech->send_digit_end) ? "yes" : "no",
(cl->tech->send_html) ? "yes" : "no",
@@ -719,12 +720,12 @@ char *ast_transfercapability2str(int transfercapability)
}
/*! \brief Pick the best audio codec */
-int ast_best_codec(int fmts)
+format_t ast_best_codec(format_t fmts)
{
/* This just our opinion, expressed in code. We are asked to choose
the best codec to use, given no information */
int x;
- static const int prefs[] =
+ static const format_t prefs[] =
{
/*! Okay, ulaw is used by all telephony equipment, so start with it */
AST_FORMAT_ULAW,
@@ -732,6 +733,7 @@ int ast_best_codec(int fmts)
AST_FORMAT_ALAW,
AST_FORMAT_SIREN14,
AST_FORMAT_SIREN7,
+ AST_FORMAT_TESTLAW,
/*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
AST_FORMAT_G722,
/*! Okay, well, signed linear is easy to translate into other stuff */
@@ -758,6 +760,7 @@ int ast_best_codec(int fmts)
/*! Down to G.723.1 which is proprietary but at least designed for voice */
AST_FORMAT_G723_1,
};
+ char buf[512];
/* Strip out video */
fmts &= AST_FORMAT_AUDIO_MASK;
@@ -768,7 +771,7 @@ int ast_best_codec(int fmts)
return prefs[x];
}
- ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts);
+ ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
return 0;
}
@@ -1071,7 +1074,7 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
/* See if the last frame on the queue is a hangup, if so don't queue anything */
if ((cur = AST_LIST_LAST(&chan->readq)) &&
(cur->frametype == AST_FRAME_CONTROL) &&
- (cur->subclass == AST_CONTROL_HANGUP)) {
+ (cur->subclass.integer == AST_CONTROL_HANGUP)) {
ast_channel_unlock(chan);
return 0;
}
@@ -1156,7 +1159,7 @@ int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup(struct ast_channel *chan)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -1168,7 +1171,7 @@ int ast_queue_hangup(struct ast_channel *chan)
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
if (cause >= 0)
f.data.uint32 = cause;
@@ -1188,10 +1191,7 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
/*! \brief Queue a control frame */
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
-
- f.subclass = control;
-
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
return ast_queue_frame(chan, &f);
}
@@ -1199,12 +1199,7 @@ int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type cont
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
const void *data, size_t datalen)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
-
- f.subclass = control;
- f.data.ptr = (void *) data;
- f.datalen = datalen;
-
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
return ast_queue_frame(chan, &f);
}
@@ -2348,7 +2343,7 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
}
cur = ast_read(chan);
if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
- (cur->subclass == AST_CONTROL_HANGUP))) {
+ (cur->subclass.integer == AST_CONTROL_HANGUP))) {
if (cur) {
ast_frfree(cur);
}
@@ -2937,12 +2932,12 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
case AST_FRAME_DTMF_BEGIN:
break;
case AST_FRAME_DTMF_END:
- res = f->subclass;
+ res = f->subclass.integer;
ast_frfree(f);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
case AST_FRAME_CONTROL:
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
ast_frfree(f);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
@@ -2955,7 +2950,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
/* Unimportant */
break;
default:
- ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass);
+ ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
break;
}
break;
@@ -3007,9 +3002,9 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
chan->generatordata = NULL; /* reset, to let writes go through */
- if (f->subclass != chan->writeformat) {
+ if (f->subclass.codec != chan->writeformat) {
float factor;
- factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass));
+ factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass.codec));
samples = (int) ( ((float) f->samples) * factor );
} else {
samples = f->samples;
@@ -3045,7 +3040,7 @@ static inline void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame *
struct ast_frame *fr = &chan->dtmff;
fr->frametype = AST_FRAME_DTMF_END;
- fr->subclass = f->subclass;
+ fr->subclass.integer = f->subclass.integer;
fr->len = f->len;
/* The only time this function will be called is for a frame that just came
@@ -3222,7 +3217,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* Interpret hangup and return NULL */
/* XXX why not the same for frames from the channel ? */
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
cause = f->data.uint32;
ast_frfree(f);
f = NULL;
@@ -3264,7 +3259,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
switch (f->frametype) {
case AST_FRAME_CONTROL:
- if (f->subclass == AST_CONTROL_ANSWER) {
+ if (f->subclass.integer == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
ast_debug(1, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
@@ -3282,8 +3277,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
}
break;
case AST_FRAME_DTMF_END:
- send_dtmf_event(chan, "Received", f->subclass, "No", "Yes");
- ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass, chan->name, f->len);
+ send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes");
+ ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len);
/* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
queue_dtmf_readq(chan, f);
@@ -3300,7 +3295,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* There was no begin, turn this into a begin and send the end later */
f->frametype = AST_FRAME_DTMF_BEGIN;
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = f->subclass;
+ chan->emulate_dtmf_digit = f->subclass.integer;
chan->dtmf_tv = ast_tvnow();
if (f->len) {
if (f->len > AST_MIN_DTMF_DURATION)
@@ -3309,7 +3304,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
} else
chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
- ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass, chan->emulate_dtmf_duration, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
}
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
@@ -3323,23 +3318,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
} else {
struct timeval now = ast_tvnow();
if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
- ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name);
ast_clear_flag(chan, AST_FLAG_IN_DTMF);
if (!f->len)
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
} else if (!f->len) {
- ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
f->len = AST_MIN_DTMF_DURATION;
}
if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
- ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass, f->len, AST_MIN_DTMF_DURATION, chan->name);
+ ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = f->subclass;
+ chan->emulate_dtmf_digit = f->subclass.integer;
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
ast_frfree(f);
f = &ast_null_frame;
} else {
- ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
if (f->len < AST_MIN_DTMF_DURATION) {
f->len = AST_MIN_DTMF_DURATION;
}
@@ -3354,18 +3349,18 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
}
break;
case AST_FRAME_DTMF_BEGIN:
- send_dtmf_event(chan, "Received", f->subclass, "Yes", "No");
- ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass, chan->name);
+ send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
+ ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name);
if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) ||
(!ast_tvzero(chan->dtmf_tv) &&
ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) {
- ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name);
ast_frfree(f);
f = &ast_null_frame;
} else {
ast_set_flag(chan, AST_FLAG_IN_DTMF);
chan->dtmf_tv = ast_tvnow();
- ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name);
}
break;
case AST_FRAME_NULL:
@@ -3383,12 +3378,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
- f->subclass = chan->emulate_dtmf_digit;
+ f->subclass.integer = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
- ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
@@ -3423,7 +3418,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
- f->subclass = chan->emulate_dtmf_digit;
+ f->subclass.integer = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
if (chan->audiohooks) {
@@ -3432,17 +3427,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (old_frame != f)
ast_frfree(old_frame);
}
- ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
} else {
/* Drop voice frames while we're still in the middle of the digit */
ast_frfree(f);
f = &ast_null_frame;
}
- } else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass & chan->nativeformats)) {
+ } else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass.codec & chan->nativeformats)) {
/* This frame is not one of the current native formats -- drop it on the floor */
char to[200];
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
- chan->name, ast_getformatname(f->subclass), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
+ chan->name, ast_getformatname(f->subclass.codec), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
@@ -3525,7 +3520,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
done:
if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
- chan->generator->digit(chan, f->subclass);
+ chan->generator->digit(chan, f->subclass.integer);
ast_channel_unlock(chan);
return f;
@@ -3767,7 +3762,7 @@ char *ast_recvtext(struct ast_channel *chan, int timeout)
f = ast_read(chan);
if (f == NULL)
break; /* no frame */
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP)
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP)
done = 1; /* force a break */
else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
@@ -3867,7 +3862,7 @@ int ast_prod(struct ast_channel *chan)
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
ast_debug(1, "Prodding channel '%s'\n", chan->name);
- a.subclass = chan->rawwriteformat;
+ a.subclass.codec = chan->rawwriteformat;
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
if (ast_write(chan, &a))
@@ -3929,13 +3924,13 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
* stop the generator */
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = ast_senddigit_end(chan, fr->subclass, fr->len);
+ res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
- } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_UNHOLD) {
+ } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
/* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
res = (chan->tech->indicate == NULL) ? 0 :
- chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen);
+ chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
}
res = 0; /* XXX explain, why 0 ? */
goto done;
@@ -3948,7 +3943,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
switch (fr->frametype) {
case AST_FRAME_CONTROL:
res = (chan->tech->indicate == NULL) ? 0 :
- chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen);
+ chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
break;
case AST_FRAME_DTMF_BEGIN:
if (chan->audiohooks) {
@@ -3957,10 +3952,10 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
if (old_frame != fr)
f = fr;
}
- send_dtmf_event(chan, "Sent", fr->subclass, "Yes", "No");
+ send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No");
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = ast_senddigit_begin(chan, fr->subclass);
+ res = ast_senddigit_begin(chan, fr->subclass.integer);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
@@ -3973,15 +3968,15 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
ast_frfree(new_frame);
}
}
- send_dtmf_event(chan, "Sent", fr->subclass, "No", "Yes");
+ send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes");
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = ast_senddigit_end(chan, fr->subclass, fr->len);
+ res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
case AST_FRAME_TEXT:
- if (fr->subclass == AST_FORMAT_T140) {
+ if (fr->subclass.integer == AST_FORMAT_T140) {
res = (chan->tech->write_text == NULL) ? 0 :
chan->tech->write_text(chan, fr);
} else {
@@ -3991,7 +3986,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
break;
case AST_FRAME_HTML:
res = (chan->tech->send_html == NULL) ? 0 :
- chan->tech->send_html(chan, fr->subclass, (char *) fr->data.ptr, fr->datalen);
+ chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
break;
case AST_FRAME_VIDEO:
/* XXX Handle translation of video codecs one day XXX */
@@ -4007,7 +4002,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
break; /*! \todo XXX should return 0 maybe ? */
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
- if (fr->subclass == chan->rawwriteformat)
+ if (fr->subclass.codec == chan->rawwriteformat)
f = fr;
else
f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
@@ -4145,10 +4140,10 @@ done:
return res;
}
-static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format,
+static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format,
struct ast_trans_pvt **trans, const int direction)
{
- int native, native_fmt = ast_best_codec(fmt);
+ format_t native, native_fmt = ast_best_codec(fmt);
int res;
char from[200], to[200];
@@ -4162,8 +4157,8 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
/* See if the underlying channel driver is capable of performing transcoding for us */
if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) {
- ast_debug(1, "Channel driver natively set channel %s to %s format %s (%d)\n", chan->name,
- direction ? "write" : "read", ast_getformatname(native_fmt), native_fmt);
+ ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name,
+ direction ? "write" : "read", ast_getformatname(native_fmt));
chan->nativeformats = *rawformat = *format = native_fmt;
if (*trans) {
ast_translator_free_path(*trans);
@@ -4215,13 +4210,13 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
return 0;
}
-int ast_set_read_format(struct ast_channel *chan, int fmt)
+int ast_set_read_format(struct ast_channel *chan, format_t fmt)
{
return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
&chan->readtrans, 0);
}
-int ast_set_write_format(struct ast_channel *chan, int fmt)
+int ast_set_write_format(struct ast_channel *chan, format_t fmt)
{
return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
&chan->writetrans, 1);
@@ -4263,7 +4258,7 @@ static void handle_cause(int cause, int *outstate)
}
}
-struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate)
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate)
{
char tmpchan[256];
struct ast_channel *new = NULL;
@@ -4339,7 +4334,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
return new;
}
-struct ast_channel *__ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
+struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
{
int dummy_outstate;
int cause = 0;
@@ -4411,15 +4406,15 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_RINGING: /* record but keep going */
- *outstate = f->subclass;
+ *outstate = f->subclass.integer;
break;
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
case AST_CONTROL_ANSWER:
- *outstate = f->subclass;
+ *outstate = f->subclass.integer;
timeout = 0; /* trick to force exit from the while() */
break;
@@ -4436,9 +4431,9 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s
break;
default:
- ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass);
+ ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
}
- last_subclass = f->subclass;
+ last_subclass = f->subclass.integer;
}
ast_frfree(f);
}
@@ -4478,21 +4473,21 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s
return chan;
}
-struct ast_channel *ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
+struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
{
return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL);
}
-struct ast_channel *ast_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct chanlist *chan;
struct ast_channel *c;
- int capabilities;
- int fmt;
+ format_t capabilities;
+ format_t fmt;
int res;
int foo;
- int videoformat = format & AST_FORMAT_VIDEO_MASK;
- int textformat = format & AST_FORMAT_TEXT_MASK;
+ format_t videoformat = format & AST_FORMAT_VIDEO_MASK;
+ format_t textformat = format & AST_FORMAT_TEXT_MASK;
if (!cause)
cause = &foo;
@@ -4515,7 +4510,10 @@ struct ast_channel *ast_request(const char *type, int format, const struct ast_c
*/
res = ast_translator_best_choice(&fmt, &capabilities);
if (res < 0) {
- ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format);
+ char tmp1[256], tmp2[256];
+ ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type,
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), format));
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
AST_RWLIST_UNLOCK(&backends);
return NULL;
@@ -4595,7 +4593,7 @@ int ast_transfer(struct ast_channel *chan, char *dest)
break;
}
- if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_TRANSFER) {
+ if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_TRANSFER) {
enum ast_control_transfer *message = fr->data.ptr;
if (*message == AST_TRANSFER_SUCCESS) {
@@ -4687,8 +4685,7 @@ int ast_channel_sendurl(struct ast_channel *chan, const char *url)
/*! \brief Set up translation from one channel to another */
static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
{
- int src;
- int dst;
+ format_t src, dst;
/* See if the channel driver can natively make these two channels compatible */
if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
@@ -4710,7 +4707,7 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
return 0;
if (ast_translator_best_choice(&dst, &src) < 0) {
- ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", from->name, src, to->name, dst);
+ ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name);
return -1;
}
@@ -4722,11 +4719,11 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
(ast_translate_path_steps(dst, src) != 1))
dst = AST_FORMAT_SLINEAR;
if (ast_set_read_format(from, dst) < 0) {
- ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", from->name, dst);
+ ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(dst));
return -1;
}
if (ast_set_write_format(to, dst) < 0) {
- ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", to->name, dst);
+ ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(dst));
return -1;
}
return 0;
@@ -5099,7 +5096,8 @@ static void report_new_callerid(const struct ast_channel *chan)
*/
int ast_do_masquerade(struct ast_channel *original)
{
- int x,i;
+ format_t x;
+ int i;
int res=0;
int origstate;
struct ast_frame *current;
@@ -5112,8 +5110,8 @@ int ast_do_masquerade(struct ast_channel *original)
} exchange;
struct ast_channel *clonechan;
struct ast_cdr *cdr;
- int rformat = original->readformat;
- int wformat = original->writeformat;
+ format_t rformat = original->readformat;
+ format_t wformat = original->writeformat;
char newn[AST_CHANNEL_NAME];
char orig[AST_CHANNEL_NAME];
char masqn[AST_CHANNEL_NAME];
@@ -5369,7 +5367,8 @@ int ast_do_masquerade(struct ast_channel *original)
ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
}
- ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+ ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name,
+ ast_getformatname(wformat), ast_getformatname(rformat));
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
@@ -5552,8 +5551,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
struct ast_channel *cs[3];
struct ast_frame *f;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
- int o0nativeformats;
- int o1nativeformats;
+ format_t o0nativeformats;
+ format_t o1nativeformats;
int watch_c0_dtmf;
int watch_c1_dtmf;
void *pvt0, *pvt1;
@@ -5660,20 +5659,20 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
int bridge_exit = 0;
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_REDIRECTING:
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
break;
case AST_CONTROL_CONNECTED_LINE:
if (ast_channel_connected_line_macro(who, other, f, other == c0, 1)) {
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
}
break;
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
if (jb_in_use) {
ast_jb_empty_and_reset(c0, c1);
}
@@ -5682,7 +5681,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*fo = f;
*rc = who;
bridge_exit = 1;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name);
break;
}
if (bridge_exit)
@@ -5839,8 +5838,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
struct ast_channel *who = NULL;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
int nativefailed=0;
- int o0nativeformats;
- int o1nativeformats;
+ format_t o0nativeformats;
+ format_t o1nativeformats;
long time_left_ms=0;
char caller_warning = 0;
char callee_warning = 0;
@@ -6138,7 +6137,7 @@ struct tonepair_state {
int v1_2;
int v2_2;
int v3_2;
- int origwfmt;
+ format_t origwfmt;
int pos;
int duration;
int modulate;
@@ -6218,7 +6217,7 @@ static int tonepair_generator(struct ast_channel *chan, void *data, int len, int
ts->data[x] = ts->v3_1 + ts->v3_2;
}
ts->f.frametype = AST_FRAME_VOICE;
- ts->f.subclass = AST_FORMAT_SLINEAR;
+ ts->f.subclass.codec = AST_FORMAT_SLINEAR;
ts->f.datalen = len;
ts->f.samples = samples;
ts->f.offset = AST_FRIENDLY_OFFSET;
@@ -6421,7 +6420,7 @@ static int silence_generator_generate(struct ast_channel *chan, void *data, int
short buf[samples];
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf,
.samples = samples,
.datalen = sizeof(buf),
diff --git a/main/dial.c b/main/dial.c
index 4c57cb12d..cd8a7af7a 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -390,7 +390,7 @@ static void set_state(struct ast_dial *dial, enum ast_dial_result state)
static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel, struct ast_frame *fr, struct ast_channel *chan)
{
if (fr->frametype == AST_FRAME_CONTROL) {
- switch (fr->subclass) {
+ switch (fr->subclass.integer) {
case AST_CONTROL_ANSWER:
ast_verb(3, "%s answered %s\n", channel->owner->name, chan->name);
AST_LIST_LOCK(&dial->channels);
@@ -474,7 +474,7 @@ static void handle_frame_ownerless(struct ast_dial *dial, struct ast_dial_channe
if (fr->frametype != AST_FRAME_CONTROL)
return;
- switch (fr->subclass) {
+ switch (fr->subclass.integer) {
case AST_CONTROL_ANSWER:
ast_verb(3, "%s answered\n", channel->owner->name);
AST_LIST_LOCK(&dial->channels);
diff --git a/main/dsp.c b/main/dsp.c
index 585403786..b3c87ddec 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1092,7 +1092,7 @@ int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf)
ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n");
return 0;
}
- if (inf->subclass != AST_FORMAT_SLINEAR) {
+ if (inf->subclass.codec != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n");
return 0;
}
@@ -1266,7 +1266,7 @@ int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
ast_log(LOG_WARNING, "Can't calculate silence on a non-voice frame\n");
return 0;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n");
return 0;
}
@@ -1284,7 +1284,7 @@ int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
ast_log(LOG_WARNING, "Can't calculate noise on a non-voice frame\n");
return 0;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only calculate noise on signed-linear frames :(\n");
return 0;
}
@@ -1315,12 +1315,13 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
odata = af->data.ptr;
len = af->datalen;
/* Make sure we have short data */
- switch (af->subclass) {
+ switch (af->subclass.codec) {
case AST_FORMAT_SLINEAR:
shortdata = af->data.ptr;
len = af->datalen / 2;
break;
case AST_FORMAT_ULAW:
+ case AST_FORMAT_TESTLAW:
shortdata = alloca(af->datalen * 2);
for (x = 0;x < len; x++) {
shortdata[x] = AST_MULAW(odata[x]);
@@ -1333,7 +1334,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
}
break;
default:
- ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass));
+ ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass.codec));
return af;
}
@@ -1355,7 +1356,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
chan->_softhangup |= AST_SOFTHANGUP_DEV;
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
- dsp->f.subclass = AST_CONTROL_BUSY;
+ dsp->f.subclass.integer = AST_CONTROL_BUSY;
ast_frfree(af);
ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
return ast_frisolate(&dsp->f);
@@ -1401,7 +1402,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
if (event) {
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = event;
- dsp->f.subclass = event_digit;
+ dsp->f.subclass.integer = event_digit;
outf = &dsp->f;
goto done;
}
@@ -1413,7 +1414,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_DTMF;
- dsp->f.subclass = fax_digit;
+ dsp->f.subclass.integer = fax_digit;
outf = &dsp->f;
goto done;
}
@@ -1429,7 +1430,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
case AST_CONTROL_HANGUP:
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
- dsp->f.subclass = res;
+ dsp->f.subclass.integer = res;
dsp->f.src = "dsp_progress";
if (chan)
ast_queue_frame(chan, &dsp->f);
@@ -1448,7 +1449,7 @@ done:
memset(shortdata + dsp->mute_data[x].start, 0, sizeof(int16_t) * (dsp->mute_data[x].end - dsp->mute_data[x].start));
}
- switch (af->subclass) {
+ switch (af->subclass.codec) {
case AST_FORMAT_SLINEAR:
break;
case AST_FORMAT_ULAW:
diff --git a/main/features.c b/main/features.c
index cfce3f1d7..fe79d4977 100644
--- a/main/features.c
+++ b/main/features.c
@@ -2483,30 +2483,30 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
}
if (f->frametype == AST_FRAME_CONTROL || f->frametype == AST_FRAME_DTMF || f->frametype == AST_FRAME_TEXT) {
- if (f->subclass == AST_CONTROL_RINGING) {
- state = f->subclass;
+ if (f->subclass.integer == AST_CONTROL_RINGING) {
+ state = f->subclass.integer;
ast_verb(3, "%s is ringing\n", chan->name);
ast_indicate(caller, AST_CONTROL_RINGING);
- } else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
- state = f->subclass;
+ } else if ((f->subclass.integer == AST_CONTROL_BUSY) || (f->subclass.integer == AST_CONTROL_CONGESTION)) {
+ state = f->subclass.integer;
ast_verb(3, "%s is busy\n", chan->name);
ast_indicate(caller, AST_CONTROL_BUSY);
ast_frfree(f);
f = NULL;
break;
- } else if (f->subclass == AST_CONTROL_ANSWER) {
+ } else if (f->subclass.integer == AST_CONTROL_ANSWER) {
/* This is what we are hoping for */
- state = f->subclass;
+ state = f->subclass.integer;
ast_frfree(f);
f = NULL;
ready=1;
break;
- } else if (f->subclass == AST_CONTROL_CONNECTED_LINE) {
+ } else if (f->subclass.integer == AST_CONTROL_CONNECTED_LINE) {
if (ast_channel_connected_line_macro(chan, caller, f, 1, 1)) {
ast_indicate_data(caller, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
}
- } else if (f->subclass != -1 && f->subclass != AST_CONTROL_PROGRESS) {
- ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass);
+ } else if (f->subclass.integer != -1 && f->subclass.integer != AST_CONTROL_PROGRESS) {
+ ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass.integer);
}
/* else who cares */
} else if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
@@ -2529,7 +2529,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
} else {
if (f->frametype == AST_FRAME_DTMF) {
- dialed_code[x++] = f->subclass;
+ dialed_code[x++] = f->subclass.integer;
dialed_code[x] = '\0';
if (strlen(dialed_code) == len) {
x = 0;
@@ -2941,19 +2941,19 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
}
if (!f || (f->frametype == AST_FRAME_CONTROL &&
- (f->subclass == AST_CONTROL_HANGUP || f->subclass == AST_CONTROL_BUSY ||
- f->subclass == AST_CONTROL_CONGESTION))) {
+ (f->subclass.integer == AST_CONTROL_HANGUP || f->subclass.integer == AST_CONTROL_BUSY ||
+ f->subclass.integer == AST_CONTROL_CONGESTION))) {
res = -1;
break;
}
/* many things should be sent to the 'other' channel */
other = (who == chan) ? peer : chan;
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_RINGING:
case AST_CONTROL_FLASH:
case -1:
- ast_indicate(other, f->subclass);
+ ast_indicate(other, f->subclass.integer);
break;
case AST_CONTROL_CONNECTED_LINE:
if (!ast_channel_connected_line_macro(who, other, f, who != chan, 1)) {
@@ -2962,7 +2962,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
/* The implied "else" falls through purposely */
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
break;
case AST_CONTROL_OPTION:
aoh = f->data.ptr;
@@ -2992,7 +2992,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
* not overflowing it.
* \todo XXX how do we guarantee the latter ?
*/
- featurecode[strlen(featurecode)] = f->subclass;
+ featurecode[strlen(featurecode)] = f->subclass.integer;
/* Get rid of the frame before we start doing "stuff" with the channels */
ast_frfree(f);
f = NULL;
@@ -3391,7 +3391,7 @@ int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds,
/* See if they need servicing */
f = ast_read(pu->chan);
/* Hangup? */
- if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
+ if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
if (f)
ast_frfree(f);
post_manager_event("ParkedCallGiveUp", pu);
diff --git a/main/file.c b/main/file.c
index 10764c67f..fce474ba5 100644
--- a/main/file.c
+++ b/main/file.c
@@ -128,7 +128,7 @@ int ast_stopstream(struct ast_channel *tmp)
ast_closestream(tmp->stream);
tmp->stream = NULL;
if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat))
- ast_log(LOG_WARNING, "Unable to restore format back to %d\n", tmp->oldwriteformat);
+ ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(tmp->oldwriteformat));
}
/* Stop the video stream too */
if (tmp->vstream != NULL) {
@@ -149,7 +149,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
if (fs->fmt->format & AST_FORMAT_AUDIO_MASK) {
/* This is the audio portion. Call the video one... */
if (!fs->vfs && fs->filename) {
- const char *type = ast_getformatname(f->subclass & ~0x1);
+ const char *type = ast_getformatname(f->subclass.codec & ~0x1);
fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
ast_debug(1, "Opened video output file\n");
}
@@ -165,7 +165,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
ast_log(LOG_WARNING, "Tried to write non-voice frame\n");
return -1;
}
- if (((fs->fmt->format | alt) & f->subclass) == f->subclass) {
+ if (((fs->fmt->format | alt) & f->subclass.codec) == f->subclass.codec) {
res = fs->fmt->write(fs, f);
if (res < 0)
ast_log(LOG_WARNING, "Natural write failed\n");
@@ -174,18 +174,18 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
} else {
/* XXX If they try to send us a type of frame that isn't the normal frame, and isn't
the one we've setup a translator for, we do the "wrong thing" XXX */
- if (fs->trans && f->subclass != fs->lastwriteformat) {
+ if (fs->trans && f->subclass.codec != fs->lastwriteformat) {
ast_translator_free_path(fs->trans);
fs->trans = NULL;
}
if (!fs->trans)
- fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass);
+ fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass.codec);
if (!fs->trans)
ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n",
- fs->fmt->name, ast_getformatname(f->subclass));
+ fs->fmt->name, ast_getformatname(f->subclass.codec));
else {
struct ast_frame *trf;
- fs->lastwriteformat = f->subclass;
+ fs->lastwriteformat = f->subclass.codec;
/* Get the translated frame but don't consume the original in case they're using it on another stream */
if ((trf = ast_translate(fs->trans, f, 0))) {
struct ast_frame *cur;
@@ -660,7 +660,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
/* As above, but for video. But here we don't have translators
* so we must enforce a format.
*/
- unsigned int format;
+ format_t format;
char *buf;
int buflen;
@@ -1233,15 +1233,15 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
switch (fr->frametype) {
case AST_FRAME_DTMF_END:
if (context) {
- const char exten[2] = { fr->subclass, '\0' };
+ const char exten[2] = { fr->subclass.integer, '\0' };
if (ast_exists_extension(c, context, exten, 1, c->cid.cid_num)) {
- res = fr->subclass;
+ res = fr->subclass.integer;
ast_frfree(fr);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
}
} else {
- res = fr->subclass;
+ res = fr->subclass.integer;
if (strchr(forward, res)) {
int eoftest;
ast_stream_fastforward(c->stream, skip_ms);
@@ -1261,7 +1261,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
}
break;
case AST_FRAME_CONTROL:
- switch (fr->subclass) {
+ switch (fr->subclass.integer) {
case AST_CONTROL_HANGUP:
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
@@ -1278,7 +1278,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
/* Unimportant */
break;
default:
- ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass);
+ ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass.integer);
}
break;
case AST_FRAME_VOICE:
diff --git a/main/frame.c b/main/frame.c
index f24c7a4dc..a11644577 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -80,7 +80,7 @@ enum frame_type {
struct ast_smoother {
int size;
- int format;
+ format_t format;
int flags;
float samplesperbyte;
unsigned int opt_needs_swap:1;
@@ -119,6 +119,7 @@ static const struct ast_format_list AST_FORMAT_LIST[] = {
{ AST_FORMAT_T140, "t140", 0, "Passthrough T.140 Realtime Text" }, /*!< Passthrough support for T.140 Realtime Text */
{ AST_FORMAT_SIREN7, "siren7", 16000, "ITU G.722.1 (Siren7, licensed from Polycom)", 80, 20, 80, 20, 20 }, /*!< Binary commercial distribution */
{ AST_FORMAT_SIREN14, "siren14", 32000, "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)", 120, 20, 80, 20, 20 }, /*!< Binary commercial distribution */
+ { AST_FORMAT_TESTLAW, "testlaw", 8000, "G.711 test-law", 80, 10, 150, 10, 20 }, /*!< codec_ulaw.c */
};
struct ast_frame ast_null_frame = { AST_FRAME_NULL, };
@@ -205,10 +206,11 @@ int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap)
return -1;
}
if (!s->format) {
- s->format = f->subclass;
+ s->format = f->subclass.codec;
s->samplesperbyte = (float)f->samples / (float)f->datalen;
- } else if (s->format != f->subclass) {
- ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass);
+ } else if (s->format != f->subclass.codec) {
+ ast_log(LOG_WARNING, "Smoother was working on %s format frames, now trying to feed %s?\n",
+ ast_getformatname(s->format), ast_getformatname(f->subclass.codec));
return -1;
}
if (s->len + f->datalen > SMOOTHER_SIZE) {
@@ -259,7 +261,7 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s)
len = s->len;
/* Make frame */
s->f.frametype = AST_FRAME_VOICE;
- s->f.subclass = s->format;
+ s->f.subclass.codec = s->format;
s->f.data.ptr = s->framedata + AST_FRIENDLY_OFFSET;
s->f.offset = AST_FRIENDLY_OFFSET;
s->f.datalen = len;
@@ -404,7 +406,7 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr)
return NULL;
}
out->frametype = fr->frametype;
- out->subclass = fr->subclass;
+ out->subclass.codec = fr->subclass.codec;
out->datalen = fr->datalen;
out->samples = fr->samples;
out->offset = fr->offset;
@@ -506,7 +508,7 @@ struct ast_frame *ast_frdup(const struct ast_frame *f)
}
out->frametype = f->frametype;
- out->subclass = f->subclass;
+ out->subclass.codec = f->subclass.codec;
out->datalen = f->datalen;
out->samples = f->samples;
out->delivery = f->delivery;
@@ -557,7 +559,7 @@ const struct ast_format_list *ast_get_format_list(size_t *size)
return AST_FORMAT_LIST;
}
-char* ast_getformatname(int format)
+char* ast_getformatname(format_t format)
{
int x;
char *ret = "unknown";
@@ -570,7 +572,7 @@ char* ast_getformatname(int format)
return ret;
}
-char *ast_getformatname_multiple(char *buf, size_t size, int format)
+char *ast_getformatname_multiple(char *buf, size_t size, format_t format)
{
int x;
unsigned len;
@@ -578,14 +580,14 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format)
if (!size)
return buf;
- snprintf(end, size, "0x%x (", format);
+ snprintf(end, size, "0x%llx (", (unsigned long long) format);
len = strlen(end);
end += len;
size -= len;
start = end;
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits & format) {
- snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name);
+ snprintf(end, size, "%s|", AST_FORMAT_LIST[x].name);
len = strlen(end);
end += len;
size -= len;
@@ -594,7 +596,7 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format)
if (start == end)
ast_copy_string(start, "nothing)", size);
else if (size > 1)
- *(end -1) = ')';
+ *(end - 1) = ')';
return buf;
}
@@ -620,9 +622,10 @@ static const char *ast_expand_codec_alias(const char *in)
return in;
}
-int ast_getformatbyname(const char *name)
+format_t ast_getformatbyname(const char *name)
{
- int x, all, format = 0;
+ int x, all;
+ format_t format = 0;
all = strcasecmp(name, "all") ? 0 : 1;
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
@@ -638,7 +641,7 @@ int ast_getformatbyname(const char *name)
return format;
}
-char *ast_codec2str(int codec)
+char *ast_codec2str(format_t codec)
{
int x;
char *ret = "unknown";
@@ -676,27 +679,30 @@ static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
ast_cli(a->fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC");
ast_cli(a->fd, "--------------------------------------------------------------------------------\n");
- if ((a->argc == 3) || (!strcasecmp(a->argv[3],"audio"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], "audio"))) {
found = 1;
- for (i=0;i<13;i++) {
- snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(a->fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ for (i = 0; i < 48; i++) {
+ if (!((1LL << i) & AST_FORMAT_AUDIO_MASK)) {
+ continue;
+ }
+ snprintf(hex, sizeof(hex), "(0x%Lx)", 1LL << i);
+ ast_cli(a->fd, "%11Lu (1 << %2d) %10s audio %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i));
}
}
- if ((a->argc == 3) || (!strcasecmp(a->argv[3],"image"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], "image"))) {
found = 1;
- for (i=16;i<18;i++) {
- snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(a->fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ for (i = 16; i < 18; i++) {
+ snprintf(hex, sizeof(hex), "(0x%Lx)", 1LL << i);
+ ast_cli(a->fd, "%11Lu (1 << %2d) %10s image %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i));
}
}
- if ((a->argc == 3) || (!strcasecmp(a->argv[3],"video"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], "video"))) {
found = 1;
- for (i=18;i<22;i++) {
- snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(a->fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ for (i = 18; i < 63; i++) {
+ snprintf(hex, sizeof(hex), "(0x%Lx)", 1LL << i);
+ ast_cli(a->fd, "%11Lu (1 << %2d) %10s video %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i));
}
}
@@ -708,12 +714,13 @@ static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args *
static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- int codec, i, found=0;
+ format_t codec;
+ int i, found = 0;
switch (cmd) {
case CLI_INIT:
e->command = "core show codec";
- e->usage =
+ e->usage =
"Usage: core show codec <number>\n"
" Displays codec mapping\n";
return NULL;
@@ -724,17 +731,17 @@ static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args
if (a->argc != 4)
return CLI_SHOWUSAGE;
- if (sscanf(a->argv[3], "%30d", &codec) != 1)
+ if (sscanf(a->argv[3], "%30Ld", &codec) != 1)
return CLI_SHOWUSAGE;
- for (i = 0; i < 32; i++)
- if (codec & (1 << i)) {
+ for (i = 0; i < 63; i++)
+ if (codec & (1LL << i)) {
found = 1;
- ast_cli(a->fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
+ ast_cli(a->fd, "%11Lu (1 << %2d) %s\n", 1LL << i, i, ast_codec2str(1LL << i));
}
if (!found)
- ast_cli(a->fd, "Codec %d not found\n", codec);
+ ast_cli(a->fd, "Codec %Ld not found\n", codec);
return CLI_SUCCESS;
}
@@ -772,17 +779,17 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
switch(f->frametype) {
case AST_FRAME_DTMF_BEGIN:
strcpy(ftype, "DTMF Begin");
- subclass[0] = f->subclass;
+ subclass[0] = f->subclass.integer;
subclass[1] = '\0';
break;
case AST_FRAME_DTMF_END:
strcpy(ftype, "DTMF End");
- subclass[0] = f->subclass;
+ subclass[0] = f->subclass.integer;
subclass[1] = '\0';
break;
case AST_FRAME_CONTROL:
strcpy(ftype, "Control");
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
strcpy(subclass, "Hangup");
break;
@@ -851,7 +858,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
strcpy(subclass, "Stop generators");
break;
default:
- snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass);
+ snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass.integer);
}
break;
case AST_FRAME_NULL:
@@ -861,7 +868,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
case AST_FRAME_IAX:
/* Should never happen */
strcpy(ftype, "IAX Specific");
- snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass);
+ snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass.integer);
break;
case AST_FRAME_TEXT:
strcpy(ftype, "Text");
@@ -870,11 +877,11 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
break;
case AST_FRAME_IMAGE:
strcpy(ftype, "Image");
- snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass));
+ snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass.codec));
break;
case AST_FRAME_HTML:
strcpy(ftype, "HTML");
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_HTML_URL:
strcpy(subclass, "URL");
ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo));
@@ -905,13 +912,13 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
strcpy(subclass, "Link Reject");
break;
default:
- snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass);
+ snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass.integer);
break;
}
break;
case AST_FRAME_MODEM:
strcpy(ftype, "Modem");
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_MODEM_T38:
strcpy(subclass, "T.38");
break;
@@ -919,7 +926,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
strcpy(subclass, "V.150");
break;
default:
- snprintf(subclass, sizeof(subclass), "Unknown MODEM frame '%d'\n", f->subclass);
+ snprintf(subclass, sizeof(subclass), "Unknown MODEM frame '%d'\n", f->subclass.integer);
break;
}
break;
@@ -932,7 +939,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
f->frametype,
term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass,
+ f->subclass.integer,
term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
else
@@ -941,7 +948,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
f->frametype,
term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass,
+ f->subclass.integer,
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
}
@@ -970,11 +977,11 @@ void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size,
} else {
to = pref->order;
from = buf;
- mem = 32;
+ mem = sizeof(format_t) * 8;
}
memset(to, 0, mem);
- for (x = 0; x < 32 ; x++) {
+ for (x = 0; x < sizeof(format_t) * 8; x++) {
if (!from[x])
break;
to[x] = right ? (from[x] + differential) : (from[x] - differential);
@@ -983,15 +990,16 @@ void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size,
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size)
{
- int x, codec;
+ int x;
+ format_t codec;
size_t total_len, slen;
char *formatname;
- memset(buf,0,size);
+ memset(buf, 0, size);
total_len = size;
buf[0] = '(';
total_len--;
- for(x = 0; x < 32 ; x++) {
+ for (x = 0; x < sizeof(format_t) * 8; x++) {
if (total_len <= 0)
break;
if (!(codec = ast_codec_pref_index(pref,x)))
@@ -1003,7 +1011,7 @@ int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size)
strncat(buf, formatname, total_len - 1); /* safe */
total_len -= slen;
}
- if (total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) {
+ if (total_len && x < sizeof(format_t) * 8 - 1 && ast_codec_pref_index(pref, x + 1)) {
strncat(buf, "|", total_len - 1); /* safe */
total_len--;
}
@@ -1016,7 +1024,7 @@ int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size)
return size - total_len;
}
-int ast_codec_pref_index(struct ast_codec_pref *pref, int idx)
+format_t ast_codec_pref_index(struct ast_codec_pref *pref, int idx)
{
int slot = 0;
@@ -1028,7 +1036,7 @@ int ast_codec_pref_index(struct ast_codec_pref *pref, int idx)
}
/*! \brief Remove codec from pref list */
-void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
+void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format)
{
struct ast_codec_pref oldorder;
int x, y = 0;
@@ -1051,11 +1059,10 @@ void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
pref->framing[y++] = size;
}
}
-
}
/*! \brief Append codec to list */
-int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
+int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format)
{
int x, newindex = 0;
@@ -1081,7 +1088,7 @@ int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
}
/*! \brief Prepend codec to list */
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing)
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing)
{
int x, newindex = 0;
@@ -1097,7 +1104,7 @@ void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if
return;
/* Now find any existing occurrence, or the end */
- for (x = 0; x < 32; x++) {
+ for (x = 0; x < sizeof(format_t) * 8; x++) {
if (!pref->order[x] || pref->order[x] == newindex)
break;
}
@@ -1118,7 +1125,7 @@ void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if
}
/*! \brief Set packet size for codec */
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems)
{
int x, idx = -1;
@@ -1156,7 +1163,7 @@ int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
}
/*! \brief Get packet size for codec */
-struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format)
+struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format)
{
int x, idx = -1, framems = 0;
struct ast_format_list fmt = { 0, };
@@ -1195,9 +1202,10 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int f
}
/*! \brief Pick a codec */
-int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
+format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best)
{
- int x, ret = 0, slot;
+ int x, slot;
+ format_t ret = 0;
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
slot = pref->order[x];
@@ -1217,11 +1225,11 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
return find_best ? ast_best_codec(formats) : 0;
}
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing)
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing)
{
- int errors = 0;
+ int errors = 0, framems = 0;
char *parse = NULL, *this = NULL, *psize = NULL;
- int format = 0, framems = 0;
+ format_t format = 0;
parse = ast_strdupa(list);
while ((this = strsep(&parse, ","))) {
@@ -1418,8 +1426,9 @@ static int speex_samples(unsigned char *data, int len)
int ast_codec_get_samples(struct ast_frame *f)
{
int samples = 0;
+ char tmp[64];
- switch(f->subclass) {
+ switch (f->subclass.codec) {
case AST_FORMAT_SPEEX:
samples = speex_samples(f->data.ptr, f->datalen);
break;
@@ -1446,6 +1455,7 @@ int ast_codec_get_samples(struct ast_frame *f)
break;
case AST_FORMAT_ULAW:
case AST_FORMAT_ALAW:
+ case AST_FORMAT_TESTLAW:
samples = f->datalen;
break;
case AST_FORMAT_G722:
@@ -1463,12 +1473,12 @@ int ast_codec_get_samples(struct ast_frame *f)
samples = (int) f->datalen * ((float) 32000 / 6000);
break;
default:
- ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(f->subclass));
+ ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), f->subclass.codec));
}
return samples;
}
-int ast_codec_get_len(int format, int samples)
+int ast_codec_get_len(format_t format, int samples)
{
int len = 0;
@@ -1492,6 +1502,7 @@ int ast_codec_get_len(int format, int samples)
break;
case AST_FORMAT_ULAW:
case AST_FORMAT_ALAW:
+ case AST_FORMAT_TESTLAW:
len = samples;
break;
case AST_FORMAT_G722:
@@ -1521,7 +1532,7 @@ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
short *fdata = f->data.ptr;
short adjust_value = abs(adjustment);
- if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR))
+ if ((f->frametype != AST_FRAME_VOICE) || (f->subclass.codec != AST_FORMAT_SLINEAR))
return -1;
if (!adjustment)
@@ -1543,10 +1554,10 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2)
int count;
short *data1, *data2;
- if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass != AST_FORMAT_SLINEAR))
+ if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass.codec != AST_FORMAT_SLINEAR))
return -1;
- if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass != AST_FORMAT_SLINEAR))
+ if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass.codec != AST_FORMAT_SLINEAR))
return -1;
if (f1->samples != f2->samples)
diff --git a/main/indications.c b/main/indications.c
index b658e3f51..78010e0e7 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -209,7 +209,7 @@ static int playtones_generator(struct ast_channel *chan, void *data, int len, in
}
ps->f.frametype = AST_FRAME_VOICE;
- ps->f.subclass = AST_FORMAT_SLINEAR;
+ ps->f.subclass.codec = AST_FORMAT_SLINEAR;
ps->f.datalen = len;
ps->f.samples = samples;
ps->f.offset = AST_FRIENDLY_OFFSET;
diff --git a/main/manager.c b/main/manager.c
index e618a2fef..b2a21bd87 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3162,12 +3162,12 @@ static int action_atxfer(struct mansession *s, const struct message *m)
}
for (feature_code = atxfer_feature->exten; feature_code && *feature_code; ++feature_code) {
- struct ast_frame f = { AST_FRAME_DTMF, *feature_code };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code };
ast_queue_frame(chan, &f);
}
for (feature_code = (char *)exten; feature_code && *feature_code; ++feature_code) {
- struct ast_frame f = { AST_FRAME_DTMF, *feature_code };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code };
ast_queue_frame(chan, &f);
}
@@ -3274,7 +3274,7 @@ struct fast_originate_helper {
/*! data can contain a channel name, extension number, username, password, etc. */
char data[512];
int timeout;
- int format; /*!< Codecs used for a call */
+ format_t format; /*!< Codecs used for a call */
char app[AST_MAX_APP];
char appdata[AST_MAX_EXTENSION];
char cid_name[AST_MAX_EXTENSION];
@@ -3359,7 +3359,7 @@ static int action_originate(struct mansession *s, const struct message *m)
int reason = 0;
char tmp[256];
char tmp2[256];
- int format = AST_FORMAT_SLINEAR;
+ format_t format = AST_FORMAT_SLINEAR;
pthread_t th;
if (ast_strlen_zero(name)) {
diff --git a/main/pbx.c b/main/pbx.c
index 6125b1758..ed852956a 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -8155,8 +8155,8 @@ static void *async_wait(void *data)
if (!f)
break;
if (f->frametype == AST_FRAME_CONTROL) {
- if ((f->subclass == AST_CONTROL_BUSY) ||
- (f->subclass == AST_CONTROL_CONGESTION) ) {
+ if ((f->subclass.integer == AST_CONTROL_BUSY) ||
+ (f->subclass.integer == AST_CONTROL_CONGESTION) ) {
ast_frfree(f);
break;
}
@@ -8224,7 +8224,7 @@ static int ast_pbx_outgoing_cdr_failed(void)
return 0; /* success */
}
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
{
struct ast_channel *chan;
struct async_stat *as;
@@ -8390,7 +8390,7 @@ static void *ast_pbx_run_app(void *data)
return NULL;
}
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
+int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
{
struct ast_channel *chan;
struct app_tmp *tmp;
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 9818ea584..5a8e5090b 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -601,7 +601,7 @@ struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs
return result;
}
-void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astformats, int *nonastformats)
+void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats)
{
int i;
@@ -619,7 +619,7 @@ void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astforma
}
}
-int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const int code)
+int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
{
int i;
@@ -638,7 +638,7 @@ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asteris
return -1;
}
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int code, enum ast_rtp_options options)
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options)
{
int i;
@@ -655,7 +655,7 @@ const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int co
return "";
}
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code)
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code)
{
unsigned int i;
@@ -668,15 +668,16 @@ unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code)
return 0;
}
-char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const int capability, const int asterisk_format, enum ast_rtp_options options)
+char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options)
{
- int format, found = 0;
+ format_t format;
+ int found = 0;
if (!buf) {
return NULL;
}
- ast_str_append(&buf, 0, "0x%x (", capability);
+ ast_str_append(&buf, 0, "0x%llx (", (unsigned long long) capability);
for (format = 1; format < AST_RTP_MAX; format <<= 1) {
if (capability & format) {
@@ -851,13 +852,13 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
res = AST_BRIDGE_COMPLETE;
break;
} else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) {
- if ((fr->subclass == AST_CONTROL_HOLD) ||
- (fr->subclass == AST_CONTROL_UNHOLD) ||
- (fr->subclass == AST_CONTROL_VIDUPDATE) ||
- (fr->subclass == AST_CONTROL_SRCUPDATE) ||
- (fr->subclass == AST_CONTROL_T38_PARAMETERS)) {
+ if ((fr->subclass.integer == AST_CONTROL_HOLD) ||
+ (fr->subclass.integer == AST_CONTROL_UNHOLD) ||
+ (fr->subclass.integer == AST_CONTROL_VIDUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_SRCUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS)) {
/* If we are going on hold, then break callback mode and P2P bridging */
- if (fr->subclass == AST_CONTROL_HOLD) {
+ if (fr->subclass.integer == AST_CONTROL_HOLD) {
if (instance0->engine->local_bridge) {
instance0->engine->local_bridge(instance0, NULL);
}
@@ -866,7 +867,7 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
}
instance0->bridged = NULL;
instance1->bridged = NULL;
- } else if (fr->subclass == AST_CONTROL_UNHOLD) {
+ } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) {
if (instance0->engine->local_bridge) {
instance0->engine->local_bridge(instance0, instance1);
}
@@ -876,12 +877,12 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
instance0->bridged = instance1;
instance1->bridged = instance0;
}
- ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen);
+ ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen);
ast_frfree(fr);
} else {
*fo = fr;
*rc = who;
- ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
+ ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name);
res = AST_BRIDGE_COMPLETE;
break;
}
@@ -923,12 +924,12 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct ast_channel *c1, struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1,
struct ast_rtp_instance *vinstance0, struct ast_rtp_instance *vinstance1, struct ast_rtp_instance *tinstance0,
- struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, int codec0, int codec1, int timeoutms,
+ struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, format_t codec0, format_t codec1, int timeoutms,
int flags, struct ast_frame **fo, struct ast_channel **rc, void *pvt0, void *pvt1)
{
enum ast_bridge_result res = AST_BRIDGE_FAILED;
struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, };
- int oldcodec0 = codec0, oldcodec1 = codec1;
+ format_t oldcodec0 = codec0, oldcodec1 = codec1;
struct sockaddr_in ac1 = {0,}, vac1 = {0,}, tac1 = {0,}, ac0 = {0,}, vac0 = {0,}, tac0 = {0,};
struct sockaddr_in t1 = {0,}, vt1 = {0,}, tt1 = {0,}, t0 = {0,}, vt0 = {0,}, tt0 = {0,};
struct ast_frame *fr = NULL;
@@ -1009,18 +1010,18 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct
(vinstance1 && inaddrcmp(&vt1, &vac1)) ||
(tinstance1 && inaddrcmp(&tt1, &tac1)) ||
(codec1 != oldcodec1)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
- c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1);
- ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n",
- c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1);
- ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %d)\n",
- c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), codec1);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), oldcodec1);
+ ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n",
+ c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), ast_getformatname(codec1));
+ ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %s)\n",
+ c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), ast_getformatname(codec1));
+ ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %s)\n",
+ c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), ast_getformatname(codec1));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), ast_getformatname(oldcodec1));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), ast_getformatname(oldcodec1));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), ast_getformatname(oldcodec1));
if (glue0->update_peer(c0, t1.sin_addr.s_addr ? instance1 : NULL, vt1.sin_addr.s_addr ? vinstance1 : NULL, tt1.sin_addr.s_addr ? tinstance1 : NULL, codec1, 0)) {
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
}
@@ -1033,10 +1034,10 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct
(vinstance0 && inaddrcmp(&vt0, &vac0)) ||
(tinstance0 && inaddrcmp(&tt0, &tac0)) ||
(codec0 != oldcodec0)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
- c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
+ ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n",
+ c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), ast_getformatname(codec0));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), ast_getformatname(oldcodec0));
if (glue1->update_peer(c1, t0.sin_addr.s_addr ? instance0 : NULL, vt0.sin_addr.s_addr ? vinstance0 : NULL, tt0.sin_addr.s_addr ? tinstance0 : NULL, codec0, 0)) {
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
}
@@ -1070,19 +1071,19 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct
res = AST_BRIDGE_COMPLETE;
break;
} else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) {
- if ((fr->subclass == AST_CONTROL_HOLD) ||
- (fr->subclass == AST_CONTROL_UNHOLD) ||
- (fr->subclass == AST_CONTROL_VIDUPDATE) ||
- (fr->subclass == AST_CONTROL_SRCUPDATE) ||
- (fr->subclass == AST_CONTROL_T38_PARAMETERS)) {
- if (fr->subclass == AST_CONTROL_HOLD) {
+ if ((fr->subclass.integer == AST_CONTROL_HOLD) ||
+ (fr->subclass.integer == AST_CONTROL_UNHOLD) ||
+ (fr->subclass.integer == AST_CONTROL_VIDUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_SRCUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS)) {
+ if (fr->subclass.integer == AST_CONTROL_HOLD) {
/* If we someone went on hold we want the other side to reinvite back to us */
if (who == c0) {
glue1->update_peer(c1, NULL, NULL, NULL, 0, 0);
} else {
glue0->update_peer(c0, NULL, NULL, NULL, 0, 0);
}
- } else if (fr->subclass == AST_CONTROL_UNHOLD) {
+ } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) {
/* If they went off hold they should go back to being direct */
if (who == c0) {
glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0);
@@ -1102,12 +1103,12 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct
if (glue1->get_codec && c1->tech_pvt) {
oldcodec1 = codec1 = glue1->get_codec(c1);
}
- ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen);
+ ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen);
ast_frfree(fr);
} else {
*fo = fr;
*rc = who;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name);
return AST_BRIDGE_COMPLETE;
}
} else {
@@ -1164,7 +1165,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_bridge_result res = AST_BRIDGE_FAILED;
- int codec0 = 0, codec1 = 0;
+ format_t codec0 = 0, codec1 = 0;
int unlock_chans = 1;
/* Lock both channels so we can look for the glue that binds them together */
@@ -1229,7 +1230,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
codec0 = glue0->get_codec ? glue0->get_codec(c0) : 0;
codec1 = glue1->get_codec ? glue1->get_codec(c1) : 0;
if (codec0 && codec1 && !(codec0 & codec1)) {
- ast_debug(1, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1);
+ ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n", ast_getformatname(codec0), ast_getformatname(codec1));
res = AST_BRIDGE_FAILED_NOWARN;
goto done;
}
@@ -1286,7 +1287,7 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc
struct ast_rtp_glue *glue0, *glue1;
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
- int codec0 = 0, codec1 = 0;
+ format_t codec0 = 0, codec1 = 0;
int res = 0;
/* Lock both channels so we can look for the glue that binds them together */
@@ -1370,7 +1371,7 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1
struct ast_rtp_glue *glue0, *glue1;
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
- int codec0 = 0, codec1 = 0;
+ format_t codec0 = 0, codec1 = 0;
int res = 0;
/* If there is no second channel just immediately bail out, we are of no use in that scenario */
@@ -1538,12 +1539,12 @@ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_in
}
}
-int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, int format)
+int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format)
{
return instance->engine->set_read_format ? instance->engine->set_read_format(instance, format) : -1;
}
-int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, int format)
+int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format)
{
return instance->engine->set_write_format ? instance->engine->set_write_format(instance, format) : -1;
}
@@ -1584,9 +1585,9 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
return res;
}
-int ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk)
+format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk)
{
- int formats;
+ format_t formats;
if (instance->engine->available_formats && (formats = instance->engine->available_formats(instance, to_endpoint, to_asterisk))) {
return formats;
diff --git a/main/slinfactory.c b/main/slinfactory.c
index 8f004da8d..4da443af5 100644
--- a/main/slinfactory.c
+++ b/main/slinfactory.c
@@ -85,19 +85,19 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
return 0;
}
- if (f->subclass != sf->output_format) {
- if (sf->trans && f->subclass != sf->format) {
+ if (f->subclass.codec != sf->output_format) {
+ if (sf->trans && f->subclass.codec != sf->format) {
ast_translator_free_path(sf->trans);
sf->trans = NULL;
}
if (!sf->trans) {
- if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass))) {
- ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass),
+ if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass.codec))) {
+ ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass.codec),
ast_getformatname(sf->output_format));
return 0;
}
- sf->format = f->subclass;
+ sf->format = f->subclass.codec;
}
if (!(begin_frame = ast_translate(sf->trans, f, 0))) {
diff --git a/main/strcompat.c b/main/strcompat.c
index 7f9d2813b..156809003 100644
--- a/main/strcompat.c
+++ b/main/strcompat.c
@@ -334,3 +334,55 @@ int getloadavg(double *list, int nelem)
#endif /* linux */
#endif /* !HAVE_GETLOADAVG */
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return net64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ union {
+ unsigned char c[8];
+ uint64_t u;
+ } number;
+ number.u = net64;
+ return
+ (((uint64_t) number.c[0]) << 0) |
+ (((uint64_t) number.c[1]) << 8) |
+ (((uint64_t) number.c[2]) << 16) |
+ (((uint64_t) number.c[3]) << 24) |
+ (((uint64_t) number.c[4]) << 32) |
+ (((uint64_t) number.c[5]) << 40) |
+ (((uint64_t) number.c[6]) << 48) |
+ (((uint64_t) number.c[7]) << 56);
+#else
+ #error "Unknown byte order"
+#endif
+}
+#endif
+
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return host64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ union {
+ unsigned char c[8];
+ uint64_t u;
+ } number;
+ number.u = host64;
+ return
+ (((uint64_t) number.c[0]) << 0) |
+ (((uint64_t) number.c[1]) << 8) |
+ (((uint64_t) number.c[2]) << 16) |
+ (((uint64_t) number.c[3]) << 24) |
+ (((uint64_t) number.c[4]) << 32) |
+ (((uint64_t) number.c[5]) << 40) |
+ (((uint64_t) number.c[6]) << 48) |
+ (((uint64_t) number.c[7]) << 56);
+#else
+ #error "Unknown byte order"
+#endif
+}
+#endif
+
diff --git a/main/translate.c b/main/translate.c
index a4a915291..fbe6e5852 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -70,14 +70,14 @@ static struct translator_path tr_matrix[MAX_FORMAT][MAX_FORMAT];
*/
/*! \brief returns the index of the lowest bit set */
-static force_inline int powerof(unsigned int d)
+static force_inline int powerof(format_t d)
{
- int x = ffs(d);
+ int x = ffsll(d);
if (x)
return x - 1;
- ast_log(LOG_WARNING, "No bits set? %d\n", d);
+ ast_log(LOG_WARNING, "No bits set? %llu\n", (unsigned long long) d);
return -1;
}
@@ -221,7 +221,7 @@ struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt,
}
f->frametype = AST_FRAME_VOICE;
- f->subclass = 1 << (pvt->t->dstfmt);
+ f->subclass.codec = 1LL << (pvt->t->dstfmt);
f->mallocd = 0;
f->offset = AST_FRIENDLY_OFFSET;
f->src = pvt->t->name;
@@ -247,7 +247,7 @@ void ast_translator_free_path(struct ast_trans_pvt *p)
}
/*! \brief Build a chain of translators based upon the given source and dest formats */
-struct ast_trans_pvt *ast_translator_build_path(int dest, int source)
+struct ast_trans_pvt *ast_translator_build_path(format_t dest, format_t source)
{
struct ast_trans_pvt *head = NULL, *tail = NULL;
@@ -271,7 +271,8 @@ struct ast_trans_pvt *ast_translator_build_path(int dest, int source)
return NULL;
}
if (!(cur = newpvt(t))) {
- ast_log(LOG_WARNING, "Failed to build translator step from %d to %d\n", source, dest);
+ ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n",
+ ast_getformatname(source), ast_getformatname(dest));
if (head)
ast_translator_free_path(head);
AST_RWLIST_UNLOCK(&translators);
@@ -327,7 +328,7 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f,
path->nextout = f->delivery;
}
/* Predict next incoming sample */
- path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass)));
+ path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass.codec)));
}
delivery = f->delivery;
for ( ; out && p ; p = p->next) {
@@ -351,7 +352,7 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f,
/* Predict next outgoing timestamp from samples in this
frame. */
- path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass)));
+ path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass.codec)));
} else {
out->delivery = ast_tv(0, 0);
ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);
@@ -492,7 +493,7 @@ static void rebuild_matrix(int samples)
tr_matrix[x][z].cost = newcost;
tr_matrix[x][z].multistep = 1;
ast_debug(3, "Discovered %d cost path from %s to %s, via %s\n", tr_matrix[x][z].cost,
- ast_getformatname(1 << x), ast_getformatname(1 << z), ast_getformatname(1 << y));
+ ast_getformatname(1LL << x), ast_getformatname(1LL << z), ast_getformatname(1LL << y));
changed++;
}
}
@@ -550,7 +551,7 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd,
ast_cli(a->fd, " Source Format (Rows) Destination Format (Columns)\n\n");
/* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */
for (x = 0; x < SHOW_TRANS; x++) {
- curlen = strlen(ast_getformatname(1 << (x)));
+ curlen = strlen(ast_getformatname(1LL << (x)));
if (curlen > longest)
longest = curlen;
for (y = 0; y < SHOW_TRANS; y++) {
@@ -562,15 +563,15 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd,
for (x = -1; x < SHOW_TRANS; x++) {
struct ast_str *out = ast_str_alloca(125);
/*Go ahead and move to next iteration if dealing with an unknown codec*/
- if(x >= 0 && !strcmp(ast_getformatname(1 << (x)), "unknown"))
+ if(x >= 0 && !strcmp(ast_getformatname(1LL << (x)), "unknown"))
continue;
ast_str_set(&out, -1, " ");
for (y = -1; y < SHOW_TRANS; y++) {
/*Go ahead and move to next iteration if dealing with an unknown codec*/
- if (y >= 0 && !strcmp(ast_getformatname(1 << (y)), "unknown"))
+ if (y >= 0 && !strcmp(ast_getformatname(1LL << (y)), "unknown"))
continue;
if (y >= 0)
- curlen = strlen(ast_getformatname(1 << (y)));
+ curlen = strlen(ast_getformatname(1LL << (y)));
if (y >= 0 && magnitude[y] + 1 > curlen) {
curlen = magnitude[y] + 1;
}
@@ -581,10 +582,10 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd,
ast_str_append(&out, -1, "%*d", curlen + 1, tr_matrix[x][y].cost);
} else if (x == -1 && y >= 0) {
/* Top row - use a dynamic size */
- ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(1 << (y)) );
+ ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(1LL << (y)) );
} else if (y == -1 && x >= 0) {
/* Left column - use a static size. */
- ast_str_append(&out, -1, "%*s", longest, ast_getformatname(1 << (x)) );
+ ast_str_append(&out, -1, "%*s", longest, ast_getformatname(1LL << (x)) );
} else if (x >= 0 && y >= 0) {
/* Codec not supported */
ast_str_append(&out, -1, "%*s", curlen + 1, "-");
@@ -638,8 +639,8 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
return -1;
}
if (t->dstfmt != powerof(AST_FORMAT_SLINEAR))
- ast_log(LOG_WARNING, "plc_samples %d format %x\n",
- t->plc_samples, t->dstfmt);
+ ast_log(LOG_WARNING, "plc_samples %d format %llx\n",
+ t->plc_samples, (unsigned long long) t->dstfmt);
}
if (t->srcfmt >= MAX_FORMAT) {
ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
@@ -669,7 +670,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod)
ast_verb(2, "Registered translator '%s' from format %s to %s, cost %d\n",
term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
- ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost);
+ ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt), t->cost);
if (!added_cli) {
ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate));
@@ -713,7 +714,7 @@ int ast_unregister_translator(struct ast_translator *t)
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
if (u == t) {
AST_RWLIST_REMOVE_CURRENT(list);
- ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt));
+ ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt));
found = 1;
break;
}
@@ -745,15 +746,15 @@ void ast_translator_deactivate(struct ast_translator *t)
}
/*! \brief Calculate our best translator source format, given costs, and a desired destination */
-int ast_translator_best_choice(int *dst, int *srcs)
+format_t ast_translator_best_choice(format_t *dst, format_t *srcs)
{
int x,y;
- int best = -1;
- int bestdst = 0;
- int cur, cursrc;
+ format_t best = -1;
+ format_t bestdst = 0;
+ format_t cur, cursrc;
int besttime = INT_MAX;
int beststeps = INT_MAX;
- int common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */
+ format_t common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */
if (common) { /* yes, pick one and return */
for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) {
@@ -792,7 +793,7 @@ int ast_translator_best_choice(int *dst, int *srcs)
}
}
-unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
+unsigned int ast_translate_path_steps(format_t dest, format_t src)
{
unsigned int res = -1;
@@ -814,12 +815,12 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
return res;
}
-unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src)
+format_t ast_translate_available_formats(format_t dest, format_t src)
{
- unsigned int res = dest;
- unsigned int x;
- unsigned int src_audio = src & AST_FORMAT_AUDIO_MASK;
- unsigned int src_video = src & AST_FORMAT_VIDEO_MASK;
+ format_t res = dest;
+ format_t x;
+ format_t src_audio = src & AST_FORMAT_AUDIO_MASK;
+ format_t src_video = src & AST_FORMAT_VIDEO_MASK;
/* if we don't have a source format, we just have to try all
possible destination formats */
@@ -840,7 +841,11 @@ unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src
known audio formats to determine whether there exists
a translation path from the source format to the
destination format. */
- for (x = 1; src_audio && (x & AST_FORMAT_AUDIO_MASK); x <<= 1) {
+ for (x = 1LL; src_audio && x > 0; x <<= 1) {
+ if (!(x & AST_FORMAT_AUDIO_MASK)) {
+ continue;
+ }
+
/* if this is not a desired format, nothing to do */
if (!(dest & x))
continue;
@@ -866,7 +871,11 @@ unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src
known video formats to determine whether there exists
a translation path from the source format to the
destination format. */
- for (; src_video && (x & AST_FORMAT_VIDEO_MASK); x <<= 1) {
+ for (x = 1LL; src_video && x > 0; x <<= 1) {
+ if (!(x & AST_FORMAT_VIDEO_MASK)) {
+ continue;
+ }
+
/* if this is not a desired format, nothing to do */
if (!(dest & x))
continue;
diff --git a/main/udptl.c b/main/udptl.c
index db2ae8f01..77fe8b157 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -368,7 +368,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, unsigned int len)
/* Decode the secondary IFP packet */
//fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]);
s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
+ s->f[ifp_no].subclass.codec = AST_MODEM_T38;
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = seq_no - i;
@@ -470,7 +470,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, unsigned int len)
if (repaired[l]) {
//fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
+ s->f[ifp_no].subclass.codec = AST_MODEM_T38;
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = j;
@@ -491,7 +491,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, unsigned int len)
if (seq_no >= s->rx_seq_no) {
/* Decode the primary IFP packet */
s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
+ s->f[ifp_no].subclass.codec = AST_MODEM_T38;
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = seq_no;
@@ -988,7 +988,7 @@ int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f)
return 0;
if ((f->frametype != AST_FRAME_MODEM) ||
- (f->subclass != AST_MODEM_T38)) {
+ (f->subclass.codec != AST_MODEM_T38)) {
ast_log(LOG_WARNING, "UDPTL can only send T.38 data.\n");
return -1;
}
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 88f81ae8c..fddba86f5 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -66,7 +66,7 @@ struct outgoing {
int retrytime; /*!< How long to wait between retries (in seconds) */
int waittime; /*!< How long to wait for an answer */
long callingpid; /*!< PID which is currently calling */
- int format; /*!< Formats (codecs) for this call */
+ format_t format; /*!< Formats (codecs) for this call */
AST_DECLARE_STRING_FIELDS (
AST_STRING_FIELD(fn); /*!< File name of call file */
AST_STRING_FIELD(tech); /*!< Which channel technology to use for outgoing call */
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 4d2aaaa8f..32f168850 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -133,7 +133,7 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l
else
*remain = *remain - amt;
outf.frametype = AST_FRAME_VOICE;
- outf.subclass = AST_FORMAT_ULAW;
+ outf.subclass.codec = AST_FORMAT_ULAW;
outf.data.ptr = buf;
outf.datalen = amt;
outf.samples = amt;
@@ -162,7 +162,7 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l
continue;
}
- if (inf->subclass != AST_FORMAT_ULAW) {
+ if (inf->subclass.codec != AST_FORMAT_ULAW) {
ast_log(LOG_WARNING, "Channel not in ulaw?\n");
ast_frfree(inf);
return -1;
@@ -173,7 +173,7 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l
else if (remain)
*remain = inf->datalen - amt;
outf.frametype = AST_FRAME_VOICE;
- outf.subclass = AST_FORMAT_ULAW;
+ outf.subclass.codec = AST_FORMAT_ULAW;
outf.data.ptr = buf;
outf.datalen = amt;
outf.samples = amt;
@@ -230,16 +230,16 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
return -1;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (f->subclass == 'A') {
+ if (f->subclass.integer == 'A') {
/* Okay, this is an ADSI CPE. Note this for future reference, too */
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_AVAILABLE;
break;
} else {
- if (f->subclass == 'D')
+ if (f->subclass.integer == 'D')
ast_debug(1, "Off-hook capable CPE only, not ADSI\n");
else
- ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass);
+ ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass.integer);
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_UNAVAILABLE;
errno = ENOSYS;
diff --git a/res/res_agi.c b/res/res_agi.c
index 3141ca443..e868601bd 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -1305,7 +1305,7 @@ static enum agi_result launch_asyncagi(struct ast_channel *chan, char *argv[], i
}
/* is there any other frame we should care about
besides AST_CONTROL_HANGUP? */
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
ast_log(LOG_DEBUG, "Got HANGUP frame on channel %s, going out ...\n", chan->name);
ast_frfree(f);
break;
@@ -2164,14 +2164,14 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
}
switch(f->frametype) {
case AST_FRAME_DTMF:
- if (strchr(argv[4], f->subclass)) {
+ if (strchr(argv[4], f->subclass.integer)) {
/* This is an interrupting chracter, so rewind to chop off any small
amount of DTMF that may have been recorded
*/
ast_stream_rewind(fs, 200);
ast_truncstream(fs);
sample_offset = ast_tellstream(fs);
- ast_agi_send(agi->fd, chan, "200 result=%d (dtmf) endpos=%ld\n", f->subclass, sample_offset);
+ ast_agi_send(agi->fd, chan, "200 result=%d (dtmf) endpos=%ld\n", f->subclass.integer, sample_offset);
ast_closestream(fs);
ast_frfree(f);
if (sildet)
@@ -2818,8 +2818,8 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
if (fr) {
if (fr->frametype == AST_FRAME_DTMF) {
reason = "dtmf";
- dtmf = fr->subclass;
- } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_HANGUP) {
+ dtmf = fr->subclass.integer;
+ } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_HANGUP) {
reason = "hangup";
}
ast_frfree(fr);
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index b5bc77d74..604ff300e 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -148,7 +148,7 @@ static int respawn_time = 20;
struct moh_files_state {
struct mohclass *class;
- int origwfmt;
+ format_t origwfmt;
int samples;
int sample_queue;
int pos;
@@ -180,7 +180,7 @@ struct mohclass {
int total_files;
unsigned int flags;
/*! The format from the MOH source, not applicable to "files" mode */
- int format;
+ format_t format;
/*! The pid of the external application delivering MOH */
int pid;
time_t start;
@@ -198,7 +198,7 @@ struct mohclass {
struct mohdata {
int pipe[2];
- int origwfmt;
+ format_t origwfmt;
struct mohclass *parent;
struct ast_frame f;
AST_LIST_ENTRY(mohdata) list;
@@ -235,7 +235,7 @@ static void moh_files_release(struct ast_channel *chan, void *data)
}
if (state->origwfmt && ast_set_write_format(chan, state->origwfmt)) {
- ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt);
+ ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%s'\n", chan->name, ast_getformatname(state->origwfmt));
}
state->save_pos = state->pos;
@@ -773,7 +773,7 @@ static struct mohdata *mohalloc(struct mohclass *cl)
fcntl(moh->pipe[1], F_SETFL, flags | O_NONBLOCK);
moh->f.frametype = AST_FRAME_VOICE;
- moh->f.subclass = cl->format;
+ moh->f.subclass.codec = cl->format;
moh->f.offset = AST_FRIENDLY_OFFSET;
moh->parent = mohclass_ref(cl, "Reffing music class for mohdata parent");
@@ -789,7 +789,7 @@ static void moh_release(struct ast_channel *chan, void *data)
{
struct mohdata *moh = data;
struct mohclass *class = moh->parent;
- int oldwfmt;
+ format_t oldwfmt;
ao2_lock(class);
AST_LIST_REMOVE(&moh->parent->members, moh, list);
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index eba2e852f..80e29f3b0 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -324,7 +324,7 @@ static inline int rtcp_debug_test_addr(struct sockaddr_in *addr)
return 1;
}
-static int rtp_get_rate(int subclass)
+static int rtp_get_rate(format_t subclass)
{
return (subclass == AST_FORMAT_G722) ? 8000 : ast_format_rate(subclass);
}
@@ -952,9 +952,9 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
int pred, mark = 0;
unsigned int ms = calc_txstamp(rtp, &frame->delivery);
struct sockaddr_in remote_address = { 0, };
- int rate = rtp_get_rate(frame->subclass) / 1000;
+ int rate = rtp_get_rate(frame->subclass.codec) / 1000;
- if (frame->subclass == AST_FORMAT_G722) {
+ if (frame->subclass.codec == AST_FORMAT_G722) {
frame->samples /= 2;
}
@@ -978,7 +978,7 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
}
}
} else if (frame->frametype == AST_FRAME_VIDEO) {
- mark = frame->subclass & 0x1;
+ mark = frame->subclass.codec & 0x1;
pred = rtp->lastovidtimestamp + frame->samples;
/* Re-calculate last TS */
rtp->lastts = rtp->lastts + ms * 90;
@@ -1105,7 +1105,7 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr
{
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
struct sockaddr_in remote_address = { 0, };
- int codec, subclass;
+ format_t codec, subclass;
ast_rtp_instance_get_remote_address(instance, &remote_address);
@@ -1135,12 +1135,12 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr
}
/* Grab the subclass and look up the payload we are going to use */
- subclass = frame->subclass;
+ subclass = frame->subclass.codec;
if (frame->frametype == AST_FRAME_VIDEO) {
subclass &= ~0x1;
}
if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, subclass)) < 0) {
- ast_log(LOG_WARNING, "Don't know how to send format %s packets with RTP\n", ast_getformatname(frame->subclass));
+ ast_log(LOG_WARNING, "Don't know how to send format %s packets with RTP\n", ast_getformatname(frame->subclass.codec));
return -1;
}
@@ -1169,13 +1169,13 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr
default:
if (fmt.inc_ms) {
if (!(rtp->smoother = ast_smoother_new((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms))) {
- ast_log(LOG_WARNING, "Unable to create smoother: format %d ms: %d len: %d\n", subclass, fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
+ ast_log(LOG_WARNING, "Unable to create smoother: format %s ms: %d len: %d\n", ast_getformatname(subclass), fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
return -1;
}
if (fmt.flags) {
ast_smoother_set_flags(rtp->smoother, fmt.flags);
}
- ast_debug(1, "Created smoother: format: %d ms: %d len: %d\n", subclass, fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
+ ast_debug(1, "Created smoother: format: %s ms: %d len: %d\n", ast_getformatname(subclass), fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
}
}
}
@@ -1234,7 +1234,7 @@ static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int t
double d;
double dtv;
double prog;
- int rate = rtp_get_rate(rtp->f.subclass);
+ int rate = rtp_get_rate(rtp->f.subclass.codec);
double normdev_rxjitter_current;
if ((!rtp->rxcore.tv_sec && !rtp->rxcore.tv_usec) || mark) {
@@ -1296,10 +1296,10 @@ static struct ast_frame *send_dtmf(struct ast_rtp_instance *instance, enum ast_f
ast_debug(1, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(remote_address.sin_addr));
if (rtp->resp == 'X') {
rtp->f.frametype = AST_FRAME_CONTROL;
- rtp->f.subclass = AST_CONTROL_FLASH;
+ rtp->f.subclass.integer = AST_CONTROL_FLASH;
} else {
rtp->f.frametype = type;
- rtp->f.subclass = rtp->resp;
+ rtp->f.subclass.integer = rtp->resp;
}
rtp->f.datalen = 0;
rtp->f.samples = 0;
@@ -1381,7 +1381,7 @@ static struct ast_frame *process_dtmf_rfc2833(struct ast_rtp_instance *instance,
if ((rtp->lastevent != seqno) && rtp->resp) {
rtp->dtmf_duration = new_duration;
f = send_dtmf(instance, AST_FRAME_DTMF_END, 0);
- f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
+ f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass.codec)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_duration = rtp->dtmf_timeout = 0;
}
@@ -1391,7 +1391,7 @@ static struct ast_frame *process_dtmf_rfc2833(struct ast_rtp_instance *instance,
if (rtp->resp && rtp->resp != resp) {
/* Another digit already began. End it */
f = send_dtmf(instance, AST_FRAME_DTMF_END, 0);
- f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
+ f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass.codec)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_duration = rtp->dtmf_timeout = 0;
}
@@ -1486,10 +1486,10 @@ static struct ast_frame *process_dtmf_cisco(struct ast_rtp_instance *instance, u
}
} else if ((rtp->resp == resp) && !power) {
f = send_dtmf(instance, AST_FRAME_DTMF_END, ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_DTMF_COMPENSATE));
- f->samples = rtp->dtmfsamples * (rtp_get_rate(f->subclass) / 1000);
+ f->samples = rtp->dtmfsamples * (rtp_get_rate(f->subclass.codec) / 1000);
rtp->resp = 0;
} else if (rtp->resp == resp)
- rtp->dtmfsamples += 20 * (rtp_get_rate(f->subclass) / 1000);
+ rtp->dtmfsamples += 20 * (rtp_get_rate(f->subclass.codec) / 1000);
rtp->dtmf_timeout = 0;
return f;
@@ -1529,7 +1529,7 @@ static struct ast_frame *process_cn_rfc3389(struct ast_rtp_instance *instance, u
rtp->f.datalen = 0;
}
rtp->f.frametype = AST_FRAME_CNG;
- rtp->f.subclass = data[0] & 0x7f;
+ rtp->f.subclass.integer = data[0] & 0x7f;
rtp->f.datalen = len - 1;
rtp->f.samples = 0;
rtp->f.delivery.tv_usec = rtp->f.delivery.tv_sec = 0;
@@ -1771,7 +1771,7 @@ static struct ast_frame *ast_rtcp_read(struct ast_rtp_instance *instance)
if (rtcp_debug_test_addr(&sin))
ast_verbose("Received an RTCP Fast Update Request\n");
rtp->f.frametype = AST_FRAME_CONTROL;
- rtp->f.subclass = AST_CONTROL_VIDUPDATE;
+ rtp->f.subclass.integer = AST_CONTROL_VIDUPDATE;
rtp->f.datalen = 0;
rtp->f.samples = 0;
rtp->f.mallocd = 0;
@@ -2041,8 +2041,8 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
return f ? f : &ast_null_frame;
}
- rtp->lastrxformat = rtp->f.subclass = payload.code;
- rtp->f.frametype = (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
+ rtp->lastrxformat = rtp->f.subclass.codec = payload.code;
+ rtp->f.frametype = (rtp->f.subclass.codec & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass.codec & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
rtp->rxseqno = seqno;
@@ -2052,7 +2052,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
if (rtp->resp) {
struct ast_frame *f;
f = send_dtmf(instance, AST_FRAME_DTMF_END, 0);
- f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
+ f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass.codec)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_timeout = rtp->dtmf_duration = 0;
return f;
@@ -2068,7 +2068,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
rtp->f.offset = hdrlen + AST_FRIENDLY_OFFSET;
rtp->f.seqno = seqno;
- if (rtp->f.subclass == AST_FORMAT_T140 && (int)seqno - (prev_seqno+1) > 0 && (int)seqno - (prev_seqno+1) < 10) {
+ if (rtp->f.subclass.codec == AST_FORMAT_T140 && (int)seqno - (prev_seqno+1) > 0 && (int)seqno - (prev_seqno+1) < 10) {
unsigned char *data = rtp->f.data.ptr;
memmove(rtp->f.data.ptr+3, rtp->f.data.ptr, rtp->f.datalen);
@@ -2078,7 +2078,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
*data = 0xBD;
}
- if (rtp->f.subclass == AST_FORMAT_T140RED) {
+ if (rtp->f.subclass.codec == AST_FORMAT_T140RED) {
unsigned char *data = rtp->f.data.ptr;
unsigned char *header_end;
int num_generations;
@@ -2087,7 +2087,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
int diff =(int)seqno - (prev_seqno+1); /* if diff = 0, no drop*/
int x;
- rtp->f.subclass = AST_FORMAT_T140;
+ rtp->f.subclass.codec = AST_FORMAT_T140;
header_end = memchr(data, ((*data) & 0x7f), rtp->f.datalen);
if (header_end == NULL) {
return &ast_null_frame;
@@ -2125,16 +2125,16 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
}
}
- if (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) {
+ if (rtp->f.subclass.codec & AST_FORMAT_AUDIO_MASK) {
rtp->f.samples = ast_codec_get_samples(&rtp->f);
- if (rtp->f.subclass == AST_FORMAT_SLINEAR)
+ if (rtp->f.subclass.codec == AST_FORMAT_SLINEAR)
ast_frame_byteswap_be(&rtp->f);
calc_rxstamp(&rtp->f.delivery, rtp, timestamp, mark);
/* Add timing data to let ast_generic_bridge() put the frame into a jitterbuf */
ast_set_flag(&rtp->f, AST_FRFLAG_HAS_TIMING_INFO);
- rtp->f.ts = timestamp / (rtp_get_rate(rtp->f.subclass) / 1000);
- rtp->f.len = rtp->f.samples / ((ast_format_rate(rtp->f.subclass) / 1000));
- } else if (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) {
+ rtp->f.ts = timestamp / (rtp_get_rate(rtp->f.subclass.codec) / 1000);
+ rtp->f.len = rtp->f.samples / ((ast_format_rate(rtp->f.subclass.codec) / 1000));
+ } else if (rtp->f.subclass.codec & AST_FORMAT_VIDEO_MASK) {
/* Video -- samples is # of samples vs. 90000 */
if (!rtp->lastividtimestamp)
rtp->lastividtimestamp = timestamp;
@@ -2148,7 +2148,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
* involved here since we deal with video.
*/
if (mark)
- rtp->f.subclass |= 0x1;
+ rtp->f.subclass.codec |= 0x1;
} else {
/* TEXT -- samples is # of samples vs. 1000 */
if (!rtp->lastitexttimestamp)
@@ -2264,7 +2264,7 @@ static int rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int
}
rtp->red->t140.frametype = AST_FRAME_TEXT;
- rtp->red->t140.subclass = AST_FORMAT_T140RED;
+ rtp->red->t140.subclass.codec = AST_FORMAT_T140RED;
rtp->red->t140.data.ptr = &rtp->red->buf_data;
rtp->red->t140.ts = 0;
diff --git a/res/res_rtp_multicast.c b/res/res_rtp_multicast.c
index a612db5e8..b58f4b36e 100644
--- a/res/res_rtp_multicast.c
+++ b/res/res_rtp_multicast.c
@@ -206,7 +206,7 @@ static int multicast_rtp_write(struct ast_rtp_instance *instance, struct ast_fra
}
/* Grab the actual payload number for when we create the RTP packet */
- if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, frame->subclass)) < 0) {
+ if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, frame->subclass.codec)) < 0) {
return -1;
}