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; /*!< Scheduler ID of any scheduled action to process queued requests */
int maxcallbitrate; /*!< Maximum Bitrate for a video call */
int expire; /*!< When to expire this peer registration */
- int capability; /*!< Codec capability */
+ format_t capability; /*!< Codec capability */
int rtptimeout; /*!< RTP timeout */
int rtpholdtimeout; /*!< RTP Hold Timeout */
int rtpkeepalive; /*!< Send RTP packets for keepalive */
in coming releases. */
/*--- PBX interface functions */
-static struct ast_channel *sip_request_call(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *sip_request_call(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int sip_devicestate(void *data);
static int sip_sendtext(struct ast_channel *ast, const char *text);
static int sip_call(struct ast_channel *ast, char *dest, int timeout);
static const char *get_sdp(struct sip_request *req, const char *name);
static int find_sdp(struct sip_request *req);
static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action);
-static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
+static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
struct ast_str **m_buf, struct ast_str **a_buf,
int debug, int *min_packet_size);
static void add_noncodec_to_sdp(const struct sip_pvt *p, int format,
static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p);
/*------- RTP Glue functions -------- */
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active);
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active);
/*!--- SIP MWI Subscription support */
static int sip_subscribe_mwi(const char *value, int lineno);
/*! \brief Try setting codec suggested by the SIP_CODEC channel variable */
static void try_suggested_sip_codec(struct sip_pvt *p)
{
- int fmt;
+ format_t fmt;
const char *codec;
struct ast_channel* chan;
switch (frame->frametype) {
case AST_FRAME_VOICE:
- if (!(frame->subclass & ast->nativeformats)) {
+ if (!(frame->subclass.codec & ast->nativeformats)) {
char s1[512], s2[512], s3[512];
- ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %s(%d) read/write = %s(%d)/%s(%d)\n",
- frame->subclass,
- ast_getformatname_multiple(s1, sizeof(s1) - 1, ast->nativeformats & AST_FORMAT_AUDIO_MASK),
- ast->nativeformats & AST_FORMAT_AUDIO_MASK,
- ast_getformatname_multiple(s2, sizeof(s2) - 1, ast->readformat),
- ast->readformat,
- ast_getformatname_multiple(s3, sizeof(s3) - 1, ast->writeformat),
- ast->writeformat);
+ ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(s1, sizeof(s1), ast->nativeformats & AST_FORMAT_AUDIO_MASK),
+ ast_getformatname_multiple(s2, sizeof(s2), ast->readformat),
+ ast_getformatname_multiple(s3, sizeof(s3), ast->writeformat));
return 0;
}
if (p) {
{
struct ast_channel *tmp;
struct ast_variable *v = NULL;
- int fmt;
- int what;
- int video;
- int text;
- int needvideo = 0;
+ format_t fmt;
+ format_t what;
+ format_t video;
+ format_t text;
+ format_t needvideo = 0;
int needtext = 0;
char buf[SIPBUFSIZE];
char *decoded_exten;
/* Don't forward RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) &&
(ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833)) {
- ast_debug(1, "Ignoring DTMF (%c) RTP frame because dtmfmode is not RFC2833\n", f->subclass);
+ ast_debug(1, "Ignoring DTMF (%c) RTP frame because dtmfmode is not RFC2833\n", f->subclass.integer);
return &ast_null_frame;
}
if (!p->owner || (f && f->frametype != AST_FRAME_VOICE))
return f;
- if (f && f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (!(f->subclass & p->jointcapability)) {
+ if (f && f->subclass.codec != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+ if (!(f->subclass.codec & p->jointcapability)) {
ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
- ast_getformatname(f->subclass), p->owner->name);
+ ast_getformatname(f->subclass.codec), p->owner->name);
return &ast_null_frame;
}
- ast_debug(1, "Oooh, format changed to %d %s\n",
- f->subclass, ast_getformatname(f->subclass));
- p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass;
+ ast_debug(1, "Oooh, format changed to %s\n",
+ ast_getformatname(f->subclass.codec));
+ p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass.codec;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
if (f && p->dsp) {
f = ast_dsp_process(p->owner, p->dsp, f);
if (f && f->frametype == AST_FRAME_DTMF) {
- if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && f->subclass == 'f') {
+ if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && f->subclass.integer == 'f') {
ast_debug(1, "Fax CNG detected on %s\n", ast->name);
*faxdetect = 1;
} else {
- ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass.integer);
}
}
}
int old = 0;
/* Peer capability is the capability in the SDP, non codec is RFC2833 DTMF (101) */
- int peercapability = 0, peernoncodeccapability = 0;
- int vpeercapability = 0, vpeernoncodeccapability = 0;
- int tpeercapability = 0, tpeernoncodeccapability = 0;
+ format_t peercapability = 0, vpeercapability = 0, tpeercapability = 0;
+ int peernoncodeccapability = 0, vpeernoncodeccapability = 0, tpeernoncodeccapability = 0;
struct sockaddr_in sin; /*!< media socket address */
struct sockaddr_in vsin; /*!< Video socket address */
struct sockaddr_in tsin; /*!< Text socket address */
int sendonly = -1;
int numberofports;
struct ast_rtp_codecs newaudiortp, newvideortp, newtextrtp;
- int newjointcapability; /* Negotiated capability */
- int newpeercapability;
+ format_t newjointcapability; /* Negotiated capability */
+ format_t newpeercapability;
int newnoncodeccapability;
int numberofmediastreams = 0;
int debug = sip_debug_test_pvt(p);
if (!format.asterisk_format || !format.code) /* non-codec or not found */
continue;
if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format.code, framing);
+ ast_log(LOG_DEBUG, "Setting framing for %s to %ld\n", ast_getformatname(format.code), framing);
ast_codec_pref_setsize(pref, format.code, framing);
}
ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, pref);
}
/*! \brief Add codec offer to SDP offer/answer body in INVITE or 200 OK */
-static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
+static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
struct ast_str **m_buf, struct ast_str **a_buf,
int debug, int *min_packet_size)
{
if (debug)
- ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
+ ast_verbose("Adding codec 0x%Lx (%s) to SDP\n", codec, ast_getformatname(codec));
if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->rtp), 1, codec)) == -1)
return;
static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
{
int len = 0;
- int alreadysent = 0;
+ format_t alreadysent = 0;
struct sockaddr_in sin = { 0, };
struct sockaddr_in vsin = { 0, };
struct ast_str *a_text = ast_str_alloca(1024); /* Attributes for text */
struct ast_str *a_modem = ast_str_alloca(1024); /* Attributes for modem */
- int x;
- int capability = 0;
+ format_t x;
+ format_t capability = 0;
int needaudio = FALSE;
int needvideo = FALSE;
int needtext = FALSE;
Note that p->prefcodec can include video codecs, so mask them out
*/
if (capability & p->prefcodec) {
- int codec = p->prefcodec & AST_FORMAT_AUDIO_MASK;
+ format_t codec = p->prefcodec & AST_FORMAT_AUDIO_MASK;
add_codec_to_sdp(p, codec, &m_audio, &a_audio, debug, &min_audio_packet_size);
alreadysent |= codec;
}
/* Start by sending our preferred audio/video codecs */
- for (x = 0; x < 32; x++) {
- int codec;
+ for (x = 0; x < 64; x++) {
+ format_t codec;
if (!(codec = ast_codec_pref_index(&p->prefs, x)))
break;
}
/* Now send any other common audio and video codecs, and non-codec formats: */
- for (x = 1; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
+ for (x = 1LL; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
if (!(capability & x)) /* Codec not requested */
continue;
}
/* Now add DTMF RFC2833 telephony-event as a codec */
- for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
+ for (x = 1LL; x <= AST_RTP_MAX; x <<= 1) {
if (!(p->jointnoncodeccapability & x))
continue;
ast_verbose("SIP Text message received: '%s'\n", buf);
memset(&f, 0, sizeof(f));
f.frametype = AST_FRAME_TEXT;
- f.subclass = 0;
+ f.subclass.integer = 0;
f.offset = 0;
f.data.ptr = buf;
f.datalen = strlen(buf);
/*! \brief Print codec list from preference to CLI/manager */
static void print_codec_to_cli(int fd, struct ast_codec_pref *pref)
{
- int x, codec;
+ int x;
+ format_t codec;
- for(x = 0; x < 32 ; x++) {
+ for(x = 0; x < 64 ; x++) {
codec = ast_codec_pref_index(pref, x);
if (!codec)
break;
struct ast_codec_pref *pref;
struct ast_variable *v;
struct sip_auth *auth;
- int x = 0, codec = 0, load_realtime;
+ int x = 0, load_realtime;
+ format_t codec = 0;
int realtimepeers;
realtimepeers = ast_check_realtime("sippeers");
astman_append(s, "%s\r\n", codec_buf);
astman_append(s, "CodecOrder: ");
pref = &peer->prefs;
- for(x = 0; x < 32 ; x++) {
+ for(x = 0; x < 64 ; x++) {
codec = ast_codec_pref_index(pref, x);
if (!codec)
break;
astman_append(s, "%s", ast_getformatname(codec));
- if (x < 31 && ast_codec_pref_index(pref, x+1))
+ if (x < 63 && ast_codec_pref_index(pref, x+1))
astman_append(s, ",");
}
ast_cli(a->fd, " Curr. trans. direction: %s\n", ast_test_flag(&cur->flags[0], SIP_OUTGOING) ? "Outgoing" : "Incoming");
ast_cli(a->fd, " Call-ID: %s\n", cur->callid);
ast_cli(a->fd, " Owner channel ID: %s\n", cur->owner ? cur->owner->name : "<none>");
- ast_cli(a->fd, " Our Codec Capability: %d\n", cur->capability);
+ ast_cli(a->fd, " Our Codec Capability: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->capability));
ast_cli(a->fd, " Non-Codec Capability (DTMF): %d\n", cur->noncodeccapability);
- ast_cli(a->fd, " Their Codec Capability: %d\n", cur->peercapability);
- ast_cli(a->fd, " Joint Codec Capability: %d\n", cur->jointcapability);
+ ast_cli(a->fd, " Their Codec Capability: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->peercapability));
+ ast_cli(a->fd, " Joint Codec Capability: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->jointcapability));
ast_cli(a->fd, " Format: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->owner ? cur->owner->nativeformats : 0) );
ast_cli(a->fd, " T.38 support %s\n", cli_yesno(cur->udptl != NULL));
ast_cli(a->fd, " Video support %s\n", cli_yesno(cur->vrtp != NULL));
event = atoi(buf);
if (event == 16) {
/* send a FLASH event */
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH, };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH, } };
ast_queue_frame(p->owner, &f);
if (sipdebug)
ast_verbose("* DTMF-relay event received: FLASH\n");
/* send a DTMF event */
struct ast_frame f = { AST_FRAME_DTMF, };
if (event < 10) {
- f.subclass = '0' + event;
- } else if (event < 11) {
- f.subclass = '*';
- } else if (event < 12) {
- f.subclass = '#';
+ f.subclass.integer = '0' + event;
+ } else if (event == 10) {
+ f.subclass.integer = '*';
+ } else if (event == 11) {
+ f.subclass.integer = '#';
} else if (event < 16) {
- f.subclass = 'A' + (event - 12);
+ f.subclass.integer = 'A' + (event - 12);
}
f.len = duration;
ast_queue_frame(p->owner, &f);
if (sipdebug)
- ast_verbose("* DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("* DTMF-relay event received: %c\n", (int) f.subclass.integer);
}
transmit_response(p, "200 OK", req);
return;
event = atoi(buf);
if (event == 16) {
/* send a FLASH event */
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH, };
+ struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_FLASH }, };
ast_queue_frame(p->owner, &f);
if (sipdebug)
ast_verbose("* DTMF-relay event received: FLASH\n");
/* send a DTMF event */
struct ast_frame f = { AST_FRAME_DTMF, };
if (event < 10) {
- f.subclass = '0' + event;
- } else if (event < 11) {
- f.subclass = '*';
- } else if (event < 12) {
- f.subclass = '#';
+ f.subclass.integer = '0' + event;
+ } else if (event == 10) {
+ f.subclass.integer = '*';
+ } else if (event == 11) {
+ f.subclass.integer = '#';
} else if (event < 16) {
- f.subclass = 'A' + (event - 12);
+ f.subclass.integer = 'A' + (event - 12);
}
f.len = duration;
ast_queue_frame(p->owner, &f);
if (sipdebug)
- ast_verbose("* DTMF-relay event received: %c\n", f.subclass);
+ ast_verbose("* DTMF-relay event received: %c\n", (int) f.subclass.integer);
}
transmit_response(p, "200 OK", req);
return;
/* Send the feature code to the PBX as DTMF, just like the handset had sent it */
f.len = 100;
for (j=0; j < strlen(feat->exten); j++) {
- f.subclass = feat->exten[j];
+ f.subclass.integer = feat->exten[j];
ast_queue_frame(p->owner, &f);
if (sipdebug)
- ast_verbose("* DTMF-relay event faked: %c\n", f.subclass);
+ ast_verbose("* DTMF-relay event faked: %c\n", f.subclass.integer);
}
ast_unlock_call_features();
}
} else if (!strncasecmp(colname, "codec[", 6)) {
char *codecnum;
- int codec = 0;
+ format_t codec = 0;
codecnum = colname + 6; /* move past the '[' */
codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */
* or SIP/host!dnid
* \endverbatim
*/
-static struct ast_channel *sip_request_call(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *sip_request_call(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct sip_pvt *p;
struct ast_channel *tmpc = NULL;
char *authname = NULL;
char *trans = NULL;
enum sip_transport transport = 0;
- int oldformat = format;
+ format_t oldformat = format;
/* mask request with some set of allowed formats.
* XXX this needs to be fixed.
return res;
}
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active)
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active)
{
struct sip_pvt *p;
int changed = 0;
return 0;
}
-static int sip_get_codec(struct ast_channel *chan)
+static format_t sip_get_codec(struct ast_channel *chan)
{
struct sip_pvt *p = chan->tech_pvt;
return p->peercapability ? p->peercapability : p->capability;
static const char tdesc[] = "Skinny Client Control Protocol (Skinny)";
static const char config[] = "skinny.conf";
-static int default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW;
+static format_t default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW;
static struct ast_codec_pref default_prefs;
enum skinny_codecs {
int instance; \
int group; \
int needdestroy; \
- int confcapability; \
+ format_t confcapability; \
struct ast_codec_pref confprefs; \
- int capability; \
+ format_t capability; \
struct ast_codec_pref prefs; \
int nonCodecCapability; \
int onhooktime; \
int registered; \
int lastlineinstance; \
int lastcallreference; \
- int confcapability; \
+ format_t confcapability; \
struct ast_codec_pref confprefs; \
- int capability; \
+ format_t capability; \
int earlyrtp; \
int transfer; \
int callwaiting; \
AST_LIST_ENTRY(skinnysession) list;
};
-static struct ast_channel *skinny_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *skinny_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static AST_LIST_HEAD_STATIC(sessions, skinnysession);
static int skinny_devicestate(void *data);
}
-static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active)
+static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
{
struct skinny_subchannel *sub;
struct skinny_line *l;
fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
if (skinnydebug)
- ast_verb(1, "Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
+ ast_verb(1, "Setting payloadType to '%s' (%d ms)\n", ast_getformatname(fmt.bits), fmt.cur_ms);
req->data.startmedia.conferenceId = htolel(sub->callid);
req->data.startmedia.passThruPartyId = htolel(sub->callid);
if (ast) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != ast->nativeformats) {
- ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
- ast->nativeformats = f->subclass;
+ if (f->subclass.codec != ast->nativeformats) {
+ ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(f->subclass.codec));
+ ast->nativeformats = f->subclass.codec;
ast_set_read_format(ast, ast->readformat);
ast_set_write_format(ast, ast->writeformat);
}
return 0;
}
} else {
- if (!(frame->subclass & ast->nativeformats)) {
- ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
- frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
+ if (!(frame->subclass.codec & ast->nativeformats)) {
+ char buf[256];
+ ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
return -1;
}
}
// Should throw an error
tmp->nativeformats = default_capability;
fmt = ast_best_codec(tmp->nativeformats);
- if (skinnydebug)
- ast_verb(1, "skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
+ if (skinnydebug) {
+ char buf[256];
+ ast_verb(1, "skinny_new: tmp->nativeformats=%s fmt=%s\n",
+ ast_getformatname_multiple(buf, sizeof(buf), tmp->nativeformats),
+ ast_getformatname(fmt));
+ }
if (sub->rtp) {
ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
}
ast_log(LOG_WARNING, "Unsupported digit %d\n", digit);
}
- f.subclass = dgt;
+ f.subclass.integer = dgt;
f.src = "skinny";
uint32_t count = 0;
int codecs = 0;
int i;
+ char buf[256];
count = letohl(req->data.caps.count);
if (count > SKINNY_MAX_CAPABILITIES) {
}
d->capability = d->confcapability & codecs;
- ast_verb(0, "Device capability set to '%d'\n", d->capability);
+ ast_verb(0, "Device capability set to '%s'\n", ast_getformatname_multiple(buf, sizeof(buf), d->capability));
AST_LIST_TRAVERSE(&d->lines, l, list) {
ast_mutex_lock(&l->lock);
l->capability = l->confcapability & d->capability;
fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
if (skinnydebug)
- ast_verb(1, "Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
+ ast_verb(1, "Setting payloadType to '%s' (%d ms)\n", ast_getformatname(fmt.bits), fmt.cur_ms);
req->data.startmedia.conferenceId = htolel(sub->callid);
req->data.startmedia.passThruPartyId = htolel(sub->callid);
return get_devicestate(l);
}
-static struct ast_channel *skinny_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+static struct ast_channel *skinny_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct skinny_line *l;
struct ast_channel *tmpc = NULL;
oldformat = format;
if (!(format &= AST_FORMAT_AUDIO_MASK)) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), format));
return NULL;
}
static int unload_module(void);
static int reload_config(void);
static void show_main_page(struct unistimsession *pte);
-static struct ast_channel *unistim_request(const char *type, int format, const struct ast_channel *requestor,
+static struct ast_channel *unistim_request(const char *type, format_t format, const struct ast_channel *requestor,
void *data, int *cause);
static int unistim_call(struct ast_channel *ast, char *dest, int timeout);
static int unistim_hangup(struct ast_channel *ast);
struct sockaddr_in us = { 0, };
struct sockaddr_in public = { 0, };
struct sockaddr_in sin = { 0, };
- int codec;
+ format_t codec;
struct sockaddr_in sout = { 0, };
/* Sanity checks */
sin.sin_port = htons(sub->parent->parent->rtp_port);
ast_rtp_instance_set_remote_address(sub->rtp, &sin);
if (!(sub->owner->nativeformats & sub->owner->readformat)) {
- int fmt;
+ format_t fmt;
+ char tmp[256];
fmt = ast_best_codec(sub->owner->nativeformats);
ast_log(LOG_WARNING,
- "Our read/writeformat has been changed to something incompatible : %s (%d), using %s (%d) best codec from %d\n",
+ "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
ast_getformatname(sub->owner->readformat),
- sub->owner->readformat, ast_getformatname(fmt), fmt,
- sub->owner->nativeformats);
+ ast_getformatname(fmt),
+ ast_getformatname_multiple(tmp, sizeof(tmp), sub->owner->nativeformats));
sub->owner->readformat = fmt;
sub->owner->writeformat = fmt;
}
else
memcpy(&public, &public_ip, sizeof(public)); /* override */
if (unistimdebug) {
- ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s (%d)\n",
+ ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s\n",
ast_inet_ntoa(us.sin_addr),
- htons(us.sin_port), ast_getformatname(sub->owner->readformat),
- sub->owner->readformat);
+ htons(us.sin_port), ast_getformatname(sub->owner->readformat));
ast_verb(0, "Starting phone RTP stack. Our public IP is %s\n",
ast_inet_ntoa(public.sin_addr));
}
if ((sub->owner->readformat == AST_FORMAT_ULAW) ||
(sub->owner->readformat == AST_FORMAT_ALAW)) {
if (unistimdebug)
- ast_verb(0, "Sending packet_send_rtp_packet_size for codec %d\n", codec);
+ ast_verb(0, "Sending packet_send_rtp_packet_size for codec %s\n", ast_getformatname(codec));
memcpy(buffsend + SIZE_HEADER, packet_send_rtp_packet_size,
sizeof(packet_send_rtp_packet_size));
- buffsend[10] = codec;
+ buffsend[10] = (int) codec & 0xffffffffLL;
send_client(SIZE_HEADER + sizeof(packet_send_rtp_packet_size), buffsend,
sub->parent->parent->session);
}
else if (sub->owner->readformat == AST_FORMAT_G729A)
buffsend[42] = 2; /* 1 = 10ms (10 bytes), 2 = 20ms (20 bytes) */
else
- ast_log(LOG_WARNING, "Unsupported codec %s (%d) !\n",
- ast_getformatname(sub->owner->readformat), sub->owner->readformat);
+ ast_log(LOG_WARNING, "Unsupported codec %s!\n",
+ ast_getformatname(sub->owner->readformat));
/* Source port for transmit RTP and Destination port for receiving RTP */
buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;
buffsend[46] = (htons(sin.sin_port) & 0x00ff);
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
{
- struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass = digit, .src = "unistim" };
+ struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = digit, .src = "unistim" };
struct unistim_subchannel *sub;
sub = pte->device->lines->subs[SUB_REAL];
if (!sub->owner || sub->alreadygone) {
if (sub->owner) {
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
- if (f->subclass != sub->owner->nativeformats) {
+ if (f->subclass.codec != sub->owner->nativeformats) {
ast_debug(1,
- "Oooh, format changed from %s (%d) to %s (%d)\n",
+ "Oooh, format changed from %s to %s\n",
ast_getformatname(sub->owner->nativeformats),
- sub->owner->nativeformats, ast_getformatname(f->subclass),
- f->subclass);
+ ast_getformatname(f->subclass.codec));
- sub->owner->nativeformats = f->subclass;
+ sub->owner->nativeformats = f->subclass.codec;
ast_set_read_format(sub->owner, sub->owner->readformat);
ast_set_write_format(sub->owner, sub->owner->writeformat);
}
return 0;
}
} else {
- if (!(frame->subclass & ast->nativeformats)) {
+ if (!(frame->subclass.codec & ast->nativeformats)) {
+ char tmp[256];
ast_log(LOG_WARNING,
- "Asked to transmit frame type %s (%d), while native formats is %s (%d) (read/write = %s (%d)/%d)\n",
- ast_getformatname(frame->subclass), frame->subclass,
- ast_getformatname(ast->nativeformats), ast->nativeformats,
- ast_getformatname(ast->readformat), ast->readformat,
- ast->writeformat);
+ "Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
+ ast_getformatname(frame->subclass.codec),
+ ast_getformatname_multiple(tmp, sizeof(tmp), ast->nativeformats),
+ ast_getformatname(ast->readformat),
+ ast_getformatname(ast->writeformat));
return -1;
}
}
send_tone(pte, 0, 0);
f.frametype = AST_FRAME_DTMF;
- f.subclass = digit;
+ f.subclass.integer = digit;
f.src = "unistim";
ast_queue_frame(sub->owner, &f);
if (!tmp->nativeformats)
tmp->nativeformats = CAPABILITY;
fmt = ast_best_codec(tmp->nativeformats);
- if (unistimdebug)
- ast_verb(0, "Best codec = %d from nativeformats %d (line cap=%d global=%d)\n", fmt,
- tmp->nativeformats, l->capability, CAPABILITY);
+ if (unistimdebug) {
+ char tmp1[256], tmp2[256], tmp3[256];
+ ast_verb(0, "Best codec = %s from nativeformats %s (line cap=%s global=%s)\n",
+ ast_getformatname(fmt),
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), tmp->nativeformats),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), l->capability),
+ ast_getformatname_multiple(tmp3, sizeof(tmp3), CAPABILITY));
+ }
if ((sub->rtp) && (sub->subtype == 0)) {
if (unistimdebug)
ast_verb(0, "New unistim channel with a previous rtp handle ?\n");
/*--- unistim_request: PBX interface function ---*/
/* UNISTIM calls initiated by the PBX arrive here */
-static struct ast_channel *unistim_request(const char *type, int format, const struct ast_channel *requestor, void *data,
+static struct ast_channel *unistim_request(const char *type, format_t format, const struct ast_channel *requestor, void *data,
int *cause)
{
- int oldformat;
+ format_t oldformat;
struct unistim_subchannel *sub;
struct ast_channel *tmpc = NULL;
char tmp[256];
oldformat = format;
format &= CAPABILITY;
ast_log(LOG_NOTICE,
- "Asked to get a channel of format %s while capability is %d result : %s (%d) \n",
- ast_getformatname(oldformat), CAPABILITY, ast_getformatname(format), format);
+ "Asked to get a channel of format %s while capability is %s result : %s\n",
+ ast_getformatname(oldformat),
+ ast_getformatname_multiple(tmp, sizeof(tmp), CAPABILITY),
+ ast_getformatname(format));
if (!format) {
ast_log(LOG_NOTICE,
"Asked to get a channel of unsupported format %s while capability is %s\n",
- ast_getformatname(oldformat), ast_getformatname(CAPABILITY));
+ ast_getformatname(oldformat), ast_getformatname_multiple(tmp, sizeof(tmp), CAPABILITY));
return NULL;
}
static struct ast_channel *vpb_new(struct vpb_pvt *i, enum ast_channel_state state, const char *context, const char *linkedid);
static void *do_chanreads(void *pvt);
-static struct ast_channel *vpb_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel *vpb_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
static int vpb_digit_begin(struct ast_channel *ast, char digit);
static int vpb_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int vpb_call(struct ast_channel *ast, char *dest, int timeout);
/* Check if we need to break */
if (break_for_dtmf) {
break;
- } else if ((f->frametype == AST_FRAME_DTMF) && ((f->subclass == '#') || (f->subclass == '*'))) {
+ } else if ((f->frametype == AST_FRAME_DTMF) && ((f->subclass.integer == '#') || (f->subclass.integer == '*'))) {
break;
}
} else {
switch (e->type) {
case VPB_RING:
if (p->mode == MODE_FXO) {
- f.subclass = AST_CONTROL_RING;
+ f.subclass.integer = AST_CONTROL_RING;
vpb_timer_stop(p->ring_timer);
vpb_timer_start(p->ring_timer);
} else
if (p->owner->_state != AST_STATE_UP) {
/* Assume caller has hung up */
vpb_timer_stop(p->ring_timer);
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
vpb_timer_stop(p->ring_timer);
f.frametype = AST_FRAME_NULL;
f.frametype = AST_FRAME_NULL;
} else if (p->owner->_state == AST_STATE_UP) {
f.frametype = AST_FRAME_DTMF;
- f.subclass = e->data;
+ f.subclass.integer = e->data;
} else
f.frametype = AST_FRAME_NULL;
break;
if (e->data == VPB_BUSY || e->data == VPB_BUSY_308 || e->data == VPB_BUSY_AUST ) {
ast_debug(4, "%s: handle_owned: got event: BUSY\n", p->dev);
if (p->owner->_state == AST_STATE_UP) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
- f.subclass = AST_CONTROL_BUSY;
+ f.subclass.integer = AST_CONTROL_BUSY;
}
} else if (e->data == VPB_FAX) {
if (!p->faxhandled) {
* Timeout connection */
ast_verb(3, "grunt timeout\n");
ast_log(LOG_NOTICE, "%s: Line hangup due of lack of conversation\n", p->dev);
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
p->lastgrunt = ast_tvnow();
f.frametype = AST_FRAME_NULL;
case VPB_CALLEND:
#ifdef DIAL_WITH_CALL_PROGRESS
if (e->data == VPB_CALL_CONNECTED) {
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
} else if (e->data == VPB_CALL_NO_DIAL_TONE || e->data == VPB_CALL_NO_RING_BACK) {
- f.subclass = AST_CONTROL_CONGESTION;
+ f.subclass.integer = AST_CONTROL_CONGESTION;
} else if (e->data == VPB_CALL_NO_ANSWER || e->data == VPB_CALL_BUSY) {
- f.subclass = AST_CONTROL_BUSY;
+ f.subclass.integer = AST_CONTROL_BUSY;
} else if (e->data == VPB_CALL_DISCONNECTED) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
}
#else
ast_log(LOG_NOTICE, "%s: Got call progress callback but blind dialing \n", p->dev);
break;
case VPB_STATION_OFFHOOK:
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
break;
case VPB_DROP:
if ((p->mode == MODE_FXO) && (UseLoopDrop)) { /* ignore loop drop on stations */
if (p->owner->_state == AST_STATE_UP) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
f.frametype = AST_FRAME_NULL;
}
break;
case VPB_LOOP_ONHOOK:
if (p->owner->_state == AST_STATE_UP) {
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
} else {
f.frametype = AST_FRAME_NULL;
}
break;
case VPB_STATION_ONHOOK:
- f.subclass = AST_CONTROL_HANGUP;
+ f.subclass.integer = AST_CONTROL_HANGUP;
break;
case VPB_STATION_FLASH:
- f.subclass = AST_CONTROL_FLASH;
+ f.subclass.integer = AST_CONTROL_FLASH;
break;
/* Called when dialing has finished and ringing starts
*/
case VPB_DIALEND:
if (p->state < 5) {
- f.subclass = AST_CONTROL_ANSWER;
+ f.subclass.integer = AST_CONTROL_ANSWER;
ast_verb(2, "%s: Dialend\n", p->dev);
} else {
f.frametype = AST_FRAME_NULL;
}
ast_verb(4, "%s: handle_owned: Prepared frame type[%d]subclass[%d], bridge=%p owner=[%s]\n",
- p->dev, f.frametype, f.subclass, (void *)p->bridge, p->owner->name);
+ p->dev, f.frametype, f.subclass.integer, (void *)p->bridge, p->owner->name);
/* Trylock used here to avoid deadlock that can occur if we
* happen to be in here handling an event when hangup is called
ast_verb(4, "%s: handled_owned: Queued Frame to [%s]\n", p->dev, p->owner->name);
} else {
ast_verbose("%s: handled_owned: Missed event %d/%d \n",
- p->dev, f.frametype, f.subclass);
+ p->dev, f.frametype, f.subclass.integer);
}
}
res = ast_mutex_unlock(&p->lock);
return &f;
}
-static inline AudioCompress ast2vpbformat(int ast_format)
+static inline AudioCompress ast2vpbformat(format_t ast_format)
{
switch (ast_format) {
case AST_FORMAT_ALAW:
}
}
-static inline const char * ast2vpbformatname(int ast_format)
+static inline const char * ast2vpbformatname(format_t ast_format)
{
switch(ast_format) {
case AST_FORMAT_ALAW:
}
}
-static inline int astformatbits(int ast_format)
+static inline int astformatbits(format_t ast_format)
{
switch (ast_format) {
case AST_FORMAT_SLINEAR:
/* ast_mutex_unlock(&p->lock); */
return 0;
} else if (ast->_state != AST_STATE_UP) {
- ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%d] on not up chan(state[%d])\n",ast->name, frame->frametype, frame->subclass,ast->_state);
+ ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%s] on not up chan(state[%d])\n", ast->name, frame->frametype, ast_getformatname(frame->subclass.codec), ast->_state);
p->lastoutput = -1;
/* ast_mutex_unlock(&p->lock); */
return 0;
/* ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */
- fmt = ast2vpbformat(frame->subclass);
+ fmt = ast2vpbformat(frame->subclass.codec);
if (fmt < 0) {
- ast_log(LOG_WARNING, "%s: vpb_write: Cannot handle frames of %d format!\n", ast->name, frame->subclass);
+ ast_log(LOG_WARNING, "%s: vpb_write: Cannot handle frames of %s format!\n", ast->name, ast_getformatname(frame->subclass.codec));
return -1;
}
/* Check if we have set up the play_buf */
if (p->lastoutput == -1) {
vpb_play_buf_start(p->handle, fmt);
- ast_verb(2, "%s: vpb_write: Starting play mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(frame->subclass));
+ ast_verb(2, "%s: vpb_write: Starting play mode (codec=%d)[%s]\n", p->dev, fmt, ast2vpbformatname(frame->subclass.codec));
p->lastoutput = fmt;
ast_mutex_unlock(&p->play_lock);
return 0;
struct ast_frame *fr = &p->fr;
char *readbuf = ((char *)p->buf) + AST_FRIENDLY_OFFSET;
int bridgerec = 0;
- int afmt, readlen, res, trycnt=0;
+ format_t afmt;
+ int readlen, res, trycnt=0;
AudioCompress fmt;
int ignore_dtmf;
const char * getdtmf_var = NULL;
}
fmt = ast2vpbformat(afmt);
if (fmt < 0) {
- ast_log(LOG_WARNING, "%s: Record failure (unsupported format %d)\n", p->dev, afmt);
+ ast_log(LOG_WARNING, "%s: Record failure (unsupported format %s)\n", p->dev, ast_getformatname(afmt));
return NULL;
}
readlen = VPB_SAMPLES * astformatbits(afmt) / 8;
a_gain_vector(p->rxswgain - MAX_VPB_GAIN, (short *)readbuf, readlen / sizeof(short));
ast_verb(6, "%s: chanreads: applied gain\n", p->dev);
- fr->subclass = afmt;
+ fr->subclass.codec = afmt;
fr->data.ptr = readbuf;
fr->datalen = readlen;
fr->frametype = AST_FRAME_VOICE;
- if ((use_ast_dtmfdet)&&(p->vad)) {
- fr = ast_dsp_process(p->owner,p->vad,fr);
+ if ((use_ast_dtmfdet) && (p->vad)) {
+ fr = ast_dsp_process(p->owner, p->vad, fr);
if (fr && (fr->frametype == AST_FRAME_DTMF)) {
- ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n", p->dev, fr->subclass);
- } else if (fr->subclass == 'f') {
+ ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n", p->dev, fr->subclass.integer);
+ } else if (fr->subclass.integer == 'f') {
}
}
/* Using trylock here to prevent deadlock when channel is hungup
return tmp;
}
-static struct ast_channel *vpb_request(const char *type, int format, const struct ast_channel *requestor, void *vdata, int *cause)
+static struct ast_channel *vpb_request(const char *type, format_t format, const struct ast_channel *requestor, void *vdata, int *cause)
{
- int oldformat;
+ format_t oldformat;
struct vpb_pvt *p;
struct ast_channel *tmp = NULL;
char *sepstr, *data = (char *)vdata, *name;
oldformat = format;
format &= prefformat;
if (!format) {
- ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat);
+ ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname(oldformat));
return NULL;
}
#define CHAN_H323_H
#include <arpa/inet.h>
+#include "asterisk/frame_defs.h"
/*
* Enable support for sending/reception of tunnelled Q.SIG messages and
int progress_audio;
int dtmfcodec[2];
int dtmfmode;
- int capability;
+ format_t capability;
int bridge;
int nat;
int tunnelOptions;
}
+static void dump_versioned_codec(char *output, int maxlen, void *value, int len)
+{
+ char *version = (char *) value;
+ if (version[0] == 0) {
+ if (len == (int) (sizeof(format_t) + sizeof(char))) {
+ format_t codec = ntohll(get_unaligned_uint64(value + 1));
+ ast_copy_string(output, ast_getformatname(codec), maxlen);
+ } else {
+ ast_copy_string(output, "Invalid length!", maxlen);
+ }
+ } else {
+ ast_copy_string(output, "Unknown version!", maxlen);
+ }
+}
+
static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int len);
static void dump_prov(char *output, int maxlen, void *value, int len)
{
{ IAX_IE_USERNAME, "USERNAME", dump_string },
{ IAX_IE_PASSWORD, "PASSWORD", dump_string },
{ IAX_IE_CAPABILITY, "CAPABILITY", dump_int },
+ { IAX_IE_CAPABILITY2, "CAPABILITY2", dump_versioned_codec },
{ IAX_IE_FORMAT, "FORMAT", dump_int },
+ { IAX_IE_FORMAT2, "FORMAT2", dump_versioned_codec },
{ IAX_IE_LANGUAGE, "LANGUAGE", dump_string },
{ IAX_IE_VERSION, "VERSION", dump_short },
{ IAX_IE_ADSICPE, "ADSICPE", dump_short },
return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
}
+int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value)
+{
+ struct _local {
+ unsigned char version;
+ uint64_t value;
+ } __attribute__((packed)) newval = { version, };
+ put_unaligned_uint64(&newval.value, htonll(value));
+ return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
+}
+
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
{
unsigned int newval;
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
- } else
- ies->capability = ntohl(get_unaligned_uint32(data + 2));
+ } else if (ies->capability == 0) { /* Don't overwrite capability2, if specified */
+ ies->capability = ntohll(get_unaligned_uint32(data + 2));
+ }
+ break;
+ case IAX_IE_CAPABILITY2:
+ {
+ int version = data[2];
+ if (version == 0) {
+ if (len != (int)sizeof(char) + sizeof(format_t)) {
+ snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int) (sizeof(format_t) + sizeof(char)), len);
+ errorf(tmp);
+ } else {
+ ies->capability = (format_t) ntohll(get_unaligned_uint64(data + 3));
+ }
+ } /* else unknown version */
+ }
break;
case IAX_IE_FORMAT:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
- } else
+ } else if (ies->format == 0) { /* Don't overwrite format2, if specified */
ies->format = ntohl(get_unaligned_uint32(data + 2));
+ }
+ break;
+ case IAX_IE_FORMAT2:
+ {
+ int version = data[2];
+ if (version == 0) {
+ if (len != (int)sizeof(char) + sizeof(format_t)) {
+ snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int) (sizeof(format_t) + sizeof(char)), len);
+ errorf(tmp);
+ } else {
+ ies->format = (format_t) ntohll(get_unaligned_uint64(data + 3));
+ }
+ } /* else unknown version */
+ }
break;
case IAX_IE_LANGUAGE:
ies->language = (char *)data + 2;
void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
{
fr->af.frametype = f->frametype;
- fr->af.subclass = f->subclass;
+ fr->af.subclass.codec = f->subclass.codec;
fr->af.mallocd = 0; /* Our frame is static relative to the container */
fr->af.datalen = f->datalen;
fr->af.samples = f->samples;
}
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* We need to byte-swap slinear samples from network byte order */
- if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass == AST_FORMAT_SLINEAR)) {
+ if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass.codec == AST_FORMAT_SLINEAR)) {
/* 2 bytes / sample for SLINEAR */
ast_swapcopy_samples(fr->af.data.ptr, f->data.ptr, copy_len / 2);
} else
#include "asterisk/linkedlists.h"
#include "asterisk/aes.h"
+#include "asterisk/frame_defs.h"
struct iax_ies {
char *called_number;
char *called_context;
char *username;
char *password;
- unsigned int capability;
- unsigned int format;
+ format_t capability;
+ format_t format;
char *codec_prefs;
char *language;
int version;
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
+int iax_ie_append_versioned_uint64(struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value);
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
#define IAX_FLAG_SC_LOG 0x80
-#define IAX_MAX_SHIFT 0x1F
+#define IAX_MAX_SHIFT 0x3F
#define IAX_WINDOW 64
#define IAX_IE_OSPTOKEN 53 /*!< OSP token */
#define IAX_IE_CALLTOKEN 54 /*!< Call number security token */
+#define IAX_IE_CAPABILITY2 55 /*!< Actual codec capability - u8 version + integer array */
+#define IAX_IE_FORMAT2 56 /*!< Desired codec format - u8 version + integer array */
+
#define IAX_MAX_OSPBLOCK_SIZE 254 /*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
#define IAX_MAX_OSPBLOCK_NUM 4
#define IAX_MAX_OSPTOKEN_SIZE (IAX_MAX_OSPBLOCK_SIZE * IAX_MAX_OSPBLOCK_NUM)
static int analog_handles_digit(struct ast_frame *f)
{
- char subclass = toupper(f->subclass);
+ char subclass = toupper(f->subclass.integer);
switch (subclass) {
case '1':
/* Upon receiving a DTMF digit, consider this an answer confirmation instead
of a DTMF digit */
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
*dest = &p->subs[index].f;
/* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
analog_set_confirmanswer(p, 0);
}
if (p->callwaitcas) {
- if ((f->subclass == 'A') || (f->subclass == 'D')) {
+ if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
ast_log(LOG_ERROR, "Got some DTMF, but it's for the CAS\n");
p->cid.cid_name = p->callwait_name;
p->cid.cid_num = p->callwait_num;
if (analog_handles_digit(f))
p->callwaitcas = 0;
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
*dest = &p->subs[index].f;
} else {
analog_cb_handle_dtmfup(p, ast, index, dest);
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- dtmfbuf[i++] = f->subclass;
- ast_debug(1, "CID got digit '%c'\n", f->subclass);
+ dtmfbuf[i++] = f->subclass.integer;
+ ast_debug(1, "CID got digit '%c'\n", f->subclass.integer);
res = 2000;
}
ast_frfree(f);
mysig = p->outsigmod;
}
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
p->subs[index].f.datalen = 0;
p->subs[index].f.samples = 0;
p->subs[index].f.mallocd = 0;
ast_debug(1, "Detected %sdigit '%c'\n", (res & ANALOG_EVENT_PULSEDIGIT) ? "pulse ": "", res & 0xff);
analog_confmute(p, 0);
p->subs[index].f.frametype = AST_FRAME_DTMF_END;
- p->subs[index].f.subclass = res & 0xff;
+ p->subs[index].f.subclass.integer = res & 0xff;
analog_handle_dtmfup(p, ast, index, &f);
return f;
}
/* Mute conference */
analog_confmute(p, 1);
p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
- p->subs[index].f.subclass = res & 0xff;
+ p->subs[index].f.subclass.integer = res & 0xff;
return f;
}
if (ast->_state == AST_STATE_DIALING_OFFHOOK) {
ast_setstate(ast, AST_STATE_UP);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
break;
} else { /* if to state wait for offhook to dial rest */
/* we now wait for off hook */
} else if (!p->answeronpolarityswitch) {
ast_setstate(ast, AST_STATE_UP);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
/* If aops=0 and hops=1, this is necessary */
p->polarity = POLARITY_REV;
} else {
analog_set_echocanceller(p, 1);
analog_train_echocanceller(p);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
/* Make sure it stops ringing */
analog_off_hook(p);
ast_debug(1, "channel %d answered\n", p->channel);
if (analog_check_confirmanswer(p)) {
/* Ignore answer if "confirm answer" is enabled */
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
} else if (!ast_strlen_zero(p->dop.dialstr)) {
/* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
res = analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop);
} else {
ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
analog_set_dialing(p, 1);
}
p->dop.dialstr[0] = '\0';
ast_setstate(ast, AST_STATE_RING);
ast->rings = 1;
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
+ p->subs[index].f.subclass.integer = AST_CONTROL_OFFHOOK;
ast_debug(1, "channel %d picked up\n", p->channel);
return &p->subs[index].f;
case AST_STATE_UP:
if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
ast_debug(1, "Ring detected\n");
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_RING;
+ p->subs[index].f.subclass.integer = AST_CONTROL_RING;
} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
ast_debug(1, "Line answered\n");
if (analog_check_confirmanswer(p)) {
p->subs[index].f.frametype = AST_FRAME_NULL;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
} else {
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_ANSWER;
+ p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
ast_setstate(ast, AST_STATE_UP);
}
} else if (ast->_state != AST_STATE_RING) {
p->callwaitcas = 0;
}
p->subs[index].f.frametype = AST_FRAME_CONTROL;
- p->subs[index].f.subclass = AST_CONTROL_RINGING;
+ p->subs[index].f.subclass.integer = AST_CONTROL_RINGING;
break;
case ANALOG_EVENT_RINGERON:
break;
p->subs[index].f.samples = 0;
p->subs[index].f.mallocd = 0;
p->subs[index].f.offset = 0;
- p->subs[index].f.subclass = 0;
+ p->subs[index].f.subclass.integer = 0;
p->subs[index].f.delivery = ast_tv(0,0);
p->subs[index].f.src = "dahdi_exception";
p->subs[index].f.data.ptr = NULL;
p->calls->queue_control(p->chan_pvt, subclass);
}
- f.subclass = subclass;
+ f.subclass.integer = subclass;
pri_queue_frame(p, &f, pri);
}
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_ANSWER:
/* Launch the PBX */
ast_copy_string(chan->exten, pvt->pri->idleext, sizeof(chan->exten));
} else {
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_HOLD;
+ f.subclass.integer = AST_CONTROL_HOLD;
ast_queue_frame(owner, &f);
retval = 0;
}
{
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_UNHOLD;
+ f.subclass.integer = AST_CONTROL_UNHOLD;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
sig_pri_unlock_private(pri->pvts[chanpos]);
int i;
for (i = 0; i < digitlen; i++) {
- struct ast_frame f = { AST_FRAME_DTMF, e->digit.digits[i], };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = e->digit.digits[i], };
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
int i;
for (i = 0; i < digitlen; i++) {
- struct ast_frame f = { AST_FRAME_DTMF, e->ring.callednum[i], };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = e->ring.callednum[i], };
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
|| (e->proceeding.progress == 8)
#endif
) {
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_PROGRESS, };
if (e->proceeding.cause > -1) {
ast_verb(3, "PROGRESS with cause code %d received\n", e->proceeding.cause);
ast_verb(3, "PROGRESS with 'user busy' received, signaling AST_CONTROL_BUSY instead of AST_CONTROL_PROGRESS\n");
pri->pvts[chanpos]->owner->hangupcause = e->proceeding.cause;
- f.subclass = AST_CONTROL_BUSY;
+ f.subclass.integer = AST_CONTROL_BUSY;
}
}
}
#endif
) {
/* Bring voice path up */
- f.subclass = AST_CONTROL_PROGRESS;
+ f.subclass.integer = AST_CONTROL_PROGRESS;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
pri->pvts[chanpos]->progress = 1;
sig_pri_handle_subcmds(pri, chanpos, e->e, e->proceeding.channel,
e->proceeding.subcmds, e->proceeding.call);
if (!pri->pvts[chanpos]->proceeding) {
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_PROCEEDING, };
ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
#endif
) {
/* Bring voice path up */
- f.subclass = AST_CONTROL_PROGRESS;
+ f.subclass.integer = AST_CONTROL_PROGRESS;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
pri->pvts[chanpos]->proceeding = 1;
if (!pri->discardremoteholdretrieval) {
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_HOLD;
+ f.subclass.integer = AST_CONTROL_HOLD;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
break;
if (!pri->discardremoteholdretrieval) {
struct ast_frame f = { AST_FRAME_CONTROL, };
- f.subclass = AST_CONTROL_UNHOLD;
+ f.subclass.integer = AST_CONTROL_UNHOLD;
pri_queue_frame(pri->pvts[chanpos], &f, pri);
}
break;
{
struct codec_dahdi_pvt *dahdip = pvt->pvt;
- if (!f->subclass) {
+ if (!f->subclass.codec) {
/* We're just faking a return for calculation purposes. */
dahdip->fake = 2;
pvt->samples = f->samples;
if (2 == dahdip->fake) {
dahdip->fake = 1;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 0;
+ pvt->f.subclass.codec = 0;
pvt->f.samples = dahdip->required_samples;
pvt->f.data.ptr = NULL;
pvt->f.offset = 0;
pvt->f.datalen = res;
pvt->f.samples = dahdip->required_samples;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 1 << (pvt->t->dstfmt);
+ pvt->f.subclass.codec = 1 << (pvt->t->dstfmt);
pvt->f.mallocd = 0;
pvt->f.offset = AST_FRIENDLY_OFFSET;
pvt->f.src = pvt->t->name;
{
struct codec_dahdi_pvt *dahdip = pvt->pvt;
- if (!f->subclass) {
+ if (!f->subclass.codec) {
/* We're just faking a return for calculation purposes. */
dahdip->fake = 2;
pvt->samples = f->samples;
if (2 == dahdip->fake) {
dahdip->fake = 1;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 0;
+ pvt->f.subclass.codec = 0;
pvt->f.samples = dahdip->required_samples;
pvt->f.data.ptr = NULL;
pvt->f.offset = 0;
}
pvt->datalen = 0;
pvt->f.frametype = AST_FRAME_VOICE;
- pvt->f.subclass = 1 << (pvt->t->dstfmt);
+ pvt->f.subclass.codec = 1 << (pvt->t->dstfmt);
pvt->f.mallocd = 0;
pvt->f.offset = AST_FRIENDLY_OFFSET;
pvt->f.src = pvt->t->name;
.plc_samples = 160,
};
+static struct ast_translator testlawtolin = {
+ .name = "testlawtolin",
+ .srcfmt = AST_FORMAT_TESTLAW,
+ .dstfmt = AST_FORMAT_SLINEAR,
+ .framein = ulawtolin_framein,
+ .sample = ulaw_sample,
+ .buffer_samples = BUFFER_SAMPLES,
+ .buf_size = BUFFER_SAMPLES * 2,
+ .plc_samples = 160,
+};
+
/*!
* \brief The complete translator for LinToulaw.
*/
.buffer_samples = BUFFER_SAMPLES,
};
+static struct ast_translator lintotestlaw = {
+ .name = "lintotestlaw",
+ .srcfmt = AST_FORMAT_SLINEAR,
+ .dstfmt = AST_FORMAT_TESTLAW,
+ .framein = lintoulaw_framein,
+ .sample = slin8_sample,
+ .buf_size = BUFFER_SAMPLES,
+ .buffer_samples = BUFFER_SAMPLES,
+};
+
static int parse_config(int reload)
{
struct ast_variable *var;
res = ast_unregister_translator(&lintoulaw);
res |= ast_unregister_translator(&ulawtolin);
+ res |= ast_unregister_translator(&testlawtolin);
+ res |= ast_unregister_translator(&lintotestlaw);
return res;
}
if (parse_config(0))
return AST_MODULE_LOAD_DECLINE;
res = ast_register_translator(&ulawtolin);
- if (!res)
+ if (!res) {
res = ast_register_translator(&lintoulaw);
- else
+ res |= ast_register_translator(&lintotestlaw);
+ res |= ast_register_translator(&testlawtolin);
+ } else
ast_unregister_translator(&ulawtolin);
if (res)
return AST_MODULE_LOAD_FAILURE;
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ADPCM,
+ .subclass.codec = AST_FORMAT_ADPCM,
.datalen = sizeof(ex_adpcm),
.samples = ARRAY_LEN(ex_adpcm) * 2,
.mallocd = 0,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ALAW,
+ .subclass.codec = AST_FORMAT_ALAW,
.datalen = sizeof(ex_alaw),
.samples = ARRAY_LEN(ex_alaw),
.mallocd = 0,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G722,
+ .subclass.codec = AST_FORMAT_G722,
.datalen = sizeof(ex_g722),
.samples = ARRAY_LEN(ex_g722),
.mallocd = 0,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G726,
+ .subclass.codec = AST_FORMAT_G726,
.datalen = sizeof(ex_g726),
.samples = ARRAY_LEN(ex_g726) * 2, /* 2 samples per byte */
.mallocd = 0,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_GSM,
+ .subclass.codec = AST_FORMAT_GSM,
.datalen = sizeof(ex_gsm),
/* All frames are 20 ms long */
.samples = GSM_SAMPLES,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ILBC,
+ .subclass.codec = AST_FORMAT_ILBC,
.datalen = sizeof(ex_ilbc),
/* All frames are 30 ms long */
.samples = ILBC_SAMPLES,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_LPC10,
+ .subclass.codec = AST_FORMAT_LPC10,
.datalen = sizeof(ex_lpc10),
/* All frames are 22 ms long (maybe a little more -- why did he choose
LPC10_SAMPLES_PER_FRAME sample frames anyway?? */
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SPEEX,
+ .subclass.codec = AST_FORMAT_SPEEX,
.datalen = sizeof(ex_speex),
/* All frames are 20 ms long */
.samples = SPEEX_SAMPLES,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_ULAW,
+ .subclass.codec = AST_FORMAT_ULAW,
.datalen = sizeof(ex_ulaw),
.samples = ARRAY_LEN(ex_ulaw),
.mallocd = 0,
#! /bin/sh
-# From configure.ac Revision: 226018 .
+# From configure.ac Revision: 227579 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6.
#
-for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl
+
+
+for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap ntohll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
+AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap ntohll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
# NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
# so that AC_CHECK_FUNCS can detect functions in that library.
--- /dev/null
+CODEC BIT EXPANSION
+-------------------
+
+The code base up to and including Asterisk 1.6.2 has a basic limit of 32 codecs
+recognizable, due to the use of a 32-bit integer for the codec bitmask. We
+have expanded the number of available codecs from 32 to 64, through the use of
+an immutable type, called format_t. This should make future expansion to even
+more bits more easily done.
+
+The design of this expansion has made some changes to the architecture of codecs
+in order to accomplish this task. I will attempt to enumerate them here.
+
+The initial set of 32-bits were allocated as the first 16 to audio codecs, the
+next 8 to video codecs, and the remaining to text codecs (which are used for
+fax capabilities). Initially, there is an assumption in the code that all
+audio codecs are contiguous, followed by a contiguous set of video codecs.
+After the conversion, this assumption will no longer be true. The codec bits
+for the existing codecs will continue to be allocated as-is, and the additional
+codec bits should be allocated on an as-needed basis, with audio codecs
+occupying slots 32-47 and video codecs occupying slots 48-62 (with a 0-based
+offset). Slot 63 is reserved and should not be allocated; it is used in code
+as an end condition for iterating through the entire set of codecs.
+
+The frame structure has been altered. Initially, the subclass held an integer
+whose meaning was specified by the frametype. If the frametype was
+AST_FRAME_VOICE, the subclass specified the audio codec. If the frametype was
+AST_FRAME_VIDEO, the subclass specified the video codec, with the 0-bit set to
+specify a key frame. This was done with a union on the subclass, where the
+"integer" union member specifies the traditional 32-bit subclass and the "codec"
+union member specifies the new 64-bit codec bitmask. This additionally
+guarantees that code compiled under the old scheme will need to be altered to
+compile under the new scheme, which helps avoid incorrect assumptions about the
+state of code which might otherwise compile without errors.
+
+The IAX2 code initially used a 32-bit integer IE to specify both the codec as
+well as the preferred format. An additional IE has been added, which specifies
+a single byte version number as the initial part of the data. This version
+number is initially specified as 00 and requires 8 bytes to follow, specifying
+the 64-bit codec bitmask, in network-byte order. This schema should allow
+further codec expansion in the future without allocation of any additional IEs.
+
+Little changes are required to support further codec expansion in the future,
+though the majority of the work has already been accomplished. Specifically,
+the bitwise operations that are immutable operations in the gcc compiler will
+need to be altered to handle larger bitmasks. Additionally, the constants that
+define specific codecs will need to be changed from integers to structures.
+
}
/* Read the data into the buffer */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_G723_1;
+ s->fr.subclass.codec = AST_FORMAT_G723_1;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != size) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_G723_1) {
+ if (f->subclass.codec != AST_FORMAT_G723_1) {
ast_log(LOG_WARNING, "Asked to write non-g723 frame!\n");
return -1;
}
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_G726;
+ s->fr.subclass.codec = AST_FORMAT_G726;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
s->fr.samples = 8 * FRAME_TIME;
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_G726) {
- ast_log(LOG_WARNING, "Asked to write non-G726 frame (%d)!\n",
- f->subclass);
+ if (f->subclass.codec != AST_FORMAT_G726) {
+ ast_log(LOG_WARNING, "Asked to write non-G726 frame (%s)!\n",
+ ast_getformatname(f->subclass.codec));
return -1;
}
if (f->datalen % frame_size[fs->rate]) {
int res;
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_G729A;
+ s->fr.subclass.codec = AST_FORMAT_G729A;
s->fr.mallocd = 0;
s->fr.samples = G729A_SAMPLES;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_G729A) {
- ast_log(LOG_WARNING, "Asked to write non-G729 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_G729A) {
+ ast_log(LOG_WARNING, "Asked to write non-G729 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (f->datalen % 10) {
int res;
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_GSM;
+ s->fr.subclass.codec = AST_FORMAT_GSM;
AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
s->fr.mallocd = 0;
if ((res = fread(s->fr.data.ptr, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_GSM) {
- ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_GSM) {
+ ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (!(f->datalen % 65)) {
static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
{
int res;
- int mark;
+ format_t mark;
unsigned short len;
unsigned int ts;
struct h263_desc *fs = (struct h263_desc *)s->_private;
return NULL;
}
s->fr.frametype = AST_FRAME_VIDEO;
- s->fr.subclass = AST_FORMAT_H263;
+ s->fr.subclass.codec = AST_FORMAT_H263;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
}
s->fr.samples = fs->lastts; /* XXX what ? */
s->fr.datalen = len;
- s->fr.subclass |= mark;
+ s->fr.subclass.codec |= mark;
s->fr.delivery.tv_sec = 0;
s->fr.delivery.tv_usec = 0;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
int res;
unsigned int ts;
unsigned short len;
- int subclass;
- int mark=0;
+ format_t subclass;
+ format_t mark=0;
if (f->frametype != AST_FRAME_VIDEO) {
ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
return -1;
}
- subclass = f->subclass;
+ subclass = f->subclass.codec;
if (subclass & 0x1)
mark=0x8000;
subclass &= ~0x1;
if (subclass != AST_FORMAT_H263) {
- ast_log(LOG_WARNING, "Asked to write non-h263 frame (%d)!\n", f->subclass);
+ ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
ts = htonl(f->samples);
len = BUF_SIZE; /* XXX truncate */
}
s->fr.frametype = AST_FRAME_VIDEO;
- s->fr.subclass = AST_FORMAT_H264;
+ s->fr.subclass.codec = AST_FORMAT_H264;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
}
s->fr.samples = fs->lastts;
s->fr.datalen = len;
- s->fr.subclass |= mark;
+ s->fr.subclass.codec |= mark;
s->fr.delivery.tv_sec = 0;
s->fr.delivery.tv_usec = 0;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
return -1;
}
- mark = (f->subclass & 0x1) ? 0x8000 : 0;
- if ((f->subclass & ~0x1) != AST_FORMAT_H264) {
- ast_log(LOG_WARNING, "Asked to write non-h264 frame (%d)!\n", f->subclass);
+ mark = (f->subclass.codec & 0x1) ? 0x8000 : 0;
+ if ((f->subclass.codec & ~0x1) != AST_FORMAT_H264) {
+ ast_log(LOG_WARNING, "Asked to write non-h264 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
ts = htonl(f->samples);
int res;
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_ILBC;
+ s->fr.subclass.codec = AST_FORMAT_ILBC;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_ILBC) {
- ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_ILBC) {
+ ast_log(LOG_WARNING, "Asked to write non-iLBC frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (f->datalen % 50) {
}
memset(&fr, 0, sizeof(fr));
fr.frametype = AST_FRAME_IMAGE;
- fr.subclass = AST_FORMAT_JPEG;
+ fr.subclass.codec = AST_FORMAT_JPEG;
fr.data.ptr = buf;
fr.src = "JPEG Read";
fr.datalen = len;
ast_log(LOG_WARNING, "Not an image\n");
return -1;
}
- if (fr->subclass != AST_FORMAT_JPEG) {
+ if (fr->subclass.codec != AST_FORMAT_JPEG) {
ast_log(LOG_WARNING, "Not a jpeg image\n");
return -1;
}
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n",
- f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%s)!\n",
+ ast_getformatname(f->subclass.codec));
return -1;
}
if (!f->datalen)
short *buf; /* SLIN data buffer */
fs->fr.frametype = AST_FRAME_VOICE;
- fs->fr.subclass = AST_FORMAT_SLINEAR;
+ fs->fr.subclass.codec = AST_FORMAT_SLINEAR;
fs->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
buf = (short *)(fs->fr.data.ptr); /* SLIN data buffer */
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = s->fmt->format;
+ s->fr.subclass.codec = s->fmt->format;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != fs->fmt->format) {
- ast_log(LOG_WARNING, "Asked to write incompatible format frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != fs->fmt->format) {
+ ast_log(LOG_WARNING, "Asked to write incompatible format frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SIREN14;
+ s->fr.subclass.codec = AST_FORMAT_SIREN14;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SIREN14) {
- ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SIREN14) {
+ ast_log(LOG_WARNING, "Asked to write non-Siren14 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SIREN7;
+ s->fr.subclass.codec = AST_FORMAT_SIREN7;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SIREN7) {
- ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SIREN7) {
+ ast_log(LOG_WARNING, "Asked to write non-Siren7 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SLINEAR;
+ s->fr.subclass.codec = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-slinear frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-slinear frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SLINEAR16;
+ s->fr.subclass.codec = AST_FORMAT_SLINEAR16;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR16) {
- ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR16) {
+ ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
/* Send a frame from the file to the appropriate channel */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_ADPCM;
+ s->fr.subclass.codec = AST_FORMAT_ADPCM;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_ADPCM) {
- ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_ADPCM) {
+ ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) {
bytes = 0;
/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_SLINEAR;
+ s->fr.subclass.codec = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
if (!f->datalen)
struct wavg_desc *fs = (struct wavg_desc *)s->_private;
s->fr.frametype = AST_FRAME_VOICE;
- s->fr.subclass = AST_FORMAT_GSM;
+ s->fr.subclass.codec = AST_FORMAT_GSM;
s->fr.offset = AST_FRIENDLY_OFFSET;
s->fr.samples = GSM_SAMPLES;
s->fr.mallocd = 0;
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if (f->subclass != AST_FORMAT_GSM) {
- ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
+ if (f->subclass.codec != AST_FORMAT_GSM) {
+ ast_log(LOG_WARNING, "Asked to write non-GSM frame (%s)!\n", ast_getformatname(f->subclass.codec));
return -1;
}
/* XXX this might fail... if the input is a multiple of MSGSM_FRAME_SIZE
/* Only use DTMF coming from the source... not going to it */
if (direction != AST_AUDIOHOOK_DIRECTION_READ)
return 0;
- if (frame->subclass == '*') {
+ if (frame->subclass.integer == '*') {
vi->tx_gain += 1;
vi->rx_gain += 1;
- } else if (frame->subclass == '#') {
+ } else if (frame->subclass.integer == '#') {
vi->tx_gain -= 1;
vi->rx_gain -= 1;
}
#include <sys/time.h>
+#include "asterisk/frame_defs.h"
+
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
/*! \brief The time the next frame should be played. */
long next;
/*! \brief Voice format of the last frame in. */
- int last_format;
+ format_t last_format;
/*! \brief File for frame timestamp tracing. */
FILE *logfile;
/*! \brief Jitterbuffer internal state flags. */
/* these two are used in struct ast_audiohook */
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
-
+#include "asterisk/frame_defs.h"
#include "asterisk/slinfactory.h"
enum ast_audiohook_type {
* \param format Format of frame remote side wants back
* \return Returns frame on success, NULL on failure
*/
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format);
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format);
/*! \brief Attach audiohook to channel
* \param chan Channel
/* Define to the version of the Hoard Memory Allocator library. */
#undef HAVE_HOARD_VERSION
+/* Define to 1 if you have the `htonll' function. */
+#undef HAVE_HTONLL
+
/* Define to 1 if you have the ical libraries library. */
#undef HAVE_ICAL
/* Define to the version of the newt library. */
#undef HAVE_NEWT_VERSION
+/* Define to 1 if you have the `ntohll' function. */
+#undef HAVE_NTOHLL
+
/* Define to 1 if your ODBC library has wide (Unicode) types. */
#undef HAVE_ODBC_WCHAR
* This creates a simple two party bridge that will be destroyed once one of
* the channels hangs up.
*/
-struct ast_bridge *ast_bridge_new(int capabilities, int flags);
+struct ast_bridge *ast_bridge_new(format_t capabilities, int flags);
/*! \brief See if it is possible to create a bridge
*
* This sees if it is possible to create a bridge capable of bridging two channels
* together.
*/
-int ast_bridge_check(int capabilities);
+int ast_bridge_check(format_t capabilities);
/*! \brief Destroy a bridge
*
/*! Unique name to this bridge technology */
const char *name;
/*! The capabilities that this bridge technology is capable of */
- int capabilities;
+ format_t capabilities;
/*! Preference level that should be used when determining whether to use this bridge technology or not */
enum ast_bridge_preference preference;
/*! Callback for when a bridge is being created */
/*! Callback for poking a bridge thread */
int (*poke)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
/*! Formats that the bridge technology supports */
- int formats;
+ format_t formats;
/*! Bit to indicate whether the bridge technology is currently suspended or not */
unsigned int suspended:1;
/*! Module this bridge technology belongs to. Is used for reference counting when creating/destroying a bridge. */
const char * const type;
const char * const description;
- int capabilities; /*!< Bitmap of formats this channel can handle */
+ format_t capabilities; /*!< Bitmap of formats this channel can handle */
- int properties; /*!< Technology Properties */
+ int properties; /*!< Technology Properties */
/*! \brief Requester - to set up call data structures (pvt's) */
- struct ast_channel *(* const requester)(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause);
+ struct ast_channel *(* const requester)(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause);
int (* const devicestate)(void *data); /*!< Devicestate call back */
int fdno; /*!< Which fd had an event detected on */
int streamid; /*!< For streaming playback, the schedule ID */
int vstreamid; /*!< For streaming video playback, the schedule ID */
- int oldwriteformat; /*!< Original writer format */
+ format_t oldwriteformat; /*!< Original writer format */
int timingfd; /*!< Timing fd */
enum ast_channel_state _state; /*!< State of line -- Don't write directly, use ast_setstate() */
int rings; /*!< Number of rings so far */
int hangupcause; /*!< Why is the channel hanged up. See causes.h */
unsigned int flags; /*!< channel flags of AST_FLAG_ type */
int alertpipe[2];
- int nativeformats; /*!< Kinds of data this channel can natively handle */
- int readformat; /*!< Requested read format */
- int writeformat; /*!< Requested write format */
- int rawreadformat; /*!< Raw read format */
- int rawwriteformat; /*!< Raw write format */
+ format_t nativeformats; /*!< Kinds of data this channel can natively handle */
+ format_t readformat; /*!< Requested read format */
+ format_t writeformat; /*!< Requested write format */
+ format_t rawreadformat; /*!< Raw read format */
+ format_t rawwriteformat; /*!< Raw write format */
unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
#ifdef HAVE_EPOLL
int epfd;
* \retval NULL failure
* \retval non-NULL channel on success
*/
-struct ast_channel *ast_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *status);
+struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status);
/*!
* \brief Request a channel of a given type, with data as optional information used
* \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
* to know if the call was answered or not.
*/
-struct ast_channel *ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data,
+struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
int timeout, int *reason, const char *cid_num, const char *cid_name);
/*!
* \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state
* to know if the call was answered or not.
*/
-struct ast_channel *__ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data,
+struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data,
int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh);
/*!
* \param outstate reason why unsuccessful (if uncuccessful)
* \return Returns the forwarded call's ast_channel on success or NULL on failure
*/
-struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate);
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate);
/*!
* \brief Register a channel technology (a new channel driver)
* \param format format to change to
* \return Returns 0 on success, -1 on failure
*/
-int ast_set_read_format(struct ast_channel *chan, int format);
+int ast_set_read_format(struct ast_channel *chan, format_t format);
/*!
* \brief Sets write format on channel chan
* \param format new format for writing
* \return Returns 0 on success, -1 on failure
*/
-int ast_set_write_format(struct ast_channel *chan, int format);
+int ast_set_write_format(struct ast_channel *chan, format_t format);
/*!
* \brief Sends text to a channel
/*! Pick the best codec
* Choose the best codec... Uhhh... Yah. */
-int ast_best_codec(int fmts);
+format_t ast_best_codec(format_t fmts);
/*!
int getloadavg(double *list, int nelem);
#endif
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64);
+#endif
+
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64);
+#endif
+
#ifndef HAVE_SETENV
int setenv(const char *name, const char *value, int overwrite);
#endif
#include <sys/time.h>
+#include "asterisk/frame_defs.h"
#include "asterisk/endian.h"
#include "asterisk/linkedlists.h"
struct ast_codec_pref {
- char order[32];
- char framing[32];
+ char order[sizeof(format_t) * 8];
+ char framing[sizeof(format_t) * 8];
};
/*!
/*! Kind of frame */
enum ast_frame_type frametype;
/*! Subclass, frame dependent */
- int subclass;
+ union {
+ int integer;
+ format_t codec;
+ } subclass;
/*! Length of data */
int datalen;
/*! Number of samples in this frame */
/* Data formats for capabilities and frames alike */
/*! G.723.1 compression */
-#define AST_FORMAT_G723_1 (1 << 0)
+#define AST_FORMAT_G723_1 (1ULL << 0)
/*! GSM compression */
-#define AST_FORMAT_GSM (1 << 1)
+#define AST_FORMAT_GSM (1ULL << 1)
/*! Raw mu-law data (G.711) */
-#define AST_FORMAT_ULAW (1 << 2)
+#define AST_FORMAT_ULAW (1ULL << 2)
/*! Raw A-law data (G.711) */
-#define AST_FORMAT_ALAW (1 << 3)
+#define AST_FORMAT_ALAW (1ULL << 3)
/*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
-#define AST_FORMAT_G726_AAL2 (1 << 4)
+#define AST_FORMAT_G726_AAL2 (1ULL << 4)
/*! ADPCM (IMA) */
-#define AST_FORMAT_ADPCM (1 << 5)
+#define AST_FORMAT_ADPCM (1ULL << 5)
/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
-#define AST_FORMAT_SLINEAR (1 << 6)
+#define AST_FORMAT_SLINEAR (1ULL << 6)
/*! LPC10, 180 samples/frame */
-#define AST_FORMAT_LPC10 (1 << 7)
+#define AST_FORMAT_LPC10 (1ULL << 7)
/*! G.729A audio */
-#define AST_FORMAT_G729A (1 << 8)
+#define AST_FORMAT_G729A (1ULL << 8)
/*! SpeeX Free Compression */
-#define AST_FORMAT_SPEEX (1 << 9)
+#define AST_FORMAT_SPEEX (1ULL << 9)
/*! iLBC Free Compression */
-#define AST_FORMAT_ILBC (1 << 10)
+#define AST_FORMAT_ILBC (1ULL << 10)
/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
-#define AST_FORMAT_G726 (1 << 11)
+#define AST_FORMAT_G726 (1ULL << 11)
/*! G.722 */
-#define AST_FORMAT_G722 (1 << 12)
+#define AST_FORMAT_G722 (1ULL << 12)
/*! G.722.1 (also known as Siren7, 32kbps assumed) */
-#define AST_FORMAT_SIREN7 (1 << 13)
+#define AST_FORMAT_SIREN7 (1ULL << 13)
/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
-#define AST_FORMAT_SIREN14 (1 << 14)
+#define AST_FORMAT_SIREN14 (1ULL << 14)
/*! Raw 16-bit Signed Linear (16000 Hz) PCM */
-#define AST_FORMAT_SLINEAR16 (1 << 15)
+#define AST_FORMAT_SLINEAR16 (1ULL << 15)
/*! Maximum audio mask */
-#define AST_FORMAT_AUDIO_MASK ((1 << 16)-1)
+#define AST_FORMAT_AUDIO_MASK 0xFFFF0000FFFFULL
/*! JPEG Images */
-#define AST_FORMAT_JPEG (1 << 16)
+#define AST_FORMAT_JPEG (1ULL << 16)
/*! PNG Images */
-#define AST_FORMAT_PNG (1 << 17)
+#define AST_FORMAT_PNG (1ULL << 17)
/*! H.261 Video */
-#define AST_FORMAT_H261 (1 << 18)
+#define AST_FORMAT_H261 (1ULL << 18)
/*! H.263 Video */
-#define AST_FORMAT_H263 (1 << 19)
+#define AST_FORMAT_H263 (1ULL << 19)
/*! H.263+ Video */
-#define AST_FORMAT_H263_PLUS (1 << 20)
+#define AST_FORMAT_H263_PLUS (1ULL << 20)
/*! H.264 Video */
-#define AST_FORMAT_H264 (1 << 21)
+#define AST_FORMAT_H264 (1ULL << 21)
/*! MPEG4 Video */
-#define AST_FORMAT_MP4_VIDEO (1 << 22)
-#define AST_FORMAT_VIDEO_MASK (((1 << 25)-1) & ~(AST_FORMAT_AUDIO_MASK))
+#define AST_FORMAT_MP4_VIDEO (1ULL << 22)
+#define AST_FORMAT_VIDEO_MASK ((((1ULL << 25)-1) & ~(AST_FORMAT_AUDIO_MASK)) | 0x7FFF000000000000ULL)
/*! T.140 RED Text format RFC 4103 */
-#define AST_FORMAT_T140RED (1 << 26)
+#define AST_FORMAT_T140RED (1ULL << 26)
/*! T.140 Text format - ITU T.140, RFC 4103 */
-#define AST_FORMAT_T140 (1 << 27)
+#define AST_FORMAT_T140 (1ULL << 27)
/*! Maximum text mask */
-#define AST_FORMAT_MAX_TEXT (1 << 28))
-#define AST_FORMAT_TEXT_MASK (((1 << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
+#define AST_FORMAT_MAX_TEXT (1ULL << 28)
+#define AST_FORMAT_TEXT_MASK (((1ULL << 30)-1) & ~(AST_FORMAT_AUDIO_MASK) & ~(AST_FORMAT_VIDEO_MASK))
+/*! Raw mu-law data (G.711) */
+#define AST_FORMAT_TESTLAW (1ULL << 47)
+/*! Reserved bit - do not use */
+#define AST_FORMAT_RESERVED (1ULL << 63)
enum ast_control_frame_type {
AST_CONTROL_HANGUP = 1, /*!< Other end has hungup */
/*! \brief Definition of supported media formats (codecs) */
struct ast_format_list {
- int bits; /*!< bitmask value */
+ format_t bits; /*!< bitmask value */
char *name; /*!< short name */
int samplespersecond; /*!< Number of samples per second (8000/16000) */
char *desc; /*!< Description */
* \param format id of format
* \return A static string containing the name of the format or "unknown" if unknown.
*/
-char* ast_getformatname(int format);
+char* ast_getformatname(format_t format);
/*! \brief Get the names of a set of formats
* \param buf a buffer for the output string
* ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
* \return The return value is buf.
*/
-char* ast_getformatname_multiple(char *buf, size_t size, int format);
+char* ast_getformatname_multiple(char *buf, size_t size, format_t format);
/*!
* \brief Gets a format from a name.
* \param name string of format
* \return This returns the form of the format in binary on success, 0 on error.
*/
-int ast_getformatbyname(const char *name);
+format_t ast_getformatbyname(const char *name);
/*! \brief Get a name from a format
* Gets a name from a format
* \param codec codec number (1,2,4,8,16,etc.)
* \return This returns a static string identifying the format on success, 0 on error.
*/
-char *ast_codec2str(int codec);
+char *ast_codec2str(format_t codec);
/*! \name AST_Smoother
*/
* \brief Codec located at a particular place in the preference index.
* \arg \ref AudioCodecPref
*/
-int ast_codec_pref_index(struct ast_codec_pref *pref, int index);
+format_t ast_codec_pref_index(struct ast_codec_pref *pref, int index);
/*! \brief Remove audio a codec from a preference list */
-void ast_codec_pref_remove(struct ast_codec_pref *pref, int format);
+void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format);
/*! \brief Append a audio codec to a preference list, removing it first if it was already there
*/
-int ast_codec_pref_append(struct ast_codec_pref *pref, int format);
+int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format);
/*! \brief Prepend an audio codec to a preference list, removing it first if it was already there
*/
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing);
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing);
/*! \brief Select the best audio format according to preference list from supplied options.
If "find_best" is non-zero then if nothing is found, the "Best" format of
the format list is selected, otherwise 0 is returned. */
-int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best);
+format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best);
/*! \brief Set packet size for codec
*/
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems);
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems);
/*! \brief Get packet size for codec
*/
-struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format);
+struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format);
/*! \brief Parse an "allow" or "deny" line in a channel or device configuration
and update the capabilities mask and pref if provided.
Video codecs are not added to codec preference lists, since we can not transcode
\return Returns number of errors encountered during parsing
*/
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing);
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing);
/*! \brief Dump audio codec preference list into a string */
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size);
int ast_codec_get_samples(struct ast_frame *f);
/*! \brief Returns the number of bytes for the number of samples of the given format */
-int ast_codec_get_len(int format, int samples);
+int ast_codec_get_len(format_t format, int samples);
/*! \brief Appends a frame to the end of a list of frames, truncating the maximum length of the list */
struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe);
/*! \brief Gets duration in ms of interpolation frame for a format */
-static inline int ast_codec_interp_len(int format)
+static inline int ast_codec_interp_len(format_t format)
{
return (format == AST_FORMAT_ILBC) ? 30 : 20;
}
/*!
* \brief Get the sample rate for a given format.
*/
-static force_inline int ast_format_rate(int format)
+static force_inline int ast_format_rate(format_t format)
{
switch (format) {
case AST_FORMAT_G722:
--- /dev/null
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2009, Digium, Inc.
+ *
+ * Mark Spencer <markster@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Asterisk internal frame definitions.
+ * \arg For an explanation of frames, see \ref Def_Frame
+ * \arg Frames are send of Asterisk channels, see \ref Def_Channel
+ */
+
+#ifndef _ASTERISK_FRAME_DEFS_H
+#define _ASTERISK_FRAME_DEFS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+typedef int64_t format_t;
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_FRAME_DEFS_H */
/*! Synchronously or asynchronously make an outbound call and send it to a
particular extension */
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
/*! Synchronously or asynchronously make an outbound call and send it to a
particular application with given extension */
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
/*!
* \brief Evaluate a condition
/*! Is this an Asterisk value */
int asterisk_format;
/*! Actual internal value of the payload */
- int code;
+ format_t code;
};
/*! Structure that represents statistics from an RTP instance */
/*! Callback for setting an RTP property */
void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
/*! Callback for setting a payload */
- void (*payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, int format);
+ void (*payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, format_t format);
/*! Callback for setting packetization preferences */
void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
/*! Callback for setting the remote address that RTP is to be sent to */
/*! Callback to locally bridge two RTP instances */
int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
/*! Callback to set the read format */
- int (*set_read_format)(struct ast_rtp_instance *instance, int format);
+ int (*set_read_format)(struct ast_rtp_instance *instance, format_t format);
/*! Callback to set the write format */
- int (*set_write_format)(struct ast_rtp_instance *instance, int format);
+ int (*set_write_format)(struct ast_rtp_instance *instance, format_t format);
/*! Callback to make two instances compatible */
int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
/*! Callback to see if two instances are compatible with DTMF */
*/
enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
/*! Callback for updating the destination that the remote side should send RTP to */
- int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active);
+ int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active);
/*! Callback for retrieving codecs that the channel can do */
- int (*get_codec)(struct ast_channel *chan);
+ format_t (*get_codec)(struct ast_channel *chan);
/*! Linked list information */
AST_RWLIST_ENTRY(ast_rtp_glue) entry;
};
*
* \since 1.6.3
*/
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code);
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code);
/*!
* \brief Retrieve all formats that were found
*
* \since 1.6.3
*/
-void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astformats, int *nonastformats);
+void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats);
/*!
* \brief Retrieve a payload based on whether it is an Asterisk format and the code
*
* \since 1.6.3
*/
-int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const int code);
+int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code);
/*!
* \brief Retrieve mime subtype information on a payload
*
* \since 1.6.3
*/
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int code, enum ast_rtp_options options);
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options);
/*!
* \brief Convert formats into a string and put them into a buffer
*
* \since 1.6.3
*/
-char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const int capability, const int asterisk_format, enum ast_rtp_options options);
+char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options);
/*!
* \brief Set codec packetization preferences
*
* \since 1.6.3
*/
-int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, int format);
+int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format);
/*!
* \brief Tell underlying RTP engine that audio frames will be provided in a specific format
*
* \since 1.6.3
*/
-int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, int format);
+int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format);
/*!
* \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
*
* \since 1.6.3
*/
-int ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
+format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
/*!
* \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.datalen = sizeof(ex_slin8),
.samples = ARRAY_LEN(ex_slin8) / 2,
.mallocd = 0,
{
static struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR16,
+ .subclass.codec = AST_FORMAT_SLINEAR16,
.datalen = sizeof(ex_slin16),
.samples = ARRAY_LEN(ex_slin16) / 2,
.mallocd = 0,
short *offset; /*!< Offset into the hold where audio begins */
size_t holdlen; /*!< Number of samples currently in the hold */
unsigned int size; /*!< Number of samples currently in the factory */
- unsigned int format; /*!< Current format the translation path is converting from */
- unsigned int output_format; /*!< The output format desired */
+ format_t format; /*!< Current format the translation path is converting from */
+ format_t output_format; /*!< The output format desired */
};
/*!
#ifndef _ASTERISK_TRANSLATE_H
#define _ASTERISK_TRANSLATE_H
-#define MAX_AUDIO_FORMAT 15 /* Do not include video here */
-#define MAX_FORMAT 32 /* Do include video here */
+#define MAX_AUDIO_FORMAT 47 /* Do not include video here */
+#define MAX_FORMAT 64 /* Do include video here */
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
* Generic plc is only available for dstfmt = SLINEAR
*/
struct ast_translator {
- const char name[80]; /*!< Name of translator */
- int srcfmt; /*!< Source format (note: bit position,
- converted to index during registration) */
- int dstfmt; /*!< Destination format (note: bit position,
- converted to index during registration) */
+ const char name[80]; /*!< Name of translator */
+ format_t srcfmt; /*!< Source format (note: bit position,
+ * converted to index during registration) */
+ format_t dstfmt; /*!< Destination format (note: bit position,
+ * converted to index during registration) */
int (*newpvt)(struct ast_trans_pvt *); /*!< initialize private data
- associated with the translator */
+ * associated with the translator */
int (*framein)(struct ast_trans_pvt *pvt, struct ast_frame *in);
- /*!< Input frame callback. Store
- (and possibly convert) input frame. */
+ /*!< Input frame callback. Store
+ * (and possibly convert) input frame. */
struct ast_frame * (*frameout)(struct ast_trans_pvt *pvt);
- /*!< Output frame callback. Generate a frame
- with outbuf content. */
+ /*!< Output frame callback. Generate a frame
+ * with outbuf content. */
void (*destroy)(struct ast_trans_pvt *pvt);
- /*!< cleanup private data, if needed
- (often unnecessary). */
+ /*!< cleanup private data, if needed
+ * (often unnecessary). */
- struct ast_frame * (*sample)(void); /*!< Generate an example frame */
+ struct ast_frame * (*sample)(void); /*!< Generate an example frame */
- /*! \brief size of outbuf, in samples. Leave it 0 if you want the framein
+ /*!\brief size of outbuf, in samples. Leave it 0 if you want the framein
* callback deal with the frame. Set it appropriately if you
* want the code to checks if the incoming frame fits the
* outbuf (this is e.g. required for plc).
*/
- int buffer_samples; /*< size of outbuf, in samples */
+ int buffer_samples; /*< size of outbuf, in samples */
/*! \brief size of outbuf, in bytes. Mandatory. The wrapper code will also
* allocate an AST_FRIENDLY_OFFSET space before.
*/
int buf_size;
- int desc_size; /*!< size of private descriptor in pvt->pvt, if any */
- int plc_samples; /*!< set to the plc block size if used, 0 otherwise */
- int useplc; /*!< current status of plc, changed at runtime */
- int native_plc; /*!< true if the translator can do native plc */
+ int desc_size; /*!< size of private descriptor in pvt->pvt, if any */
+ int plc_samples; /*!< set to the plc block size if used, 0 otherwise */
+ int useplc; /*!< current status of plc, changed at runtime */
+ int native_plc; /*!< true if the translator can do native plc */
- struct ast_module *module; /* opaque reference to the parent module */
+ struct ast_module *module; /*!< opaque reference to the parent module */
- int cost; /*!< Cost in milliseconds for encoding/decoding 1 second of sound */
- int active; /*!< Whether this translator should be used or not */
- AST_LIST_ENTRY(ast_translator) list; /*!< link field */
+ int cost; /*!< Cost in milliseconds for encoding/decoding 1 second of sound */
+ int active; /*!< Whether this translator should be used or not */
+ AST_LIST_ENTRY(ast_translator) list; /*!< link field */
};
/*! \brief
* \return Returns 0 on success, -1 if no path could be found.
* \note Modifies dests and srcs in place
*/
-int ast_translator_best_choice(int *dsts, int *srcs);
+format_t ast_translator_best_choice(format_t *dsts, format_t *srcs);
/*!
* \brief Builds a translator path
* \param source source format
* \return ast_trans_pvt on success, NULL on failure
* */
-struct ast_trans_pvt *ast_translator_build_path(int dest, int source);
+struct ast_trans_pvt *ast_translator_build_path(format_t dest, format_t source);
/*!
* \brief Frees a translator path
* \param src source format
* \return the number of translation steps required, or -1 if no path is available
*/
-unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src);
+unsigned int ast_translate_path_steps(format_t dest, format_t src);
/*!
* \brief Mask off unavailable formats from a format bitmask
* \note Only a single audio format and a single video format can be
* present in 'src', or the function will produce unexpected results.
*/
-unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src);
+format_t ast_translate_available_formats(format_t dest, format_t src);
#if defined(__cplusplus) || defined(c_plusplus)
}
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2009, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
#ifdef __GNUC__
/* If we just tell GCC what's going on, we can trust it to behave optimally */
+static inline uint64_t get_unaligned_uint64(const void *p)
+{
+ const struct { uint64_t d; } __attribute__((packed)) *pp = p;
+ return pp->d;
+}
+
static inline unsigned int get_unaligned_uint32(const void *p)
{
const struct { unsigned int d; } __attribute__((packed)) *pp = p;
return pp->d;
}
+static inline void put_unaligned_uint64(void *p, uint64_t datum)
+{
+ struct { uint64_t d; } __attribute__((packed)) *pp = p;
+
+ pp->d = datum;
+}
+
static inline void put_unaligned_uint32(void *p, unsigned int datum)
{
struct { unsigned int d; } __attribute__((packed)) *pp = p;
pp->d = datum;
}
#elif defined(SOLARIS) && defined(__sparc__)
+static inline uint64_t get_unaligned_uint64(const void *p)
+{
+ const unsigned char *cp = p;
+
+ return
+ (((uint64_t) cp[0]) << 56) |
+ (((uint64_t) cp[1]) << 48) |
+ (((uint64_t) cp[2]) << 40) |
+ (((uint64_t) cp[3]) << 32) |
+ (((uint64_t) cp[4]) << 24) |
+ (((uint64_t) cp[5]) << 16) |
+ (((uint64_t) cp[6]) << 8) |
+ (((uint64_t) cp[7]) << 0);
+}
+
static inline unsigned int get_unaligned_uint32(const void *p)
{
const unsigned char *cp = p;
return (cp[0] << 8) | cp[1] ;
}
+static inline void put_unaligned_uint64(void *p, uint64_t datum)
+{
+ unsigned char *cp = p;
+
+ cp[0] = (datum >> 56) & 0xff;
+ cp[1] = (datum >> 48) & 0xff;
+ cp[2] = (datum >> 40) & 0xff;
+ cp[3] = (datum >> 32) & 0xff;
+ cp[4] = (datum >> 24) & 0xff;
+ cp[5] = (datum >> 16) & 0xff;
+ cp[6] = (datum >> 8) & 0xff;
+ cp[7] = (datum >> 0) & 0xff;
+}
+
static inline void put_unaligned_uint32(void *p, unsigned int datum)
{
unsigned char *cp = p;
cp[1] = datum;
}
#else /* Not GCC, not Solaris/SPARC. Assume we can handle direct load/store. */
+#define get_unaligned_uint64(p) (*((uint64_t *)(p)))
#define get_unaligned_uint32(p) (*((unsigned int *)(p)))
#define get_unaligned_uint16(p) (*((unsigned short *)(p)))
+#define put_unaligned_uint64(p,d) do { uint64_t *__P = (p); *__P = d; } while(0)
#define put_unaligned_uint32(p,d) do { unsigned int *__P = (p); *__P = d; } while(0)
#define put_unaligned_uint16(p,d) do { unsigned short *__P = (p); *__P = d; } while(0)
#endif
case JB_IMPL_DROP:
jb_framelog("\tJB_GET {now=%ld}: %s frame with ts=%ld and len=%ld\n",
now, jb_get_actions[res], f->ts, f->len);
- jb->last_format = f->subclass;
+ jb->last_format = f->subclass.codec;
ast_frfree(f);
break;
case JB_IMPL_INTERP:
/* interpolate a frame */
f = &finterp;
f->frametype = AST_FRAME_VOICE;
- f->subclass = jb->last_format;
+ f->subclass.codec = jb->last_format;
f->datalen = 0;
f->samples = interpolation_len * 8;
f->mallocd = 0;
jb->next = jbimpl->next(jbobj);
/* Init last format for a first time. */
- jb->last_format = frr->subclass;
+ jb->last_format = frr->subclass.codec;
/* Create a frame log file */
if (ast_test_flag(jbconf, AST_JB_LOG)) {
struct linear_state *ls = data;
struct ast_frame f = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf + AST_FRIENDLY_OFFSET / 2,
.offset = AST_FRIENDLY_OFFSET,
};
} else if (f->frametype == AST_FRAME_DTMF) {
if (prepend) {
/* stop recording with any digit */
- ast_verb(3, "User ended message by pressing %c\n", f->subclass);
+ ast_verb(3, "User ended message by pressing %c\n", f->subclass.integer);
res = 't';
outmsg = 2;
break;
}
- if (strchr(acceptdtmf, f->subclass)) {
- ast_verb(3, "User ended message by pressing %c\n", f->subclass);
- res = f->subclass;
+ if (strchr(acceptdtmf, f->subclass.integer)) {
+ ast_verb(3, "User ended message by pressing %c\n", f->subclass.integer);
+ res = f->subclass.integer;
outmsg = 2;
break;
}
- if (strchr(canceldtmf, f->subclass)) {
- ast_verb(3, "User cancelled message by pressing %c\n", f->subclass);
- res = f->subclass;
+ if (strchr(canceldtmf, f->subclass.integer)) {
+ ast_verb(3, "User cancelled message by pressing %c\n", f->subclass.integer);
+ res = f->subclass.integer;
outmsg = 0;
break;
}
asprintf;
strtoq;
getloadavg;
+ ntohll;
+ htonll;
local:
*;
};
struct ast_audiohook_translate {
struct ast_trans_pvt *trans_pvt;
- int format;
+ format_t format;
};
struct ast_audiohook_list {
short buf[samples];
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf,
.datalen = sizeof(buf),
.samples = samples,
short buf1[samples], buf2[samples], *read_buf = NULL, *write_buf = NULL, *final_buf = NULL, *data1 = NULL, *data2 = NULL;
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = NULL,
.datalen = sizeof(buf1),
.samples = samples,
* \param format Format of frame remote side wants back
* \return Returns frame on success, NULL on failure
*/
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format)
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format)
{
struct ast_frame *read_frame = NULL, *final_frame = NULL;
int samples = frame->samples;
/* If the frame coming in is not signed linear we have to send it through the in_translate path */
- if (frame->subclass != AST_FORMAT_SLINEAR) {
- if (in_translate->format != frame->subclass) {
+ if (frame->subclass.codec != AST_FORMAT_SLINEAR) {
+ if (in_translate->format != frame->subclass.codec) {
if (in_translate->trans_pvt)
ast_translator_free_path(in_translate->trans_pvt);
- if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass)))
+ if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass.codec)))
return frame;
- in_translate->format = frame->subclass;
+ in_translate->format = frame->subclass.codec;
}
if (!(middle_frame = ast_translate(in_translate->trans_pvt, frame, 0)))
return frame;
/* Now we figure out what to do with our end frame (whether to transcode or not) */
if (middle_frame == end_frame) {
/* Middle frame was modified and became the end frame... let's see if we need to transcode */
- if (end_frame->subclass != start_frame->subclass) {
- if (out_translate->format != start_frame->subclass) {
+ if (end_frame->subclass.codec != start_frame->subclass.codec) {
+ if (out_translate->format != start_frame->subclass.codec) {
if (out_translate->trans_pvt)
ast_translator_free_path(out_translate->trans_pvt);
- if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass, AST_FORMAT_SLINEAR))) {
+ if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass.codec, AST_FORMAT_SLINEAR))) {
/* We can't transcode this... drop our middle frame and return the original */
ast_frfree(middle_frame);
return start_frame;
}
- out_translate->format = start_frame->subclass;
+ out_translate->format = start_frame->subclass.codec;
}
/* Transcode from our middle (signed linear) frame to new format of the frame that came in */
if (!(end_frame = ast_translate(out_translate->trans_pvt, middle_frame, 0))) {
{
struct ast_frame hangup_frame = {
.frametype = AST_FRAME_CONTROL,
- .subclass = AST_CONTROL_HANGUP,
+ .subclass.integer = AST_CONTROL_HANGUP,
};
for (;;) {
/* See if this DTMF matches the beginnings of any feature hooks, if so we switch to the feature state to either execute the feature or collect more DTMF */
AST_LIST_TRAVERSE(&features->hooks, hook, entry) {
- if (hook->dtmf[0] == frame->subclass) {
+ if (hook->dtmf[0] == frame->subclass.integer) {
ast_frfree(frame);
frame = NULL;
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
struct ast_frame *frame = (((bridge->features.mute) || (bridge_channel->features && bridge_channel->features->mute)) ? ast_read_noaudio(chan) : ast_read(chan));
/* This is pretty simple... see if they hung up */
- if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
+ if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass.integer == AST_CONTROL_HANGUP)) {
/* Signal the thread that is handling the bridged channel that it should be ended */
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
- } else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass)) {
+ } else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass.integer)) {
ast_debug(1, "Dropping control frame from bridge channel %p\n", bridge_channel);
} else {
if (frame->frametype == AST_FRAME_DTMF_BEGIN) {
}
/*! \brief Helper function used to find the "best" bridge technology given a specified capabilities */
-static struct ast_bridge_technology *find_best_technology(int capabilities)
+static struct ast_bridge_technology *find_best_technology(format_t capabilities)
{
struct ast_bridge_technology *current = NULL, *best = NULL;
AST_RWLIST_RDLOCK(&bridge_technologies);
AST_RWLIST_TRAVERSE(&bridge_technologies, current, entry) {
- ast_debug(1, "Bridge technology %s has capabilities %d and we want %d\n", current->name, current->capabilities, capabilities);
+ char tmp1[256], tmp2[256];
+ ast_debug(1, "Bridge technology %s has capabilities %s and we want %s\n", current->name,
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), current->capabilities),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), capabilities));
if (current->suspended) {
ast_debug(1, "Bridge technology %s is suspended. Skipping.\n", current->name);
continue;
return;
}
-struct ast_bridge *ast_bridge_new(int capabilities, int flags)
+struct ast_bridge *ast_bridge_new(format_t capabilities, int flags)
{
struct ast_bridge *bridge = NULL;
struct ast_bridge_technology *bridge_technology = NULL;
/* If no bridge technology was found we can't possibly do bridging so fail creation of the bridge */
if (!bridge_technology) {
- ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %d\n", capabilities);
+ char codec_buf[256];
+ ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %s\n",
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), capabilities));
return NULL;
}
return bridge;
}
-int ast_bridge_check(int capabilities)
+int ast_bridge_check(format_t capabilities)
{
struct ast_bridge_technology *bridge_technology = NULL;
static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
- int formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
+ format_t formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
/* Are the formats currently in use something ths bridge can handle? */
if (!(bridge->technology->formats & bridge_channel->chan->readformat)) {
- int best_format = ast_best_codec(bridge->technology->formats);
+ format_t best_format = ast_best_codec(bridge->technology->formats);
/* Read format is a no go... */
if (option_debug) {
char codec_buf[512];
- ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats);
- ast_debug(1, "Bridge technology %s wants to read any of formats %s(%d) but channel has %s(%d)\n", bridge->technology->name, codec_buf, bridge->technology->formats, ast_getformatname(formats[0]), formats[0]);
+ ast_debug(1, "Bridge technology %s wants to read any of formats %s but channel has %s\n", bridge->technology->name,
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats),
+ ast_getformatname(formats[0]));
}
/* Switch read format to the best one chosen */
if (ast_set_read_format(bridge_channel->chan, best_format)) {
- ast_log(LOG_WARNING, "Failed to set channel %s to read format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_log(LOG_WARNING, "Failed to set channel %s to read format %s\n", bridge_channel->chan->name, ast_getformatname(best_format));
return -1;
}
- ast_debug(1, "Bridge %p put channel %s into read format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_debug(1, "Bridge %p put channel %s into read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format));
} else {
- ast_debug(1, "Bridge %p is happy that channel %s already has read format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[0]), formats[0]);
+ ast_debug(1, "Bridge %p is happy that channel %s already has read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[0]));
}
if (!(bridge->technology->formats & formats[1])) {
/* Write format is a no go... */
if (option_debug) {
char codec_buf[512];
- ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats);
- ast_debug(1, "Bridge technology %s wants to write any of formats %s(%d) but channel has %s(%d)\n", bridge->technology->name, codec_buf, bridge->technology->formats, ast_getformatname(formats[1]), formats[1]);
+ ast_debug(1, "Bridge technology %s wants to write any of formats %s but channel has %s\n", bridge->technology->name,
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats),
+ ast_getformatname(formats[1]));
}
/* Switch write format to the best one chosen */
if (ast_set_write_format(bridge_channel->chan, best_format)) {
- ast_log(LOG_WARNING, "Failed to set channel %s to write format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_log(LOG_WARNING, "Failed to set channel %s to write format %s\n", bridge_channel->chan->name, ast_getformatname(best_format));
return -1;
}
- ast_debug(1, "Bridge %p put channel %s into write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+ ast_debug(1, "Bridge %p put channel %s into write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format));
} else {
- ast_debug(1, "Bridge %p is happy that channel %s already has write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[1]), formats[1]);
+ ast_debug(1, "Bridge %p is happy that channel %s already has write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[1]));
}
return 0;
/*! \brief Perform the smart bridge operation. Basically sees if a new bridge technology should be used instead of the current one. */
static int smart_bridge_operation(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int count)
{
- int new_capabilities = 0;
+ format_t new_capabilities = 0;
struct ast_bridge_technology *new_technology = NULL, *old_technology = bridge->technology;
struct ast_bridge temp_bridge = {
.technology = bridge->technology,
/* Attempt to find a new bridge technology to satisfy the capabilities */
if (!(new_technology = find_best_technology(new_capabilities))) {
- ast_debug(1, "Smart bridge operation was unable to find new bridge technology with capabilities %d to satisfy bridge %p\n", new_capabilities, bridge);
+ char codec_buf[256];
+ ast_debug(1, "Smart bridge operation was unable to find new bridge technology with capabilities %s to satisfy bridge %p\n",
+ ast_getformatname_multiple(codec_buf, sizeof(codec_buf), new_capabilities), bridge);
return -1;
}
static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct chanlist *cl = NULL;
+ char buf[512];
switch (cmd) {
case CLI_INIT:
" Device State: %s\n"
" Indication: %s\n"
" Transfer : %s\n"
- " Capabilities: %d\n"
+ " Capabilities: %s\n"
" Digit Begin: %s\n"
" Digit End: %s\n"
" Send HTML : %s\n"
(cl->tech->devicestate) ? "yes" : "no",
(cl->tech->indicate) ? "yes" : "no",
(cl->tech->transfer) ? "yes" : "no",
- (cl->tech->capabilities) ? cl->tech->capabilities : -1,
+ ast_getformatname_multiple(buf, sizeof(buf), (cl->tech->capabilities) ? cl->tech->capabilities : -1),
(cl->tech->send_digit_begin) ? "yes" : "no",
(cl->tech->send_digit_end) ? "yes" : "no",
(cl->tech->send_html) ? "yes" : "no",
}
/*! \brief Pick the best audio codec */
-int ast_best_codec(int fmts)
+format_t ast_best_codec(format_t fmts)
{
/* This just our opinion, expressed in code. We are asked to choose
the best codec to use, given no information */
int x;
- static const int prefs[] =
+ static const format_t prefs[] =
{
/*! Okay, ulaw is used by all telephony equipment, so start with it */
AST_FORMAT_ULAW,
AST_FORMAT_ALAW,
AST_FORMAT_SIREN14,
AST_FORMAT_SIREN7,
+ AST_FORMAT_TESTLAW,
/*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
AST_FORMAT_G722,
/*! Okay, well, signed linear is easy to translate into other stuff */
/*! Down to G.723.1 which is proprietary but at least designed for voice */
AST_FORMAT_G723_1,
};
+ char buf[512];
/* Strip out video */
fmts &= AST_FORMAT_AUDIO_MASK;
return prefs[x];
}
- ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts);
+ ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
return 0;
}
/* See if the last frame on the queue is a hangup, if so don't queue anything */
if ((cur = AST_LIST_LAST(&chan->readq)) &&
(cur->frametype == AST_FRAME_CONTROL) &&
- (cur->subclass == AST_CONTROL_HANGUP)) {
+ (cur->subclass.integer == AST_CONTROL_HANGUP)) {
ast_channel_unlock(chan);
return 0;
}
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup(struct ast_channel *chan)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
if (cause >= 0)
f.data.uint32 = cause;
/*! \brief Queue a control frame */
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
-
- f.subclass = control;
-
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
return ast_queue_frame(chan, &f);
}
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
const void *data, size_t datalen)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
-
- f.subclass = control;
- f.data.ptr = (void *) data;
- f.datalen = datalen;
-
+ struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
return ast_queue_frame(chan, &f);
}
}
cur = ast_read(chan);
if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
- (cur->subclass == AST_CONTROL_HANGUP))) {
+ (cur->subclass.integer == AST_CONTROL_HANGUP))) {
if (cur) {
ast_frfree(cur);
}
case AST_FRAME_DTMF_BEGIN:
break;
case AST_FRAME_DTMF_END:
- res = f->subclass;
+ res = f->subclass.integer;
ast_frfree(f);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
case AST_FRAME_CONTROL:
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
ast_frfree(f);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
/* Unimportant */
break;
default:
- ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass);
+ ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
break;
}
break;
chan->generatordata = NULL; /* reset, to let writes go through */
- if (f->subclass != chan->writeformat) {
+ if (f->subclass.codec != chan->writeformat) {
float factor;
- factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass));
+ factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass.codec));
samples = (int) ( ((float) f->samples) * factor );
} else {
samples = f->samples;
struct ast_frame *fr = &chan->dtmff;
fr->frametype = AST_FRAME_DTMF_END;
- fr->subclass = f->subclass;
+ fr->subclass.integer = f->subclass.integer;
fr->len = f->len;
/* The only time this function will be called is for a frame that just came
/* Interpret hangup and return NULL */
/* XXX why not the same for frames from the channel ? */
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
cause = f->data.uint32;
ast_frfree(f);
f = NULL;
switch (f->frametype) {
case AST_FRAME_CONTROL:
- if (f->subclass == AST_CONTROL_ANSWER) {
+ if (f->subclass.integer == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
ast_debug(1, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
}
break;
case AST_FRAME_DTMF_END:
- send_dtmf_event(chan, "Received", f->subclass, "No", "Yes");
- ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass, chan->name, f->len);
+ send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes");
+ ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len);
/* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
queue_dtmf_readq(chan, f);
/* There was no begin, turn this into a begin and send the end later */
f->frametype = AST_FRAME_DTMF_BEGIN;
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = f->subclass;
+ chan->emulate_dtmf_digit = f->subclass.integer;
chan->dtmf_tv = ast_tvnow();
if (f->len) {
if (f->len > AST_MIN_DTMF_DURATION)
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
} else
chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
- ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass, chan->emulate_dtmf_duration, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
}
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
} else {
struct timeval now = ast_tvnow();
if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
- ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name);
ast_clear_flag(chan, AST_FLAG_IN_DTMF);
if (!f->len)
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
} else if (!f->len) {
- ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
f->len = AST_MIN_DTMF_DURATION;
}
if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
- ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass, f->len, AST_MIN_DTMF_DURATION, chan->name);
+ ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
- chan->emulate_dtmf_digit = f->subclass;
+ chan->emulate_dtmf_digit = f->subclass.integer;
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
ast_frfree(f);
f = &ast_null_frame;
} else {
- ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
if (f->len < AST_MIN_DTMF_DURATION) {
f->len = AST_MIN_DTMF_DURATION;
}
}
break;
case AST_FRAME_DTMF_BEGIN:
- send_dtmf_event(chan, "Received", f->subclass, "Yes", "No");
- ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass, chan->name);
+ send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
+ ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name);
if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) ||
(!ast_tvzero(chan->dtmf_tv) &&
ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) {
- ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name);
ast_frfree(f);
f = &ast_null_frame;
} else {
ast_set_flag(chan, AST_FLAG_IN_DTMF);
chan->dtmf_tv = ast_tvnow();
- ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name);
}
break;
case AST_FRAME_NULL:
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
- f->subclass = chan->emulate_dtmf_digit;
+ f->subclass.integer = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
- ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
ast_frfree(f);
f = &chan->dtmff;
f->frametype = AST_FRAME_DTMF_END;
- f->subclass = chan->emulate_dtmf_digit;
+ f->subclass.integer = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
if (chan->audiohooks) {
if (old_frame != f)
ast_frfree(old_frame);
}
- ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
+ ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
} else {
/* Drop voice frames while we're still in the middle of the digit */
ast_frfree(f);
f = &ast_null_frame;
}
- } else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass & chan->nativeformats)) {
+ } else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass.codec & chan->nativeformats)) {
/* This frame is not one of the current native formats -- drop it on the floor */
char to[200];
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
- chan->name, ast_getformatname(f->subclass), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
+ chan->name, ast_getformatname(f->subclass.codec), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
done:
if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
- chan->generator->digit(chan, f->subclass);
+ chan->generator->digit(chan, f->subclass.integer);
ast_channel_unlock(chan);
return f;
f = ast_read(chan);
if (f == NULL)
break; /* no frame */
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP)
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP)
done = 1; /* force a break */
else if (f->frametype == AST_FRAME_TEXT) { /* what we want */
buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
ast_debug(1, "Prodding channel '%s'\n", chan->name);
- a.subclass = chan->rawwriteformat;
+ a.subclass.codec = chan->rawwriteformat;
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
if (ast_write(chan, &a))
* stop the generator */
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = ast_senddigit_end(chan, fr->subclass, fr->len);
+ res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
- } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_UNHOLD) {
+ } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
/* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
res = (chan->tech->indicate == NULL) ? 0 :
- chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen);
+ chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
}
res = 0; /* XXX explain, why 0 ? */
goto done;
switch (fr->frametype) {
case AST_FRAME_CONTROL:
res = (chan->tech->indicate == NULL) ? 0 :
- chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen);
+ chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
break;
case AST_FRAME_DTMF_BEGIN:
if (chan->audiohooks) {
if (old_frame != fr)
f = fr;
}
- send_dtmf_event(chan, "Sent", fr->subclass, "Yes", "No");
+ send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No");
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = ast_senddigit_begin(chan, fr->subclass);
+ res = ast_senddigit_begin(chan, fr->subclass.integer);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
ast_frfree(new_frame);
}
}
- send_dtmf_event(chan, "Sent", fr->subclass, "No", "Yes");
+ send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes");
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
- res = ast_senddigit_end(chan, fr->subclass, fr->len);
+ res = ast_senddigit_end(chan, fr->subclass.integer, fr->len);
ast_channel_lock(chan);
CHECK_BLOCKING(chan);
break;
case AST_FRAME_TEXT:
- if (fr->subclass == AST_FORMAT_T140) {
+ if (fr->subclass.integer == AST_FORMAT_T140) {
res = (chan->tech->write_text == NULL) ? 0 :
chan->tech->write_text(chan, fr);
} else {
break;
case AST_FRAME_HTML:
res = (chan->tech->send_html == NULL) ? 0 :
- chan->tech->send_html(chan, fr->subclass, (char *) fr->data.ptr, fr->datalen);
+ chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
break;
case AST_FRAME_VIDEO:
/* XXX Handle translation of video codecs one day XXX */
break; /*! \todo XXX should return 0 maybe ? */
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
- if (fr->subclass == chan->rawwriteformat)
+ if (fr->subclass.codec == chan->rawwriteformat)
f = fr;
else
f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
return res;
}
-static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format,
+static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format,
struct ast_trans_pvt **trans, const int direction)
{
- int native, native_fmt = ast_best_codec(fmt);
+ format_t native, native_fmt = ast_best_codec(fmt);
int res;
char from[200], to[200];
/* See if the underlying channel driver is capable of performing transcoding for us */
if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) {
- ast_debug(1, "Channel driver natively set channel %s to %s format %s (%d)\n", chan->name,
- direction ? "write" : "read", ast_getformatname(native_fmt), native_fmt);
+ ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name,
+ direction ? "write" : "read", ast_getformatname(native_fmt));
chan->nativeformats = *rawformat = *format = native_fmt;
if (*trans) {
ast_translator_free_path(*trans);
return 0;
}
-int ast_set_read_format(struct ast_channel *chan, int fmt)
+int ast_set_read_format(struct ast_channel *chan, format_t fmt)
{
return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
&chan->readtrans, 0);
}
-int ast_set_write_format(struct ast_channel *chan, int fmt)
+int ast_set_write_format(struct ast_channel *chan, format_t fmt)
{
return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
&chan->writetrans, 1);
}
}
-struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate)
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate)
{
char tmpchan[256];
struct ast_channel *new = NULL;
return new;
}
-struct ast_channel *__ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
+struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
{
int dummy_outstate;
int cause = 0;
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_RINGING: /* record but keep going */
- *outstate = f->subclass;
+ *outstate = f->subclass.integer;
break;
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
case AST_CONTROL_ANSWER:
- *outstate = f->subclass;
+ *outstate = f->subclass.integer;
timeout = 0; /* trick to force exit from the while() */
break;
break;
default:
- ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass);
+ ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
}
- last_subclass = f->subclass;
+ last_subclass = f->subclass.integer;
}
ast_frfree(f);
}
return chan;
}
-struct ast_channel *ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
+struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
{
return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL);
}
-struct ast_channel *ast_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause)
+struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
struct chanlist *chan;
struct ast_channel *c;
- int capabilities;
- int fmt;
+ format_t capabilities;
+ format_t fmt;
int res;
int foo;
- int videoformat = format & AST_FORMAT_VIDEO_MASK;
- int textformat = format & AST_FORMAT_TEXT_MASK;
+ format_t videoformat = format & AST_FORMAT_VIDEO_MASK;
+ format_t textformat = format & AST_FORMAT_TEXT_MASK;
if (!cause)
cause = &foo;
*/
res = ast_translator_best_choice(&fmt, &capabilities);
if (res < 0) {
- ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format);
+ char tmp1[256], tmp2[256];
+ ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type,
+ ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities),
+ ast_getformatname_multiple(tmp2, sizeof(tmp2), format));
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
AST_RWLIST_UNLOCK(&backends);
return NULL;
break;
}
- if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_TRANSFER) {
+ if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_TRANSFER) {
enum ast_control_transfer *message = fr->data.ptr;
if (*message == AST_TRANSFER_SUCCESS) {
/*! \brief Set up translation from one channel to another */
static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
{
- int src;
- int dst;
+ format_t src, dst;
/* See if the channel driver can natively make these two channels compatible */
if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
return 0;
if (ast_translator_best_choice(&dst, &src) < 0) {
- ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", from->name, src, to->name, dst);
+ ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name);
return -1;
}
(ast_translate_path_steps(dst, src) != 1))
dst = AST_FORMAT_SLINEAR;
if (ast_set_read_format(from, dst) < 0) {
- ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", from->name, dst);
+ ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(dst));
return -1;
}
if (ast_set_write_format(to, dst) < 0) {
- ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", to->name, dst);
+ ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(dst));
return -1;
}
return 0;
*/
int ast_do_masquerade(struct ast_channel *original)
{
- int x,i;
+ format_t x;
+ int i;
int res=0;
int origstate;
struct ast_frame *current;
} exchange;
struct ast_channel *clonechan;
struct ast_cdr *cdr;
- int rformat = original->readformat;
- int wformat = original->writeformat;
+ format_t rformat = original->readformat;
+ format_t wformat = original->writeformat;
char newn[AST_CHANNEL_NAME];
char orig[AST_CHANNEL_NAME];
char masqn[AST_CHANNEL_NAME];
ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
}
- ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+ ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name,
+ ast_getformatname(wformat), ast_getformatname(rformat));
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
struct ast_channel *cs[3];
struct ast_frame *f;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
- int o0nativeformats;
- int o1nativeformats;
+ format_t o0nativeformats;
+ format_t o1nativeformats;
int watch_c0_dtmf;
int watch_c1_dtmf;
void *pvt0, *pvt1;
if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
int bridge_exit = 0;
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_REDIRECTING:
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
break;
case AST_CONTROL_CONNECTED_LINE:
if (ast_channel_connected_line_macro(who, other, f, other == c0, 1)) {
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
}
break;
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
if (jb_in_use) {
ast_jb_empty_and_reset(c0, c1);
}
*fo = f;
*rc = who;
bridge_exit = 1;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name);
break;
}
if (bridge_exit)
struct ast_channel *who = NULL;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
int nativefailed=0;
- int o0nativeformats;
- int o1nativeformats;
+ format_t o0nativeformats;
+ format_t o1nativeformats;
long time_left_ms=0;
char caller_warning = 0;
char callee_warning = 0;
int v1_2;
int v2_2;
int v3_2;
- int origwfmt;
+ format_t origwfmt;
int pos;
int duration;
int modulate;
ts->data[x] = ts->v3_1 + ts->v3_2;
}
ts->f.frametype = AST_FRAME_VOICE;
- ts->f.subclass = AST_FORMAT_SLINEAR;
+ ts->f.subclass.codec = AST_FORMAT_SLINEAR;
ts->f.datalen = len;
ts->f.samples = samples;
ts->f.offset = AST_FRIENDLY_OFFSET;
short buf[samples];
struct ast_frame frame = {
.frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
+ .subclass.codec = AST_FORMAT_SLINEAR,
.data.ptr = buf,
.samples = samples,
.datalen = sizeof(buf),
static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel, struct ast_frame *fr, struct ast_channel *chan)
{
if (fr->frametype == AST_FRAME_CONTROL) {
- switch (fr->subclass) {
+ switch (fr->subclass.integer) {
case AST_CONTROL_ANSWER:
ast_verb(3, "%s answered %s\n", channel->owner->name, chan->name);
AST_LIST_LOCK(&dial->channels);
if (fr->frametype != AST_FRAME_CONTROL)
return;
- switch (fr->subclass) {
+ switch (fr->subclass.integer) {
case AST_CONTROL_ANSWER:
ast_verb(3, "%s answered\n", channel->owner->name);
AST_LIST_LOCK(&dial->channels);
ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n");
return 0;
}
- if (inf->subclass != AST_FORMAT_SLINEAR) {
+ if (inf->subclass.codec != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n");
return 0;
}
ast_log(LOG_WARNING, "Can't calculate silence on a non-voice frame\n");
return 0;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n");
return 0;
}
ast_log(LOG_WARNING, "Can't calculate noise on a non-voice frame\n");
return 0;
}
- if (f->subclass != AST_FORMAT_SLINEAR) {
+ if (f->subclass.codec != AST_FORMAT_SLINEAR) {
ast_log(LOG_WARNING, "Can only calculate noise on signed-linear frames :(\n");
return 0;
}
odata = af->data.ptr;
len = af->datalen;
/* Make sure we have short data */
- switch (af->subclass) {
+ switch (af->subclass.codec) {
case AST_FORMAT_SLINEAR:
shortdata = af->data.ptr;
len = af->datalen / 2;
break;
case AST_FORMAT_ULAW:
+ case AST_FORMAT_TESTLAW:
shortdata = alloca(af->datalen * 2);
for (x = 0;x < len; x++) {
shortdata[x] = AST_MULAW(odata[x]);
}
break;
default:
- ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass));
+ ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass.codec));
return af;
}
chan->_softhangup |= AST_SOFTHANGUP_DEV;
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
- dsp->f.subclass = AST_CONTROL_BUSY;
+ dsp->f.subclass.integer = AST_CONTROL_BUSY;
ast_frfree(af);
ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
return ast_frisolate(&dsp->f);
if (event) {
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = event;
- dsp->f.subclass = event_digit;
+ dsp->f.subclass.integer = event_digit;
outf = &dsp->f;
goto done;
}
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_DTMF;
- dsp->f.subclass = fax_digit;
+ dsp->f.subclass.integer = fax_digit;
outf = &dsp->f;
goto done;
}
case AST_CONTROL_HANGUP:
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
- dsp->f.subclass = res;
+ dsp->f.subclass.integer = res;
dsp->f.src = "dsp_progress";
if (chan)
ast_queue_frame(chan, &dsp->f);
memset(shortdata + dsp->mute_data[x].start, 0, sizeof(int16_t) * (dsp->mute_data[x].end - dsp->mute_data[x].start));
}
- switch (af->subclass) {
+ switch (af->subclass.codec) {
case AST_FORMAT_SLINEAR:
break;
case AST_FORMAT_ULAW:
}
if (f->frametype == AST_FRAME_CONTROL || f->frametype == AST_FRAME_DTMF || f->frametype == AST_FRAME_TEXT) {
- if (f->subclass == AST_CONTROL_RINGING) {
- state = f->subclass;
+ if (f->subclass.integer == AST_CONTROL_RINGING) {
+ state = f->subclass.integer;
ast_verb(3, "%s is ringing\n", chan->name);
ast_indicate(caller, AST_CONTROL_RINGING);
- } else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
- state = f->subclass;
+ } else if ((f->subclass.integer == AST_CONTROL_BUSY) || (f->subclass.integer == AST_CONTROL_CONGESTION)) {
+ state = f->subclass.integer;
ast_verb(3, "%s is busy\n", chan->name);
ast_indicate(caller, AST_CONTROL_BUSY);
ast_frfree(f);
f = NULL;
break;
- } else if (f->subclass == AST_CONTROL_ANSWER) {
+ } else if (f->subclass.integer == AST_CONTROL_ANSWER) {
/* This is what we are hoping for */
- state = f->subclass;
+ state = f->subclass.integer;
ast_frfree(f);
f = NULL;
ready=1;
break;
- } else if (f->subclass == AST_CONTROL_CONNECTED_LINE) {
+ } else if (f->subclass.integer == AST_CONTROL_CONNECTED_LINE) {
if (ast_channel_connected_line_macro(chan, caller, f, 1, 1)) {
ast_indicate_data(caller, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
}
- } else if (f->subclass != -1 && f->subclass != AST_CONTROL_PROGRESS) {
- ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass);
+ } else if (f->subclass.integer != -1 && f->subclass.integer != AST_CONTROL_PROGRESS) {
+ ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass.integer);
}
/* else who cares */
} else if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
} else {
if (f->frametype == AST_FRAME_DTMF) {
- dialed_code[x++] = f->subclass;
+ dialed_code[x++] = f->subclass.integer;
dialed_code[x] = '\0';
if (strlen(dialed_code) == len) {
x = 0;
}
if (!f || (f->frametype == AST_FRAME_CONTROL &&
- (f->subclass == AST_CONTROL_HANGUP || f->subclass == AST_CONTROL_BUSY ||
- f->subclass == AST_CONTROL_CONGESTION))) {
+ (f->subclass.integer == AST_CONTROL_HANGUP || f->subclass.integer == AST_CONTROL_BUSY ||
+ f->subclass.integer == AST_CONTROL_CONGESTION))) {
res = -1;
break;
}
/* many things should be sent to the 'other' channel */
other = (who == chan) ? peer : chan;
if (f->frametype == AST_FRAME_CONTROL) {
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_RINGING:
case AST_CONTROL_FLASH:
case -1:
- ast_indicate(other, f->subclass);
+ ast_indicate(other, f->subclass.integer);
break;
case AST_CONTROL_CONNECTED_LINE:
if (!ast_channel_connected_line_macro(who, other, f, who != chan, 1)) {
/* The implied "else" falls through purposely */
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
- ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen);
+ ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
break;
case AST_CONTROL_OPTION:
aoh = f->data.ptr;
* not overflowing it.
* \todo XXX how do we guarantee the latter ?
*/
- featurecode[strlen(featurecode)] = f->subclass;
+ featurecode[strlen(featurecode)] = f->subclass.integer;
/* Get rid of the frame before we start doing "stuff" with the channels */
ast_frfree(f);
f = NULL;
/* See if they need servicing */
f = ast_read(pu->chan);
/* Hangup? */
- if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
+ if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) {
if (f)
ast_frfree(f);
post_manager_event("ParkedCallGiveUp", pu);
ast_closestream(tmp->stream);
tmp->stream = NULL;
if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat))
- ast_log(LOG_WARNING, "Unable to restore format back to %d\n", tmp->oldwriteformat);
+ ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(tmp->oldwriteformat));
}
/* Stop the video stream too */
if (tmp->vstream != NULL) {
if (fs->fmt->format & AST_FORMAT_AUDIO_MASK) {
/* This is the audio portion. Call the video one... */
if (!fs->vfs && fs->filename) {
- const char *type = ast_getformatname(f->subclass & ~0x1);
+ const char *type = ast_getformatname(f->subclass.codec & ~0x1);
fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
ast_debug(1, "Opened video output file\n");
}
ast_log(LOG_WARNING, "Tried to write non-voice frame\n");
return -1;
}
- if (((fs->fmt->format | alt) & f->subclass) == f->subclass) {
+ if (((fs->fmt->format | alt) & f->subclass.codec) == f->subclass.codec) {
res = fs->fmt->write(fs, f);
if (res < 0)
ast_log(LOG_WARNING, "Natural write failed\n");
} else {
/* XXX If they try to send us a type of frame that isn't the normal frame, and isn't
the one we've setup a translator for, we do the "wrong thing" XXX */
- if (fs->trans && f->subclass != fs->lastwriteformat) {
+ if (fs->trans && f->subclass.codec != fs->lastwriteformat) {
ast_translator_free_path(fs->trans);
fs->trans = NULL;
}
if (!fs->trans)
- fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass);
+ fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass.codec);
if (!fs->trans)
ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n",
- fs->fmt->name, ast_getformatname(f->subclass));
+ fs->fmt->name, ast_getformatname(f->subclass.codec));
else {
struct ast_frame *trf;
- fs->lastwriteformat = f->subclass;
+ fs->lastwriteformat = f->subclass.codec;
/* Get the translated frame but don't consume the original in case they're using it on another stream */
if ((trf = ast_translate(fs->trans, f, 0))) {
struct ast_frame *cur;
/* As above, but for video. But here we don't have translators
* so we must enforce a format.
*/
- unsigned int format;
+ format_t format;
char *buf;
int buflen;
switch (fr->frametype) {
case AST_FRAME_DTMF_END:
if (context) {
- const char exten[2] = { fr->subclass, '\0' };
+ const char exten[2] = { fr->subclass.integer, '\0' };
if (ast_exists_extension(c, context, exten, 1, c->cid.cid_num)) {
- res = fr->subclass;
+ res = fr->subclass.integer;
ast_frfree(fr);
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
return res;
}
} else {
- res = fr->subclass;
+ res = fr->subclass.integer;
if (strchr(forward, res)) {
int eoftest;
ast_stream_fastforward(c->stream, skip_ms);
}
break;
case AST_FRAME_CONTROL:
- switch (fr->subclass) {
+ switch (fr->subclass.integer) {
case AST_CONTROL_HANGUP:
case AST_CONTROL_BUSY:
case AST_CONTROL_CONGESTION:
/* Unimportant */
break;
default:
- ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass);
+ ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass.integer);
}
break;
case AST_FRAME_VOICE:
struct ast_smoother {
int size;
- int format;
+ format_t format;
int flags;
float samplesperbyte;
unsigned int opt_needs_swap:1;
{ AST_FORMAT_T140, "t140", 0, "Passthrough T.140 Realtime Text" }, /*!< Passthrough support for T.140 Realtime Text */
{ AST_FORMAT_SIREN7, "siren7", 16000, "ITU G.722.1 (Siren7, licensed from Polycom)", 80, 20, 80, 20, 20 }, /*!< Binary commercial distribution */
{ AST_FORMAT_SIREN14, "siren14", 32000, "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)", 120, 20, 80, 20, 20 }, /*!< Binary commercial distribution */
+ { AST_FORMAT_TESTLAW, "testlaw", 8000, "G.711 test-law", 80, 10, 150, 10, 20 }, /*!< codec_ulaw.c */
};
struct ast_frame ast_null_frame = { AST_FRAME_NULL, };
return -1;
}
if (!s->format) {
- s->format = f->subclass;
+ s->format = f->subclass.codec;
s->samplesperbyte = (float)f->samples / (float)f->datalen;
- } else if (s->format != f->subclass) {
- ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass);
+ } else if (s->format != f->subclass.codec) {
+ ast_log(LOG_WARNING, "Smoother was working on %s format frames, now trying to feed %s?\n",
+ ast_getformatname(s->format), ast_getformatname(f->subclass.codec));
return -1;
}
if (s->len + f->datalen > SMOOTHER_SIZE) {
len = s->len;
/* Make frame */
s->f.frametype = AST_FRAME_VOICE;
- s->f.subclass = s->format;
+ s->f.subclass.codec = s->format;
s->f.data.ptr = s->framedata + AST_FRIENDLY_OFFSET;
s->f.offset = AST_FRIENDLY_OFFSET;
s->f.datalen = len;
return NULL;
}
out->frametype = fr->frametype;
- out->subclass = fr->subclass;
+ out->subclass.codec = fr->subclass.codec;
out->datalen = fr->datalen;
out->samples = fr->samples;
out->offset = fr->offset;
}
out->frametype = f->frametype;
- out->subclass = f->subclass;
+ out->subclass.codec = f->subclass.codec;
out->datalen = f->datalen;
out->samples = f->samples;
out->delivery = f->delivery;
return AST_FORMAT_LIST;
}
-char* ast_getformatname(int format)
+char* ast_getformatname(format_t format)
{
int x;
char *ret = "unknown";
return ret;
}
-char *ast_getformatname_multiple(char *buf, size_t size, int format)
+char *ast_getformatname_multiple(char *buf, size_t size, format_t format)
{
int x;
unsigned len;
if (!size)
return buf;
- snprintf(end, size, "0x%x (", format);
+ snprintf(end, size, "0x%llx (", (unsigned long long) format);
len = strlen(end);
end += len;
size -= len;
start = end;
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits & format) {
- snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name);
+ snprintf(end, size, "%s|", AST_FORMAT_LIST[x].name);
len = strlen(end);
end += len;
size -= len;
if (start == end)
ast_copy_string(start, "nothing)", size);
else if (size > 1)
- *(end -1) = ')';
+ *(end - 1) = ')';
return buf;
}
return in;
}
-int ast_getformatbyname(const char *name)
+format_t ast_getformatbyname(const char *name)
{
- int x, all, format = 0;
+ int x, all;
+ format_t format = 0;
all = strcasecmp(name, "all") ? 0 : 1;
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
return format;
}
-char *ast_codec2str(int codec)
+char *ast_codec2str(format_t codec)
{
int x;
char *ret = "unknown";
ast_cli(a->fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC");
ast_cli(a->fd, "--------------------------------------------------------------------------------\n");
- if ((a->argc == 3) || (!strcasecmp(a->argv[3],"audio"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], "audio"))) {
found = 1;
- for (i=0;i<13;i++) {
- snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(a->fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ for (i = 0; i < 48; i++) {
+ if (!((1LL << i) & AST_FORMAT_AUDIO_MASK)) {
+ continue;
+ }
+ snprintf(hex, sizeof(hex), "(0x%Lx)", 1LL << i);
+ ast_cli(a->fd, "%11Lu (1 << %2d) %10s audio %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i));
}
}
- if ((a->argc == 3) || (!strcasecmp(a->argv[3],"image"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], "image"))) {
found = 1;
- for (i=16;i<18;i++) {
- snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(a->fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ for (i = 16; i < 18; i++) {
+ snprintf(hex, sizeof(hex), "(0x%Lx)", 1LL << i);
+ ast_cli(a->fd, "%11Lu (1 << %2d) %10s image %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i));
}
}
- if ((a->argc == 3) || (!strcasecmp(a->argv[3],"video"))) {
+ if ((a->argc == 3) || (!strcasecmp(a->argv[3], "video"))) {
found = 1;
- for (i=18;i<22;i++) {
- snprintf(hex,25,"(0x%x)",1<<i);
- ast_cli(a->fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ for (i = 18; i < 63; i++) {
+ snprintf(hex, sizeof(hex), "(0x%Lx)", 1LL << i);
+ ast_cli(a->fd, "%11Lu (1 << %2d) %10s video %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i));
}
}
static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- int codec, i, found=0;
+ format_t codec;
+ int i, found = 0;
switch (cmd) {
case CLI_INIT:
e->command = "core show codec";
- e->usage =
+ e->usage =
"Usage: core show codec <number>\n"
" Displays codec mapping\n";
return NULL;
if (a->argc != 4)
return CLI_SHOWUSAGE;
- if (sscanf(a->argv[3], "%30d", &codec) != 1)
+ if (sscanf(a->argv[3], "%30Ld", &codec) != 1)
return CLI_SHOWUSAGE;
- for (i = 0; i < 32; i++)
- if (codec & (1 << i)) {
+ for (i = 0; i < 63; i++)
+ if (codec & (1LL << i)) {
found = 1;
- ast_cli(a->fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
+ ast_cli(a->fd, "%11Lu (1 << %2d) %s\n", 1LL << i, i, ast_codec2str(1LL << i));
}
if (!found)
- ast_cli(a->fd, "Codec %d not found\n", codec);
+ ast_cli(a->fd, "Codec %Ld not found\n", codec);
return CLI_SUCCESS;
}
switch(f->frametype) {
case AST_FRAME_DTMF_BEGIN:
strcpy(ftype, "DTMF Begin");
- subclass[0] = f->subclass;
+ subclass[0] = f->subclass.integer;
subclass[1] = '\0';
break;
case AST_FRAME_DTMF_END:
strcpy(ftype, "DTMF End");
- subclass[0] = f->subclass;
+ subclass[0] = f->subclass.integer;
subclass[1] = '\0';
break;
case AST_FRAME_CONTROL:
strcpy(ftype, "Control");
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
strcpy(subclass, "Hangup");
break;
strcpy(subclass, "Stop generators");
break;
default:
- snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass);
+ snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass.integer);
}
break;
case AST_FRAME_NULL:
case AST_FRAME_IAX:
/* Should never happen */
strcpy(ftype, "IAX Specific");
- snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass);
+ snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass.integer);
break;
case AST_FRAME_TEXT:
strcpy(ftype, "Text");
break;
case AST_FRAME_IMAGE:
strcpy(ftype, "Image");
- snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass));
+ snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass.codec));
break;
case AST_FRAME_HTML:
strcpy(ftype, "HTML");
- switch(f->subclass) {
+ switch (f->subclass.integer) {
case AST_HTML_URL:
strcpy(subclass, "URL");
ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo));
strcpy(subclass, "Link Reject");
break;
default:
- snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass);
+ snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass.integer);
break;
}
break;
case AST_FRAME_MODEM:
strcpy(ftype, "Modem");
- switch (f->subclass) {
+ switch (f->subclass.integer) {
case AST_MODEM_T38:
strcpy(subclass, "T.38");
break;
strcpy(subclass, "V.150");
break;
default:
- snprintf(subclass, sizeof(subclass), "Unknown MODEM frame '%d'\n", f->subclass);
+ snprintf(subclass, sizeof(subclass), "Unknown MODEM frame '%d'\n", f->subclass.integer);
break;
}
break;
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
f->frametype,
term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass,
+ f->subclass.integer,
term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)),
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
else
term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)),
f->frametype,
term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)),
- f->subclass,
+ f->subclass.integer,
term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn)));
}
} else {
to = pref->order;
from = buf;
- mem = 32;
+ mem = sizeof(format_t) * 8;
}
memset(to, 0, mem);
- for (x = 0; x < 32 ; x++) {
+ for (x = 0; x < sizeof(format_t) * 8; x++) {
if (!from[x])
break;
to[x] = right ? (from[x] + differential) : (from[x] - differential);
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size)
{
- int x, codec;
+ int x;
+ format_t codec;
size_t total_len, slen;
char *formatname;
- memset(buf,0,size);
+ memset(buf, 0, size);
total_len = size;
buf[0] = '(';
total_len--;
- for(x = 0; x < 32 ; x++) {
+ for (x = 0; x < sizeof(format_t) * 8; x++) {
if (total_len <= 0)
break;
if (!(codec = ast_codec_pref_index(pref,x)))
strncat(buf, formatname, total_len - 1); /* safe */
total_len -= slen;
}
- if (total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) {
+ if (total_len && x < sizeof(format_t) * 8 - 1 && ast_codec_pref_index(pref, x + 1)) {
strncat(buf, "|", total_len - 1); /* safe */
total_len--;
}
return size - total_len;
}
-int ast_codec_pref_index(struct ast_codec_pref *pref, int idx)
+format_t ast_codec_pref_index(struct ast_codec_pref *pref, int idx)
{
int slot = 0;
}
/*! \brief Remove codec from pref list */
-void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
+void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format)
{
struct ast_codec_pref oldorder;
int x, y = 0;
pref->framing[y++] = size;
}
}
-
}
/*! \brief Append codec to list */
-int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
+int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format)
{
int x, newindex = 0;
}
/*! \brief Prepend codec to list */
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing)
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing)
{
int x, newindex = 0;
return;
/* Now find any existing occurrence, or the end */
- for (x = 0; x < 32; x++) {
+ for (x = 0; x < sizeof(format_t) * 8; x++) {
if (!pref->order[x] || pref->order[x] == newindex)
break;
}
}
/*! \brief Set packet size for codec */
-int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems)
{
int x, idx = -1;
}
/*! \brief Get packet size for codec */
-struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format)
+struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format)
{
int x, idx = -1, framems = 0;
struct ast_format_list fmt = { 0, };
}
/*! \brief Pick a codec */
-int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
+format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best)
{
- int x, ret = 0, slot;
+ int x, slot;
+ format_t ret = 0;
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
slot = pref->order[x];
return find_best ? ast_best_codec(formats) : 0;
}
-int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing)
+int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing)
{
- int errors = 0;
+ int errors = 0, framems = 0;
char *parse = NULL, *this = NULL, *psize = NULL;
- int format = 0, framems = 0;
+ format_t format = 0;
parse = ast_strdupa(list);
while ((this = strsep(&parse, ","))) {
int ast_codec_get_samples(struct ast_frame *f)
{
int samples = 0;
+ char tmp[64];
- switch(f->subclass) {
+ switch (f->subclass.codec) {
case AST_FORMAT_SPEEX:
samples = speex_samples(f->data.ptr, f->datalen);
break;
break;
case AST_FORMAT_ULAW:
case AST_FORMAT_ALAW:
+ case AST_FORMAT_TESTLAW:
samples = f->datalen;
break;
case AST_FORMAT_G722:
samples = (int) f->datalen * ((float) 32000 / 6000);
break;
default:
- ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(f->subclass));
+ ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), f->subclass.codec));
}
return samples;
}
-int ast_codec_get_len(int format, int samples)
+int ast_codec_get_len(format_t format, int samples)
{
int len = 0;
break;
case AST_FORMAT_ULAW:
case AST_FORMAT_ALAW:
+ case AST_FORMAT_TESTLAW:
len = samples;
break;
case AST_FORMAT_G722:
short *fdata = f->data.ptr;
short adjust_value = abs(adjustment);
- if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR))
+ if ((f->frametype != AST_FRAME_VOICE) || (f->subclass.codec != AST_FORMAT_SLINEAR))
return -1;
if (!adjustment)
int count;
short *data1, *data2;
- if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass != AST_FORMAT_SLINEAR))
+ if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass.codec != AST_FORMAT_SLINEAR))
return -1;
- if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass != AST_FORMAT_SLINEAR))
+ if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass.codec != AST_FORMAT_SLINEAR))
return -1;
if (f1->samples != f2->samples)
}
ps->f.frametype = AST_FRAME_VOICE;
- ps->f.subclass = AST_FORMAT_SLINEAR;
+ ps->f.subclass.codec = AST_FORMAT_SLINEAR;
ps->f.datalen = len;
ps->f.samples = samples;
ps->f.offset = AST_FRIENDLY_OFFSET;
}
for (feature_code = atxfer_feature->exten; feature_code && *feature_code; ++feature_code) {
- struct ast_frame f = { AST_FRAME_DTMF, *feature_code };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code };
ast_queue_frame(chan, &f);
}
for (feature_code = (char *)exten; feature_code && *feature_code; ++feature_code) {
- struct ast_frame f = { AST_FRAME_DTMF, *feature_code };
+ struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code };
ast_queue_frame(chan, &f);
}
/*! data can contain a channel name, extension number, username, password, etc. */
char data[512];
int timeout;
- int format; /*!< Codecs used for a call */
+ format_t format; /*!< Codecs used for a call */
char app[AST_MAX_APP];
char appdata[AST_MAX_EXTENSION];
char cid_name[AST_MAX_EXTENSION];
int reason = 0;
char tmp[256];
char tmp2[256];
- int format = AST_FORMAT_SLINEAR;
+ format_t format = AST_FORMAT_SLINEAR;
pthread_t th;
if (ast_strlen_zero(name)) {
if (!f)
break;
if (f->frametype == AST_FRAME_CONTROL) {
- if ((f->subclass == AST_CONTROL_BUSY) ||
- (f->subclass == AST_CONTROL_CONGESTION) ) {
+ if ((f->subclass.integer == AST_CONTROL_BUSY) ||
+ (f->subclass.integer == AST_CONTROL_CONGESTION) ) {
ast_frfree(f);
break;
}
return 0; /* success */
}
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
{
struct ast_channel *chan;
struct async_stat *as;
return NULL;
}
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
+int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
{
struct ast_channel *chan;
struct app_tmp *tmp;
return result;
}
-void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astformats, int *nonastformats)
+void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats)
{
int i;
}
}
-int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const int code)
+int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
{
int i;
return -1;
}
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int code, enum ast_rtp_options options)
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options)
{
int i;
return "";
}
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code)
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code)
{
unsigned int i;
return 0;
}
-char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const int capability, const int asterisk_format, enum ast_rtp_options options)
+char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options)
{
- int format, found = 0;
+ format_t format;
+ int found = 0;
if (!buf) {
return NULL;
}
- ast_str_append(&buf, 0, "0x%x (", capability);
+ ast_str_append(&buf, 0, "0x%llx (", (unsigned long long) capability);
for (format = 1; format < AST_RTP_MAX; format <<= 1) {
if (capability & format) {
res = AST_BRIDGE_COMPLETE;
break;
} else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) {
- if ((fr->subclass == AST_CONTROL_HOLD) ||
- (fr->subclass == AST_CONTROL_UNHOLD) ||
- (fr->subclass == AST_CONTROL_VIDUPDATE) ||
- (fr->subclass == AST_CONTROL_SRCUPDATE) ||
- (fr->subclass == AST_CONTROL_T38_PARAMETERS)) {
+ if ((fr->subclass.integer == AST_CONTROL_HOLD) ||
+ (fr->subclass.integer == AST_CONTROL_UNHOLD) ||
+ (fr->subclass.integer == AST_CONTROL_VIDUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_SRCUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS)) {
/* If we are going on hold, then break callback mode and P2P bridging */
- if (fr->subclass == AST_CONTROL_HOLD) {
+ if (fr->subclass.integer == AST_CONTROL_HOLD) {
if (instance0->engine->local_bridge) {
instance0->engine->local_bridge(instance0, NULL);
}
}
instance0->bridged = NULL;
instance1->bridged = NULL;
- } else if (fr->subclass == AST_CONTROL_UNHOLD) {
+ } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) {
if (instance0->engine->local_bridge) {
instance0->engine->local_bridge(instance0, instance1);
}
instance0->bridged = instance1;
instance1->bridged = instance0;
}
- ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen);
+ ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen);
ast_frfree(fr);
} else {
*fo = fr;
*rc = who;
- ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
+ ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name);
res = AST_BRIDGE_COMPLETE;
break;
}
static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct ast_channel *c1, struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1,
struct ast_rtp_instance *vinstance0, struct ast_rtp_instance *vinstance1, struct ast_rtp_instance *tinstance0,
- struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, int codec0, int codec1, int timeoutms,
+ struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, format_t codec0, format_t codec1, int timeoutms,
int flags, struct ast_frame **fo, struct ast_channel **rc, void *pvt0, void *pvt1)
{
enum ast_bridge_result res = AST_BRIDGE_FAILED;
struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, };
- int oldcodec0 = codec0, oldcodec1 = codec1;
+ format_t oldcodec0 = codec0, oldcodec1 = codec1;
struct sockaddr_in ac1 = {0,}, vac1 = {0,}, tac1 = {0,}, ac0 = {0,}, vac0 = {0,}, tac0 = {0,};
struct sockaddr_in t1 = {0,}, vt1 = {0,}, tt1 = {0,}, t0 = {0,}, vt0 = {0,}, tt0 = {0,};
struct ast_frame *fr = NULL;
(vinstance1 && inaddrcmp(&vt1, &vac1)) ||
(tinstance1 && inaddrcmp(&tt1, &tac1)) ||
(codec1 != oldcodec1)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
- c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1);
- ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n",
- c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1);
- ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %d)\n",
- c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), codec1);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), oldcodec1);
+ ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n",
+ c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), ast_getformatname(codec1));
+ ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %s)\n",
+ c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), ast_getformatname(codec1));
+ ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %s)\n",
+ c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), ast_getformatname(codec1));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), ast_getformatname(oldcodec1));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), ast_getformatname(oldcodec1));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), ast_getformatname(oldcodec1));
if (glue0->update_peer(c0, t1.sin_addr.s_addr ? instance1 : NULL, vt1.sin_addr.s_addr ? vinstance1 : NULL, tt1.sin_addr.s_addr ? tinstance1 : NULL, codec1, 0)) {
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
}
(vinstance0 && inaddrcmp(&vt0, &vac0)) ||
(tinstance0 && inaddrcmp(&tt0, &tac0)) ||
(codec0 != oldcodec0)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
- c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0);
- ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n",
- c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
+ ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n",
+ c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), ast_getformatname(codec0));
+ ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
+ c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), ast_getformatname(oldcodec0));
if (glue1->update_peer(c1, t0.sin_addr.s_addr ? instance0 : NULL, vt0.sin_addr.s_addr ? vinstance0 : NULL, tt0.sin_addr.s_addr ? tinstance0 : NULL, codec0, 0)) {
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
}
res = AST_BRIDGE_COMPLETE;
break;
} else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) {
- if ((fr->subclass == AST_CONTROL_HOLD) ||
- (fr->subclass == AST_CONTROL_UNHOLD) ||
- (fr->subclass == AST_CONTROL_VIDUPDATE) ||
- (fr->subclass == AST_CONTROL_SRCUPDATE) ||
- (fr->subclass == AST_CONTROL_T38_PARAMETERS)) {
- if (fr->subclass == AST_CONTROL_HOLD) {
+ if ((fr->subclass.integer == AST_CONTROL_HOLD) ||
+ (fr->subclass.integer == AST_CONTROL_UNHOLD) ||
+ (fr->subclass.integer == AST_CONTROL_VIDUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_SRCUPDATE) ||
+ (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS)) {
+ if (fr->subclass.integer == AST_CONTROL_HOLD) {
/* If we someone went on hold we want the other side to reinvite back to us */
if (who == c0) {
glue1->update_peer(c1, NULL, NULL, NULL, 0, 0);
} else {
glue0->update_peer(c0, NULL, NULL, NULL, 0, 0);
}
- } else if (fr->subclass == AST_CONTROL_UNHOLD) {
+ } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) {
/* If they went off hold they should go back to being direct */
if (who == c0) {
glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0);
if (glue1->get_codec && c1->tech_pvt) {
oldcodec1 = codec1 = glue1->get_codec(c1);
}
- ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen);
+ ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen);
ast_frfree(fr);
} else {
*fo = fr;
*rc = who;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name);
return AST_BRIDGE_COMPLETE;
}
} else {
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_bridge_result res = AST_BRIDGE_FAILED;
- int codec0 = 0, codec1 = 0;
+ format_t codec0 = 0, codec1 = 0;
int unlock_chans = 1;
/* Lock both channels so we can look for the glue that binds them together */
codec0 = glue0->get_codec ? glue0->get_codec(c0) : 0;
codec1 = glue1->get_codec ? glue1->get_codec(c1) : 0;
if (codec0 && codec1 && !(codec0 & codec1)) {
- ast_debug(1, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1);
+ ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n", ast_getformatname(codec0), ast_getformatname(codec1));
res = AST_BRIDGE_FAILED_NOWARN;
goto done;
}
struct ast_rtp_glue *glue0, *glue1;
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
- int codec0 = 0, codec1 = 0;
+ format_t codec0 = 0, codec1 = 0;
int res = 0;
/* Lock both channels so we can look for the glue that binds them together */
struct ast_rtp_glue *glue0, *glue1;
enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
- int codec0 = 0, codec1 = 0;
+ format_t codec0 = 0, codec1 = 0;
int res = 0;
/* If there is no second channel just immediately bail out, we are of no use in that scenario */
}
}
-int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, int format)
+int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format)
{
return instance->engine->set_read_format ? instance->engine->set_read_format(instance, format) : -1;
}
-int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, int format)
+int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format)
{
return instance->engine->set_write_format ? instance->engine->set_write_format(instance, format) : -1;
}
return res;
}
-int ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk)
+format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk)
{
- int formats;
+ format_t formats;
if (instance->engine->available_formats && (formats = instance->engine->available_formats(instance, to_endpoint, to_asterisk))) {
return formats;
return 0;
}
- if (f->subclass != sf->output_format) {
- if (sf->trans && f->subclass != sf->format) {
+ if (f->subclass.codec != sf->output_format) {
+ if (sf->trans && f->subclass.codec != sf->format) {
ast_translator_free_path(sf->trans);
sf->trans = NULL;
}
if (!sf->trans) {
- if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass))) {
- ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass),
+ if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass.codec))) {
+ ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass.codec),
ast_getformatname(sf->output_format));
return 0;
}
- sf->format = f->subclass;
+ sf->format = f->subclass.codec;
}
if (!(begin_frame = ast_translate(sf->trans, f, 0))) {
#endif /* linux */
#endif /* !HAVE_GETLOADAVG */
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return net64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ union {
+ unsigned char c[8];
+ uint64_t u;
+ } number;
+ number.u = net64;
+ return
+ (((uint64_t) number.c[0]) << 0) |
+ (((uint64_t) number.c[1]) << 8) |
+ (((uint64_t) number.c[2]) << 16) |
+ (((uint64_t) number.c[3]) << 24) |
+ (((uint64_t) number.c[4]) << 32) |
+ (((uint64_t) number.c[5]) << 40) |
+ (((uint64_t) number.c[6]) << 48) |
+ (((uint64_t) number.c[7]) << 56);
+#else
+ #error "Unknown byte order"
+#endif
+}
+#endif
+
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return host64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ union {
+ unsigned char c[8];
+ uint64_t u;
+ } number;
+ number.u = host64;
+ return
+ (((uint64_t) number.c[0]) << 0) |
+ (((uint64_t) number.c[1]) << 8) |
+ (((uint64_t) number.c[2]) << 16) |
+ (((uint64_t) number.c[3]) << 24) |
+ (((uint64_t) number.c[4]) << 32) |
+ (((uint64_t) number.c[5]) << 40) |
+ (((uint64_t) number.c[6]) << 48) |
+ (((uint64_t) number.c[7]) << 56);
+#else
+ #error "Unknown byte order"
+#endif
+}
+#endif
+
*/
/*! \brief returns the index of the lowest bit set */
-static force_inline int powerof(unsigned int d)
+static force_inline int powerof(format_t d)
{
- int x = ffs(d);
+ int x = ffsll(d);
if (x)
return x - 1;
- ast_log(LOG_WARNING, "No bits set? %d\n", d);
+ ast_log(LOG_WARNING, "No bits set? %llu\n", (unsigned long long) d);
return -1;
}
}
f->frametype = AST_FRAME_VOICE;
- f->subclass = 1 << (pvt->t->dstfmt);
+ f->subclass.codec = 1LL << (pvt->t->dstfmt);
f->mallocd = 0;
f->offset = AST_FRIENDLY_OFFSET;
f->src = pvt->t->name;
}
/*! \brief Build a chain of translators based upon the given source and dest formats */
-struct ast_trans_pvt *ast_translator_build_path(int dest, int source)
+struct ast_trans_pvt *ast_translator_build_path(format_t dest, format_t source)
{
struct ast_trans_pvt *head = NULL, *tail = NULL;
return NULL;
}
if (!(cur = newpvt(t))) {
- ast_log(LOG_WARNING, "Failed to build translator step from %d to %d\n", source, dest);
+ ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n",
+ ast_getformatname(source), ast_getformatname(dest));
if (head)
ast_translator_free_path(head);
AST_RWLIST_UNLOCK(&translators);
path->nextout = f->delivery;
}
/* Predict next incoming sample */
- path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass)));
+ path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass.codec)));
}
delivery = f->delivery;
for ( ; out && p ; p = p->next) {
/* Predict next outgoing timestamp from samples in this
frame. */
- path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass)));
+ path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass.codec)));
} else {
out->delivery = ast_tv(0, 0);
ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);
tr_matrix[x][z].cost = newcost;
tr_matrix[x][z].multistep = 1;
ast_debug(3, "Discovered %d cost path from %s to %s, via %s\n", tr_matrix[x][z].cost,
- ast_getformatname(1 << x), ast_getformatname(1 << z), ast_getformatname(1 << y));
+ ast_getformatname(1LL << x), ast_getformatname(1LL << z), ast_getformatname(1LL << y));
changed++;
}
}
ast_cli(a->fd, " Source Format (Rows) Destination Format (Columns)\n\n");
/* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */
for (x = 0; x < SHOW_TRANS; x++) {
- curlen = strlen(ast_getformatname(1 << (x)));
+ curlen = strlen(ast_getformatname(1LL << (x)));
if (curlen > longest)
longest = curlen;
for (y = 0; y < SHOW_TRANS; y++) {
for (x = -1; x < SHOW_TRANS; x++) {
struct ast_str *out = ast_str_alloca(125);
/*Go ahead and move to next iteration if dealing with an unknown codec*/
- if(x >= 0 && !strcmp(ast_getformatname(1 << (x)), "unknown"))
+ if(x >= 0 && !strcmp(ast_getformatname(1LL << (x)), "unknown"))
continue;
ast_str_set(&out, -1, " ");
for (y = -1; y < SHOW_TRANS; y++) {
/*Go ahead and move to next iteration if dealing with an unknown codec*/
- if (y >= 0 && !strcmp(ast_getformatname(1 << (y)), "unknown"))
+ if (y >= 0 && !strcmp(ast_getformatname(1LL << (y)), "unknown"))
continue;
if (y >= 0)
- curlen = strlen(ast_getformatname(1 << (y)));
+ curlen = strlen(ast_getformatname(1LL << (y)));
if (y >= 0 && magnitude[y] + 1 > curlen) {
curlen = magnitude[y] + 1;
}
ast_str_append(&out, -1, "%*d", curlen + 1, tr_matrix[x][y].cost);
} else if (x == -1 && y >= 0) {
/* Top row - use a dynamic size */
- ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(1 << (y)) );
+ ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(1LL << (y)) );
} else if (y == -1 && x >= 0) {
/* Left column - use a static size. */
- ast_str_append(&out, -1, "%*s", longest, ast_getformatname(1 << (x)) );
+ ast_str_append(&out, -1, "%*s", longest, ast_getformatname(1LL << (x)) );
} else if (x >= 0 && y >= 0) {
/* Codec not supported */
ast_str_append(&out, -1, "%*s", curlen + 1, "-");
return -1;
}
if (t->dstfmt != powerof(AST_FORMAT_SLINEAR))
- ast_log(LOG_WARNING, "plc_samples %d format %x\n",
- t->plc_samples, t->dstfmt);
+ ast_log(LOG_WARNING, "plc_samples %d format %llx\n",
+ t->plc_samples, (unsigned long long) t->dstfmt);
}
if (t->srcfmt >= MAX_FORMAT) {
ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
ast_verb(2, "Registered translator '%s' from format %s to %s, cost %d\n",
term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
- ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost);
+ ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt), t->cost);
if (!added_cli) {
ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate));
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
if (u == t) {
AST_RWLIST_REMOVE_CURRENT(list);
- ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt));
+ ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt));
found = 1;
break;
}
}
/*! \brief Calculate our best translator source format, given costs, and a desired destination */
-int ast_translator_best_choice(int *dst, int *srcs)
+format_t ast_translator_best_choice(format_t *dst, format_t *srcs)
{
int x,y;
- int best = -1;
- int bestdst = 0;
- int cur, cursrc;
+ format_t best = -1;
+ format_t bestdst = 0;
+ format_t cur, cursrc;
int besttime = INT_MAX;
int beststeps = INT_MAX;
- int common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */
+ format_t common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */
if (common) { /* yes, pick one and return */
for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) {
}
}
-unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
+unsigned int ast_translate_path_steps(format_t dest, format_t src)
{
unsigned int res = -1;
return res;
}
-unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src)
+format_t ast_translate_available_formats(format_t dest, format_t src)
{
- unsigned int res = dest;
- unsigned int x;
- unsigned int src_audio = src & AST_FORMAT_AUDIO_MASK;
- unsigned int src_video = src & AST_FORMAT_VIDEO_MASK;
+ format_t res = dest;
+ format_t x;
+ format_t src_audio = src & AST_FORMAT_AUDIO_MASK;
+ format_t src_video = src & AST_FORMAT_VIDEO_MASK;
/* if we don't have a source format, we just have to try all
possible destination formats */
known audio formats to determine whether there exists
a translation path from the source format to the
destination format. */
- for (x = 1; src_audio && (x & AST_FORMAT_AUDIO_MASK); x <<= 1) {
+ for (x = 1LL; src_audio && x > 0; x <<= 1) {
+ if (!(x & AST_FORMAT_AUDIO_MASK)) {
+ continue;
+ }
+
/* if this is not a desired format, nothing to do */
if (!(dest & x))
continue;
known video formats to determine whether there exists
a translation path from the source format to the
destination format. */
- for (; src_video && (x & AST_FORMAT_VIDEO_MASK); x <<= 1) {
+ for (x = 1LL; src_video && x > 0; x <<= 1) {
+ if (!(x & AST_FORMAT_VIDEO_MASK)) {
+ continue;
+ }
+
/* if this is not a desired format, nothing to do */
if (!(dest & x))
continue;
/* Decode the secondary IFP packet */
//fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]);
s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
+ s->f[ifp_no].subclass.codec = AST_MODEM_T38;
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = seq_no - i;
if (repaired[l]) {
//fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
+ s->f[ifp_no].subclass.codec = AST_MODEM_T38;
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = j;
if (seq_no >= s->rx_seq_no) {
/* Decode the primary IFP packet */
s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
+ s->f[ifp_no].subclass.codec = AST_MODEM_T38;
s->f[ifp_no].mallocd = 0;
s->f[ifp_no].seqno = seq_no;
return 0;
if ((f->frametype != AST_FRAME_MODEM) ||
- (f->subclass != AST_MODEM_T38)) {
+ (f->subclass.codec != AST_MODEM_T38)) {
ast_log(LOG_WARNING, "UDPTL can only send T.38 data.\n");
return -1;
}
int retrytime; /*!< How long to wait between retries (in seconds) */
int waittime; /*!< How long to wait for an answer */
long callingpid; /*!< PID which is currently calling */
- int format; /*!< Formats (codecs) for this call */
+ format_t format; /*!< Formats (codecs) for this call */
AST_DECLARE_STRING_FIELDS (
AST_STRING_FIELD(fn); /*!< File name of call file */
AST_STRING_FIELD(tech); /*!< Which channel technology to use for outgoing call */
else
*remain = *remain - amt;
outf.frametype = AST_FRAME_VOICE;
- outf.subclass = AST_FORMAT_ULAW;
+ outf.subclass.codec = AST_FORMAT_ULAW;
outf.data.ptr = buf;
outf.datalen = amt;
outf.samples = amt;
continue;
}
- if (inf->subclass != AST_FORMAT_ULAW) {
+ if (inf->subclass.codec != AST_FORMAT_ULAW) {
ast_log(LOG_WARNING, "Channel not in ulaw?\n");
ast_frfree(inf);
return -1;
else if (remain)
*remain = inf->datalen - amt;
outf.frametype = AST_FRAME_VOICE;
- outf.subclass = AST_FORMAT_ULAW;
+ outf.subclass.codec = AST_FORMAT_ULAW;
outf.data.ptr = buf;
outf.datalen = amt;
outf.samples = amt;
return -1;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (f->subclass == 'A') {
+ if (f->subclass.integer == 'A') {
/* Okay, this is an ADSI CPE. Note this for future reference, too */
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_AVAILABLE;
break;
} else {
- if (f->subclass == 'D')
+ if (f->subclass.integer == 'D')
ast_debug(1, "Off-hook capable CPE only, not ADSI\n");
else
- ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass);
+ ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass.integer);
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_UNAVAILABLE;
errno = ENOSYS;
}
/* is there any other frame we should care about
besides AST_CONTROL_HANGUP? */
- if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
ast_log(LOG_DEBUG, "Got HANGUP frame on channel %s, going out ...\n", chan->name);
ast_frfree(f);
break;
}
switch(f->frametype) {
case AST_FRAME_DTMF:
- if (strchr(argv[4], f->subclass)) {
+ if (strchr(argv[4], f->subclass.integer)) {
/* This is an interrupting chracter, so rewind to chop off any small
amount of DTMF that may have been recorded
*/
ast_stream_rewind(fs, 200);
ast_truncstream(fs);
sample_offset = ast_tellstream(fs);
- ast_agi_send(agi->fd, chan, "200 result=%d (dtmf) endpos=%ld\n", f->subclass, sample_offset);
+ ast_agi_send(agi->fd, chan, "200 result=%d (dtmf) endpos=%ld\n", f->subclass.integer, sample_offset);
ast_closestream(fs);
ast_frfree(f);
if (sildet)
if (fr) {
if (fr->frametype == AST_FRAME_DTMF) {
reason = "dtmf";
- dtmf = fr->subclass;
- } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_HANGUP) {
+ dtmf = fr->subclass.integer;
+ } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_HANGUP) {
reason = "hangup";
}
ast_frfree(fr);
struct moh_files_state {
struct mohclass *class;
- int origwfmt;
+ format_t origwfmt;
int samples;
int sample_queue;
int pos;
int total_files;
unsigned int flags;
/*! The format from the MOH source, not applicable to "files" mode */
- int format;
+ format_t format;
/*! The pid of the external application delivering MOH */
int pid;
time_t start;
struct mohdata {
int pipe[2];
- int origwfmt;
+ format_t origwfmt;
struct mohclass *parent;
struct ast_frame f;
AST_LIST_ENTRY(mohdata) list;
}
if (state->origwfmt && ast_set_write_format(chan, state->origwfmt)) {
- ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt);
+ ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%s'\n", chan->name, ast_getformatname(state->origwfmt));
}
state->save_pos = state->pos;
fcntl(moh->pipe[1], F_SETFL, flags | O_NONBLOCK);
moh->f.frametype = AST_FRAME_VOICE;
- moh->f.subclass = cl->format;
+ moh->f.subclass.codec = cl->format;
moh->f.offset = AST_FRIENDLY_OFFSET;
moh->parent = mohclass_ref(cl, "Reffing music class for mohdata parent");
{
struct mohdata *moh = data;
struct mohclass *class = moh->parent;
- int oldwfmt;
+ format_t oldwfmt;
ao2_lock(class);
AST_LIST_REMOVE(&moh->parent->members, moh, list);
return 1;
}
-static int rtp_get_rate(int subclass)
+static int rtp_get_rate(format_t subclass)
{
return (subclass == AST_FORMAT_G722) ? 8000 : ast_format_rate(subclass);
}
int pred, mark = 0;
unsigned int ms = calc_txstamp(rtp, &frame->delivery);
struct sockaddr_in remote_address = { 0, };
- int rate = rtp_get_rate(frame->subclass) / 1000;
+ int rate = rtp_get_rate(frame->subclass.codec) / 1000;
- if (frame->subclass == AST_FORMAT_G722) {
+ if (frame->subclass.codec == AST_FORMAT_G722) {
frame->samples /= 2;
}
}
}
} else if (frame->frametype == AST_FRAME_VIDEO) {
- mark = frame->subclass & 0x1;
+ mark = frame->subclass.codec & 0x1;
pred = rtp->lastovidtimestamp + frame->samples;
/* Re-calculate last TS */
rtp->lastts = rtp->lastts + ms * 90;
{
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
struct sockaddr_in remote_address = { 0, };
- int codec, subclass;
+ format_t codec, subclass;
ast_rtp_instance_get_remote_address(instance, &remote_address);
}
/* Grab the subclass and look up the payload we are going to use */
- subclass = frame->subclass;
+ subclass = frame->subclass.codec;
if (frame->frametype == AST_FRAME_VIDEO) {
subclass &= ~0x1;
}
if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, subclass)) < 0) {
- ast_log(LOG_WARNING, "Don't know how to send format %s packets with RTP\n", ast_getformatname(frame->subclass));
+ ast_log(LOG_WARNING, "Don't know how to send format %s packets with RTP\n", ast_getformatname(frame->subclass.codec));
return -1;
}
default:
if (fmt.inc_ms) {
if (!(rtp->smoother = ast_smoother_new((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms))) {
- ast_log(LOG_WARNING, "Unable to create smoother: format %d ms: %d len: %d\n", subclass, fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
+ ast_log(LOG_WARNING, "Unable to create smoother: format %s ms: %d len: %d\n", ast_getformatname(subclass), fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
return -1;
}
if (fmt.flags) {
ast_smoother_set_flags(rtp->smoother, fmt.flags);
}
- ast_debug(1, "Created smoother: format: %d ms: %d len: %d\n", subclass, fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
+ ast_debug(1, "Created smoother: format: %s ms: %d len: %d\n", ast_getformatname(subclass), fmt.cur_ms, ((fmt.cur_ms * fmt.fr_len) / fmt.inc_ms));
}
}
}
double d;
double dtv;
double prog;
- int rate = rtp_get_rate(rtp->f.subclass);
+ int rate = rtp_get_rate(rtp->f.subclass.codec);
double normdev_rxjitter_current;
if ((!rtp->rxcore.tv_sec && !rtp->rxcore.tv_usec) || mark) {
ast_debug(1, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(remote_address.sin_addr));
if (rtp->resp == 'X') {
rtp->f.frametype = AST_FRAME_CONTROL;
- rtp->f.subclass = AST_CONTROL_FLASH;
+ rtp->f.subclass.integer = AST_CONTROL_FLASH;
} else {
rtp->f.frametype = type;
- rtp->f.subclass = rtp->resp;
+ rtp->f.subclass.integer = rtp->resp;
}
rtp->f.datalen = 0;
rtp->f.samples = 0;
if ((rtp->lastevent != seqno) && rtp->resp) {
rtp->dtmf_duration = new_duration;
f = send_dtmf(instance, AST_FRAME_DTMF_END, 0);
- f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
+ f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass.codec)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_duration = rtp->dtmf_timeout = 0;
}
if (rtp->resp && rtp->resp != resp) {
/* Another digit already began. End it */
f = send_dtmf(instance, AST_FRAME_DTMF_END, 0);
- f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
+ f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass.codec)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_duration = rtp->dtmf_timeout = 0;
}
}
} else if ((rtp->resp == resp) && !power) {
f = send_dtmf(instance, AST_FRAME_DTMF_END, ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_DTMF_COMPENSATE));
- f->samples = rtp->dtmfsamples * (rtp_get_rate(f->subclass) / 1000);
+ f->samples = rtp->dtmfsamples * (rtp_get_rate(f->subclass.codec) / 1000);
rtp->resp = 0;
} else if (rtp->resp == resp)
- rtp->dtmfsamples += 20 * (rtp_get_rate(f->subclass) / 1000);
+ rtp->dtmfsamples += 20 * (rtp_get_rate(f->subclass.codec) / 1000);
rtp->dtmf_timeout = 0;
return f;
rtp->f.datalen = 0;
}
rtp->f.frametype = AST_FRAME_CNG;
- rtp->f.subclass = data[0] & 0x7f;
+ rtp->f.subclass.integer = data[0] & 0x7f;
rtp->f.datalen = len - 1;
rtp->f.samples = 0;
rtp->f.delivery.tv_usec = rtp->f.delivery.tv_sec = 0;
if (rtcp_debug_test_addr(&sin))
ast_verbose("Received an RTCP Fast Update Request\n");
rtp->f.frametype = AST_FRAME_CONTROL;
- rtp->f.subclass = AST_CONTROL_VIDUPDATE;
+ rtp->f.subclass.integer = AST_CONTROL_VIDUPDATE;
rtp->f.datalen = 0;
rtp->f.samples = 0;
rtp->f.mallocd = 0;
return f ? f : &ast_null_frame;
}
- rtp->lastrxformat = rtp->f.subclass = payload.code;
- rtp->f.frametype = (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
+ rtp->lastrxformat = rtp->f.subclass.codec = payload.code;
+ rtp->f.frametype = (rtp->f.subclass.codec & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass.codec & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
rtp->rxseqno = seqno;
if (rtp->resp) {
struct ast_frame *f;
f = send_dtmf(instance, AST_FRAME_DTMF_END, 0);
- f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
+ f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass.codec)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_timeout = rtp->dtmf_duration = 0;
return f;
rtp->f.offset = hdrlen + AST_FRIENDLY_OFFSET;
rtp->f.seqno = seqno;
- if (rtp->f.subclass == AST_FORMAT_T140 && (int)seqno - (prev_seqno+1) > 0 && (int)seqno - (prev_seqno+1) < 10) {
+ if (rtp->f.subclass.codec == AST_FORMAT_T140 && (int)seqno - (prev_seqno+1) > 0 && (int)seqno - (prev_seqno+1) < 10) {
unsigned char *data = rtp->f.data.ptr;
memmove(rtp->f.data.ptr+3, rtp->f.data.ptr, rtp->f.datalen);
*data = 0xBD;
}
- if (rtp->f.subclass == AST_FORMAT_T140RED) {
+ if (rtp->f.subclass.codec == AST_FORMAT_T140RED) {
unsigned char *data = rtp->f.data.ptr;
unsigned char *header_end;
int num_generations;
int diff =(int)seqno - (prev_seqno+1); /* if diff = 0, no drop*/
int x;
- rtp->f.subclass = AST_FORMAT_T140;
+ rtp->f.subclass.codec = AST_FORMAT_T140;
header_end = memchr(data, ((*data) & 0x7f), rtp->f.datalen);
if (header_end == NULL) {
return &ast_null_frame;
}
}
- if (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) {
+ if (rtp->f.subclass.codec & AST_FORMAT_AUDIO_MASK) {
rtp->f.samples = ast_codec_get_samples(&rtp->f);
- if (rtp->f.subclass == AST_FORMAT_SLINEAR)
+ if (rtp->f.subclass.codec == AST_FORMAT_SLINEAR)
ast_frame_byteswap_be(&rtp->f);
calc_rxstamp(&rtp->f.delivery, rtp, timestamp, mark);
/* Add timing data to let ast_generic_bridge() put the frame into a jitterbuf */
ast_set_flag(&rtp->f, AST_FRFLAG_HAS_TIMING_INFO);
- rtp->f.ts = timestamp / (rtp_get_rate(rtp->f.subclass) / 1000);
- rtp->f.len = rtp->f.samples / ((ast_format_rate(rtp->f.subclass) / 1000));
- } else if (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) {
+ rtp->f.ts = timestamp / (rtp_get_rate(rtp->f.subclass.codec) / 1000);
+ rtp->f.len = rtp->f.samples / ((ast_format_rate(rtp->f.subclass.codec) / 1000));
+ } else if (rtp->f.subclass.codec & AST_FORMAT_VIDEO_MASK) {
/* Video -- samples is # of samples vs. 90000 */
if (!rtp->lastividtimestamp)
rtp->lastividtimestamp = timestamp;
* involved here since we deal with video.
*/
if (mark)
- rtp->f.subclass |= 0x1;
+ rtp->f.subclass.codec |= 0x1;
} else {
/* TEXT -- samples is # of samples vs. 1000 */
if (!rtp->lastitexttimestamp)
}
rtp->red->t140.frametype = AST_FRAME_TEXT;
- rtp->red->t140.subclass = AST_FORMAT_T140RED;
+ rtp->red->t140.subclass.codec = AST_FORMAT_T140RED;
rtp->red->t140.data.ptr = &rtp->red->buf_data;
rtp->red->t140.ts = 0;
}
/* Grab the actual payload number for when we create the RTP packet */
- if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, frame->subclass)) < 0) {
+ if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, frame->subclass.codec)) < 0) {
return -1;
}