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;
}
/* 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;
}
continue;
}
- digit_string[i++] = f->subclass; /* save digit */
+ digit_string[i++] = f->subclass.integer; /* save digit */
ast_frfree(f);
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)) {
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;
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);
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;
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) {
}
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) {
}
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;
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");
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);
}
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");
/* 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))) {
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);
}
}
}
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;
}
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;
}
break;
case DMODE_RECORD:
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case '1':
ast_set_flag(&flags, DFLAG_PAUSE);
mode = DMODE_PLAY;
got = 0;
}
if (!got) {
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case '#':
done = 1;
continue;
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);
continue;
}
- j = f->subclass; /* save digit */
+ j = f->subclass.integer; /* save digit */
ast_frfree(f);
if (!i) {
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);
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;
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);
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) {
struct ast_frame outf = {
.frametype = AST_FRAME_MODEM,
- .subclass = AST_MODEM_T38,
+ .subclass.integer = AST_MODEM_T38,
.src = __FUNCTION__,
};
struct ast_frame outf = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.src = __FUNCTION__,
};
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;
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");
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) {
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");
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;
}
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;
}
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;
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) {
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;
}
}
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) {
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),
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:
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;
}
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);
}
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);
}
dtmf = 0;
}
} else {
- dtmf = f->subclass;
+ dtmf = f->subclass.integer;
}
if (dtmf) {
switch(dtmf) {
dtmf = 0;
}
} else {
- dtmf = f->subclass;
+ dtmf = f->subclass.integer;
}
if (dtmf) {
switch (dtmf) {
} 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) {
&& 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;
} 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) {
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;
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__,
};
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;
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;
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) {
}
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;
}
}
/* 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) {
}
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;
}
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;
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;
/* 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) {
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)
}
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;
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);
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]);
break;
}
if (f->frametype == AST_FRAME_HTML) {
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_HTML_LDCOMPLETE:
res = 0;
ast_frfree(f);
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);
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);
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;
/* 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;
/* 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);
}
#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); \
} \
} 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);
{
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);
}
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 */
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;
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",
if (!f)
return -1;
if (f->frametype == AST_FRAME_DTMF)
- res = f->subclass;
+ res = f->subclass.integer;
else
res = 0;
ast_frfree(f);
}
/*! \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;
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)
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);
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);
}
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);
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;
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;
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;
}
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);
}
}
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) {
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);
}
}
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);
}
#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);
}
/*! \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;
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);
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),
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);
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;
}
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);
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);
}
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) {
pvt->hookstate = 0;
- ast_queue_frame(pvt->owner, &f);
+ ast_queue_control(pvt->owner, AST_CONTROL_FLASH);
unref_pvt(pvt);
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 */
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);
*/
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) {
ast_indicate(pvt->owner, -1);
- ast_queue_frame(pvt->owner, &f);
+ ast_queue_control(pvt->owner, AST_CONTROL_ANSWER);
unref_pvt(pvt);
}
-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);
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 */
}
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;
}
}
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;
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);
}
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 */
}
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;
}
}
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;
#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
/* 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;
}
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 */
} 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 {
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)
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
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);
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);
} 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';
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:
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)
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;
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;
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;
/* 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;
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
/* 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;
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;
}
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;
/* 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;
}
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 */
|| (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 */
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;
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) {
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);
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);
}
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);
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;
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");
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 */
};
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 */
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);
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))
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;
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"))) {
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);
}
}
}
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);
}
{
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) {
}
/*! \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;
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 */
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);
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",
};
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);
}
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);
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);
}
}
}
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;
}
}
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;
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) {
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;
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;
}
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;
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);
}
}
-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;
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;
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;
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 */
/*! 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 */
/*! 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 */
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);
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;
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) {
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;
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 */
/* 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));
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;
}
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)
}
struct create_addr_info {
- int capability;
+ format_t capability;
uint64_t flags;
int maxtime;
int encmethods;
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);
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;
{
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;
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) {
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));
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])
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;
}
/*! \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;
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;
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;
/* 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;
* 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;
}
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;
}
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
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)
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;
int res = 0;
f.frametype = type;
- f.subclass = command;
+ f.subclass.integer = command;
f.datalen = datalen;
f.src = __FUNCTION__;
f.data.ptr = (void *) data;
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);
}
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)
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;
/* 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;
}
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;
} else {
/* Don't know anything about it yet */
f.frametype = AST_FRAME_NULL;
- f.subclass = 0;
+ f.subclass.integer = 0;
}
if (!fr->callno) {
* 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;
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);
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);
}
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;
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 */
}
} 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++;
}
/* 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;
}
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;
/* 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]);
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;
}
}
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;
}
}
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;
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... */
}
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;
}
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) {
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 */
}
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",
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");
}
}
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");
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)))
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");
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) */
}
/* 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);
}
} 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);
/* 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);
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)) {
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;
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));
}
}
-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;
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;
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;
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 */
};
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 */
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);
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)
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))
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;
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"))) {
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);
}
}
}
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);
} */
}
}
{
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) {
}
/*! \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;
.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);
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");
} 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);
/* 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)))
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);
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);
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)))
{
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;
}
/*! \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;
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];
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 */
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);
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);
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);
}
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);
}
{
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;
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; */
}
}
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");
/* 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) {
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
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);
}
}
}
- 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);
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
}
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);
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);
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);
{
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];
(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);
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];
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));
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;
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;
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;
}
}
- 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;
}
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;
}
- 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;
}
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;
}
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;
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] = "";
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;
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;
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;
/* 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;
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);
}
/*! \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)) {
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);
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);
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);
}
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;
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;
AST_APP_ARG(flags);
);
char *parse = ast_strdupa(data);
+ char buf[256];
AST_NONSTANDARD_APP_ARGS(args, parse, '/');
o = find_desc(args.name);
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) {
/*! \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)
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);
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) {
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 */
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;
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 */
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);
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;
}
}
/* 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;
}
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;
#endif
/* Strange -- nothing there.. */
p->fr.frametype = AST_FRAME_NULL;
- p->fr.subclass = 0;
+ p->fr.subclass.integer = 0;
return &p->fr;
}
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;
}
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
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);
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);
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);
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);
}
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;
} 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);
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;
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;
}
}
#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
/*@}*/
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.
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;